Development Tools Python scripts - Top 4 Download

Development Tools Python script downloads

xml parser and generator

Sometimes one needs a quick and dirty solution for parsing and generating xml. This script uses only the python parser itself for the parsing of xml. xml code is translated to valid python code and then evaluated. The generated objects can then be manipluated within python itself and treated as regular python ...
Python

CSV to XML with configuration

This script uses a python csv package, but adds configuration file, so that the document, row and field tags can be specified. ...
Python

xml2obj

xml2obj is a generic script that allows you to convert xml into objects. ...
Python

Using the SAX2 LexicalHandler Interface

This code shows how to use the relatively unknown LexicalHandler interface, which is an extension to the standard SAX2 interfaces like ContentHandler. ...
Python

Parsing an XML file with xml parsers expat

This script shows you a reusable way to use "xml.parsers.expat" to parse an XML file. When re-using the "MyXML" class, all you need to define a new class, with "MyXML" as the parent. Once you have done that, all you have to do is overwrite the inherited XML handlers and you are ready ...
Python

Breaking large XML documents into chunks

One of the few problems with using Python to process XML is the speed -- if the XML becomes somewhat large >(1Mb), it slows down exponentially as the size of the XML increases. One way to increase the processing speed is to break the XML down via tag name. This is ...
Python

Colorize xml source

This script takes an xml file as input and output a colorized version of this file, using html or docbook (with emphasis elements and a particular role). It provides a little command line interface and it's really easy to configure your output. ...
Python

XML Lexing

Sometimes you want to work more with the form of an XML document than with the structural information it contains. For instance if you wanted to change a bunch of entity references or element names. Also, sometimes you have slightly incorrect XML that a traditional parser will choke on. In that ...
Python

Multiple handlers for xml sax parser

SAX is commonly used on large XML files because they don't fit nicely into core memory necessary for the friendlier DOM API. When dealing with -really- large XML files, multiple passes over the file becomes costly. The SAX handler in this script allows you to handle an XML file multiple ways in ...
Python

Support for the in operator

This script adds support for the "in" operator to the attributes map of minidom elements. When you parse XML using minidom, you can get a map of attributes for any element. The problem is that using the "in" operator on this map will raise an exception and this script will fix ...
Python

ElementTree Text Helper

This script solves the "tail-problem" for prose-oriented XML. It recursively pulls text out of elements and their sub-elements and extracts text from DocBook, XMHTL, and other nested XML markup. ...
Python

Align XML ElementTrees with original text

Often when a program adds some XML markup to a plain-text document, it doesn't retain the original whitespace formatting. This script determines the character offsets the XML elements should have had in the original document. ...
Python

MarkupString

This script contains a subclass of String that allows simple handling of simple XML markup. The goal here is to allow a slice of a python markup string to "do the right thing" and preserve formatting correctly. In other words, MarkupString(Hello World)[6:] = "World". ...
Python

A SAX filter for normalizing text events

SAX parser can report contiguous text using multiple characters events. This is often unexpected and can cause obscure bugs or require complicated adjustments to SAX handlers. By inserting text_normalize_filter into the SAX handler chain all downstream parsers are ensured that all text nodes in the document Infoset are reported as a ...
Python

xmlreader

This script reads an xml file into a python dictionary of dictionaries (repeated elements are read in as lists). It works with repeating elements without having to specify the multiple attribute. ...
Python

XML as Dictionary

This script uses two simple classes to provide the mechanism for XML conversion. ...
Python

Simple XML serlializer de serializer

This script presents a way of serializing & de-serializing XML using the marshal module. The XML is converted to an equivalent Python dictionary first, which is marshaled to serialize it. De-serialization first unmarshals the dictionary from the file, and constructs the original XML. ...
Python

Remove whitespace from an XML DOM

When creating a DOM from an XML source, XML parsers are required to consider several conditions when deciding whether to include whitespace-only text nodes. This function ignores all of those conditions and removes all whitespace-only text descendants of the specified node. If the unlink flag is specified, the removed text nodes ...
Python

mbsa2txt

This script allows you to read the Microsoft Baseline Security Analyzer 1.2.1 XML output and sends it to standard output in a readable text format. ...
Python

Validating XML with External DTDs using xmlproc

PyXML is a useful package for parsing XML. The xmlval and xmldtd modules let you validate XML docs against an external DTD file. This is a simple, straightforward script that illustrates how to use the xmlval and xmldtd modules for validated XML parsing. ...
Python