Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/pylocator
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#!/usr/bin/env python3
"""Run pylocator"""

import getopt
Expand All @@ -17,8 +17,8 @@ def main():
def info_exit(option = None, value = None):
"""Print usage information and abort execution"""
if not (option in ["-h", "--help"] or option == None):
print "Wrong argument:", option, ",", value
print USAGE
print("Wrong argument:", option, ",", value)
print(USAGE)
sys.exit(0)
try:
options, args = getopt.getopt(
Expand Down
8 changes: 4 additions & 4 deletions doc/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
master_doc = 'index'

# General information about the project.
project = u'PyLocator'
copyright = u'2011-2012, Thorsten Kranz'
project = 'PyLocator'
copyright = '2011-2012, Thorsten Kranz'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -168,8 +168,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [
('index', 'pylocator.tex', ur'PyLocator Documentation',
ur'Thorsten Kranz', 'manual'),
('index', 'pylocator.tex', r'PyLocator Documentation',
r'Thorsten Kranz', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down
6 changes: 3 additions & 3 deletions doc/src/sphinxext/autosummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import sphinx.addnodes, sphinx.roles
from sphinx.util import patfilter

from docscrape_sphinx import get_doc_object
from .docscrape_sphinx import get_doc_object


def setup(app):
Expand Down Expand Up @@ -288,7 +288,7 @@ def _import_by_name(name):
# ... then as MODNAME, MODNAME.OBJ1, MODNAME.OBJ1.OBJ2, ...
last_j = 0
modname = None
for j in reversed(range(1, len(name_parts)+1)):
for j in reversed(list(range(1, len(name_parts)+1))):
last_j = j
modname = '.'.join(name_parts[:j])
try:
Expand All @@ -305,7 +305,7 @@ def _import_by_name(name):
return obj
else:
return sys.modules[modname]
except (ValueError, ImportError, AttributeError, KeyError), e:
except (ValueError, ImportError, AttributeError, KeyError) as e:
raise ImportError(e)

#------------------------------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions doc/src/sphinxext/autosummary_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

"""
import glob, re, inspect, os, optparse, pydoc
from autosummary import import_by_name
from .autosummary import import_by_name

try:
from phantom_import import import_phantom_module
from .phantom_import import import_phantom_module
except ImportError:
import_phantom_module = lambda x: x

Expand All @@ -42,7 +42,7 @@ def main():

# read
names = {}
for name, loc in get_documented(args).items():
for name, loc in list(get_documented(args).items()):
for (filename, sec_title, keyword, toctree) in loc:
if toctree is not None:
path = os.path.join(os.path.dirname(filename), toctree)
Expand All @@ -58,8 +58,8 @@ def main():

try:
obj, name = import_by_name(name)
except ImportError, e:
print "Failed to import '%s': %s" % (name, e)
except ImportError as e:
print("Failed to import '%s': %s" % (name, e))
continue

fn = os.path.join(path, '%s.rst' % name)
Expand Down Expand Up @@ -127,8 +127,8 @@ def get_documented_in_docstring(name, module=None, filename=None):
return get_documented_in_lines(lines, module=name, filename=filename)
except AttributeError:
pass
except ImportError, e:
print "Failed to import '%s': %s" % (name, e)
except ImportError as e:
print("Failed to import '%s': %s" % (name, e))
return {}

def get_documented_in_lines(lines, module=None, filename=None):
Expand Down
6 changes: 3 additions & 3 deletions doc/src/sphinxext/comment_eater.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from cStringIO import StringIO
from io import StringIO
import compiler
import inspect
import textwrap
import tokenize

from compiler_unparse import unparse
from .compiler_unparse import unparse


class Comment(object):
Expand Down Expand Up @@ -68,7 +68,7 @@ def __init__(self):
def process_file(self, file):
""" Process a file object.
"""
for token in tokenize.generate_tokens(file.next):
for token in tokenize.generate_tokens(file.__next__):
self.process_token(*token)
self.make_index()

Expand Down
8 changes: 4 additions & 4 deletions doc/src/sphinxext/compiler_unparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"""

import sys
import cStringIO
import io
from compiler.ast import Const, Name, Tuple, Div, Mul, Sub, Add

def unparse(ast, single_line_functions=False):
s = cStringIO.StringIO()
s = io.StringIO()
UnparseCompilerAst(ast, s, single_line_functions)
return s.getvalue().lstrip()

Expand Down Expand Up @@ -504,7 +504,7 @@ def __binary_op(self, t, symbol):
# Check if parenthesis are needed on left side and then dispatch
has_paren = False
left_class = str(t.left.__class__)
if (left_class in op_precedence.keys() and
if (left_class in list(op_precedence.keys()) and
op_precedence[left_class] < op_precedence[str(t.__class__)]):
has_paren = True
if has_paren:
Expand All @@ -517,7 +517,7 @@ def __binary_op(self, t, symbol):
# Check if parenthesis are needed on the right side and then dispatch
has_paren = False
right_class = str(t.right.__class__)
if (right_class in op_precedence.keys() and
if (right_class in list(op_precedence.keys()) and
op_precedence[right_class] < op_precedence[str(t.__class__)]):
has_paren = True
if has_paren:
Expand Down
20 changes: 10 additions & 10 deletions doc/src/sphinxext/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import textwrap
import re
import pydoc
from StringIO import StringIO
from io import StringIO
from warnings import warn
4
class Reader(object):
Expand Down Expand Up @@ -113,7 +113,7 @@ def __getitem__(self,key):
return self._parsed_data[key]

def __setitem__(self,key,val):
if not self._parsed_data.has_key(key):
if key not in self._parsed_data:
warn("Unknown section %s" % key)
else:
self._parsed_data[key] = val
Expand Down Expand Up @@ -369,7 +369,7 @@ def _str_index(self):
idx = self['index']
out = []
out += ['.. index:: %s' % idx.get('default','')]
for section, references in idx.iteritems():
for section, references in idx.items():
if section == 'default':
continue
out += [' :%s: %s' % (section, ', '.join(references))]
Expand Down Expand Up @@ -411,10 +411,10 @@ def __init__(self, func, role='func'):
self._role = role # e.g. "func" or "meth"
try:
NumpyDocString.__init__(self,inspect.getdoc(func) or '')
except ValueError, e:
print '*'*78
print "ERROR: '%s' while parsing `%s`" % (e, self._f)
print '*'*78
except ValueError as e:
print('*'*78)
print("ERROR: '%s' while parsing `%s`" % (e, self._f))
print('*'*78)
#print "Docstring follows:"
#print doclines
#print '='*78
Expand All @@ -427,7 +427,7 @@ def __init__(self, func, role='func'):
argspec = inspect.formatargspec(*argspec)
argspec = argspec.replace('*','\*')
signature = '%s%s' % (func_name, argspec)
except TypeError, e:
except TypeError as e:
signature = '%s()' % func_name
self['Signature'] = signature

Expand All @@ -449,8 +449,8 @@ def __str__(self):
'meth': 'method'}

if self._role:
if not roles.has_key(self._role):
print "Warning: invalid role %s" % self._role
if self._role not in roles:
print("Warning: invalid role %s" % self._role)
out += '.. %s:: %s\n \n\n' % (roles.get(self._role,''),
func_name)

Expand Down
4 changes: 2 additions & 2 deletions doc/src/sphinxext/docscrape_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re, inspect, textwrap, pydoc
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc

class SphinxDocString(NumpyDocString):
# string conversion routines
Expand Down Expand Up @@ -73,7 +73,7 @@ def _str_index(self):
return out

out += ['.. index:: %s' % idx.get('default','')]
for section, references in idx.iteritems():
for section, references in idx.items():
if section == 'default':
continue
elif section == 'refguide':
Expand Down
6 changes: 3 additions & 3 deletions doc/src/sphinxext/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""

import os, re, pydoc
from docscrape_sphinx import get_doc_object, SphinxDocString
from .docscrape_sphinx import get_doc_object, SphinxDocString
import inspect

def mangle_docstrings(app, what, name, obj, options, lines,
Expand All @@ -44,7 +44,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
try:
references.append(int(l[len('.. ['):l.index(']')]))
except ValueError:
print "WARNING: invalid reference in %s docstring" % name
print("WARNING: invalid reference in %s docstring" % name)

# Start renaming from the biggest number, otherwise we may
# overwrite references.
Expand Down Expand Up @@ -99,7 +99,7 @@ def monkeypatch_sphinx_ext_autodoc():
if sphinx.ext.autodoc.format_signature is our_format_signature:
return

print "[numpydoc] Monkeypatching sphinx.ext.autodoc ..."
print("[numpydoc] Monkeypatching sphinx.ext.autodoc ...")
_original_format_signature = sphinx.ext.autodoc.format_signature
sphinx.ext.autodoc.format_signature = our_format_signature

Expand Down
4 changes: 2 additions & 2 deletions doc/src/sphinxext/phantom_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup(app):
def initialize(app):
fn = app.config.phantom_import_file
if (fn and os.path.isfile(fn)):
print "[numpydoc] Phantom importing modules from", fn, "..."
print("[numpydoc] Phantom importing modules from", fn, "...")
import_phantom_module(fn)

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -129,7 +129,7 @@ def base_cmp(a, b):
doc = "%s%s\n\n%s" % (funcname, argspec, doc)
obj = lambda: 0
obj.__argspec_is_invalid_ = True
obj.func_name = funcname
obj.__name__ = funcname
obj.__name__ = name
obj.__doc__ = doc
if inspect.isclass(object_cache[parent]):
Expand Down
14 changes: 7 additions & 7 deletions doc/src/sphinxext/plot_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

"""

import sys, os, glob, shutil, imp, warnings, cStringIO, re, textwrap
import sys, os, glob, shutil, imp, warnings, io, re, textwrap

def setup(app):
setup.app = app
Expand Down Expand Up @@ -137,12 +137,12 @@ def run_code(code, code_path):
if code_path is not None:
os.chdir(os.path.dirname(code_path))
stdout = sys.stdout
sys.stdout = cStringIO.StringIO()
sys.stdout = io.StringIO()
try:
code = unescape_doctest(code)
ns = {}
exec setup.config.plot_pre_code in ns
exec code in ns
exec(setup.config.plot_pre_code, ns)
exec(code, ns)
finally:
os.chdir(pwd)
sys.stdout = stdout
Expand Down Expand Up @@ -203,7 +203,7 @@ def makefig(code, code_path, output_dir, output_base, config):
return i

# We didn't find the files, so build them
print "-- Plotting figures %s" % output_base
print("-- Plotting figures %s" % output_base)

# Clear between runs
plt.close('all')
Expand Down Expand Up @@ -311,7 +311,7 @@ def run(arguments, content, options, state_machine, state, lineno):

# is it in doctest format?
is_doctest = contains_doctest(code)
if options.has_key('format'):
if 'format' in options:
if options['format'] == 'python':
is_doctest = False
else:
Expand Down Expand Up @@ -367,7 +367,7 @@ def run(arguments, content, options, state_machine, state, lineno):
return [sm]


opts = [':%s: %s' % (key, val) for key, val in options.items()
opts = [':%s: %s' % (key, val) for key, val in list(options.items())
if key in ('alt', 'height', 'width', 'scale', 'align', 'class')]

result = jinja.from_string(TEMPLATE).render(
Expand Down
10 changes: 5 additions & 5 deletions doc/src/sphinxext/traitsdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
import os
import pydoc

import docscrape
import docscrape_sphinx
from docscrape_sphinx import SphinxClassDoc, SphinxFunctionDoc, SphinxDocString
from . import docscrape
from . import docscrape_sphinx
from .docscrape_sphinx import SphinxClassDoc, SphinxFunctionDoc, SphinxDocString

import numpydoc
from . import numpydoc

import comment_eater
from . import comment_eater

class SphinxTraitsDoc(SphinxClassDoc):
def __init__(self, cls, modulename='', func_doc=SphinxFunctionDoc):
Expand Down
8 changes: 4 additions & 4 deletions pylocator/GtkGLExtVTKRenderWindowInteractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import gtk.gtkgl
import vtk

from shared import shared
from .shared import shared

class GtkGLExtVTKRenderWindowInteractor(gtk.gtkgl.DrawingArea):
"""
Expand Down Expand Up @@ -86,8 +86,8 @@ def __getattr__(self, attr):
elif hasattr(self._Iren, attr):
return getattr(self._Iren, attr)
else:
raise AttributeError, self.__class__.__name__ + \
" has no attribute named " + attr
raise AttributeError(self.__class__.__name__ + \
" has no attribute named " + attr)

def CreateTimer(self, obj, event):
gtk.timeout_add(10, self._Iren.TimerEvent)
Expand Down Expand Up @@ -143,7 +143,7 @@ def _GetCtrlShift(self, event):
return ctrl, shift

def OnButtonDown(self, wid, event):
if shared.debug: print "GtkGLExtVTKRenderWindowInteractor.OnButtonDown()"
if shared.debug: print("GtkGLExtVTKRenderWindowInteractor.OnButtonDown()")
"""Mouse button pressed."""
m = self.get_pointer()
ctrl, shift = self._GetCtrlShift(event)
Expand Down
Loading