Permalink
Browse files

got rid of trunk, branches, and tags

  • Loading branch information...
1 parent e47aa61 commit 74c0af57bcb19df854a502be60227f3d132c68c5 @gsf gsf committed Feb 19, 2008
Showing 355 changed files with 0 additions and 37,007 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -1,28 +0,0 @@
-v0.6 Tue Nov 29 20:48:31 CST 2005
- - fixed test suite to run under the unittest that ships with python2.3
- - allow non-integer field tags
- - fixed MARCWriter and added test (thanks Mikel Larreategi)
-
-v0.5 Thu Feb 10 10:01:12 CST 2005
- - handle empty subfields
-
-v0.4 Wed Feb 2 22:29:33 CST 2005
- - fixed directory validation: thanks Aaron Lav
- - added iterator for pymarc.Field for iterating through subfields
- - added pymarc.Field.value() for getting a field value easily
-
-v0.3 Wed Jan 5 17:03:37 CST 2005
- - changed mind about accessors (again):
- removed getField() must use getFields()
- renamed subfield() to getSubfields() and have it return a list
- - added doctest support to pymarc/__init__.py
- - added a test batch file of python data
-
-v0.2 Tue Jan 4 21:01:22 CST 2005
- - removed getField() and renamed getFields() to find()
-
-v0.11 Mon Jan 3 20:42:19 CST 2005
- - fixed test suite execution
-
-v0.1 Wed Dec 29 19:54:23 CST 2004
- - initial release
View
@@ -1,30 +0,0 @@
-DESCRIPTION
------------
-
-pymarc is a python library for working with MARC21 bibliographic data
-loosely based on the MARC/Perl suite of modules (http://marcpm.sf.net).
-More about pymarc can be found at http://www.textualize.com/pymarc
-
-INSTALLATION
-------------
-
-Run the pymarc test suite to make sure things are in order with the
-distribution:
-
- python test.py
-
-And then install:
-
- python setup.py install
-
-For typical usage of this library look at the documentation in
-pymarc/__init__.py
-
-TODO
-----
-
-- marc8/utf8 translation
-- marcxml support
-
-LICENSE: BSD
-AUTHOR: Ed Summers <ehs@pobox.com>
@@ -1,71 +0,0 @@
-# __init__.py
-
-r'''
-
-The pymarc module provides an API for reading, writing and modifying
-MARC records. MARC (MAchine Readable Cataloging) is a metadata format for
-bibliographic data. More about MARC can be found at the Library of Congress:
-http://lcweb.loc.gov/marc
-
-Below are some common examples of how you might want to use pymarc. If you
-run across an example that you think should be here please contribute it
-by writing to the author.
-
-1. Reading a batch of records and printing out the 245 subfield a. If you
- are curious this example uses the batch file available in the distribution.
-
- >>> from pymarc import MARCReader
- >>> reader = MARCReader( 'test/marc.dat' )
- >>> for record in reader:
- ... print record['245']['a']
- The pragmatic programmer :
- Programming Python /
- Learning Python /
- Python cookbook /
- Python programming for the absolute beginner /
- Web programming :
- Python programming on Win32 /
- Python programming :
- Python Web programming /
- Core python programming /
- Python and Tkinter programming /
- Game programming with Python, Lua, and Ruby /
- Python programming patterns /
- Python programming with the Java class libraries :
- Learn to program using Python :
- Programming with Python /
- BSD Sockets programming from a multi-language perspective /
- Design patterns :
- Introduction to algorithms /
- ANSI Common Lisp /
-
-2. Creating a record and writing it out to a file.
-
- >>> from pymarc import Record, Field
- >>> record = Record()
- >>> record.addField( \
- ... Field( \
- ... tag = '245',
- ... indicators = ['0','1'],
- ... subfields = [ \
- ... 'a', 'The pragmatic programmer : ',
- ... 'b', 'from journeyman to master /',
- ... 'c', 'Andrew Hunt, David Thomas.' ] ) )
- >>> out = file( 'file.dat', 'w' )
- >>> out.write( record.asMARC21() )
-
-'''
-
-__version__ = '0.11'
-
-from record import *
-from field import *
-from exceptions import *
-from reader import *
-from writer import *
-from constants import *
-
-if __name__ == "__main__":
- import doctest
- doctest.testmod()
-
@@ -1,7 +0,0 @@
-LEADER_LEN = 24
-DIRECTORY_ENTRY_LEN = 12
-SUBFIELD_INDICATOR = chr( 0x1F )
-END_OF_FIELD = chr( 0x1E )
-END_OF_RECORD = chr( 0x1D )
-
-
@@ -1,30 +0,0 @@
-class pymarcException( Exception ):
- pass
-
-class RecordLengthInvalid( pymarcException):
- def __str__( self ):
- return( "Invalid record length in first 5 bytes of record" )
-
-class RecordLeaderInvalid( pymarcException ):
- def __str__ ( self ):
- return "Unable to extract record leader"
-
-class RecordDirectoryInvalid( pymarcException ):
- def __str__( self ):
- return "Invalid directory"
-
-class NoFieldsFound( pymarcException ):
- def __str__ ( self ):
- return "Unable to locate fields in record data"
-
-class BaseAddressInvalid( pymarcException ):
- def __str__ ( self ):
- return "Base address exceeds size of record"
-
-class WriteNeedsRecord( pymarcException ):
- def __str__( self ):
- return "Write requires a pymarc.Record object as an argument"
-
-class NoActiveFile( pymarcException ):
- def __str__( self ):
- return "There is no active file to write to in call to write"
@@ -1,118 +0,0 @@
-from constants import *
-from exceptions import *
-
-class Field( object ):
-
- def __init__( self, tag, indicators=[], subfields=[], data='' ):
- """
- Field() pass in the field tag, indicators and subfields for the tag.
-
- field = Field( \
- tag = '245',
- indicators = ['0','1'],
- subfields = [ \
- 'a', 'The pragmatic programmer : ',
- 'b', 'from journeyman to master /',
- 'c', 'Andrew Hunt, David Thomas.' ]
-
- If you want to create a control field you don't pas in the indicators
- and use a data parameter rather than a subfields parameter:
-
- field = Field( tag='001', data='fol05731351' )
-
- """
- tag = "%03s" % tag
- if ( tag < '010' ):
- self.tag = tag
- self.data = data
- else:
- self.tag = tag
- self.indicator1 = indicators[0]
- self.indicator2 = indicators[1]
- self.subfields = subfields
-
- def __iter__(self):
- self.__pos = 0
- return self
-
- def __str__( self ):
- """
- A Field object in a string context will return the tag, indicators
- and subfield as a string.
- """
- if ( self.isControlField() ):
- text = "%s %s" % ( self.tag, self.data )
- else:
- text = "%s %s%s " % ( self.tag, self.indicator1, self.indicator2 )
- for subfield in self:
- text += ("$%s%s" % subfield)
- return text
-
- def __getitem__( self, subfield ):
- """
- Retrieve the first subfield with a given subfield code in a field:
-
- field['a']
-
- Handy for quick lookups.
- """
- subfields = self.getSubfields( subfield )
- if len(subfields) > 0: return subfields[0]
- return None
-
- def next( self ):
- while self.__pos < len(self.subfields):
- subfield = ( self.subfields[ self.__pos ], \
- self.subfields[ self.__pos+1 ] )
- self.__pos += 2
- return subfield
- raise StopIteration
-
- def value( self ):
- """
- Returns the field as a string without tag, indicators, and
- subfield indicators.
- """
- if self.isControlField():
- return self.data
- string = ""
- for subfield in self:
- string += subfield[1]
- return string
-
- def getSubfields( self, *codes ):
- """
- getSubfields() accepts one or more subfield codes and will return a list
- of subfield values. The order of the subfield values in the list
- will be the order that they appear in the field.
-
- print field.getSubfields( 'a' )
-
- print field.getSubfields( 'a', 'b', 'z' )
- """
- values = []
- for subfield in self:
- if subfield[0] in codes:
- values.append( subfield[1] )
- return values
-
- def isControlField( self ):
- """
- returns true or false if the field is considered a control field.
- Control fields lack indicators and subfields.
- """
- if self.tag < '010':
- return True
- return False
-
- def asMARC21( self ):
- """
- used during conversion of a field to raw marc
- """
- if self.isControlField():
- return self.data + END_OF_FIELD
- marc = str(self.indicator1) + str(self.indicator2)
- for subfield in self:
- marc += SUBFIELD_INDICATOR + subfield[0] + subfield[1]
- return marc + END_OF_FIELD
-
@@ -1,58 +0,0 @@
-from pymarc import Record, Field
-from constants import END_OF_RECORD
-from exceptions import *
-from types import *
-import string
-
-class Reader( object ):
- """
- A base class for all iterating readers in the pymarc package.
- """
- def __iter__( self ):
- return self
-
-class MARCReader( Reader ):
- """
- An iterator class for reading a file of MARC21 records.
-
- Simple usage:
-
- from pymarc import MARCReader
-
- ## pass in a filename
- reader = MARCReader( 'file.dat' )
- for record in reader:
- ...
-
- ## pass in a file object
- f = file( 'file.dat' );
- reader = MARCReader( f )
- for record in reader:
- ...
-
- """
-
- def __init__( self, f ):
- """
- The constructor which you can pass either the full path to a file
- you want to read, or a file object.
- """
- if ( type( f ) == FileType ): self.fh = f
- else: self.fh = file( f, 'r' )
-
- def next( self ):
- """
- To support iteration.
- """
- first5 = self.fh.read( 5 )
- if not first5:
- raise StopIteration
- if len( first5 ) < 5:
- raise RecordLengthInvalid
-
- length = int( first5 )
- chunk = self.fh.read( length - 5 )
- chunk = first5 + chunk
- r = Record( chunk )
- return r
-
Oops, something went wrong.

0 comments on commit 74c0af5

Please sign in to comment.