Skip to content

Instantly share code, notes, and snippets.

@nickpresta
Created August 26, 2014 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickpresta/4296c2e75cad392f351f to your computer and use it in GitHub Desktop.
Save nickpresta/4296c2e75cad392f351f to your computer and use it in GitHub Desktop.
Parsing "dict" arguments for Invoke
def parse_extra_args(extra_args):
"""Expects `extra_args` to be in the format of: key=val,key2=val,key3=val"""
if extra_args is None:
return {}
parts = extra_args.split(',')
return {k: v for k, v in (i.split('=') for i in parts)}
@task
def foo(extra_args=None):
args = parse_extra_args(extra_args)
# do stuff with args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment