-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample2.py
executable file
·44 lines (36 loc) · 947 Bytes
/
sample2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os, sys
from stat import *
def reverse(path):
s = ""
for i in path:
s = i + s
return s
""" def getNextdir(fullS):
nextDir = fullS.split("/")[-1]
for f in os.listdir(): """
def filterFullpath(fullS):
i = len(fullS)-1
while (i > -1):
if (fullS[i] == "/"):
return fullS[:i+1]
i = i-1
return None
def getRestPath(givenP,fullS):
fullS = fullS + "*"
result = givenP.split(fullS)[1]
return result
def stringUptoStar(path):
result = ""
i = 0
while (path[i] != "*"):
result = result + path[i]
i = i+1
return result
def main():
givenPath = "/media/abc/def/dp*/jmt/li*"
fullstring = stringUptoStar(givenPath)
givenPath = getRestPath(givenPath,fullstring)
fullPath = filterFullpath(fullstring)
#fullPath = getNextdir(fullstring)
if __name__ == "__main__":
main()