+
+ def load(self, options):
+ langs = get_languages(options['lang'])
+
+ for src in SOURCES:
+ src.load(options['directory'], langs)
+
+ def handle(self, *a, **options):
+ if options['load']:
+ if not options['directory'] or not os.path.exists(options['directory']):
+ print "Directory not provided or does not exist, please use -d"
+ sys.exit(1)
+
+ if options['merge']: self.merge_setup(options['directory'])
+ self.load(options)
+ if options['merge']: self.merge_finish(options['message'])
+ else:
+ self.save(options)
+
+ merge_branch = 'wl-locale-merge'
+ last_branch = None
+
+ def merge_setup(self, directory):
+ self.last_branch = self.current_branch()
+ rev = open(os.path.join(directory, '.revision')).read()
+
+ self.system('git checkout -b %s %s' % (self.merge_branch, rev))
+
+ def merge_finish(self, message):
+ self.system('git commit -a -m "%s"' % message.replace('"', '\\"'))
+ self.system('git checkout %s' % self.last_branch)
+ self.system('git merge -s recursive -X theirs %s' % self.merge_branch)
+ self.system('git branch -d %s' % self.merge_branch)
+
+ def system(self, fmt, *args):
+ code = os.system(fmt % args)
+ if code != 0:
+ raise OSError('Command %s returned with exit code %d' % (fmt % args, code))
+ return code