コード例 #1
0
    def __init__(self):
        impl = minidom.getDOMImplementation()
        doct = impl.createDocumentType(
            'plist', '-//Apple//DTD PLIST 1.0//EN',
            'http://www.apple.com/DTDs/PropertyList-1.0.dtd')
        self.tree = impl.createDocument(None, 'plist', doct)
        self.tree.documentElement.setAttribute('version', '1.0')

        self.log = Log.get(__name__, self.__class__.__name__)
コード例 #2
0
 def __init__(self, ident, *depends, prime=None):
     self.ident = ident
     self.prime = prime if prime else ident
     self.below = []
     self.above = []
     for elem in depends:
         self.below.append(elem)
         elem.above.append(self)
     self.log = Log.get(__name__, self.__class__.__name__)
コード例 #3
0
from datetime import datetime, timedelta

from lib.snips.alert import Log, show_pretty
from lib.snips.fetch import get_baseurl, make_paths_req, send_get_req

LOG = Log.get(__name__)


def time_span(curr, points):
    edge = timedelta(hours=(12 / points))
    zero = curr.replace(hour=0, minute=0, second=0, microsecond=0)

    for idx in range(0, (2 * points)):
        head = zero + (idx * edge)
        tail = head + edge
        if curr <= tail and curr >= head:
            rise = (idx % 2 == 0)

            LOG.debug(
                'start {:%H:%M} >= {:%H:%M:%S} [/{}] <= {:%H:%M} end ({})',
                head, curr, points, tail, 'rising' if rise else 'falling')
            return head, tail, rise


def get_color(curr, points, *, c_lo, c_hi):
    head, tail, rise = time_span(curr, points=points)
    value, flank = (curr - head), (tail - head)
    s_val, s_flk = value.total_seconds(), flank.total_seconds()

    LOG.debug('passed ({} == {}) of ({} == {})', value, s_val, flank, s_flk)
    color = s_val * (c_hi - c_lo) / (s_flk + c_lo)