summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-10-25 23:42:43 -0400
committerChris McDonough <chrism@plope.com>2010-10-25 23:42:43 -0400
commitb555698bbeca3aaa4380ef17f1631ebb1fd20170 (patch)
tree9fe02147c8de0d9e49c61bd5dda52e176a7f79ec
parent2e6905e15221691e645e5ff4ba0378a6d9438c29 (diff)
downloadpyramid-b555698bbeca3aaa4380ef17f1631ebb1fd20170.tar.gz
pyramid-b555698bbeca3aaa4380ef17f1631ebb1fd20170.tar.bz2
pyramid-b555698bbeca3aaa4380ef17f1631ebb1fd20170.zip
be more restrictive about replacing ZCML attributes with repoze.bfg in them
-rw-r--r--pyramid/fixers/fix_bfg_imports.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/pyramid/fixers/fix_bfg_imports.py b/pyramid/fixers/fix_bfg_imports.py
index cc3c0faf5..c4a0605fe 100644
--- a/pyramid/fixers/fix_bfg_imports.py
+++ b/pyramid/fixers/fix_bfg_imports.py
@@ -10,7 +10,7 @@ from lib2to3 import fixer_base
MAPPING = {'repoze.bfg':'pyramid'}
-for name in (
+MODULE_NAMES = (
'compat',
'configuration',
'authentication',
@@ -42,7 +42,7 @@ for name in (
'tests.test_configuration',
'tests.ccbugapp',
'tests.exceptionviewapp',
- 'repoze.bfg.tests.exceptionviewapp.models',
+ 'tests.exceptionviewapp.models',
'tests.fixtureapp',
'tests.fixtureapp.models',
'tests.grokkedapp',
@@ -57,7 +57,9 @@ for name in (
'view',
'wsgi',
'zcml',
- ):
+ )
+
+for name in MODULE_NAMES:
frm = 'repoze.bfg.' + name
to = 'pyramid.' + name
MAPPING[frm] = to
@@ -167,8 +169,14 @@ class FixBfgImports(fixer_base.BaseFix):
if new_name:
node.replace(Name(new_name, prefix=bare_name.prefix))
+MODULE_ALTERNATIVES = []
+for name in MODULE_NAMES:
+ MODULE_ALTERNATIVES.append(r'\.' + re.escape(name)+r'[\w\.]*?')
+
+MODULE_ALTERNATIVES = '|'.join(MODULE_ALTERNATIVES)
+
BFG_NS_RE = r'xmlns\s*?=\s*?[\'\"]http://namespaces\.repoze\.org/bfg[\'\"]'
-BFG_IN_ATTR = r'[\'\"]\s*?(repoze\.bfg)(.*?)[\'\"]'
+BFG_IN_ATTR = r'[\'\"]\s*?(repoze\.bfg)(%s)\s*?[\'\"]' % MODULE_ALTERNATIVES
ATTR = re.compile(BFG_IN_ATTR, re.MULTILINE)
NS = re.compile(BFG_NS_RE, re.MULTILINE)