]> git.decadent.org.uk Git - dak.git/blobdiff - alyson
Add new top level directories
[dak.git] / alyson
diff --git a/alyson b/alyson
index 831f54c4a1d2b7d385ab615c2713037869e87234..a1b75d34381f3ca66ba1c979dc86da5e1dbac9bb 100755 (executable)
--- a/alyson
+++ b/alyson
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
 # Sync the ISC configuartion file and the SQL database
-# Copyright (C) 2000, 2001, 2002  James Troup <james@nocrew.org>
-# $Id: alyson,v 1.10 2002-10-16 02:47:32 troup Exp $
+# Copyright (C) 2000, 2001, 2002, 2003  James Troup <james@nocrew.org>
+# $Id: alyson,v 1.12 2003-09-07 13:52:07 troup Exp $
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -31,6 +31,15 @@ projectB = None;
 
 ################################################################################
 
+def usage(exit_code=0):
+    print """Usage: alyson
+Initalizes some tables in the projectB database based on the config file.
+
+  -h, --help                show this help and exit."""
+    sys.exit(exit_code)
+
+################################################################################
+
 def get (c, i):
     if c.has_key(i):
         return "'%s'" % (c[i]);
@@ -41,8 +50,16 @@ def main ():
     global Cnf, projectB;
 
     Cnf = utils.get_conf()
+    Arguments = [('h',"help","Alyson::Options::Help")];
+    for i in [ "help" ]:
+       if not Cnf.has_key("Alyson::Options::%s" % (i)):
+           Cnf["Alyson::Options::%s" % (i)] = "";
+
+    apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv);
 
-    apt_pkg.ParseCommandLine(Cnf,[],sys.argv);
+    Options = Cnf.SubTree("Alyson::Options")
+    if Options["Help"]:
+       usage();
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]));
     db_access.init(Cnf, projectB);
@@ -141,14 +158,14 @@ def main ():
     for component in Cnf.SubTree("Component").List():
         if Cnf["Natalie::ComponentPosition"] == "prefix":
             suffix = "";
-            if component != 'main':
+            if component != "main":
                 prefix = component + '/';
             else:
                 prefix = "";
         else:
             prefix = "";
             component = component.replace("non-US/", "");
-            if component != 'main':
+            if component != "main":
                 suffix = '/' + component;
             else:
                 suffix = "";
@@ -156,7 +173,7 @@ def main ():
             projectB.query("INSERT INTO section (section) VALUES ('%s%s%s')" % (prefix, section, suffix));
     projectB.query("COMMIT WORK");
 
-#######################################################################################
+################################################################################
 
 if __name__ == '__main__':
     main()