Ignore:
Timestamp:
16/08/12 13:23:10 (8 years ago)
Author:
mnagni
Message:

Incomplete - # 22528: Migration of FAtCat Open Search link for HPFeld
 http://team.ceda.ac.uk/trac/ceda/ticket/22528
Incomplete - # 22534: Add versiojn number to the gui page
 http://team.ceda.ac.uk/trac/ceda/ticket/22534

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/libs/migration/processor/commons.py

    r8517 r8522  
    126126 
    127127LINK_MARKERS = ['Deployment', 'DOWNLOAD', 'DOCUMENTATION', 'ACCESS', 'LOGO', 'ACTIVITY', \ 
    128                'DPT', 'OBS'] 
     128               'DPT', 'OBS', 'TOOLS'] 
    129129 
    130130#MD_Identifier codes 
     
    137137    """ 
    138138        Returns an md5 hexadecimal representation of the given text 
    139         @param text: the string to encode 
     139        @param text: a string or an array of strings to encode 
    140140        @return: the hexadecimal md5 value of the given text  
    141141    """ 
    142142    encoder = md5() 
    143     encoder.update(text) 
     143    messages = [] 
     144    if not isinstance(text, list): 
     145        messages.append(text) 
     146    else: 
     147        messages = text 
     148         
     149    for item in messages: 
     150        encoder.update(item) 
     151 
    144152    return encoder.hexdigest() 
    145153 
     
    395403    return links_dict 
    396404 
    397 def find_links_in_migration_document(data_entity_migration): 
     405def find_links_in_migration_document(data_entity_migration, key = None): 
    398406    data_ent_XML = _get_atom_document_by_mo(data_entity_migration) 
    399407    links_dict = _extract_links(data_ent_XML, LINK_MARKERS) 
    400     return links_dict 
    401  
    402  
     408    if key is None: 
     409        return links_dict 
     410     
     411    if links_dict.has_key(key): 
     412        return links_dict[key]     
     413    return {}        
     414     
    403415 
    404416def find_download_links_in_migration_document(migration_object): 
     
    409421        @return: a list of dictionaries 
    410422    """ 
    411     links_dict = find_links_in_migration_document(migration_object) 
    412     if links_dict.has_key('DOWNLOAD'): 
    413         return links_dict['DOWNLOAD']     
    414     return {}        
     423    return find_links_in_migration_document(migration_object, 'DOWNLOAD') 
     424 
     425def find_tools_links_in_migration_document(migration_object): 
     426    """ 
     427        Return a list of dictionaries describing a <link rel="...TOOLS..."> tag type 
     428        Each dictionary has two keys: 'href' and 'title' 
     429        @param migrationObject: the migration instance to retrieve and parse 
     430        @return: a list of dictionaries 
     431    """ 
     432    return find_links_in_migration_document(migration_object, 'TOOLS') 
    415433 
    416434def find_access_links_in_migration_document(migration_object): 
     
    421439        @return: a list of dictionaries 
    422440    """ 
    423     links_dict = find_links_in_migration_document(migration_object) 
    424     if links_dict.has_key('ACCESS'): 
    425         return links_dict['ACCESS']      
    426     return {}     
     441    return find_links_in_migration_document(migration_object, 'ACCESS') 
     442 
    427443 
    428444def find_documentation_in_migration_document(migration_object): 
     
    434450        @return: a list of dictionaries 
    435451    """ 
    436     links_dict = find_links_in_migration_document(migration_object) 
    437     if links_dict.has_key('DOCUMENTATION'): 
    438         return links_dict['DOCUMENTATION']      
    439     return {} 
     452    return find_links_in_migration_document(migration_object, 'DOCUMENTATION') 
    440453 
    441454def find_doi_in_migration_document(migration_object): 
Note: See TracChangeset for help on using the changeset viewer.