commit: 352422106f5005c07704f3a00d10ae60d94cc64f Author: André Erdmann <dywi <AT> mailerd <DOT> de> AuthorDate: Thu Jul 17 14:04:09 2014 +0000 Commit: André Erdmann <dywi <AT> mailerd <DOT> de> CommitDate: Thu Jul 17 14:04:09 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=35242210
roverlay/util/portage_regex: small cleanup/fix --- roverlay/util/portage_regex/default.py | 17 +++++++++-------- roverlay/util/portage_regex/wildcard.py | 13 +------------ 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/roverlay/util/portage_regex/default.py b/roverlay/util/portage_regex/default.py index fcaee68..a8d032a 100644 --- a/roverlay/util/portage_regex/default.py +++ b/roverlay/util/portage_regex/default.py @@ -64,7 +64,7 @@ PAT_DEP_ATOM_USE = ( ) -_FMT_PAT_01_WORD = r'(?:[{0}][{0}{1}]*)[{0}]' +_FMT_PAT_01_WORD = r'(?:[{0}][{0}{1}]*)?[{0}]' @@ -317,15 +317,16 @@ RE_PACKAGE = MultiRegexProxy.compile_exact ( PAT_PACKAGE ) ##) - - -if __name__ == '__main__': - import sys - - for s in sys.argv[1:]: - match = RE_PACKAGE.match(s) +def regex_main ( re_obj, pattern_list ): + for s in pattern_list: + match = re_obj.match ( s ) if match: print ( "{!s} : {!s}".format ( s, match.groupdict() ) ) else: print ( "{!s} not matched".format ( s ) ) +# --- end of regex_main (...) --- + +if __name__ == '__main__': + import sys + regex_main ( RE_PACKAGE, sys.argv[1:] ) diff --git a/roverlay/util/portage_regex/wildcard.py b/roverlay/util/portage_regex/wildcard.py index fd6308f..bd5b770 100644 --- a/roverlay/util/portage_regex/wildcard.py +++ b/roverlay/util/portage_regex/wildcard.py @@ -61,15 +61,4 @@ RE_WILDCARD_PACKAGE = pre_default.MultiRegexProxy.compile_exact ( if __name__ == '__main__': import sys - - for s in sys.argv[1:]: - match = RE_WILDCARD_PACKAGE.match(s) - k,h,x = s.partition("/") - if h: - print(k,RE_WILDCARD_CATEGORY.match(k),PAT_WILDCARD_CATEGORY) - - - if match: - print ( "{!s} : {!s}".format ( s, match.groupdict() ) ) - else: - print ( "{!s} not matched".format ( s ) ) + pre_default.regex_main ( RE_WILDCARD_PACKAGE, sys.argv[1:] )