def from_dict(self, data):
        assert 'apps' in data
        assert 'minutes' in data
        _a = data['apps']
        _indexed = [track_common.app_info().load(d) for d in _a]
        _m = data['minutes']
        _minutes = {
            int(i) : track_common.minute().init(
                (
                    m[0],
                    {
                        _indexed[a]: c for a, c in m[1]
                    }
                )
            ) 
            for i, m in _m.items()
        }
        
        # x = {i:len({a:0 for a in i}) for i in l}
        _apps = {a.generate_identifier(): a for a in _indexed}
        with track_qt.change_emitter(self):

            self._apps = _apps
            self._minutes = _minutes

            if len(self._minutes) > 0:
                self._index_min = min(self._minutes.keys())
                self._index_max = max(self._minutes.keys())
            else:
                self._index_min = None
                self._index_max = None
                
            self._sort()
    def update(self, minute_index, app):
        with track_qt.change_emitter(self):
        
            _app_id = app.generate_identifier()

            if _app_id not in self._apps:
                self._apps[_app_id] = app
#                if "Firefox" in _app_id:
#                    app._category = 1
#                else:
#                    app._category = 0
            # print([a._category for a in self._apps.values()])
            _app = self._apps[_app_id]
            _app._count += 1

            if minute_index not in self._minutes:
                self._minutes[minute_index] = track_common.minute()
                if not self._index_min or self._index_min > minute_index:
                    self._index_min = minute_index
                    
                if not self._index_max or self._index_max < minute_index:
                    self._index_max = minute_index

            self._minutes[minute_index].add(_app)

            self._sort()
    def update(self, minute_index, app):
        with track_qt.change_emitter(self):
            _app_id = app.generate_identifier()

            if _app_id not in self._apps:
                self._apps[_app_id] = app
#                if "Firefox" in _app_id:
#                    app._category = 1
#                else:
#                    app._category = 0
# print([a._category for a in self._apps.values()])
            _app = self._apps[_app_id]
            _app._count += 1

            if minute_index not in self._minutes:
                self._minutes[minute_index] = track_base.minute()
                if not self._index_min or self._index_min > minute_index:
                    self._index_min = minute_index

                if not self._index_max or self._index_max < minute_index:
                    self._index_max = minute_index

            self._minutes[minute_index].add(_app)

            self._sort()
    def from_dict(self, data):
        assert 'apps' in data
        assert 'minutes' in data
        _a = data['apps']
        _indexed = [track_base.app_info().load(d) for d in _a]
        _m = data['minutes']
        _minutes = {
            int(i): track_base.minute().init(
                (m[0], {_indexed[a]: c
                        for a, c in m[1]}))
            for i, m in _m.items()
        }

        # x = {i:len({a:0 for a in i}) for i in l}
        _apps = {a.generate_identifier(): a for a in _indexed}
        with track_qt.change_emitter(self):

            self._apps = _apps
            self._minutes = _minutes

            if len(self._minutes) > 0:
                self._index_min = min(self._minutes.keys())
                self._index_max = max(self._minutes.keys())
            else:
                self._index_min = None
                self._index_max = None

            self._sort()
Example #5
0
 def highlight_string(self, string):
     with track_qt.change_emitter(self):
         self._matching = []
         for i, [r, c] in enumerate(self._rules):
             if re.search(r, string):
                 self._matching.append(True)
             else:
                 self._matching.append(False)
Example #6
0
 def highlight_string(self, string):
     with track_qt.change_emitter(self):
         self._matching = []
         for i, (r, c) in enumerate(self._rules):
             if re.search(r, string):
                 # print("'%s' matches" % r)
                 self._matching.append(True)
             else:
                 self._matching.append(False)
Example #7
0
    def update(self, minute_index, app):
        with track_qt.change_emitter(self):
            _app_id = app.generate_identifier()
            if _app_id not in self._apps:
                self._apps[_app_id] = app
            _app = self._apps[_app_id]
            _app.set_new_category(app.get_category())
            _app._count += 1 #seconds using the app
            if minute_index not in self._minutes:
                self._minutes[minute_index] = track_common.minute()
                if not self._index_min or self._index_min > minute_index:
                    self._index_min = minute_index
                    
                if not self._index_max or self._index_max < minute_index:
                    self._index_max = minute_index

            self._minutes[minute_index].add(_app)

            self._sort()
 def clear(self):
     with track_qt.change_emitter(self):
         self._index_min = None
         self._index_max = None
         self._apps = {}     # app identifier => app_info instance
         self._minutes = {}  # i_min          => minute
 def clear(self):
     with track_qt.change_emitter(self):
         self._index_min = None
         self._index_max = None
         self._apps = {}  # app identifier => app_info instance
         self._minutes = {}  # i_min          => minute
Example #10
0
def test_change_emitter():
    class mock:
        pass
    m = mock()
    ce = track_qt.change_emitter(m)