[csw-devel] SF.net SVN: gar:[19241] csw/mgar/gar/v2-yann/lib/python/inspective_package. py

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Wed Sep 19 23:59:22 CEST 2012


Revision: 19241
          http://gar.svn.sourceforge.net/gar/?rev=19241&view=rev
Author:   chninkel
Date:     2012-09-19 21:59:21 +0000 (Wed, 19 Sep 2012)
Log Message:
-----------
more verbose regexp

Modified Paths:
--------------
    csw/mgar/gar/v2-yann/lib/python/inspective_package.py

Modified: csw/mgar/gar/v2-yann/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2-yann/lib/python/inspective_package.py	2012-09-19 21:06:25 UTC (rev 19240)
+++ csw/mgar/gar/v2-yann/lib/python/inspective_package.py	2012-09-19 21:59:21 UTC (rev 19241)
@@ -393,25 +393,67 @@
 
   def _ParseElfdumpLine(self, line, section=None):
 
-    headers_re = (r'(?P<section>Version Needed|Version Definition|Symbol Table|Syminfo) Section:\s+(?:\.SUNW_version|\.dynsym|\.SUNW_syminfo|.symtab)\s*$|'
-                   '\s*(?:index\s+)?version\s+dependency\s*$|'
-                   '\s*(?:index\s+)?file\s+version\s*$|'
-                   '\s*index\s*value\s+size\s+type\s+bind\s+oth\s+ver\s+shndx\s+name\s*$|'
-                   '\s*index\s+flags\s+bound to\s+symbol\s*$|'
-                   '\s*$')
+    headers_re = (
+      r"""
+       (?P<section>Version\sNeeded|Symbol\sTable     # Section header
+                  |Version\sDefinition|Syminfo)
+                   \sSection:
+        \s+(?:\.SUNW_version|\.dynsym
+             |\.SUNW_syminfo|.symtab)\s*$
+       |\s*(?:index\s+)?version\s+dependency\s*$     # Version needed header
+       |\s*(?:index\s+)?file\s+version\s*$           # Version definition header
+       |\s*index\s*value\s+size\s+type\s+bind        # Symbol table header
+        \s+oth\s+ver\s+shndx\s+name\s*$
+       |\s*index\s+flags\s+bound to\s+symbol\s*$     # Syminfo header
+       |\s*$                                         # There is always a blank
+                                                     # line before a new section
+       """)
 
-    re_by_section = { 'version definition': (r'\s*(?:\[(?P<index>\d+)\]\s+)?(?P<version>.*\S)\s+(?P<dependency>\S+)?\s*$'),
-                      'version needed': (r'\s*(?:\[(?P<index>\d+)\]\s+)?(?:(?P<file>\S+)\s+(?!\[ (?:INFO|WEAK) \]))?(?P<version>\S+)(?:\s+\[ (?:INFO|WEAK) \])?\s*$'),
-                      'symbol table': (r'\s*\[\d+\]\s+(?:0x[0-9a-f]+|REG_G\d+)\s+0x[0-9a-f]+\s+\S+\s+(?P<bind>\S+)\s+\S+\s+(?P<ver>\S+)\s+(?P<shndx>\S+)\s+(?P<name>\S+)?\s*$'),
-                      'syminfo': (r'\s*\[\d+\]\s+(?P<flags>[ABCDFILNPS]+)\s+(?:(?:\[\d+\]\s+(?P<library>.*\S)|<self>)\s+)?(?P<symbol>.*\S)\s*') }
+    re_by_section = {
+      'version definition': (r"""
+        \s*(?:\[(?P<index>\d+)\]\s+)? # index might be not present
+                                      # if no version binding is enabled
+        (?P<version>.*\S)
+        \s+(?P<dependency>\S+)?\s*$
+                              """),
+      'version needed': (r"""
+        \s*(?:\[(?P<index>\d+)\]\s+)?     # index might be not present
+                                          # if no version binding is enabled
+        (?:(?P<file>\S+)\s+               # file can be absent if the same as
+         (?!\[\s(?:INFO|WEAK)\s\]))?      # the previous line, we make sure
+                                          # version is not confused with file
+                                          # in that case
+        (?P<version>\S+)
+        (?:\s+\[\s(?:INFO|WEAK)\s\])?\s*$ #
+                          """),
+      'symbol table': (r"""
+         \s*\[\d+\]
+         \s+(?:0x[0-9a-f]+|REG_G\d+)
+         \s+0x[0-9a-f]+
+         \s+\S+
+         \s+(?P<bind>\S+)
+         \s+\S+
+         \s+(?P<ver>\S+)
+         \s+(?P<shndx>\S+)
+         \s+(?P<name>\S+)?\s*$
+                        """),
+      'syminfo': (r"""
+         \s*\[\d+\]
+         \s+(?P<flags>[ABCDFILNPS]+)
+         \s+(?:(?:\[\d+\]                   # some kind of library index
+         \s+(?P<library>.*\S)|<self>)\s+)?  # library is not present
+                                            # for external symbols not
+                                            # directly bound
+         (?P<symbol>.*\S)\s*
+                   """)}
 
     elfdump_data = None
-    m = re.match(headers_re, line)
+    m = re.match(headers_re, line, re.VERBOSE)
     if m:
       if m.lastindex:
         section = m.group('section').lower()
     elif section:
-      m = re.match(re_by_section[section], line)
+      m = re.match(re_by_section[section], line, re.VERBOSE)
       if m:
         elfdump_data = m.groupdict()
 

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