Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.402.068 Times

Elementflow 0.2.0

Company: Ivan Sagalaev
Date Added: November 18, 2013  |  Visits: 392

Elementflow

Report Broken Link
Printer Friendly Version


Product Homepage
Download (35 downloads)



Elementflow is a Python library for generating XML as a stream without first building a tree in memory.<br /><br />Some existing XML producing libraries (like ElementTree, lxml) build a whole XML tree in memory and then serialize it. It might be inefficient for moderately large XML payloads (think of a content-oriented Web service producing lots of XML data output). Python's built-in xml.sax.saxutils.XMLGenerator is very low-level and requires closing elements by hand.<br /><br />Also, most XML libraries, to be honest, suck when dealing with namespaces.<br /><br />Usage:<br /><br />Basic XML generation:<br /><br />import elementflow<br />file = open('text.xml', 'w') # can be any object with .write() method<br /><br />with elementflow.xml(file, u'root') as xml:<br /> xml.element(u'item', attrs={u'key': u'value'}, text=u'text')<br /> with xml.container(u'container', attrs={u'key': u'value'}):<br /> xml.text(u'text')<br /> xml.element(u'subelement', text=u'subelement text')<br /><br />Using with is required to properly close container elements. The library expects unicode strings on input and produces utf-8 encoded output (you may omit those "u"s for purely ASCII strings if you want to, Python will convert the, automatically).<br /><br />XML with namespaces:<br /><br />with elementflow.xml(file, 'root', namespaces={'': 'urn:n', 'n1': 'urn:n1'}) as xml:<br /> xml.element('item')<br /> with xml.container('container', namespaces={'n2': 'urn:n2'):<br /> xml.element('n1:subelement')<br /> xml.element('n2:subelement')<br /><br />Elements with namespaces are defined using prefixes. You can define namespaces at the root level and for any container. The library will check for namespace prefixes that wasn't defined beforehand and will raise ValueError in that case.<br /><br />Pretty-printing is also supported:<br /><br />with elementflow.xml(file, 'root', indent=True):<br /> # ...<br /><br />In some cases it's more convenient to have such XML producer as a Python iterator. This is easily done by wrapping XML generation code into a generator function:<br /><br />def g():<br /> xml = elementflow.xml(elementflow.Queue(), 'root')<br /> with xml:<br /> for item in collection:<br /> xml.element(...)<br /> yield xml.file.pop()<br /> yield xml.file.pop()<br /><br />elementflow.Queue() is a temporary buffer that accepts data from an XML generator and is cleared upon calling .pop() on it. You also might want to yield data from the iterator only when this buffer reaches a certain size:<br /><br />if len(xml.file) > BUFSIZE:<br /> yield xml.file.pop()<br /><br />#md5=01cc616c72b46945c95d24167f251b2a

Requirements: No special requirements
Platforms: *nix, Linux
Keyword: Attrs Key Buffer Container Defined Elementflowxmlfile Elements Generator Iterator Library Namespaces Output Prefixes Producing Python Root Strings U039value039 Xmlfilepop Yield
Users rating: 0/10

License: Freeware Size: 10.24 KB
USER REVIEWS
More Reviews or Write Review


ELEMENTFLOW RELATED
Miscellaneous  -  Loop over and descend into sequences 1.0
This is a function to iterate over a container and its elements that checks for recursive traps. The condition for descending into elements is highly configurable (a list of type() results, or a callable).
 
Programming  -  DTD Manipulator 0.1
DTD parser, manipulator, and generator Java library licensed under LGPL. Start here: http://acct001.com/wordpress/?p=5
271.4 KB  
Multimedia  -  iTunes Export 1.4
Export playlist files defined in the iTunes music library iTunes Export is a free and easy to use software which exports playlists defined in your iTunes Music Library to standard .m3u, .wpl (Windows Media), .zpl (Zune), or .mpl...
 
Networking Tools  -  WEP Key Changer 0.2
WEP Key Changer project, in short WepKC is a client/server application that allows you to protect your ad-hoc (point to point) wireless network when you are unable to use (due to software or hardware limitations) sophisticated protocols like WPA....
4.2 MB  
Modules  -  CCK Input Elements 6.x-1.0-beta2
This module hosts a set of fields to be used by the Content Construction Kit.Fields are used to create various content types. They appear as input fields when creating or editing a node. They are rendered to text, when shown to page visitors.The...
20.48 KB  
Password Managers  -  Password Dragon 5.0
Password Dragon is a free password manager that works on Windows, Mac and Linux. Passwords are stored in a highly-encrypted file, that can be unlocked with the master password. Password Dragon also provides flexible Password Generator....
736.56 KB  
Network & Internet  -  Python Web Graph Generator 2.40
Python Web Graph Generator is a threaded Web graph (Power law random graph) generator. It can generate a synthetic Web graph of about one million nodes in a few minutes on a desktop machine. This software implements a threaded variant of the...
614.4 KB  
Libraries  -  XML::Generator::DOM 0.99
XML::Generator::DOM is an XML::Generator subclass for producing DOM trees instead of strings. SYNOPSIS use XML::Generator::DOM; my $dg = XML::Generator::DOM->new(); my $doc = $dg->xml($dg->xmlcmnt("Test document."), $dg->foo({baz => bam},...
21.5 KB  
Utilities  -  FakeNES 0.5.7
FakeNES project is a portable, Open Source NES emulator which is written mostly in pure C, while using the Allegro library for multi-platform capabilities. Currently supported systems are Windows 9x/2000/Me/XP, 32-bit DOS, Linux, FreeBSD, QNX,...
296.96 KB  
Libraries  -  Data::Diver 1.0101
Data::Diver is a simple, ad-hoc access to elements of deeply nested structures. SUMMARY Data::Diver provides the Dive() and DiveVal() functions for ad-hoc access to elements of deeply nested data structures, and the DiveRef(), DiveError(),...
8.19 KB  
NEW DOWNLOADS IN LINUX SOFTWARE, PROGRAMMING
Linux Software  -  EasyEDA PCB Designer for Linux 2.0.0
EasyEDA, a great web based EDA(Electronics Design Automation) tool, online PCB tool, online PCB software for electronics engineers, educators, students, makers and enthusiasts. Theres no need to install any software. Just open EasyEDA in any...
34.4 MB  
Linux Software  -  wpCache® WordPress HTTP Cache 1.9
wpCache® is a high-performance, distributed object, caching system application, generic in nature, but intended for use in speeding up dynamic web applications, by decreasing database load time. wpCache® decreases dramatically the page...
3.51 MB  
Linux Software  -  Polling Autodialer Software 3.4
ICTBroadcast Auto Dialer software has a survey campaign for telephone surveys and polls. This auto dialer software automatically dials a list of numbers and asks them a set of questions that they can respond to, by using their telephone keypad....
488 B  
Linux Software  -  Total Video Converter Mac Free 3.5.5
Total Video Converter Mac Free developed by EffectMatrix Ltd is the official legal version of Total Video Converter which was a globally recognized brand since 2006. Total Video Converter Mac Free is a free but powerful all-in-one video...
17.7 MB  
Linux Software  -  Skeith mod_log_sql Analyzer 2.10beta2
Skeith is a php based front end for analyzing logs for Apache using mod_log_sql.
47.5 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB