Skip to content

Latest commit

 

History

History
203 lines (135 loc) · 6.5 KB

04-python_2.md

File metadata and controls

203 lines (135 loc) · 6.5 KB
marp header footer theme paginate
true
Introduction to Python
Prof. Dr. Gerit Wagner
ub-theme
true

Projekt: Einführung in Python (2)


Switch the data directory

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.


Overview of the tutorial

width:800px center


Object-oriented programming

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

width:800px center


Using CoLRev infrastructure

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 the ReviewManager's logger.
  • Instead of using the record dicts, it is recommended to work with the Record class and its update_field() method.

To checkout the solution, run:

git reset --hard 0ae830b4c77d7a19d3beb7bc6b7485d3d871dbe9

width:800px center


Save and commit changes

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

width:800px center


Resources

Introductory:

More advanced:

Tip: You can use this tutorial for more insights in Python


Next: Best practice and hacking sessions (per group)

  • Read the CoLRev-Enhancement Proposal on SearchSources CEP-002, and raise questions in the issue feed (if any)
  • Take notes on key challenges and questions (for the best practice session)
  • Attend consultation sessions: schedule a session via calendly (May 27-31: e-mail/remote only)