Skip to content

Commit 55ec85a

Browse files
vbwagnerVictorSpirin
authored andcommitted
Make genlist.py compatible with both 2 and 3 python and pylint-clean
1 parent ea292b2 commit 55ec85a

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

build/helpers/genlists.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,58 @@
44
This script reads list of glob patterns from files, specified in the
55
command-line and generates lists of files for each pattern
66
"""
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
812

13+
#pylint: disable=invalid-name
914
filelist_name = sys.argv.pop(1)
1015
if os.path.isdir(filelist_name):
1116
# Generate filelist ourselves
1217
pwd = os.getcwd()
1318
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("\\", "/")
1722
for f in files:
18-
filelist.add(dirname+"/"+f)
23+
filelist.add(dirname + "/" + f)
1924
os.chdir(pwd)
2025
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:
3440
if p.startswith("#"):
3541
continue
3642
for f in filelist:
37-
if fnmatch.fnmatch(f,p):
43+
if fnmatch.fnmatch(f, p):
3844
found.add(f)
3945
filelist -= found
40-
with open(modname+"_list.nsi","w") as out:
41-
curdir=""
46+
with open(modname + "_list.nsi", "w") as out:
47+
curdir = ""
4248
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)
4856

4957
# 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)
5261
sys.exit(1)
53-
54-
55-
56-
57-

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy