basic python 3 port, nearly works

This commit is contained in:
Sebastian Thiel
2021-01-05 23:24:57 +08:00
parent 2573462792
commit 043f3752e6
10 changed files with 20 additions and 24 deletions

View File

@@ -168,7 +168,7 @@ ${rbuild.new(resource, c)}
// CallBuilders ###
// #################
% for resource, methods in c.rta_map.iteritems():
% for resource, methods in c.rta_map.items():
% for method in methods:
${mbuild.new(resource, method, c)}

View File

@@ -156,7 +156,7 @@ let r = hub.resource().activity(...).${api.terms.action}()
Or specifically ...
```ignore
% for an, a in c.sta_map[fr.id].iteritems():
% for an, a in c.sta_map[fr.id].items():
<% category, resource, activity = activity_split(an) %>\
let r = hub.${mangle_ident(resource)}().${mangle_ident(activity)}(...).${api.terms.action}()
% endfor

View File

@@ -154,7 +154,7 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
///
/// # Additional Parameters
///
% for opn, op in list((opn, op) for (opn, op) in parameters.iteritems() if opn not in [p.name for p in params]):
% for opn, op in list((opn, op) for (opn, op) in parameters.items() if opn not in [p.name for p in params]):
/// * *${opn}* (${op.location}-${op.type}) - ${op.description}
% endfor
% endif
@@ -336,7 +336,7 @@ ${capture(lib.test_hub, hub_type_name, comments=show_all) | hide_filter}
// into the respective structure. Some of the parts shown here might not be applicable !
// ${random_value_warning}
let mut ${rb_name} = ${request_value_type}::default();
% for spn, sp in request_value.get('properties', dict()).iteritems():
% for spn, sp in request_value.get('properties', dict()).items():
% if parts is not None and spn not in parts:
<% continue %>
% endif
@@ -896,7 +896,7 @@ if enable_resource_parsing \
% for p in media_params:
${p.description | rust_doc_sanitize, rust_doc_comment, indent_all_but_first_by(1)}
///
% for item_name, item in p.info.iteritems():
% for item_name, item in p.info.items():
/// * *${split_camelcase_s(item_name)}*: ${isinstance(item, (list, tuple)) and put_and(enclose_in("'", item)) or str(item)}
% endfor
pub fn ${upload_action_fn(api.terms.upload_action, p.type.suffix)}<${mtype_param}>(self, ${p.type.arg_name}: ${mtype_param}, mime_type: mime::Mime) -> ${rtype}

View File

@@ -110,7 +110,7 @@ impl${rb_params} ${ThisType} {
% for p in optional_props:
${property(p.name)}: Default::default(),
% endfor
% for prop_key, custom_name in api.properties.iteritems():
% for prop_key, custom_name in api.properties.items():
% if prop_key == 'scopes' and not method_default_scope(m):
<% continue %>\
% endif

View File

@@ -12,7 +12,7 @@
<% struct = 'pub struct ' + unique_type_name(s.id) %>\
% if properties:
${struct} {
% for pn, p in properties.iteritems():
% for pn, p in properties.items():
${p.get('description', 'no description provided') | rust_doc_sanitize, rust_doc_comment, indent_all_but_first_by(1)}
% if pn != mangle_ident(pn):
#[serde(rename="${pn}")]
@@ -111,7 +111,7 @@ impl ${TO_PARTS_MARKER} for ${s_type} {
/// the parts you want to see in the server response.
fn to_parts(&self) -> String {
let mut r = String::new();
% for pn, p in s.properties.iteritems():
% for pn, p in s.properties.items():
<%
mn = 'self.' + mangle_ident(pn)
rt = to_rust_type(schemas, s.id, pn, p, allow_optionals=allow_optionals)
@@ -140,7 +140,7 @@ ${s.get('description', 'There is no detailed description.')}
This type is used in activities, which are methods you may call on this type or where this type is involved in.
The list links the activity name, along with information about where it is used (one of ${put_and(enclose_in('*', IO_TYPES))}).
% for a, iot in c.sta_map[s.id].iteritems():
% for a, iot in c.sta_map[s.id].items():
<%
category, name, method = activity_split(a)
name_suffix = ' ' + split_camelcase_s(name)