Try using __all__

 

utils.py:

__all__ = ['which']

 

frobnosticate.py:

__all__ = ['frobber']

 

http://docs.fabfile.org/en/1.3.3/usage/tasks.html?highlight=__all__

 

You really don't even need the __all__ in the utils.py.

 

fabfile/__init__.py:

 

import frobnosticate

import utils

 

fabfile/utils.py:

 

from fabric.api import *

 

@task

def which():

    pass

 

fabfile/frobnosticate.py:

 

from fabric.api import *

from test import which

 

__all__ = ['frobber']

 

@task

def frobber():

    which()

 

 

loki:fabtest stha3155$ fab -l

Available commands:

 

    frobnosticate.frobber

    utils.which

 

 

From: [email protected]
[mailto:[email protected]]
On Behalf Of VanL
Sent: Monday, December 19, 2011 1:34 PM
To: [email protected]
Subject: [Fab-user] Exposed tasks via @task

 

Is there a way to limit tasks to the context in which they are exposed?
For example, I like to build up a number of subfunctions that may be
individually useful, mark them as @tasks, and then have higher-level
tasks that use a number of these subfunctions to perform some scripted
action. If the subfunction task is imported from another module, it
results in the task name being repeated in both contexts. For example:

fabfile.py/
  /__init__.py
  /utils.py # defines "which"
  /frobnosticate.py # imports "which" from utils and uses it in the
function "frobber"


fab -l
  utils.which
  frobnosticate.frobber
  frobnosticate.which

In this case, frobnosticate.which *is* utils.which. Is it possible to
keep tasks marked by the @task decorator to the context in which they
are defined?

Thanks,

Van



_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to