Example #1
0
    def get(self, key, default=sentinel):
        if default is sentinel:
            val = Storage.get(self, key)
        else:
            val = Storage.get(self, key, default)

        return self._lazy_load(key, val)
Example #2
0
def unpack_packet(data):
    packet_header, data = GrowlPacketHeader.unpack(data)
    packet = Storage(extra=Storage())

    for attr in ('notification', 'title', 'description', 'appname'):
        value, data = readstring(data, getattr(packet_header, 'len_' + attr))
        packet[attr] = value

    #md5, data = data[:16], data[16:]

    if packet.description.find('\0') != -1:
        packet.description, extra = packet.description.split('\0')

        import simplejson
        packet.extra = simplejson.loads(extra)

    return packet, data
Example #3
0
 def __init__(self, controls, parent):
     self.parent = parent
     self.controls = controls
     self.addresslabel, self.addresstext = self.controls.LabeledTextInput(
         _("Email"))
     self.type = Storage()
     self.type.Value = []
     #            self.unitlabel, self.unittext  = self.controls.LabeledTextInput("Unit")
     self.elems = [self.addresslabel, self.addresstext]
Example #4
0
 def __init__(self, controls, parent):
     self.parent = parent
     self.controls = controls
     self.numberlabel, self.numbertext = self.controls.LabeledTextInput(
         _("Number"))
     self.type = Storage()
     self.type.Value = []
     #            self.unitlabel, self.unittext  = self.controls.LabeledTextInput("Unit")
     self.elems = [self.numberlabel, self.numbertext]
Example #5
0
def unpack_packet(data):
    packet_header, data = GrowlPacketHeader.unpack(data)
    packet = Storage(extra=Storage())

    for attr in ("notification", "title", "description", "appname"):
        value, data = readstring(data, getattr(packet_header, "len_" + attr))
        packet[attr] = value

    # md5, data = data[:16], data[16:]

    if packet.description.find("\0") != -1:
        packet.description, extra = packet.description.split("\0")

        import simplejson

        packet.extra = simplejson.loads(extra)

    return packet, data
Example #6
0
    def __init__(self, yahoo, buddy, **kws):
        IncomingFileTransfer.__init__(self)
        self.yahoo = yahoo
        self.buddy = buddy
        self.name = kws['filename']
        self.packet = Storage(**kws)
        self.numfiles = 1
        self.size = int(kws['filesize'])

        self.on_get_buddy(self.buddy)
Example #7
0
 def check_types(self):
     for attr in ('title', 'status', 'message'):
         if not isinstance(getattr(self, attr, None), basestring):
             setattr(self, attr, u'')
     from util.primitives import Storage
     if self.format is not None:
         assert isinstance(self.format, dict)
         if not isinstance(self.format, Storage):
             self.format = Storage(self.format)
     if not self.exceptions: #StatusMessageException's have a tuple
         return
     for ex,exobj in self.exceptions.items():
         if not isinstance(exobj, StatusMessage):
             assert isinstance(exobj, dict)
             self.exceptions[ex] = StatusMessageException(**exobj)
Example #8
0
 def __init__(self, controls, parent):
     self.parent = parent
     self.controls = controls
     l = self.controls.LabeledTextInput
     self.poboxtext = Storage()
     self.poboxtext.Value = ''
     common_ = ('H', )
     d = [
         ('street', _("Street")),
         ('extadr', ""),
         #                 ('pobox', "PO BOX"),
         ('locality', _("City")),
         ('region', _("State")),
         ('pcode', _("Postal Code")),
         ('ctry', _("Country"))
     ]
     self.elems = []
     for i in d:
         one, two = l(i[1])
         self.elems.append(one)
         self.elems.append(two)
         setattr(self, i[0] + 'label', one)
         setattr(self, i[0] + 'text', two)
Example #9
0
def build_font_css():
    import wx
    from gui.textutil import default_font
    from util import Point2HTMLSize

    h = Storage()

#-------------------------------------------------------------------------------
#       Code for TagFont function
#----------------------------------------
    h.header   = get('infobox.fonts.header', default_font)
    h.title    = get('infobox.fonts.title', default_font)
    h.major    = get('infobox.fonts.major', default_font)
    h.minor    = get('infobox.fonts.minor', default_font)
    h.link     = get('infobox.fonts.link',  default_font)

    h.headerfc = get('infobox.fontcolors.header', wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)
    h.titlefc  = get('infobox.fontcolors.title', wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)
    h.majorfc  = get('infobox.fontcolors.major', wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)
    h.minorfc  = get('infobox.fontcolors.minor', lambda: wx.Color(128, 128, 128)).GetAsString(wx.C2S_HTML_SYNTAX)
    h.linkfc   = get('infobox.fontcolors.link', wx.BLUE).GetAsString(wx.C2S_HTML_SYNTAX)

    import io
    sio = io.StringIO()
    for name in ('major', 'minor', 'header', 'title', 'link'):
        writeline = lambda s: sio.write(s+u'\n')
        if name == 'link':
            sio.write(u'a, ')

        writeline('.%s {' % name)
        writeline('\tcolor: %s;' % getattr(h, '%sfc' % name))
        writeline('\tfont-family: "%s";' % h[name].FaceName)
        writeline('\tfont-size: %spt;' % h[name].PointSize)
        if h[name].Style == wx.ITALIC:
            writeline('\tfont-style: italic;')
        else:
            writeline('\tfont-style: normal;')

        if h[name].Weight == wx.BOLD:
            writeline('\tfont-weight: bold;')
        else:
            writeline('\tfont-weight: normal;')

        if h[name].Underlined:
            writeline('\ttext-decoration: underline;')
        else:
            writeline('\ttext-decoration: none;')

        writeline('}')

    return sio.getvalue()
Example #10
0
 def skin_open(self, req):
     from util import Storage
     val = get(req.get_host())
     return Storage(read=lambda:val)
Example #11
0
from util.primitives import Storage
import wx
from gui.shell import PyCrustFrame

class FakeApp(wx.PySimpleApp):

    def OnInit(self, *a, **k):
        PyCrustFrame(standalone=True).Show()
        return True

def main():
    FakeApp().MainLoop()

if __name__ == '__main__':
    import gettext
    gettext.install("digsby")
    import main as main_mod
    main_mod.setup_log_system()
    main_mod.init_threadpool()
    from common.commandline import *
    import digsbyprofile; digsbyprofile.profile = Storage(username = '******')
    main()