File: Krank.py

package info (click to toggle)
krank 0.7%2Bdfsg2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,092 kB
  • sloc: python: 3,421; sh: 31; makefile: 11
file content (51 lines) | stat: -rw-r--r-- 1,623 bytes parent folder | download | duplicates (2)
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
#
# Krank.py

#-----------------------------------------------------------------------------------------------
# imports

import sys, os.path, math, re, shutil, time, copy, pickle, random
import pygame

kNEXT_LEVEL, kMENU_LEVEL, kLOAD_LEVEL = list(range(pygame.USEREVENT, pygame.USEREVENT+3))

from Math import *

#-----------------------------------------------------------------------------------------------
# logging

_log_ = []

def log(*args, **kwargs):
    if not _log_: return
    level = kwargs.get('level', 1)
    catjust, clsjust, mthjust = 8 ,23, 22
    if "log" in kwargs:
        if kwargs["log"] not in _log_:
            return
        print(kwargs["log"].rjust(catjust),)
    else:
        print(" ".rjust(catjust),)
    print("[", )
    mth = sys._getframe(level).f_code.co_name
    try:
        obj = sys._getframe(level).f_locals['self']
        cls = hasattr(obj.__class__, 'className') and obj.__class__.className(obj) or str(obj.__class__.__name__)
        print(cls.ljust(clsjust), mth.ljust(mthjust),)
    except Exception as e:
        try:
            file = sys._getframe(level).f_globals['__file__']
            moduleName = os.path.join(os.path.split(os.path.dirname(file))[-1], os.path.basename(file))
            print(moduleName.ljust(clsjust), mth.ljust(mthjust),)
        except:
            print("???".ljust(clsjust), mth.ljust(mthjust),)
    print("]",)
    for i in args: print(i,)
    print("")

#-----------------------------------------------------------------------------------------------

def error(*args, **kwargs):
    kwargs['level'] = 2
    log("[ERROR]", *args, **kwargs)