Версия 0.2.3

This commit is contained in:
Tiendil 2020-10-06 14:36:21 +03:00
parent 20c3baa828
commit b09704a4f4
4 changed files with 7 additions and 13 deletions

View file

@ -23,9 +23,8 @@ class FromListGenerator(BaseGenerator):
error_msg = 'FromListGenerator: you must make subclass of FromListGenerator and define attribute SOURCE in it.'
raise NotImplementedError(error_msg)
with open(self.SOURCE, encoding='utf-8') as f:
names_data = json.load(f, encoding='utf-8')
names_data = json.load(f)
self.native_language = names_data['native_language']
self.languages = set(names_data['languages'])
self.full_forms_for_languages = set(names_data.get('full_forms_for_languages', set()))

View file

@ -48,14 +48,14 @@ class TestName(unittest.TestCase):
test_file_path = os.path.join(root_dir, 'tests', 'fixtures', 'test_from_list_generator.json')
with open(test_file_path) as f:
with open(test_file_path, 'rb') as f:
target_content = f.read()
with file_adapter(test_file_path) as f:
self.assertEqual(f.read(), target_content)
django_file_object = ContentFile(target_content)
classic_file_object = open(test_file_path, 'r')
classic_file_object = open(test_file_path, 'rb')
for tested_file_object in [django_file_object, classic_file_object]:
with file_adapter(tested_file_object) as f:

View file

@ -51,11 +51,11 @@ def is_file(obj):
@contextlib.contextmanager
def file_adapter(file_or_path):
def file_adapter(file_or_path, mode='rb'):
"""Context manager that works similar to ``open(file_path)``but also accepts already openned file-like objects."""
if is_file(file_or_path):
file_obj = file_or_path
else:
file_obj = open(file_or_path, 'rb')
file_obj = open(file_or_path, mode)
yield file_obj
file_obj.close()

View file

@ -3,9 +3,9 @@ import setuptools
setuptools.setup(
name='Pynames',
version='0.2.2',
version='0.2.3',
description='name generation library',
long_description = open('README.rst').read(),
long_description=open('README.rst').read(),
url='https://github.com/Tiendil/pynames',
author='Aleksey Yeletsky <Tiendil>',
author_email='a.eletsky@gmail.com',
@ -20,11 +20,6 @@ setuptools.setup(
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Natural Language :: English',
'Natural Language :: Russian'],
keywords=['gamedev', 'game', 'game development', 'names', 'names generation'],