summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Ulrich Niedermann <hun@n-dimensional.de>2008-02-13 14:44:25 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2008-02-13 14:44:25 +0100
commitfac01aae34559b33796105b293987c4a1dcbabf9 (patch)
tree0bd41c856c38262d42a85f3da81ef6b219bcdef7
parentf3a330021747c412714804266f93b064c2793d2f (diff)
downloadndim-git-utils-fac01aae34559b33796105b293987c4a1dcbabf9.tar.gz
ndim-git-utils-fac01aae34559b33796105b293987c4a1dcbabf9.tar.xz
ndim-git-utils-fac01aae34559b33796105b293987c4a1dcbabf9.zip
Cosmetics
-rw-r--r--nbb/nbb_lib.in35
1 files changed, 24 insertions, 11 deletions
diff --git a/nbb/nbb_lib.in b/nbb/nbb_lib.in
index 2345eb6..65a95c6 100644
--- a/nbb/nbb_lib.in
+++ b/nbb/nbb_lib.in
@@ -1,11 +1,5 @@
-import sys
-import os
-import getopt
-
-import subprocess
-import urlparse
-
-"""nbb_lib - moo
+"""\
+nbb_lib - moo
TODO:
* VCS config support ('git config', etc.)
@@ -22,6 +16,13 @@ TODO:
* run custom (make) commands
"""
+import sys
+import os
+import getopt
+
+import subprocess
+import urlparse
+
########################################################################
# Utility functions
@@ -29,6 +30,7 @@ TODO:
def prog_stdout(call_list):
+ """Run program and return stdout (similar to shell backticks)"""
p = subprocess.Popen(call_list,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
@@ -37,6 +39,7 @@ def prog_stdout(call_list):
class ProgramRunError(Exception):
+ """A program run returns a retcode != 0"""
def __init__(self, call_list, retcode, cwd=None):
self.call_list = call_list
self.retcode = retcode
@@ -52,6 +55,7 @@ class ProgramRunError(Exception):
def prog_run(call_list):
+ """Run program showing its output. Raise exception if retcode != 0."""
print "RUN:", call_list
print " in", os.getcwd()
return None
@@ -63,6 +67,7 @@ def prog_run(call_list):
class AbstractConfig(object):
+ """Return static config until we implement real config reading"""
def __init__(self, srcdir, nick):
self.srcdir = srcdir
self.nick = nick
@@ -117,6 +122,13 @@ class BSSourceTree(object):
return "BS-Source-Tree(%s, %s)" % (self.bs_name,
repr(self.tree_root()))
+ # Abstract methods
+ def tree_root(self): raise NotImplementedError()
+ def init(self): raise NotImplementedError()
+ def configure(self): raise NotImplementedError()
+ def build(self): raise NotImplementedError()
+ def install(self): raise NotImplementedError()
+
class AutomakeSourceTree(BSSourceTree):
bs_name = 'automake'
@@ -201,7 +213,7 @@ class VCSourceTree(object):
__metaclass__ = VCSourceTreeMeta
def detect(cls, srcdir):
- """Find VCS tree type and return it"""
+ """Detect VCS tree type and return object representing it"""
if len(VCSourceTree.plugins) < 1:
raise "No VC source tree classes registered"
def check_class(klass):
@@ -220,9 +232,11 @@ class VCSourceTree(object):
detect = classmethod(detect)
def get_config(self):
+ """Get configuration object which determines builddir etc"""
return AbstractConfig(self.tree_root(), self.branch_name())
def tree_root(self):
+ """Get absolute path to source tree root"""
raise NotImplementedError()
def branch_name(self):
@@ -322,8 +336,7 @@ def main(argv):
idx = prog.rfind('/')
if idx >= 0:
prog = prog[idx+1:]
- optlist, args = getopt.getopt(argv[1:], 'hV', [
- 'help', 'version'])
+ optlist, args = getopt.getopt(argv[1:], 'hV', ['help', 'version'])
for opt, arg in optlist:
if opt in ('-h', '--help'):
print "Usage: %(prog)s" % locals()