From 30d33956fb38c0bc0fb4033c8c9e431a93b1da79 Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Sat, 29 Dec 2012 21:51:29 -0500 Subject: [PATCH] examples fix -- prevent adding invalid entry to sys.path while searching for pyqtgraph added script for generating debian changelog from bzr log --- examples/initExample.py | 22 +++++++++---- tools/generateChangelog.py | 66 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 tools/generateChangelog.py diff --git a/examples/initExample.py b/examples/initExample.py index 38dd3edc..6ee9db27 100644 --- a/examples/initExample.py +++ b/examples/initExample.py @@ -1,11 +1,21 @@ ## make this version of pyqtgraph importable before any others +## we do this to make sure that, when running examples, the correct library +## version is imported (if there are multiple versions present). import sys, os -path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -path.rstrip(os.path.sep) -if 'pyqtgraph' in os.listdir(path): - sys.path.insert(0, path) ## examples adjacent to pyqtgraph (as in source) -elif path.endswith('pyqtgraph'): - sys.path.insert(0, os.path.abspath(os.path.join(path, '..'))) ## examples installed inside pyqtgraph package + +if not hasattr(sys, 'frozen'): + path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + path.rstrip(os.path.sep) + if 'pyqtgraph' in os.listdir(path): + sys.path.insert(0, path) ## examples adjacent to pyqtgraph (as in source tree) + else: + for p in sys.path: + if len(p) < 3: + continue + if path.startswith(p): ## If the example is already in an importable location, promote that location + sys.path.remove(p) + sys.path.insert(0, p) + ## should force example to use PySide instead of PyQt if 'pyside' in sys.argv: diff --git a/tools/generateChangelog.py b/tools/generateChangelog.py new file mode 100644 index 00000000..0c8bf3e6 --- /dev/null +++ b/tools/generateChangelog.py @@ -0,0 +1,66 @@ +from subprocess import check_output +import re, time + +def run(cmd): + return check_output(cmd, shell=True) + +tags = run('bzr tags') +versions = [] +for tag in tags.split('\n'): + if tag.strip() == '': + continue + ver, rev = re.split(r'\s+', tag) + if ver.startswith('pyqtgraph-'): + versions.append(ver) + +for i in range(len(versions)-1)[::-1]: + log = run('bzr log -r tag:%s..tag:%s' % (versions[i], versions[i+1])) + changes = [] + times = [] + inmsg = False + for line in log.split('\n'): + if line.startswith('message:'): + inmsg = True + continue + elif line.startswith('-----------------------'): + inmsg = False + continue + + if inmsg: + changes.append(line) + else: + m = re.match(r'timestamp:\s+(.*)$', line) + if m is not None: + times.append(m.groups()[0]) + + citime = time.strptime(times[0][:-6], '%a %Y-%m-%d %H:%M:%S') + + print "python-pyqtgraph (%s-1) UNRELEASED; urgency=low" % versions[i+1].split('-')[1] + print "" + for line in changes: + for n in range(len(line)): + if line[n] != ' ': + n += 1 + break + + words = line.split(' ') + nextline = '' + for w in words: + if len(w) + len(nextline) > 79: + print nextline + nextline = (' '*n) + w + else: + nextline += ' ' + w + print nextline + #print '\n'.join(changes) + print "" + print " -- Luke %s -0%d00" % (time.strftime('%a, %d %b %Y %H:%M:%S', citime), time.timezone/3600) + #print " -- Luke %s -0%d00" % (times[0], time.timezone/3600) + print "" + +print """python-pyqtgraph (0.9.0-1) UNRELEASED; urgency=low + + * Initial release. + + -- Luke Thu, 27 Dec 2012 02:46:26 -0500""" +