Changeset 2089 for metadata


Ignore:
Timestamp:
08/15/12 09:24:12 (12 years ago)
Author:
sanmai
Message:
  • Replace stale version of cmdi-lrt-template.xml with newer one in order

to fix functionality of lrt2cmdi.2.py

  • Small improvements to checks/debuggability in lrt2cmdi.2.py
Location:
metadata/trunk/toolkit/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • metadata/trunk/toolkit/scripts/cmdi-lrt-template.xml

    r2086 r2089  
    77        <MdSelfLink/>
    88        <MdProfile>clarin.eu:cr1:p_1289827960126</MdProfile>
    9         <MdCollectionDisplayName>CLARIN LRT inventory</MdCollectionDisplayName>
     9    <MdCollectionDisplayName>CLARIN LRT inventory</MdCollectionDisplayName>
    1010    </Header>
    1111    <Resources>
     
    5454            </LrtIPR>
    5555
    56             <LrtCollectionDetails/>
     56            <LrtCollectionDetails>
     57                <LongTermPreservationBy />
     58                <Location />
     59                <ContentType />
     60                <FormatDetailed />
     61                <Quality />
     62                <Applications />
     63                <Size />
     64                <DistributionForm />
     65                <Access />
     66                <Source />
     67                <WorkingLanguages />
     68            </LrtCollectionDetails>
    5769   
    58             <LrtLexiconDetails/>
     70            <LrtLexiconDetails>
     71                <Date />
     72                <Type />
     73                <FormatDetailed />
     74                <SchemaReference />
     75                <Size />
     76                <Access />
     77                <WorkingLanguages />
     78            </LrtLexiconDetails>
    5979   
    60             <LrtServiceDetails/>
     80            <LrtServiceDetails>
     81                <Date />
     82                <LocationWebservice />
     83                <InterfaceReference />
     84                <Input />
     85                <InputSchemaReference />
     86                <Output />
     87                <OutputSchema />
     88                <DevDescription />
     89                <Access />
     90            </LrtServiceDetails>
    6191   
    6292            <tags/>
  • metadata/trunk/toolkit/scripts/lrt2cmdi.2.py

    r2087 r2089  
    44# Dieter says: I deny the existance of this script!
    55
    6 import urllib, csv, datetime, pdb, xml.etree.ElementTree as ElementTree
     6import csv, datetime, pdb, sys, traceback, urllib, xml.etree.ElementTree as ElementTree
    77from curses.ascii import ascii
    88
    9 class CmdiFile:
     9if sys.version_info < (2, 7) :
     10    sys.stderr.write("WARNING: this script was only tested with Python version 2.7.3! You are running version " + str(sys.version_info[1]) + "." + str(sys.version_info[2]) + " instead.\n")
     11
     12class CmdiFile :
    1013    def __init__(self, nodeId) :
    1114        template            = open("cmdi-lrt-template.xml").read()
     
    1619        self.fillElement("//MdSelfLink", "http://www.clarin.eu/node/%s" % nodeId)
    1720
    18     def fillElement(self, xpath, value):
    19         self.xmlTree.find(xpath).text = value.strip()
    20 
    21     def fillOptionalElement(self, XPath, value):
    22 
     21    def fillElement(self, XPath, value) :
     22        try :
     23            self.xmlTree.find(XPath).text = value.strip()
     24        except :
     25            print "Error in filling element " + XPath
     26            print traceback.format_exc()
     27
     28            pdb.set_trace()
     29       
     30
     31    def fillOptionalElement(self, XPath, value) :
    2332        try :
    2433            result = self.fillElement(XPath, value)
    2534        except :
    26             print "Error in filling optional element"
     35            print "Error in filling optional element " + XPath
     36            print traceback.format_exc()
    2737
    2838            pdb.set_trace()
     
    3040            return result
    3141
    32         ### Conceptual code that should remove optional element that are filled with an empty text.
     42        ### Conceptual code that should remove optional elements if they are being filled with empty strings.
    3343        # optional_element_parent_XPath   = XPath + "/.."
    3444        # optional_element_parent         = self.xmlTree.find(optional_element_parent_XPath)
Note: See TracChangeset for help on using the changeset viewer.