refactor(CLI): better vector building

Instead of using multiple lines to add vectors up involving iterators,
I just add slices together. This should produce less, and possibly
faster machine code, with less ascii code.

Downloads tested with drive2, and are verified to be working !

Close #97
This commit is contained in:
Sebastian Thiel
2015-05-06 10:33:04 +02:00
parent f1fe6bac01
commit ef63790422
2 changed files with 8 additions and 7 deletions

View File

@@ -82,10 +82,13 @@ def new_method_context(resource, method, c):
return MethodContext(m, response_schema, params, request_value, media_params,
required_props, optional_props, part_prop)
def comma_sep_fields(fields):
return ', '.join('"%s"' % mangle_subcommand(f) for f in fields)
# Returns a string representing a string-vector of mangled names
# fields is an iterator
def field_vec(fields):
return "vec![%s]" % ', '.join('"%s"' % mangle_subcommand(f) for f in fields)
return "vec![%s]" % comma_sep_fields(fields)
def pretty(n):
return ' '.join(s.capitalize() for s in mangle_subcommand(n).split('-'))