def test_processFileSet(self): json = JsonBackend('testjsonbackend.json') json.load() self.assertEquals(len(json.projects), 2) self._validate_mozilla_project(json.projects[0])
def process_projects(po_directory, tmx_directory, out_directory): json = JsonBackend('../../cfg/projects/') json.load() projects = sorted(json.projects, key=lambda x: x.name.lower()) all_projects = [proj for proj in projects if proj.downloadable] softcatala_projects = [proj for proj in all_projects if proj.softcatala] memories = [] build_combined_memory(all_projects, memories, 'tots-tm.po', u'Totes les memòries de tots els projectes', po_directory, tmx_directory, out_directory) build_combined_memory(softcatala_projects, memories, 'softcatala-tm.po', u'Totes les memòries de projectes de Softcatalà', po_directory, tmx_directory, out_directory) build_invidual_projects_memory(all_projects, memories, po_directory, tmx_directory, out_directory) ctx = { 'generation_date': datetime.date.today().strftime("%d/%m/%Y"), 'memories': memories, } process_template("templates/download.mustache", "download.html", ctx)
def process_projects(po_directory, tmx_directory, out_directory): json = JsonBackend("../builder/projects.json") json.load() projects = sorted(json.projects, key=lambda x: x.name.lower()) all_projects = [proj for proj in projects if proj.downloadable] softcatala_projects = [proj for proj in all_projects if proj.softcatala] memories = [] build_combined_memory(all_projects, memories, 'tots-tm.po', u'Totes les memòries de tots els projectes', po_directory, tmx_directory, out_directory) build_combined_memory(softcatala_projects, memories, 'softcatala-tm.po', u'Totes les memòries de projectes de Softcatalà', po_directory, tmx_directory, out_directory) build_invidual_projects_memory(all_projects, memories, po_directory, tmx_directory, out_directory) ctx = { 'generation_date': datetime.date.today().strftime("%d/%m/%Y"), 'memories': memories, } process_template("templates/download.mustache", "download.html", ctx)
def process_projects(self): json = JsonBackend("../projects.json") json.load() for project_dto in json.projects: if self.projects_names: found = False for project_name in self.projects_names: project_dto_lower = project_dto.name.lower().strip() if project_name.lower().strip() == project_dto_lower: found = True if not found: continue if project_dto.selectable: self.options.append(project_dto.name) self._process_project(project_dto.name, project_dto.filename, project_dto.softcatala) self.projects += 1 print('Total sentences {0}, indexed {1}'.format(self.sentences, self.sentences_indexed)) self.writer.commit()
def check(self): """Reads the json and makes sure that for every project we have a po and a tmx that is a download published with the expected files """ json = JsonBackend("../src/projects.json") json.load() TM_ITSELF = 1 expected_files = TM_ITSELF + sum(p.downloadable is True for p in json.projects) self.downloads_for_project('tots', expected_files) expected_files = TM_ITSELF + sum(p.softcatala is True and p.downloadable is True for p in json.projects) self.downloads_for_project('softcatala', expected_files) expected_files = 1 for project_dto in json.projects: if not project_dto.downloadable: continue self.downloads_for_project(project_dto.name, expected_files) self.check_project_link(project_dto.projectweb)
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 test_processFileSet(self): folder = path.dirname(path.realpath(__file__)) json = JsonBackend(path.join(folder, 'testjsonbackend.json')) json.load() self.assertEquals(len(json.projects), 2) self._validate_mozilla_project(json.projects[0])
def process_projects(self, po_directory): json = JsonBackend("../../src/projects.json") json.load() for project_dto in json.projects: self._process_project(po_directory, project_dto.name, project_dto.filename) self.projects = self.projects + 1 self.write_statistics()
def process_projects(): json = JsonBackend("../../src/projects.json") json.load() html = u'<h1 class ="section">Baixa les memòries de traducció</h1>\r' html += u'<p>Baixeu les memòries de traducció per poder-les configurar al vostre programa de traducció habitual.</p>\r' html += u'<p>Disposem instruccions de com fer-ho ' html += u'<a href="http://www.softcatala.org/wiki/Configurar_PoEdit_amb_mem%C3%B2ries_de_traducci%C3%B3">pas a pas</a> ' html += u'amb l\'eina de traducció PoEdit.</p>\r' html += '<table border="1" cellpadding="5px" cellspacing="5px" style="border-collapse:collapse;">\r' html += '<tr>\r' html += '<th>Projecte</th>\r' html += '<th>Fitxer PO</th>\r' html += '<th>Fitxer TMX</th>\r' html += u'<th>Paraules traduïdes</th>\r' html += u'<th>Última actualització</th>\r' html += '</tr>\r' memories = {u'Totes les memòries de tots els projectes' : 'tm.po', u'Totes les memòries de projectes de Softcatalà': 'softcatala-tm.po'} for name, filename in memories.items(): html += table_row(name, '', filename) create_zipfile(po_directory, filename) create_zipfile(tmx_directory, get_tmx_file(filename)) projects = sorted(json.projects, key=lambda x: x.name.lower()) for project_dto in projects: if (project_dto.name != 'Header'): create_zipfile(po_directory, project_dto.filename) create_zipfile(tmx_directory, get_tmx_file(project_dto.filename)) html += table_row(project_dto.name, project_dto.projectweb, project_dto.filename) html += '</table>\r' today = datetime.date.today() html += '<br>\r' html += u'Data de generació d\'aquesta pàgina: ' + today.strftime("%d/%m/%Y") html += '<br>\r' return html
def process_projects(src_directory, trg_directory): json = JsonBackend("../../cfg/projects/") 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 load_projects_from_json(add_source, projects_names, projects_json, softcatala_only): json = JsonBackend(projects_json) json.load() msg = 'Projects defined in json file {0}'.format(len(json.projects)) logging.info(msg) for project_dto in json.projects: project_dto_lower = project_dto.name.lower().strip() if softcatala_only and not project_dto.softcatala: continue if projects_names: found = False for project_name in projects_names: if project_name.lower().strip() == project_dto_lower: found = True if not found: continue projects.add_project(project_dto, add_source)
def load_projects_from_json(add_source, projects_names, projects_dir, softcatala_only): json = JsonBackend(projects_dir) json.load() msg = 'Projects defined in the json directory {0}'.format(len(json.projects)) logging.info(msg) for project_dto in json.projects: project_dto_lower = project_dto.name.lower().strip() if softcatala_only and not project_dto.softcatala: continue if projects_names: found = False for project_name in projects_names: if project_name.lower().strip() == project_dto_lower: found = True if not found: continue projects.add_project(project_dto, add_source)
def load_projects_from_json(): json = JsonBackend(projects_json) json.load() global softcatala_only msg = 'Projects defined in json file {0}'.format(len(json.projects)) logging.info(msg) for project_dto in json.projects: project_dto_lower = project_dto.name.lower().strip() if softcatala_only is True and len(project_dto.softcatala) == 0: continue if projects_names: found = False for project_name in projects_names: if project_name.lower().strip() == project_dto_lower: found = True if not found: continue projects.add_project(project_dto, add_source)
def process_projects(): json = JsonBackend("projects.json") json.load() projects = sorted(json.projects, key=lambda x: x.name.lower()) for project_dto in projects: if project_dto.name != "Header": 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) is True and os.path.isfile(trg_file) is False: print "{0} is missing in the new version".format(project_dto.filename) if os.path.isfile(src_file) is False and os.path.isfile(trg_file) is True: 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 )