Package: clocking
clockingclockingis a command line utility to help you manage your worked hours, vacation, projects or whatever you need to
consider tracking time.TestingTo test package before use it, follow this:pip install -U pytest
git clone https://github.com/MatteoGuadrini/clocking.git
cd clocking
pytest testsInstallingTo install package, follow below.Withpip:pip install clockingWithgit:git clone https://github.com/MatteoGuadrini/clocking.git
cd clocking
pip install .Usageclockingwas born to be a python library that offers a command line utility.
For more information, see the official documentation onReadTheDocs.As a command lineUse the command line to track and take daily hours worked on projects or not.$clocking-husage: clocking [-h] {config,cfg,c,set,st,s,delete,del,d,print,prt,p} ...tracking or monitoring worked hourspositional arguments:{config,cfg,c,set,st,s,delete,del,d,print,prt,p}commands to runconfig (cfg, c)     default's configurationset (st, s)         setting valuesdelete (del, d)     remove valuesprint (prt, p)      print valuesoptions:-h, --help            show this help message and exitConfigurationclockinguses configurations to apply automatically determine information when insert data into database; these
configurations to creates in command line throughconfigsection.#Createconfiguration$>clockingconfig--daily-hours8--hour-reward10--extraordinary-reward12--location"Milan Office"--currency€#Printconfiguration$>clockingconfig--print...#Enable/loadconfiguration$>clockingconfig--select-id1#Orallinone$>clockingconfig--daily-hours8--hour-reward10--extraordinary-reward12--location"Milan Office"--currency€--select-id1--printUseconfigaction also to delete or clean configurations:#Deleteconfiguration$>clockingconfig--delete-id1#Cleanallconfigurations$>clockingconfig--resetSettingclockinguses set mode to insert data into own database; insert data in command line throughsetsection.#Setcurrentworkingday$>clockingset--hours8#Setotherworkingday$>clockingset--hours9.5--date'11/25/2022'#Setdisease$>clockingset--disease#Setholiday$>clockingset--holiday#Setcustomvalue$>clockingset--custom'Today I not work! I play guitar!'#Setcustomdayvalue:thismonth,thisyearbutfirstday$>clockingset--hours8--day1#Setcustommonthvalue:thisday,thisyearbutmonthnovember$>clockingset--hours8--month11#Setcustomyearvalue:thisday,thismonthbutyear2022$>clockingset--hours8--year2021#Setextraordinaryhours$>clockingset--hours8--extraordinary1#Setpermithours$>clockingset--hours7--permit1#Setotherhours$>clockingset--hours8--other0.5#Setlocation$>clockingset--hours8--location'Milan Office, p.za Duomo'#Setdescription$>clockingset--hours8--description'Project: #1'#Setall$>clockingset--hours8--day5--month5--year2019--location'Milan Office'\--description'Study Programming Python'--extraordinary1--other1#Resetaday,withoutprompt$>clockingset--date'10/09/2023'--reset--force#Deleteaday,withoutprompt$>clockingset--date'10/09/2023'--remove--forceDeletingclockinguses delete mode to delete data from own database; delete data in command line throughdeletesection.#Deleteworkingfirstdayofmonth$>clockingdelete--day1Delete day.To continue? [y/N]#Deleteworkingfirstdayofmonth,withoutprompt$>clockingdelete--day1--force#Deleteprecisedate,withoutprompt$>clockingdelete--date2/2/2021--force#Deletewholemonth(currentyear),withoutprompt$>clockingdelete--month11--force#Deletewholeyear2022,withoutprompt$>clockingdelete--year2022--force#Deletewholeuserdata,withoutprompt$>clockingdelete--clear--forcePrintingclockinguses print mode to print data from own database; print data in command line throughprintsection.#Printday$>clockingprint--date'01/25/2022'+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day | hours | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220125 | 2022 |   1   |  25 |  8.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+$>clockingprint--day25--month1--year2022+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day | hours | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220125 | 2022 |   1   |  25 |  8.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+#Printwholemonth$>clockingprint--year2022--month1+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day | hours | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220124 | 2022 |   1   |  24 |  8.0  |     None    |  Milan   |      0.0      |     0.0      |     0.0     |    0    |    0    || 20220125 | 2022 |   1   |  25 |  8.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+#Printwholeyear$>clockingprint--year2022+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day | hours | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220103 | 2022 |   1   |  3  |  8.0  |     None    |  Milan   |      0.0      |     0.0      |     0.0     |    0    |    0    || 20220124 | 2022 |   1   |  24 |  8.0  |     None    |  Milan   |      0.0      |     0.0      |     0.0     |    0    |    0    || 20220125 | 2022 |   1   |  25 |  8.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+#Printholidayinwholeyear$>clockingprint--holiday--year2022+----------+------+-------+-----+------------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day |   hours    | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+------------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220104 | 2022 |   1   |  4  | Not worked |     None    |  Home!   |      0.0      |     0.0      |     0.0     |    1    |    0    |+----------+------+-------+-----+------------+-------------+----------+---------------+--------------+-------------+---------+---------+#Printdiseaseinwholemonth$>clockingprint--disease--month1+----------+------+-------+-----+------------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day |   hours    | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+------------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220105 | 2022 |   1   |  5  | Not worked |   Disease   |  Home!   |      0.0      |     0.0      |     0.0     |    0    |    1    |+----------+------+-------+-----+------------+-------------+----------+---------------+--------------+-------------+---------+---------+#Printdiseaseinwholeyear$>clockingprint--disease--year2022+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day | hours | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220111 | 2022 |   1   |  11 |  7.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    || 20220125 | 2022 |   1   |  25 |  8.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+#Printinotherformat:csv,json,html$>clockingprint--date'01/25/2022'--csvdate_id,year,month,day,hours,description,location,extraordinary,permit_hours,other_hours,holiday,disease20220125,2022,1,25,8.0,,Milan,1.0,0.0,0.0,0,0$>clockingprint--date'01/25/2022'--json[["date_id","year","month","day","hours","description","location","extraordinary","permit_hours","other_hours","holiday","disease"],{"date_id": 20220125,"day": 25,"description": null,"disease": "0","extraordinary": 1.0,"holiday": "0","hours": 8.0,"location": "Milan","month": 1,"other_hours": 0.0,"permit_hours": 0.0,"year": 2022}]$>clockingprint--date'01/25/2022'--html<table><thead><tr><th>date_id</th><th>year</th><th>month</th><th>day</th><th>hours</th><th>description</th><th>location</th><th>extraordinary</th><th>permit_hours</th><th>other_hours</th><th>holiday</th><th>disease</th></tr></thead><tbody><tr><td>20220125</td><td>2022</td><td>1</td><td>25</td><td>8.0</td><td>None</td><td>Milan</td><td>1.0</td><td>0.0</td><td>0.0</td><td>0</td><td>0</td></tr></tbody></table>#Printwithrewards$>clockingprint--date'01/25/2022'--rewards+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+---------+| date_id  | year | month | day | hours | description | location | extraordinary | permit_hours | other_hours | holiday | disease | rewards |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+---------+| 20220125 | 2022 |   1   |  25 |  8.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    |  81.0€  |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+---------+#Exportdata$>clockingprint--date'01/25/2022'--exportmy_hours.txt$>catmy_hours.txt+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| date_id  | year | month | day | hours | description | location | extraordinary | permit_hours | other_hours | holiday | disease |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+| 20220125 | 2022 |   1   |  25 |  8.0  |     None    |  Milan   |      1.0      |     0.0      |     0.0     |    0    |    0    |+----------+------+-------+-----+-------+-------------+----------+---------------+--------------+-------------+---------+---------+As a python moduleAll useful functions to create scripts or software to track time on projects or days worked, are found in the core
module:clocking.coreI create a simple script that tracks hours worked daily.fromsysimportargvfromclocking.coreimport*mydb='mydb.db'user='myuser'# Create configuration if not was createdifnotget_current_configuration(mydb,user):# Update versionupdate_version(mydb)# Create default configurationcreate_configuration_table(mydb)add_configuration(mydb,active=True,user=user,location='Italy Office',empty_value='not work!',daily_hours=8.0,working_days="Mon Tue Wed Thu Fri",extraordinary=0.5,permit_hours=1.0,disease='disease',holiday='holiday',currency='€',hour_reward=7.5,extraordinary_reward=8.5,food_ticket=0,other_hours=0,other_reward=8.0)enable_configuration(mydb,row_id=1)# Insert daily hours...insert_working_hours(mydb,user,argv[1])# ...and print it!print_working_table(get_working_hours(mydb,user))Open sourceclockingis an open source project. Any contribute, It's welcome.A great thanks.For donations, press thisFor meForTelethonThe Telethon Foundation is a non-profit organization recognized by the Ministry of University and Scientific and
Technological Research.
They were born in 1990 to respond to the appeal of patients suffering from rare diseases.
Come today, we are organized to dare to listen to them and answers, every day of the year.Adopt the futureTreewareThis package isTreeware. If you use it in production,
then we ask that youbuy the world a treeto thank us for
our work.
By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.AcknowledgmentsThanks to Mark Lutz for writing theLearning PythonandProgramming Pythonbooks that make up my python foundation.Thanks to Kenneth Reitz and Tanya Schlusser for writing theThe Hitchhiker’s Guide to Pythonbooks.Thanks to Dane Hillard for writing thePractices of the Python Probooks.Special thanks go to my wife, who understood the hours of absence for this development.
Thanks to my children, for the daily inspiration they give me and to make me realize, that life must be simple.Thanks Python!