Passing arguments by name into action.

50 views
Skip to first unread message

Franken Stein

unread,
Aug 4, 2015, 5:33:37 AM8/4/15
to python-doit
Hello again! :)

I have faced new unclear place while my investigation of 'DoIt' system.
It's flexibility impressing me at every new time! :)
I have figured that i can pass some arguments into action, also it's great to pass arguments from command line by it's names. And more than, it' great to pass arguments into actions using results from other tasks. Amazing!
But that is not the end. More amazing thing is passing arguments into actions using mixed 'params' and 'getargs' approaches with!

And here is one unclear for me place. Mb i had missed some words in documentation, so feel free to show me some doc link on my question...
Both 'params' and 'getargs' will place arguments into actions by it's names.
When i write some like:
def FirstAction( act_var ):
pass
def SecondAction( act_var ):
pass

yield {
'actions': [ FirstAction, SecondAction ],
'getargs': {
'act_var': ( 'OtherTask', 'some_var' )
}
}
i expecting that my 'act_var' will be passed into my actions by it's name. And same for 'params'.

But what if i need directly pass some arguments into action by it's name? Smth like this:
def FirstAction( act_var, direct_var_a ):
pass
def SecondAction( act_var, direct_var_b ):
pass

yield {
'actions': [
( FirstAction, ??? ),
( SecondAction, ??? )
],
'getargs': {
'act_var': ( 'OtherTask', 'some_var' )
}
}
What i have to write replacing the '???' pattern if i need direcly pass 'direct_var_a' and 'direct_var_b'?

Or mby more complex example:
def BuildFunction( target_path, sdk_path, lib_path, build_flags, target_lib, num_threads ):
pass

global_target_path = '...'
global_build_flags = '...'
yield {
'actions': [
( BuildFunction, [ global_target_path ] ),
],
'getargs': {
'sdk_path': ( 'RetrieveEnvPaths', 'sdk' ),
'lib_path': ( 'RetrieveEnvPaths', 'lib' ),
'num_threads': ( 'RetrieveCpuInfo', 'units' ),
},
'params': [
{ 'name': 'target_lib', 'short': 't', 'type': str },
]
}
Can i pass 'global_build_flags' into 'BuildFunction' directly as 'build_flags' argument?



Eduardo Schettino

unread,
Aug 4, 2015, 6:12:54 AM8/4/15
to python-doit
On Tue, Aug 4, 2015 at 5:33 PM, Franken Stein <dr.fran...@gmail.com> wrote:
Can i pass 'global_build_flags' into 'BuildFunction' directly as 'build_flags' argument?

Python functions can take positional arguments and keyword arguments. right?

    'actions': [
( BuildFunction, [], {'build_flags': global_target_path} ),
],

I checked and the docs and it do not show any example using keyword arguments.
Can you contribute a patch to the documentation?

cheers

Franken Stein

unread,
Aug 4, 2015, 7:44:29 AM8/4/15
to python-doit
I checked and the docs and it do not show any example using keyword arguments.
Can you contribute a patch to the documentation?
Ok, i'll do it.
Tnx for your help. :)
Reply all
Reply to author
Forward
0 new messages