Advanced Usage
All exercises and programs known to Exj are stored in JSON files. It makes it relatively easy to add custom exercises and programs.
To add new exercises into Exercises list, modify exercises_and_metrics_library/common_exercises.json
or
add another JSON file similar to metric.json
{
"category": "Metrics",
"exercises": [
{
"name": "Weight",
"exercise_type": "MetricSingle"
}
]
}
and place it into exercises_and_metrics_library
folder or it's sub-folder.
Names of exercises can be arbitrary, but avoid identical names.
The type of the exercise should be one of the classes defined in the exercises_and_metrics_types
folder (*.py
files without *Widget
suffix).
A simple program is a list of trainings each one consisting of several exercises.
In that sense, it is very close to the journal.
To add new programs, copy and edit one of the JSON files in the simple_programs_library
folder.
For simple programs, only names and types of exercises are essential; the details such as sets, reps and
so on are used only in the case, when no exercises with a given name and type has been found in the journal.
To perform some advanced analysis of the journal, it is convenient to create a special script. To load journal file into that script:
- Create new folder and copy journal file:
mkdir your-folder
cp /exj-folder/journals/your-journal.json /your-folder/
- Copy class definitions of Journal, Training and various Exercises types.
cp /exj-folder/{Journal.py, Training.py, Exercise.py, Metric.py} /your-folder/
cp -r /exj-folder/exercises_and_metrics_types/ /your-folder/
rm /your-folder/exercises_and_metrics_types/*Widget.py
- Import these modules in your main program and load the journal
import os.path
from Journal import *
journal_file = "your-journal.json"
if os.path.isfile( journal_file ):
journal = Journal.load_journal( journal_file )
- It is possible to iterate over each training and each exercises using the following construct:
for tr in journal.trainings:
print( tr )
for ex in tr.exercises:
print( ex )