Created
October 6, 2014 12:57
-
-
Save devnull255/d040b643d43add946c04 to your computer and use it in GitHub Desktop.
Return a dictionary from list of key=value strings
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_keywords(keywords): | |
""" | |
Returns a dictionary for valid key=value strings | |
""" | |
d = {} | |
try: | |
d = dict([x.split('=',1) for x in keywords]) | |
except ValueError,e: | |
for kw in keywords: | |
if '=' not in kw: | |
print "Keyword: %s is invalid" % kw | |
print "All keywords should be formatted as key=value." | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment