summaryrefslogtreecommitdiffstats
path: root/nbb/nbb_lib.in
blob: cfe34287488ad2252acb5128bef229a26cda7001 (plain)
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
import sys
import os
from subprocess import Popen
import subprocess

class AbstractSourceTree(object):
    def __init__(self, srcdir):
        raise "Moo"

srctree_classes = []

def prog_stdout(call_list):
    p = Popen(call_list, stdout=subprocess.PIPE)
    stdout, stderr = p.communicate()
    return stdout.strip()

class GitSourceTree(object):
    def __init__(self, srcdir):
        if "true" != prog_stdout(["git", "rev-parse", "--is-inside-work-tree"]):
            raise "Not a git sourcetree"
        self.top_srcdir = os.path.join(srcdir,

srctree_classes.append(GitSourceTree)

def get_sourcetree(srcdir):
    for cls in srctree_classes:
        try:
            return cls(srcdir)
        except "Moo":
            pass
    raise "Source tree type for '%s' not detected" % (srcdir,)

class NBB(object):
    def __init__(self):
        srcdir = os.getcwd()
        self.sourcetree = get_sourcetree(srcdir)

def main(argv):
    prog = argv[0]
    idx = prog.rfind('/')
    if idx >= 0:
        prog = prog[idx+1:]
    for arg in argv[1:]:
        if arg in ('-h', '--help'):
            print "Usage: %(prog)s" % locals()
            return
        elif arg in ('-V', '--version'):
            print "%(prog)s (@PACKAGE_NAME@) @PACKAGE_VERSION@"
            return
        else:
            pass
    nbb = NBB()

if __name__ == '__main__':
    raise "This is not a library"

# Local Variables:
# mode: python
# End: