mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2025-12-26 17:02:24 +01:00
fix dict access errors while running test
Signed-off-by: OMGeeky <aalaalgmx@gmail.com>
This commit is contained in:
@@ -488,7 +488,7 @@ def is_nested_type_property(t):
|
||||
|
||||
# Return True if the schema is nested
|
||||
def is_nested_type(s):
|
||||
return len(s.parents) > 0
|
||||
return len(s['parents']) > 0
|
||||
|
||||
|
||||
# convert a rust-type to something that would be taken as input of a function
|
||||
@@ -509,9 +509,9 @@ def is_pod_property(p):
|
||||
return 'format' in p or p.get('type', '') == 'boolean'
|
||||
|
||||
|
||||
def _traverse_schema_ids(s, c):
|
||||
ids = [s.id]
|
||||
used_by = s.used_by + s.parents
|
||||
def _traverse_schema_ids(s: dict, c):
|
||||
ids = [s['id']]
|
||||
used_by = s['used_by'] + s['parents']
|
||||
|
||||
seen = set() # protect against loops, just to be sure ...
|
||||
while used_by:
|
||||
@@ -522,8 +522,8 @@ def _traverse_schema_ids(s, c):
|
||||
ids.append(id)
|
||||
|
||||
oid = c.schemas[id]
|
||||
used_by.extend(oid.used_by)
|
||||
used_by.extend(oid.parents)
|
||||
used_by.extend(oid['used_by'])
|
||||
used_by.extend(oid['parents'])
|
||||
# end gather usages
|
||||
return ids
|
||||
|
||||
@@ -531,9 +531,9 @@ def _traverse_schema_ids(s, c):
|
||||
# Return sorted type names of all markers applicable to the given schema
|
||||
# This list is transitive. Thus, if the schema is used as child of someone with a trait, it
|
||||
# inherits this trait
|
||||
def schema_markers(s, c, transitive=True):
|
||||
def schema_markers(s: dict, c, transitive=True):
|
||||
res = set()
|
||||
ids = transitive and _traverse_schema_ids(s, c) or [s.id]
|
||||
ids = transitive and _traverse_schema_ids(s, c) or [s['id']]
|
||||
|
||||
has_activity = False
|
||||
for sid in ids:
|
||||
@@ -562,7 +562,7 @@ def schema_markers(s, c, transitive=True):
|
||||
if is_nested_type(s):
|
||||
res.add(NESTED_MARKER_TRAIT)
|
||||
# if len(s.used_by) + len(s.parents) > 0:
|
||||
if len(c.sta_map.get(s.id, dict())) == 0:
|
||||
if len(c.sta_map.get(s['id'], dict())) == 0:
|
||||
res.add(PART_MARKER_TRAIT)
|
||||
|
||||
if not has_activity:
|
||||
@@ -633,7 +633,7 @@ def _method_params(m, required=None, location=None):
|
||||
np['priority'] = prio
|
||||
res.append(np)
|
||||
# end for each parameter
|
||||
return sorted(res, key=lambda p: (p.priority, p.name), reverse=True)
|
||||
return sorted(res, key=lambda p: (p['priority'], p['name']), reverse=True)
|
||||
|
||||
|
||||
def _method_io(type_name, c, m, marker=None):
|
||||
@@ -671,7 +671,7 @@ def rust_copy_value_s(n, tn, p):
|
||||
# convert a schema into a property (for use with rust type generation).
|
||||
# n = name of the property
|
||||
def schema_to_required_property(s, n):
|
||||
return type(s)({'name': n, TREF: s.id, 'priority': REQUEST_PRIORITY, 'is_query_param': False})
|
||||
return type(s)({'name': n, TREF: s['id'], 'priority': REQUEST_PRIORITY, 'is_query_param': False})
|
||||
|
||||
|
||||
def is_required_property(p):
|
||||
@@ -1137,7 +1137,7 @@ def find_fattest_resource(c):
|
||||
def parts_from_params(params):
|
||||
part_prop = None
|
||||
for p in params:
|
||||
if p.name == 'part':
|
||||
if p['name'] == 'part':
|
||||
part_prop = p
|
||||
break
|
||||
# end for each param
|
||||
|
||||
Reference in New Issue
Block a user