[Piuparts-devel] [Git][debian/piuparts][develop] piupartslib.dwke - memory
Holger Levsen
gitlab at salsa.debian.org
Thu Jan 31 15:02:33 GMT 2019
Holger Levsen pushed to branch develop at Debian / piuparts
Commits:
2f67d80c by hpfn at 2019-01-31T15:01:38Z
piupartslib.dwke - memory
close #5
- - - - -
2 changed files:
- debian/changelog
- piupartslib/dwke.py
Changes:
=====================================
debian/changelog
=====================================
@@ -3,6 +3,19 @@ piuparts (0.97) UNRELEASED; urgency=medium
[ Herbert Fortes ]
* piuparts.py, piuparts-slave.py, piupartslib/pkgsummary.py and
piuparts-analyze.py: add '()' to print. Py2 and Py3 compatible.
+ * piupartslib/dwke.py:
+ - class Problem:
+ - Class attr instead of instance attr
+ Save some memory
+ - get_file_dict function:
+ - dictionary comprehension. "More readable and
+ often faster at the same time".
+ - create_problem_list function:
+ - list.sort() instead of sorted(list).
+ sorted() returns a *new* sorted list. This is
+ not necessary here.
+ list.sort() sorts the list in place.
+ Save some memory
-- Holger Levsen <holger at debian.org> Sun, 13 Jan 2019 16:58:44 +0100
=====================================
piupartslib/dwke.py
=====================================
@@ -34,6 +34,8 @@ LOG_EXT = '.log'
class Problem():
""" Encapsulate a particular known problem """
+ required_tags = ["PATTERN", "WHERE", "ISSUE", "HEADER", "HELPTEXT"]
+ optional_tags = ["EXCLUDE_PATTERN", "EXPLAIN", "PRIORITY"]
def __init__(self, probpath):
"""probpath is the path to the problem definition file"""
@@ -44,10 +46,6 @@ class Problem():
self.tags_are_valid = True
- self.required_tags = ["PATTERN", "WHERE", "ISSUE",
- "HEADER", "HELPTEXT"]
- self.optional_tags = ["EXCLUDE_PATTERN", "EXPLAIN", "PRIORITY"]
-
self.init_problem()
for tag in self.required_tags:
@@ -194,22 +192,19 @@ def get_file_dict(workdirs, ext):
"""For files in [workdirs] with extension 'ext', create a dict of
<pkgname>_<version>: <path>"""
- filedict = {}
-
- for dir in workdirs:
- for fl in os.listdir(dir):
- if os.path.splitext(fl)[1] == ext:
- filedict[os.path.splitext(os.path.basename(fl))[0]] \
- = os.path.join(dir, fl)
-
- return filedict
+ return {os.path.splitext(os.path.basename(fl))[0]: os.path.join(d, fl)
+ for d in workdirs
+ for fl in os.listdir(d)
+ if os.path.splitext(fl)[1] == ext}
def create_problem_list(pdir):
plist = []
+ pdir_list = os.listdir(pdir)
+ pdir_list.sort()
- for pfile in [x for x in sorted(os.listdir(pdir)) if x.endswith(".conf")]:
+ for pfile in [x for x in pdir_list if x.endswith(".conf")]:
prob = Problem(os.path.join(pdir, pfile))
if prob.valid():
View it on GitLab: https://salsa.debian.org/debian/piuparts/commit/2f67d80c5ae89c597e698c02483da8b3c4158d22
--
View it on GitLab: https://salsa.debian.org/debian/piuparts/commit/2f67d80c5ae89c597e698c02483da8b3c4158d22
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20190131/dabc9ec8/attachment-0001.html>
More information about the Piuparts-devel
mailing list