Cleanup: remove pointless try/except.
[cdist.git] / cdist
diff --git a/cdist b/cdist
index da87f8473986e64d866b2ae7fc8dbe9ce3a635f1..5ba3eb4b337b76882db195d77f2890b26617aca3 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -88,7 +88,7 @@ globals = Globals()
 # Configuration
 #
 
-class Option(object):
+class Option:
     def __init__(self, key, default=None):
         self.key = key
         self.value = default
@@ -97,7 +97,7 @@ class Option(object):
         if key == self.key:
             self.value = value
 
-class BoolOption(object):
+class BoolOption:
     def __init__(self, key):
         self.key = key
         self.value = False
@@ -140,22 +140,19 @@ class Config:
             print('Template config file written to %s; please edit and try again.' % config_file, file=sys.stderr)
             sys.exit(1)
 
-        try:
-            f = open('%s/.config/cdist' % os.path.expanduser('~'), 'r')
-            while True:
-                l = f.readline()
-                if l == '':
-                    break
-
-                if len(l) > 0 and l[0] == '#':
-                    continue
-
-                s = l.strip().split()
-                if len(s) == 2:
-                    for k in self.options:
-                        k.offer(s[0], s[1])
-        except:
-            raise
+        f = open('%s/.config/cdist' % os.path.expanduser('~'), 'r')
+        while True:
+            l = f.readline()
+            if l == '':
+                break
+
+            if len(l) > 0 and l[0] == '#':
+                continue
+
+            s = l.strip().split()
+            if len(s) == 2:
+                for k in self.options:
+                    k.offer(s[0], s[1])
 
     def has(self, k):
         for o in self.options:
@@ -383,7 +380,7 @@ class Version:
 # Targets
 #
 
-class Target(object):
+class Target:
     """
     Class representing the target that we are building for.  This is exposed to cscripts,
     though not all of it is guaranteed 'API'.  cscripts may expect:
@@ -891,7 +888,7 @@ class OSXUniversalTarget(OSXTarget):
             self._copy_packages(tree, p, output_dir)
 
 class SourceTarget(Target):
-    """Build a source .tar.bz2"""
+    """Build a source .tar.bz2 and .zst"""
     def __init__(self):
         super(SourceTarget, self).__init__('source')
 
@@ -907,8 +904,12 @@ class SourceTarget(Target):
         with TreeDirectory(tree):
             name = read_wscript_variable(os.getcwd(), 'APPNAME')
             command('./waf dist')
-            p = os.path.abspath('%s-%s.tar.bz2' % (name, tree.version))
-            copyfile(p, os.path.join(output_dir, os.path.basename(devel_to_git(tree.commit, p))))
+            bz2 = os.path.abspath('%s-%s.tar.bz2' % (name, tree.version))
+            copyfile(bz2, os.path.join(output_dir, os.path.basename(devel_to_git(tree.commit, bz2))))
+            command('tar xjf %s' % bz2)
+            command('tar --zstd -cf %s-%s.tar.zst %s-%s' % (name, tree.version, name, tree.version))
+            zstd = os.path.abspath('%s-%s.tar.zst' % (name, tree.version))
+            copyfile(zstd, os.path.join(output_dir, os.path.basename(devel_to_git(tree.commit, zstd))))
 
 # @param s Target string:
 #       windows-{32,64}
@@ -982,7 +983,7 @@ def target_factory(args):
 # Tree
 #
 
-class Tree(object):
+class Tree:
     """Description of a tree, which is a checkout of a project,
        possibly built.  This class is never exposed to cscripts.
        Attributes:
@@ -1144,28 +1145,6 @@ class Tree(object):
 #
 
 def main():
-
-    commands = {
-        "build": "build project",
-        "package": "build and package the project",
-        "release": "release a project using its next version number (adding a tag)",
-        "pot": "build the project's .pot files",
-        "manual": "build the project's manual",
-        "doxygen": "build the project's Doxygen documentation",
-        "latest": "print out the latest version",
-        "test": "build the project and run its unit tests",
-        "shell": "start a shell in the project''s work directory",
-        "checkout": "check out the project",
-        "revision": "print the head git revision number",
-        "dependencies" : "print details of the project's dependencies as a .dot file"
-    }
-
-    one_of = ""
-    summary = ""
-    for k, v in commands.items():
-        one_of += "\t%s%s\n" % (k.ljust(20), v)
-        summary += k + " "
-
     parser = argparse.ArgumentParser()
     parser.add_argument('-p', '--project', help='project name')
     parser.add_argument('-c', '--checkout', help='string to pass to git for checkout')
@@ -1200,7 +1179,7 @@ def main():
     parser_test = subparsers.add_parser("test", help="build the project and run its unit tests")
     parser_test.add_argument('--no-implicit-build', help='do not build first', action='store_true')
     parser_test.add_argument('--test', help="name of test to run, defaults to all")
-    parser_shell = subparsers.add_parser("shell", help="build the project then start a shell")
+    parser_shell = subparsers.add_parser("shell", help="start a shell in the project's work directory")
     parser_checkout = subparsers.add_parser("checkout", help="check out the project")
     parser_revision = subparsers.add_parser("revision", help="print the head git revision number")
     parser_dependencies = subparsers.add_parser("dependencies", help="print details of the project's dependencies as a .dot file")