/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/the.py

  • Committer: Tim Marston
  • Date: 2014-01-05 11:51:35 UTC
  • Revision ID: tim@ed.am-20140105115135-6ses87ggwyjrxzfj
added global objects (the.repo, the.program), deployment object and implemented
init command

Show diffs side-by-side

added added

removed removed

20
20
 
21
21
 
22
22
import os
23
 
import util
24
23
 
25
24
 
26
25
# the program
29
28
# main command
30
29
command = None
31
30
 
32
 
# config
33
 
config = None
34
 
 
35
 
# repo name, set by late_init() to an instance of Repo
36
 
repo = 'home'
37
 
 
38
 
# verbose level
39
 
verbose = 0
 
31
# main repo
 
32
repo = None
 
33
 
 
34
# verbose?
 
35
verbose = False
40
36
 
41
37
# data directory
42
38
dir = '~/.stdhome'
43
39
 
44
 
# fully qualified data dir
45
 
full_dir = util.canonicalise_path( dir )
46
 
 
47
 
# metadata directory
48
 
mddir = os.path.join( dir, '.metadata' )
49
 
 
50
 
# fully qualified metadata directory
51
 
full_mddir = util.canonicalise_path( mddir )
52
 
 
53
 
# home directory
54
 
home_dir = '~/'
55
 
 
56
 
# fully qualified home directory, set by late_init()
57
 
full_home_dir = None
58
 
 
59
 
# config file
60
 
config_file = os.path.expanduser( '~/.stdhomerc' )
61
 
 
62
 
 
63
 
def late_init():
64
 
 
65
 
        global home_dir, full_home_dir
66
 
        full_home_dir = util.canonicalise_path( home_dir )
67
 
        if verbose >= 2: print "home-dir at " + home_dir
68
 
 
 
40
# expanded data dir
 
41
expanded_dir = os.path.expanduser( dir )
 
42
 
 
43
# filesystem dir
 
44
fsdir = '~/'
 
45
 
 
46
# expanded filesystem dir
 
47
expanded_fsdir = os.path.expanduser( fsdir )
 
48
 
 
49
 
 
50
def set_repo( repo_name ):
69
51
        global repo
70
 
        if repo is not None:
71
 
                from repo import Repo
72
 
                repo = Repo( repo )
73
 
                if verbose >= 2: print "repo at " + repo.dir
74
 
                repo.detect_vcs()
 
52
        from repo import Repo
 
53
        repo = Repo( repo_name if repo_name else 'home' )
 
54