def pre_sub_commands(self, opts):
     require_git_master()
     require_clean_git()
     if 'PUBLISH_BUILD_DONE' not in os.environ:
         subprocess.check_call([sys.executable, 'setup.py', 'build'])
         os.environ['PUBLISH_BUILD_DONE'] = '1'
         os.execl(os.path.abspath('setup.py'), './setup.py', 'publish')
Esempio n. 2
0
    def run(self, opts):
        require_git_master()
        pot_header = textwrap.dedent('''\
        # Translation template file..
        # Copyright (C) %(year)s Kovid Goyal
        # Kovid Goyal <*****@*****.**>, %(year)s.
        #
        msgid ""
        msgstr ""
        "Project-Id-Version: %(appname)s %(version)s\\n"
        "POT-Creation-Date: %(time)s\\n"
        "PO-Revision-Date: %(time)s\\n"
        "Last-Translator: Automatically generated\\n"
        "Language-Team: LANGUAGE\\n"
        "MIME-Version: 1.0\\n"
        "Report-Msgid-Bugs-To: https://bugs.launchpad.net/calibre\\n"
        "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
        "Content-Type: text/plain; charset=UTF-8\\n"
        "Content-Transfer-Encoding: 8bit\\n"

        ''')%dict(appname=__appname__, version=__version__,
                year=time.strftime('%Y'),
                time=time.strftime('%Y-%m-%d %H:%M+%Z'))

        files = self.source_files()
        qt_inputs = qt_sources()

        with tempfile.NamedTemporaryFile() as fl:
            fl.write('\n'.join(files))
            fl.flush()
            out = tempfile.NamedTemporaryFile(suffix='.pot', delete=False)
            out.close()
            self.info('Creating translations template...')
            subprocess.check_call(['xgettext', '-f', fl.name,
                '--default-domain=calibre', '-o', out.name, '-L', 'Python',
                '--from-code=UTF-8', '--sort-by-file', '--omit-header',
                '--no-wrap', '-k__', '--add-comments=NOTE:',
                ])
            subprocess.check_call(['xgettext', '-j',
                '--default-domain=calibre', '-o', out.name,
                '--from-code=UTF-8', '--sort-by-file', '--omit-header',
                '--no-wrap', '-kQT_TRANSLATE_NOOP:2',
                ] + qt_inputs)

            with open(out.name, 'rb') as f:
                src = f.read()
            os.remove(out.name)
            src = pot_header + '\n' + src
            src += '\n\n' + self.get_tweaks_docs()
            pot = os.path.join(self.LP_PATH, __appname__+'.pot')
            # Workaround for bug in xgettext:
            # https://savannah.gnu.org/bugs/index.php?41668
            src = re.sub(r'#, python-brace-format\s+msgid ""\s+.*<code>{0:</code>',
                   lambda m: m.group().replace('python-brace', 'no-python-brace'), src)
            with open(pot, 'wb') as f:
                f.write(src)
            self.info('Translations template:', os.path.abspath(pot))
            self.upload_pot(os.path.abspath(pot))

        return pot
Esempio n. 3
0
 def pre_sub_commands(self, opts):
     require_git_master()
     require_clean_git()
     if 'PUBLISH_BUILD_DONE' not in os.environ:
         subprocess.check_call([sys.executable, 'setup.py', 'build'])
         os.environ['PUBLISH_BUILD_DONE'] = '1'
         os.execl(os.path.abspath('setup.py'), './setup.py', 'publish')
Esempio n. 4
0
 def run(self, opts):
     require_git_master()
     self.tx('pull -a')
     if self.is_modified:
         self.check_for_errors()
         self.upload_to_vcs()
     else:
         print ('No translations were updated')
Esempio n. 5
0
 def run(self, opts):
     require_git_master()
     self.tx('pull -a')
     if self.is_modified:
         self.check_for_errors()
         self.upload_to_vcs()
     else:
         print ('No translations were updated')
