Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Unified Diff: third_party/cython/src/Cython/Debugger/DebugWriter.py

Issue 385073004: Adding cython v0.20.2 in third-party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reference cython dev list thread. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/cython/src/Cython/Debugger/DebugWriter.py
diff --git a/third_party/cython/src/Cython/Debugger/DebugWriter.py b/third_party/cython/src/Cython/Debugger/DebugWriter.py
new file mode 100644
index 0000000000000000000000000000000000000000..7242a582ed6e3add6be064b0c11d416fe0553b22
--- /dev/null
+++ b/third_party/cython/src/Cython/Debugger/DebugWriter.py
@@ -0,0 +1,78 @@
+from __future__ import with_statement
+
+import os
+import sys
+import errno
+
+try:
+ from lxml import etree
+ have_lxml = True
+except ImportError:
+ have_lxml = False
+ try:
+ # Python 2.5
+ from xml.etree import cElementTree as etree
+ except ImportError:
+ try:
+ # Python 2.5
+ from xml.etree import ElementTree as etree
+ except ImportError:
+ try:
+ # normal cElementTree install
+ import cElementTree as etree
+ except ImportError:
+ try:
+ # normal ElementTree install
+ import elementtree.ElementTree as etree
+ except ImportError:
+ etree = None
+
+from Cython.Compiler import Errors
+
+
+class CythonDebugWriter(object):
+ """
+ Class to output debugging information for cygdb
+
+ It writes debug information to cython_debug/cython_debug_info_<modulename>
+ in the build directory.
+ """
+
+ def __init__(self, output_dir):
+ if etree is None:
+ raise Errors.NoElementTreeInstalledException()
+
+ self.output_dir = os.path.join(output_dir, 'cython_debug')
+ self.tb = etree.TreeBuilder()
+ # set by Cython.Compiler.ParseTreeTransforms.DebugTransform
+ self.module_name = None
+ self.start('cython_debug', attrs=dict(version='1.0'))
+
+ def start(self, name, attrs=None):
+ self.tb.start(name, attrs or {})
+
+ def end(self, name):
+ self.tb.end(name)
+
+ def serialize(self):
+ self.tb.end('Module')
+ self.tb.end('cython_debug')
+ xml_root_element = self.tb.close()
+
+ try:
+ os.makedirs(self.output_dir)
+ except OSError, e:
+ if e.errno != errno.EEXIST:
+ raise
+
+ et = etree.ElementTree(xml_root_element)
+ kw = {}
+ if have_lxml:
+ kw['pretty_print'] = True
+
+ fn = "cython_debug_info_" + self.module_name
+ et.write(os.path.join(self.output_dir, fn), encoding="UTF-8", **kw)
+
+ interpreter_path = os.path.join(self.output_dir, 'interpreter')
+ with open(interpreter_path, 'w') as f:
+ f.write(sys.executable)
« no previous file with comments | « third_party/cython/src/Cython/Debugger/Cygdb.py ('k') | third_party/cython/src/Cython/Debugger/Tests/TestLibCython.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698