-
-
Save ccdos/fe2b0014b81a8ba60e9c to your computer and use it in GitHub Desktop.
Revisions
-
oldrev revised this gist
Jun 28, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def purge(dir): dirs = [os.path.join(dir, o) for o in os.listdir(dir) if os.path.isdir(os.path.join(dir, o)) and o != LOCAL] for d in dirs: print 'Deleting: ', d shutil.rmtree(d) def purge_all(dir): -
oldrev revised this gist
Jun 28, 2014 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,15 @@ #encoding: utf-8 # Orchard Language Package Cleanner # Author: Wei "oldrev" Li <[email protected]> # License: New BSD import sys, os, shutil LOCAL = 'zh-CN' def purge(dir): dirs = [os.path.join(dir, o) for o in os.listdir(dir) if os.path.isdir(os.path.join(dir, o)) and o != LOCAL] for d in dirs: print 'Delete directory: ', d shutil.rmtree(d) @@ -16,7 +18,7 @@ def purge_all(dir): for root, dirs, files in os.walk(dir): for f in files: fp = os.path.join(root, f) if root.endswith('App_Data\\Localization\\' + LOCAL): dp = os.path.dirname(root) purge(dp) @@ -36,7 +38,7 @@ def print_usage(): print 'python {0} <path-to-orchard-language-package>'.format(sys.argv[0]) print print 'Orchard CMS Language Package Cleanner for ' + LOCAL if len(sys.argv) < 2: print_usage() -
oldrev created this gist
Jun 28, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ #encoding: utf-8 # Orchard Language Package Cleanner for zh-CN # Author: Wei "oldrev" Li <[email protected]> # License: New BSD import sys, os, shutil def purge(dir): dirs = [os.path.join(dir, o) for o in os.listdir(dir) if os.path.isdir(os.path.join(dir, o)) and o != 'zh-CN'] for d in dirs: print 'Delete directory: ', d shutil.rmtree(d) def purge_all(dir): for root, dirs, files in os.walk(dir): for f in files: fp = os.path.join(root, f) if root.endswith(r'App_Data\Localization\zh-CN'): dp = os.path.dirname(root) purge(dp) def check_orchard_directory(root): subdirs = ['Core', 'App_Data', 'Themes', 'Modules'] if not os.path.isdir(root): return False for subdir in subdirs: dir = os.path.join(root, subdir) if not os.path.isdir(dir): return False return True def print_usage(): print print 'Usage: ' print 'python {0} <path-to-orchard-language-package>'.format(sys.argv[0]) print print 'Orchard CMS Language Package Cleanner for zh-CN' if len(sys.argv) < 2: print_usage() exit() if not check_orchard_directory(sys.argv[1]): print 'Error: The path "{0}" seems not like an Orchard language package.'.format(sys.argv[1]) exit() print "Cleaning po files..." purge_all(sys.argv[1])