Example #1
0
    def scan_source_files(self):
        source_files = []
        kid_files = []
        js_files = []
        srcdir = self.options.source_dir or get_package_name().split('.', 1)[0]
        print 'Scanning source directory', srcdir
        for root, dirs, files in os.walk(srcdir):
            if os.path.basename(root).lower() in ('cvs', '.svn'):
                continue
            for fname in files:
                name, ext = os.path.splitext(fname)
                srcfile = os.path.join(root, fname)
                if ext == '.py':
                    source_files.append(srcfile)
                elif ext == '.kid':
                    kid_files.append(srcfile)
                elif ext == '.js':
                    js_files.append(srcfile)
                else:
                    pass # do nothing
        tmp_handle, tmp_potfile = tempfile.mkstemp(
            '.pot', 'tmp', self.locale_dir)
        os.close(tmp_handle)
        potbasename = os.path.basename(tmp_potfile)[:-4]
        pygettext_options = ['-v', '-d', potbasename, \
                '-p', os.path.dirname(tmp_potfile)]
        if self.options.ascii_output:
            pygettext_options.insert(0, '-E')
        pygettext.sys.argv = [''] + pygettext_options + source_files
        pygettext.main()
        if not os.path.exists(tmp_potfile):
            raise ProgramError, 'pygettext failed'
        atexit.register(silent_os_remove, tmp_potfile)
        if kid_files and self.options.kid_support:
            self.scan_kid_files(tmp_potfile, kid_files)

        if js_files and self.options.js_support:
            self.scan_js_files(tmp_potfile, js_files)
        potfile = self.get_potfile_path()
        if os.path.isfile(potfile):
            bakfile = potfile.replace('.pot', '.bak')
            silent_os_remove(bakfile)
            os.rename(potfile, bakfile)
            print 'Backup existing file to', bakfile
        os.rename(tmp_potfile, potfile)
        print 'Message templates written to', potfile
Example #2
0
    def scan_source_files(self):
        source_files = []
        kid_files = []
        js_files = []
        srcdir = self.options.source_dir or get_package_name().split('.', 1)[0]
        print 'Scanning source directory', srcdir
        for root, dirs, files in os.walk(srcdir):
            if os.path.basename(root).lower() in ('cvs', '.svn'):
                continue
            for fname in files:
                name, ext = os.path.splitext(fname)
                srcfile = os.path.join(root, fname)
                if ext == '.py':
                    source_files.append(srcfile)
                elif ext == '.kid':
                    kid_files.append(srcfile)
                elif ext == '.js':
                    js_files.append(srcfile)
                else:
                    pass  # do nothing
        tmp_handle, tmp_potfile = tempfile.mkstemp('.pot', 'tmp',
                                                   self.locale_dir)
        os.close(tmp_handle)
        potbasename = os.path.basename(tmp_potfile)[:-4]
        pygettext_options = ['-v', '-d', potbasename, \
                '-p', os.path.dirname(tmp_potfile)]
        if self.options.ascii_output:
            pygettext_options.insert(0, '-E')
        pygettext.sys.argv = [''] + pygettext_options + source_files
        pygettext.main()
        if not os.path.exists(tmp_potfile):
            raise ProgramError, 'pygettext failed'
        atexit.register(silent_os_remove, tmp_potfile)
        if kid_files and self.options.kid_support:
            self.scan_kid_files(tmp_potfile, kid_files)

        if js_files and self.options.js_support:
            self.scan_js_files(tmp_potfile, js_files)
        potfile = self.get_potfile_path()
        if os.path.isfile(potfile):
            bakfile = potfile.replace('.pot', '.bak')
            silent_os_remove(bakfile)
            os.rename(potfile, bakfile)
            print 'Backup existing file to', bakfile
        os.rename(tmp_potfile, potfile)
        print 'Message templates written to', potfile
Example #3
0
 def clean_generated_files(self):
     potfile = self.get_potfile_path()
     silent_os_remove(potfile.replace('.pot', '.bak'))
     for fname in self.list_message_catalogs():
         silent_os_remove(fname.replace('.po', '.mo'))
         silent_os_remove(fname.replace('.po', '.back'))
Example #4
0
 def clean_generated_files(self):
     potfile = self.get_potfile_path()
     silent_os_remove(potfile.replace('.pot', '.bak'))
     for fname in self.list_message_catalogs():
         silent_os_remove(fname.replace('.po', '.mo'))
         silent_os_remove(fname.replace('.po', '.back'))