hal.times package

Submodules

hal.times.cron module

Cron-ify python apps with simple config files

class hal.times.cron.AppCronLock(lock_file)[source]

Bases: object

Checks if app can proceed; generates lock

DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
can_proceed()[source]

Checks whether app can proceed

Returns:True iff app is not locked and times since last update < app update interval
parse_lock()[source]

Parses app lock file

Returns:Details about last update
set_update_interval(days=7)[source]

Sets app interval update

Parameters:days – Days between 2 consecutive app updates
write_lock(last_update=datetime.datetime(2020, 11, 28, 19, 2, 19, 418209))[source]

Writes lock file

Parameters:last_update – last update of app

hal.times.dates module

Datetime utils

class hal.times.dates.Day(date_time, week_end=<Weekday.SUNDAY: 6>)[source]

Bases: object

get_just_date()[source]

Parses just date from date-time

Returns:Just day, month and year (setting hours to 00:00:00)
get_last_weekday(including_today=False)[source]

Gets last week day

Parameters:including_today – If today is sunday and requesting next sunday
Returns:Date of last monday, tuesday ..
get_next_weekday(including_today=False)[source]

Gets next week day

Parameters:including_today – If today is sunday and requesting next sunday
Returns:Date of next monday, tuesday ..
is_date_in_between(start, end, include_start=True, include_end=True)[source]

Checks if date is in between dates

Parameters:
  • start – Date cannot be before this date
  • end – Date cannot be after this date
  • include_start – True iff date is start
  • include_end – True iff date is end
Returns:

True iff date is in between dates

is_in_this_week()[source]

Checks if date is in this week (from sunday to sunday)

Returns:True iff date is in this week (from sunday to sunday)
class hal.times.dates.Weekday[source]

Bases: enum.Enum

Representing weekday by using ints (datetime standard)

FRIDAY = 4
MONDAY = 0
SATURDAY = 5
SUNDAY = 6
THURSDAY = 3
TUESDAY = 1
WEDNESDAY = 2
get_last = <function Weekday.get_last>[source]
get_next = <function Weekday.get_next>[source]

hal.times.profile module

Tired of formatting ETA times? This is just for you

hal.times.profile.get_time_eta(total_done, total, start_time)[source]

Gets ETA

Parameters:
  • total_done – items processed
  • total – total # of items to process
  • start_time – Time of start processing items
Returns:

Time to go

hal.times.utils module

Parse, convert times formats

class hal.times.utils.Timing(raw)[source]

Bases: object

Time

get_seconds()[source]

Gets seconds from raw time

Returns:Seconds in time
parse_hh_mm()[source]

Parses raw time

Returns:Time parsed
parse_hh_mm_ss()[source]

Parses raw time

Returns:Time parsed