Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate venues in favor of sources #8

Merged
merged 1 commit into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pip install pyalex
PyAlex offers support for all [Entity Objects (Works, Authors, Venues, Institutions, Concepts)](https://docs.openalex.org/about-the-data#entity-objects).

```python
from pyalex import Works, Authors, Venues, Institutions, Concepts
from pyalex import Works, Authors, Sources, Institutions, Concepts
```

### The polite pool
Expand Down Expand Up @@ -97,7 +97,7 @@ Get a [random Work, Author, Venue, Institution or Concept](https://docs.openalex
```python
Works().random()
Authors().random()
Venues().random()
Sources().random()
Institutions().random()
Concepts().random()
```
Expand Down
8 changes: 8 additions & 0 deletions pyalex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
from pyalex.api import Institutions
from pyalex.api import Journals
from pyalex.api import People
from pyalex.api import Publisher
from pyalex.api import Publishers
from pyalex.api import Source
from pyalex.api import Sources
from pyalex.api import Venue
from pyalex.api import Venues
from pyalex.api import Work
Expand All @@ -25,6 +29,10 @@
"Work",
"Authors",
"Author",
"Sources",
"Source",
"Publishers",
"Publisher",
"Venues",
"Venue",
"Institutions",
Expand Down
50 changes: 43 additions & 7 deletions pyalex/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import warnings
from urllib.parse import quote_plus

import requests
Expand Down Expand Up @@ -85,7 +86,7 @@ class Author(OpenAlexEntity):
pass


class Venue(OpenAlexEntity):
class Source(OpenAlexEntity):
pass


Expand All @@ -97,6 +98,18 @@ class Concept(OpenAlexEntity):
pass


class Publisher(OpenAlexEntity):
pass


# deprecated


class Venue(OpenAlexEntity):
warnings.warn("deprecated", DeprecationWarning, stacklevel=2)
pass


class CursorPaginator(object):
def __init__(self, alex_class=None, per_page=None, cursor="*", n_max=None):

Expand Down Expand Up @@ -147,13 +160,14 @@ def __getattr__(self, key):

if key == "groupby":
raise AttributeError(
"Object has no attribute 'groupby'. "
"Did you mean 'group_by'?")
"Object has no attribute 'groupby'. " "Did you mean 'group_by'?"
)

if key == "filter_search":
raise AttributeError(
"Object has no attribute 'filter_search'. "
"Did you mean 'search_filter'?")
"Did you mean 'search_filter'?"
)

return getattr(self, key)

Expand Down Expand Up @@ -299,10 +313,10 @@ class Authors(BaseOpenAlex):
obj = Author


class Venues(BaseOpenAlex):
class Sources(BaseOpenAlex):

url = config.openalex_url + "/venues"
obj = Venue
url = config.openalex_url + "/sources"
obj = Source


class Institutions(BaseOpenAlex):
Expand All @@ -317,6 +331,28 @@ class Concepts(BaseOpenAlex):
obj = Concept


class Publishers(BaseOpenAlex):

url = config.openalex_url + "/publishers"
obj = Publisher


# deprecated


class Venues(BaseOpenAlex):

# warn about deprecation
warnings.warn(
"Venues is deprecated. Use Sources instead.",
DeprecationWarning,
stacklevel=2,
)

url = config.openalex_url + "/venues"
obj = Venue


# aliases
People = Authors
Journals = Venues
4 changes: 2 additions & 2 deletions tests/test_pyalex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pyalex import Authors
from pyalex import Concepts
from pyalex import Institutions
from pyalex import Venues
from pyalex import Sources
from pyalex import Work
from pyalex import Works

Expand All @@ -28,7 +28,7 @@ def test_meta_entities():
assert "count" in m
_, m = Institutions().get(return_meta=True)
assert "count" in m
_, m = Venues().get(return_meta=True)
_, m = Sources().get(return_meta=True)
assert "count" in m
_, m = Works().get(return_meta=True)
assert "count" in m
Expand Down