-
-
Save ccdos/fe2b0014b81a8ba60e9c to your computer and use it in GitHub Desktop.
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 characters
| #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 'Deleting: ', 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('App_Data\\Localization\\' + LOCAL): | |
| 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 'Usage: ' | |
| print 'python {0} <path-to-orchard-language-package>'.format(sys.argv[0]) | |
| print 'Orchard CMS Language Package Cleanner for ' + LOCAL | |
| 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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment