forked from linpeng109/py_metasploit_20200409
-
Notifications
You must be signed in to change notification settings - Fork 0
/
py_path.py
62 lines (52 loc) · 1.86 KB
/
py_path.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import os.path
import sys
import pkgutil
class Path():
@classmethod
def splitFullPathFileName(self, fullPathFileName):
fullPathFileName = fullPathFileName.lower()
driver = os.path.splitdrive(fullPathFileName)[0]
path = os.path.split(fullPathFileName)[0]
filename = os.path.split(fullPathFileName)[1]
ext = os.path.splitext(fullPathFileName)[1]
main = filename.strip(ext)
sep = os.sep
return {'driver': driver, 'sep': sep, 'path': path, 'filename': filename, 'main': main, 'ext': ext}
@classmethod
def filenameIsContains(self, fullPathFileName: str, strs):
filename = Path.splitFullPathFileName(fullPathFileName).get('filename').lower()
result = True
for str in strs:
result = filename.__contains__(str.lower()) and result
return result
@classmethod
def outpathIsExist(self, outputPath):
isExist = os.path.isdir(outputPath)
if not isExist:
os.makedirs(outputPath)
print('The Path is not exist. Created (%s).' % outputPath)
@classmethod
def resource_path(self, relative_path: str):
if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS
else:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
@classmethod
def get_base_path(self):
return os.path.abspath('.')
@classmethod
def join(self, p1, p2):
return os.path.join(p1, p2)
if __name__ == '__main__':
# fullname = '/home/pi/Shared/AFS-8510.xlsx'
# result1 = splitFullPathFileName(fullname)
# print(result1)
# result = filenameIsContains(fullname, ['AFS', 'xlsx'])
# print(result)
# Path.outpathIsExist('e:/watchdogdir/aass')
path = Path()
p1 = path.get_base_path()
p2 = 'sclScript'
print(path.join(p1,p2))