Shipyard iconShipyard 0.02

Shipyard is a module to process data in a format inspired by email headers (RFC 2822).
Shipyard is a module to process data in a format inspired by email headers (RFC 2822).

Shipyard's goal is to have a simple, human readable and human writable replacement for CSV that works better for long data and many rows and doesn’t need difficult escaping rules for special characters.

It's called shipyard because that word contains py and doesn't seem to be taken yet.

Usage

The navigation menu on the left side of is created from a shipyard file files.sy that contains the following lines:

ID: shipyard
Section: /software/shipyard
Path: software/shipyard
Short: Shipyard
Desc: Shipyard is a Python module to process data in a format
inspired by email headers (RFC 2822).

ID: firkin
Section: /software/firkin
Path: software/firkin
Short: firkin
Desc: Firkin is a Python module to convert between units

#ID: loci
#Section: /software/loci
#Path: software/loci
#Short: Loci

loci isn't ready for release yet so its data lines are commented out [1].

First we open the file:

>>> f=open(path, "rb")

Then we create a parser object:

>>> reader=shipyard.Parser(keys=['ID', 'Section', 'Path','Short',
'Long', 'Desc'])

For every record the given keys are initialized with None.

To get some fancy output we create a pretty printer:

>>> import pprint
>>> pp = pprint.PrettyPrinter(indent=4)

Now we can iterater through the records:

>>> for record in reader.parse(input):
... pp.pprint(record)
{ 'Desc': 'Shipyard is a Python module to process data in a formatn'
'inspired by email headers (RFC 2822).',
'ID': 'shipyard',
'Long': None,
'Path': 'software/shipyard',
'Section': '/software/shipyard',
'Short': 'Shipyard'}
{ 'Desc': 'Firkin is a Python module to convert between units',
'ID': 'firkin',
'Long': None,
'Path': 'software/firkin',
'Section': '/software/firkin',
'Short': 'firkin'}

We don't need the file anymore so we close it:

>>> input.close()

last updated on:
October 20th, 2008, 7:18 GMT
price:
FREE!
developed by:
Florian Diesch
license type:
GPL (GNU General Public License) 
category:
ROOT \ Utilities

FREE!

In a hurry? Add it to your Download Basket!

user rating 22

UNRATED
3.4/5
 

0/5

What's New in This Release:
  • This release adds support for character encoding declaration and has many API improvements.
read full changelog

Add your review!

SUBMIT