diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-03-06 01:16:30 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-03-06 01:16:30 +0000 |
commit | 33ac92965f17401fc02093f2363100ff2ed9734d (patch) | |
tree | c5eb35ad688ee393db04506e2c9524f8efd01e8a /bin/filter-bash-environment.py | |
parent | Implement the sed-based declare -r filter in python. (diff) | |
download | portage-multirepo-33ac92965f17401fc02093f2363100ff2ed9734d.tar.gz portage-multirepo-33ac92965f17401fc02093f2363100ff2ed9734d.tar.bz2 portage-multirepo-33ac92965f17401fc02093f2363100ff2ed9734d.zip |
Remove egrep syntax emulation since it's not really needed.
svn path=/main/trunk/; revision=9447
Diffstat (limited to 'bin/filter-bash-environment.py')
-rwxr-xr-x | bin/filter-bash-environment.py | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py index 5e109295..bac104f1 100755 --- a/bin/filter-bash-environment.py +++ b/bin/filter-bash-environment.py @@ -5,12 +5,6 @@ import os, re, sys -egrep_compat_map = { - "[:alnum:]" : r'\w', - "[:digit:]" : r'\d', - "[:space:]" : r'\s', -} - here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$') func_start_re = re.compile(r'^[-\w]+\s*\(\)\s*$') func_end_re = re.compile(r'^\}$') @@ -19,11 +13,6 @@ var_assign_re = re.compile(r'(^|^declare\s+-\S+\s+|^export\s+)([^=\s]+)=("|\')?. close_quote_re = re.compile(r'(\\"|"|\')\s*$') readonly_re = re.compile(r'^declare\s+-(\S*)r(\S*)\s+') -def compile_egrep_pattern(s): - for k, v in egrep_compat_map.iteritems(): - s = s.replace(k, v) - return re.compile(s) - def have_end_quote(quote, line): """ Check if the line has an end quote (useful for handling multi-line @@ -104,10 +93,7 @@ if __name__ == "__main__": "names matching a given PATTERN " + \ "while leaving bash function definitions and here-documents " + \ "intact. The PATTERN is a space separated list of variable names" + \ - " and it supports python regular expression syntax in addition to" + \ - " [:alnum:], [:digit:], and [:space:] " + \ - "character classes which will be automatically translated " + \ - "for compatibility with egrep syntax." + " and it supports python regular expression syntax." usage = "usage: %s PATTERN" % os.path.basename(sys.argv[0]) from optparse import OptionParser parser = OptionParser(description=description, usage=usage) @@ -124,5 +110,5 @@ if __name__ == "__main__": var_pattern = "^(%s)$" % "|".join(var_pattern) filter_bash_environment( - compile_egrep_pattern(var_pattern), file_in, file_out) + re.compile(var_pattern), file_in, file_out) file_out.flush() |