source: TI01-discovery/trunk/ingestAutomation/OAIBatch/ @ 2252

Subversion URL:
Revision 2252, 1.3 KB checked in by selatham, 14 years ago (diff)

Copes with MDIP format. Some new config file

1try: #python 2.5
2    from xml.etree import ElementTree as ET
3except ImportError:
4    try:
5        # if you've installed it yourself it comes this way
6        import ElementTree as ET
7    except ImportError:
8        # if you've egged it this is the way it comes
9        from elementtree import ElementTree as ET
10#this is a fix to the  ElementTree namespace problem that namespaces are usually represented as ns0, ns1, ns2 etc.
11#ET._namespace_map.update({'': 'mdip', '':'xlink'})
13from ETxmlView import loadET, nsdumb
14class MDIP:
15    ''' Supports the MDIP interim format for extraction of the (unique) identifier '''
16    def __init__(self,file):
17        # we use loadET to protect ourselves from scummy characters and unicode problems
18        self.tree=loadET(file)
19        #debugging stuff
20        #print self.tree.tag
21        #print self.tree.keys()
22        #for i in self.tree: print i.tag
23        #print dir(self.tree)
24        #we use nsdumb in case the namespace causes difficulties ...
25        helper=nsdumb(self.tree)
26        #print helper
28        print 'id [%s]'%id
29if __name__=="__main__":
30    import sys
31    f=sys.argv[1]
32    print 'file:[%s]'%f
33    ff=file(f)
35    x=MDIP(xml)
Note: See TracBrowser for help on using the repository browser.