diff --git a/conf.py b/conf.py index a84c999..7a6aef2 100644 --- a/conf.py +++ b/conf.py @@ -41,8 +41,8 @@ master_doc = 'index' # General information about the project. -project = u'py_sonicvisualiser' -copyright = u'2014, David Doukhan' +project = 'py_sonicvisualiser' +copyright = '2014, David Doukhan' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -193,8 +193,8 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'py_sonicvisualiser.tex', u'py\\_sonicvisualiser Documentation', - u'David Doukhan', 'manual'), + ('index', 'py_sonicvisualiser.tex', 'py\\_sonicvisualiser Documentation', + 'David Doukhan', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -223,8 +223,8 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'py_sonicvisualiser', u'py_sonicvisualiser Documentation', - [u'David Doukhan'], 1) + ('index', 'py_sonicvisualiser', 'py_sonicvisualiser Documentation', + ['David Doukhan'], 1) ] # If true, show URL addresses after external links. @@ -237,8 +237,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'py_sonicvisualiser', u'py_sonicvisualiser Documentation', - u'David Doukhan', 'py_sonicvisualiser', 'One line description of project.', + ('index', 'py_sonicvisualiser', 'py_sonicvisualiser Documentation', + 'David Doukhan', 'py_sonicvisualiser', 'One line description of project.', 'Miscellaneous'), ] diff --git a/examples/example1.py b/examples/example1.py index 26b7e16..832307e 100644 --- a/examples/example1.py +++ b/examples/example1.py @@ -14,7 +14,7 @@ # append a continuous annotation layer corresponding to a sinusoidal signal # on the spectrogram view previously defined -x = np.array(range(10000, 20000, 5)) / 1000. +x = np.array(list(range(10000, 20000, 5))) / 1000. sve.add_continuous_annotations(x, 1 + 3 * np.sin(2 * x), view=specview) # append a labelled interval annotation layer on a new view diff --git a/py_sonicvisualiser/SVContentHandler.py b/py_sonicvisualiser/SVContentHandler.py index 41ade44..8c774cc 100644 --- a/py_sonicvisualiser/SVContentHandler.py +++ b/py_sonicvisualiser/SVContentHandler.py @@ -22,7 +22,7 @@ import xml.sax as sax import xml.dom.minidom as minidom -from SVDataset import SVDataset2D, SVDataset3D +from .SVDataset import SVDataset2D, SVDataset3D class SVContentHandler(sax.ContentHandler): """ @@ -43,7 +43,7 @@ def startElement(self, name, attrs): if name in ['model', 'dataset', 'layer']: self.nbdata += 1 - if name == 'model' and attrs.has_key('mainModel') and attrs.getValue('mainModel') == 'true': + if name == 'model' and 'mainModel' in attrs and attrs.getValue('mainModel') == 'true': self.samplerate = int(attrs.getValue('sampleRate')) self.nframes = int(attrs.getValue('end')) self.mediafile = attrs.getValue('file') @@ -72,7 +72,7 @@ def startElement(self, name, attrs): elif name == 'window': self.defwidth = int(attrs.getValue('width')) - for at, val in attrs.items(): + for at, val in list(attrs.items()): node.setAttribute(at, val) self.curnode = node diff --git a/py_sonicvisualiser/SVDataset.py b/py_sonicvisualiser/SVDataset.py index 62a80eb..76d8ff6 100644 --- a/py_sonicvisualiser/SVDataset.py +++ b/py_sonicvisualiser/SVDataset.py @@ -57,19 +57,19 @@ def set_data_from_iterable(self, frames, values, labels=None): :type y: iterable """ if not isinstance(frames, collections.Iterable): - raise TypeError, "frames must be an iterable" + raise TypeError("frames must be an iterable") if not isinstance(values, collections.Iterable): - raise TypeError, "values must be an iterable" + raise TypeError("values must be an iterable") assert(len(frames) == len(values)) self.frames = frames self.values = values if labels is None: self.label2int['New Point'] = 0 self.int2label[0] = 'New Point' - self.labels = [0 for i in xrange(len(frames))] + self.labels = [0 for i in range(len(frames))] else: if not isinstance(labels, collections.Iterable): - raise TypeError, "labels must be an iterable" + raise TypeError("labels must be an iterable") for l in labels: if l not in self.label2int: self.label2int[l] = len(self.label2int) @@ -111,7 +111,7 @@ def __init__(self, domdoc, datasetid, samplerate): def set_data_from_iterable(self, frames, values, durations, labels=None): SVDataset2D.set_data_from_iterable(self, frames, values, labels) if not isinstance(durations, collections.Iterable): - raise TypeError, "durations must be an iterable" + raise TypeError("durations must be an iterable") assert(len(self.frames) == len(durations)) self.durations = durations diff --git a/py_sonicvisualiser/SVEnv.py b/py_sonicvisualiser/SVEnv.py index ab19af9..c3e3534 100644 --- a/py_sonicvisualiser/SVEnv.py +++ b/py_sonicvisualiser/SVEnv.py @@ -31,8 +31,8 @@ from os.path import basename #import wave import numpy as np -from SVDataset import SVDataset2D, SVDataset3D -from SVContentHandler import SVContentHandler +from .SVDataset import SVDataset2D, SVDataset3D +from .SVContentHandler import SVContentHandler import scipy.io.wavfile as SW import wave @@ -186,7 +186,7 @@ def add_continuous_annotations(self, x, y, colourName='Purple', colour='#c832ff' # datasetnode.set_data_from_iterable(map(int, np.array(x) * self.samplerate), y) # data = dataset.appendChild(datasetnode) dataset = self.data.appendChild(SVDataset2D(self.doc, str(imodel), self.samplerate)) - dataset.set_data_from_iterable(map(int, np.array(x) * self.samplerate), y) + dataset.set_data_from_iterable(list(map(int, np.array(x) * self.samplerate)), y) self.nbdata += 2 ###### add layers @@ -246,7 +246,7 @@ def add_interval_annotations(self, temp_idx, durations, labels, values=None, col dataset = self.data.appendChild(SVDataset3D(self.doc, str(imodel), self.samplerate)) if values is None: values = ([0] * len(temp_idx)) - dataset.set_data_from_iterable(map(int, np.array(temp_idx) * self.samplerate), values, map(int, np.array(durations) * self.samplerate), labels) + dataset.set_data_from_iterable(list(map(int, np.array(temp_idx) * self.samplerate)), values, list(map(int, np.array(durations) * self.samplerate)), labels) # dataset = self.data.appendChild(self.doc.createElement('dataset')) @@ -444,7 +444,7 @@ def __add_spectrogram(self, model): # append a continuous annotation layer corresponding to a sinusoidal signal # on the spectrogram view previously defined - x = np.array(range(10000, 20000, 5)) / 1000. + x = np.array(list(range(10000, 20000, 5))) / 1000. sve.add_continuous_annotations(x, 1 + 3 * np.sin(2 * x), view=specview) # append a labelled interval annotation layer on a new view diff --git a/py_sonicvisualiser/__init__.py b/py_sonicvisualiser/__init__.py index 53c0253..3e8d826 100644 --- a/py_sonicvisualiser/__init__.py +++ b/py_sonicvisualiser/__init__.py @@ -3,4 +3,4 @@ __version__ = get_versions()['version'] del get_versions -from SVEnv import SVEnv +from .SVEnv import SVEnv diff --git a/py_sonicvisualiser/_version.py b/py_sonicvisualiser/_version.py index 8b79f4e..c4d20de 100644 --- a/py_sonicvisualiser/_version.py +++ b/py_sonicvisualiser/_version.py @@ -33,19 +33,19 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): if e.errno == errno.ENOENT: continue if verbose: - print("unable to run %s" % args[0]) + print(("unable to run %s" % args[0])) print(e) return None else: if verbose: - print("unable to find command, tried %s" % (commands,)) + print(("unable to find command, tried %s" % (commands,))) return None stdout = p.communicate()[0].strip() if sys.version >= '3': stdout = stdout.decode() if p.returncode != 0: if verbose: - print("unable to run %s (error)" % args[0]) + print(("unable to run %s (error)" % args[0])) return None return stdout @@ -97,15 +97,15 @@ def versions_from_expanded_variables(variables, tag_prefix, verbose=False): # "stabilization", as well as "HEAD" and "master". tags = set([r for r in refs if re.search(r'\d', r)]) if verbose: - print("discarding '%s', no digits" % ",".join(refs-tags)) + print(("discarding '%s', no digits" % ",".join(refs-tags))) if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) + print(("likely tags: %s" % ",".join(sorted(tags)))) for ref in sorted(tags): # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): r = ref[len(tag_prefix):] if verbose: - print("picking %s" % r) + print(("picking %s" % r)) return { "version": r, "full": variables["full"].strip() } # no suitable tags, so we use the full revision id @@ -122,7 +122,7 @@ def versions_from_vcs(tag_prefix, root, verbose=False): if not os.path.exists(os.path.join(root, ".git")): if verbose: - print("no .git in %s" % root) + print(("no .git in %s" % root)) return {} GITS = ["git"] @@ -134,7 +134,7 @@ def versions_from_vcs(tag_prefix, root, verbose=False): return {} if not stdout.startswith(tag_prefix): if verbose: - print("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix)) + print(("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix))) return {} tag = stdout[len(tag_prefix):] stdout = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) @@ -152,8 +152,8 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False): dirname = os.path.basename(root) if not dirname.startswith(parentdir_prefix): if verbose: - print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" % - (root, dirname, parentdir_prefix)) + print(("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" % + (root, dirname, parentdir_prefix))) return None return {"version": dirname[len(parentdir_prefix):], "full": ""} diff --git a/setup.py b/setup.py index 2190c77..c5824bb 100644 --- a/setup.py +++ b/setup.py @@ -37,11 +37,11 @@ long_description = open('README.md').read(), author = "David Doukhan", author_email = "david.doukhan@gmail.com", -# version = '0.0.1', + version = '0.3.2', # versioneer - version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass(), + #version=versioneer.get_version(), + #cmdclass=versioneer.get_cmdclass(), install_requires = [ 'setuptools', diff --git a/versioneer.py b/versioneer.py index 2cacf9b..ec0e929 100644 --- a/versioneer.py +++ b/versioneer.py @@ -466,19 +466,19 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False): if e.errno == errno.ENOENT: continue if verbose: - print("unable to run %s" % args[0]) + print(("unable to run %s" % args[0])) print(e) return None else: if verbose: - print("unable to find command, tried %s" % (commands,)) + print(("unable to find command, tried %s" % (commands,))) return None stdout = p.communicate()[0].strip() if sys.version >= '3': stdout = stdout.decode() if p.returncode != 0: if verbose: - print("unable to run %s (error)" % args[0]) + print(("unable to run %s (error)" % args[0])) return None return stdout @@ -530,15 +530,15 @@ def versions_from_expanded_variables(variables, tag_prefix, verbose=False): # "stabilization", as well as "HEAD" and "master". tags = set([r for r in refs if re.search(r'\d', r)]) if verbose: - print("discarding '%s', no digits" % ",".join(refs-tags)) + print(("discarding '%s', no digits" % ",".join(refs-tags))) if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) + print(("likely tags: %s" % ",".join(sorted(tags)))) for ref in sorted(tags): # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): r = ref[len(tag_prefix):] if verbose: - print("picking %s" % r) + print(("picking %s" % r)) return { "version": r, "full": variables["full"].strip() } # no suitable tags, so we use the full revision id @@ -555,7 +555,7 @@ def versions_from_vcs(tag_prefix, root, verbose=False): if not os.path.exists(os.path.join(root, ".git")): if verbose: - print("no .git in %s" % root) + print(("no .git in %s" % root)) return {} GITS = ["git"] @@ -567,7 +567,7 @@ def versions_from_vcs(tag_prefix, root, verbose=False): return {} if not stdout.startswith(tag_prefix): if verbose: - print("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix)) + print(("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix))) return {} tag = stdout[len(tag_prefix):] stdout = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) @@ -585,8 +585,8 @@ def versions_from_parentdir(parentdir_prefix, root, verbose=False): dirname = os.path.basename(root) if not dirname.startswith(parentdir_prefix): if verbose: - print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" % - (root, dirname, parentdir_prefix)) + print(("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" % + (root, dirname, parentdir_prefix))) return None return {"version": dirname[len(parentdir_prefix):], "full": ""} import os.path @@ -675,7 +675,7 @@ def write_to_version_file(filename, versions): f = open(filename, "w") f.write(SHORT_VERSION_PY % versions) f.close() - print("set %s to '%s'" % (filename, versions["version"])) + print(("set %s to '%s'" % (filename, versions["version"]))) def get_root(): try: @@ -706,25 +706,25 @@ def get_versions(default=DEFAULT, verbose=False): if variables: ver = versions_from_expanded_variables(variables, tag_prefix) if ver: - if verbose: print("got version from expanded variable %s" % ver) + if verbose: print(("got version from expanded variable %s" % ver)) return ver ver = versions_from_file(versionfile_abs) if ver: - if verbose: print("got version from file %s %s" % (versionfile_abs,ver)) + if verbose: print(("got version from file %s %s" % (versionfile_abs,ver))) return ver ver = versions_from_vcs(tag_prefix, root, verbose) if ver: - if verbose: print("got version from git %s" % ver) + if verbose: print(("got version from git %s" % ver)) return ver ver = versions_from_parentdir(parentdir_prefix, root, verbose) if ver: - if verbose: print("got version from parentdir %s" % ver) + if verbose: print(("got version from parentdir %s" % ver)) return ver - if verbose: print("got version from default %s" % ver) + if verbose: print(("got version from default %s" % ver)) return default def get_version(verbose=False): @@ -740,7 +740,7 @@ def finalize_options(self): pass def run(self): ver = get_version(verbose=True) - print("Version is currently: %s" % ver) + print(("Version is currently: %s" % ver)) class cmd_build(_build): @@ -750,7 +750,7 @@ def run(self): # now locate _version.py in the new build/ directory and replace it # with an updated value target_versionfile = os.path.join(self.build_lib, versionfile_build) - print("UPDATING %s" % target_versionfile) + print(("UPDATING %s" % target_versionfile)) os.unlink(target_versionfile) f = open(target_versionfile, "w") f.write(SHORT_VERSION_PY % versions) @@ -763,7 +763,7 @@ class cmd_build_exe(_build_exe): def run(self): versions = get_versions(verbose=True) target_versionfile = versionfile_source - print("UPDATING %s" % target_versionfile) + print(("UPDATING %s" % target_versionfile)) os.unlink(target_versionfile) f = open(target_versionfile, "w") f.write(SHORT_VERSION_PY % versions) @@ -791,7 +791,7 @@ def make_release_tree(self, base_dir, files): # now locate _version.py in the new base_dir directory (remembering # that it may be a hardlink) and replace it with an updated value target_versionfile = os.path.join(base_dir, versionfile_source) - print("UPDATING %s" % target_versionfile) + print(("UPDATING %s" % target_versionfile)) os.unlink(target_versionfile) f = open(target_versionfile, "w") f.write(SHORT_VERSION_PY % self._versioneer_generated_versions) @@ -812,7 +812,7 @@ def initialize_options(self): def finalize_options(self): pass def run(self): - print(" creating %s" % versionfile_source) + print((" creating %s" % versionfile_source)) f = open(versionfile_source, "w") f.write(LONG_VERSION_PY % {"DOLLAR": "$", "TAG_PREFIX": tag_prefix, @@ -827,12 +827,12 @@ def run(self): except EnvironmentError: old = "" if INIT_PY_SNIPPET not in old: - print(" appending to %s" % ipy) + print((" appending to %s" % ipy)) f = open(ipy, "a") f.write(INIT_PY_SNIPPET) f.close() else: - print(" %s unmodified" % ipy) + print((" %s unmodified" % ipy)) # Make sure both the top-level "versioneer.py" and versionfile_source # (PKG/_version.py, used by runtime code) are in MANIFEST.in, so @@ -859,8 +859,8 @@ def run(self): else: print(" 'versioneer.py' already in MANIFEST.in") if versionfile_source not in simple_includes: - print(" appending versionfile_source ('%s') to MANIFEST.in" % - versionfile_source) + print((" appending versionfile_source ('%s') to MANIFEST.in" % + versionfile_source)) f = open(manifest_in, "a") f.write("include %s\n" % versionfile_source) f.close()