-
Notifications
You must be signed in to change notification settings - Fork 4
/
Bridge.py
48 lines (34 loc) · 1.13 KB
/
Bridge.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
"""Bridge.py. The main Python-(Swift) plugin bundle entry module"""
import logging
import sys
import objc
from Foundation import NSObject
from Cocoa import NSView
from AppKit import NSGraphicsContext, NSRectToCGRect
import Quartz
from behavior_detector.behavior_detector import BehaviorDetector
from behavior_detector.aggregator import Aggregator
from calendar_integration import quickstart
BridgeInterface = objc.protocolNamed("StackFlow.BridgeInterface")
class Bridge(NSObject, protocols=[BridgeInterface]):
@classmethod
def createInstance(self):
return Bridge.alloc().init()
def getPythonInformation(self):
return sys.version
def addWithA_b_(self, a, b):
return a + b
def shouldBreathe(self):
return BD.should_breathe()
def findFlowTime(self):
return quickstart.find_flowtime()
def aggregateByHour(self):
return AG.aggregate_by_time()
def aggregateByProgram(self):
return AG.aggregate_by_program()
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
logger.info("Loaded python bundle")
BD = BehaviorDetector()
BD.run()
AG = Aggregator()