diff --git a/pyproject.toml b/pyproject.toml index e825d7f..8e843bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ dependencies = [ "networkx~=3.0", "pydantic~=2.10.6", "requests~=2.32.3", - "typer[all]~=0.9.0", + "typer[all]~=0.16.0", ] requires-python = ">=3.9" classifiers = [ @@ -44,7 +44,7 @@ dev = [ ] [project.scripts] -bibx = "bibx.cli:app" +bibx = "bibx.cli:main" [tool.ruff.lint] select = [ diff --git a/src/bibx/__init__.py b/src/bibx/__init__.py index 4b8d583..5cef193 100644 --- a/src/bibx/__init__.py +++ b/src/bibx/__init__.py @@ -28,7 +28,7 @@ "read_wos", ] -__version__ = "0.6.3" +__version__ = "0.7.0" def query_openalex( diff --git a/src/bibx/builders/wos.py b/src/bibx/builders/wos.py index afdce0c..c46decb 100644 --- a/src/bibx/builders/wos.py +++ b/src/bibx/builders/wos.py @@ -261,7 +261,7 @@ def __init__(self, *isi_files: TextIO) -> None: def build(self) -> Collection: """Build a collection of articles from Web of Science (WoS) ISI files.""" articles = self._get_articles_from_files() - return Collection(list(articles)) + return Collection(Collection.deduplicate_articles(list(articles))) def _get_articles_as_str_from_files(self) -> Iterable[str]: for file in self._files: diff --git a/src/bibx/cli.py b/src/bibx/cli.py index ad391e9..189b3ef 100644 --- a/src/bibx/cli.py +++ b/src/bibx/cli.py @@ -21,7 +21,7 @@ @app.callback() -def main( +def set_verbose( verbose: Annotated[ # noqa: FBT002 bool, typer.Option("--verbose", "-v", help="Enable verbose logging.") ] = False, @@ -99,14 +99,8 @@ def openalex( help="how to handle references", default=EnrichReferences.BASIC, ), - verbose: bool = typer.Option( - help="be more verbose", - default=False, - ), ) -> None: """Run the sap algorithm on a seed file of any supported format.""" - if verbose: - logging.basicConfig(level=logging.INFO) c = query_openalex(" ".join(query), enrich=enrich) s = Sap() graph = s.create_graph(c) @@ -115,5 +109,10 @@ def openalex( rprint(graph) +def main() -> None: + """Entry point for the CLI.""" + app() + + if __name__ == "__main__": app() diff --git a/src/bibx/collection.py b/src/bibx/collection.py index 59803eb..48c91f3 100644 --- a/src/bibx/collection.py +++ b/src/bibx/collection.py @@ -46,6 +46,8 @@ def _uniqe_articles_by_id(cls, articles: list[Article]) -> dict[str, Article]: graph = nx.Graph() id_to_article: defaultdict[str, list[Article]] = defaultdict(list) for article in cls._all_articles(articles): + if not article.ids: + continue first, *rest = article.ids # Add a loop edge so that the unique articles are included graph.add_edge(first, first)