-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseinput.py
More file actions
25 lines (18 loc) · 888 Bytes
/
parseinput.py
File metadata and controls
25 lines (18 loc) · 888 Bytes
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
# When using PyQt GUI
# def browse_dir(self):
# self.analytic_dir = QtGui.QFileDialog.getExistingDirectory(self, 'Open File', '/')
# self.lineEdit.setText(self.analytic_dir)
# def func_analytics(self):
# inputstream = str(self.lineEdit.text())
inputstream = "/home/ahmad/somerandomplace/file.jpg"
if os.path.isfile(inputstream) and inputstream.lower().endswith(('.png', '.jpg', '.jpeg')):
print("Its an image")
elif os.path.isdir(inputstream):
print("Its a dir")
files = [item for sublist in [glob.glob(inputstream + ext) for ext in ["/*.png", "/*.jpg", "/*.JPG", "/*.PNG"]] for item in sublist]
for everyfile in files:
print(everyfile)
elif os.path.isfile(inputstream) and inputstream.lower().endswith(('.mp4', '.avi'))::
print("Its a video..")
else:
print("What are you trying to run ?!")