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(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 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)