Skip to content

Commit

Permalink
Now handling lists of entities as attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mw44118 committed Sep 27, 2009
1 parent 1247bf9 commit fc00a83
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 13 deletions.
26 changes: 26 additions & 0 deletions pitz/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,29 @@ def pitz_add_status():
proj.append(s)
print("Added %s to the project." % s.summarized_view)
proj.save_entities_to_yaml_files()


def pitz_destroy():

p = setup_options()
p.add_option('-t', '--title', help='Status title')

options, args = p.parse_args()

if options.version:
print_version()

pitzdir = Project.find_pitzdir(options.pitzdir)

proj = Project.from_pitzdir(pitzdir)
proj.find_me()

e = proj[args[0]]

if isinstance(e, Entity):

e.self_destruct(proj)

print("""Entity %(frag)s: "%(title)s" is no longer part of the project.""" % e)

proj.save_entities_to_yaml_files()
9 changes: 8 additions & 1 deletion pitz/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ def replace_pointers_with_objects(self):
In other words, replace the uuid "matt" with the object that
has "matt" as its uuid.
Also works when the values are lists and tuples of UUIDs.
"""

if not self.project:
Expand All @@ -542,6 +544,9 @@ def replace_pointers_with_objects(self):
if isinstance(val, uuid.UUID):
self[attr] = self.project.by_uuid(val)

if isinstance(val, (list, tuple)):
self[attr] = [self.project.by_uuid(x) for x in val]

self.update_modified_time = True
return self

Expand All @@ -560,6 +565,9 @@ def replace_objects_with_pointers(self):
for attr, val in self.items():
self[attr] = getattr(val, 'uuid', val)

if isinstance(val, (tuple, list)):
self[attr] = [getattr(e, 'uuid', e) for e in val]

self.update_modified_time = True
return self

Expand Down Expand Up @@ -848,7 +856,6 @@ class Task(Entity):
status=lambda proj: Status(proj, title='unstarted'),
estimate=lambda proj: Estimate(proj, title='not estimated'),
components=lambda proj: list(),
comments=lambda proj: list(),
)


Expand Down
14 changes: 14 additions & 0 deletions pitzdir/comment-fbc127a3-2224-4034-860f-e0b24a8efacd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
created_by: &id001 !!python/object:uuid.UUID
int: 217356799640352244068158184369341070513
created_time: 2009-09-26 21:53:21.286160
description: ''
entity: !!python/object:uuid.UUID
int: 213698503728120633235772951478161491030
modified_time: 2009-09-26 21:53:21.304776
pscore: 0
title: This oughtta be easy
type: comment
uuid: !!python/object:uuid.UUID
int: 334639144174442452935173160871585053389
who_said_it: *id001
yaml_file_saved: 2009-09-26 21:56:51.855341
11 changes: 11 additions & 0 deletions pitzdir/component-8041326b-791a-4980-8c78-779da99372ac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
created_by: !!python/object:uuid.UUID
int: 217356799640352244068158184369341070513
created_time: 2009-09-26 21:59:25.949294
description: ''
modified_time: 2009-09-26 21:59:25.952044
pscore: 0
title: data model
type: component
uuid: !!python/object:uuid.UUID
int: 170479705391647032501098302123768246956
yaml_file_saved: 2009-09-26 22:08:12.813295
12 changes: 12 additions & 0 deletions pitzdir/milestone-d4065a87-0fa0-42d3-b4a4-4eade0473646.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
created_by: !!python/object:uuid.UUID
int: 217356799640352244068158184369341070513
created_time: 2009-09-26 19:03:46.900475
description: Nice-to-have features will get added here.
modified_time: 2009-09-26 19:03:46.903507
pscore: 0
reached: false
title: '1.1'
type: milestone
uuid: !!python/object:uuid.UUID
int: 281829325005055660957328011118288254534
yaml_file_saved: 2009-09-26 19:03:47.310944
23 changes: 23 additions & 0 deletions pitzdir/task-3181ae38-fff9-4230-84cf-06ab8ac6f111.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
comments: []
components: []
created_by: !!python/object:uuid.UUID
int: 217356799640352244068158184369341070513
created_time: 2009-09-26 18:44:20.410711
description: 'A task can be linked to many components, so this is a little different
than linking a task to an estimate or a status or anything where it can
be linked to only one entity of that type.'
estimate: !!python/object:uuid.UUID
int: 194238884256655928753821602839070306529
milestone: !!python/object:uuid.UUID
int: 286057988816149038667284962231564097114
modified_time: 2009-09-26 18:44:20.413389
pscore: 0
status: !!python/object:uuid.UUID
int: 327359014471868074244219043980996376403
title: Ask about components during pitz-add-task
type: task
uuid: !!python/object:uuid.UUID
int: 65805511743480019330552147231377912081
yaml_file_saved: 2009-09-26 18:44:20.414121
66 changes: 62 additions & 4 deletions pitzdir/task-a0c4d5b1-8684-4b2c-a66a-3de346d9c456.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
comments: []
components: []
components:
- !!python/object/new:pitz.entity.Component
dictitems:
created_by: !!python/object/new:pitz.entity.Person
dictitems:
abbr: matt
abc: &id002 !!python/tuple
- 1
- 2
- 3
comments: &id003 []
created_time: &id004 2009-03-10 22:25:32.240143
description: ''
email: matt@tplus1.com
frag: a38565
html_file_saved: &id001 2009-09-26 18:21:54.697138
modified_time: *id001
pscore: 0
title: W. Matthew Wilson
type: person
uuid: &id005 !!python/object:uuid.UUID
int: 217356799640352244068158184369341070513
yaml_file_saved: &id006 2009-09-26 18:21:58.214546
state:
abbr: matt
abc: *id002
comments: *id003
created_time: *id004
description: ''
email: matt@tplus1.com
frag: a38565
html_file_saved: *id001
modified_time: *id001
pscore: 0
title: W. Matthew Wilson
type: person
uuid: *id005
yaml_file_saved: *id006
created_time: &id007 2009-09-26 21:59:25.949294
description: ''
frag: '804132'
modified_time: &id008 2009-09-26 21:59:25.952044
pscore: 0
title: data model
type: component
uuid: &id009 !!python/object:uuid.UUID
int: 170479705391647032501098302123768246956
yaml_file_saved: &id010 2009-09-26 22:08:12.813295
state:
created_by: *id005
created_time: *id007
description: ''
frag: '804132'
modified_time: *id008
pscore: 0
title: data model
type: component
uuid: *id009
yaml_file_saved: *id010
created_time: 2009-09-13 09:48:56.072090
description: 'Right now, to store a comment on a task, you gotta create a Comment
Expand All @@ -11,15 +69,15 @@ description: 'Right now, to store a comment on a task, you gotta create a Commen
'
estimate: !!python/object:uuid.UUID
int: 207205260775652781422748338617572801073
html_file_saved: &id001 2009-09-26 18:21:53.937708
html_file_saved: 2009-09-26 18:21:53.937708
milestone: !!python/object:uuid.UUID
int: 286057988816149038667284962231564097114
modified_time: *id001
modified_time: 2009-09-26 21:59:59.396191
pscore: 0
status: !!python/object:uuid.UUID
int: 327359014471868074244219043980996376403
title: Add a comment method on the Task class
type: task
uuid: !!python/object:uuid.UUID
int: 213698503728120633235772951478161491030
yaml_file_saved: 2009-09-26 18:21:58.067691
yaml_file_saved: 2009-09-26 22:08:12.817899
8 changes: 4 additions & 4 deletions pitzdir/task-a791554b-f0b7-4b6c-98bb-b48cc1d873ff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ description: 'Right now, if I delete a yaml file manually, the pickle still has
'
estimate: !!python/object:uuid.UUID
int: 207205260775652781422748338617572801073
html_file_saved: &id001 2009-09-26 18:21:55.047294
html_file_saved: 2009-09-26 18:21:55.047294
milestone: !!python/object:uuid.UUID
int: 286057988816149038667284962231564097114
modified_time: *id001
modified_time: 2009-09-26 21:51:35.668303
pscore: 0
status: !!python/object:uuid.UUID
int: 327359014471868074244219043980996376403
int: 181191650815078915740523248343325601886
title: Write a pitz-destroy script
type: task
uuid: !!python/object:uuid.UUID
int: 222735688361994991705736513514701878271
yaml_file_saved: 2009-09-26 18:21:58.299259
yaml_file_saved: 2009-09-26 21:51:35.668869
8 changes: 4 additions & 4 deletions pitzdir/task-a929ce40-2dbd-46db-96cd-5afa1e912974.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ description: 'Right now, the sort order lists the most recently created tasks in
'
estimate: !!python/object:uuid.UUID
int: 207205260775652781422748338617572801073
html_file_saved: &id001 2009-09-26 18:21:54.964678
html_file_saved: 2009-09-26 18:21:54.964678
milestone: !!python/object:uuid.UUID
int: 286057988816149038667284962231564097114
modified_time: *id001
modified_time: 2009-09-26 19:02:28.236446
pscore: 0
status: !!python/object:uuid.UUID
int: 327359014471868074244219043980996376403
int: 181191650815078915740523248343325601886
title: Append new tasks to end of milestone
type: task
uuid: !!python/object:uuid.UUID
int: 224856598719987110648762970187861404020
yaml_file_saved: 2009-09-26 18:21:58.278271
yaml_file_saved: 2009-09-26 19:02:28.237064
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
pitz-add-status = pitz.cmdline:pitz_add_status
pitz-add-estimate = pitz.cmdline:pitz_add_estimate
pitz-add-component = pitz.cmdline:pitz_add_component
pitz-destroy = pitz.cmdline:pitz_destroy
""",

test_suite = 'nose.collector',
Expand Down

0 comments on commit fc00a83

Please sign in to comment.