From 649792a97a294124ea560a455948191ec3f03775 Mon Sep 17 00:00:00 2001 From: xi Date: Sun, 23 Apr 2006 18:07:52 +0000 Subject: [PATCH] Prepare setup.py for release. Fix #7. git-svn-id: http://svn.pyyaml.org/pyyaml/trunk@150 18f92427-320e-0410-9341-c67f048884a3 --- lib/yaml/representer.py | 14 ++++++------ setup.py | 36 ++++++++++++++++++++++++++++--- tests/data/float-representer-2.3-bug.code | 7 ++++++ tests/data/float-representer-2.3-bug.data | 5 +++++ tests/test_appliance.py | 2 +- tests/test_constructor.py | 4 ++-- tests/test_representer.py | 4 ++-- 7 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 tests/data/float-representer-2.3-bug.code create mode 100644 tests/data/float-representer-2.3-bug.data diff --git a/lib/yaml/representer.py b/lib/yaml/representer.py index af02c93..668b32b 100644 --- a/lib/yaml/representer.py +++ b/lib/yaml/representer.py @@ -184,18 +184,20 @@ class SafeRepresenter(BaseRepresenter): def represent_long(self, data): return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data)) - inf_value = 1e300000 - nan_value = inf_value/inf_value + repr_pos_inf = repr(1e300000) + repr_neg_inf = repr(-1e30000) + repr_nan = repr(1e300000/1e300000) def represent_float(self, data): - if data == self.inf_value: + repr_data = repr(data) + if repr_data == self.repr_pos_inf: value = u'.inf' - elif data == -self.inf_value: + elif repr_data == self.repr_neg_inf: value = u'-.inf' - elif data == self.nan_value or data != data: + elif repr_data == self.repr_nan: value = u'.nan' else: - value = unicode(repr(data)) + value = unicode(repr_data) return self.represent_scalar(u'tag:yaml.org,2002:float', value) def represent_list(self, data): diff --git a/setup.py b/setup.py index e1f12d1..8cdd1ed 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,35 @@ -NAME = 'PyYAML3000' -VERSION = '0.1' -DESCRIPTION = "The next generation YAML parser for Python" +NAME = 'PyYAML' +VERSION = '3.0' +DESCRIPTION = "YAML parser and emitter for Python" +LONG_DESCRIPTION = """\ +YAML is a data serialization format designed for human readability and +interaction with scripting languages. PyYAML is a YAML parser and emitter +for Python. + +PyYAML features a complete YAML 1.1 parser, Unicode support, event-based parser +and emitter (like SAX), API for serializing and deserializing Python objects +(like DOM or pickle). PyYAML supports all tags from the YAML types repository +and allows you to extend it easily. + +PyYAML is applicable for a broad range of tasks from configuration files to +object persistance.""" AUTHOR = "Kirill Simonov" AUTHOR_EMAIL = 'xi@resolvent.net' LICENSE = "MIT" +PLATFORMS = "Any" +URL = "http://pyyaml.org/wiki/PyYAML" +DOWNLOAD_URL = "http://pyyaml.org/download/pyyaml/%s-%s.tar.gz" % (NAME, VERSION) +CLASSIFIERS = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Text Processing :: Markup", +] + from distutils.core import setup @@ -12,9 +37,14 @@ setup( name=NAME, version=VERSION, description=DESCRIPTION, + long_description=LONG_DESCRIPTION, author=AUTHOR, author_email=AUTHOR_EMAIL, license=LICENSE, + platforms=PLATFORMS, + url=URL, + download_url=DOWNLOAD_URL, + classifiers=CLASSIFIERS, package_dir={'': 'lib'}, packages=['yaml'], diff --git a/tests/data/float-representer-2.3-bug.code b/tests/data/float-representer-2.3-bug.code new file mode 100644 index 0000000..d8db834 --- /dev/null +++ b/tests/data/float-representer-2.3-bug.code @@ -0,0 +1,7 @@ +{ +# 0.0: 0, + 1.0: 1, + 1e300000: +10, + -1e300000: -10, + 1e300000/1e300000: 100, +} diff --git a/tests/data/float-representer-2.3-bug.data b/tests/data/float-representer-2.3-bug.data new file mode 100644 index 0000000..efd1716 --- /dev/null +++ b/tests/data/float-representer-2.3-bug.data @@ -0,0 +1,5 @@ +#0.0: # hash(0) == hash(nan) and 0 == nan in Python 2.3 +1.0: 1 ++.inf: 10 +-.inf: -10 +.nan: 100 diff --git a/tests/test_appliance.py b/tests/test_appliance.py index 6d4cc45..d5e5d3e 100644 --- a/tests/test_appliance.py +++ b/tests/test_appliance.py @@ -26,7 +26,7 @@ class TestAppliance(unittest.TestCase): filenames = [os.path.join(cls.DATA, test+ext) for ext in extensions] def test_method(self, test=test, filenames=filenames): getattr(self, '_'+method_name)(test, *filenames) - test = test.replace('-', '_') + test = test.replace('-', '_').replace('.', '_') try: test_method.__name__ = '%s_%s' % (method_name, test) except TypeError: diff --git a/tests/test_constructor.py b/tests/test_constructor.py index 23fac0c..efbdbd4 100644 --- a/tests/test_constructor.py +++ b/tests/test_constructor.py @@ -255,10 +255,10 @@ class TestConstructorTypes(test_appliance.TestAppliance): self.failUnlessEqual(data1, data2) except AssertionError: if isinstance(data1, dict): - data1 = data1.items() + data1 = [(repr(key), value) for key, value in data1.items()] data1.sort() data1 = repr(data1) - data2 = data2.items() + data2 = [(repr(key), value) for key, value in data2.items()] data2.sort() data2 = repr(data2) if data1 != data2: diff --git a/tests/test_representer.py b/tests/test_representer.py index 6835dfd..3de0a28 100644 --- a/tests/test_representer.py +++ b/tests/test_representer.py @@ -18,10 +18,10 @@ class TestRepresenterTypes(test_appliance.TestAppliance): self.failUnlessEqual(data1, data2) except AssertionError: if isinstance(data1, dict): - data1 = data1.items() + data1 = [(repr(key), value) for key, value in data1.items()] data1.sort() data1 = repr(data1) - data2 = data2.items() + data2 = [(repr(key), value) for key, value in data2.items()] data2.sort() data2 = repr(data2) if data1 != data2: -- 2.11.4.GIT