File size: 1,177 Bytes
404d2af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b973ee
404d2af
 
 
8b973ee
404d2af
 
 
8b973ee
404d2af
 
 
8b973ee
404d2af
 
 
8b973ee
404d2af
 
 
8b973ee
404d2af
 
 
8b973ee
404d2af
8b973ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
"""
Copyright 2017, Zixin Luo, HKUST.
Commonly used functions
"""

from __future__ import print_function

import os
from datetime import datetime


class ClassProperty(property):
    """For dynamically obtaining system time"""

    def __get__(self, cls, owner):
        return classmethod(self.fget).__get__(None, owner)()


class Notify(object):
    """Colorful printing prefix.
    A quick example:
    print(Notify.INFO, YOUR TEXT, Notify.ENDC)
    """

    def __init__(self):
        pass

    @ClassProperty
    def HEADER(cls):
        return str(datetime.now()) + ": \033[95m"

    @ClassProperty
    def INFO(cls):
        return str(datetime.now()) + ": \033[92mI"

    @ClassProperty
    def OKBLUE(cls):
        return str(datetime.now()) + ": \033[94m"

    @ClassProperty
    def WARNING(cls):
        return str(datetime.now()) + ": \033[93mW"

    @ClassProperty
    def FAIL(cls):
        return str(datetime.now()) + ": \033[91mF"

    @ClassProperty
    def BOLD(cls):
        return str(datetime.now()) + ": \033[1mB"

    @ClassProperty
    def UNDERLINE(cls):
        return str(datetime.now()) + ": \033[4mU"

    ENDC = "\033[0m"