/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
 
# repo name, set by late_init() to an instance of Repo
33
 
repo = 'home'
 
31
# main repo
 
32
repo = None
34
33
 
35
 
# verbose level
36
 
verbose = 0
 
34
# verbose?
 
35
verbose = False
37
36
 
38
37
# data directory
39
38
dir = '~/.stdhome'
40
39
 
41
 
# fully qualified data dir
42
 
full_dir = util.canonicalise_path( dir )
43
 
 
44
 
# metadata directory
45
 
mddir = os.path.join( dir, '.metadata' )
46
 
 
47
 
# fully qualified metadata directory
48
 
full_mddir = util.canonicalise_path( mddir )
49
 
 
50
 
# home directory
51
 
home_dir = '~/'
52
 
 
53
 
# fully qualified home directory, set by late_init()
54
 
full_home_dir = None
55
 
 
56
 
# config file
57
 
config_file = os.path.expanduser( '~/.stdhomerc' )
58
 
 
59
 
 
60
 
def late_init():
61
 
 
62
 
        global home_dir, full_home_dir
63
 
        full_home_dir = util.canonicalise_path( home_dir )
64
 
 
 
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 ):
65
51
        global repo
66
52
        from repo import Repo
67
 
        if isinstance( repo, Repo ):
68
 
                raise RuntimeError( 'logic error: the.repo is already set' )
69
 
        repo = Repo( repo )
 
53
        repo = Repo( repo_name if repo_name else 'home' )
 
54