feat(doit): set upload media type

Related to #17
This commit is contained in:
Sebastian Thiel
2015-03-17 10:39:11 +01:00
parent 91f69ffd6e
commit 33e85ddd29
2 changed files with 24 additions and 1 deletions

View File

@@ -454,6 +454,24 @@ else {
self.${api.properties.scopes}.insert(${scope_url_to_variant(name, default_scope, fully_qualified=True)}.as_slice().to_string(), ());
}
% endif
## Only one of them is going to be set, even though we generate code that doesn't care
% if media_params:
{
let protocol =\
% for mp in media_params:
% if loop.first:
if \
% else:
else if \
% endif
${mp.type.arg_name}.is_some() {
"${mp.protocol}"
}\
% endfor
else { unreachable!() };
params.push(("uploadType", protocol.to_string()));
}
% endif
url.push('?');
url.push_str(&url::form_urlencoded::serialize(params.iter().map(|t| (t.0, t.1.as_slice()))));

View File

@@ -10,6 +10,10 @@ re_linestart = re.compile('^', flags=re.MULTILINE)
re_first_4_spaces = re.compile('^ {1,4}', flags=re.MULTILINE)
re_desc_parts = re.compile("((the part (names|properties) that you can include in the parameter value are)|(supported values are ))(.*?)\.", flags=re.IGNORECASE|re.MULTILINE)
re_find_replacements = re.compile("\{\w+\}")
USE_FORMAT = 'use_format_field'
TYPE_MAP = {'boolean' : 'bool',
'integer' : USE_FORMAT,
@@ -524,7 +528,8 @@ def method_media_params(m):
except KeyError:
raise AssertionError("media upload protocol '%s' is not implemented" % pn)
p = type(m)({'name': 'media_%s',
'info': pi,
'info': pi,
'protocol': pn,
'path': proto.path,
'type': ti,
'description': ti.description,