dodo as class

49 views
Skip to first unread message

rol...@gmail.com

unread,
Sep 30, 2014, 5:35:52 AM9/30/14
to pytho...@googlegroups.com
Hello,
First of all, thanks for creating this tool: powerful task management, easy to write, easy to debug, that's great!

In order to integrate task management in my build tool, I have extended the "as an executable file" sample to obtain this "as a class" sample:

class Dodo(object):

   
def task_hello(self):
         
"""hello"""

       
def python_hello(targets):
           
with open(targets[0], "a") as output:
            output
.write("Python says Hello World!!!\n")

       
return {
           
'actions': [python_hello],
           
'targets': ["hello.txt"],
           
}

   
def run(self):
       
import inspect
        methods = dict(inspect.getmembers(self, predicate=inspect.ismethod))

        import doit
        doit.run(methods)
      


For it to work, only one line was modified with the following patch:

--- doit/loader.py    2014-09-30 10:21:27.037582200 +0200
+++ patch/loader.py    2014-09-30 10:35:22.174694600 +0200
@@ -112,7 +112,7 @@
     
for name, ref in six.iteritems(dodo_module):
 
         
# function is a task creator because of its name
-        if inspect.isfunction(ref) and name.startswith(TASK_STRING):
+        if (inspect.isfunction(ref) or inspect.ismethod(ref)) and name.startswith(TASK_STRING):
             
# remove TASK_STRING prefix from name
             task_name
= name[prefix_len:]



What's your opinion?
Is it possible to integrate this patch?

Best regards,

Ronan

Eduardo Schettino

unread,
Sep 30, 2014, 7:21:49 AM9/30/14
to python-doit
Hi Ronan,

Which python version are you using?
inspect.ismethod() is not exactly the same thing on python2 and python3.

The change seems ok, please create a pull-request on github.
And I follow up from there.

cheers,
 Eduardo


rol...@gmail.com

unread,
Sep 30, 2014, 12:10:04 PM9/30/14
to pytho...@googlegroups.com
Hi,

I'm using python 2.7

Thanks for your response, I will create a pull-request soon.


Ronan
Reply all
Reply to author
Forward
0 new messages