def test_extract_tower_template(): fileobj = StringIO(TEST_TEMPLATE_INPUT) method = "tower.management.commands.extract.extract_tower_template" output = fake_extract_from_dir(filename="filename", fileobj=fileobj, method=method) # god help you if these are ever unequal eq_(TEST_TEMPLATE_OUTPUT, unicode(create_pofile_from_babel(output)))
def test_extract_tower_json(self): """ Tests for :py:func:`require_i18n.util.extract_tower_json`. """ po_input = """ define({ "root": { "cannot_load_bg": "Error for you!", } }); """ po_output = """\ #: filename:4 msgid "Error for you!" msgstr "" """ fileobj = BytesIO(po_input) method = 'require_i18n.util.extract_tower_json' output = fake_extract_from_dir('filename', fileobj, method, keywords=TOWER_KEYWORDS, options=OPTIONS_MAP, comment_tags=COMMENT_TAGS) self.assertEqual(po_output, str(create_pofile_from_babel(output)))
def test_extract_tower_python_backwards_compatible(): fileobj = StringIO(TEST_PO_INPUT) method = "tower.management.commands.extract.extract_tower_python" output = fake_extract_from_dir(filename="filename", fileobj=fileobj, method=method) # god help you if these are ever unequal eq_(TEST_PO_OUTPUT, unicode(create_pofile_from_babel(output)))
def test_extract_tower_template(): fileobj = BytesIO(TEST_TEMPLATE_INPUT) method = 'tower.extract_tower_template' output = fake_extract_from_dir(filename="filename", fileobj=fileobj, method=method) # god help you if these are ever unequal eq_(TEST_TEMPLATE_OUTPUT, unicode(create_pofile_from_babel(output)))
def test_extract_tower_python(): fileobj = StringIO(TEST_PO_INPUT) method = 'tower.extract_tower_python' output = fake_extract_from_dir(filename="filename", fileobj=fileobj, method=method) # god help you if these are ever unequal eq_(TEST_PO_OUTPUT, unicode(create_pofile_from_babel(output)))
def test_extract_tower_template_backwards_compatible(): fileobj = StringIO(TEST_TEMPLATE_INPUT) method = 'tower.management.commands.extract.extract_tower_template' output = fake_extract_from_dir(filename="filename", fileobj=fileobj, method=method) # god help you if these are ever unequal eq_(TEST_TEMPLATE_OUTPUT, unicode(create_pofile_from_babel(output)))
def handle(self, *args, **options): if args: # mimics tower.management.commands.extract for a list of files outputdir = os.path.join(settings.ROOT, 'locale', 'templates', 'LC_MESSAGES') if not os.path.isdir(outputdir): os.makedirs(outputdir) extracted = extract_from_files(args) catalog = extract.create_pofile_from_babel(extracted) catalog.savefile(os.path.join(outputdir, '%s.pot' % DOMAIN)) else: # This is basically a wrapper around the tower extract # command, we might want to do some things around this in the # future gettext_extract() pot_to_langfiles()