def process_projects(src_directory, trg_directory): json = JsonBackend("projects.json") json.load() projects = sorted(json.projects, key=lambda x: x.name.lower()) for project_dto in projects: if project_dto.downloadable: src_file = os.path.join(src_directory, project_dto.filename) trg_file = os.path.join(trg_directory, project_dto.filename) if os.path.isfile(src_file) and not os.path.isfile(trg_file): print "{0} is missing in the new version".format( project_dto.filename) if not os.path.isfile(src_file) and os.path.isfile(trg_file): print "{0} has been added in the new version".format( project_dto.filename) src_stats = POFile(src_file).get_statistics() trg_stats = POFile(trg_file).get_statistics() print "{0} project {1}: words (before), {2} words (now), delta {3}".format( project_dto.filename, src_stats, trg_stats, trg_stats - src_stats)
def get_words(potext, po_directory): full_filename = os.path.join(po_directory, potext) words = POFile(full_filename).get_statistics() if words == 0: print("Skipping empty translation memory: " + potext) return None return words
def add_comments(self): if not self.add_source: return findFiles = FindFiles() for filename in findFiles.find(self.temp_dir, '*.po'): relative = filename.replace(self.temp_dir, '') pofile = POFile(filename) if self.project_name.lower().strip() == self.name.lower().strip(): msg = 'Source: {0} from project \'{1}\'' \ .format(relative, self.project_name) else: msg = 'Source: {0} from project \'{1} - {2}\'' \ .format(relative, self.project_name, self.name) pofile.add_comment_to_all_entries(msg) pofile.calculate_localized_string_checksum(self.checksum)