def __init__(self, args, config, stdout=None, stdin=None): """Construct Command object.""" self.args = args self.config = config if stdout is None: self.stdout = sys.stdout else: self.stdout = stdout if stdin is None: self.stdin = sys.stdin else: self.stdin = stdin self.wlc = wlc.Weblate(config=config)
def weblate_operation(): # 首先登录 weblate weblate_key = access_token() # 获取 access key weblate = wlc.Weblate(key=weblate_key, url='https://weblate.exz.me/api') # pull、commit、push 一气呵成 pull = weblate.post('/projects/langpack/repository/', operation='pull') print('Weblate all pull!') commit = weblate.post('/projects/langpack/repository/', operation='commit') print('Weblate all commit!') push = weblate.post('/projects/langpack/repository/', operation='push') print('Weblate all push!') # 接下来返回操作情况 if pull['result'] and commit['result'] and push['result']: return True else: return False