Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35bd1c3

Browse files
committed
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
1 parent 3b7e63f commit 35bd1c3

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

etc/bin/update-json.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ api_base=${2:?Second argument must be the destination path to which to copy the
55

66
(cd ${repo_path} && git pull --ff-only) || exit $?
77

8-
for json_path in `cd ${repo_path} && find . -type f -name "*-api.json"`; do
8+
for json_path in `cd ${repo_path} && find . -type f -name "*-api.json" -or -name "*-gen.go"`; do
99
dest=${api_base}/`dirname ${json_path}`
1010
mkdir -p ${dest} || exit $?
1111
cp ${repo_path}/${json_path} ${dest} || exit $?

src/mako/lib.rs.mako

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl<'a, C, NC, A> ${hub_type}${ht_params}
111111
${schema.new(s, c)}
112112
% endfor
113113

114+
% if nested_schemas:
114115
// ###################
115116
// NESTED SCHEMAS ###
116117
// #################
@@ -119,6 +120,7 @@ ${schema.new(s, c)}
119120
% for s in nested_schemas:
120121
${schema.new(s, c)}
121122
% endfor
123+
% endif
122124

123125
// ###################
124126
// MethodBuilders ###

src/mako/lib/util.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,7 @@ def schema_markers(s, c):
372372
# return (name, method)
373373
def activity_split(fqan):
374374
t = fqan.split('.')
375-
assert len(t) == 3
376-
return t[1:]
375+
return t[1], '.'.join(t[2:])
377376

378377
# Shorthand to get a type from parameters of activities
379378
def activity_rust_type(p, allow_optionals=True):
@@ -535,10 +534,14 @@ def new_context(resources):
535534
# A: { SchemaTypeName -> { fqan -> ['request'|'response', ...]}
536535
# B: { fqan -> activity_method_data }
537536
# fqan = fully qualified activity name
538-
def build_activity_mappings(activities):
539-
res = dict()
540-
fqan = dict()
537+
def build_activity_mappings(activities, res = None, fqan = None):
538+
if res is None:
539+
res = dict()
540+
if fqan is None:
541+
fqan = dict()
541542
for an, a in activities.iteritems():
543+
if 'resources' in a:
544+
build_activity_mappings(a.resources, res, fqan)
542545
if 'methods' not in a:
543546
continue
544547
for mn, m in a.methods.iteritems():
@@ -648,7 +651,7 @@ def scope_url_to_variant(name, url, fully_qualified=True):
648651
FULL = 'Full'
649652
fqvn = lambda n: fully_qualified and 'Scope::%s' % n or n
650653
base = os.path.basename(url)
651-
# special case, which works for now ...
654+
# special case, which works for now ... https://mail.gmail.com
652655
if not base.startswith(name):
653656
return fqvn(FULL)
654657
base = base[len(name):]

0 commit comments

Comments
 (0)