Skip to content

Commit

Permalink
release commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Aug 23, 2024
1 parent 6620000 commit 247c790
Show file tree
Hide file tree
Showing 25 changed files with 1,539 additions and 945 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
os: [ubuntu-latest]
python-version: ['3.10']
#os: [ubuntu-latest, macos-latest, windows-latest]
#python-version: [3.8, 3.9, '3.10', '3.11']
#python-version: [ '3.9', '3.10', '3.11', '3.12' ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/upload-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
Expand All @@ -22,6 +25,3 @@ jobs:
hatch build
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ dmypy.json
.pyre/
# CEUR-WS sample data
ceur-ws

# mkdocs
docs
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RESTFul Single Point of Truth Server for CEUR-WS
[![PyPI Status](https://img.shields.io/pypi/v/pyCEURspt.svg)](https://pypi.python.org/pypi/pyCEURspt/)
[![GitHub issues](https://img.shields.io/github/issues/ceurws/ceur-spt.svg)](https://github.com/ceurws/ceur-spt/issues)
[![GitHub closed issues](https://img.shields.io/github/issues-closed/ceurws/ceur-spt.svg)](https://github.com/ceurws/ceur-spt/issues/?q=is%3Aissue+is%3Aclosed)
[![API Docs](https://img.shields.io/badge/API-Documentation-blue)](https://ceurws.github.io/ceur-spt/)
[![License](https://img.shields.io/github/license/ceurws/ceur-spt.svg)](https://www.apache.org/licenses/LICENSE-2.0)

## Introduction
### CEUR-WS
### CEUR-WS
CEUR Workshop Proceedings (CEUR-WS.org)
Free Open-Access Proceedings for Computer Science Workshops
https://ceur-ws.org/
Expand All @@ -21,5 +22,3 @@ https://ceur-ws.org/
### Single Point of Truth
- http://ceurspt.wikidata.dbis.rwth-aachen.de/index.html
- http://ceurspt.wikidata.dbis.rwth-aachen.de/docs


2 changes: 1 addition & 1 deletion ceurspt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__="0.0.7"
__version__ = "0.0.7"
117 changes: 85 additions & 32 deletions ceurspt/bibtex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass, asdict
from dataclasses import asdict, dataclass
from datetime import datetime
from functools import partial
from operator import is_not
Expand All @@ -16,6 +16,7 @@ class ProceedingsEntry:
see https://ftp.mpi-inf.mpg.de/pub/tex/mirror/ftp.dante.de/pub/tex/macros/latex/contrib/biblatex/doc/biblatex.pdf
"""

title: str
year: str
date: str
Expand Down Expand Up @@ -64,26 +65,38 @@ def from_volume(cls, volume: Volume) -> "ProceedingsEntry":
Convert given volume to ProceedingsEntry
"""
record = volume.getMergedDict()
pub_date = datetime.fromisoformat(record.get("wd.publication_date")) if record.get("wd.publication_date") is not None else None
pub_date = (
datetime.fromisoformat(record.get("wd.publication_date"))
if record.get("wd.publication_date") is not None
else None
)
proceeding = ProceedingsEntry(
title=volume.title,
date=pub_date.date().isoformat(),
year=str(pub_date.year) if pub_date else None,
url=record.get("spt.url"),
eventtitle=record.get("wd.eventLabel", None),
eventdate=record.get("wd.startDate", None),
venue=",".join(filter(partial(is_not, None),[record.get("wd.locationLabel", None), record.get("wd.countryLabel", None)])),
volume=str(volume.number),
editor=record.get("cvb.editors", "").replace(",", " and")
title=volume.title,
date=pub_date.date().isoformat(),
year=str(pub_date.year) if pub_date else None,
url=record.get("spt.url"),
eventtitle=record.get("wd.eventLabel", None),
eventdate=record.get("wd.startDate", None),
venue=",".join(
filter(
partial(is_not, None),
[
record.get("wd.locationLabel", None),
record.get("wd.countryLabel", None),
],
)
),
volume=str(volume.number),
editor=record.get("cvb.editors", "").replace(",", " and"),
)
proceeding.__volume = volume
return proceeding

def to_bibtex_record(self) -> dict:
record = {
'ENTRYTYPE': 'proceedings',
'ID': self.get_id(),
**{k: v for k, v in asdict(self).items() if v not in [None, ""]}
"ENTRYTYPE": "proceedings",
"ID": self.get_id(),
**{k: v for k, v in asdict(self).items() if v not in [None, ""]},
}
return record

Expand All @@ -101,6 +114,7 @@ class InProceedingsEntry:
"""
see https://ftp.mpi-inf.mpg.de/pub/tex/mirror/ftp.dante.de/pub/tex/macros/latex/contrib/biblatex/doc/biblatex.pdf
"""

title: str
author: Union[str, List[str]]
booktitle: str
Expand Down Expand Up @@ -151,28 +165,51 @@ class InProceedingsEntry:
@classmethod
def from_paper(cls, paper: Paper) -> "InProceedingsEntry":
record = paper.getMergedDict()
pub_date = datetime.fromisoformat(record.get("spt.volume").get("date")) if record.get("spt.volume") is not None else None
pub_date = (
datetime.fromisoformat(record.get("spt.volume").get("date"))
if record.get("spt.volume") is not None
else None
)
authors = record.get("cvb.authors", None)
if authors is not None:
if isinstance(authors, str):
authors = authors.replace(",", " and ")
elif "dblp.authors" in record:
authors = " and ".join([author_record.get("label") for author_record in record.get("dblp.authors")])
authors = " and ".join(
[
author_record.get("label")
for author_record in record.get("dblp.authors")
]
)
in_proceedings = InProceedingsEntry(
title=record.get("spt.title", None),
author=authors,
year=str(pub_date.year),
date=pub_date.date().isoformat(),
booktitle=record.get("spt.volume", {}).get("title", None),
url=str(record.get("spt.pdfUrl")) if record.get("spt.pdfUrl", None) else None,
volume=str(record.get("spt.volume", {}).get("number"))
title=record.get("spt.title", None),
author=authors,
year=str(pub_date.year),
date=pub_date.date().isoformat(),
booktitle=record.get("spt.volume", {}).get("title", None),
url=(
str(record.get("spt.pdfUrl"))
if record.get("spt.pdfUrl", None)
else None
),
volume=str(record.get("spt.volume", {}).get("number")),
)
if hasattr(paper, "vm") and isinstance(paper.vm, Volume):
volume_record = paper.vm.getMergedDict()
in_proceedings.eventtitle = volume_record.get("wd.eventLabel", None)
in_proceedings.eventdate = volume_record.get("wd.startDate", None)
in_proceedings.venue = ",".join(filter(partial(is_not, None), [volume_record.get("wd.locationLabel", None), volume_record.get("wd.countryLabel", None)]))
in_proceedings.editor = volume_record.get("cvb.editors", "").replace(",", " and")
in_proceedings.venue = ",".join(
filter(
partial(is_not, None),
[
volume_record.get("wd.locationLabel", None),
volume_record.get("wd.countryLabel", None),
],
)
)
in_proceedings.editor = volume_record.get("cvb.editors", "").replace(
",", " and"
)
in_proceedings.__paper = paper
return in_proceedings

Expand All @@ -182,22 +219,34 @@ def to_bibtex_record(self, crossref: Optional[str] = None) -> dict:
Args:
crossref: bibtex key of the proceedings. If set the proceeding specific fields are excluded.
"""
proceedings_keys = ["series", "location", "eventtitle", "venue", "volume", "editor", "eventdate"]
proceedings_keys = [
"series",
"location",
"eventtitle",
"venue",
"volume",
"editor",
"eventdate",
]
record_fields = {k: v for k, v in asdict(self).items() if v not in [None, ""]}
if crossref is not None:
record_fields = {k:v for k, v in record_fields.items() if k not in proceedings_keys}
record_fields = {
k: v for k, v in record_fields.items() if k not in proceedings_keys
}
record_fields["crossref"] = crossref
record = {
'ENTRYTYPE': 'inproceedings',
'ID': f"ceur-ws:{self.get_id()}",
**record_fields
"ENTRYTYPE": "inproceedings",
"ID": f"ceur-ws:{self.get_id()}",
**record_fields,
}
return record

def get_id(self) -> str:
entry_id = None
try:
entry_id = self.__paper.getMergedDict().get("spt.id", None).replace("/", ":")
entry_id = (
self.__paper.getMergedDict().get("spt.id", None).replace("/", ":")
)
except KeyError:
pass
return entry_id
Expand All @@ -218,7 +267,11 @@ def convert_volume(cls, volume: Volume) -> str:
library.entries.append(proceedings_entry.to_bibtex_record())
for paper in volume.papers:
in_proceedings_entry = InProceedingsEntry.from_paper(paper)
library.entries.append(in_proceedings_entry.to_bibtex_record(crossref=proceedings_entry.get_id()))
library.entries.append(
in_proceedings_entry.to_bibtex_record(
crossref=proceedings_entry.get_id()
)
)
bibtex = bibtexparser.dumps(library)
return bibtex

Expand Down
Loading

0 comments on commit 247c790

Please sign in to comment.