pybliometrics-dev / pybliometrics

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

Documentation for init() missing #330

Closed 10b14224cc closed 2 months ago

10b14224cc commented 2 months ago

I recently upgrade pybliometrics to the latest git version.

I have my ~/.config/pybliometrics.cfg.

Regardless of that, i get:

In [51]: from pybliometrics.scopus import AbstractRetrieval
In [52]: ab = AbstractRetrieval("10.1016/j.softx.2019.100263")
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[52], line 1
----> 1 ab = AbstractRetrieval("10.1016/j.softx.2019.100263")

File ~/.pyenv/versions/3.12.1/envs/paper_5/lib/python3.12/site-packages/pybliometrics/scopus/abstract_retrieval.py:745, in AbstractRet
rieval.__init__(self, identifier, refresh, view, id_type, **kwds)
    743 self._view = view
    744 self._refresh = refresh
--> 745 Retrieval.__init__(self, identifier=identifier, id_type=id_type,
    746                    api='AbstractRetrieval', **kwds)
    747 if self._view in ('META', 'META_ABS', 'REF', 'FULL'):
    748     self._json = self._json['abstracts-retrieval-response']

File ~/.pyenv/versions/3.12.1/envs/paper_5/lib/python3.12/site-packages/pybliometrics/scopus/superclasses/retrieval.py:46, in Retrieva
l.__init__(self, identifier, api, id_type, **kwds)
     44     stem = identifier.replace('/', '_')
     45 # Get cache file path
---> 46 config = get_config()
     47 parent = Path(config.get('Directories', api))
     48 self._cache_file_path = parent/self._view/stem

File ~/.pyenv/versions/3.12.1/envs/paper_5/lib/python3.12/site-packages/pybliometrics/scopus/utils/startup.py:66, in get_config()
     64 """Function to get the config parser."""
     65 if not CONFIG:
---> 66     raise FileNotFoundError('No configuration file found.'
     67                             'Please initialize Pybliometrics with init().\n'
     68                             'For more information visit: '
     69                             'https://pybliometrics.readthedocs.io/en/stable/configuration.html')
     70 return CONFIG

FileNotFoundError: No configuration file found.Please initialize Pybliometrics with init().
For more information visit: https://pybliometrics.readthedocs.io/en/stable/configuration.html

and there is no init() documented at that webpage

10b14224cc commented 2 months ago

For now I fixed it by running

pybliometrics.scopus.utils.startup.init("/home/USERNAME/.config/pybliometrics.cfg")

Notice that ~ is NOT resolved to home path

Michael-E-Rose commented 2 months ago

Yes, you're using undocumented code for a version that is not a stable release.

In future it will be sufficient to use

import pybliometrics

pybliometrics.scopus.init()

If your configuration file resides outside the usual folder, you may provide the location. So, in your car, it would not be necessary. I'll document this soon, but in general rather use the latest release.