|
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 | | -importsys,fnmatch,os,os.path |
| 7 | +from __future__importprint_function |
| 8 | +importsys |
| 9 | +importfnmatch |
| 10 | +importos |
| 11 | +importos.path |
8 | 12 |
|
| 13 | +#pylint: disable=invalid-name |
9 | 14 | filelist_name=sys.argv.pop(1) |
10 | 15 | ifos.path.isdir(filelist_name): |
11 | 16 | # Generate filelist ourselves |
12 | 17 | pwd=os.getcwd() |
13 | 18 | os.chdir(filelist_name) |
14 | | -filelist=set() |
15 | | -fordirname,subdirlist,filesinos.walk("."): |
16 | | -dirname=dirname.replace("\\","/") |
| 19 | +filelist=set() |
| 20 | +fordirname,subdirlist,filesinos.walk("."): |
| 21 | +dirname=dirname.replace("\\","/") |
17 | 22 | forfinfiles: |
18 | | -filelist.add(dirname+"/"+f) |
| 23 | +filelist.add(dirname+"/"+f) |
19 | 24 | os.chdir(pwd) |
20 | 25 | else: |
21 | | -withopen(filelist_name,"r")asf: |
22 | | -filelist=set(map(lambdax:x.strip(),f.readlines())) |
23 | | - |
24 | | -formoduleinsys.argv[1:]: |
25 | | -modname=module[:module.find(".")] |
26 | | -print>>sys.stderr,"Processing module ",modname |
27 | | -withopen(module,"r")asf: |
28 | | -patterns=map(lambdax:x.strip(),f.readlines()) |
29 | | -forpinpatterns: |
30 | | -ifp.startswith("./bin/")andnotp.endswith(".dll"): |
31 | | -patterns.append("./share/locale/*/LC_MESSAGES/"+p[6:p.rfind(".")]+"*.mo") |
32 | | -found=set() |
33 | | -forpinpatterns: |
| 26 | +withopen(filelist_name,"r")asf: |
| 27 | +filelist=set(map(lambdax:x.strip(),f.readlines())) |
| 28 | + |
| 29 | +formoduleinsys.argv[1:]: |
| 30 | +modname=module[:module.find(".")] |
| 31 | +print("Processing module ",modname,file=sys.stderr) |
| 32 | +withopen(module,"r")asf: |
| 33 | +patterns= [x.strip()forxinf.readlines()] |
| 34 | +forpinpatterns: |
| 35 | +ifp.startswith("./bin/")andnotp.endswith(".dll"): |
| 36 | +patterns.append("./share/locale/*/LC_MESSAGES/"+ |
| 37 | +p[6:p.rfind(".")]+"*.mo") |
| 38 | +found=set() |
| 39 | +forpinpatterns: |
34 | 40 | ifp.startswith("#"): |
35 | 41 | continue |
36 | 42 | forfinfilelist: |
37 | | -iffnmatch.fnmatch(f,p): |
| 43 | +iffnmatch.fnmatch(f,p): |
38 | 44 | found.add(f) |
39 | 45 | filelist-=found |
40 | | -withopen(modname+"_list.nsi","w")asout: |
41 | | -curdir="" |
| 46 | +withopen(modname+"_list.nsi","w")asout: |
| 47 | +curdir="" |
42 | 48 | forfinsorted(found): |
43 | | -filedir=os.path.dirname(f) |
44 | | -iffiledir!=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 | +iffiledir!=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 | | -iflen(filelist): |
51 | | -print>>sys.stderr,"Following unprocessed files found:\n",", ".join(sorted(filelist)) |
| 58 | +iffilelist: |
| 59 | +print("Following unprocessed files found:\n",", ".join(sorted(filelist)), |
| 60 | +file=sys.stderr) |
52 | 61 | sys.exit(1) |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
|