mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 11:30:19 +01:00
Imports modules over objects/functions.
This commit is contained in:
@@ -5,11 +5,33 @@
|
||||
Author: Roman 'gryf' Dobosz, gryf73@gmail.com
|
||||
Created: 2009-04-05
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
from pycatalog import logger
|
||||
|
||||
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38)
|
||||
|
||||
RESET_SEQ = '\033[0m'
|
||||
COLOR_SEQ = '\033[1;%dm'
|
||||
BOLD_SEQ = '\033[1m'
|
||||
|
||||
LOG = logger.get_logger()
|
||||
|
||||
|
||||
def colorize(txt, color):
|
||||
"""Pretty print with colors to console."""
|
||||
color_map = {'black': BLACK,
|
||||
'red': RED,
|
||||
'green': GREEN,
|
||||
'yellow': YELLOW,
|
||||
'blue': BLUE,
|
||||
'magenta': MAGENTA,
|
||||
'cyan': CYAN,
|
||||
'white': WHITE}
|
||||
return COLOR_SEQ % color_map[color] + txt + RESET_SEQ
|
||||
|
||||
|
||||
def float_to_string(float_length):
|
||||
"""
|
||||
Parse float digit into time string
|
||||
@@ -23,3 +45,12 @@ def float_to_string(float_length):
|
||||
float_length -= minutes * 60
|
||||
sec = int(float_length)
|
||||
return f"{hour:02}:{minutes:02}:{sec:02}"
|
||||
|
||||
|
||||
def asserdb(func):
|
||||
def wrapper(args):
|
||||
if not os.path.exists(args.db):
|
||||
print(colorize("File `%s' does not exists!" % args.db, 'red'))
|
||||
sys.exit(1)
|
||||
func(args)
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user