Skip to content

Commit

Permalink
Merge pull request #119 from transifex/yaml-default-tag
Browse files Browse the repository at this point in the history
Fix YAML's default tag value
  • Loading branch information
rigaspapas committed Oct 29, 2018
2 parents 15ef843 + 156905c commit d28316c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions openformats/formats/yaml/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ def parse(self, content, **kwargs):
start = node.get('start')
end_ = node.get('end')
key = node.get('key')
tag = node.get('tag', '')
tag = node.get('tag')
value = node.get('value')
style = node.get('style')
if not value:
continue
if isinstance(value, dict) and not all(value.values()):
continue
string_object = OpenString(
key, value, context=tag, flags=style, order=order,
key, value, context=tag or '', flags=style, order=order,
)
stringset.append(string_object)
order += 1
Expand Down
14 changes: 13 additions & 1 deletion openformats/tests/formats/yaml/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ def test_parse_pluralized_value(self):
self.handler.parse_pluralized_value('')

def test_parse_invalid_yaml(self):
invalid_content = "foo: bar\nwrong intentation"
invalid_content = "foo: bar\nwrong indentation"
with self.assertRaises(ParseError):
self.handler.parse(invalid_content)

def test_openstring_attributes(self):
content = "foo: bar\ntest: !tag 'content'"
template, strings = self.handler.parse(content)

test_string = strings[0]
self.assertEqual(test_string.context, '')
self.assertEqual(test_string.flags, '')

content_string = strings[1]
self.assertEqual(content_string.context, '!tag')
self.assertEqual(content_string.flags, "'")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name="openformats",
version='0.0.40',
version='0.0.41',
description="The Transifex Open Formats library",
author="Transifex",
author_email="support@transifex.com",
Expand Down

0 comments on commit d28316c

Please sign in to comment.