summaryrefslogtreecommitdiff
path: root/giscanner/xmlwriter.py
Commit message (Collapse)AuthorAgeFilesLines
* Clean shebangs out of non-executable scripts and drop exec perm from ↵Dominique Leuenberger2019-01-091-0/+0
| | | | xmlwriter.py
* Drop all Python 2 compat codeChristoph Reiter2018-12-081-15/+2
| | | | We only support 3.4+ now.
* tests: depend on flake8 instead of including pep8/pyflakesChristoph Reiter2018-08-151-1/+0
| | | | | | | | | | | | | | | | g-i includes an old version of pep8 and pyflakes and uses that during "make check". It (1) doesn't catch all cases newer versions of pycodestyle/pyflakes catch and (2) doesn't test all Python files (3) doesn't work with meson. Instead of updating just remove them and depend on flake8 instead. To run the checks simply run flake8 in the root dir. This also makes it possible to run those checks when using meson and not autotools. To not get test suite failures on flake8 updates move the checks from "make check" to an extra "make check.quality" target.
* xmlwriter: move collect_attributes() back to a Python implementationChristoph Reiter2018-07-271-7/+37
| | | | | | | | | This reverts f345916405d94829696985 and related. The commit states that both versions are about the same in performance, but the C version is more code and harder to maintain. It also states that the behaviour re invalid control characters is better with the C version which produces entities. But those make any Python xml parser fail, which given that most of our tooling is Python, doesn't seem better to me, see #135.
* tests: run xmlwriter tests during make checkChristoph Reiter2018-07-271-24/+0
| | | | | There was a stray test() function already there. Move it to a unittest file and run it with the other tests.
* giscanner: Use StringIO instead of cStringIO in Python 2Simon Feltman2015-09-291-6/+21
| | | | | | | | | | | | Replace usage of the Python 2 cStringIO module with StringIO and conditionally use io.StringIO for Python 3. This is needed to build up a unicode version of the XML since cStringIO does not support unicode. Add XMLWriter.get_encoded_xml() which returns a utf-8 encoded bytes object of the XML data. Open files for reading/writing in binary mode since we explicitly encode and decode as utf-8. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use unicode literals in all Python filesSimon Feltman2015-09-291-13/+14
| | | | | | | | | | | | Add unicode_literals future import which turns any string literal into a unicode string. Return unicode strings from the Python C extension module. Force writing of annotations (g-ir-annotation-tool) to output utf8 encoded data to stdout. This is an initial pass at following the "unicode sandwich" model of programming (http://nedbatchelder.com/text/unipain.html) needed for supporting Python 3. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use print as a function for Python 3 compatibilitySimon Feltman2015-09-291-0/+1
| | | | | | | Use future import "print_function" and update relevant uses of print as a function call. See: PEP 3105 https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Enable "true division" for all Python filesSimon Feltman2015-09-291-0/+1
| | | | | | | | | | Import Python 3 compatible "true division" from the future (PEP 238). This changes the Python 2 classic division which uses floor division on integers to true division. Verfied we don't actually use the division operator anywhere in the code base so this a safety for supporting both Python 2 and 3. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: Use absolute_import for all Python filesSimon Feltman2015-09-291-0/+1
| | | | | | Use absolute_import to ensure Python 3 compatibility of the code base. https://bugzilla.gnome.org/show_bug.cgi?id=679438
* giscanner: remove Python xml attribute formatterDieter Verfaillie2013-10-091-44/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no sense in keeping it around as it is never used. And even though measuring the time it takes to build Gtk-3.0.gir using a) the C version and b) the Python version reveals there is no measurable difference to speak of (when *not* running under Python's cProfile module): With C collect_attributes: ========================== real 0m30.614s real 0m32.255s real 0m31.034s With Python collect_attributes: =============================== real 0m31.530s real 0m31.549s real 0m31.673s The C version ends up using g_markup_escape_text() which will escape \004 as . Even though this is invalid xml 1.0 (but valid xml 1.1), the Python version leaves the \004 as is, which is even less desirable...
* tests: Update misc/pep8.py to 1.4.5Dieter Verfaillie2013-05-071-10/+8
| | | | | | | | | | | | | | | | | Version in our tree is a wee bit outdated. For example, later work will introduce an utf8 encoded python source file which our old pep8.py does not yet understand (yeah, it really was *that* ancient)... Updated from: https://raw.github.com/jcrocholl/pep8/1.4.5/pep8.py Takes 552c1f1525e37a30376790151c1ba437776682c5, f941537d1c0a40f0906490ed160db6c79af572d3, 5a4afe2a77d0ff7d9fea13dd93c3304a6ca993de and a17f157e19bd6792c00321c8020dca5e5a281f45 into account... https://bugzilla.gnome.org/show_bug.cgi?id=699535
* giscanner: remove unneeded encode('utf-8').decode('utf-8') roundtripDieter Verfaillie2013-05-071-1/+1
| | | | | | | | | line is a unicode() instance, xml.sax.saxutils.escape() does nothing more than call a couple of replace() methods on said unicode() instance so it makes little sense to encode line into a str() and decode the escaped result back into a unicode(). https://bugzilla.gnome.org/show_bug.cgi?id=699533
* mallardwriter: Use xmlwriter for xrefsJasper St. Pierre2013-02-011-15/+19
|
* giscanner/mallardwriter: Adding experimental Mallard output to g-ir-doc-toolShaun McCance2011-08-151-1/+1
|
* scanner: More XML unicode fixesColin Walters2010-12-021-9/+13
| | | | | | Coerce input temporarily inside xmlwriter into Unicode to do string manipulation, and then only convert it to "UTF8str" when writing into the data buffer.
* Add proper unicode support to the source scannerJohan Dahlin2010-12-021-1/+1
| | | | | | The assumption is that the only allowed source encoding is utf-8. Always strings as unicode and fix up the transformer and xml writer to properly output utf-8.
* Switch to nonrecursive make for core (i.e. not tests/)Colin Walters2010-11-091-1/+6
| | | | | This is cleaner and faster, and prepares us better for an incoming import of CMPH.
* Add ability to write unindented lines via xmlwriterZachary Goldberg2010-08-171-3/+20
|
* [scanner] Make it compatible with python 2.yJohan Dahlin2010-07-221-1/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=618562
* Move doc to toplevel element, write <any> for unknown containersColin Walters2010-07-081-2/+2
| | | | | | | | | Moving to <doc> allows us to better preserve whitespace. XML has no facility for whitespace-preserving attributes. Second, for arrays and lists, both types with unknown element_type can occur in the current scanner; it's least wrong if we write out an <any> type.
* Bug 571548 - Generic attributesColin Walters2009-03-031-0/+2
| | | | | | | | We now support an extensible mechanism where arbitrary key-value pairs may be associated with almost all items, including objects, methods, and properties. These attributes appear in both the .gir and the .typelib.
* Send in an empty list instead of None.Johan Dahlin2009-02-201-0/+2
|
* Add generated file warning commentColin Walters2009-01-141-0/+3
| | | | | | We don't want people manually editing .gir files. svn path=/trunk/; revision=1034
* Bug 563794 - Redo annotation parsing & applyingJohan Dahlin2009-01-121-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2009-01-12 Johan Dahlin <jdahlin@async.com.br> Bug 563794 - Redo annotation parsing & applying Thanks to Colin for helping out considerably in landing this. * giscanner/Makefile.am: * giscanner/ast.py: * giscanner/dumper.py: * giscanner/girparser.py: * giscanner/giscannermodule.c (pygi_source_scanner_get_comments), (calc_attrs_length), (pygi_collect_attributes), (init_giscanner): * giscanner/glibtransformer.py: * giscanner/scannerlexer.l: * giscanner/sourcescanner.c (gi_source_symbol_unref), (gi_source_scanner_new), (gi_source_scanner_free), (gi_source_scanner_get_comments): * giscanner/sourcescanner.h: * giscanner/sourcescanner.py: * giscanner/transformer.py: * giscanner/xmlwriter.py: * tests/scanner/annotation-1.0-expected.gir: * tests/scanner/annotation-1.0-expected.tgir: * tests/scanner/annotation.c: * tests/scanner/annotation.h: * tests/scanner/foo-1.0-expected.gir: * tests/scanner/foo-1.0-expected.tgir: * tests/scanner/foo.h: * tools/g-ir-scanner: This commit merges the annotation parser rewrite branch. It'll change the annotation parsing to be done completely in python code which will make it easier to do further annotation parsing easier. svn path=/trunk/; revision=1017
* Fix inconsistencies with PEP8Jürg Billeter2009-01-031-2/+0
| | | | | | | | | | | | | | | | 2009-01-03 Jürg Billeter <j@bitron.ch> * giscanner/ast.py: * giscanner/dumper.py: * giscanner/girparser.py: * giscanner/glibtransformer.py: * giscanner/sourcescanner.py: * giscanner/transformer.py: * giscanner/xmlwriter.py: Fix inconsistencies with PEP8 svn path=/trunk/; revision=997
* Relicense the giscanner library under LGPLv2+. This has been approved byJohan Dahlin2008-11-041-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2008-11-04 Johan Dahlin <jdahlin@async.com.br> * giscanner/__init__.py: * giscanner/ast.py: * giscanner/cachestore.py: * giscanner/cgobject.py: * giscanner/girparser.py: * giscanner/girwriter.py: * giscanner/giscannermodule.c: * giscanner/glibast.py: * giscanner/glibtransformer.py: * giscanner/libtoolimporter.py: * giscanner/minixpath.py: * giscanner/odict.py: * giscanner/sourcescanner.c: * giscanner/sourcescanner.h: * giscanner/sourcescanner.py: * giscanner/transformer.py: * giscanner/utils.py: * giscanner/xmlwriter.py: * COPYING: Relicense the giscanner library under LGPLv2+. This has been approved by all contributors. svn path=/trunk/; revision=862
* Write a C version of the xml namespace formatter. Saves 15% of the time itJohan Dahlin2008-10-301-4/+12
| | | | | | | | | | | | | 2008-10-30 Johan Dahlin <jdahlin@async.com.br> * giscanner/giscannermodule.c (calc_attrs_length), (pygi_collect_attributes): * giscanner/xmlwriter.py: Write a C version of the xml namespace formatter. Saves 15% of the time it takes to create a gtk gir. svn path=/trunk/; revision=846
* Abstract attribute formatting to a function external to the XMLWriterJohan Dahlin2008-10-301-41/+49
| | | | | | | | | | 2008-10-30 Johan Dahlin <jdahlin@async.com.br> * giscanner/xmlwriter.py: Abstract attribute formatting to a function external to the XMLWriter class. svn path=/trunk/; revision=845
* Bug 554854: The --typelib-xml and --inject options should reuse giscannerLucas Rocha2008-10-111-5/+11
| | | | | | | | | | | | | | | | | | | 2008-10-11 Lucas Rocha <lucasr@gnome.org> Bug 554854: The --typelib-xml and --inject options should reuse giscanner parser/writer. * giscanner/ast.py: add constructor list to Struct and Union. Add new param in Return's contructor to define transfer. * giscanner/girparser.py: several additions to the parser in order to have parsing all nodes of the gir xml files. * tools/g-ir-scanner (typelib_xml_strip, inject): use gir parser and writer in --inject and --typelib-xml options. * giscanner/xmlwriter.py: ignore empty attributes instead of raising an error as this basically exposes a bug in GIRParser. This should be reverted as soon as the parser is fixed. svn path=/trunk/; revision=665
* Pass through recursive types. Avoid overwriting errors. Always write theColin Walters2008-08-221-0/+1
| | | | | | | | | | | | | | | | | | | | 2008-08-22 Colin Walters <walters@verbum.org> * girepository/girparser.c: Pass through recursive types. Avoid overwriting errors. * giscanner/xmlwriter.py: Always write the XML header. * tests/*.gir: Adjust. * tests/scanner/Makefile.am: Build typelibs, and generate XML from those. Once we have a good diff mechanism... * tests/scanner/*-expected.gir: Add XML header. * tools/g-ir-scanner: Accept --typelib-xml option. * tools/generate.c: Better defaults for transfer. svn path=/trunk/; revision=457
* PEP8ifyJohan Dahlin2008-08-091-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | 2008-08-09 Johan Dahlin <johan@gnome.org> * giscanner/__init__.py: * giscanner/ast.py: * giscanner/cgobject.py: * giscanner/gidlparser.py: * giscanner/gidlwriter.py: * giscanner/girparser.py: * giscanner/girwriter.py: * giscanner/glibast.py: * giscanner/glibtransformer.py: * giscanner/odict.py: * giscanner/sourcescanner.py: * giscanner/transformer.py: * giscanner/utils.py: * giscanner/xmlwriter.py: * tools/g-ir-scanner: PEP8ify svn path=/trunk/; revision=341
* Improve line wrapping when > 79 charatersJohan Dahlin2008-06-071-7/+31
| | | | | | | | | | 2008-06-07 Johan Dahlin <jdahlin@async.com.br> * giscanner/xmlwriter.py: Improve line wrapping when > 79 charaters svn path=/trunk/; revision=286
* Improve error reporting when trying to quote None. Do not print warningsJohan Dahlin2008-05-311-1/+6
| | | | | | | | | | | | | | | | | | | | | 2008-05-31 Johan Dahlin <jdahlin@async.com.br> * giscanner/xmlwriter.py: Improve error reporting when trying to quote None. * giscanner/girparser.py: Do not print warnings when including more complete .gir files * giscanner/girwriter.py: Do not require a name for parameters, add a todo for singletons * giscanner/glibtransformer.py: Refactor the way structs are done, add a couple of hacks to allow us to get further. * giscanner/transformer.py: Add enough hacks so cairo, atk and pango.gir can be parsed properly * gobject-introspection-1.0.pc.in: Export girdir, so we can access gobject-2.0.gir from outside svn path=/trunk/; revision=280
* Write record/structs to gir file too. Add a couple of tests, fix an off byJohan Dahlin2008-04-291-1/+1
| | | | | | | | | | | | | | | | 2008-04-29 Johan Dahlin <jdahlin@async.com.br> * giscanner/girwriter.py: * giscanner/glibtransformer.py: * giscanner/transformer.py: * giscanner/xmlwriter.py: * tests/parser/Foo-expected.gir: * tests/parser/foo-object.h: Write record/structs to gir file too. Add a couple of tests, fix an off by one error in xmlwriter.py. svn path=/trunk/; revision=257
* Calculate the line length properly, include the provided extra indentationJohan Dahlin2008-04-281-6/+6
| | | | | | | | | | 2008-04-28 Johan Dahlin <johan@gnome.org> * giscanner/xmlwriter.py: Calculate the line length properly, include the provided extra indentation in the calculation, really. svn path=/trunk/; revision=256
* Check explicitly for None, so we can write FalseJohan Dahlin2008-04-281-1/+1
| | | | svn path=/trunk/; revision=248
* Line wrap license headerJohan Dahlin2008-04-281-1/+2
| | | | svn path=/trunk/; revision=247
* Include indentation in line length calculationJohan Dahlin2008-04-281-3/+5
| | | | | | | | | | | 2008-04-27 Johan Dahlin <johan@gnome.org> * giscanner/xmlwriter.py: * tests/parser/Foo-expected.gir: Include indentation in line length calculation svn path=/trunk/; revision=239
* Refactor pretty attribute indentation to be more generic and always use itJohan Dahlin2008-04-281-39/+30
| | | | svn path=/trunk/; revision=236
* Wrap attributes for lines which are wider than 79 charactersJohan Dahlin2008-04-281-0/+17
| | | | | | | | | | 2008-04-27 Johan Dahlin <johan@gnome.org> * giscanner/xmlwriter.py: Wrap attributes for lines which are wider than 79 characters svn path=/trunk/; revision=235
* Simplify & Remove a bit of unused codeJohan Dahlin2008-04-281-11/+22
| | | | svn path=/trunk/; revision=234
* Add LGPLv2 license header and install all python filesJohan Dahlin2008-04-261-0/+19
| | | | | | | | | | | | | | | | | | | | | | 2008-04-25 Johan Dahlin <jdahlin@async.com.br> * giscanner/Makefile.am: * giscanner/__init__.py: * giscanner/cgobject.py: * giscanner/gidlparser.py: * giscanner/gidlwriter.py: * giscanner/girwriter.py: * giscanner/gobjecttreebuilder.py: * giscanner/odict.py: * giscanner/sourcescanner.py: * giscanner/treebuilder.py: * giscanner/xmlwriter.py: * tools/Makefile.am: * tools/g-ir-scanner: Add LGPLv2 license header and install all python files svn path=/trunk/; revision=227
* Add a simple api for writing tags which can be used with the new 'withJohan Dahlin2008-04-211-0/+11
| | | | | | | | | | | | 2008-04-21 Johan Dahlin <jdahlin@async.com.br> * giscanner/gidlwriter.py: * giscanner/xmlwriter.py: Add a simple api for writing tags which can be used with the new 'with statement' in python 2.5 svn path=/trunk/; revision=190
* Add a simplistic gidl writer, which can't do too much.Johan Dahlin2008-04-181-0/+55
2008-04-18 Johan Dahlin <jdahlin@async.com.br> * giscanner/gidlwriter.py: * giscanner/xmlwriter.py: * tools/g-ir-scanner: Add a simplistic gidl writer, which can't do too much. svn path=/trunk/; revision=175