Skip to content

Commit

Permalink
Prepend colons to roles from parse_triples()
Browse files Browse the repository at this point in the history
Fixes #80
  • Loading branch information
goodmami committed May 5, 2020
1 parent 64da43a commit f5c46fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* `penman.interface` is removed from the public API but remains
temporarily for backward compatibility ([#78])

### Fixed

* `parse_triples()` now prepends a colon to roles ([#80])

### Changed

* Make `parse()`, `format()`, `interpret()`, and `configure()`
Expand Down Expand Up @@ -697,3 +701,4 @@ First release with very basic functionality.
[#76]: https://github.com/goodmami/penman/issues/76
[#77]: https://github.com/goodmami/penman/issues/77
[#78]: https://github.com/goodmami/penman/issues/78
[#80]: https://github.com/goodmami/penman/issues/80
2 changes: 2 additions & 0 deletions penman/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def _parse_triples(tokens: TokenIterator) -> List[BasicTriple]:
role = tokens.expect('SYMBOL').text
if strip_caret and role.startswith('^'):
role = role[1:]
if not role.startswith(':'):
role = ':' + role
tokens.expect('LPAREN')
# SYMBOL may contain commas, so handle it here. If there
# is no space between the comma and the next SYMBOL, they
Expand Down
2 changes: 1 addition & 1 deletion tests/test_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_parse(self):
assert codec.parse('(a / alpha)') == ('a', [('/', 'alpha')])

def test_parse_triples(self):
assert codec.parse_triples('role(a, b)') == [('a', 'role', 'b')]
assert codec.parse_triples('role(a, b)') == [('a', ':role', 'b')]

def test_format(self):
assert codec.format(('a', [('/', 'alpha')])) == '(a / alpha)'
Expand Down

0 comments on commit f5c46fd

Please sign in to comment.