summaryrefslogtreecommitdiffstats
path: root/tools/upgrade/1.3/migrate_perms_to_mode.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-11-08 11:16:59 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-11-08 11:17:05 -0500
commit35e53dcc29b204b9dd8a119bc77933c6625db2f3 (patch)
tree2b2887d55c6aa3b3dd35525e2887a489a979e1a2 /tools/upgrade/1.3/migrate_perms_to_mode.py
parentdc696de30352cd9b2f08d25c14eec62764879475 (diff)
downloadbcfg2-35e53dcc29b204b9dd8a119bc77933c6625db2f3.tar.gz
bcfg2-35e53dcc29b204b9dd8a119bc77933c6625db2f3.tar.bz2
bcfg2-35e53dcc29b204b9dd8a119bc77933c6625db2f3.zip
tools: skip ignored files (e.g., .svn) in migrate_perms_to_mode (from Matt Baker)
Diffstat (limited to 'tools/upgrade/1.3/migrate_perms_to_mode.py')
-rwxr-xr-xtools/upgrade/1.3/migrate_perms_to_mode.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/upgrade/1.3/migrate_perms_to_mode.py b/tools/upgrade/1.3/migrate_perms_to_mode.py
index 18abffec2..ee440bc8e 100755
--- a/tools/upgrade/1.3/migrate_perms_to_mode.py
+++ b/tools/upgrade/1.3/migrate_perms_to_mode.py
@@ -3,7 +3,8 @@
import lxml.etree
import os
import sys
-
+from fnmatch import fnmatch
+from Bcfg2.Compat import any
import Bcfg2.Options
@@ -53,9 +54,15 @@ def convertstructure(structfile):
writefile(structfile, xdata)
+def skip_path(path, setup):
+ return any(fnmatch(path, p) or fnmatch(os.path.basename(path), p)
+ for p in setup['ignore'])
+
+
def main():
opts = dict(repo=Bcfg2.Options.SERVER_REPOSITORY,
configfile=Bcfg2.Options.CFILE,
+ ignore=Bcfg2.Options.SERVER_FAM_IGNORE,
plugins=Bcfg2.Options.SERVER_PLUGINS)
setup = Bcfg2.Options.OptionParser(opts)
setup.parse(sys.argv[1:])
@@ -64,11 +71,17 @@ def main():
for plugin in setup['plugins']:
if plugin in ['Base', 'Bundler', 'Rules']:
for root, dirs, files in os.walk(os.path.join(repo, plugin)):
+ if skip_path(root, setup):
+ continue
for fname in files:
+ if skip_path(fname, setup):
+ continue
convertstructure(os.path.join(root, fname))
if plugin not in ['Cfg', 'TGenshi', 'TCheetah', 'SSHbase', 'SSLCA']:
continue
for root, dirs, files in os.walk(os.path.join(repo, plugin)):
+ if skip_path(root, setup):
+ continue
for fname in files:
if fname == 'info.xml':
convertinfo(os.path.join(root, fname))