Skip to content

Commit

Permalink
feat(doit): set upload media type
Browse files Browse the repository at this point in the history
Related to #17
  • Loading branch information
Byron committed Mar 17, 2015
1 parent 91f69ff commit 33e85dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/mako/lib/mbuild.mako
Original file line number Diff line number Diff line change
Expand Up @@ -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()))));
Expand Down
7 changes: 6 additions & 1 deletion src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 33e85dd

Please sign in to comment.