Commit 86822a65 authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 3.10

parent 3e293a44
For a complete Subversion changelog, see 'http://pyyaml.org/log/pyyaml'.
3.10 (2011-05-30)
-----------------
* Do not try to build LibYAML bindings on platforms other than CPython
(Thank to olt(at)bogosoft(dot)com).
* Clear cyclic references in the parser and the emitter
(Thank to kristjan(at)ccpgames(dot)com).
* Dropped support for Python 2.3 and 2.4.
3.09 (2009-08-31)
-----------------
......
Metadata-Version: 1.0
Name: PyYAML
Version: 3.09
Version: 3.10
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.09.tar.gz
Download-URL: http://pyyaml.org/download/pyyaml/PyYAML-3.10.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.
......@@ -29,8 +29,10 @@ 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 :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.0
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup
This diff is collapsed.
......@@ -311,6 +311,9 @@ cdef class CParser:
yaml_parser_delete(&self.parser)
yaml_event_delete(&self.parsed_event)
def dispose(self):
pass
cdef object _parser_error(self):
if self.parser.error == YAML_MEMORY_ERROR:
return MemoryError
......@@ -993,6 +996,9 @@ cdef class CEmitter:
def __dealloc__(self):
yaml_emitter_delete(&self.emitter)
def dispose(self):
pass
cdef object _emitter_error(self):
if self.emitter.error == YAML_MEMORY_ERROR:
return MemoryError
......
......@@ -8,7 +8,7 @@ from nodes import *
from loader import *
from dumper import *
__version__ = '3.09'
__version__ = '3.10'
try:
from cyaml import *
......@@ -21,16 +21,22 @@ def scan(stream, Loader=Loader):
Scan a YAML stream and produce scanning tokens.
"""
loader = Loader(stream)
try:
while loader.check_token():
yield loader.get_token()
finally:
loader.dispose()
def parse(stream, Loader=Loader):
"""
Parse a YAML stream and produce parsing events.
"""
loader = Loader(stream)
try:
while loader.check_event():
yield loader.get_event()
finally:
loader.dispose()
def compose(stream, Loader=Loader):
"""
......@@ -38,7 +44,10 @@ def compose(stream, Loader=Loader):
and produce the corresponding representation tree.
"""
loader = Loader(stream)
try:
return loader.get_single_node()
finally:
loader.dispose()
def compose_all(stream, Loader=Loader):
"""
......@@ -46,8 +55,11 @@ def compose_all(stream, Loader=Loader):
and produce corresponding representation trees.
"""
loader = Loader(stream)
try:
while loader.check_node():
yield loader.get_node()
finally:
loader.dispose()
def load(stream, Loader=Loader):
"""
......@@ -55,7 +67,10 @@ def load(stream, Loader=Loader):
and produce the corresponding Python object.
"""
loader = Loader(stream)
try:
return loader.get_single_data()
finally:
loader.dispose()
def load_all(stream, Loader=Loader):
"""
......@@ -63,8 +78,11 @@ def load_all(stream, Loader=Loader):
and produce corresponding Python objects.
"""
loader = Loader(stream)
try:
while loader.check_data():
yield loader.get_data()
finally:
loader.dispose()
def safe_load(stream):
"""
......@@ -96,8 +114,11 @@ def emit(events, stream=None, Dumper=Dumper,
getvalue = stream.getvalue
dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
allow_unicode=allow_unicode, line_break=line_break)
try:
for event in events:
dumper.emit(event)
finally:
dumper.dispose()
if getvalue:
return getvalue()
......@@ -122,10 +143,13 @@ def serialize_all(nodes, stream=None, Dumper=Dumper,
allow_unicode=allow_unicode, line_break=line_break,
encoding=encoding, version=version, tags=tags,
explicit_start=explicit_start, explicit_end=explicit_end)
try:
dumper.open()
for node in nodes:
dumper.serialize(node)
dumper.close()
finally:
dumper.dispose()
if getvalue:
return getvalue()
......@@ -160,10 +184,13 @@ def dump_all(documents, stream=None, Dumper=Dumper,
allow_unicode=allow_unicode, line_break=line_break,
encoding=encoding, version=version, tags=tags,
explicit_start=explicit_start, explicit_end=explicit_end)
try:
dumper.open()
for data in documents:
dumper.represent(data)
dumper.close()
finally:
dumper.dispose()
if getvalue:
return getvalue()
......
......@@ -7,11 +7,6 @@ from nodes import *
import datetime
try:
set
except NameError:
from sets import Set as set
import binascii, re, sys, types
class ConstructorError(MarkedYAMLError):
......@@ -58,11 +53,11 @@ class BaseConstructor(object):
return data
def construct_object(self, node, deep=False):
if node in self.constructed_objects:
return self.constructed_objects[node]
if deep:
old_deep = self.deep_construct
self.deep_construct = True
if node in self.constructed_objects:
return self.constructed_objects[node]
if node in self.recursive_objects:
raise ConstructorError(None, None,
"found unconstructable recursive node", node.start_mark)
......@@ -502,11 +497,7 @@ class Constructor(SafeConstructor):
raise ConstructorError("while constructing a Python object", mark,
"expected non-empty name appended to the tag", mark)
if u'.' in name:
# Python 2.4 only
#module_name, object_name = name.rsplit('.', 1)
items = name.split('.')
object_name = items.pop()
module_name = '.'.join(items)
module_name, object_name = name.rsplit('.', 1)
else:
module_name = '__builtin__'
object_name = name
......
......@@ -103,6 +103,11 @@ class Emitter(object):
self.analysis = None
self.style = None
def dispose(self):
# Reset the state attributes (to clear self-references)
self.states = []
self.state = None
def emit(self, event):
self.events.append(event)
while not self.need_more_events():
......
......@@ -86,6 +86,11 @@ class Parser(object):
self.marks = []
self.state = self.parse_stream_start
def dispose(self):
# Reset the state attributes (to clear self-references)
self.states = []
self.state = None
def check_event(self, *choices):
# Check the type of the next event.
if self.current_event is None:
......
......@@ -21,41 +21,6 @@ from error import YAMLError, Mark
import codecs, re
# Unfortunately, codec functions in Python 2.3 does not support the `finish`
# arguments, so we have to write our own wrappers.
try:
codecs.utf_8_decode('', 'strict', False)
from codecs import utf_8_decode, utf_16_le_decode, utf_16_be_decode
except TypeError:
def utf_16_le_decode(data, errors, finish=False):
if not finish and len(data) % 2 == 1:
data = data[:-1]
return codecs.utf_16_le_decode(data, errors)
def utf_16_be_decode(data, errors, finish=False):
if not finish and len(data) % 2 == 1:
data = data[:-1]
return codecs.utf_16_be_decode(data, errors)
def utf_8_decode(data, errors, finish=False):
if not finish:
# We are trying to remove a possible incomplete multibyte character
# from the suffix of the data.
# The first byte of a multi-byte sequence is in the range 0xc0 to 0xfd.
# All further bytes are in the range 0x80 to 0xbf.
# UTF-8 encoded UCS characters may be up to six bytes long.
count = 0
while count < 5 and count < len(data) \
and '\x80' <= data[-count-1] <= '\xBF':
count -= 1
if count < 5 and count < len(data) \
and '\xC0' <= data[-count-1] <= '\xFD':
data = data[:-count-1]
return codecs.utf_8_decode(data, errors)
class ReaderError(YAMLError):
def __init__(self, name, position, character, encoding, reason):
......@@ -159,13 +124,13 @@ class Reader(object):
self.update_raw()
if not isinstance(self.raw_buffer, unicode):
if self.raw_buffer.startswith(codecs.BOM_UTF16_LE):
self.raw_decode = utf_16_le_decode
self.raw_decode = codecs.utf_16_le_decode
self.encoding = 'utf-16-le'
elif self.raw_buffer.startswith(codecs.BOM_UTF16_BE):
self.raw_decode = utf_16_be_decode
self.raw_decode = codecs.utf_16_be_decode
self.encoding = 'utf-16-be'
else:
self.raw_decode = utf_8_decode
self.raw_decode = codecs.utf_8_decode
self.encoding = 'utf-8'
self.update(1)
......
......@@ -7,11 +7,6 @@ from nodes import *
import datetime
try:
set
except NameError:
from sets import Set as set
import sys, copy_reg, types
class RepresenterError(YAMLError):
......
......@@ -8,7 +8,7 @@ from .nodes import *
from .loader import *
from .dumper import *
__version__ = '3.09'
__version__ = '3.10'
try:
from .cyaml import *
__with_libyaml__ = True
......@@ -22,16 +22,22 @@ def scan(stream, Loader=Loader):
Scan a YAML stream and produce scanning tokens.
"""
loader = Loader(stream)
try:
while loader.check_token():
yield loader.get_token()
finally:
loader.dispose()
def parse(stream, Loader=Loader):
"""
Parse a YAML stream and produce parsing events.
"""
loader = Loader(stream)
try:
while loader.check_event():
yield loader.get_event()
finally:
loader.dispose()
def compose(stream, Loader=Loader):
"""
......@@ -39,7 +45,10 @@ def compose(stream, Loader=Loader):
and produce the corresponding representation tree.
"""
loader = Loader(stream)
try:
return loader.get_single_node()
finally:
loader.dispose()
def compose_all(stream, Loader=Loader):
"""
......@@ -47,8 +56,11 @@ def compose_all(stream, Loader=Loader):
and produce corresponding representation trees.
"""
loader = Loader(stream)
try:
while loader.check_node():
yield loader.get_node()
finally:
loader.dispose()
def load(stream, Loader=Loader):
"""
......@@ -56,7 +68,10 @@ def load(stream, Loader=Loader):
and produce the corresponding Python object.
"""
loader = Loader(stream)
try:
return loader.get_single_data()
finally:
loader.dispose()
def load_all(stream, Loader=Loader):
"""
......@@ -64,8 +79,11 @@ def load_all(stream, Loader=Loader):
and produce corresponding Python objects.
"""
loader = Loader(stream)
try:
while loader.check_data():
yield loader.get_data()
finally:
loader.dispose()
def safe_load(stream):
"""
......@@ -96,8 +114,11 @@ def emit(events, stream=None, Dumper=Dumper,
getvalue = stream.getvalue
dumper = Dumper(stream, canonical=canonical, indent=indent, width=width,
allow_unicode=allow_unicode, line_break=line_break)
try:
for event in events:
dumper.emit(event)
finally:
dumper.dispose()
if getvalue:
return getvalue()
......@@ -121,10 +142,13 @@ def serialize_all(nodes, stream=None, Dumper=Dumper,
allow_unicode=allow_unicode, line_break=line_break,
encoding=encoding, version=version, tags=tags,
explicit_start=explicit_start, explicit_end=explicit_end)
try:
dumper.open()
for node in nodes:
dumper.serialize(node)
dumper.close()
finally:
dumper.dispose()
if getvalue:
return getvalue()
......@@ -158,10 +182,13 @@ def dump_all(documents, stream=None, Dumper=Dumper,
allow_unicode=allow_unicode, line_break=line_break,
encoding=encoding, version=version, tags=tags,
explicit_start=explicit_start, explicit_end=explicit_end)
try:
dumper.open()
for data in documents:
dumper.represent(data)
dumper.close()
finally:
dumper.dispose()
if getvalue:
return getvalue()
......
......@@ -51,11 +51,11 @@ class BaseConstructor:
return data
def construct_object(self, node, deep=False):
if node in self.constructed_objects:
return self.constructed_objects[node]
if deep:
old_deep = self.deep_construct
self.deep_construct = True
if node in self.constructed_objects:
return self.constructed_objects[node]
if node in self.recursive_objects:
raise ConstructorError(None, None,
"found unconstructable recursive node", node.start_mark)
......
......@@ -103,6 +103,11 @@ class Emitter:
self.analysis = None
self.style = None
def dispose(self):
# Reset the state attributes (to clear self-references)
self.states = []
self.state = None
def emit(self, event):
self.events.append(event)
while not self.need_more_events():
......
......@@ -86,6 +86,11 @@ class Parser:
self.marks = []
self.state = self.parse_stream_start
def dispose(self):
# Reset the state attributes (to clear self-references)
self.states = []
self.state = None
def check_event(self, *choices):
# Check the type of the next event.
if self.current_event is None:
......
......@@ -17,19 +17,19 @@
# The following options are used to build PyYAML Windows installer
# for Python 2.3 on my PC:
#include_dirs=../../../libyaml/tags/0.1.3/include
#library_dirs=../../../libyaml/tags/0.1.3/win32/vc6/output/release/lib
#include_dirs=../../../libyaml/tags/0.1.4/include
#library_dirs=../../../libyaml/tags/0.1.4/win32/vc6/output/release/lib
#define=YAML_DECLARE_STATIC
# The following options are used to build PyYAML Windows installer
# for Python 2.4 and Python 2.5 on my PC:
#include_dirs=../../../libyaml/tags/0.1.3/include
#library_dirs=../../../libyaml/tags/0.1.3/win32/vs2003/output/release/lib
#include_dirs=../../../libyaml/tags/0.1.4/include
#library_dirs=../../../libyaml/tags/0.1.4/win32/vs2003/output/release/lib
#define=YAML_DECLARE_STATIC
# The following options are used to build PyYAML Windows installer
# for Python 2.6, Python 3.0 and Python 3.1 on my PC:
#include_dirs=../../../libyaml/tags/0.1.3/include
#library_dirs=../../../libyaml/tags/0.1.3/win32/vs2008/output/release/lib
# for Python 2.6, 2.7, 3.0, 3.1 and 3.2 on my PC:
#include_dirs=../../../libyaml/tags/0.1.4/include
#library_dirs=../../../libyaml/tags/0.1.4/win32/vs2008/output/release/lib
#define=YAML_DECLARE_STATIC
NAME = 'PyYAML'
VERSION = '3.09'
VERSION = '3.10'
DESCRIPTION = "YAML parser and emitter for Python"
LONG_DESCRIPTION = """\
YAML is a data serialization format designed for human readability
......@@ -31,9 +31,11 @@ CLASSIFIERS = [
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.0",
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
]
......@@ -122,6 +124,8 @@ class Distribution(_Distribution):
return False
def ext_status(self, ext):
if 'Java' in sys.version or 'IronPython' in sys.version or 'PyPy' in sys.version:
return False
if isinstance(ext, Extension):
with_ext = getattr(self, ext.attr_name)
return with_ext
......
......@@ -211,6 +211,9 @@ class CanonicalParser:
self.events = []
self.parsed = False
def dispose(self):
pass
# stream: STREAM-START document* STREAM-END
def parse_stream(self):
self.get_token(yaml.StreamStartToken)
......
......@@ -212,6 +212,9 @@ class CanonicalParser:
self.events = []
self.parsed = False
def dispose(self):
pass
# stream: STREAM-START document* STREAM-END
def parse_stream(self):
self.get_token(yaml.StreamStartToken)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment