From c38b34a000395d8e5082d2b0b3dfc5e0e594f227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Wed, 3 Apr 2013 23:49:21 +0200 Subject: [PATCH] misc fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- setup.py | 40 +++++++++++++++++----------------------- src/backend.py | 2 +- src/metadata.py | 4 ++-- src/ponysay.py | 2 +- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/setup.py b/setup.py index 4eca0b90..55a705a6 100755 --- a/setup.py +++ b/setup.py @@ -421,7 +421,7 @@ class Setup(): data = data.replace('#!/usr/bin/env python3', '#!/usr/bin/env ' + env) else: data = data.replace('#!/usr/bin/env python', '#!/usr/bin/env ' + env) - data = data.replace('/usr/share/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) + data = data.replace('/usr/share/ponysay/', conf['share-dir'] + ('' if conf['share-dir'].endswith('/') else '/')) data = data.replace('/etc/', conf['sysconf-dir'] + ('' if conf['sysconf-dir'].endswith('/') else '/')) data = data.replace('\nVERSION = \'dev\'', '\nVERSION = \'%s\'' % (PONYSAY_VERSION)) @@ -429,14 +429,10 @@ class Setup(): finally: if fileout is not None: fileout.close() if filein is not None: filein .close() - try: - os.chdir('src') - print('Creating uncompressed zip file ponysay.zip with files from src: ' + ' '.join(ponysaysrc)) - with ZipFile('../ponysay.zip', 'w') as myzip: - for src in ponysaysrc: - myzip.write(src) - finally: - os.chdir('..') + print('Creating uncompressed zip file ponysay.zip with files from src: ' + ' '.join(ponysaysrc)) + with ZipFile('ponysay.zip', 'w') as myzip: + for src in ponysaysrc: + myzip.write('src/%s.install' % src, src) os.chmod('ponysay.zip', 0o755) try: fileout = open('ponysay.install', 'wb+') @@ -530,7 +526,7 @@ class Setup(): data = data.replace('/usr/bin/ponysay', conf[command]) data = data.replace('/ponysay', '\0') data = data.replace('ponysay', command) - data = data.replace('/usr/share/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) + data = data.replace('/usr/share/ponysay/', conf['share-dir'] if conf['share-dir'].endswith('/') else (conf['share-dir'] + '/')) data = data.replace('\0', '/ponysay') fileout.write(data.encode('utf-8')) @@ -992,21 +988,20 @@ class Setup(): conf['~prefix~'] = prefix if opts['--opt'] is not None: - if opts['--bin-dir'] is None: opts['--bin-dir'] = ['/opt/ponysay/bin'] - if opts['--lib-dir'] is None: opts['--lib-dir'] = ['/opt/ponysay/lib'] - if opts['--libexec-dir'] is None: opts['--libexec-dir'] = ['/opt/ponysay/libexec'] - if opts['--share-dir'] is None: opts['--share-dir'] = ['/opt/ponysay/share'] + if opts['--bin-dir'] is None: opts['--bin-dir'] = ['/opt/ponysay'] + if opts['--lib-dir'] is None: opts['--lib-dir'] = ['/opt/ponysay'] + if opts['--libexec-dir'] is None: opts['--libexec-dir'] = ['/opt/ponysay'] + if opts['--share-dir'] is None: opts['--share-dir'] = ['/opt/ponysay'] if opts['--with-shared-cache'] is None: opts['--with-shared-cache'] = ['/var/opt/ponysay/cache'] for dir in ['bin', 'lib', 'libexec', 'share']: - if opts['--' + dir + '-dir'] is not None: - d = opts['--' + dir + '-dir'][0] - if dir == 'lib': - dir += '/ponysay' - for key in conf: - if conf[key] not in [None, True, False]: - if conf[key].startswith(prefix + '/' + dir): - conf[key] = d + conf[key][5 + len(dir):] + key = dir + '-dir' + if opts['--' + key] is not None: + conf[key] = opts['--' + key][0] + if (dir == 'share') and (opts['--opt'] is None): + conf[key] += '/ponysay' + if conf[key].startswith('usr/'): + conf[key] = prefix + conf[key][3:] if opts['--cache-dir'] is not None: dir = opts['--cache-dir'][0] for key in conf: @@ -1087,7 +1082,6 @@ class Setup(): conf['man-section-' + mansection[0]] = mansection[1] - self.destDir = None if opts['--dest-dir'] is None else opts['--dest-dir'][0] return conf diff --git a/src/backend.py b/src/backend.py index 10b2c9dd..83e65624 100755 --- a/src/backend.py +++ b/src/backend.py @@ -375,7 +375,7 @@ class Backend(): self.output = self.output.replace(AUTO_PUSH, '').replace(AUTO_POP, '') - if self.balloon is not None: + if self.balloon is None: if (self.balloontop > 0) or (self.balloonbottom > 0): self.output = self.output.split('\n') self.output = self.output[self.balloontop : ~(self.balloonbottom)] diff --git a/src/metadata.py b/src/metadata.py index 74c92709..cdf01bca 100755 --- a/src/metadata.py +++ b/src/metadata.py @@ -45,9 +45,9 @@ class Metadata(): ''' @staticmethod def makeRestrictionLogic(restriction): - table = [(get_test(cell[:cell.index('=')], + table = [(get_test((cell[:cell.index('=')], cell[cell.index('=') + 1:] - ) + )) for cell in clause.lower().replace('_', '').replace(' ', '').split('+')) for clause in restriction ] diff --git a/src/ponysay.py b/src/ponysay.py index 2a365a5d..68d6655e 100755 --- a/src/ponysay.py +++ b/src/ponysay.py @@ -509,7 +509,7 @@ class Ponysay(): ponies = {} for ponydir in ponydirs: for pony in Metadata.restrictedPonies(ponydir, logic): - if (pony not in passed) and (pony in oldponies): + if pony in oldponies: # XXX and (pony not in passed) ponyfile = ponydir + pony + '.pony' if oldponies[pony] == ponyfile: ponies[pony] = ponyfile