mirror of
https://gitee.com/openharmony/third_party_pyyaml
synced 2024-11-23 07:20:31 +00:00
Prepare setup.py for release. Fix #7.
This commit is contained in:
parent
fc01755908
commit
410d822bd5
@ -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):
|
||||
|
36
setup.py
36
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'],
|
||||
|
7
tests/data/float-representer-2.3-bug.code
Normal file
7
tests/data/float-representer-2.3-bug.code
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
# 0.0: 0,
|
||||
1.0: 1,
|
||||
1e300000: +10,
|
||||
-1e300000: -10,
|
||||
1e300000/1e300000: 100,
|
||||
}
|
5
tests/data/float-representer-2.3-bug.data
Normal file
5
tests/data/float-representer-2.3-bug.data
Normal file
@ -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
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user