blob: 8dbe75cba09d2da115ff28833374731468c2e5c6 (
plain)
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
|
import filecmp, os, re, shutil
# source_files_list --
# Return a list of the source file names in filelist.
def source_files_list():
list=[]
file_re = re.compile(r'^(\w|/)+/((\w|.)+)')
for line in open('filelist', 'r'):
if file_re.match(line):
list.append(file_re.match(line).group(2))
return sorted(list)
# source_files --
# Print a list of the source file names in filelist.
def source_files():
for line in source_files_list():
print(line)
# source_paths_list --
# Return a list of the source file paths in filelist.
def source_paths_list():
list=[]
file_re = re.compile(r'^\w')
for line in open('filelist', 'r'):
if file_re.match(line):
list.append(line.rstrip())
return sorted(list)
# source_paths --
# Print a list of the source file paths in filelist.
def source_paths():
for line in source_paths_list():
print(line)
# directory_files_list --
# Return a list of the directories in filelist.
def directory_files_list():
dirs = {}
dir_re = re.compile(r'^((\w|/)+/)')
for line in open('filelist', 'r'):
if dir_re.match(line):
dirs[dir_re.match(line).group(1)] = 1
return sorted(dirs)
# directory_files --
# Print a list of the directories in filelist.
def directory_files():
for entry in directory_files_list():
print(entry)
# compare_srcfile --
# Compare two files, and if they differ, update the source file.
def compare_srcfile(tmp, src):
if not os.path.isfile(src) or \
not filecmp.cmp(tmp, src, False):
print('Updating ' + src)
shutil.copyfile(tmp, src)
os.remove(tmp)
|