pybliometrics-dev / pybliometrics

Python-based API-Wrapper to access Scopus
https://pybliometrics.readthedocs.io/en/stable/
Other
420 stars 129 forks source link

Error accessing custom configuration file with location from environment variable #228

Closed bz-dev closed 2 years ago

bz-dev commented 2 years ago

Bug report? pybliometrics version: 3.1.0

Using code from Configuration - Custom location:

import os

os.environ['PYB_CONFIG_FILE'] = "C:/Custom/Location/config.ini"

import pybliometrics

Then call pybliometrics.scopus.ScopusSearch, will end up with error below:

File "D:\Repository\lit_portal\venv\lib\site-packages\pybliometrics\scopus\utils\create_config.py", line 7, in create_config if not CONFIG_FILE.exists(): AttributeError: 'str' object has no attribute 'exists'

This should be caused by line 9 in startup.py where the CONFIG_FILE from environment variable is treated as a string: CONFIG_FILE = environ['PYB_CONFIG_FILE']

Michael-E-Rose commented 2 years ago

Ah, good you found this! The path variable needs to be of object type pathlib.Path(). Will fix this in the documentation.

bz-dev commented 2 years ago

Ah, good you found this! The path variable needs to be of object type pathlib.Path(). Will fix this in the documentation.

Thanks for your quick reply. The documentation is fine as the environment variable only takes str. But the actual code needs updating. I've submitted a very minor pull request #229

Michael-E-Rose commented 2 years ago

Thanks for this!