Esempio n. 6
0
 def run(self, opts):
     require_git_master()
     if opts.check_for_errors:
         self.check_all()
         return
     self.tx('pull -a --parallel --no-interactive')
     if not self.is_modified:
         self.info('No translations were updated')
         return
     self.upload_to_vcs()
     self.check_all()
Esempio n. 7
0
 def run(self, opts):
     require_git_master()
     if opts.check_for_errors:
         self.check_all()
         return
     self.tx('pull -a')
     if not self.is_modified:
         self.info('No translations were updated')
         return
     self.upload_to_vcs()
     self.check_all()
Esempio n. 8
0
    def run(self, opts):
        if not is_ci:
            require_git_master()
        self.get_iso639_strings()
        if not is_ci:
            self.get_website_strings()
        self.get_content_server_strings()
        self.get_user_manual_docs()
        files = self.source_files()
        qt_inputs = qt_sources()
        pot_header = self.pot_header()

        with tempfile.NamedTemporaryFile() as fl:
            fl.write('\n'.join(files).encode('utf-8'))
            fl.flush()
            out = tempfile.NamedTemporaryFile(suffix='.pot', delete=False)
            out.close()
            self.info('Creating translations template...')
            subprocess.check_call(['xgettext', '-f', fl.name,
                '--default-domain=calibre', '-o', out.name, '-L', 'Python',
                '--from-code=UTF-8', '--sort-by-file', '--omit-header',
                '--no-wrap', '-k__', '--add-comments=NOTE:',
                ])
            subprocess.check_call(['xgettext', '-j',
                '--default-domain=calibre', '-o', out.name,
                '--from-code=UTF-8', '--sort-by-file', '--omit-header',
                                   '--no-wrap', '-kQT_TRANSLATE_NOOP:2', '-ktr', '-ktranslate:2',
                ] + qt_inputs)

            with open(out.name, 'rb') as f:
                src = f.read().decode('utf-8')
            os.remove(out.name)
            src = pot_header + '\n' + src
            src += '\n\n' + self.get_tweaks_docs()
            bdir = os.path.join(self.TRANSLATIONS, __appname__)
            if not os.path.exists(bdir):
                os.makedirs(bdir)
            pot = os.path.join(bdir, 'main.pot')
            # Workaround for bug in xgettext:
            # https://savannah.gnu.org/bugs/index.php?41668
            src = re.sub(r'#, python-brace-format\s+msgid ""\s+.*<code>{0:</code>',
                   lambda m: m.group().replace('python-brace', 'no-python-brace'), src)
            with open(pot, 'wb') as f:
                f.write(src.encode('utf-8'))
            self.info('Translations template:', os.path.abspath(pot))
            self.upload_pot(resource='main')
            self.git(['add', os.path.abspath(pot)])

        if not is_ci and self.git('diff-index --cached --quiet --ignore-submodules HEAD --', use_call=True) != 0:
            self.git(['commit', '-m', 'Updated translation templates'])
            self.git('push')

        return pot
Esempio n. 9
0
    def run(self, opts):
        require_git_master()
        if not self.modified_translations:
            try:
                subprocess.check_call(['bzr', 'merge', self.BRANCH], cwd=self.LP_BASE)
            except subprocess.CalledProcessError:
                self.resolve_conflicts()
        self.check_for_errors()

        if self.modified_translations:
            subprocess.check_call(['bzr', 'commit', '-m',
                self.CMSG], cwd=self.LP_BASE)
        else:
            print('No updated translations available')
Esempio n. 10
0
    def run(self, opts):
        require_git_master()
        self.get_website_strings()
        self.get_content_server_strings()
        self.get_user_manual_docs()
        files = self.source_files()
        qt_inputs = qt_sources()
        pot_header = self.pot_header()

        with tempfile.NamedTemporaryFile() as fl:
            fl.write('\n'.join(files))
            fl.flush()
            out = tempfile.NamedTemporaryFile(suffix='.pot', delete=False)
            out.close()
            self.info('Creating translations template...')
            subprocess.check_call(['xgettext', '-f', fl.name,
                '--default-domain=calibre', '-o', out.name, '-L', 'Python',
                '--from-code=UTF-8', '--sort-by-file', '--omit-header',
                '--no-wrap', '-k__', '--add-comments=NOTE:',
                ])
            subprocess.check_call(['xgettext', '-j',
                '--default-domain=calibre', '-o', out.name,
                '--from-code=UTF-8', '--sort-by-file', '--omit-header',
                                   '--no-wrap', '-kQT_TRANSLATE_NOOP:2', '-ktr', '-ktranslate:2',
                ] + qt_inputs)

            with open(out.name, 'rb') as f:
                src = f.read()
            os.remove(out.name)
            src = pot_header + '\n' + src
            src += '\n\n' + self.get_tweaks_docs()
            bdir = os.path.join(self.TRANSLATIONS, __appname__)
            if not os.path.exists(bdir):
                os.makedirs(bdir)
            pot = os.path.join(bdir, 'main.pot')
            # Workaround for bug in xgettext:
            # https://savannah.gnu.org/bugs/index.php?41668
            src = re.sub(r'#, python-brace-format\s+msgid ""\s+.*<code>{0:</code>',
                   lambda m: m.group().replace('python-brace', 'no-python-brace'), src)
            with open(pot, 'wb') as f:
                f.write(src)
            self.info('Translations template:', os.path.abspath(pot))
            self.upload_pot(resource='main')
            self.git(['add', os.path.abspath(pot)])

        if self.git('diff-index --cached --quiet --ignore-submodules HEAD --', use_call=True) != 0:
            self.git(['commit', '-m', 'Updated translation templates'])
            self.git('push')

        return pot
Esempio n. 11
0
    def run(self, opts):
        require_git_master()
        if not self.modified_translations:
            try:
                subprocess.check_call(['bzr', 'merge', self.BRANCH],
                                      cwd=self.LP_BASE)
            except subprocess.CalledProcessError:
                self.resolve_conflicts()
        self.check_for_errors()

        if self.modified_translations:
            subprocess.check_call(['bzr', 'commit', '-m', self.CMSG],
                                  cwd=self.LP_BASE)
        else:
            print('No updated translations available')
Esempio n. 12
0
 def pre_sub_commands(self, opts):
     require_git_master()
     require_clean_git()
Esempio n. 13
0
 def pre_sub_commands(self, opts):
     require_git_master()
     require_clean_git()
Esempio n. 14
0
    def run(self, opts):
        require_git_master()
        self.get_content_server_strings()
        self.get_user_manual_docs()
        pot_header = textwrap.dedent('''\
        # Translation template file..
        # Copyright (C) %(year)s Kovid Goyal
        # Kovid Goyal <*****@*****.**>, %(year)s.
        #
        msgid ""
        msgstr ""
        "Project-Id-Version: %(appname)s %(version)s\\n"
        "POT-Creation-Date: %(time)s\\n"
        "PO-Revision-Date: %(time)s\\n"
        "Last-Translator: Automatically generated\\n"
        "Language-Team: LANGUAGE\\n"
        "MIME-Version: 1.0\\n"
        "Report-Msgid-Bugs-To: https://bugs.launchpad.net/calibre\\n"
        "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
        "Content-Type: text/plain; charset=UTF-8\\n"
        "Content-Transfer-Encoding: 8bit\\n"

        ''') % dict(appname=__appname__,
                    version=__version__,
                    year=time.strftime('%Y'),
                    time=time.strftime('%Y-%m-%d %H:%M+%Z'))

        files = self.source_files()
        qt_inputs = qt_sources()

        with tempfile.NamedTemporaryFile() as fl:
            fl.write('\n'.join(files))
            fl.flush()
            out = tempfile.NamedTemporaryFile(suffix='.pot', delete=False)
            out.close()
            self.info('Creating translations template...')
            subprocess.check_call([
                'xgettext',
                '-f',
                fl.name,
                '--default-domain=calibre',
                '-o',
                out.name,
                '-L',
                'Python',
                '--from-code=UTF-8',
                '--sort-by-file',
                '--omit-header',
                '--no-wrap',
                '-k__',
                '--add-comments=NOTE:',
            ])
            subprocess.check_call([
                'xgettext',
                '-j',
                '--default-domain=calibre',
                '-o',
                out.name,
                '--from-code=UTF-8',
                '--sort-by-file',
                '--omit-header',
                '--no-wrap',
                '-kQT_TRANSLATE_NOOP:2',
                '-ktr',
                '-ktranslate:2',
            ] + qt_inputs)

            with open(out.name, 'rb') as f:
                src = f.read()
            os.remove(out.name)
            src = pot_header + '\n' + src
            src += '\n\n' + self.get_tweaks_docs()
            bdir = os.path.join(self.TRANSLATIONS, __appname__)
            if not os.path.exists(bdir):
                os.makedirs(bdir)
            pot = os.path.join(bdir, 'main.pot')
            # Workaround for bug in xgettext:
            # https://savannah.gnu.org/bugs/index.php?41668
            src = re.sub(
                r'#, python-brace-format\s+msgid ""\s+.*<code>{0:</code>',
                lambda m: m.group().replace('python-brace', 'no-python-brace'),
                src)
            with open(pot, 'wb') as f:
                f.write(src)
            self.info('Translations template:', os.path.abspath(pot))
            self.upload_pot(os.path.abspath(pot))

            self.git(['add', os.path.abspath(pot)])

        if self.git('diff-index --cached --quiet --ignore-submodules HEAD --',
                    use_call=True) != 0:
            self.git(['commit', '-m', 'Updated translation templates'])
            self.git('push')

        return pot
