-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Copyright 2023-2024 Vlad Krupinskii <[email protected]> | ||
# SPDX-License-Identifier: MIT | ||
|
||
import random | ||
import time | ||
from datetime import datetime | ||
from functools import wraps | ||
|
@@ -9,8 +10,6 @@ | |
|
||
from gi.repository import GLib, Gtk # type:ignore | ||
|
||
from errands.lib.logging import Log | ||
|
||
|
||
def get_human_datetime(date_time: str) -> str: | ||
if date_time: | ||
|
@@ -58,17 +57,6 @@ def wrapper(*args, **kwargs): | |
return wrapper | ||
|
||
|
||
def catch_errors(function: Callable): | ||
"""Catch errors and log them""" | ||
|
||
@wraps(function) | ||
def wrapper(*args, **kwargs): | ||
try: | ||
function(*args, **kwargs) | ||
except Exception as e: | ||
Log.error(e) | ||
|
||
|
||
def timeit(func): | ||
@wraps(func) | ||
def timeit_wrapper(*args, **kwargs): | ||
|
@@ -81,3 +69,12 @@ def timeit_wrapper(*args, **kwargs): | |
return result | ||
|
||
return timeit_wrapper | ||
|
||
|
||
def rgb_to_hex(r: str, g: str, b: str) -> str: | ||
return "#{:02x}{:02x}{:02x}".format(int(r), int(g), int(b)) | ||
|
||
|
||
def random_hex_color() -> str: | ||
hex_chars: str = "0123456789ABCDEF" | ||
return "#" + "".join(random.choice(hex_chars) for _ in range(6)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters