|
4 | 4 | This script reads list of glob patterns from files, specified in the |
5 | 5 | command-line and generates lists of files for each pattern |
6 | 6 | """ |
7 | | -import sys,fnmatch, os, os.path |
| 7 | +from __future__ import print_function |
| 8 | +import sys |
| 9 | +import fnmatch |
| 10 | +import os |
| 11 | +import os.path |
8 | 12 |
|
| 13 | +#pylint: disable=invalid-name |
9 | 14 | filelist_name = sys.argv.pop(1) |
10 | 15 | if os.path.isdir(filelist_name): |
11 | 16 | # Generate filelist ourselves |
12 | 17 | pwd = os.getcwd() |
13 | 18 | os.chdir(filelist_name) |
14 | | - filelist=set() |
15 | | - for dirname,subdirlist,files in os.walk("."): |
16 | | - dirname = dirname.replace("\\","/") |
| 19 | + filelist = set() |
| 20 | + for dirname, subdirlist, files in os.walk("."): |
| 21 | + dirname = dirname.replace("\\", "/") |
17 | 22 | for f in files: |
18 | | - filelist.add(dirname+"/"+f) |
| 23 | + filelist.add(dirname + "/" + f) |
19 | 24 | os.chdir(pwd) |
20 | 25 | else: |
21 | | - with open(filelist_name,"r") as f: |
22 | | - filelist = set(map(lambda x:x.strip(),f.readlines())) |
23 | | - |
24 | | -for module in sys.argv[1:]: |
25 | | - modname = module[:module.find(".")] |
26 | | - print >> sys.stderr,"Processing module ",modname |
27 | | - with open(module,"r") as f: |
28 | | - patterns = map(lambda x:x.strip(),f.readlines()) |
29 | | - for p in patterns: |
30 | | - if p.startswith("./bin/") and not p.endswith(".dll"): |
31 | | - patterns.append("./share/locale/*/LC_MESSAGES/"+p[6:p.rfind(".")]+"*.mo") |
32 | | - found=set() |
33 | | - for p in patterns: |
| 26 | + with open(filelist_name, "r") as f: |
| 27 | + filelist = set(map(lambda x: x.strip(), f.readlines())) |
| 28 | + |
| 29 | +for module in sys.argv[1:]: |
| 30 | + modname = module[:module.find(".")] |
| 31 | + print("Processing module ", modname, file=sys.stderr) |
| 32 | + with open(module, "r") as f: |
| 33 | + patterns = [x.strip() for x in f.readlines()] |
| 34 | + for p in patterns: |
| 35 | + if p.startswith("./bin/") and not p.endswith(".dll"): |
| 36 | + patterns.append("./share/locale/*/LC_MESSAGES/" + |
| 37 | + p[6:p.rfind(".")] + "*.mo") |
| 38 | + found = set() |
| 39 | + for p in patterns: |
34 | 40 | if p.startswith("#"): |
35 | 41 | continue |
36 | 42 | for f in filelist: |
37 | | - if fnmatch.fnmatch(f,p): |
| 43 | + if fnmatch.fnmatch(f, p): |
38 | 44 | found.add(f) |
39 | 45 | filelist -= found |
40 | | - with open(modname+"_list.nsi","w") as out: |
41 | | - curdir="" |
| 46 | + with open(modname + "_list.nsi", "w") as out: |
| 47 | + curdir = "" |
42 | 48 | for f in sorted(found): |
43 | | - filedir=os.path.dirname(f) |
44 | | - if filedir !=curdir: |
45 | | - print >>out,"SetOutPath $INSTDIR"+filedir[1:].replace("/","\\") |
46 | | - curdir=filedir |
47 | | - print >>out, "File ${PG_INS_SOURCE_DIR}"+f[1:].replace("/","\\") |
| 49 | + filedir = os.path.dirname(f) |
| 50 | + if filedir != curdir: |
| 51 | + print("SetOutPath $INSTDIR" + filedir[1:].replace("/", "\\"), |
| 52 | + file=out) |
| 53 | + curdir = filedir |
| 54 | + print("File ${PG_INS_SOURCE_DIR}" + f[1:].replace("/", "\\"), |
| 55 | + file=out) |
48 | 56 |
|
49 | 57 | # When all module files are processed: |
50 | | -if len(filelist): |
51 | | - print >>sys.stderr,"Following unprocessed files found:\n",", ".join(sorted(filelist)) |
| 58 | +if filelist: |
| 59 | + print("Following unprocessed files found:\n", ", ".join(sorted(filelist)), |
| 60 | + file=sys.stderr) |
52 | 61 | sys.exit(1) |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
|
0 commit comments