Skip to content

Commit

Permalink
[archive] simplify settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kidanger committed Jun 18, 2023
1 parent c6a39dc commit 0736b86
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions ipol_demo/modules/archive/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import os
import os.path
from pathlib import Path
import re
import shutil
import sqlite3 as lite
Expand All @@ -22,14 +23,21 @@


class Settings(BaseSettings):
blobs_dir: str = "staticData/blobs/"
blobs_thumbs_dir: str = "staticData/blobs_thumbs/"
database_file: str = os.path.join("db", "archive.db")
config_common_dir: str = (
os.path.expanduser("~") + "/ipolDevel/ipol_demo/modules/config_common"
)
data_root: Path
authorized_patterns_path: Path
number_of_experiments_by_pages: int = 5
authorized_patterns: str = "authorized_patterns.conf"

@property
def blobs_dir(self) -> str:
return os.path.join(self.data_root, "staticData/blobs/")

@property
def blobs_thumbs_dir(self) -> str:
return os.path.join(self.data_root, "staticData/blobs_thumbs/")

@property
def database_file(self) -> str:
return os.path.join(self.data_root, "db/archive.db")


settings = Settings()
Expand Down Expand Up @@ -938,9 +946,7 @@ def read_authorized_patterns() -> list:
Read from the IPs conf file
"""
# Check if the config file exists
authorized_patterns_path = os.path.join(
settings.config_common_dir, settings.authorized_patterns
)
authorized_patterns_path = settings.authorized_patterns_path.as_posix()
if not os.path.isfile(authorized_patterns_path):
log.exception(
f"read_authorized_patterns: \
Expand Down

0 comments on commit 0736b86

Please sign in to comment.