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
|
#!/usr/bin/python
# Copyright 2008 (C) Canonical Ltd.
import os
import sys
import locale
from gettext import gettext as _
import gettext
from fiveaday import bzr, files, parser, signature
def main():
gettext.textdomain("5-a-day")
args = parser.parse_args()
username = files.get_lpid()
if not username:
return 102 #102: username not defined
if args[0] == "--update":
err = bzr.update_branch()
if err:
# stop if creating/updating branch was not successful
print >> sys.stderr, _("bzr failed with error code"), err
return 103 #103: error while updating bzr branch
return signature.update(args[1:])
if args[0] == "--add":
if not os.path.exists(files.local_branch()):
bzr.update_branch()
return bzr.add(args[1:])
if args[0] in ["--add-tag", "--remove-tag"]:
files.modify_tags(args)
if args[0] in ["--add-team", "--remove-team"]:
if files.modify_teams(args):
bzr.add_if_not_in_inventory(files.local_branch(),
os.path.basename(files.team_file()))
bzr.commit_changes(force=True)
return 0
return 1
if args[0] in ["--show-team", "--show-teams"]:
files.show_teams()
sys.exit(0)
if args[0] in ["--show-tag", "--show-tags"]:
files.show_tags()
sys.exit(0)
if __name__ == "__main__":
sys.exit(main())
|