Skip to content

Commit

Permalink
newick.pyx: In loads(), convert parser from int parser.
Browse files Browse the repository at this point in the history
This allows the common usage of calling loads() with an old-style int
that specifies the parser to use.
  • Loading branch information
jordibc committed Mar 7, 2024
1 parent 5117b5a commit 0f986e0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ete4/parser/newick.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ def loads(tree_text, parser=None, tree_class=Tree):
if not tree_text.endswith(';'):
raise NewickError('text ends with no ";"')

if type(parser) == int: # parser is an integer? (old-style/shortcut)
parser = INT_PARSERS[parser] # substitute it for the actual parser

if tree_text[0] == '(':
nodes, pos = read_nodes(tree_text, parser, 0, tree_class)
else:
Expand Down

0 comments on commit 0f986e0

Please sign in to comment.