pyalex 0.15__tar.gz → 0.15.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyalex
3
- Version: 0.15
3
+ Version: 0.15.1
4
4
  Summary: Python interface to the OpenAlex database
5
5
  Author-email: Jonathan de Bruin <jonathandebruinos@gmail.com>
6
6
  License: MIT
@@ -378,6 +378,18 @@ Works()["W2023271753"].ngrams()
378
378
  ```
379
379
 
380
380
 
381
+ ### Serialize
382
+
383
+ All results from PyAlex can be serialized. For example, save the results to a JSON file:
384
+
385
+ ```python
386
+ with open(Path("works.json"), "w") as f:
387
+ json.dump(Works().get(), f)
388
+
389
+ with open(Path("works.json")) as f:
390
+ works = [Work(w) for w in json.load(f)]
391
+ ```
392
+
381
393
  ## Code snippets
382
394
 
383
395
  A list of awesome use cases of the OpenAlex dataset.
@@ -354,6 +354,18 @@ Works()["W2023271753"].ngrams()
354
354
  ```
355
355
 
356
356
 
357
+ ### Serialize
358
+
359
+ All results from PyAlex can be serialized. For example, save the results to a JSON file:
360
+
361
+ ```python
362
+ with open(Path("works.json"), "w") as f:
363
+ json.dump(Works().get(), f)
364
+
365
+ with open(Path("works.json")) as f:
366
+ works = [Work(w) for w in json.load(f)]
367
+ ```
368
+
357
369
  ## Code snippets
358
370
 
359
371
  A list of awesome use cases of the OpenAlex dataset.
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.15'
16
- __version_tuple__ = version_tuple = (0, 15)
15
+ __version__ = version = '0.15.1'
16
+ __version_tuple__ = version_tuple = (0, 15, 1)
@@ -23,7 +23,7 @@ class AlexConfig(dict):
23
23
  config = AlexConfig(
24
24
  email=None,
25
25
  api_key=None,
26
- user_agent="pyalex/{__version__}",
26
+ user_agent=f"pyalex/{__version__}",
27
27
  openalex_url="https://api.openalex.org",
28
28
  max_retries=0,
29
29
  retry_backoff_factor=0.1,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyalex
3
- Version: 0.15
3
+ Version: 0.15.1
4
4
  Summary: Python interface to the OpenAlex database
5
5
  Author-email: Jonathan de Bruin <jonathandebruinos@gmail.com>
6
6
  License: MIT
@@ -378,6 +378,18 @@ Works()["W2023271753"].ngrams()
378
378
  ```
379
379
 
380
380
 
381
+ ### Serialize
382
+
383
+ All results from PyAlex can be serialized. For example, save the results to a JSON file:
384
+
385
+ ```python
386
+ with open(Path("works.json"), "w") as f:
387
+ json.dump(Works().get(), f)
388
+
389
+ with open(Path("works.json")) as f:
390
+ works = [Work(w) for w in json.load(f)]
391
+ ```
392
+
381
393
  ## Code snippets
382
394
 
383
395
  A list of awesome use cases of the OpenAlex dataset.
@@ -244,6 +244,17 @@ def test_serializable(tmpdir):
244
244
  assert "W4238809453" in json.load(f)["id"]
245
245
 
246
246
 
247
+ def test_serializable_list(tmpdir):
248
+ with open(Path(tmpdir, "test.json"), "w") as f:
249
+ json.dump(Works().get(), f)
250
+
251
+ with open(Path(tmpdir, "test.json")) as f:
252
+ works = [Work(w) for w in json.load(f)]
253
+
254
+ assert len(works) == 25
255
+ assert all(isinstance(w, Work) for w in works)
256
+
257
+
247
258
  def test_ngrams_without_metadata():
248
259
  r = Works()["W2023271753"].ngrams(return_meta=False)
249
260
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes