From ff5cbb3bf410276fbe5af8cc966ac363e448970c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 10 Mar 2015 15:12:26 +0100 Subject: [PATCH] fix(api-versions): ignore beta/alpha,assure latest There were a few bugs in the generator program, which caused old versions to be picked up, and alphas/betas --- Makefile | 1 - etc/api/api-list.yaml | 48 +++++++++++++++++----------------- etc/bin/api_version_to_yaml.py | 25 +++++++++++++----- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 8ba21e25d0c..9cb0311b203 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,6 @@ regen-apis: clean-apis apis license clean: clean-apis -rm -Rf $(VENV_DIR) -rm $(API_DEPS) - -rm $(API_LIST) update-json: etc/bin/update-json.sh $(GOOGLE_GO_APIS_REPO) etc/api diff --git a/etc/api/api-list.yaml b/etc/api/api-list.yaml index 247fcd7cc85..7166932a7ab 100644 --- a/etc/api/api-list.yaml +++ b/etc/api/api-list.yaml @@ -1,22 +1,22 @@ # DO NOT EDIT !!! -# File created from 'etc/bin/api_version_to_yaml.py etc/api etc/api/api-list.yaml etc/api/api-list.yaml' +# Created by 'etc/bin/api_version_to_yaml.py etc/api etc/api/api-list.yaml etc/api/api-list.yaml' # DO NOT EDIT !!! api: list: adexchangebuyer: - - v1.2 + - v1.3 adexchangeseller: - - v1 + - v2.0 admin: - - directory_v1 + - reports_v1 adsense: - - v1.2 + - v1.4 adsensehost: - v4.1 analytics: - - v2.4 + - v3 androidpublisher: - - v1 + - v2 appsactivity: - v1 appstate: @@ -28,13 +28,13 @@ api: bigquery: - v2 blogger: - - v2 + - v3 books: - v1 calendar: - v3 civicinfo: - - us_v1 + - v2 cloudlatencytest: - v2 cloudmonitoring: @@ -52,11 +52,11 @@ api: dataflow: - v1b4 datastore: - - v1beta1 + - v1beta2 deploymentmanager: - v2beta1 dfareporting: - - v1 + - v2.0 discovery: - v1 dns: @@ -66,11 +66,11 @@ api: doubleclicksearch: - v2 drive: - - v1 + - v2 fitness: - v1 freebase: - - v1 + - v1sandbox games: - v1 gamesconfiguration: @@ -80,7 +80,7 @@ api: gan: - v1beta1 genomics: - - v1beta + - v1beta2 gmail: - v1 groupsmigration: @@ -94,43 +94,43 @@ api: manager: - v1beta2 mapsengine: - - exp2 + - v1 mirror: - v1 oauth2: - - v1 + - v2 pagespeedonline: - - v1 + - v2 plus: - v1 plusdomains: - v1 prediction: - - v1.2 + - v1.6 pubsub: - - v1beta1 + - v1beta2 qpxexpress: - v1 replicapool: - - v1beta1 + - v1beta2 replicapoolupdater: - v1beta1 reseller: - - v1 + - v1sandbox resourceviews: - - v1beta1 + - v1beta2 siteverification: - v1 spectrum: - v1explorer sqladmin: - - v1beta1 + - v1beta4 storage: - v1 tagmanager: - v1 taskqueue: - - v1beta1 + - v1beta2 tasks: - v1 translate: diff --git a/etc/bin/api_version_to_yaml.py b/etc/bin/api_version_to_yaml.py index 47196be4043..debae466df9 100755 --- a/etc/bin/api_version_to_yaml.py +++ b/etc/bin/api_version_to_yaml.py @@ -23,21 +23,32 @@ raise ValueError("Directory '%s' not accessible" % api_base) yaml_path = sys.argv[2] -if not isfile(yaml_path): - raise ValueError("Didn't find yaml data at '%s'" % yaml_path) +if isfile(yaml_path): + api_data = yaml.load(open(yaml_path, 'r'))['api']['list'] +else: + api_data = dict() -api_data = yaml.load(open(yaml_path, 'r'))['api']['list'] + for api_name in sorted(os.listdir(api_base)): api_path = join(api_base, api_name) if not isdir(api_path): continue - last_version = list(sorted(v for v in os.listdir(api_path) if isdir(join(api_path, v)))) - if not last_version: + all_versions = sorted((v for v in os.listdir(api_path) if isdir(join(api_path, v))), reverse=True) + if not all_versions: continue - versions = api_data.get('api_name', list()) + last_version = None + for v in all_versions: + if 'beta' not in v and 'alpha' not in v: + last_version = v + break + # end for each version + if last_version is None: + last_version = all_versions[0] + + versions = api_data.get(api_name, list()) if last_version not in versions: - versions.append(last_version[0]) + versions.append(last_version) api_data[api_name] = list(sorted(versions)) # end for each item in api-base