Allow specifying a target path for generating language packs with babel_pack

This commit is contained in:
Gina Häußge 2015-06-10 17:14:14 +02:00
parent 6a7a858065
commit 496828482d

View file

@ -338,10 +338,11 @@ class BundleTranslation(Command):
class PackTranslation(Command):
description = "bundles translations"
description = "creates language packs for translations"
user_options = [
('locale=', 'l', 'locale for the translation to bundle'),
('author=', 'a', 'author of the translation')
('locale=', 'l', 'locale for the translation to pack'),
('author=', 'a', 'author of the translation'),
('target=', 't', 'target folder for the pack')
]
boolean_options = []
@ -367,6 +368,7 @@ class PackTranslation(Command):
def initialize_options(self):
self.locale = None
self.author = None
self.target = None
def finalize_options(self):
if self.locale is None:
@ -383,7 +385,10 @@ class PackTranslation(Command):
now = datetime.datetime.utcnow().replace(microsecond=0)
zip_path = os.path.join(self.__class__.source_dir, "{prefix}{locale}_{date}.zip".format(prefix=self.__class__.pack_name_prefix, locale=locale, date=now.strftime("%Y%m%d%H%M%S")))
if self.target is None:
self.target = self.__class__.source_dir
zip_path = os.path.join(self.target, "{prefix}{locale}_{date}.zip".format(prefix=self.__class__.pack_name_prefix, locale=locale, date=now.strftime("%Y%m%d%H%M%S")))
print("Packing translation to {zip_path}".format(**locals()))
def add_recursively(zip, path, prefix):