Skip to content

compatible with python-2.6 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cldoc/generators/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ def generate(self, outdir):
except OSError:
pass

ElementTree.register_namespace('gobject', 'http://jessevdk.github.com/cldoc/gobject/1.0')
ElementTree.register_namespace('cldoc', 'http://jessevdk.github.com/cldoc/1.0')
if ElementTree.VERSION[0:3] == '1.2':
ElementTree._namespace_map['http://jessevdk.github.com/cldoc/gobject/1.0'] = 'gobject'
ElementTree._namespace_map['http://jessevdk.github.com/cldoc/1.0'] = 'cldoc'
else:
ElementTree.register_namespace('gobject', 'http://jessevdk.github.com/cldoc/gobject/1.0')
ElementTree.register_namespace('cldoc', 'http://jessevdk.github.com/cldoc/1.0')

self.index = ElementTree.Element('index')
self.written = {}
Expand Down Expand Up @@ -110,7 +114,10 @@ def write_xml(self, elem, fname):
self.indent(tree.getroot())

f = fs.fs.open(os.path.join(self.outdir, fname), 'w')
tree.write(f, encoding='utf-8', xml_declaration=True)
if ElementTree.VERSION[0:3] == '1.2':
tree.write(f, encoding='UTF-8')
else:
tree.write(f, encoding='UTF-8', xml_declaration=True)
f.write('\n')

f.close()
Expand Down
2 changes: 1 addition & 1 deletion tests/output/abstract-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" interface="true" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<method abstract="yes" id="A::f" name="f" virtual="yes">
<brief>A function of A.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/abstract-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
</index>
2 changes: 1 addition & 1 deletion tests/output/base-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<doc>
The class A.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/base-Base.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="Base" interface="true" name="Base" xmlns="http://jessevdk.github.com/cldoc/1.0">
<subclass access="public" name="A" ref="A#A" />
<method abstract="yes" id="Base::b" name="b" virtual="yes">
Expand Down
2 changes: 1 addition & 1 deletion tests/output/base-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
<class name="Base" ref="Base#Base" />
Expand Down
2 changes: 1 addition & 1 deletion tests/output/class-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<doc>
The class A.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/class-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
</index>
2 changes: 1 addition & 1 deletion tests/output/constructor-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<constructor id="A::A" name="A">
<brief>Constructor.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/constructor-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
</index>
2 changes: 1 addition & 1 deletion tests/output/cstruct-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<struct id="A" name="A" typedef="yes" xmlns="http://jessevdk.github.com/cldoc/1.0">
<field id="A::I" name="I">
<type builtin="yes" name="int" />
Expand Down
2 changes: 1 addition & 1 deletion tests/output/cstruct-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<struct name="A" ref="A#A" />
</index>
2 changes: 1 addition & 1 deletion tests/output/destructor-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<destructor id="A::~A" name="~A">
<brief>Destructor.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/destructor-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
</index>
2 changes: 1 addition & 1 deletion tests/output/enum-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<enum anonymous="yes" id="A" name="A">
<brief> The enum A.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/interface-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" interface="true" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<doc>
The class A.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/interface-Impl.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="Impl" name="Impl" xmlns="http://jessevdk.github.com/cldoc/1.0">
<doc>
The Impl class.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/interface-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
<class name="Impl" ref="Impl#Impl" />
Expand Down
2 changes: 1 addition & 1 deletion tests/output/method-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<method id="A::f" name="f">
<brief>A function of A.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/method-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
</index>
2 changes: 1 addition & 1 deletion tests/output/namespace-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<namespace id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<brief> The namespace A.</brief>
<doc>Longer description of namespace A.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/namespace-A::B.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A::B" name="B" xmlns="http://jessevdk.github.com/cldoc/1.0">
<brief>Class B.</brief>
<doc>Class B in namespace A.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/namespace-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<namespace name="A" ref="A#A">
<brief> The namespace A.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/operator-N.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<namespace id="N" name="N" xmlns="http://jessevdk.github.com/cldoc/1.0">
<struct name="A" ref="N::A#N::A" />
</namespace>
2 changes: 1 addition & 1 deletion tests/output/operator-N::A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<struct id="N::A" interface="true" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<method abstract="yes" id="N::A::operator&lt;" name="operator&lt;">
<return>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/operator-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<namespace name="N" ref="N#N">
<struct name="A" ref="N::A#N::A" />
Expand Down
2 changes: 1 addition & 1 deletion tests/output/struct-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<struct id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<brief> The struct A.</brief>
<doc>A longer description of A.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/struct-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<struct name="A" ref="A#A">
<brief> The struct A.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/template-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<classtemplate id="A" interface="true" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<brief> The class A.</brief>
<doc>A longer description of A.
Expand Down
2 changes: 1 addition & 1 deletion tests/output/template-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<classtemplate name="A" ref="A#A">
<brief> The class A.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/utf8-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<brief>Copyright ©</brief>
</class>
2 changes: 1 addition & 1 deletion tests/output/utf8-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A">
<brief>Copyright ©</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/virtual-A.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<class id="A" name="A" xmlns="http://jessevdk.github.com/cldoc/1.0">
<method id="A::f" name="f" virtual="yes">
<brief>A function of A.</brief>
Expand Down
2 changes: 1 addition & 1 deletion tests/output/virtual-index.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<index xmlns="http://jessevdk.github.com/cldoc/1.0">
<class name="A" ref="A#A" />
</index>
6 changes: 3 additions & 3 deletions tests/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
lcldoc = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, lcldoc)

import unittest
import unittest2
from cldoc import cmdgenerate

from cldoc import fs
Expand All @@ -15,7 +15,7 @@

fs.fs = fs.Virtual

class Regression(unittest.TestCase):
class Regression(unittest2.TestCase):
def setUp(self):
pass

Expand Down Expand Up @@ -70,6 +70,6 @@ def generate_tests():
generate_tests()

if __name__ == '__main__':
unittest.main()
unittest2.main()

# vi:ts=4:et