Commit e88e4d2f authored by c24b's avatar c24b

NAMING convention for PARSERS dep

parent 87d24fb0
......@@ -243,10 +243,10 @@ def load_crawler(resource):
PARSER filename: ISTEX
PARSER object: ISTexCrawler
'''
filename = resource["name"].replace("Crawler", "")
filename = resource["crawler"].replace("Crawler", "").upper()
module = 'gargantext.util.crawlers.%s' %(filename)
module = importlib.import_module(module)
return getattr(module, resource.crawler)
return getattr(module, resource["crawler"])
......
This diff is collapsed.
from .Ris import RISParser
from .RIS import RISParser
class ISIParser(RISParser):
_begin = 3
_parameters = {
b"ER": {"type": "delimiter"},
b"TI": {"type": "hyperdata", "key": "title", "separator": " "},
......@@ -17,4 +17,3 @@ class ISIParser(RISParser):
b"AB": {"type": "hyperdata", "key": "abstract", "separator": " "},
b"WC": {"type": "hyperdata", "key": "fields"},
}
import importlib
from gargantext.constants import RESOURCETYPES
from gargantext.settings import DEBUG
#if DEBUG:
# print("Loading available PARSERS:")
if DEBUG:
print("Loading available PARSERS:")
base_parser = "gargantext.util.parsers"
for resource in RESOURCETYPES:
if resource["parser"] is not None:
#parser file is without Parser
try:
fname = resource["parser"].replace("Parser", "")
#parser file is formatted as a title
module = base_parser+".%s" %(fname.title())
#parser module is has shown in constants
parser = importlib.import_module(module)
#if DEBUG:
# print("\t-", resource["parser"])
#getattr(parser,resource["parser"])
except Exception as e:
print("Check constants.py %s \nLANGUAGES declaration of taggers. Parser %s is not available" %(str(e), resource["parser"]))
fname = resource["parser"].replace("Parser", "")
#parser file is formatted as a title
module = base_parser+".%s" %(fname.upper())
#parser module is has shown in constants
parser = importlib.import_module(module)
if DEBUG:
print("\t-", resource["parser"])
getattr(parser,resource["parser"])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment