From a178af925ed2072f3986000a4e19a529d96e568c Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 19 Jun 2011 09:10:16 +0100 Subject: Add clean command, and don't panic if setup.py does not exist. --- unperish | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/unperish b/unperish index 8d1089e..d882ef7 100755 --- a/unperish +++ b/unperish @@ -143,6 +143,17 @@ class Unperish(cliapp.Application): dsc] self.runcmd(*argv, cwd=self.settings['build-area']) + def cmd_clean(self, args): + '''Clean up the build-area (remove everything except the dir).''' + area = self.settings['build-area'] + if os.path.isdir(area): + for x in os.listdir(area): + pathname = os.path.join(area, x) + if os.path.isdir(x): + shutil.rmtree(x) + else: + os.remove(x) + def add_debian_changelog_entry(self): target = self.settings['upload-target'] self.runcmd('dch', @@ -160,13 +171,14 @@ class Unperish(cliapp.Application): return cp def autofill_meta(self): - name = self.runcmd('python', 'setup.py', '--name').strip() - if name: - self.meta.set('project', 'name', name) - - version = self.runcmd('python', 'setup.py', '--version').strip() - if version: - self.meta.set('project', 'version', version) + if os.path.exists('setup.py'): + name = self.runcmd('python', 'setup.py', '--name').strip() + if name: + self.meta.set('project', 'name', name) + + version = self.runcmd('python', 'setup.py', '--version').strip() + if version: + self.meta.set('project', 'version', version) def read_meta(self): self.meta.read([self.metafilename]) -- cgit v1.2.1