-
Notifications
You must be signed in to change notification settings - Fork 2
/
__init__.py
1372 lines (917 loc) · 32.9 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# vim: set expandtab ts=4 sw=4 filetype=python:
from __future__ import with_statement
import logging
import optparse
import os
import sys
import warnings
warnings.simplefilter('ignore', DeprecationWarning)
import clepy
import pitz
from pitz.project import Project
from pitz.entity import Component, Entity, Estimate, Milestone, \
Person, Status, Tag, Task
log = logging.getLogger('pitz.cmdline')
class PitzHelp(object):
def add_to_list_of_scripts(self, f):
if not hasattr(self, 'scripts'):
self.scripts = {}
self.scripts[f.script_name] = f.__doc__.strip() \
if f.__doc__ else 'No description'
return f
def __call__(self):
for name, description in sorted(self.scripts.items()):
print(
" %-26s %-44s"
% (name, clepy.maybe_add_ellipses(description, 44)))
pitz_help = PitzHelp()
f = pitz_help.add_to_list_of_scripts
class PitzScript(object):
"""
Got this idea from a commenter, Linus, on my blog here:
http://blog.tplus1.com/index.php/2009/10/18/help-me-rewrite-some-repetitive-scripts/
Thanks Linus!
This is the generic script class.
"""
def __init__(self, title=None, save_proj=True, script_name=None,
doc=None, **filter):
self.save_proj = save_proj
self.filter = filter
self.title = title
if script_name:
self.script_name = script_name
if doc:
self.__doc__ = doc
def handle_p(self, p):
"""
Use this to monkey with the optparse.OptionParser instance p.
For example, set a specific usage message, or add an extra
option.
"""
def handle_options_and_args(self, p, options, args):
"""
Use this to examine the options and args parsed from the
command line. Usually, at this point, scripts will make sure
they got all the right args and options.
"""
def handle_proj(self, p, options, args, proj):
"""
Do the interesting stuff of the script in here.
"""
def apply_filter_and_grep(self, p, options, args, b):
"""
Return a new bag after filtering and grepping the bag b passed
in.
"""
filter = pitz.build_filter(args)
results = b
if filter:
results = results(**filter)
if getattr(options, 'grep', False):
results = results.grep(options.grep)
return results
def setup_p(self):
p = optparse.OptionParser(version='pitz %s' % pitz.__version__)
p.add_option('-l', '--log-level',
help='DEBUG, INFO (default), WARNING, ERROR, CRITICAL',
default='INFO',
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'])
p.add_option('--pitzdir')
p.add_option(
'--pdb',
help='Drop into debugger or error',
action='store_true')
if self.__doc__:
p.epilog = self.__doc__.lstrip()
return p
@classmethod
def maybe_glue_args_together(cls, args):
"""
When a list of values is split across several elements,
this function glues them together:
>>> f = PitzScript.maybe_glue_args_together
>>> f(['tags=[a,', 'b,', 'c]'])
['tags=[a,b,c]']
Just pass through the args if nothing is split up:
>>> f(['tags=[a,b,c]'])
['tags=[a,b,c]']
Some nastier examples:
>>> f([
... 'tags=[a,', 'b,', 'c]',
... 'owner=[matt,', 'lindsey,', 'charlie]',
... ])
['tags=[a,b,c]', 'owner=[matt,lindsey,charlie]']
>>> f(['abc123', 'def456'])
['abc123', 'def456']
>>> f(['a=1', 'b=2'])
['a=1', 'b=2']
"""
if len(args) == 1:
return args
glued_args = []
prev = ""
inside_list = False
for a in args:
if '[' in a and ']' not in a:
inside_list = True
if inside_list:
prev += a
if ']' in a:
inside_list = False
if not inside_list and not prev:
glued_args.append(a)
if not inside_list and prev:
glued_args.append(prev)
prev = ""
return glued_args
def setup_options_and_args(self, p):
options, args = p.parse_args()
return options, self.maybe_glue_args_together(args)
def setup_proj(self, p, options, args):
pitzdir = Project.find_pitzdir(options.pitzdir)
pidfile = write_pidfile_or_die(pitzdir)
proj = Project.from_pitzdir(pitzdir)
log.debug("Loaded project from %s" % proj.loaded_from)
proj.pidfile = pidfile
proj.find_me()
return proj
def add_grep_option(self, p):
p.add_option('-g', '--grep',
help='Filter to entities matching a regex')
return p
@classmethod
def figure_out_colorization(cls, cli_option=None,
my_preference=None):
"""
The CLI option (if defined) trumps the setting stored in
me.yaml.
>>> PitzScript.figure_out_colorization(None, True)
True
>>> PitzScript.figure_out_colorization(False, True)
False
>>> PitzScript.figure_out_colorization(True, False)
True
>>> PitzScript.figure_out_colorization(None, False)
False
"""
if cli_option is not None:
return cli_option
else:
return my_preference
def add_view_options(self, p):
p.add_option('-c', '--color', help='Colorize output',
default=None, action='store_true')
p.add_option('--no-color', help='Do not colorize output',
action='store_false', dest='color')
p.add_option('-1', '--one-line-view', help='single line view',
dest='custom_view', action='store_const', const='one_line_view')
p.add_option('--summarized-view', help='summarized view (default)',
dest='custom_view', action='store_const', const='summarized_view')
p.add_option('--detailed-view', help='detailed view',
dest='custom_view', action='store_const', const='detailed_view')
p.add_option('--rst-detailed-view',
help='detailed view (with reST markup)',
dest='custom_view', action='store_const',
const='rst_detailed_view')
p.add_option('--rst-summarized-view',
help='summarized view (compatible with reStructuredText)',
dest='custom_view', action='store_const',
const='rst_summarized_view')
p.add_option('--verbose-view', help='verbose view (shows everything)',
dest='custom_view', action='store_const', const='verbose_view')
p.add_option('--abbr-view', help='abbreviated view',
dest='custom_view', action='store_const', const='abbr')
p.add_option('--frag-view', help='fragment view',
dest='custom_view', action='store_const', const='frag')
p.add_option('-n', '--limit', help='limit to N results',
default=0, action='store', type='int')
return p
def __call__(self):
with clepy.spinning_distraction():
p = self.setup_p()
# Call to the first specialized function.
self.handle_p(p)
options, args = self.setup_options_and_args(p)
pitz.setup_logging(getattr(logging, options.log_level))
# Call the second specialized function.
self.handle_options_and_args(p, options, args)
proj = self.setup_proj(p, options, args)
# Third special function.
if options.pdb:
clepy.into_debugger(self.handle_proj)(p, options, args, proj)
else:
self.handle_proj(p, options, args, proj)
if self.save_proj:
proj.save_entities_to_yaml_files()
os.remove(proj.pidfile)
class MyTodo(PitzScript):
"""
My todo list
"""
script_name = 'pitz-my-todo'
def handle_p(self, p):
self.add_grep_option(p)
self.add_view_options(p)
def handle_proj(self, p, options, args, proj):
if not proj.me:
print("Sorry, I don't know who you are.")
print("Use pitz-me to add yourself to the project.")
raise SystemExit
if proj.me.my_todo:
results = self.apply_filter_and_grep(
p, options, args, proj.me.my_todo)
if options.limit:
results = results[:options.limit]
clepy.send_through_pager(
results.custom_view(
options.custom_view or 'summarized_view',
self.figure_out_colorization(options.color,
proj.me.use_colorization)),
clepy.figure_out_pager(os.environ))
else:
print("I didn't find any tasks for you (%(title)s)."
% proj.me)
class PitzEverything(PitzScript):
"""
Everything in the project
"""
script_name = 'pitz-everything'
def handle_p(self, p):
self.add_grep_option(p)
self.add_view_options(p)
def handle_proj(self, p, options, args, proj):
results = self.apply_filter_and_grep(p, options, args, proj)
if self.filter:
results = results(**self.filter)
if options.limit:
results = results[:options.limit]
if self.title:
results.title = "%s: %s" % (proj.title, self.title)
clepy.send_through_pager(
results.custom_view(
options.custom_view or 'summarized_view',
self.figure_out_colorization(options.color,
proj.me.use_colorization if proj.me else None)),
clepy.figure_out_pager(os.environ))
class PitzTodo(PitzScript):
"""
List every unstarted and started task in the project.
"""
script_name = 'pitz-todo'
def handle_p(self, p):
self.add_grep_option(p)
self.add_view_options(p)
p.add_option('--by-owner', help='Group tasks by owner',
action='store_true')
def handle_proj(self, p, options, args, proj):
results = self.apply_filter_and_grep(p, options, args, proj.todo)
if options.by_owner:
results = results.order(pitz.by_whatever('xxx',
'owner', 'milestone', 'status', 'pscore'))
# I have to wait to apply the limit until AFTER I sorted the
# bag.
if options.limit:
results = results[:options.limit]
clepy.send_through_pager(
results.colorized_by_owner_view
if self.figure_out_colorization(options.color,
proj.me.use_colorization)
else results.by_owner_view,
clepy.figure_out_pager(os.environ))
else:
if options.limit:
results = results[:options.limit]
clepy.send_through_pager(
results.custom_view(
options.custom_view or 'summarized_view',
self.figure_out_colorization(
options.color,
proj.me.use_colorization if proj.me else None)),
clepy.figure_out_pager(os.environ))
class RecentActivity(PitzScript):
def handle_p(self, p):
self.add_grep_option(p)
self.add_view_options(p)
def handle_proj(self, p, options, args, proj):
results = self.apply_filter_and_grep(
p, options, args, proj.recent_activity)
if options.limit:
results = results[:options.limit]
clepy.send_through_pager(results.custom_view(
options.custom_view or 'summarized_view'),
clepy.figure_out_pager(os.environ))
def print_version():
from pitz import __version__
print(__version__)
def pid_is_running(pid):
"""
Return pid if pid is still going.
>>> import os
>>> mypid = os.getpid()
>>> mypid == pid_is_running(mypid)
True
>>> pid_is_running(1000000) == None
True
"""
try:
os.kill(pid, 0)
except OSError:
return
else:
return pid
def write_pidfile_or_die(pitzdir):
pidfile = os.path.join(pitzdir, 'pitz.pid')
if os.path.exists(pidfile):
pid = int(open(pidfile).read())
if pid_is_running(pid):
print("Sorry, found a pidfile! Kill process %s." % pid)
raise SystemExit
else:
os.remove(pidfile)
open(pidfile, 'w').write(str(os.getpid()))
return pidfile
def pitz_shell():
"""
Start an ipython session after loading in a project.
"""
p = setup_options()
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
pidfile = write_pidfile_or_die(pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj._shell_mode = True
proj.find_me()
# Everything in this dictionary will be added to the top-level
# namespace in the shell.
ns = dict([(C.__name__, C) for C in proj.classes.values()])
ns['p'] = proj
ns['send_through_pager'] = clepy.send_through_pager
ns['edit_with_editor'] = clepy.edit_with_editor
from IPython.Shell import IPShellEmbed
s = IPShellEmbed(['-colors', 'Linux'])
s(local_ns=ns)
# This stuff happens when you close the IPython session.
answer = raw_input("Write out updated yaml files? ([y]/n) ").strip()
if answer.lower() not in ['n', 'no']:
proj.to_yaml_file()
proj.to_pickle()
proj.save_entities_to_yaml_files()
# Remove the pidfile.
os.remove(pidfile)
pitz_shell.script_name = 'pitz-shell'
f(pitz_shell)
def setup_options():
p = optparse.OptionParser()
p.add_option('--pitzdir')
p.add_option('-l', '--log-level',
help='DEBUG, INFO (default), WARNING, ERROR, CRITICAL',
default='INFO',
choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'])
p.add_option('--version', action='store_true',
help='show pitz version')
return p
class PitzShow(PitzScript):
"""
Show a custom view of one entity (detailed by default)
"""
script_name = 'pitz-show'
def handle_p(self, p):
p.set_usage("%prog frag")
self.add_view_options(p)
def handle_options_and_args(self, p, options, args):
if not args:
p.print_usage()
raise SystemExit
def handle_proj(self, p, options, args, proj):
e = proj[args[0]]
if isinstance(e, Entity):
colorization = None
if proj.me:
colorization = proj.me.use_colorization
clepy.send_through_pager(
e.custom_view(
options.custom_view or 'detailed_view',
color=self.figure_out_colorization(
options.color, colorization)),
clepy.figure_out_pager(os.environ))
else:
print("Sorry, couldn't find %s" % args[0])
def pitz_html():
"""
Write out a bunch of HTML files.
"""
with clepy.spinning_distraction():
p = setup_options()
p.set_usage('%prog [options] directory')
p.add_option('--force',
help='Ignore timestamps and regenerate all files',
action='store_true',
default=False)
options, args = p.parse_args()
if options.version:
print_version()
return
if not args:
p.print_usage()
sys.exit()
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
htmldir = args[0]
proj.to_html(htmldir)
proj.todo.to_html(htmldir)
proj.milestones.to_html(htmldir)
proj.tasks.to_html(htmldir)
proj.components.to_html(htmldir)
print("Wrote %d html files out of %d entities in project."
% (
len([e for e in proj
if e.to_html_file(htmldir, options.force)]),
len(proj)))
# Record that we rebuilt all the HTML files.
proj.save_entities_to_yaml_files()
def pitz_add_milestone():
p = setup_options()
p.add_option('-t', '--title', help='Milestone title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
pidfile = write_pidfile_or_die(pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
m = Milestone(
proj,
title=options.title or raw_input("Milestone title: ").strip(),
description=clepy.edit_with_editor(
'# Milestone description goes here'),
reached=Milestone.choose_from_allowed_values('reached', False),
)
proj.append(m)
print("Added %s to the project." % m.summarized_view)
proj.save_entities_to_yaml_files()
os.remove(pidfile)
def pitz_add_person():
p = setup_options()
p.add_option('-t', '--title', help='Person title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
person = Person(
proj,
title=options.title or raw_input("Person title: ").strip(),
description=clepy.edit_with_editor('# Person description goes here'),
)
proj.append(person)
print("Added %s to the project." % person.summarized_view)
proj.save_entities_to_yaml_files()
if raw_input("Should I identify you as %(title)s? (y/N)" % person)\
.strip().lower().startswith('y'):
person.save_as_me_yaml()
print("OK, I'll recognize you as %(title)s from now on.")
def pitz_add_estimate():
p = setup_options()
p.add_option('-t', '--title', help='Estimate title')
p.add_option('--from-builtin-estimates',
action='store_true',
help='Choose from estimates I already made')
options, args = p.parse_args()
if options.version:
print_version()
raise SystemExit
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
if options.from_builtin_estimates:
print("Right now, you got %d estimates in your project."
% (proj.estimates.length))
range = Estimate.choose_estimate_range()
if range:
print("Adding...")
Estimate.add_range_of_estimates_to_project(proj, range)
proj.save_entities_to_yaml_files()
raise SystemExit
est = Estimate(
proj,
title=options.title or raw_input("Estimate title: ").strip(),
description=clepy.edit_with_editor('# Estimate description goes here'),
points=int(raw_input("Points: ").strip()),
)
proj.append(est)
print("Added %s to the project." % est.summarized_view)
proj.save_entities_to_yaml_files()
def pitz_add_component():
p = setup_options()
p.add_option('-t', '--title', help='Component title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
c = Component(
proj,
title=options.title or raw_input("Component title: ").strip(),
description=clepy.edit_with_editor(
'# Component description goes here'),
)
proj.append(c)
print("Added %s to the project." % c.summarized_view)
proj.save_entities_to_yaml_files()
def pitz_add_status():
p = setup_options()
p.add_option('-t', '--title', help='Status title')
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
s = Status(
proj,
title=options.title or raw_input("Status title: ").strip(),
description=clepy.edit_with_editor('# Status description goes here'),
)
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()
return
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("""%(frag)s: "%(title)s" is no longer part of the project."""
% e)
proj.save_entities_to_yaml_files()
def pitz_me():
"""
Pick a Person or make a new one, then save a me.yaml file.
"""
p = setup_options()
options, args = p.parse_args()
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
if proj.me:
print("You are %(title)s." % proj.me)
print("Delete this file if you want to be somebody else:")
print(os.path.join(proj.pathname, 'me.yaml'))
return
if Person.already_instantiated:
print("You may already be in pitz:")
choice = Person.choose_from_already_instantiated()
if choice:
person = choice
person.save_as_me_yaml()
print("OK, I'll recognize you as %(title)s from now on."
% person)
return
print("I'll add you to pitz.")
pitz_add_person()
def pitz_claim_task():
p = setup_options()
p.set_usage("%prog task")
options, args = p.parse_args()
if not args:
p.print_usage()
return
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
if not proj.me:
print("Sorry, I don't know who you are.")
print("Use pitz-me to add yourself to the project.")
return
t = proj[args[0]]
t.assign(proj.me)
proj.save_entities_to_yaml_files()
def pitz_assign_task():
"""
Add this task to somebody's to-do list
"""
script_name = 'pitz-assign-task'
p = setup_options()
p.set_usage("%prog task [person]")
options, args = p.parse_args()
if not args:
p.print_usage()
return
if options.version:
print_version()
return
pitzdir = Project.find_pitzdir(options.pitzdir)
proj = Project.from_pitzdir(pitzdir)
proj.find_me()
t = proj[args[0]]
if len(args) == 2:
person = proj[args[1]]
else:
person = Person.choose_from_already_instantiated()
if not person:
print("Pick somebody!")
return
t.assign(person)
proj.save_entities_to_yaml_files()
class PitzStartTask(PitzScript):
"""
Begin a task
"""
script_name = 'pitz-start-task'
def handle_p(self, p):
p.set_usage("%prog task")
p.add_option('-z', '--pause-other-tasks',
action='store_true')
p.add_option('-i', '--ignore-other-started-tasks',
action='store_true')
def handle_options_and_args(self, p, options, args):
if not args:
p.print_usage()
raise SystemExit
def handle_proj(self, p, options, args, proj):
if not proj.me:
print("Sorry, I don't know who you are.")
print("Use pitz-me to add yourself to the project.")
raise SystemExit
t = proj[args[0]]
if isinstance(t, Entity):
t.assign(proj.me)
if options.pause_other_tasks:
for tsk in proj.me.my_todo(status='started'):
tsk['status'] = Status(title='paused')
try: