Created
August 26, 2014 18:31
-
-
Save nickpresta/4296c2e75cad392f351f to your computer and use it in GitHub Desktop.
Parsing "dict" arguments for Invoke
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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