marp | header | footer | theme | paginate |
---|---|---|---|---|
true |
Introduction to Python |
Prof. Dr. Gerit Wagner |
ub-theme |
true |
To use the typical CoLRev environments (objects), we switch to an existing CoLRev project:
cd ~
git clone https://github.com/CoLRev-Environment/example.git
cd example
colrev status
Briefly check the last commits of the project.
Our next goal is to implement the previous example (adding the journal impact factor to the records) using Python objects/methods, and using the CoLRev infrastructure.
As a first step, create the JIFLabeler
class, instantiate an object, and add the add_jif()
method (based on the Python objects/methods syntax). Run and revise the code (if necessary).
Note: Also adapt the path of the records to data/records.bib
. This is where CoLRev projects store the main records file.
To checkout the solution, run:
git reset --hard 19f283870f7abf20f7e52e1783b94cc6bcf330a6
To use the CoLRev infrastructure, take a look at the API reference and find the classes and methods that can be used to load and save records.
Upon instantiating the JIFLabeler
, we would like to instantiate a ReviewManager
object and keep it as an object variable.
When calling the main
method, the records should be loaded by using the ReviewManager
's dataset methods.
Note: Remember to import the required modules. Test your code, run the linters, and try to address potential warnings.
To checkout the solution, run:
git reset --hard 34a59a63e0d02fa49d1963dda6f065a66e3be2cd
Before completing the task, we need to implement two changes:
- Instead of
print()
statement, it is recommended to use theReviewManager
's logger. - Instead of using the record dicts, it is recommended to work with the
Record
class and itsupdate_field()
method.
To checkout the solution, run:
git reset --hard 0ae830b4c77d7a19d3beb7bc6b7485d3d871dbe9
Finally, we need to save the records (using the dataset
attribute of ReviewManager
) and create a commit (using the ReviewManager
).
Review the commit and its content.
To checkout the solution, run:
git reset --hard 402d602b91e4eff1cdd1499a5fbd7b5bf816d743
Introductory:
- Python challenges
- Python CheatSheet
- 11 tips for Python beginners
- PEP 8 — the Style Guide for Python Code
More advanced:
Tip: You can use this tutorial for more insights in Python