Mercurial > lbo > hg > async-google-apis
changeset 99:6ebd42ca8ce2
yapf
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sat, 24 Oct 2020 22:43:12 +0200 |
parents | d23accf5a6ca |
children | 42625070b740 |
files | generate/generate.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/generate/generate.py Sat Oct 24 22:42:29 2020 +0200 +++ b/generate/generate.py Sat Oct 24 22:43:12 2020 +0200 @@ -474,25 +474,28 @@ for s in services: f.write(s) + def from_cache(apiId): try: - with open(path.join('cache', apiId+'.json'), 'r') as f: + with open(path.join('cache', apiId + '.json'), 'r') as f: print('Found API description in cache for', apiId) return json.load(f) except Exception as e: print('Fetching description from cache failed:', e) return None + def to_cache(apiId, doc): try: os.makedirs('cache', exist_ok=True) - with open(path.join('cache', apiId+'.json'), 'w') as f: + with open(path.join('cache', apiId + '.json'), 'w') as f: json.dump(doc, f) except Exception as e: print(e) return None return None + def fetch_discovery_base(url, apis): """Fetch the discovery base document from `url`. Return api documents for APIs with IDs in `apis`.