# Path: common.py
# def init(workDBName, dropWorkDB=False, matchDBName = None, dropMatchDB=False,
#          indexes=False):
# def checkStatusUpdate(fromStat, toStat):
# def get_id(what):
# def deleteDB(dbname):
# def rmMatchData(dbname):
# def infoDB(dbname):


import re
import json
from common import RGDadm 
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This Python file uses the following encoding: utf-8
"""
<
"""

#json maps from indataValidering
namMap = {}
datMap = {}
placMap = {}
sourMap = {}

def loadMaps(dir):
    global namMap, datMap, placMap, sourMap
    err = ''
    #Read mappings from indataValidering
    try: namMap = json.load(open(dir + '/name.dat'))
    except: err += "ERROR - namnfil saknas\n"
    try: placMap = json.load(open(dir + '/plac.dat'))
    except: err += "ERROR - platsfil saknas\n"
    try: datMap = json.load(open(dir + '/date.dat'))
    except: err += "ERROR - datumfil saknas\n"
    try: sourMap = json.load(open(dir + '/sour.dat'))
    except: err += "ERROR - sourcefil saknas\n"
    try:
        RGDadm.datMap.insert_many([{'_id': key, 'val': val} for key,val in datMap.iteritems()],
                                  ordered= False)
    except: pass
    try:

# Path: common.py
# def init(workDBName, dropWorkDB=False, matchDBName = None, dropMatchDB=False,
#          indexes=False):
# def checkStatusUpdate(fromStat, toStat):
# def get_id(what):
# def deleteDB(dbname):
# def rmMatchData(dbname):
# def infoDB(dbname):


# Path: importUtils.py
import re
import json
from common import RGDadm 

#!/usr/bin/python
# -*- coding: utf-8 -*-
# This Python file uses the following encoding: utf-8
"""
<
"""

#json maps from indataValidering
namMap = {}
datMap = {}
placMap = {}
sourMap = {}

def loadMaps(dir):
    global namMap, datMap, placMap, sourMap
    err = ''
    #Read mappings from indataValidering
    try: namMap = json.load(open(dir + '/name.dat'))
    except: err += "ERROR - namnfil saknas\n"
    try: placMap = json.load(open(dir + '/plac.dat'))
    except: err += "ERROR - platsfil saknas\n"
    try: datMap = json.load(open(dir + '/date.dat'))
    except: err += "ERROR - datumfil saknas\n"
    try: sourMap = json.load(open(dir + '/sour.dat'))
    except: err += "ERROR - sourcefil saknas\n"
    try:
        RGDadm.datMap.insert_many([{'_id': key, 'val': val} for key,val in datMap.iteritems()],
                                  ordered= False)
    except: pass
    try:

        RGDadm.sourMap.insert_many([{'_id': key, 'val': val} for key,val in sourMap.iteritems()],