Next, we decide to load (parse) a BibTeX file stored in the project. Search for an appropriate Python library to parse BibTeX files. Try to figure out how to install it and how to use it.
We decide to use the BibtexParser package, which developed actively and available under an Open-Source license.
To install it, we could follow the instructions and run
pip install bibtexparser
To add it as a dependency of CoLRev and make it available for users of the CoLRev package, we run
poetry add bibtexparser
Check the changes and create a commit.
To checkout the solution, run:
git reset --hard 6b357d3cc5838e1c29ca908e5470dfd36335b9a2
pip install -e .[dev]
Go to the bibtexparser tutorial and figure out how to load a BibTeX file (important : use v1!). An example records.bib
file is available here.
Instead of defining the dictionary in the run.py
, use the bibtexparser to load the records.bib
file. Remember to store the records.bib
in the project directory.
Afterwards, loop over the records (for ...
) and print the title of each record.
Create a commit, and try to resolve linting errors (if any). We will address the typing-related issues together.
To checkout the solution, run:
git reset --hard ff2a044d2d0e535ea8814d31c962eae4eee64075
Next, we would like to create a function, which adds the journal_impact_factor
based on the following table:
journal | journal_impact_factor |
---|---|
MIS Quarterly | 8.3 |
Information & Management | 10.3 |
Add your changes to the staging area, run the pre-commit hooks, and address the warnings:
pre-commit run --all
To checkout the solution, run:
git reset --hard def8cd6113b9a7ded7a0d6abfd828c7735373197
pre-commit run --all
)--- # Short group sessions - who forked/leads - clear announcement for overbooked groups ask: who has a working machine? -> form groups around them! https://github.com/dirediredock/PythonWorkshop
- Use google/Stackoverflow on any error/challenge that comes up! - Using Code quality checkers and tests
FIRST: Who has a working machine?
In this session (2x90 min), we will: - [ ] Create and run a Python package command - [ ] Create and modify a dictionary data structure - [ ] Use an external library to read BibTeX records (as dicts) In the following session (2x90 min), we will: - [ ] Refactor to object-oriented code - [ ] Switch to a real CoLRev project and load the records using the CoLRev classes - [ ] Save changes and create commit
- Create a separate **project directory** to run the colrev commands. - To modify colrev functionality, switch to the **colrev package directory**. Remember: cd ..., mkdir ... (open two shells)
--- To run a Python script, simply run ``` python script.py ``` When a Python package (such as CoLRev) is installed, you can call it directly through the cli (providing parameters if necessary): ``` colrev status ``` Note : you can call installed python packages from any directory. scripts must be called by their relative/absolute path
All: update colrev and reinstall with pip! explain editable installation: pip3 install -e . git reset --hard HEAD~5 && git pull Remember: what does the command do? Note: you can also continue with your version and do the reset --hard at any time. You will have all the code available to go over again / after this session
explain __main__ -> commit: pre-commit hooks! -> explain later (they do some formatting and warn us if there are code quality issues) Goal: orientation/read code, try to figure out things
To reset, run: clarify state transitions
after 2-3 minutes: write BibtexParser on the blackboard
clarify: - call by value/reference - keyword vs positional arguments example: ************* Module colrev.ops.built_in.search_sources.aisel colrev/ops/built_in/search_sources/aisel.py:225:19: W3101: Missing timeout argument for method 'requests.get' can cause your program to hang indefinitely (missing-timeout)
Note: Pfeil-nach-oben-Taste oder bash alias nutzen!
small examples: clarify the "big goal" and start with small steps linters: already installed Code highlighting (visual studio): functions yellow, variables light blue, instances blue, classes green, strings orange python debuggers/plugins (for regular Python programming / special cases like memory usage or distributed systems)