-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_abyss.py
146 lines (114 loc) · 4.07 KB
/
new_abyss.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python
# -*- coding: utf 8 -*-
import curses
import logging
###############################################################################
##### Static Configuration ####################################################
###############################################################################
#
# All values should be relatively safe to change, so long as types are
# maintained (strings stay strings and bools remain bools), but all
# configurations are not tested and care and troubleshooting may be necessary
# depending on the type and quantity of changes made. Changing any key names
# should be expected to cause (likely fatal) Python errors.
#
INIT_CONFIGURATION = {
'logging': {
'custom_levels' : {
'history' : {
'name' : 'history'
}
},
# Governs the number and configuration of individual logging streams. Any
# number of streams should be supported. Although the literal key assigned
# to a stream can be any string, strings must be unique among all streams
# in the configuration.
# Options:
#
# enabled: Toggles stream functionality
# filepath: Specifies filepath for stream. If set to a stream value
# ('stdout', 'stderr'), will log to given stream.
# formattingG: Formatting string to use for stream.
# threshold: Threshold for the stream to start at.
#
'streams' : {
'0' : {
'enabled' : True,
'filepath' : 'stdout',
'formatting' : None,
'threshold' : None,
}
'1' : {
'enabled' : False,
'filepath' : None,
'formatting' : None,
'threshold' : None,
}
'2' : {
'enabled' : False,
'filepath' : None,
'formatting' : None,
'threshold' : None,
}
'3' : {
'enabled' : False,
'filepath' : None,
'formatting' : None,
'threshold' : None,
}
'4' : {
'enabled' : False,
'filepath' : None,
'formatting' : None,
'threshold' : None,
}
'logfile': 'test_logfile'
}
}
###############################################################################
##### Static Non-Configurables ################################################
###############################################################################
STATIC_CONFIG = {
#TODO: CONVERT TO DEDICATED FILE
logging_stream_template = {
'enabled' : False,
'filepath' : None,
'formatting' : None,
'threshold' : None
}
###############################################################################
##### Top-Level Functions #####################################################
###############################################################################
def main(stdscr):
"""Main module for the game. Instantiates a new game."""
# Globally defines a game instance. The stdscr object MUST be passed to the
# game instance in order to avoid errors with curses
global game
game = Game(stdscr)
###############################################################################
##### Classes #################################################################
###############################################################################
class Game:
""" Game class constructor. """
# Game instances must be handed a stdscr object (from curses) on
# initialization to avoid curses errors.
def __init__(self, stdscr):
""" Game instance constructor. """
# Set configuration values.
self.configuration = INIT_CONFIGURATION
# Set static configuration values.
self..configuration._static = STATIC_CONFIG
def initLogger(self):
""" Instantiates the Logger object. """
# Instantiate a logger object from the logging module.
_logger = logging.getLogger()
for _stream, _config in self.configuration
# Define a new handler and tell it where to log events to
_handler = logging.FileHandler(config.logfile)
###############################################################################
##### Runtime #################################################################
###############################################################################
# Executes when script is called
if __name__ == '__main__':
# Starts everything else
curses.wrapper(main)