aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-06 01:16:30 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-06 01:16:30 +0000
commit33ac92965f17401fc02093f2363100ff2ed9734d (patch)
treec5eb35ad688ee393db04506e2c9524f8efd01e8a /bin/filter-bash-environment.py
parentImplement the sed-based declare -r filter in python. (diff)
downloadportage-33ac92965f17401fc02093f2363100ff2ed9734d.tar.gz
portage-33ac92965f17401fc02093f2363100ff2ed9734d.tar.bz2
portage-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-xbin/filter-bash-environment.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py
index 5e109295f..bac104f13 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()