-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrent.py
More file actions
32 lines (26 loc) · 826 Bytes
/
current.py
File metadata and controls
32 lines (26 loc) · 826 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
26
27
28
29
30
31
32
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
def main(root):
path = find_and_create_path(root)
pathLog = 'Run python file: \033[32m%s\033[0m' % (path)
divLen = (len(pathLog) - 9)
print(pathLog)
print('-' * divLen)
os.system('python3 %s' % (path))
print('-' * divLen)
def find_and_create_path(root):
if is_python_file(root):
return root
file_list = filter(is_ignored, sorted(os.listdir(root)))
path = root + '/' + list(file_list)[-1]
return find_and_create_path(path)
def is_ignored(filename):
# ignore_list = ['.DS_Store']
# for _filename in ignore_list:
# return not _filename.lower() in filename.lower()
return filename[:2].isdigit()
def is_python_file(filename):
return filename[-2:] == 'py'
basic_root = 'Basic'
main(basic_root)