[csw-devel] SF.net SVN: gar:[12109] csw/mgar/gar/v2/lib/python/pkgmap.py
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Wed Dec 29 01:08:39 CET 2010
Revision: 12109
http://gar.svn.sourceforge.net/gar/?rev=12109&view=rev
Author: wahwah
Date: 2010-12-29 00:08:39 +0000 (Wed, 29 Dec 2010)
Log Message:
-----------
checkpkg: Separating the pkgmap parsing code
Modified Paths:
--------------
csw/mgar/gar/v2/lib/python/pkgmap.py
Modified: csw/mgar/gar/v2/lib/python/pkgmap.py
===================================================================
--- csw/mgar/gar/v2/lib/python/pkgmap.py 2010-12-29 00:08:09 UTC (rev 12108)
+++ csw/mgar/gar/v2/lib/python/pkgmap.py 2010-12-29 00:08:39 UTC (rev 12109)
@@ -34,57 +34,65 @@
self.analyze_permissions = permissions
self.entries = []
self.classes = None
+ self.strip = strip
for line in input:
- fields = re.split(r'\s+', line)
- if strip:
- strip_re = re.compile(r"^%s" % strip)
- fields = [re.sub(strip_re, "", x) for x in fields]
- line_to_add = None
- installed_path = None
- prototype_class = None
- line_type = fields[1]
- mode = None
- user = None
- group = None
- if len(fields) < 2:
- continue
- elif line_type in ('f', 'd'):
- # Files and directories
- line_to_add = fields[3]
- installed_path = fields[3]
- prototype_class = fields[2]
- if self.analyze_permissions:
- line_to_add += " %s %s %s" % tuple(fields[4:7])
- mode, user, group = fields[4:7]
- elif line_type in ('e'):
- # Editable files
- line_to_add = fields[3]
- installed_path = fields[3]
- prototype_class = fields[2]
- elif line_type in ('s', 'l'):
- # soft- and hardlinks
- link_from, link_to = fields[3].split("=")
- installed_path = link_from
- line_to_add = "%s --> %s" % (link_from, link_to)
- prototype_class = fields[2]
+ entry, line_to_add = self._ParseLine(line)
+ self.entries.append(entry)
if line_to_add:
self.paths.add(line_to_add)
- entry = {
- "line": line.strip(),
- "type": line_type,
- }
- entry["path"] = installed_path
- entry["class"] = prototype_class
- entry["mode"] = mode
- entry["user"] = user
- entry["group"] = group
- self.entries.append(entry)
self.entries_by_line = struct_util.IndexDictsBy(self.entries, "line")
self.entries_by_type = struct_util.IndexDictsBy(self.entries, "type")
self.entries_by_class = struct_util.IndexDictsBy(self.entries, "class")
self.entries_by_path = struct_util.IndexDictsBy(self.entries, "path")
self.entries = sorted(self.entries, key=lambda x: x["path"])
+ def _ParseLine(self, line):
+ fields = re.split(r'\s+', line)
+ if self.strip:
+ strip_re = re.compile(r"^%s" % strip)
+ fields = [re.sub(strip_re, "", x) for x in fields]
+ line_to_add = None
+ installed_path = None
+ prototype_class = None
+ line_type = fields[1]
+ mode = None
+ user = None
+ group = None
+ if len(fields) < 2:
+ return None
+ elif line_type in ('f', 'd'):
+ # Files and directories
+ line_to_add = fields[3]
+ installed_path = fields[3]
+ prototype_class = fields[2]
+ if self.analyze_permissions:
+ line_to_add += " %s %s %s" % tuple(fields[4:7])
+ mode, user, group = fields[4:7]
+ elif line_type in ('e'):
+ # Editable files
+ line_to_add = fields[3]
+ installed_path = fields[3]
+ prototype_class = fields[2]
+ elif line_type in ('s', 'l'):
+ # soft- and hardlinks
+ link_from, link_to = fields[3].split("=")
+ installed_path = link_from
+ line_to_add = "%s --> %s" % (link_from, link_to)
+ prototype_class = fields[2]
+ if line_to_add:
+ self.paths.add(line_to_add)
+ entry = {
+ "line": line.strip(),
+ "type": line_type,
+ }
+ entry["path"] = installed_path
+ entry["class"] = prototype_class
+ entry["mode"] = mode
+ entry["user"] = user
+ entry["group"] = group
+ # entry["target"] = group
+ return entry, line_to_add
+
def GetClasses(self):
"""The assumtion is that the set of classes never changes."""
if not self.classes:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list