mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 05:01:14 -07:00
Add rumps 0.3.0
This commit is contained in:
parent
1bca410bcb
commit
0571a091f7
7 changed files with 1671 additions and 0 deletions
27
lib/rumps/utils.py
Normal file
27
lib/rumps/utils.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# rumps: Ridiculously Uncomplicated macOS Python Statusbar apps.
|
||||
# Copyright: (c) 2017, Jared Suttles. All rights reserved.
|
||||
# License: BSD, see LICENSE for details.
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
from .packages.ordereddict import OrderedDict as _OrderedDict
|
||||
|
||||
|
||||
# ListDict: OrderedDict subclass with insertion methods for modifying the order of the linked list in O(1) time
|
||||
# https://gist.github.com/jaredks/6276032
|
||||
class ListDict(_OrderedDict):
|
||||
def __insertion(self, link_prev, key_value):
|
||||
key, value = key_value
|
||||
if link_prev[2] != key:
|
||||
if key in self:
|
||||
del self[key]
|
||||
link_next = link_prev[1]
|
||||
self._OrderedDict__map[key] = link_prev[1] = link_next[0] = [link_prev, link_next, key]
|
||||
dict.__setitem__(self, key, value)
|
||||
|
||||
def insert_after(self, existing_key, key_value):
|
||||
self.__insertion(self._OrderedDict__map[existing_key], key_value)
|
||||
|
||||
def insert_before(self, existing_key, key_value):
|
||||
self.__insertion(self._OrderedDict__map[existing_key][0], key_value)
|
Loading…
Add table
Add a link
Reference in a new issue