Esempio n. 15
0
    def run(self, opts):
        require_git_master()
        pot_header = textwrap.dedent('''\
        # Translation template file..
        # Copyright (C) %(year)s Kovid Goyal
        # Kovid Goyal <*****@*****.**>, %(year)s.
        #
        msgid ""
        msgstr ""
        "Project-Id-Version: %(appname)s %(version)s\\n"
        "POT-Creation-Date: %(time)s\\n"
        "PO-Revision-Date: %(time)s\\n"
        "Last-Translator: Automatically generated\\n"
        "Language-Team: LANGUAGE\\n"
        "MIME-Version: 1.0\\n"
        "Report-Msgid-Bugs-To: https://bugs.launchpad.net/calibre\\n"
        "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
        "Content-Type: text/plain; charset=UTF-8\\n"
        "Content-Transfer-Encoding: 8bit\\n"

        ''') % dict(appname=__appname__,
                    version=__version__,
                    year=time.strftime('%Y'),
                    time=time.strftime('%Y-%m-%d %H:%M+%Z'))

        files = self.source_files()
        qt_inputs = qt_sources()

        with tempfile.NamedTemporaryFile() as fl:
            fl.write('\n'.join(files))
            fl.flush()
            out = tempfile.NamedTemporaryFile(suffix='.pot', delete=False)
            out.close()
            self.info('Creating translations template...')
            subprocess.check_call([
                'xgettext',
                '-f',
                fl.name,
                '--default-domain=calibre',
                '-o',
                out.name,
                '-L',
                'Python',
                '--from-code=UTF-8',
                '--sort-by-file',
                '--omit-header',
                '--no-wrap',
                '-k__',
                '--add-comments=NOTE:',
            ])
            subprocess.check_call([
                'xgettext',
                '-j',
                '--default-domain=calibre',
                '-o',
                out.name,
                '--from-code=UTF-8',
                '--sort-by-file',
                '--omit-header',
                '--no-wrap',
                '-kQT_TRANSLATE_NOOP:2',
            ] + qt_inputs)

            with open(out.name, 'rb') as f:
                src = f.read()
            os.remove(out.name)
            src = pot_header + '\n' + src
            src += '\n\n' + self.get_tweaks_docs()
            pot = os.path.join(self.LP_PATH, __appname__ + '.pot')
            with open(pot, 'wb') as f:
                f.write(src)
            self.info('Translations template:', os.path.abspath(pot))
            self.upload_pot(os.path.abspath(pot))

        return pot