-
Notifications
You must be signed in to change notification settings - Fork 0
/
v.py
77 lines (65 loc) · 2.11 KB
/
v.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- coding: utf-8 -*-
"""
Print all py source codes and versions
"""
import os
import re
from collections import defaultdict
__version__ = '1.0.21'
re_vnr = re.compile('(\d{1,3}\.\d{1,3}\.\d{1,3})')
re_version = re.compile('(?i)version')
re_ftype = re.compile('(\.\w+)$')
include_ftypes = ['.py', '.json', '.html', '.sh']
def get_allfiles(path, extension=''):
'''get all files'''
allfiles = list()
for dirpath, dirnames, filenames in os.walk(path):
files = [file for file in filenames if file.endswith(extension)]
allfiles.extend([os.path.join(dirpath, file) for file in files])
allfiles.sort()
return allfiles
def get_ftype(fname):
'''Return file type'''
try:
return re.search(re_ftype, fname).group()
except AttributeError:
return ''
return
def check_file(ffname) -> str:
'''Open file and read version'''
txt, res = None, None
with open(ffname, 'rb') as file:
for line in file:
try: