Commit 2bdb6d06 authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 3.08

parent e9b29f00
For a complete Subversion changelog, see 'http://pyyaml.org/log/pyyaml'.
3.08 (2008-12-31)
-----------------
* Python 3 support (Thank to Erick Tryzelaar).
* Use Cython instead of Pyrex to build LibYAML bindings.
* Refactored support for unicode and byte input/output streams.
3.07 (2008-12-29)
-----------------
* The emitter learned to use an optional indentation indicator
for block scalar; thus scalars with leading whitespaces
could now be represented in a literal or folded style.
* The test suite is now included in the source distribution.
To run the tests, type 'python setup.py test'.
* Refactored the test suite: dropped unittest in favor of
a custom test appliance.
* Fixed the path resolver in CDumper.
* Forced an explicit document end indicator when there is
a possibility of parsing ambiguity.
* More setup.py improvements: the package should be usable
when any combination of setuptools, Pyrex and LibYAML
is installed.
* Windows binary packages are built against LibYAML-0.1.2.
* Minor typos and corrections (Thank to Ingy dot Net
and Andrey Somov).
3.06 (2008-10-03)
-----------------
* setup.py checks whether LibYAML is installed and if so, builds
and installs LibYAML bindings. To force or disable installation
of LibYAML bindings, use '--with-libyaml' or '--without-libyaml'
respectively.
* The source distribution includes compiled Pyrex sources so
building LibYAML bindings no longer requires Pyrex installed.
* 'yaml.load()' raises an exception if the input stream contains
more than one YAML document.
* Fixed exceptions produced by LibYAML bindings.
* Fixed a dot '.' character being recognized as !!float.
* Fixed Python 2.3 compatibility issue in constructing !!timestamp values.
* Windows binary packages are built against the LibYAML stable branch.
* Added attributes 'yaml.__version__' and 'yaml.__with_libyaml__'.
3.05 (2007-05-13)
-----------------
* Windows binary packages were built with LibYAML trunk.
* Fixed a bug that prevent processing a live stream of YAML documents in
timely manner (Thanks edward(at)sweetbytes(dot)net).
* Fixed a bug when the path in add_path_resolver contains boolean values
(Thanks jstroud(at)mbi(dot)ucla(dot)edu).
* Fixed loss of microsecond precision in timestamps
(Thanks edemaine(at)mit(dot)edu).
* Fixed loading an empty YAML stream.
* Allowed immutable subclasses of YAMLObject.
* Made the encoding of the unicode->str conversion explicit so that
the conversion does not depend on the default Python encoding.
* Forced emitting float values in a YAML compatible form.
3.04 (2006-08-20)
-----------------
* Include experimental LibYAML bindings.
* Fully support recursive structures.
* Sort dictionary keys. Mapping node values are now represented
as lists of pairs instead of dictionaries. No longer check
for duplicate mapping keys as it didn't work correctly anyway.
* Fix invalid output of single-quoted scalars in cases when a single
quote is not escaped when preceeded by whitespaces or line breaks.
* To make porting easier, rewrite Parser not using generators.
* Fix handling of unexpected block mapping values.
* Fix a bug in Representer.represent_object: copy_reg.dispatch_table
was not correctly handled.
* Fix a bug when a block scalar is incorrectly emitted in the simple
key context.
* Hold references to the objects being represented.
* Make Representer not try to guess !!pairs when a list is represented.
* Fix timestamp constructing and representing.
* Fix the 'N' plain scalar being incorrectly recognized as !!bool.
3.03 (2006-06-19)
-----------------
* Fix Python 2.5 compatibility issues.
* Fix numerous bugs in the float handling.
* Fix scanning some ill-formed documents.
* Other minor fixes.
3.02 (2006-05-15)
-----------------
* Fix win32 installer. Apparently bdist_wininst does not work well
under Linux.
* Fix a bug in add_path_resolver.
* Add the yaml-highlight example. Try to run on a color terminal:
`python yaml_hl.py <any_document.yaml`.
3.01 (2006-05-07)
-----------------
* Initial release. The version number reflects the codename
of the project (PyYAML 3000) and differenciates it from
the abandoned PyYaml module.
Metadata-Version: 1.0
Name: PyYAML
Version: 3.06
Version: 3.08
Summary: YAML parser and emitter for Python
Home-page: http://pyyaml.org/wiki/PyYAML
Author: Kirill Simonov
Author-email: xi@resolvent.net
License: MIT
Download-URL: http://pyyaml.org/download/pyyaml/PyYAML-3.06.tar.gz
Download-URL: http://pyyaml.org/download/pyyaml/PyYAML-3.08.tar.gz
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.
......@@ -24,5 +24,12 @@ Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.3
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.0
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup
......@@ -15,10 +15,13 @@ parser and emitter as follows:
>>> yaml.load(stream, Loader=yaml.CLoader)
>>> yaml.dump(data, Dumper=yaml.CDumper)
PyYAML includes a comprehensive test suite. To run the tests,
type 'python setup.py test'.
For more information, check the PyYAML homepage:
'http://pyyaml.org/wiki/PyYAML'.
Documentation (rough and incomplete though):
For PyYAML tutorial and reference, see:
'http://pyyaml.org/wiki/PyYAMLDocumentation'.
Post your questions and opinions to the YAML-Core mailing list:
......@@ -29,3 +32,4 @@ Submit bug reports and feature requests to the PyYAML bug tracker:
PyYAML is written by Kirill Simonov <xi@resolvent.net>. It is released
under the MIT license. See the file LICENSE for more details.
This diff is collapsed.
#include <yaml.h>
#if PY_MAJOR_VERSION < 3
#define PyUnicode_FromString(s) PyUnicode_DecodeUTF8((s), strlen(s), "strict")
#else
#define PyString_CheckExact PyBytes_CheckExact
#define PyString_AS_STRING PyBytes_AS_STRING
#define PyString_GET_SIZE PyBytes_GET_SIZE
#define PyString_FromStringAndSize PyBytes_FromStringAndSize
#endif
#ifdef _MSC_VER /* MS Visual C++ 6.0 */
#if _MSC_VER == 1200
#define PyLong_FromUnsignedLongLong(z) PyInt_FromLong(i)
#endif
#endif
......@@ -9,8 +9,10 @@ cdef extern from "_yaml.h":
char *PyString_AS_STRING(object o)
int PyString_GET_SIZE(object o)
object PyString_FromStringAndSize(char *v, int l)
object PyUnicode_DecodeUTF8(char *s, int s, char *e)
object PyUnicode_FromString(char *u)
object PyUnicode_DecodeUTF8(char *u, int s, char *e)
object PyUnicode_AsUTF8String(object o)
int PY_MAJOR_VERSION
ctypedef enum:
SIZEOF_VOID_P
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ from nodes import *
from loader import *
from dumper import *
__version__ = '3.06'
__version__ = '3.08'
try:
from cyaml import *
......@@ -91,10 +91,7 @@ def emit(events, stream=None, Dumper=Dumper,
"""
getvalue = None
if stream is None:
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
from StringIO import StringIO
stream = StringIO()
getvalue = stream.getvalue
dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
......@@ -115,10 +112,10 @@ def serialize_all(nodes, stream=None, Dumper=Dumper,
"""
getvalue = None
if stream is None:
try:
from cStringIO import StringIO
except ImportError:
if encoding is None:
from StringIO import StringIO
else:
from cStringIO import StringIO
stream = StringIO()
getvalue = stream.getvalue
dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
......@@ -151,10 +148,10 @@ def dump_all(documents, stream=None, Dumper=Dumper,
"""
getvalue = None
if stream is None:
try:
from cStringIO import StringIO
except ImportError:
if encoding is None:
from StringIO import StringIO
else:
from cStringIO import StringIO
stream = StringIO()
getvalue = stream.getvalue
dumper = Dumper(stream, default_style=default_style,
......
......@@ -68,7 +68,6 @@ class BaseConstructor(object):
"found unconstructable recursive node", node.start_mark)
self.recursive_objects[node] = None
constructor = None
state_constructor = None
tag_suffix = None
if node.tag in self.yaml_constructors:
constructor = self.yaml_constructors[node.tag]
......
......@@ -41,7 +41,7 @@ class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver):
encoding=None, explicit_start=None, explicit_end=None,
version=None, tags=None):
CEmitter.__init__(self, stream, canonical=canonical,
indent=indent, width=width,
indent=indent, width=width, encoding=encoding,
allow_unicode=allow_unicode, line_break=line_break,
explicit_start=explicit_start, explicit_end=explicit_end,
version=version, tags=tags)
......@@ -58,7 +58,7 @@ class CSafeDumper(CEmitter, SafeRepresenter, Resolver):
encoding=None, explicit_start=None, explicit_end=None,
version=None, tags=None):
CEmitter.__init__(self, stream, canonical=canonical,
indent=indent, width=width,
indent=indent, width=width, encoding=encoding,
allow_unicode=allow_unicode, line_break=line_break,
explicit_start=explicit_start, explicit_end=explicit_end,
version=version, tags=tags)
......@@ -75,7 +75,7 @@ class CDumper(CEmitter, Serializer, Representer, Resolver):
encoding=None, explicit_start=None, explicit_end=None,
version=None, tags=None):
CEmitter.__init__(self, stream, canonical=canonical,
indent=indent, width=width,
indent=indent, width=width, encoding=encoding,
allow_unicode=allow_unicode, line_break=line_break,
explicit_start=explicit_start, explicit_end=explicit_end,
version=version, tags=tags)
......
......@@ -16,7 +16,7 @@ class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver):
version=None, tags=None):
Emitter.__init__(self, stream, canonical=canonical,
indent=indent, width=width,
allow_uncode=allow_unicode, line_break=line_break)
allow_unicode=allow_unicode, line_break=line_break)
Serializer.__init__(self, encoding=encoding,
explicit_start=explicit_start, explicit_end=explicit_end,
version=version, tags=tags)
......
This diff is collapsed.
......@@ -72,8 +72,6 @@ class ParserError(MarkedYAMLError):
class Parser(object):
# Since writing a recursive-descendant parser is a straightforward task, we
# do not give many comments here.
# Note that we use Python generators. If you rewrite the parser in another
# language, you may replace all 'yield'-s with event handler calls.
DEFAULT_TAGS = {
u'!': u'!',
......
......@@ -74,7 +74,7 @@ class ReaderError(YAMLError):
else:
return "unacceptable character #x%04x: %s\n" \
" in \"%s\", position %d" \
% (ord(self.character), self.reason,
% (self.character, self.reason,
self.name, self.position)
class Reader(object):
......@@ -175,7 +175,7 @@ class Reader(object):
if match:
character = match.group()
position = self.index+(len(self.buffer)-self.pointer)+match.start()
raise ReaderError(self.name, position, character,
raise ReaderError(self.name, position, ord(character),
'unicode', "special characters are not allowed")
def update(self, length):
......
......@@ -286,6 +286,7 @@ SafeRepresenter.add_representer(set,
SafeRepresenter.add_representer(datetime.date,
SafeRepresenter.represent_date)
SafeRepresenter.add_representer(datetime.datetime,
SafeRepresenter.represent_datetime)
......
......@@ -192,7 +192,7 @@ Resolver.add_implicit_resolver(
Resolver.add_implicit_resolver(
u'tag:yaml.org,2002:merge',
re.compile(ur'^(?:<<)$'),
['<'])
[u'<'])
Resolver.add_implicit_resolver(
u'tag:yaml.org,2002:null',
......@@ -213,7 +213,7 @@ Resolver.add_implicit_resolver(
Resolver.add_implicit_resolver(
u'tag:yaml.org,2002:value',
re.compile(ur'^(?:=)$'),
['='])
[u'='])
# The following resolver is only for documentation purposes. It cannot work
# because plain scalars cannot start with '!', '&', or '*'.
......
......@@ -807,7 +807,7 @@ class Scanner(object):
# See the specification for details.
length = 0
ch = self.peek(length)
while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z' \
while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' \
or ch in u'-_':
length += 1
ch = self.peek(length)
......@@ -846,7 +846,7 @@ class Scanner(object):
def scan_yaml_directive_number(self, start_mark):
# See the specification for details.
ch = self.peek()
if not (u'0' <= ch <= '9'):
if not (u'0' <= ch <= u'9'):
raise ScannerError("while scanning a directive", start_mark,
"expected a digit, but found %r" % ch.encode('utf-8'),
self.get_mark())
......@@ -912,14 +912,14 @@ class Scanner(object):
# Therefore we restrict aliases to numbers and ASCII letters.
start_mark = self.get_mark()
indicator = self.peek()
if indicator == '*':
if indicator == u'*':
name = 'alias'
else:
name = 'anchor'
self.forward()
length = 0
ch = self.peek(length)
while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z' \
while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' \
or ch in u'-_':
length += 1
ch = self.peek(length)
......@@ -1368,7 +1368,7 @@ class Scanner(object):
length = 1
ch = self.peek(length)
if ch != u' ':
while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z' \
while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' \
or ch in u'-_':
length += 1
ch = self.peek(length)
......@@ -1388,7 +1388,7 @@ class Scanner(object):
chunks = []
length = 0
ch = self.peek(length)
while u'0' <= ch <= u'9' or u'A' <= ch <= 'Z' or u'a' <= ch <= 'z' \
while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' \
or ch in u'-;/?:@&=+$,_.!~*\'()[]%':
if ch == u'%':
chunks.append(self.prefix(length))
......
......@@ -55,7 +55,7 @@ class Serializer(object):
self.emit(DocumentEndEvent(explicit=self.use_explicit_end))
self.serialized_nodes = {}
self.anchors = {}
self.last_alias_id = 0
self.last_anchor_id = 0
def anchor_node(self, node):
if node in self.anchors:
......
from .error import *
from .tokens import *
from .events import *
from .nodes import *
from .loader import *
from .dumper import *
__version__ = '3.08'
try:
from .cyaml import *
__with_libyaml__ = True
except ImportError:
__with_libyaml__ = False
import io
def scan(stream, Loader=Loader):
"""
Scan a YAML stream and produce scanning tokens.
"""
loader = Loader(stream)
while loader.check_token():
yield loader.get_token()
def parse(stream, Loader=Loader):
"""
Parse a YAML stream and produce parsing events.
"""
loader = Loader(stream)
while loader.check_event():
yield loader.get_event()
def compose(stream, Loader=Loader):