From 94d2159f80c2c13ef75a49fcad118d0640c5fe03 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 21 Aug 2011 19:41:33 +0100 Subject: Deduce values for upstream-name and upstream-version unless given. --- unperish | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/unperish b/unperish index 506c501..6ced5b7 100755 --- a/unperish +++ b/unperish @@ -75,6 +75,7 @@ class Unperish(cliapp.Application): 'upstream version for project') def process_args(self, args): + self.deduce_unset_settings() self.create_build_area() self.already = set() @@ -106,6 +107,27 @@ class Unperish(cliapp.Application): else: raise cliapp.AppException('unknown command %s' % subcommand) + def deduce_unset_settings(self): + + def deduce_upstream_name(): + if os.path.exists('setup.py'): + return self.runcmd(['python', 'setup.py', '--name']).strip() + return '' + + def deduce_upstream_version(): + if os.path.exists('setup.py'): + return self.runcmd(['python', 'setup.py', '--version']).strip() + return '' + + table = { + 'upstream-name': deduce_upstream_name, + 'upstream-version': deduce_upstream_version, + } + + for name in table: + if not self.settings[name]: + self.settings[name] = table[name]() + def create_build_area(self): if not os.path.exists(self.settings['build-area']): os.mkdir(self.settings['build-area']) -- cgit v1.2.1