Skip to content

Commit

Permalink
update the KNOWN_JOURNALS and the init_logger function
Browse files Browse the repository at this point in the history
  • Loading branch information
piconti committed Sep 20, 2024
1 parent 63dfe61 commit 13f6d51
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions impresso_essentials/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
logger = logging.getLogger(__name__)

# changed to dict to include the partner/data origin
KNOWN_JOURNALS = {
KNOWN_JOURNALS_DICT = {
"SNL-RERO": [
"BDC",
"CDV",
Expand Down Expand Up @@ -125,8 +125,8 @@
"Croquis",
"FAMDE",
"FAN",
"feuilleP", # (no OCR)
"feuillePMA", # (no OCR)
# "feuilleP", # (no OCR)
# "feuillePMA", # (no OCR)
"GAVi",
"AV",
"JY2",
Expand All @@ -145,9 +145,9 @@
"CharivariCH",
"Grelot",
"Moniteur",
"Moustique", # (no OCR)
# "Moustique", # (no OCR)
"ouistiti",
"PDN", # (no OCR)
# "PDN", # (no OCR)
"PDL",
"PJ",
"TouSuIl",
Expand All @@ -158,7 +158,7 @@
"ME",
"MB",
"NS",
"RN", # (no OCR)
# "RN", # (no OCR)
"FAM",
"FAV1",
"EM",
Expand All @@ -167,11 +167,12 @@
"VVS",
"NV1",
"NV2",
"RN1", # (no OCR)
"RN2", # (no OCR)
# "RN1", # (no OCR)
# "RN2", # (no OCR)
],
}

# flatten the known journals into a sorted list
KNOWN_JOURNALS = sorted([j for part_j in KNOWN_JOURNALS_DICT.values() for j in part_j])
PARTNERS_WITHOUT_OLR = ["NZZ", "SWA", "BCUL"]

# a simple data structure to represent input directories
Expand Down Expand Up @@ -313,20 +314,20 @@ def get_pkg_resource(


def init_logger(
level: int = logging.INFO, file: Optional[str] = None
_logger: logging.RootLogger, level: int = logging.INFO, file: Optional[str] = None
) -> logging.RootLogger:
"""Initialises the root logger.
Args:
_logger (logging.RootLogger): Logger instance to initialise.
level (int, optional): desired level of logging. Defaults to logging.INFO.
file (str | None, optional): _description_. Defaults to None.
Returns:
logging.RootLogger: the initialised logger
"""
# Initialise the logger
root_logger = logging.getLogger("")
root_logger.setLevel(level)
_logger.setLevel(level)

if file is not None:
handler = logging.FileHandler(filename=file, mode="w")
Expand All @@ -335,10 +336,10 @@ def init_logger(

formatter = logging.Formatter("%(asctime)s %(name)-12s %(levelname)-8s %(message)s")
handler.setFormatter(formatter)
root_logger.addHandler(handler)
root_logger.info("Logger successfully initialised")
_logger.addHandler(handler)
_logger.info("Logger successfully initialised")

return root_logger
return _logger


def validate_against_schema(
Expand Down

0 comments on commit 13f6d51

Please sign in to comment.