rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
where_expr = (hashtext(key_user_name) & %%(max_slots)s) in (%%(slots)s) | where_expr = (hashtext(key_user_name) & %%(max_slot)s) in (%%(slots)s) | def force_tick(self, curs, queue_name): """ Force tick into source queue so that consumer can move on faster """ q = "select pgq.force_tick(%s)" curs.execute(q, [queue_name]) res = curs.fetchone() cur_pos = res[0] |
hash_expr = self.cf.get('hash_expr') | where_expr = self.cf.get('where_expr') | def work(self): """Syncer main function.""" |
slots = dst_row['slots'] max_slot = dst_row['max_slot'] self.log.info('Source: db=%s host=%s queue=%s consumer=%s' % ( s_db, s_host, queue_name, consumer_name)) self.log.info('Target: db=%s host=%s slots=%s' % (d_db, d_host, slots)) | def work(self): """Syncer main function.""" | |
where = "(%s & %d) in (%s)" % (hash_expr, max_slot, slots) | where = where_expr % dst_row self.log.info('Source: db=%s host=%s queue=%s consumer=%s' % ( s_db, s_host, queue_name, consumer_name)) self.log.info('Target: db=%s host=%s where=%s' % (d_db, d_host, where)) | def work(self): """Syncer main function.""" |
self.do_compare(tbl, src_db, dst_db, where) | if check == 'compare': self.do_compare(tbl, src_db, dst_db, where) elif check == 'repair': r = TableRepair(tbl, self.log) r.do_repair(src_db, dst_db, where, 'fix.' + tbl, False) elif check == 'repair-apply': r = TableRepair(tbl, self.log) r.do_repair(src_db, dst_db, where, 'fix.' + tbl, True) else: raise Exception('unk... | def work(self): """Syncer main function.""" |
return self.SQL | return cls.SQL | def get_load_sql(cls, pgver): """Return SQL statement for finding objects.""" return self.SQL |
self.local_only = self.cf.getboolean('local_only', False) | def __init__(self, args): """Replication init.""" CascadedWorker.__init__(self, 'londiste3', 'db', args) | |
if self.local_only: | if self.cf.getboolean('local_only', False): if self.copy_thread: _filterlist = skytools.quote_literal(self.copy_table_name) else: _filterlist = ','.join(map(skytools.quote_literal, self.table_map.keys())) | def process_remote_batch(self, src_db, tick_id, ev_list, dst_db): "All work for a batch. Entry point from SetConsumer." |
""" % ','.join(map(skytools.quote_literal, self.table_map.keys())) | """ % _filterlist else: self.consumer_filter = None | def process_remote_batch(self, src_db, tick_id, ev_list, dst_db): "All work for a batch. Entry point from SetConsumer." |
conf = """ restore_command = '%s %s %s' """ % (self.script, cf_file, restore_command) | conf = "restore_command = '%s %s %s'\n" % (self.script, cf_file, restore_command) primary_conninfo = self.cf.get("primary_conninfo", "") if primary_conninfo: conf += "standby_mode = 'on'\n" conf += "trigger_file = '%s'\n" % os.path.join(self.cf.get("completed_wals"), "STOP") conf += "primary_conninfo = '%s'\n" % prim... | def restore_database(self): """Restore the database from backup |
srcdir = self.cf.get("completed_wals") stopfile = os.path.join(srcdir, "STOP") | stopfile = os.path.join(self.cf.get("completed_wals"), "STOP") | def restore_database(self): """Restore the database from backup |
curs.execute("set local session_replication_role = 'local'") | dst_curs.execute("set local session_replication_role = 'local'") | def handle_execute_event(self, ev, dst_curs): """handle one EXECUTE event""" |
curs.execute("set local session_replication_role = 'replica'") | dst_curs.execute("set local session_replication_role = 'replica'") | def handle_execute_event(self, ev, dst_curs): """handle one EXECUTE event""" |
if not setname: | if not setname and not link_xlog_dir: | def restore_database(self): """Restore the database from backup |
self.exec_rsync(["--delete", "--no-relative", "--exclude=pg_xlog/*", os.path.join(full_dir,""), data_dir], True) if self.wtype == MASTER and createbackup and os.path.isdir(bak): | rsync_args=["--delete", "--no-relative", "--exclude=pg_xlog/*"] if exclude_pg_xlog: rsync_args.append(exclude_pg_xlog) rsync_args += [os.path.join(full_dir, ""), data_dir] self.exec_rsync(rsync_args, True) if link_xlog_dir: os.symlink(self.cf.get('slave_pg_xlog'), "%s/pg_xlog" % data_dir) if (self.wtype == MASTER an... | def restore_database(self): """Restore the database from backup |
self.exec_cmd(["cp", "-rL", "%s/pg_xlog" % bak, data_dir]) | self.exec_cmd(["cp", "-rL", "%s/pg_xlog/" % full_dir, "%s/pg_xlog" % data_dir ]) | def restore_database(self): """Restore the database from backup |
os.mkdir(os.path.join(xlog_dir, "archive_status"), 0700) | archive_path = os.path.join(xlog_dir, "archive_status") if not os.path.exists(archive_path): os.mkdir(archive_path, 0700) | def restore_database(self): """Restore the database from backup |
dst_curs.execute(q, [self.queue_name, self.consumer_name, tick_id]) | dst_curs.execute(q, [self.queue_name, self.consumer_name, last_tick]) | def dst_reset(self): self.log.info("Resetting queue tracking on dst side") |
""" if not array or array[0] != "{" or array[-1] != '}': | >>> parse_pgarray("[0,3]={1,2,3}") ['1', '2', '3'] """ if not array or array[0] not in ("{", "[") or array[-1] != '}': | def parse_pgarray(array): r"""Parse Postgres array and return list of items inside it. Examples: >>> parse_pgarray('{}') [] >>> parse_pgarray('{a,b,null,"null"}') ['a', 'b', None, 'null'] >>> parse_pgarray(r'{"a,a","b\"b","c\\c"}') ['a,a', 'b"b', 'c\\c'] """ if not array or array[0] != "{" or array[-1] != '}': raise E... |
SELECT conname as name, pg_get_constraintdef(oid) as def, contype FROM pg_constraint WHERE conrelid = %(oid)s AND contype != 'f' | SELECT c.conname as name, pg_get_constraintdef(c.oid) as def, c.contype, i.indisclustered as is_clustered FROM pg_constraint c LEFT JOIN pg_index i ON c.conrelid = i.indrelid AND c.conname = (SELECT r.relname FROM pg_class r WHERE r.oid = i.indexrelid) WHERE c.conrelid = %(oid)s AND c.contype != 'f' | def get_drop_sql(self, curs): """Return SQL statement for dropping or None of not supported.""" return None |
pg_get_indexdef(i.indexrelid) as defn | pg_get_indexdef(i.indexrelid) as defn, c.relname as local_name, i.indisclustered as is_clustered | def get_drop_sql(self, curs): """Generate removal sql.""" fmt = "ALTER TABLE ONLY %s DROP CONSTRAINT %s;" sql = fmt % (quote_fqident(self.table_name), quote_ident(self.name)) return sql |
if not new_table_name: return self.defn name = find_new_name(curs, self.name) pnew = "INDEX %s ON %s " % (quote_ident(name), quote_fqident(new_table_name)) rx = r"\bINDEX[ ][a-z0-9._]+[ ]ON[ ][a-z0-9._]+[ ]" sql = rx_replace(rx, self.defn, pnew) | if new_table_name: iname = find_new_name(curs, self.name) tname = new_table_name pnew = "INDEX %s ON %s " % (quote_ident(iname), quote_fqident(tname)) rx = r"\bINDEX[ ][a-z0-9._]+[ ]ON[ ][a-z0-9._]+[ ]" sql = rx_replace(rx, self.defn, pnew) else: sql = self.defn iname = self.local_name tname = self.table_name if self.... | def get_create_sql(self, curs, new_table_name = None): """Generate creation SQL.""" if not new_table_name: return self.defn # fixme: seems broken name = find_new_name(curs, self.name) pnew = "INDEX %s ON %s " % (quote_ident(name), quote_fqident(new_table_name)) rx = r"\bINDEX[ ][a-z0-9._]+[ ]ON[ ][a-z0-9._]+[ ]" sql = ... |
last = self.del_wals(completed_wals, last_applied) if last: if os.path.isdir(partial_wals): self.log.debug("cleaning partial wals before %s" % last) self.del_wals(partial_wals, last) else: self.log.warning("partial_wals dir does not exist: %s" % partial_wals) | self.del_wals(completed_wals, last_applied) if os.path.isdir(partial_wals): self.log.debug("cleaning partial wals before %s" % last_applied) self.del_wals(partial_wals, last_applied) else: self.log.warning("partial_wals dir does not exist: %s" % partial_wals) | def slave_cleanup(self, last_applied): completed_wals = self.cf.get("completed_wals") partial_wals = self.cf.get("partial_wals") |
create_flags = 0 | create_flags = skytools.T_TABLE | def cmd_add_table(self, *args): """Attach table(s) to local node.""" |
create_flags += fmap[f] | create_flags |= fmap[f] | def cmd_add_table(self, *args): """Attach table(s) to local node.""" |
q = "select count(1) from only _TABLE_" | q = "select count(1) as cnt, sum(hashtext(t.*::text)) as chksum from only _TABLE_ t" | def process_sync(self, tbl, src_db, dst_db): """Actual comparision.""" |
src_str = ", ".join(map(str, src_row)) self.log.info("srcdb: res = %s" % src_str) | src_str = f % src_row self.log.info("srcdb: %s" % src_str) | def process_sync(self, tbl, src_db, dst_db): """Actual comparision.""" |
dst_str = ", ".join(map(str, dst_row)) self.log.info("dstdb: res = %s" % dst_str) | dst_str = f % dst_row self.log.info("dstdb: %s" % dst_str) | def process_sync(self, tbl, src_db, dst_db): """Actual comparision.""" |
defs = { | self.defs = { | def __init__(self, main_section, filename, sane_config = 1, user_defs = {}): """Initialize Config and read from file. |
defs.update(user_defs) | self.defs.update(user_defs) | def __init__(self, main_section, filename, sane_config = 1, user_defs = {}): """Initialize Config and read from file. |
self.cf = ConfigParser.SafeConfigParser(defs) | self.cf = ConfigParser.SafeConfigParser() | def __init__(self, main_section, filename, sane_config = 1, user_defs = {}): """Initialize Config and read from file. |
self.cf = ConfigParser.ConfigParser(defs) | self.cf = ConfigParser.ConfigParser() | def __init__(self, main_section, filename, sane_config = 1, user_defs = {}): """Initialize Config and read from file. |
return | elif not os.path.isfile(filename): raise Exception('Config file not found: '+filename) | def __init__(self, main_section, filename, sane_config = 1, user_defs = {}): """Initialize Config and read from file. |
if not os.path.isfile(filename): raise Exception('Config file not found: '+filename) self.cf.read(filename) if not self.cf.has_section(main_section): raise Exception("Wrong config file, no section '%s'"%main_section) | self.reload() | def __init__(self, main_section, filename, sane_config = 1, user_defs = {}): """Initialize Config and read from file. |
restore the directory. | restore the directory (unless a pg_xlog directory has been specified). | def restore_database(self): """Restore the database from backup |
if not setname and os.path.isdir(data_dir): | backup_datadir = self.cf.getboolean('backup_datadir', True) if os.path.isdir(data_dir) and not backup_datadir: self.log.warning('backup_datadir is disabled, deleting old data dir') shutil.rmtree(data_dir) if not setname and os.path.isdir(data_dir) and backup_datadir: | def restore_database(self): """Restore the database from backup |
s.append (prepend_symbols ('--import-impl=', impl_import (obj, prefix))) | if os.path.isdir (obj.impl_dir (prefix)): s.append (prepend_symbols ('--import-impl=', impl_import (obj, prefix))) | def import_options (obj, prefix=''): s = [] if obj.impl_dir () is not None: s.append (prepend_symbols ('--import-impl=', impl_import (obj, prefix))) if obj.sidl_file () is not None: s.append (prepend_symbols ('--import-sidl=', sidl_import (obj, prefix))) return ' '.join (s) |
s.append (prepend_symbols ('--import-sidl=', sidl_import (obj, prefix))) | if os.path.isfile (obj.sidl_file (prefix)): s.append (prepend_symbols ('--import-sidl=', sidl_import (obj, prefix))) | def import_options (obj, prefix=''): s = [] if obj.impl_dir () is not None: s.append (prepend_symbols ('--import-impl=', impl_import (obj, prefix))) if obj.sidl_file () is not None: s.append (prepend_symbols ('--import-sidl=', sidl_import (obj, prefix))) return ' '.join (s) |
admin.site.register(Nonce) | def __unicode__(self): return u"Nonce %s for %s" % (self.key, self.consumer_key) | |
admin.site.register(Consumer) | def generate_random_codes(self): """ Used to generate random key/secret pairings. Use this after you've added the other data in place of save(). | |
admin.site.register(Token) | def set_callback(self, callback): if callback != "oob": # out of band, says "we can't do this!" self.callback = callback self.callback_confirmed = True self.save() | |
if len(inspect.getargspec(maybe)[0]) == 1: | if len(inspect.getargspec(maybe)[0]) <= 1: | def _model(data, fields=()): """ Models. Will respect the `fields` and/or `exclude` on the handler (see `typemapper`.) """ ret = { } handler = self.in_typemapper(type(data), self.anonymous) get_absolute_uri = False if handler or fields: v = lambda f: getattr(data, f.attname) |
if not self._pre_test_email(): return | def test_create_pending(self): """ Ensure creating a pending Consumer sends proper emails """ # If it's pending we should have two messages in the outbox; one # to the consumer and one to the site admins. if len(settings.ADMINS): self.assertEquals(len(mail.outbox), 2) else: self.assertEquals(len(mail.outbox), 1) | |
self.consumer.delete() | self.consumer.delete() if not self._pre_test_email(): return | def test_delete_consumer(self): """ Ensure deleting a Consumer sends a cancel email """ |
self.label.set_text(self.text[:mid-6] + '…' + self.text[len(self.text)-6:]) | if mid-6 < 0: self.label.set_text(self.text) return self.label.set_text('%s…%s' %(self.text[:mid-6], self.text[len(self.text)-6:])) | def _wrap_label(self, min, max, width): mid = (min + max) / 2 self.label.set_text(self.text[:mid-6] + '…' + self.text[len(self.text)-6:]) if mid == min or self.label.get_preferred_size()[2] == width: return if self.label.get_preferred_size()[2] > width: self._wrap_label(min, mid, width) else: self._wrap_label(mid, max,... |
gobject.timeout_add(self.tooltip_duration, self._hide_tooltip) | if self._hide_timeout_id is not None: gobject.source_remove(self._hide_timeout_id) self._hide_timeout_id = gobject.timeout_add(self.tooltip_duration, self._hide_tooltip) | def _show_tooltip(self): if self.tooltip_actor and not self._tooltip_displayed: self._tooltip_displayed = True self.tooltip_actor.set_opacity(0) self.tooltip_actor.show() self.tooltip_pointer.set_opacity(0) self.tooltip_pointer.show() self.tooltip_show_timeline.start() if self.tooltip_duration > 0: gobject.timeout_add(... |
gobject.timeout_add(self.animation_duration, self._hide_tooltip_finish) | if self._animation_timeout_id is not None: gobject.source_remove(self._animation_timeout_id) self._animation_timeout_id = gobject.timeout_add(self.animation_duration, self._hide_tooltip_finish) | def _hide_tooltip(self): if self.tooltip_actor and self._tooltip_displayed: self.tooltip_hide_timeline.start() gobject.timeout_add(self.animation_duration, self._hide_tooltip_finish) return False |
preferred_width += used_width + self.spacing | preferred_width = max(preferred_width, used_width) | def do_get_preferred_width(self, for_height): inner_height = for_height - 2*self.border preferred_width = 0 if self._horizontal is False: #find size available for resizable elements resizable_elements = list() resizable_height = inner_height for element in self.elements: if element.get('resizable', 0) != 0: if element[... |
if element.get('expand') is True: if element.get('keep_ratio') is True: obj_height = element['object'].get_preferred_size()[3] obj_width = element['object'].get_preferred_size()[2] if self._horizontal is True: if obj_height != 0: ratio = float(obj_width/obj_height) obj_width = int(inner_height*ratio) resizable_width -=... | if element.get('expand') is True and element.get('keep_ratio') is True: pass | def do_allocate(self, box, flags): main_width = box.x2 - box.x1 main_height = box.y2 - box.y1 inner_width = main_width - 2*self.border inner_height = main_height - 2*self.border #find size available for resizable elements resizable_elements = list() resizable_width = inner_width resizable_height = inner_height for ele... |
original_height = obj_height | def do_allocate(self, box, flags): main_width = box.x2 - box.x1 main_height = box.y2 - box.y1 inner_width = main_width - 2*self.border inner_height = main_height - 2*self.border #find size available for resizable elements resizable_elements = list() resizable_width = inner_width resizable_height = inner_height for ele... | |
if element.get('keep_ratio') is True and original_height != 0: ratio = float(obj_height/original_height) obj_width = int(obj_width*ratio) else: original_width = obj_width | if element.get('keep_ratio') is True and original_width != 0 and original_height != 0: factor = float(obj_height) / float(original_height) obj_width = int(original_width * factor) if obj_width > special_width: obj_width = int(special_width) special_width = 0 ratio = float(original_width) / float(original_height) obj_he... | def do_allocate(self, box, flags): main_width = box.x2 - box.x1 main_height = box.y2 - box.y1 inner_width = main_width - 2*self.border inner_height = main_height - 2*self.border #find size available for resizable elements resizable_elements = list() resizable_width = inner_width resizable_height = inner_height for ele... |
if element.get('keep_ratio') is True and original_width != 0: ratio = float(obj_width/original_width) obj_height = int(obj_height*ratio) | if element.get('keep_ratio') is True and original_width != 0 and original_height != 0: factor = float(obj_width) / float(original_width) obj_height = int(original_height * factor) if obj_height > special_height: obj_height = int(special_height) special_height = 0 ratio = float(original_width) / float(original_height) o... | def do_allocate(self, box, flags): main_width = box.x2 - box.x1 main_height = box.y2 - box.y1 inner_width = main_width - 2*self.border inner_height = main_height - 2*self.border #find size available for resizable elements resizable_elements = list() resizable_width = inner_width resizable_height = inner_height for ele... |
rect1.set_size(200, 100) | rect1.set_size(200, 50) | def do_pick(self, color): if self.pick_enabled: self.do_paint() else: clutter.Actor.do_pick(self, color) |
rect2.set_size(25, 50) | rect2.set_size(20, 10) | def do_pick(self, color): if self.pick_enabled: self.do_paint() else: clutter.Actor.do_pick(self, color) |
'resizable': 1.0, | def do_pick(self, color): if self.pick_enabled: self.do_paint() else: clutter.Actor.do_pick(self, color) | |
line.props.request_mode = clutter.REQUEST_WIDTH_FOR_HEIGHT line.set_height(400) | line.set_width(500) | def do_pick(self, color): if self.pick_enabled: self.do_paint() else: clutter.Actor.do_pick(self, color) |
self._has_title = True elif title is not None: self._has_title = True else: self._has_title = False | def __init__(self, title=None, title_actor=None, content_actor=None, padding=10, title_padding=None, spacing=10, textures_package=None): clutter.Actor.__init__(self) self.padding = padding self.spacing = spacing self._highlighted = False self._highlight_color = clutter.color_from_string('#ffffff44') self._disabled = F... | |
if title is not None: | self.title_text = title self.check_title() if self.title_text is not None: | def __init__(self, title=None, title_actor=None, content_actor=None, padding=10, title_padding=None, spacing=10, textures_package=None): clutter.Actor.__init__(self) self.padding = padding self.spacing = spacing self._highlighted = False self._highlight_color = clutter.color_from_string('#ffffff44') self._disabled = F... |
self.default_title_actor.set_text(title) | self.title_text = title self.check_title() if self.title_text is not None: self.default_title_actor.set_text(title) | def set_title(self, title): self.default_title_actor.set_text(title) self.queue_relayout() |
return self.default_title_actor.get_text(title) | return self.title_text | def get_title(self): return self.default_title_actor.get_text(title) |
else: | elif self._has_title: | def do_get_preferred_width(self, for_height): if self.title_actor: max_width = self.title_actor.get_preferred_width(for_height)[1] else: max_width = self.default_title_actor.get_preferred_width(for_height)[1] if self.content_actor: max_width = max(max_width, self.content_actor.get_preferred_width(for_height)[1]) prefer... |
else: | if self.content_actor: preferred_height += self.spacing elif self._has_title: | def do_get_preferred_height(self, for_width): preferred_height = 2*self.padding if self.title_actor: preferred_height += self.title_actor.get_preferred_height(for_width)[1] else: preferred_height += self.default_title_actor.get_preferred_height(for_width)[1] if self.content_actor: preferred_height += self.spacing + sel... |
if self.content_actor: preferred_height += self.spacing + self.content_actor.get_preferred_height(for_width)[1] | if self.content_actor: preferred_height += self.spacing if self.content_actor: preferred_height += self.content_actor.get_preferred_height(for_width)[1] | def do_get_preferred_height(self, for_width): preferred_height = 2*self.padding if self.title_actor: preferred_height += self.title_actor.get_preferred_height(for_width)[1] else: preferred_height += self.default_title_actor.get_preferred_height(for_width)[1] if self.content_actor: preferred_height += self.spacing + sel... |
if self.scale_positions_list is not None : for child in self.scale_list : if child is not None : child.unparent() child.destroy() child = None | if hasattr(self, 'scale_positions_list'): if self.scale_positions_list is not None: for child in self.scale_list: if child is not None: child.unparent() child.destroy() child = None | def do_destroy(self): self.unparent() if hasattr(self, 'scrollbar_background'): if self.scrollbar_background is not None: self.scrollbar_background.unparent() self.scrollbar_background.destroy() self.scrollbar_background = None if hasattr(self, 'label'): if self.label is not None: self.label.unparent() self.label.destr... |
self._children.insert(child, 0) | self._children.insert(0, child) | def do_lower_child(self, child, sibling=None): if child not in self._children: raise Exception("Actor %s is not a child of %s" % (child, self)) if sibling: if sibling not in self._children: raise Exception("Actor %s is not a child of %s" % (sibling, self)) sibling_index = self._children.index(sibling) child_index = sel... |
def __init__(self, horizontal=True, spacing=0.0, border=0.0, bg_ignore_allocation_box=False): | def __init__(self, horizontal=True, spacing=0.0, border=0.0, bg_ignore_allocation_box=True): | def __init__(self, horizontal=True, spacing=0.0, border=0.0, bg_ignore_allocation_box=False): clutter.Actor.__init__(self) self.elements = list() self.background = None self.spacing = spacing self.border = border if horizontal == True: self._horizontal = True else: self._horizontal = False if bg_ignore_allocation_box =... |
resizable_height += self.spacing | if resizable_height != inner_height: resizable_height += self.spacing | def do_get_preferred_width(self, for_height): inner_height = for_height - 2*self.border preferred_width = 0 if self._horizontal is False: #find size available for resizable elements resizable_elements = list() resizable_height = inner_height for element in self.elements: if element.get('resizable', 0) != 0: if element[... |
resizable_width += self.spacing | if resizable_width != inner_width: resizable_width += self.spacing | def do_get_preferred_height(self, for_width): inner_width = for_width - 2*self.border preferred_height = 0 if self._horizontal is True: #find size available for resizable elements resizable_elements = list() resizable_width = inner_width for element in self.elements: if element.get('resizable', 0) != 0: if element['res... |
bgbox = clutter.ActorBox() bgbox.x1 = 0 bgbox.y1 = 0 bgbox.x2 = main_width bgbox.y2 = self.border + round(y) - self.spacing self.background.allocate(bgbox, flags) | if self._horizontal is True: bgbox = clutter.ActorBox() bgbox.x1 = 0 bgbox.y1 = 0 bgbox.x2 = self.border + round(x) - self.spacing bgbox.y2 = main_height self.background.allocate(bgbox, flags) else: bgbox = clutter.ActorBox() bgbox.x1 = 0 bgbox.y1 = 0 bgbox.x2 = main_width bgbox.y2 = self.border + round(y) - self.spaci... | def do_allocate(self, box, flags): main_width = box.x2 - box.x1 main_height = box.y2 - box.y1 inner_width = main_width - 2*self.border inner_height = main_height - 2*self.border #find size available for resizable elements resizable_elements = list() resizable_width = inner_width resizable_height = inner_height for ele... |
if border_color is not None and self._border_width > 0.0: cogl.path_round_rectangle(0, 0, width, height, self._radius, 1) | radius_size = 2*self._radius if radius_size <= width and radius_size <= height: radius = self._radius elif radius_size > width and radius_size <= height: radius = width / 2.0 elif radius_size <= width and radius_size > height: radius = height / 2.0 else: radius = min(width, height) / 2.0 if border_color is not None an... | def __paint_rectangle(self, width, height, color, border_color=None): if border_color is not None and self._border_width > 0.0: cogl.path_round_rectangle(0, 0, width, height, self._radius, 1) cogl.path_close() cogl.set_source_color(border_color) cogl.path_fill() w = self._border_width cogl.path_round_rectangle(w, w, w... |
cogl.path_round_rectangle(w, w, width - w, height - w, self._radius - w, 1) | cogl.path_round_rectangle(w, w, width - w, height - w, radius - w, 1) | def __paint_rectangle(self, width, height, color, border_color=None): if border_color is not None and self._border_width > 0.0: cogl.path_round_rectangle(0, 0, width, height, self._radius, 1) cogl.path_close() cogl.set_source_color(border_color) cogl.path_fill() w = self._border_width cogl.path_round_rectangle(w, w, w... |
cogl.path_round_rectangle(0, 0, width, height, self._radius, 1) | cogl.path_round_rectangle(0, 0, width, height, radius, 1) | def __paint_rectangle(self, width, height, color, border_color=None): if border_color is not None and self._border_width > 0.0: cogl.path_round_rectangle(0, 0, width, height, self._radius, 1) cogl.path_close() cogl.set_source_color(border_color) cogl.path_fill() w = self._border_width cogl.path_round_rectangle(w, w, w... |
cogl.set_source_texture(cogl.texture_new_from_file(self._light_path)) | cogl.set_source_texture(self._light_texture) | def __paint_rectangle(self, width, height, color, border_color=None): if border_color is not None and self._border_width > 0.0: cogl.path_round_rectangle(0, 0, width, height, self._radius, 1) cogl.path_close() cogl.set_source_color(border_color) cogl.path_fill() w = self._border_width cogl.path_round_rectangle(w, w, w... |
cogl.set_source_texture(cogl.texture_new_from_file(self._dark_path)) | cogl.set_source_texture(self._dark_texture) | def __paint_rectangle(self, width, height, color, border_color=None): if border_color is not None and self._border_width > 0.0: cogl.path_round_rectangle(0, 0, width, height, self._radius, 1) cogl.path_close() cogl.set_source_color(border_color) cogl.path_fill() w = self._border_width cogl.path_round_rectangle(w, w, w... |
if self.factor is not None: value_to_display = float(self.value * self.factor) else: value_to_display = float(self.value) decimal = round(float(value_to_display) - int(value_to_display), 1) if decimal == 0.0: self.value_btn.props.text = str(int(value_to_display)) elif decimal == 1.0: self.value_btn.props.text = str(int... | def __init__(self, min, max, default, increment=1, text=None, factor=None): Box.__init__(self, horizontal=True, spacing=5, border=5) | |
if self.factor is not None: value_to_display = float(self.value * self.factor) else: value_to_display = float(self.value) decimal = round(float(value_to_display) - int(value_to_display), 1) if decimal == 0.0: self.value_btn.props.text = str(int(value_to_display)) elif decimal == 1.0: self.value_btn.props.text = str(int... | self.update_rounded_value() | def update(self): if self.factor is not None: value_to_display = float(self.value * self.factor) else: value_to_display = float(self.value) decimal = round(float(value_to_display) - int(value_to_display), 1) if decimal == 0.0: self.value_btn.props.text = str(int(value_to_display)) elif decimal == 1.0: self.value_btn.pr... |
def set_line_alignment(self, alignement): if alignement == 'center': | def set_line_alignment(self, alignment): if alignment == 'center': self._alignment = 'center' | def set_line_alignment(self, alignement): if alignement == 'center': self.label.set_line_alignment(1) elif alignement == 'right': self.label.set_line_alignment(2) elif alignement == 'left': self.label.set_line_alignment(3) |
elif alignement == 'right': | elif alignment == 'right': self._alignment = 'right' | def set_line_alignment(self, alignement): if alignement == 'center': self.label.set_line_alignment(1) elif alignement == 'right': self.label.set_line_alignment(2) elif alignement == 'left': self.label.set_line_alignment(3) |
elif alignement == 'left': | elif alignment == 'left': self._alignment = 'left' | def set_line_alignment(self, alignement): if alignement == 'center': self.label.set_line_alignment(1) elif alignement == 'right': self.label.set_line_alignment(2) elif alignement == 'left': self.label.set_line_alignment(3) |
lbl_width = inner_width | def do_allocate(self, box, flags): btn_width = box.x2 - box.x1 btn_height = box.y2 - box.y1 inner_width = btn_width - 2*self.padding inner_height = btn_height - 2*self.padding rect_box = clutter.ActorBox() rect_box.x1 = 0 rect_box.y1 = 0 rect_box.x2 = btn_width rect_box.y2 = btn_height self.rect.allocate(rect_box, fla... | |
lbl_width = self.label.get_preferred_size()[2] lbl_height = self.label.get_preferred_size()[3] | lbl_width = self.label.get_preferred_size()[2] lbl_height = self.label.get_preferred_size()[3] x1_padding = x2_padding = round((inner_width - lbl_width) / 2.0) else: lbl_width = self.label.get_preferred_size()[2] lbl_height = self.label.get_preferred_size()[3] if self._alignment == 'right': x1_padding = inner_width - l... | def do_allocate(self, box, flags): btn_width = box.x2 - box.x1 btn_height = box.y2 - box.y1 inner_width = btn_width - 2*self.padding inner_height = btn_height - 2*self.padding rect_box = clutter.ActorBox() rect_box.x1 = 0 rect_box.y1 = 0 rect_box.x2 = btn_width rect_box.y2 = btn_height self.rect.allocate(rect_box, fla... |
lbl_box.x1 = round(self.padding + (inner_width - lbl_width) / 2) | lbl_box.x1 = self.padding + x1_padding | def do_allocate(self, box, flags): btn_width = box.x2 - box.x1 btn_height = box.y2 - box.y1 inner_width = btn_width - 2*self.padding inner_height = btn_height - 2*self.padding rect_box = clutter.ActorBox() rect_box.x1 = 0 rect_box.y1 = 0 rect_box.x2 = btn_width rect_box.y2 = btn_height self.rect.allocate(rect_box, fla... |
lbl_box.x2 = round(lbl_box.x1 + lbl_width) | lbl_box.x2 = btn_width - self.padding - x2_padding | def do_allocate(self, box, flags): btn_width = box.x2 - box.x1 btn_height = box.y2 - box.y1 inner_width = btn_width - 2*self.padding inner_height = btn_height - 2*self.padding rect_box = clutter.ActorBox() rect_box.x1 = 0 rect_box.y1 = 0 rect_box.x2 = btn_width rect_box.y2 = btn_height self.rect.allocate(rect_box, fla... |
self.rect.set_color(color) else: | def set_inner_color(self, color): if self.rect is not None: self.rect.set_color(color) else: self.rect.set_color(color) | |
self.icon.show() | if self.has_icon(): self.icon.show() | def set_icon_allocate(self, boolean): if boolean and not self._icon_allocate: self._icon_allocate = True self.icon.show() self.queue_relayout() elif not boolean and self._icon_allocate: self._icon_allocate = False self.icon.hide() self.queue_relayout() |
new_option.set_icon_allocate(False) new_option.set_reactive(True) new_option.connect('button-release-event', self._on_click) | def add_option(self, name, hname, icon_path=None): new_option = OptionLine(name, hname, padding=(self._padding.x, self._padding.y), spacing=self._spacing.x, icon_path=icon_path, icon_height=self.icon_height, enable_background=False, font=self.font, font_color=self.font_color, color=self.option_color, border_color='#000... | |
test_select.add_option('test1', 'displayed') test_select.add_option('test2', 'displayed regregreg') test_select.add_option('test3', 'displayed fezfzefezfzef') | icon_path = None test_select.add_option('test1', 'displayed', icon_path=icon_path) test_select.add_option('test2', 'displayed regregreg', icon_path=icon_path) test_select.add_option('test3', 'displayed fezfzefezfzef', icon_path=icon_path) | def do_destroy(self): self.unparent() if hasattr(self, '_hidder'): if self._hidder is not None: self._hidder.unparent() self._hidder.destroy() self._hidder = None if hasattr(self, '_background'): if self._background is not None: self._background.unparent() self._background.destroy() self._background = None if hasattr(s... |
self.rect.set_color(color) | if self.rect is not None: self.rect.set_color(color) | def set_inner_color(self, color): self.rect.set_color(color) |
remaining_width = inner_width - total_width - ((len(self._columns) - 1) * self._spacing.x) | remaining_width = inner_width - total_width if remaining_width > 0: col_to_expand = None auto_count = 0 for j in range(len(self._columns)): if self._columns[j] == 'auto': auto_count += 1 elif self._columns[j] == 'expand': col_to_expand = j break if col_to_expand: columns_widths[j] += remaining_width elif auto_count > ... | def do_allocate(self, box, flags): width = box.x2 - box.x1 height = box.y2 - box.y1 inner_width = width - 2*self._margin.x - 2*self._padding.x inner_height = height - 2*self._margin.y - 2*self._padding.y columns_widths = [0 for k in range(len(self._columns))] rows_heights = [0 for k in range(len(self._rows))] # find ... |
row_height = max(row_height, actor.get_preferred_height(for_width=-1)[1]) | row_height = max(row_height, actor.get_preferred_height(for_width=columns_widths[j])[1]) | def do_allocate(self, box, flags): width = box.x2 - box.x1 height = box.y2 - box.y1 inner_width = width - 2*self._margin.x - 2*self._padding.x inner_height = height - 2*self._margin.y - 2*self._padding.y columns_widths = [0 for k in range(len(self._columns))] rows_heights = [0 for k in range(len(self._rows))] # find ... |
remaining_height = inner_height - total_height - ((len(self._rows) - 1) * self._spacing.y) if remaining_width > 0: auto_count = 0 for j in range(len(self._columns)): if not isinstance(self._columns[j], int): auto_count += 1 if auto_count > 0: width_per_column = int(remaining_width / auto_count) for j in range(len(sel... | remaining_height = inner_height - total_height | def do_allocate(self, box, flags): width = box.x2 - box.x1 height = box.y2 - box.y1 inner_width = width - 2*self._margin.x - 2*self._padding.x inner_height = height - 2*self._margin.y - 2*self._padding.y columns_widths = [0 for k in range(len(self._columns))] rows_heights = [0 for k in range(len(self._rows))] # find ... |
if not isinstance(self._rows[j], int): | if self._rows[i] == 'auto': | def do_allocate(self, box, flags): width = box.x2 - box.x1 height = box.y2 - box.y1 inner_width = width - 2*self._margin.x - 2*self._padding.x inner_height = height - 2*self._margin.y - 2*self._padding.y columns_widths = [0 for k in range(len(self._columns))] rows_heights = [0 for k in range(len(self._rows))] # find ... |
rect_box.x1 = 0 rect_box.y1 = 0 rect_box.x2 = width rect_box.y2 = height | rect_box.x1 = base_x + 0 rect_box.y1 = base_y + 0 rect_box.x2 = base_x + width rect_box.y2 = base_y + height | def _allocate_rect(self, base_x, base_y, width, height, flags): rect_box = clutter.ActorBox() rect_box.x1 = 0 rect_box.y1 = 0 rect_box.x2 = width rect_box.y2 = height self.rect.allocate(rect_box, flags) |
paint_color = self._color | paint_color = self._color.copy() | def do_paint(self): (x1, y1, x2, y2) = self.get_allocation_box() |
border_color = self._border_color | border_color = self._border_color.copy() | def do_paint(self): (x1, y1, x2, y2) = self.get_allocation_box() |
self.actor.set_anchor_point(0,position) self.actor.set_clip(0,position,box_width,box_height) | self.actor.set_anchor_point(0, int(position)) self.actor.set_clip(0, int(position), box_width, box_height) | def do_allocate (self, box, flags): box_width = box.x2 - box.x1 box_height = box.y2 - box.y1 if self.expand == True: position = self.clipper_position * (self.actor.get_preferred_size()[3] - box_height) self.actor.set_anchor_point(0,position) self.actor.set_clip(0,position,box_width,box_height) objbox = clutter.ActorBo... |
children = (self.actor,) for child in children : func(child, data) | func(self.actor, data) | def do_foreach(self, func, data=None): children = (self.actor,) for child in children : func(child, data) |
children = (self.actor,) for child in children : child.paint() | self.actor.paint() | def do_paint(self): children = (self.actor,) for child in children : child.paint() |
children = (self.actor,) for child in children : child.paint() | self.actor.paint() | def do_pick(self, color): children = (self.actor,) for child in children : child.paint() |
if hasattr(self, '_default_title_actor'): | if hasattr(self, 'default_title_actor'): | def do_destroy(self): self.unparent() if hasattr(self, 'title_actor'): if self.title_actor: self.title_actor.unparent() self.title_actor.destroy() self.title_actor = None if hasattr(self, '_default_title_actor'): if self.default_title_actor: self.default_title_actor.unparent() self.default_title_actor.destroy() self.de... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.