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("web/templates/download.mustache", "download.html", ctx)
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 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/builder/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(self): json = JsonBackend("../../cfg/projects/") 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.save_index()
def process_projects(self): json = JsonBackend("../cfg/projects/") 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.save_index()
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/builder/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 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 check(self): """Reads the json and makes sure that for every project we have the expected quality reports """ json = JsonBackend("../cfg/projects/") json.load() for project_dto in json.projects: if not project_dto.downloadable: continue self.check_links(project_dto.name.lower())
def test_processFileSet(self): projects_dir = path.dirname(path.realpath(__file__)) projects_dir += '/data/projects' json = JsonBackend(projects_dir) json.load() self.assertEquals(len(json.projects), 2) for project in json.projects: if project.name == 'Mozilla': mozilla = project self._validate_mozilla_project(mozilla)
def load_projects_ids_from_json(self): projects = [] projects_dir = '../cfg/projects/' json = JsonBackend(projects_dir) json.load() for project_dto in json.projects: if project_dto.quality_report is False: print("Skipping quality generation for: " + project_dto.name) continue projects.append(project_dto.project_id) return projects
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_dir, softcatala_only): json = JsonBackend(projects_dir) json.load() msg = 'Projects defined in the projects configuration 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(add_source, projects_names, projects_dir, softcatala_only): json = JsonBackend(projects_dir) json.load() msg = 'Projects defined in the projects configuration 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 get_projects_cfg(self): projects_dir = path.dirname(path.realpath(__file__)) projects_dir += '/../../../cfg/projects/' json = JsonBackend(projects_dir, validation = True) json.load() return json