Skip to content

Commit

Permalink
Fixed Python 2.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
niemasd committed Jul 28, 2019
1 parent 3e88c8c commit 3f6c9d7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions docs/_modules/treeswift/Tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ <h1>Source code for treeswift.Tree</h1><div class="highlight"><pre>
<span class="n">INVALID_NEXML</span> <span class="o">=</span> <span class="s2">&quot;Invalid NeXML file&quot;</span>
<span class="n">INVALID_NEXUS</span> <span class="o">=</span> <span class="s2">&quot;Invalid Nexus file&quot;</span>
<span class="n">EULER_GAMMA</span> <span class="o">=</span> <span class="mf">0.5772156649015328606065120900824024310421</span>
<span class="n">NEWICK_SYMBOLS</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;:&#39;</span><span class="p">,</span> <span class="s1">&#39;,&#39;</span><span class="p">,</span> <span class="s1">&#39;;&#39;</span><span class="p">,</span> <span class="s1">&#39;)&#39;</span><span class="p">}</span>

<span class="c1"># store bracket open/close for convenience in label parsing</span>
<span class="n">BRACKET</span> <span class="o">=</span> <span class="p">{</span>
Expand Down Expand Up @@ -1327,7 +1326,7 @@ <h1>Source code for treeswift.Tree</h1><div class="highlight"><pre>
<span class="c1"># node label</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">label</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="p">;</span> <span class="n">bracket</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">while</span> <span class="n">bracket</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">in</span> <span class="n">BRACKET</span> <span class="ow">or</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">NEWICK_SYMBOLS</span><span class="p">:</span>
<span class="k">while</span> <span class="n">bracket</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">in</span> <span class="n">BRACKET</span> <span class="ow">or</span> <span class="p">(</span><span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;:&#39;</span> <span class="ow">and</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;,&#39;</span> <span class="ow">and</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;;&#39;</span> <span class="ow">and</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;)&#39;</span><span class="p">):</span>
<span class="k">if</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="ow">in</span> <span class="n">BRACKET</span> <span class="ow">and</span> <span class="n">bracket</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">bracket</span> <span class="o">=</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
<span class="k">elif</span> <span class="n">bracket</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">ts</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="n">BRACKET</span><span class="p">[</span><span class="n">bracket</span><span class="p">]:</span>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
here = path.abspath(path.dirname(__file__))
setup(
name='treeswift', # Required
version='1.1.2', # Required
version='1.1.3', # Required
description='TreeSwift: Fast tree module for Python 2 and 3', # Required
long_description='TreeSwift is a Python library for parsing, manipulating, and iterating over (rooted) tree structures. TreeSwift places an emphasis on speed.', # Optional
long_description_content_type='text/plain', # Optional (see note above)
Expand Down
3 changes: 1 addition & 2 deletions treeswift/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
INVALID_NEXML = "Invalid NeXML file"
INVALID_NEXUS = "Invalid Nexus file"
EULER_GAMMA = 0.5772156649015328606065120900824024310421
NEWICK_SYMBOLS = {':', ',', ';', ')'}

# store bracket open/close for convenience in label parsing
BRACKET = {
Expand Down Expand Up @@ -1288,7 +1287,7 @@ def read_tree_newick(newick):
# node label
else:
label = ''; bracket = None
while bracket is not None or ts[i] in BRACKET or ts[i] not in NEWICK_SYMBOLS:
while bracket is not None or ts[i] in BRACKET or (ts[i] != ':' and ts[i] != ',' and ts[i] != ';' and ts[i] != ')'):
if ts[i] in BRACKET and bracket is None:
bracket = ts[i]
elif bracket is not None and ts[i] == BRACKET[bracket]:
Expand Down

0 comments on commit 3f6c9d7

Please sign in to comment.