diff --git a/ceurws/ceur_ws.py b/ceurws/ceur_ws.py index 636d24b..c7a7666 100644 --- a/ceurws/ceur_ws.py +++ b/ceurws/ceur_ws.py @@ -1,8 +1,6 @@ import calendar import datetime -import os import re -from pathlib import Path from typing import Optional from urllib.request import Request, urlopen @@ -11,8 +9,8 @@ from geograpy.locator import City, Country, Location, LocationContext, Region from lodstorage.entity import EntityManager from lodstorage.jsonable import JSONAble -from lodstorage.storageconfig import StorageConfig +from ceurws.config import CEURWS from ceurws.indexparser import IndexHtmlParser, ParserConfig from ceurws.loctime import LoctimeParser from ceurws.papertocparser import PaperTocParser @@ -20,29 +18,6 @@ from ceurws.volumeparser import VolumeParser -class CEURWS: - """ - CEUR-WS - """ - - @staticmethod - def get_home_path() -> Path: - """ - Get home path - """ - home = Path.home() - if "GITHUB_WORKSPACE" in os.environ: - home = Path(os.environ["GITHUB_WORKSPACE"]) - return home - - URL = "http://ceur-ws.org" - home = get_home_path() - CACHE_DIR = home.joinpath(".ceurws") - CACHE_FILE = CACHE_DIR.joinpath("ceurws.db") - CACHE_HTML = CACHE_DIR.joinpath("index.html") - CONFIG = StorageConfig(cacheFile=str(CACHE_FILE)) - - class Volume(JSONAble): """ Represents a volume in ceur-ws @@ -587,8 +562,7 @@ def getSamples() -> list[dict]: get sample records of the entity """ samples = [ - { - # id is constructed with volume and position + { # id is constructed with volume and position # → /s/_ "id": "Vol-2436/s1/summary", "type": "summary", @@ -728,7 +702,8 @@ def __init__(self): clazz=Session, tableName="sessions", entityName=Session.__class__.__name__, - primaryKey="id", # ToDo: check if just the title is a sufficent key or if an ID must be added + primaryKey="id", + # ToDo: check if just the title is a sufficent key or if an ID must be added entityPluralName="sessions", config=CEURWS.CONFIG, name=self.__class__.__name__, diff --git a/ceurws/config.py b/ceurws/config.py new file mode 100644 index 0000000..0c62cde --- /dev/null +++ b/ceurws/config.py @@ -0,0 +1,27 @@ +import os +from pathlib import Path + +from lodstorage.storageconfig import StorageConfig + + +class CEURWS: + """ + CEUR-WS + """ + + @staticmethod + def get_home_path() -> Path: + """ + Get home path + """ + home = Path.home() + if "GITHUB_WORKSPACE" in os.environ: + home = Path(os.environ["GITHUB_WORKSPACE"]) + return home + + URL = "http://ceur-ws.org" + home = get_home_path() + CACHE_DIR = home.joinpath(".ceurws") + CACHE_FILE = CACHE_DIR.joinpath("ceurws.db") + CACHE_HTML = CACHE_DIR.joinpath("index.html") + CONFIG = StorageConfig(cacheFile=str(CACHE_FILE)) diff --git a/ceurws/volumeparser.py b/ceurws/volumeparser.py index c3f2c70..ed104a8 100644 --- a/ceurws/volumeparser.py +++ b/ceurws/volumeparser.py @@ -3,13 +3,14 @@ @author: wf """ + import os import re from pathlib import Path from bs4 import BeautifulSoup, NavigableString, PageElement, Tag -from ceurws.ceur_ws import CEURWS +from ceurws.config import CEURWS from ceurws.textparser import Textparser from ceurws.urn import URN from ceurws.utils.webscrape import ScrapeDescription, WebScrape diff --git a/ceurws/wikidatasync.py b/ceurws/wikidatasync.py index 5e3ce07..438d98a 100644 --- a/ceurws/wikidatasync.py +++ b/ceurws/wikidatasync.py @@ -15,7 +15,8 @@ from lodstorage.sparql import SPARQL from lodstorage.sql import SQLDB -from ceurws.ceur_ws import CEURWS, PaperManager, Volume, VolumeManager +from ceurws.ceur_ws import PaperManager, Volume, VolumeManager +from ceurws.config import CEURWS from ceurws.dblp import DblpAuthorIdentifier, DblpEndpoint from ceurws.endpoints import DBLP_ENDPOINT from ceurws.indexparser import ParserConfig diff --git a/tests/test_ceur.py b/tests/test_ceur.py index ca60b00..82019ae 100644 --- a/tests/test_ceur.py +++ b/tests/test_ceur.py @@ -8,7 +8,7 @@ from sqlmodel import select # Added 'select' here -from ceurws.ceur_ws import CEURWS +from ceurws.config import CEURWS from ceurws.models.ceur import Paper, Volume from ceurws.sql_cache import SqlDB from tests.basetest import Basetest