def scan_source_files(self): source_files = [] kid_files = [] genshi_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 == ".html": genshi_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: if not kid: print "Kid not installed, no support for Kid templates." else: self.scan_kid_files(tmp_potfile, kid_files) if genshi_files and self.options.genshi_support: try: self.scan_genshi_files(tmp_potfile, genshi_files) except ImportError: print "Genshi not installed, no support for Genshi templates." 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
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
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
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'))
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"))