def status(**kwargs): '''Project status''' repo = Repository() trlist = repo.get_status() exit_code = 0 if trlist is not None: not_mapped = [] print "# Mapped files:\n#" for tr in trlist: local_file = repo.get_mapped_locale(tr.get('master_file'), tr.get('iana_code')) progress = str(int(round(float(tr.get('progress'))))) + "%" if local_file is None: not_mapped.append(tr) else: print "#\t%s [%s] => %s %s" % (tr.get('master_file'), tr.get('iana_code'), local_file, progress) print "#\n# Files not mapped:\n#" for tr in not_mapped: print "#\t%s [%s] %s" % (tr.get('master_file'), tr.get('iana_code'), progress) else: print "#" print "# Nothing to report. Pull first to get a proper status." print "#" exit_code = 1 files = repo.get_changed_files() if len(files) > 0: print "#\n# Changes:\n#" for file in files: print "# \tmodified: %s" % file print "#" sys.exit(exit_code) pass
def pull(**kwargs): '''Pull available translations from server''' repo = Repository() username = kwargs.get('username') password = kwargs.get('password') if username == '' or password == '': username, password = prompt_userpw() exitVal = 0 try: translations = GLTranslations( GLProject(repo.get_project_name(), username, password)) trlist = translations.list() repo.save_status(trlist) print "#" for tr in trlist: local_file = repo.get_mapped_locale(tr.get('master_file'), tr.get('iana_code')) if local_file is None: print "# Warning: Skipping file %s (%s). Map local file first\n# e.g. with command: gl map-locale %s %s %s.\n# You can also force download files \ to their default locations with parameter --force" % ( tr.get('master_file'), tr.get('iana_code'), tr.get('master_file'), tr.get('iana_code'), tr.get('filename')) print "#" continue translations.save_translation_file( tr.get('master_file'), tr.get('iana_code'), repo.relative_to_root(local_file)) print "# Translation file %s updated" % local_file print "#" except: print traceback.format_exc() print "#" print "# Project is empty" print "#" exitVal = 1 sys.exit(exitVal)
def pull(**kwargs): '''Pull available translations from server''' repo = Repository(); username = kwargs.get('username') password = kwargs.get('password') if username == '' or password == '': username, password = prompt_userpw() exitVal = 0 try: translations = GLTranslations(GLProject(repo.get_project_name(), username, password)) trlist = translations.list() repo.save_status(trlist) print "#" for tr in trlist: local_file = repo.get_mapped_locale(tr.get('master_file'), tr.get('iana_code')) if local_file is None: print "# Warning: Skipping file %s (%s). Map local file first\n# e.g. with command: gl map-locale %s %s %s.\n# You can also force download files \ to their default locations with parameter --force" % (tr.get('master_file'), tr.get('iana_code'), tr.get('master_file'), tr.get('iana_code'), tr.get('filename')) print "#" continue translations.save_translation_file(tr.get('master_file'), tr.get('iana_code'), repo.relative_to_root(local_file)) print "# Translation file %s updated" % local_file print "#" except: print traceback.format_exc() print "#" print "# Project is empty" print "#" exitVal = 1 sys.exit(exitVal)