seomoz / shovel

Rake, for Python
MIT License
660 stars 49 forks source link

Fails to recognize arguments #1

Closed weiser closed 12 years ago

weiser commented 12 years ago

I've the following task:

@task def findArchivedSeries(fn="hi", i="mom"): '''filename is a file which contains a list of series ids (one series id per line). It prints out series which are considered by the custom crawler to be archived, but should be active according to CMOZ.''' print fn, i

I then run:

dave@dave-laptop:~/attercob (cc415)$ shovel status.findArchivedSeries --fn hvhv --i lyufg

I get an error:

[ERROR] Failed to run task findArchivedSeries Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/shovel/init.py", line 227, in call f(_args, *_kwargs) TypeError: findArchivedSeries() got multiple values for keyword argument 'i'

I'm using shovel=0.1.3

dlecocq commented 12 years ago

Should be resolved now. The problem stems from the fact that there were defaults provided, and the verbose syntax was used on the command line. When that syntax is used, the values are supplied as part of the kwargs dictionary-style arguments, and the defaults are provided in the function. The solution was to go through the arguments at evaluation time, and if there is a corresponding name is provided in kwargs, then that is used.

What was essentially getting called in the above was:

def f(a=1, b=2):
    print a, b

f(*[1, 2], **{'a': 3, 'b': 4})