-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulation.py
49 lines (37 loc) · 1.12 KB
/
simulation.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
from default import parts
class _FakeModule:
def __getattr__(*args, **kwargs):
return None
class _FakeObj:
def __getattr__(*args, **kwargs):
return lambda *args, **kwargs: None
board = _FakeModule()
neopixel = _FakeModule()
ntcore = _FakeModule()
class _FakeNeoPixel(list):
def fill(self, item):
for i, _ in enumerate(self):
self[i] = item
def show(self):
pass
_strip = _FakeNeoPixel(range(parts.NUM_LEDS))
_strip.fill((0, 0, 0))
neopixel.NeoPixel = lambda *args, **kwargs: _strip
class _FakeNwInstance(_FakeObj):
def __init__(self):
self.tables = {}
def getTable(self, key):
if key in self.tables:
return self.tables[key]
self.tables[key] = _FakeNwTable()
return self.tables[key]
@classmethod
def getDefault(self):
return _default_inst
_default_inst = _FakeNwInstance()
ntcore.NetworkTableInstance = _FakeNwInstance
class _FakeNwTable(dict):
def getValue(self, topic, default):
return self.get(topic, default)
def putValue(self, topic, value):
self[topic] = value