Ignore:
Timestamp:
08/30/16 14:33:07 (8 years ago)
Author:
sdipsl
Message:
  • add a tsquery command to the parser
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_post/xios_parser.py

    r1346 r1349  
    4040        printRecur(root) 
    4141 
     42def tsquery(args): 
     43    """query timeseries related parameters from an XIOS xml file.""" 
     44    if args.verbosity >= 1: print 'Reading timeseries_def_xml=',args.file[0] 
     45    try: 
     46        tree = ET.parse(args.file[0]) 
     47    except: 
     48        print "Parse error. Please fix so that it can be parsed." 
     49        traceback.print_exc(file=sys.stdout) 
     50        return 
     51    root=tree.getroot() 
     52    if args.verbosity >= 3: print root.tag, root.attrib 
     53    findTimeSeries(root) 
     54         
    4255def printRecur(root): 
    4356    """Recursively prints the tree.""" 
     
    5568    indent -= 4 
    5669 
     70def findTimeSeries(root): 
     71    """Recursively find and list field tag with "timeseries", "id", "output_freq" and enable=.TRUE. attribute.""" 
     72    if root.tag == 'file' and root.attrib.get('timeseries'): 
     73        if root.attrib.get('enabled') == '.TRUE.': 
     74            print 'id=%s,output_freq=%s' % (root.attrib.get('id'), root.attrib.get('output_freq')) 
     75    else: 
     76        for elem in list(root): 
     77            findTimeSeries(elem) 
     78     
    5779def findField(root): 
    5880    """Recursively find and list field tag with "id" or "field_ref" attribute.""" 
     
    165187        parser_dump.set_defaults(func=dump) 
    166188 
     189        # create the parser for the "tsquery" command 
     190        parser_check = subparsers.add_parser('tsquery', help='query timeseries related parameters from an xml file') 
     191        parser_check.add_argument('--file', nargs=1, required=True, help='XIOS xml timeseries_def type') 
     192        parser_check.set_defaults(func=tsquery) 
     193         
    167194        # create the parser for the "check" command 
    168195        parser_check = subparsers.add_parser('check', help='Check consistency between field_def and file_def files') 
     
    170197        parser_check.add_argument('--file', nargs='+', required=True, help='XIOS xml file_def type') 
    171198        parser_check.set_defaults(func=check, correction=False) 
    172  
     199         
    173200        # create the parser for the "modify" command 
    174201        parser_check = subparsers.add_parser('modify', help='Will make sure field_def is a superset of file_def') 
Note: See TracChangeset for help on using the changeset viewer.