Closed nils-herrmann closed 6 months ago
In general this strikes me as overly complex. There's many new functions and variables and I do not yet understand why they are necessary.
The implementation of init()
resulted more complex than I thought. Overall the functions are used to avoid having static global variables. Since at import the user has not had the opportunity to use init()
, the configuration has to somehow be able to be changed post import
One reason the change became so complex is because of flexibility that's not been requested not desirable. In some points please revert to the previous state.
I get your point. Sorry for that.
I changed the code to have following features:
CONFIG
variable that is passed by the init()
function. This variable has to be accessed by other parts of the library via the function get_config()
to overwrite the initial value of None
after import. Note: There is no way to have a global static config variable because the config file gets defined after import by the user using init()
.init()
function now reads or creates the config fileFileNotFoundError
if the library was not initialised. The error message looks like this: FileNotFoundError: No configuration file found. Please initialize Pybliometrics with init(). For more information visit: https://pybliometrics.readthedocs.io/en/stable/configuration.html
.check_sections()
function that checks if the config file has all the needed sections.Notes:
CONFIG_DIR
is needed to allow the current functionality of the get_folder()
function in get_content()
CUSTOM_KEYS
is needed to overwrite the variables in the config file by the passed ones to the init()
function.
This feature implements a new initialization pipeline by implementing the
init()
function. The new code logic can be found in the startup.py file. Here is an example:here is another:
The feature handles two scenarios in case no
init()
is called:FileNotFoundError
is raised with the messageNo configuration file found, please create one by initialize the scopus library with init()
The feature handles three scenarios in case the
init()
is called:Some To-Do's after the code review: