Changeset 8781 for main/waeup.kofa


Ignore:
Timestamp:
23 Jun 2012, 09:43:57 (12 years ago)
Author:
Henrik Bettermann
Message:

Be more intelligent when creating an appropriate lga key.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/tools/fix_import_file.py

    r8522 r8781  
    1717##
    1818"""
    19 Fix exports from old SRP portal to make them importable by current portal.
     19Fix exports from old SRP portal and other data sources to make
     20them importable by current portal.
    2021
    2122Usage:
     
    2829Errors/warnings will be displayed on the shell, the output will be put
    2930into the specified output file.
     31
     32
     33The lgas.py module must be copied into the same folder where this script
     34is started.
    3035"""
    3136import csv
     
    3338import re
    3439import sys
     40
     41try:
     42    from lgas import LGAS
     43except:
     44    print 'ERROR: lgas.py is missing.'
     45    sys.exit(1)
     46
     47def strip(string):
     48    string = string.replace('_', '')
     49    string = string.replace('/', '')
     50    string = string.replace('-', '')
     51    string = string.replace(' ', '')
     52    string = string.lower()
     53    return string
     54
     55LGAS_inverted_stripped = dict([(strip(i[1]), i[0]) for i in LGAS])
     56LGAS_dict = dict(LGAS)
    3557
    3658##
     
    189211        except:
    190212            return ''
     213        if value in LGAS_dict.keys():
     214            return value
     215        # If real names are given, let's see if a similar value
     216        # in LGAS exist.
     217        value = LGAS_inverted_stripped.get(strip(value), value)
    191218        return value
    192219
     
    232259        """ 'True'/'False' --> 'f'/'m'
    233260        """
    234         if value in ('True','f'):
     261        if value in ('F', 'True','f'):
    235262            value = 'f'
    236         elif value in ('False','m'):
     263        elif value in ('M', 'False','m'):
    237264            value = 'm'
    238265        else:
Note: See TracChangeset for help on using the changeset viewer.