class LogTest(unittest.TestCase): def setUp(self): self.filename = tempfile.mktemp() self.log = Logger('log') def tearDown(self): if os.path.exists(self.filename): try: os.unlink(self.filename) except OSError: # win32 permission error pass def testSetLogFile(self): set_log_file(self.filename, 'log') self.log.info("sliff") lines = open(self.filename).readlines() self.assertEqual(len(lines), 1) self.failUnless('sliff' in lines[0]) def testStdErr(self): root = logging.getLogger() stream = root.handlers[0] fd = cStringIO.StringIO() stream.stream = fd self.log.warning("this is a warning") stream.stream = sys.stderr fd.seek(0) lines = fd.readlines() self.assertEqual(len(lines), 1) self.failUnless('this is a warning' in lines[0])
def __init__(self, widget): gobject.GObject.__init__(self) self._widget = widget self._start_color = None self._background_timeout_id = -1 self._countdown_timeout_id = -1 self._log = Logger('fade') self._done = False
from stoqdrivers.enum import PaymentMethodType, TaxType, UnitType from stoqdrivers.exceptions import ( PrinterError, CloseCouponError, PendingReadX, CommandError, CouponOpenError, CommandParametersError, CouponNotOpenError, ReduceZError, HardwareFailure, DriverError, OutofPaperError, PendingReduceZ, InvalidState, CancelItemError, AlreadyTotalized) from stoqdrivers.interfaces import ICouponPrinter from stoqdrivers.serialbase import SerialBase from stoqdrivers.printers.capabilities import Capability from stoqdrivers.printers.base import BaseDriverConstants from stoqdrivers.translation import stoqdrivers_gettext _ = stoqdrivers_gettext log = Logger('stoqdrivers.sweda') class IFS9000IConstants(BaseDriverConstants): _constants = { # Page 4-12, two decimals UnitType.WEIGHT: '!', UnitType.METERS: '@', UnitType.LITERS: ')', UnitType.EMPTY: '^', PaymentMethodType.MONEY: '01', PaymentMethodType.CHECK: '01' } _tax_constants = [ # Page 4-8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # # Author(s): Johan Dahlin <*****@*****.**> # from gaxml.parser import GAXParser from kiwi.log import Logger log = Logger('gaxmlparser') class GAXMLWidgetTree(object): def __init__(self, view, gladefile, domain=None): self._view = view self._gladefile = gladefile self._parser = GAXParser() self._parser.parse_file(gladefile) self._widgets = [o.get_name() for o in self._parser.get_objects()] self._attach_widgets() def _attach_widgets(self): # Attach widgets in the widgetlist to the view specified, so # widgets = [label1, button1] -> view.label1, view.button1 for w in self._widgets: widget = self._parser.get_object(name=w)
class FadeOut(gobject.GObject): """I am a helper class to draw the fading effect of the background Call my methods start() and stop() to control the fading. """ gsignal('done') gsignal('color-changed', gdk.Color) # How long time it'll take before we start (in ms) COMPLAIN_DELAY = 500 MERGE_COLORS_DELAY = 100 ERROR_COLOR = "#ffd5d5" def __init__(self, widget): gobject.GObject.__init__(self) self._widget = widget self._start_color = None self._background_timeout_id = -1 self._countdown_timeout_id = -1 self._log = Logger('fade') self._done = False def _merge_colors(self, src_color, dst_color, steps=10): """ Change the background of widget from src_color to dst_color in the number of steps specified """ self._log.debug('_merge_colors: %s -> %s' % (src_color, dst_color)) if not src_color: yield False rs, gs, bs = src_color.red, src_color.green, src_color.blue rd, gd, bd = dst_color.red, dst_color.green, dst_color.blue rinc = (rd - rs) / float(steps) ginc = (gd - gs) / float(steps) binc = (bd - bs) / float(steps) for dummy in xrange(steps): rs += rinc gs += ginc bs += binc col = gdk.color_parse("#%02X%02X%02X" % (int(rs) >> 8, int(gs) >> 8, int(bs) >> 8)) self.emit('color-changed', col) yield True self.emit('done') self._background_timeout_id = -1 self._done = True yield False def _start_merging(self): # If we changed during the delay if self._background_timeout_id != -1: self._log.debug('_start_merging: Already running') return self._log.debug('_start_merging: Starting') func = self._merge_colors(self._start_color, gdk.color_parse(FadeOut.ERROR_COLOR)).next self._background_timeout_id = (gobject.timeout_add( FadeOut.MERGE_COLORS_DELAY, func)) self._countdown_timeout_id = -1 def start(self, color): """Schedules a start of the countdown. @param color: initial background color @returns: True if we could start, False if was already in progress """ if self._background_timeout_id != -1: self._log.debug('start: Background change already running') return False if self._countdown_timeout_id != -1: self._log.debug('start: Countdown already running') return False if self._done: self._log.debug('start: Not running, already set') return False self._start_color = color self._log.debug('start: Scheduling') self._countdown_timeout_id = gobject.timeout_add( FadeOut.COMPLAIN_DELAY, self._start_merging) return True def stop(self): """Stops the fadeout and restores the background color""" self._log.debug('Stopping') if self._background_timeout_id != -1: gobject.source_remove(self._background_timeout_id) self._background_timeout_id = -1 if self._countdown_timeout_id != -1: gobject.source_remove(self._countdown_timeout_id) self._countdown_timeout_id = -1 self._widget.update_background(self._start_color) self._done = False
Generic base class implementation for all devices. """ import gobject from kiwi.log import Logger from stoqdrivers.configparser import StoqdriversConfig from stoqdrivers.enum import DeviceType from stoqdrivers.exceptions import CriticalError, ConfigError from stoqdrivers.translation import stoqdrivers_gettext from stoqdrivers.serialbase import SerialPort _ = stoqdrivers_gettext log = Logger('stoqdrivers.basedev') class BaseDevice: """ Base class for all device interfaces, responsible for instantiate the device driver itself based on the brand and model specified or in the configuration file. """ typename_translate_dict = { DeviceType.PRINTER: "Printer", DeviceType.SCALE: "Scale", DeviceType.BARCODE_READER: "Barcode Reader", } # Subclasses must define these attributes device_dirname = None required_interfaces = None
# License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # # Author(s): Christian Reis <*****@*****.**> # Johan Dahlin <*****@*****.**> # """Holds the models part of the Kiwi Framework""" import os import pickle from kiwi import ValueUnset from kiwi.log import Logger log = Logger('model') # # A model that implements half of an observer pattern; when its # attributes are changed, it notifies any proxies of the change. # class Model: """ The Model is a mixin to be used by domain classes when attached to Proxies. It also provides autonotification of changes to the attached proxies. Note that if using setters, a specific call to notify_proxies() may be necessary; see the doc for __setattr__.""" def __init__(self): self.ensure_init()
"""The accessor module offers two important front-end functions: kgetattr and ksetattr. These functions allow retrieving attribute values from objects much in the same way as getattr/setattr allow, but with two important differences: - They follow a dot hierarchy to retrieve or modify any value reachable from the object. - They cache the method used to access a certain attribute and reuse it the next time the value is retrieved. """ import string import types from kiwi.log import Logger log = Logger('kiwi.accessor') def get_default_getter(model, attr_name, cache): """Obtains from model a callable through which attr_name can be retrieved. This callable is an accessor named get_foo, where foo is the value of attr_name, or getattr(model, foo) if the accessor does not exist. If the callable exists, it is returned; if getattr() is to be used a tuple in the format (model, attr_name) is returned.""" func = getattr(model, "get_%s" % attr_name, None) if callable(func): log.info('kgetattr based get_%s method is deprecated, ' 'replace it with a property' % attr_name) return func else:
""" Daruma FS2100 driver """ import operator from decimal import Decimal import time from stoqdrivers.printers.base import BaseDriverConstants from stoqdrivers.printers.daruma.FS345 import FS345, CMD_GET_TAX_CODES from stoqdrivers.enum import UnitType, TaxType from stoqdrivers.exceptions import DriverError from kiwi.log import Logger log = Logger('stoqdrivers.daruma') ENQ = 05 ACK = 06 LF = 10 CR = 13 ESC = 27 FS = 28 GS = 29 FF = 255 CMD_ADD_ITEM = 201 class FS2100Constants(BaseDriverConstants): _constants = {
from gobject import add_emission_hook add_emission_hook # pyflakes # XXX needed for add_emission_hook('delete-event'), something is not # initialized correctly. gtk.Window().destroy() except ImportError: try: from kiwi._kiwi import add_emission_hook add_emission_hook # pyflakes except ImportError: add_emission_hook = None _events = [] log = Logger('recorder') def register_event_type(event_type): """ Add an event type to a list of event types. @param event_type: a L{Event} subclass """ if event_type in _events: raise AssertionError("event %s already registered" % event_type) _events.append(event_type) def get_event_types(): """
HyperLink ObjectList ObjectTree ProxyLabel ProxyComboEntry ProxyComboBox ProxyCheckButton ProxyColorButton ProxyRadioButton ProxyEntry ProxyDateEntry ProxySpinButton ProxyTextView ProxyButton log = Logger('builderloader') class BuilderWidgetTree: def __init__(self, view, gladefile, domain=None): self._view = view self._gladefile = gladefile self._builder = gtk.Builder() self._builder.add_from_file(gladefile) if domain is not None: self._builder.set_translation_domain(domain) self._attach_widgets() def _attach_widgets(self): # Attach widgets in the widgetlist to the view specified, so
from kiwi.argcheck import number, percent from kiwi.currency import currency from kiwi.log import Logger from stoqdrivers.exceptions import (CloseCouponError, PaymentAdditionError, AlreadyTotalized, InvalidValue) from stoqdrivers.enum import PaymentMethodType, TaxType, UnitType from stoqdrivers.printers.base import BasePrinter from stoqdrivers.printers.capabilities import capcheck from stoqdrivers.utils import encode_text from stoqdrivers.translation import stoqdrivers_gettext _ = stoqdrivers_gettext log = Logger('stoqdrivers.fiscalprinter') # # Extra data types to argcheck # class taxcode(number): @classmethod def value_check(cls, name, value): if value not in (TaxType.NONE, TaxType.ICMS, TaxType.SUBSTITUTION, TaxType.EXEMPTION): raise ValueError("%s must be one of TaxType.* constants" % name) class unit(number): @classmethod def value_check(cls, name, value):
FIRST_COMMAND_ID = 0x81 RETRIES_BEFORE_TIMEOUT = 5 # When cancel the last coupon. This values are used to define the coupon type. FISCAL_COUPON = '1' NON_FISCAL_COUPON = '24' # Coupons status CLOSED_COUPON = '0000' OPENED_FISCAL_COUPON = '0001' OPENED_NON_FISCAL_COUPON = '1000' _ = stoqdrivers_gettext log = Logger('stoqdrivers.epson') class Reply(object): # # Printer flags # error_codes = { '0101': (CommandError(_("Invalid command for current state."))), '0102': (CommandError(_("Invalid command for current document."))), '0203': (CommandError(_("Excess fields"))), '0204': (CommandError(_("Missing fields"))), '0205': (CommandParametersError(_("Field not optional."))), '0206': (CommandParametersError(_("Invalid alphanumeric field."))),
import errno import gettext import imp import locale import os import sys from kiwi.log import Logger from kiwi.python import namedAny __all__ = [ 'Application', 'Library', 'app', 'environ', 'require_gazpacho', 'is_gazpacho_required' ] log = Logger('environ') EnvironmentError = EnvironmentError # From http://tinyurl.com/77ukj def _is_frozen(): "Helper function to check if we're frozen in a py2exe'd file" return (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") # old py2exe or imp.is_frozen("__main__")) # tools/freeze class Environment: """Environment control
import re import string import gobject import gtk from gtk import gdk from kiwi.environ import environ from kiwi.interfaces import IValidatableProxyWidget from kiwi.log import Logger from kiwi.python import namedAny from kiwi.utils import gsignal, type_register from kiwi.ui.gadgets import quit_if_last from kiwi.ui.proxy import Proxy log = Logger('kiwi.view') _non_interactive = ( gtk.Label, gtk.Alignment, gtk.AccelLabel, gtk.Arrow, gtk.EventBox, gtk.Fixed, gtk.Frame, gtk.HBox, gtk.HButtonBox, gtk.HPaned, gtk.HSeparator, gtk.Layout, gtk.Progress,
""" from stoqdrivers.printers.fiscal import FiscalPrinter from stoqdrivers.translation import stoqdrivers_gettext from stoqdrivers.exceptions import ( CommandParametersError, ) from kiwi.log import Logger from decimal import Decimal import json import re import os import ConfigParser from stoqdrivers.printers.bematech.MP25 import * from datetime import datetime _ = stoqdrivers_gettext log = Logger('fiscalv') class ParameterChecker(): def invoice(self, info): """ Check if invoice dictionary has proper indexs """ invoice_fields = ['customer', 'items', 'payments'] for cf in invoice_fields: if not info.has_key(cf): raise CommandParametersError( _('Invoice "%s" not specified' % (cf))) return True def customer(self, info):
# """ Common routines used by other parts of the ui test framework. """ import re import gobject import gtk import time from gtk import gdk from kiwi.utils import gsignal from kiwi.log import Logger log = Logger('common') try: from gtk.gdk import event_handler_set event_handler_set # pyflakes except ImportError: try: from kiwi._kiwi import event_handler_set event_handler_set # pyflakes except ImportError: event_handler_set = None def find_in_tree(gobj, *columnValuePairs): retval = []
from kiwi.ui.widgets.combo import ProxyComboEntry, ProxyComboBox, \ ProxyComboBoxEntry from kiwi.ui.widgets.entry import ProxyDateEntry, ProxyEntry from kiwi.ui.widgets.label import ProxyLabel from kiwi.ui.widgets.radiobutton import ProxyRadioButton from kiwi.ui.widgets.scale import ProxyHScale, ProxyVScale from kiwi.ui.widgets.spinbutton import ProxySpinButton from kiwi.ui.widgets.textview import ProxyTextView # Backwards compatibility + pyflakes from kiwi.ui.widgets.combobox import ComboBox, ComboBoxEntry from kiwi.ui.widgets.list import List HyperLink _ = lambda m: gettext.dgettext('kiwi', m) log = Logger('gazpacholoader') class Builder(ObjectBuilder): def find_resource(self, filename): return environ.find_resource("pixmaps", filename) class GazpachoWidgetTree: """Example class of GladeAdaptor that uses Gazpacho loader to load the glade files """ def __init__(self, view, gladefile, domain=None): self._view = view self._gladefile = gladefile self._showwarning = warnings.showwarning
from stoqdrivers.serialbase import SerialBase from stoqdrivers.exceptions import (DriverError, OutofPaperError, PrinterError, CommandError, CouponOpenError, HardwareFailure, PrinterOfflineError, PaymentAdditionError, ItemAdditionError, CancelItemError, CouponTotalizeError, CouponNotOpenError) from stoqdrivers.interfaces import ICouponPrinter from stoqdrivers.printers.capabilities import Capability from stoqdrivers.printers.base import BaseDriverConstants from stoqdrivers.enum import TaxType, UnitType from stoqdrivers.translation import stoqdrivers_gettext _ = stoqdrivers_gettext log = Logger('stoqdrivers.bematech.MP25') CASH_IN_TYPE = "SU" CASH_OUT_TYPE = "SA" # The comment after the commands are comparing the MP25 command with MP20. CMD_COUPON_OPEN = 0 # MP25 aceita 2 parametros opcionais a mais CMD_CLOSE_TILL = 5 CMD_REDUCE_Z = 5 CMD_READ_X = 6 CMD_ADD_TAX = 7 CMD_READ_MEMORY = 8 CMD_COUPON_CANCEL = 14 # MP25 aceita 3 parametros opicionais CMD_STATUS = 19 CMD_ADD_VOUCHER = 25
"""Widget for displaying a list of objects""" import gtk from gtk import gdk, keysyms from kiwi.component import implements from kiwi.interfaces import IEasyCombo from kiwi.enums import ComboColumn, ComboMode from kiwi.log import Logger from kiwi.ui.entry import KiwiEntry from kiwi.ui.entrycompletion import KiwiEntryCompletion from kiwi.utils import gsignal, type_register from kiwi.ui.cellrenderer import ComboDetailsCellRenderer log = Logger('kiwi.ui.combo') class _ComboEntryPopup(gtk.Window): gsignal('text-selected', str) def __init__(self, comboentry): gtk.Window.__init__(self, gtk.WINDOW_POPUP) self.add_events(gdk.BUTTON_PRESS_MASK) self.connect('key-press-event', self._on__key_press_event) self.connect('button-press-event', self._on__button_press_event) self._comboentry = comboentry # Number of visible rows in the popup window, sensible # default value from other toolkits self._visible_rows = 10 self._initial_text = None
class FadeOut(gobject.GObject): """I am a helper class to draw the fading effect of the background Call my methods start() and stop() to control the fading. """ gsignal('done') gsignal('color-changed', gdk.Color) # How long time it'll take before we start (in ms) COMPLAIN_DELAY = 500 MERGE_COLORS_DELAY = 100 ERROR_COLOR = "#ffd5d5" def __init__(self, widget): gobject.GObject.__init__(self) self._widget = widget self._start_color = None self._background_timeout_id = -1 self._countdown_timeout_id = -1 self._log = Logger('fade') self._done = False def _merge_colors(self, src_color, dst_color, steps=10): """ Change the background of widget from src_color to dst_color in the number of steps specified """ self._log.debug('_merge_colors: %s -> %s' % (src_color, dst_color)) if not src_color: yield False rs, gs, bs = src_color.red, src_color.green, src_color.blue rd, gd, bd = dst_color.red, dst_color.green, dst_color.blue rinc = (rd - rs) / float(steps) ginc = (gd - gs) / float(steps) binc = (bd - bs) / float(steps) for dummy in xrange(steps): rs += rinc gs += ginc bs += binc col = gdk.color_parse("#%02X%02X%02X" % (int(rs) >> 8, int(gs) >> 8, int(bs) >> 8)) self.emit('color-changed', col) yield True self.emit('done') self._background_timeout_id = -1 self._done = True yield False def _start_merging(self): # If we changed during the delay if self._background_timeout_id != -1: self._log.debug('_start_merging: Already running') return self._log.debug('_start_merging: Starting') func = self._merge_colors(self._start_color, gdk.color_parse(FadeOut.ERROR_COLOR)).next self._background_timeout_id = ( gobject.timeout_add(FadeOut.MERGE_COLORS_DELAY, func)) self._countdown_timeout_id = -1 def start(self, color): """Schedules a start of the countdown. :param color: initial background color :returns: True if we could start, False if was already in progress """ if self._background_timeout_id != -1: self._log.debug('start: Background change already running') return False if self._countdown_timeout_id != -1: self._log.debug('start: Countdown already running') return False if self._done: self._log.debug('start: Not running, already set') return False self._start_color = color self._log.debug('start: Scheduling') self._countdown_timeout_id = gobject.timeout_add( FadeOut.COMPLAIN_DELAY, self._start_merging) return True def stop(self): """Stops the fadeout and restores the background color""" self._log.debug('Stopping') if self._background_timeout_id != -1: gobject.source_remove(self._background_timeout_id) self._background_timeout_id = -1 if self._countdown_timeout_id != -1: gobject.source_remove(self._countdown_timeout_id) self._countdown_timeout_id = -1 self._widget.update_background(self._start_color) self._done = False
## ## Author(s): Johan Dahlin <*****@*****.**> ## Henrique Romano <*****@*****.**> ## from kiwi.log import Logger from serial import Serial, EIGHTBITS, PARITY_NONE, STOPBITS_ONE from zope.interface import implements from stoqdrivers.interfaces import ISerialPort from stoqdrivers.exceptions import DriverError from stoqdrivers.translation import stoqdrivers_gettext _ = stoqdrivers_gettext log = Logger('stoqdrivers.serial') class VirtualPort: implements(ISerialPort) def getDSR(self): return True def setDTR(self, value): pass def write(self, data): pass def read(self, n_bytes=1):
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ################################################################################ from stoqdrivers.printers.fiscal import FiscalPrinter from stoqdrivers.printers import base from stoqdrivers.exceptions import DriverError from stoqdrivers.translation import stoqdrivers_gettext _ = stoqdrivers_gettext from kiwi.log import Logger log = Logger('fiscalex') class FiscalPrinterEx(FiscalPrinter): def get_supported_printers(self): printers = base.get_supported_printers() for brand in printers: for i in range(0, len(printers[brand])): printers[brand][i] = str(printers[brand][i]).split(".")[3] return printers def get_supported_printers(self): return base.get_supported_printers() def set_payment_methods(self, payment_methods): log.info('set_payment_methods()')
def setUp(self): self.filename = tempfile.mktemp() self.log = Logger('log')
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # # Author(s): Johan Dahlin <*****@*****.**> # from gtk.glade import XML from kiwi.log import Logger log = Logger('libgladeloader') class LibgladeWidgetTree(XML): def __init__(self, view, gladefile, domain=None): self._view = view self._gladefile = gladefile XML.__init__(self, gladefile, domain) self._widgets = [w.get_name() for w in self.get_widget_prefix('')] self._attach_widgets() def _attach_widgets(self): # Attach widgets in the widgetlist to the view specified, so # widgets = [label1, button1] -> view.label1, view.button1 for w in self._widgets: widget = XML.get_widget(self, w)
import gettext import gobject import gtk from gtk import gdk from kiwi import ValueUnset from kiwi.component import implements from kiwi.datatypes import ValidationError, converter, BaseConverter from kiwi.environ import environ from kiwi.interfaces import IProxyWidget, IValidatableProxyWidget from kiwi.log import Logger from kiwi.ui.gadgets import FadeOut log = Logger('widget proxy') _ = lambda m: gettext.dgettext('kiwi', m) class _PixbufConverter(BaseConverter): type = gdk.Pixbuf name = 'Pixbuf' def as_string(self, value, format='png'): if value is ValueUnset: return '' buffer = [] value.save_to_callback(buffer.append, format) string = ''.join(buffer) return string
from kiwi.ui.delegates import GladeDelegate from stoqlib.api import api from stoqlib.database.interfaces import ICurrentUser from stoqlib.exceptions import DatabaseError, LoginError, UserProfileError from stoqlib.domain.person import LoginUser from stoqlib.gui.base.dialogs import RunnableView from stoqlib.gui.logo import render_logo_pixbuf from stoqlib.lib.interfaces import CookieError, ICookieFile from stoqlib.lib.message import warning from stoqlib.lib.translation import stoqlib_gettext _ = stoqlib_gettext RETRY_NUMBER = 3 log = Logger(__name__) def _encrypt_password(password): return hashlib.md5(password).hexdigest() class LoginDialog(GladeDelegate, RunnableView): toplevel_name = gladefile = "LoginDialog" size = (-1, -1) def __init__(self, title=None): self.keyactions = {gtk.keysyms.Escape: self.on_escape_pressed} GladeDelegate.__init__(self, gladefile=self.gladefile, keyactions=self.keyactions, delete_handler=gtk.main_quit)
Runner - executes recorded scripts """ import doctest import os import sys import time from StringIO import StringIO import gobject from gtk import gdk from kiwi.log import Logger from kiwi.ui.test.common import WidgetIntrospecter log = Logger('kiwi.ui.test.player') class NotReadyYet(Exception): pass class MissingWidget(KeyError): pass class MagicWindowWrapper(object): def __init__(self, window, ns): self.window = window self.ns = ns
## Foundation, Inc., or visit: http://www.gnu.org/. ## ## Author(s): Stoq Team <*****@*****.**> ## """ Simple Base64 ICookieFile implementation """ import binascii import os from kiwi.component import implements from kiwi.log import Logger from stoqlib.lib.interfaces import CookieError, ICookieFile log = Logger(__name__) class Base64CookieFile(object): implements(ICookieFile) def __init__(self, filename): self._filename = filename def get(self): if not os.path.exists(self._filename): raise CookieError("%s does not exist" % self._filename) cookiedata = open(self._filename).read() if not ':' in cookiedata:
""" import gobject import gtk from kiwi import ValueUnset from kiwi.accessor import kgetattr, ksetattr, clear_attr_cache from kiwi.datatypes import converter from kiwi.decorators import deprecated from kiwi.interfaces import IProxyWidget, IValidatableProxyWidget from kiwi.log import Logger class ProxyError(Exception): pass log = Logger('proxy') def block_widget(widget): """Blocks the signal handler of the 'content-changed' signal on widget""" connection_id = widget.get_data('content-changed-id') if connection_id: widget.handler_block(connection_id) def unblock_widget(widget): """Unblocks the signal handler of the 'content-changed' signal on widget""" connection_id = widget.get_data('content-changed-id') if connection_id: widget.handler_unblock(connection_id) def _get_widget_data_type(widget): data_type = widget.get_property('data-type')