Skip to content

Commit

Permalink
moved CEURWS cache config to separate config.py file
Browse files Browse the repository at this point in the history
  • Loading branch information
tholzheim committed Jul 16, 2024
1 parent 2be4410 commit f25a954
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
33 changes: 4 additions & 29 deletions ceurws/ceur_ws.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -11,38 +9,15 @@
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
from ceurws.utils.download import Download
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
Expand Down Expand Up @@ -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
# → <volNumber>/s<position>/<type>_<position_relative_to_type>
"id": "Vol-2436/s1/summary",
"type": "summary",
Expand Down Expand Up @@ -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__,
Expand Down
27 changes: 27 additions & 0 deletions ceurws/config.py
Original file line number Diff line number Diff line change
@@ -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))
3 changes: 2 additions & 1 deletion ceurws/volumeparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ceurws/wikidatasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ceur.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f25a954

Please sign in to comment.