Changeset 49
- Timestamp:
- 02/19/06 03:10:24 (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
ext/_syckmodule.c (modified) (1 diff)
-
lib/syck/dumpers.py (modified) (2 diffs)
-
lib/syck/loaders.py (modified) (4 diffs)
-
setup.cfg (modified) (1 diff)
-
tests/test_dumper.py (modified) (2 diffs)
-
tests/test_loader.py (modified) (2 diffs)
-
tests/test_pickle.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/_syckmodule.c
r34 r49 2136 2136 PyObject *m; 2137 2137 2138 PyEval_InitThreads(); /* Fix segfault for Python 2.3 */ 2139 2138 2140 if (PyType_Ready(&PySyckNode_Type) < 0) 2139 2141 return; -
trunk/lib/syck/dumpers.py
r36 r49 144 144 return _syck.Scalar(value, tag="tag:yaml.org,2002:float") 145 145 146 def represent_complex(self, object): 147 if object.real != 0.0: 148 value = '%s+%sj' % (repr(object.real), repr(object.imag)) 149 else: 150 value = '%sj' % repr(object.imag) 151 return _syck.Scalar(value, tag="tag:python.yaml.org,2002:complex") 152 146 153 def represent_sets_Set(self, object): 147 154 return _syck.Seq(list(object), tag="tag:yaml.org,2002:set") … … 165 172 represent_function = represent_type 166 173 represent_builtin_function_or_method = represent_type 174 175 def represent_module(self, object): 176 return _syck.Scalar('', tag="tag:python.yaml.org,2002:module:"+object.__name__) 167 177 168 178 def represent_instance(self, object): -
trunk/lib/syck/loaders.py
r36 r49 13 13 14 14 try: 15 import sets 16 except ImportError: 17 class _sets: 18 def Set(self, items): 15 Set = set 16 except: 17 try: 18 from sets import Set 19 except ImportError: 20 def Set(items): 19 21 set = {} 20 22 for items in items: 21 23 set[items] = None 22 24 return set 23 sets = _sets()24 25 25 26 import _syck … … 288 289 289 290 def construct_set(self, node): 290 return sets.Set(node.value)291 return Set(node.value) 291 292 292 293 def construct_python_none(self, node): … … 304 305 def construct_python_float(self, node): 305 306 return float(node.value) 307 308 def construct_python_complex(self, node): 309 return complex(node.value) 306 310 307 311 def construct_python_str(self, node): … … 359 363 return self.find_python_object(node) 360 364 365 def construct_python_module(self, node): 366 module_name = node.tag.split(':')[3] 367 __import__(module_name) 368 return sys.modules[module_name] 369 361 370 def construct_python_object(self, node): 362 371 cls = self.find_python_object(node) -
trunk/setup.cfg
r36 r49 5 5 6 6 # List of directories to search for 'syck.h' (separated by ':'). 7 #include_dirs=/usr/local/include:../../include7 include_dirs=/usr/local/include 8 8 9 9 # List of directories to search for 'libsyck.a' (separated by ':'). 10 #library_dirs=/usr/local/lib:../../lib10 library_dirs=/usr/local/lib 11 11 -
trunk/tests/test_dumper.py
r23 r49 16 16 17 17 try: 18 import sets18 Set = set 19 19 except: 20 class _sets: 21 def Set(self, items): 20 try: 21 from sets import Set 22 except ImportError: 23 def Set(items): 22 24 set = {} 23 25 for items in items: 24 26 set[items] = None 25 27 return set 26 sets = _sets()27 28 28 29 29 EXAMPLE = { … … 73 73 74 74 COLLECTIONS = [ 75 sets.Set(range(10)),75 Set(range(10)), 76 76 ] 77 77 -
trunk/tests/test_loader.py
r23 r49 16 16 17 17 try: 18 import sets 19 except ImportError: 20 class _sets: 21 def Set(self, items): 18 Set = set 19 except: 20 try: 21 from sets import Set 22 except ImportError: 23 def Set(items): 22 24 set = {} 23 25 for items in items: 24 26 set[items] = None 25 27 return set 26 sets = _sets() 28 27 29 28 30 INF = 1e300000 … … 128 130 """, { 129 131 # 'baseball players': sets.Set(['Mark McGwire', 'Sammy Sosa', 'Ken Griffey']), 130 'baseball teams': sets.Set(['Boston Red Sox', 'Detroit Tigers', 'New York Yankees']),132 'baseball teams': Set(['Boston Red Sox', 'Detroit Tigers', 'New York Yankees']), 131 133 } 132 134 -
trunk/tests/test_pickle.py
r36 r49 12 12 - !python/long 12345678901234567890 13 13 - !python/float 123.456 14 - !python/float 123.4560000001 14 - !python/float 123456e-3 15 - !python/complex 1.0 16 - !python/complex 0.0+1.0j 15 17 - !python/str foo bar 16 - !python/unicode FOO ЀУ bar ба Ñ18 - !python/unicode FOO ЀУ bar ба 17 19 - !python/list [1, 2, 3] 18 20 - !python/tuple [foo, bar] … … 25 27 12345678901234567890L, 26 28 123.456, 27 123.4560000001, 29 123.456, 30 1+0j, 31 1j, 28 32 'foo bar', 29 unicode('FOO ЀУ bar ба Ñ', 'utf-8'),33 unicode('FOO ЀУ bar ба', 'utf-8'), 30 34 [1, 2, 3], 31 35 ('foo', 'bar'), … … 75 79 object, 76 80 ] 81 82 import sys, unittest, encodings.cp1251, os.path 83 84 MODULES = """ 85 - !python/module:sys 86 - !python/module:unittest 87 - !python/module:encodings.cp1251 88 - !python/module:os.path 89 """, [sys, unittest, encodings.cp1251, os.path] 77 90 78 91 class AnObject(object): … … 246 259 self._testPickle(NAMES) 247 260 261 def testModules(self): 262 self._testPickle(MODULES) 263 248 264 def testObjects(self): 249 265 self._testPickle(OBJECTS)
Note: See TracChangeset
for help on using the changeset viewer.
