Ignore:
Timestamp:
21/04/08 13:10:30 (12 years ago)
Author:
cbyrom
Message:

Create Logger class to standardise output - and allow this to be
switched on/off with a verbose flag.
Implement the logger in several other classes + extend available logging in these.
Also, add a 'usage' method to oai_ingest_new to show proper usage of script.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/SchemaNameSpace.py

    r3797 r3810  
    11import sys 
     2from Logger import Logger 
    23 
    34class SchemaNameSpace: 
     
    67    NB, only currently handles correction of DIF files 
    78    ''' 
    8     def __init__(self,infile,outfile,format): 
     9    def __init__(self,infile,outfile,format, logger): 
    910        ''' 
    1011        Constructor - with the logic to do the namespace change 
     
    1920        for self.line in self.lines: 
    2021            if self.format== "DIF" and self.line.startswith('<DIF'): 
    21                 print "INFO: changing line for %s. output to %s" %(infile,outfile) 
     22                message = "INFO: changing line for %s. output to %s" %(infile,outfile) 
     23                if (logger is None): 
     24                    print message 
     25                else: 
     26                    logger.printOutput(message) 
    2227                self.line='<DIF xmlns="http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n' 
    2328            self.ww.write(self.line) 
    2429        self.ff.close() 
    2530        self.ww.close() 
    26  
    27 if __name__=="__main__": 
    28     import sys 
    29     f=sys.argv[1] 
    30     w=sys.argv[2] 
    31     form=sys.argv[3] 
    32     SchemaNameSpace(f,w,form) 
Note: See TracChangeset for help on using the changeset viewer.