Skip to content

Commit

Permalink
2to3 all .py files. versioneer.py threw an error
Browse files Browse the repository at this point in the history
  • Loading branch information
hgbrian committed Jul 3, 2016
1 parent 406664a commit e843267
Show file tree
Hide file tree
Showing 29 changed files with 3,098 additions and 3,098 deletions.
16 changes: 8 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
master_doc = 'index'

# General information about the project.
project = u'Pydna'
copyright = u'2015, Björn Johansson'
project = 'Pydna'
copyright = '2015, Björn Johansson'

# 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 @@ -221,8 +221,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Pydna.tex', u'Pydna Documentation',
u'Björn Johansson', 'manual'),
('index', 'Pydna.tex', 'Pydna Documentation',
'Björn Johansson', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -251,8 +251,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pydna', u'Pydna Documentation',
[u'Björn Johansson'], 1)
('index', 'pydna', 'Pydna Documentation',
['Björn Johansson'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -265,8 +265,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Pydna', u'Pydna Documentation',
u'Björn Johansson', 'Pydna', 'One line description of project.',
('index', 'Pydna', 'Pydna Documentation',
'Björn Johansson', 'Pydna', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
18 changes: 9 additions & 9 deletions pydna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
'''

__author__ = u"Björn Johansson"
__copyright__ = u"Copyright 2013 - 2015 Björn Johansson"
__credits__ = [u"Björn Johansson", u"Mark Budde"]
__license__ = u"BSD"
__maintainer__ = u"Björn Johansson"
__email__ = u"[email protected]"
__status__ = u"Development" # "Production" #"Prototype"
__author__ = "Björn Johansson"
__copyright__ = "Copyright 2013 - 2015 Björn Johansson"
__credits__ = ["Björn Johansson", "Mark Budde"]
__license__ = "BSD"
__maintainer__ = "Björn Johansson"
__email__ = "[email protected]"
__status__ = "Development" # "Production" #"Prototype"
from ._version import get_versions
__version__ = get_versions()['version'][:5]
__long_version__ = get_versions()['version']
Expand Down Expand Up @@ -64,7 +64,7 @@
import errno as _errno
import subprocess as _subprocess
import appdirs as _appdirs
from ConfigParser import SafeConfigParser as _SafeConfigParser
from configparser import SafeConfigParser as _SafeConfigParser

_os.environ["pydna_config_dir"] = _os.getenv("pydna_config_dir") or _appdirs.user_config_dir("pydna")

Expand Down Expand Up @@ -266,7 +266,7 @@ def delete_cache(delete=[ "amplify", "assembly", "genbank", "web", "synced" ]):
try:
_os.remove( _os.path.join( _os.environ["pydna_data_dir"], file_) )
msg += " deleted.\n"
except OSError, e:
except OSError as e:
if e._errno == _errno.ENOENT:
msg += " no file to delete.\n"
return _pretty_str(msg)
Expand Down
6 changes: 3 additions & 3 deletions pydna/_orderedset.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ def __eq__(self, other):
if __name__ == '__main__':
s = OrderedSet('abracadaba')
t = OrderedSet('simsalabim')
print(s | t)
print(s & t)
print(s - t)
print((s | t))
print((s & t))
print((s - t))
14 changes: 7 additions & 7 deletions pydna/_pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class pretty_str(str):
def _repr_pretty_(self, p, cycle):
p.text(self)

class pretty_unicode(unicode):
class pretty_unicode(str):
def _repr_pretty_(self, p, cycle):
p.text(self)

Expand All @@ -19,10 +19,10 @@ def _repr_pretty_(self, p, cycle):
if __name__=="__main__":
import pydna

print pydna.read("/home/bjorn/Desktop/python_packages/pydna/pydna/pydna_read_test.txt").format()
print pydna.read("/home/bjorn/Desktop/python_packages/pydna/pydna/pydna_read_test2.txt").format()[3270:3281]
print(pydna.read("/home/bjorn/Desktop/python_packages/pydna/pydna/pydna_read_test.txt").format())
print(pydna.read("/home/bjorn/Desktop/python_packages/pydna/pydna/pydna_read_test2.txt").format()[3270:3281])
import sys;sys.exit(42)
import StringIO
import io
from Bio import SeqIO
from Bio.Alphabet.IUPAC import IUPACAmbiguousDNA

Expand All @@ -34,17 +34,17 @@ def _repr_pretty_(self, p, cycle):

rawseq = re.findall(pattern, textwrap.dedent(raw + "\n\n"), flags=re.MULTILINE).pop(0)

handle = StringIO.StringIO(raw)
handle = io.StringIO(raw)

sr = SeqIO.read(handle, "genbank", alphabet=IUPACAmbiguousDNA())

s = sr.format("gb").strip()

print pretty_string(s[:55]+"circular"+s[63:])[3200:3300]
print(pretty_string(s[:55]+"circular"+s[63:])[3200:3300])

from pydna import Dseqrecord

v = Dseqrecord(sr)

print v.format("gb")
print(v.format("gb"))

30 changes: 15 additions & 15 deletions pydna/_sequencetrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def reverseCompSequence(sequence):
ambiguity codes.
"""
tmp = list()
for cnt in reversed(range(len(sequence))):
for cnt in reversed(list(range(len(sequence)))):
tmp.append(rclookup[sequence[cnt]])

return ''.join(tmp)
Expand Down Expand Up @@ -401,7 +401,7 @@ def followDecode(self, cdata):
udata = list()
prev = unpack('B', cdata[256])[0]
udata.append(cdata[256])
for cnt in xrange(257, len(cdata)):
for cnt in range(257, len(cdata)):
diff = unpack('b', cdata[cnt])[0]
actual = table[prev] - diff

Expand Down Expand Up @@ -460,14 +460,14 @@ def decode8BitDelta(self, cdata):

# first, unpack the 1-byte values
udata = list()
for cnt in xrange(1, len(cdata)):
for cnt in range(1, len(cdata)):
val = unpack('B', cdata[cnt])[0]
udata.append(val)

# now apply the reverse delta filtering
for clev in range(levels):
prev = 0
for cnt in xrange(0, len(udata)):
for cnt in range(0, len(udata)):
actual = udata[cnt] + prev
if actual > 255:
# simulate 1-byte integer overflow
Expand All @@ -488,14 +488,14 @@ def decode16BitDelta(self, cdata):

# first, unpack the 2-byte values
udata = list()
for cnt in xrange(1, len(cdata), 2):
for cnt in range(1, len(cdata), 2):
val = unpack('>H', cdata[cnt:cnt+2])[0]
udata.append(val)

# now apply the reverse delta filtering
for clev in range(levels):
prev = 0
for cnt in xrange(0, len(udata)):
for cnt in range(0, len(udata)):
actual = udata[cnt] + prev
if actual > 65535:
# simulate 2-byte integer overflow
Expand All @@ -516,14 +516,14 @@ def decode32BitDelta(self, cdata):

# first, unpack the 4-byte values (skipping the 2 padding bytes)
udata = list()
for cnt in xrange(3, len(cdata), 4):
for cnt in range(3, len(cdata), 4):
val = unpack('>I', cdata[cnt:cnt+4])[0]
udata.append(val)

# now apply the reverse delta filtering
for clev in range(levels):
prev = 0
for cnt in xrange(0, len(udata)):
for cnt in range(0, len(udata)):
actual = udata[cnt] + prev
if actual > 4294967295:
# simulate 1-byte integer overflow
Expand Down Expand Up @@ -706,13 +706,13 @@ def readABIIndex(self):
def printABIIndex(self, data_id):
for entry in self.abiindex:
if entry['did'] == data_id:
print 'entry ID:', entry['did']
print 'idv:', entry['idv']
print 'data format:', entry['dformat']
print 'format size:', entry['fsize']
print 'data count:', entry['dcnt']
print 'total data length:', entry['dlen']
print 'data offset:', entry['offset']
print('entry ID:', entry['did'])
print('idv:', entry['idv'])
print('data format:', entry['dformat'])
print('format size:', entry['fsize'])
print('data count:', entry['dcnt'])
print('total data length:', entry['dlen'])
print('data offset:', entry['offset'])

def getIndexEntry(self, data_id, number):
for row in self.abiindex:
Expand Down
34 changes: 17 additions & 17 deletions pydna/_simple_paths8.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def all_simple_paths_edges(G, source, target, cutoff=None, data=False):
edge_data = lambda u,v,n,E,I: (u,v)

for path in _all_simple_paths_graph(G,source,target,cutoff=cutoff):
edges = zip(path[:-1],path[1:])
edges = list(zip(path[:-1],path[1:]))
E = [] # list: items of each edge
N = [] # list: number of items of each edge
for u,v in edges:
edge_items = G[u][v].items()
edge_items = list(G[u][v].items())
E += [edge_items]
N += [len(edge_items)]
I = [0 for n in N]
idx = [i for i in reversed(range(len(I)))]
idx = [i for i in reversed(list(range(len(I))))]
while True:
path_edges = []
for n,(u,v) in enumerate(edges):
Expand All @@ -70,13 +70,13 @@ def all_simple_paths_edges(G, source, target, cutoff=None, data=False):

def all_circular_paths_edges(G):
for path in sorted(nx.simple_cycles(G), key=len, reverse =True):
edges = zip(path, path[1:]+[path[0]])
edges = list(zip(path, path[1:]+[path[0]]))
N = []
for u,v in edges:
n = len(G[u][v])
N += [n]
I = [0 for n in N]
idx = [i for i in reversed(range(len(I)))]
idx = [i for i in reversed(list(range(len(I))))]
while True:
path_edges = []
for i,(u,v) in enumerate(edges):
Expand All @@ -103,27 +103,27 @@ def all_circular_paths_edges(G):
target = 'd'

# MULTIDIGRAPH
print 'MULTIDIGRAPH (data=False)'
print('MULTIDIGRAPH (data=False)')
for path in all_simple_paths_edges(G, source, target):
print path
print(path)

print
print 'MULTIDIGRAPH (data=True)'
print()
print('MULTIDIGRAPH (data=True)')
for path in all_simple_paths_edges(G, source, target, data=True):
#print path
total_weight = sum([(I.values()[0]['weight']) for u,v,I in path])
print total_weight, '\t', path
total_weight = sum([(list(I.values())[0]['weight']) for u,v,I in path])
print(total_weight, '\t', path)

print
print()
# DIGRAPH
H = nx.DiGraph(G)
print 'DIGRAPH (data=False)'
print('DIGRAPH (data=False)')
for path in all_simple_paths_edges(H, source, target):
print path
print(path)

print
print 'DIGRAPH (data=True)'
print()
print('DIGRAPH (data=True)')
for path in all_simple_paths_edges(H, source, target, data=True):
total_weight = sum([w['weight'] for u,v,w in path])
print total_weight, '\t', path
print(total_weight, '\t', path)

20 changes: 10 additions & 10 deletions pydna/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,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" % dispcmd)
print(("unable to run %s" % dispcmd))
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_info[0] >= 3:
stdout = stdout.decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
print(("unable to run %s (error)" % dispcmd))
return None
return stdout

Expand All @@ -99,8 +99,8 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
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)))
raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
return {"version": dirname[len(parentdir_prefix):],
"full-revisionid": None,
Expand Down Expand Up @@ -155,15 +155,15 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# "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-revisionid": keywords["full"].strip(),
"dirty": False, "error": None
Expand All @@ -185,7 +185,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):

if not os.path.exists(os.path.join(root, ".git")):
if verbose:
print("no .git in %s" % root)
print(("no .git in %s" % root))
raise NotThisMethod("no .git directory")

GITS = ["git"]
Expand Down Expand Up @@ -236,7 +236,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
if not full_tag.startswith(tag_prefix):
if verbose:
fmt = "tag '%s' doesn't start with prefix '%s'"
print(fmt % (full_tag, tag_prefix))
print((fmt % (full_tag, tag_prefix)))
pieces["error"] = ("tag '%s' doesn't start with prefix '%s'"
% (full_tag, tag_prefix))
return pieces
Expand Down
Loading

0 comments on commit e843267

Please sign in to comment.