~ubuntu-branches/ubuntu/saucy/python-networkx/saucy

« back to all changes in this revision

Viewing changes to networkx/readwrite/nx_yaml.py

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2009-02-28 13:36:24 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090228133624-9l5rwi1ftlzc7b0l
* Upload to unstable now that lenny is released (yay).
* Fix FTBFS with python-support 0.90.3: no longer rely on its internal
  behaviour, and xnow set tests/test.py executable right after “setup.py
  install” (Closes: #517065).
* Drop executable bits from bz2 files.
* Update Vcs-* fields: move from DPMT's svn to collab-maint's git.
* Remote DPMT from Uploaders, following Piotr Ożarowski's request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""
 
2
****
 
3
YAML
 
4
****
 
5
 
2
6
Read and write NetworkX graphs in YAML format.
3
7
See http://www.yaml.org for documentation.
4
8
 
5
9
"""
6
10
__author__ = """Aric Hagberg (hagberg@lanl.gov)"""
7
 
__date__ = """"""
8
 
__credits__ = """"""
9
 
__revision__ = "$$"
10
 
#    Copyright (C) 2004-2007 by 
 
11
#    Copyright (C) 2004-2008 by 
11
12
#    Aric Hagberg <hagberg@lanl.gov>
12
13
#    Dan Schult <dschult@colgate.edu>
13
14
#    Pieter Swart <swart@lanl.gov>
14
15
#    Distributed under the terms of the GNU Lesser General Public License
15
16
#    http://www.gnu.org/copyleft/lesser.html
16
17
 
 
18
__all__ = ['read_yaml', 'write_yaml']
 
19
 
17
20
import cPickle 
18
21
import codecs
19
22
import locale
55
58
    return yaml.load(fh)
56
59
 
57
60
 
58
 
 
59
 
def _test_suite():
60
 
    import doctest
61
 
    import yaml
62
 
    suite = doctest.DocFileSuite('tests/readwrite/nx_yaml.txt',package='networkx')
63
 
    return suite
64
 
 
65
 
if __name__ == "__main__":
66
 
    import os 
67
 
    import sys
68
 
    import unittest
69
 
    if sys.version_info[:2] < (2, 4):
70
 
        print "Python version 2.4 or later required for tests (%d.%d detected)." %  sys.version_info[:2]
71
 
        sys.exit(-1)
72
 
    # directory of networkx package (relative to this)
73
 
    nxbase=sys.path[0]+os.sep+os.pardir
74
 
    sys.path.insert(0,nxbase) # prepend to search path
75
 
    unittest.TextTestRunner().run(_test_suite())
76