<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getj9dict(dbname = abrevDBname, manualDB = manualDBname, returnDict ='both'):
 """Returns the dictionary of journal abbreviations mapping to a list of the associated journal names. By default the local database is used. The database is in the file _dbname_ in the same directory as this source file # Parameters _dbname_ : `optional [str]` > The name of the downloaded database file, the default is determined at run time. It is recommended that this remain untouched. _manualDB_ : `optional [str]` > The name of the manually created database file, the default is determined at run time. It is recommended that this remain untouched. _returnDict_ : `optional [str]` > default `'both'`, can be used to get both databases or only one with `'WOS'` or `'manual'`. """

    dbLoc = os.path.normpath(os.path.dirname(__file__))

    retDict = {}
    try:
        if returnDict == 'both' or returnDict == 'WOS':
            with dbm.dumb.open(dbLoc + '/{}'.format(dbname)) as db:
                if len(db) == 0:
                    raise JournalDataBaseError("J9 Database empty or missing, to regenerate it import and run metaknowledge.WOS.journalAbbreviations.updatej9DB().")
                for k, v in db.items():
                    retDict[k.decode('utf-8')] = v.decode('utf-8').split('|')
    except JournalDataBaseError:
        updatej9DB()
        return getj9dict(dbname = dbname, manualDB = manualDB, returnDict = returnDict)
    try:
        if returnDict == 'both' or returnDict == 'manual':
            if os.path.isfile(dbLoc + '/{}.dat'.format(manualDB)):
                with dbm.dumb.open(dbLoc + '/{}'.format(manualDB)) as db:
                    for k, v in db.items():
                        retDict[k.decode('utf-8')] = v.decode('utf-8').split('|')
            else:
                if returnDict == 'manual':
                    raise JournalDataBaseError("Manual J9 Database ({0}) missing, to create it run addToDB(dbname = {0})".format(manualDB))
    except JournalDataBaseError:
        updatej9DB(dbname = manualDB)
        return getj9dict(dbname = dbname, manualDB = manualDB, returnDict = returnDict)
    return retDict