-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import doit.globals | ||
|
||
DOIT_CONFIG = dict( | ||
verbosity=2, | ||
) | ||
|
||
|
||
def task_create(): | ||
# dependency manager is defined for all code inside the generator: | ||
dep_manager = doit.globals.Globals.dep_manager | ||
|
||
def action(ident): | ||
# assume some involved logic to define ident: | ||
ident = 42 | ||
print('Created', ident) | ||
|
||
# store for clean: | ||
return dict(created=ident) | ||
|
||
def clean(task): | ||
result = dep_manager.get_result(task.name) | ||
if result: | ||
ident = result['created'] | ||
print('Deleted', ident) | ||
|
||
# possibly forget the task, after it was cleaned: | ||
dep_manager.remove(task.name) | ||
|
||
return dict( | ||
actions=[action], | ||
clean=[clean], | ||
) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"""Simple registry of singletons.""" | ||
|
||
|
||
class Globals: | ||
"""Accessors to doit singletons. | ||
:cvar dep_manager: The doit dependency manager, holding all persistent task data. | ||
""" | ||
dep_manager = None |
This file contains 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
This file contains 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