summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-10-25 14:50:13 -0400
committerChris McDonough <chrism@plope.com>2010-10-25 14:50:13 -0400
commit3f92751e15669538fa74f387a2f8a8717bb9e348 (patch)
tree34d5f1daba15568b6a7d4885397f09f38feb5327
parente11fd45a5dbde00d4699522bf1b629850dc4ae55 (diff)
downloadpyramid-3f92751e15669538fa74f387a2f8a8717bb9e348.tar.gz
pyramid-3f92751e15669538fa74f387a2f8a8717bb9e348.tar.bz2
pyramid-3f92751e15669538fa74f387a2f8a8717bb9e348.zip
simplify zcml replacement
-rw-r--r--pyramid/fixers/fix_bfg_imports.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/pyramid/fixers/fix_bfg_imports.py b/pyramid/fixers/fix_bfg_imports.py
index e53973469..94327cd4b 100644
--- a/pyramid/fixers/fix_bfg_imports.py
+++ b/pyramid/fixers/fix_bfg_imports.py
@@ -167,22 +167,26 @@ class FixBfgImports(fixer_base.BaseFix):
if new_name:
node.replace(Name(new_name, prefix=bare_name.prefix))
-BFG_INCLUDES_RE = (
- r'include\s+?package\s*?=\s*?[\'\"]repoze\.bfg\.includes[\'\"]')
BFG_NS_RE = (
r'xmlns\s*?=\s*?[\'\"]http://namespaces\.repoze\.org/bfg[\'\"]')
+BFG_IN_ATTR = (
+ r'[\'\"]\s*?(repoze\.bfg)(.*?)[\'\"]')
-INCLUDES = re.compile(BFG_INCLUDES_RE, re.MULTILINE)
+
+ATTR = re.compile(BFG_IN_ATTR, re.MULTILINE)
NS = re.compile(BFG_NS_RE, re.MULTILINE)
+def replace(match):
+ return '"pyramid%s"' % match.group(2)
+
def fix_zcml(path):
for root, dirs, files in os.walk(path):
for file in files:
if file.endswith('.zcml'):
absfile = os.path.join(root, file)
text = open(absfile, 'rb').read()
- newt =INCLUDES.sub('include package="pyramid.includes"', text)
- newt = NS.sub('xmlns="http://pylonshq.com/pyramid"', newt)
+ newt = NS.sub('xmlns="http://pylonshq.com/pyramid"', text)
+ newt = ATTR.sub(replace, newt)
if text != newt:
newf = open(absfile, 'wb')
newf.write(newt)