Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/SchemaNameSpace.py@3817
Revision 3817,
1.2 KB
checked in by cbyrom, 13 years ago
(diff) |
Add default logging support + create new version of ingest script, removing
all traces of the eXist DB + improve documentation and output.
|
Line | |
---|
1 | import sys, logging |
---|
2 | |
---|
3 | class SchemaNameSpace: |
---|
4 | ''' |
---|
5 | Class to change/correct namespaces to the latest ones used by NDG discovery |
---|
6 | NB, only currently handles correction of DIF files |
---|
7 | ''' |
---|
8 | def __init__(self, infile, outfile, format): |
---|
9 | ''' |
---|
10 | Constructor - with the logic to do the namespace change |
---|
11 | @param infile: file to correct namespaces in |
---|
12 | @param outfile: file to create with the corrected namespaces |
---|
13 | @param format: Format of file being processed. DIF is the only format which currently is processed. |
---|
14 | ''' |
---|
15 | logging.info("Correcting namespace in file, " + infile) |
---|
16 | |
---|
17 | self.ff=open(infile,'r') |
---|
18 | self.ww=open(outfile,'w') |
---|
19 | self.format= format |
---|
20 | self.lines=self.ff.readlines() |
---|
21 | |
---|
22 | for self.line in self.lines: |
---|
23 | if self.format== "DIF" and self.line.startswith('<DIF'): |
---|
24 | logging.info("changing line for %s. output to %s" %(infile,outfile)) |
---|
25 | self.line='<DIF xmlns="http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n' |
---|
26 | self.ww.write(self.line) |
---|
27 | self.ff.close() |
---|
28 | self.ww.close() |
---|
29 | |
---|
30 | logging.info("Corrected file written to, " + outfile) |
---|
Note: See
TracBrowser
for help on using the repository browser.