From 35bd1c3e9c8a6ab52068e279d8f925eea8af055d Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 10 Mar 2015 11:04:25 +0100 Subject: [PATCH] fix(resources): first recursive resource support However, this also means we need recursive builders, which is tottally unsupported for now ... . This means we have to generalize rbuild generation ... could be easy. Lets see --- etc/bin/update-json.sh | 2 +- src/mako/lib.rs.mako | 2 ++ src/mako/lib/util.py | 15 +++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/etc/bin/update-json.sh b/etc/bin/update-json.sh index b6e5c08a69..ecd247dd11 100755 --- a/etc/bin/update-json.sh +++ b/etc/bin/update-json.sh @@ -5,7 +5,7 @@ api_base=${2:?Second argument must be the destination path to which to copy the (cd ${repo_path} && git pull --ff-only) || exit $? -for json_path in `cd ${repo_path} && find . -type f -name "*-api.json"`; do +for json_path in `cd ${repo_path} && find . -type f -name "*-api.json" -or -name "*-gen.go"`; do dest=${api_base}/`dirname ${json_path}` mkdir -p ${dest} || exit $? cp ${repo_path}/${json_path} ${dest} || exit $? diff --git a/src/mako/lib.rs.mako b/src/mako/lib.rs.mako index 293449cd48..d6834e77f2 100644 --- a/src/mako/lib.rs.mako +++ b/src/mako/lib.rs.mako @@ -111,6 +111,7 @@ impl<'a, C, NC, A> ${hub_type}${ht_params} ${schema.new(s, c)} % endfor +% if nested_schemas: // ################### // NESTED SCHEMAS ### // ################# @@ -119,6 +120,7 @@ ${schema.new(s, c)} % for s in nested_schemas: ${schema.new(s, c)} % endfor +% endif // ################### // MethodBuilders ### diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index dcf10c5fe5..8bc18396fd 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -372,8 +372,7 @@ def schema_markers(s, c): # return (name, method) def activity_split(fqan): t = fqan.split('.') - assert len(t) == 3 - return t[1:] + return t[1], '.'.join(t[2:]) # Shorthand to get a type from parameters of activities def activity_rust_type(p, allow_optionals=True): @@ -535,10 +534,14 @@ def new_context(resources): # A: { SchemaTypeName -> { fqan -> ['request'|'response', ...]} # B: { fqan -> activity_method_data } # fqan = fully qualified activity name - def build_activity_mappings(activities): - res = dict() - fqan = dict() + def build_activity_mappings(activities, res = None, fqan = None): + if res is None: + res = dict() + if fqan is None: + fqan = dict() for an, a in activities.iteritems(): + if 'resources' in a: + build_activity_mappings(a.resources, res, fqan) if 'methods' not in a: continue for mn, m in a.methods.iteritems(): @@ -648,7 +651,7 @@ def scope_url_to_variant(name, url, fully_qualified=True): FULL = 'Full' fqvn = lambda n: fully_qualified and 'Scope::%s' % n or n base = os.path.basename(url) - # special case, which works for now ... + # special case, which works for now ... https://mail.gmail.com if not base.startswith(name): return fqvn(FULL) base = base[len(name):]