rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.beads[bot_bead_index+i].move((0, | self.beads[bot_bead_index+i].move_relative((0, | def set_rod_value(self, r, v): """ Move beads on rod r to represent value v """ bot = v % 5 top = (v-bot)/5 top_bead_index = r*(self.top_beads+self.bot_beads) bot_bead_index = r*(self.top_beads+self.bot_beads)+self.top_beads |
rod_colors = [" " " white = _svg_header(BWIDTH, BHEIGHT, self.abacus.scale) +\ _svg_bead(" _svg_footer() black = _svg_header(BWIDTH, BHEIGHT, self.abacus.scale) +\ _svg_bead(" _svg_footer() self.white = _svg_str_to_pixbuf(white) self.black = _svg_str_to_pixbuf(black) | _white = _svg_header(BWIDTH, BHEIGHT, self.abacus.scale) +\ _svg_bead(" _svg_footer() self.white = _svg_str_to_pixbuf(_white) _black = _svg_header(BWIDTH, BHEIGHT, self.abacus.scale) +\ _svg_bead(" _svg_footer() self.black = _svg_str_to_pixbuf(_black) | def draw_rods_and_beads(self, x, y): """ Override default in order to make a short rod """ rod_colors = ["#006ffe", "#007ee7", "#0082c4", "#0089ab", "#008c8b", "#008e68", "#008e4c", "#008900", "#5e7700", "#787000", "#876a00", "#986200", "#ab5600", "#d60000", "#e30038"] |
rod = _svg_header(10, self.frame_height-(FSTROKE*2), self.abacus.scale) +\ _svg_rect(10, self.frame_height-(FSTROKE*2), 0, 0, 0, 0, rod_colors[(i+5)%len(rod_colors)], " _svg_footer() self.rods.append(Sprite(self.abacus.sprites, x+i*dx+ro, y, _svg_str_to_pixbuf(rod))) | _rod = _svg_header(10, self.frame_height-(FSTROKE*2), self.abacus.scale) +\ _svg_rect(10, self.frame_height-(FSTROKE*2), 0, 0, 0, 0, ROD_COLORS[(i+5)%len(ROD_COLORS)], " _svg_footer() self.rods.append(Sprite(self.abacus.sprites, x+i*dx+ro, y, _svg_str_to_pixbuf(_rod))) | def draw_rods_and_beads(self, x, y): """ Override default in order to make a short rod """ rod_colors = ["#006ffe", "#007ee7", "#0082c4", "#0089ab", "#008c8b", "#008e68", "#008e4c", "#008900", "#5e7700", "#787000", "#876a00", "#986200", "#ab5600", "#d60000", "#e30038"] |
if i < 100: r = i/self.bot_beads if b.state == 1: v[r+1] += 1 elif i < 104: r = 10 if b.state == 1: if count_beads: v[r+1] += 1 else: v[r+1] += 2.5 else: r = (i+6)/self.bot_beads if b.state == 1: v[r+1] += 1 | if j < i: r += 1 j += self.bead_count[r] if b.state == 1: v[r+1] += 1 | def value(self, count_beads=False): """ Override to account for fourths """ string = '' v = [] for r in range(self.num_rods+1): # +1 for overflow v.append(0) |
if v[11] == 10: v[10] += 1 else: v[12] += int(v[11]) v[13] += int(10*v[11]-10*int(v[11])) for j in range(4): if v[len(v)-j-1] > 9: v[len(v)-j-1] -= 10 if j < 3: v[len(v)-j-2] += 1 else: v[len(v)-j-3] += 1 for j in range(6,16): if v[len(v)-j-1] > 9: v[len(v)-j-1] -= 10 v[len(v)-j-2] += 1 for i, j in enumerate(v): ... | for r in range(self.num_rods): if r < 10: value += pow(10, 9-r)*v[r+1] elif r == 10: value += float(0.25*v[r+1]) else: value += float(v[r+1])/pow(10, 5-(self.num_rods-r)) string = str(int(value)) if value-int(value) > 0: string = str(value) | def value(self, count_beads=False): """ Override to account for fourths """ string = '' v = [] for r in range(self.num_rods+1): # +1 for overflow v.append(0) |
if r == 10: beads = 4 bead_index = r*(self.bot_beads) o = 8 elif r < 10: beads = 10 bead_index = r*(self.bot_beads) o = 2 else: beads = 10 bead_index = r*(self.bot_beads)-6 o = 2 | o = self.bot_beads - self.bead_count[r] + 2 beads = self.bead_count[r] bead_index = 0 if r > 0: for i in range(r): bead_index += self.bead_count[i] | def set_rod_value(self, r, v): """ Move beads on rod r to represent value v """ if r == 10: beads = 4 bead_index = r*(self.bot_beads) o = 8 elif r < 10: beads = 10 bead_index = r*(self.bot_beads) o = 2 else: beads = 10 bead_index = r*(self.bot_beads)-6 o = 2 |
self.beads[bead_index+i].move((0, o*BHEIGHT*self.abacus.scale)) | self.beads[bead_index+i].move_relative((0, o*BHEIGHT*self.abacus.scale)) | def set_rod_value(self, r, v): """ Move beads on rod r to represent value v """ if r == 10: beads = 4 bead_index = r*(self.bot_beads) o = 8 elif r < 10: beads = 10 bead_index = r*(self.bot_beads) o = 2 else: beads = 10 bead_index = r*(self.bot_beads)-6 o = 2 |
r = i/self.bot_beads if r < 10: o = 2 b = i % self.bot_beads n = self.bot_beads elif i > 99 and i < 104: o = 8 b = i % self.bot_beads n = 4 else: o = 2 b = (i+6) % self.bot_beads n = self.bot_beads | count = 0 for r in range(len(self.bead_count)): count += self.bead_count[r] if i < count: break o = self.bot_beads - self.bead_count[r] + 2 b = i - (count-self.bead_count[r]) n = self.bead_count[r] | def move_bead(self, bead, dy): """ Override to account for short rod """ i = self.beads.index(bead) r = i/self.bot_beads # Take into account the rod with just 4 beads if r < 10: o = 2 b = i % self.bot_beads n = self.bot_beads elif i > 99 and i < 104: o = 8 b = i % self.bot_beads n = 4 else: o = 2 b = (i+6) % self.bot_b... |
class Fractions(AbacusGeneric): | class Fractions(Schety): """ Inherit from Russian abacus. """ | def move_bead(self, bead, dy): """ Override to account for short rod """ i = self.beads.index(bead) r = i/self.bot_beads # Take into account the rod with just 4 beads if r < 10: o = 2 b = i % self.bot_beads n = self.bot_beads elif i > 99 and i < 104: o = 8 b = i % self.bot_beads n = 4 else: o = 2 b = (i+6) % self.bot_b... |
rod_colors = [" " " white = _svg_header(BWIDTH, BHEIGHT, self.abacus.scale) +\ | _white = _svg_header(BWIDTH, BHEIGHT, self.abacus.scale) +\ | def draw_rods_and_beads(self, x, y): """ Override default in order to make a short rod """ rod_colors = ["#006ffe", "#007ee7", "#0082c4", "#0089ab", "#008c8b", "#008e68", "#008e4c", "#008900", "#5e7700", "#787000", "#876a00", "#986200", "#ab5600", "#d60000", "#e30038"] |
self.white = _svg_str_to_pixbuf(white) | self.white = _svg_str_to_pixbuf(_white) _black = _svg_header(BWIDTH, BHEIGHT, self.abacus.scale) +\ _svg_bead(" _svg_footer() self.black = _svg_str_to_pixbuf(_black) | def draw_rods_and_beads(self, x, y): """ Override default in order to make a short rod """ rod_colors = ["#006ffe", "#007ee7", "#0082c4", "#0089ab", "#008c8b", "#008e68", "#008e4c", "#008900", "#5e7700", "#787000", "#876a00", "#986200", "#ab5600", "#d60000", "#e30038"] |
rod = _svg_header(10, self.frame_height-(FSTROKE*2), self.abacus.scale) +\ _svg_rect(10, self.frame_height-(FSTROKE*2), 0, 0, 0, 0, rod_colors[(i+9)%len(rod_colors)], " _svg_footer() self.rods.append(Sprite(self.abacus.sprites, x+i*dx+ro, y, _svg_str_to_pixbuf(rod))) | _rod = _svg_header(10, self.frame_height-(FSTROKE*2), self.abacus.scale) +\ _svg_rect(10, self.frame_height-(FSTROKE*2), 0, 0, 0, 0, ROD_COLORS[(i+9)%len(ROD_COLORS)], " _svg_footer() self.rods.append(Sprite(self.abacus.sprites, x+i*dx+ro, y, _svg_str_to_pixbuf(_rod))) | def draw_rods_and_beads(self, x, y): """ Override default in order to make a short rod """ rod_colors = ["#006ffe", "#007ee7", "#0082c4", "#0089ab", "#008c8b", "#008e68", "#008e4c", "#008900", "#5e7700", "#787000", "#876a00", "#986200", "#ab5600", "#d60000", "#e30038"] |
self.beads.append(Sprite(self.abacus.sprites, x+i*dx+bo, y+(14-self.bead_count[i]+b)*BHEIGHT*\ self.abacus.scale, self.white)) | if i < 6: self.beads.append(Sprite(self.abacus.sprites, x+i*dx+bo, y+\ (14-self.bead_count[i]+b)*BHEIGHT*\ self.abacus.scale, self.white)) else: self.beads.append(Sprite(self.abacus.sprites, x+i*dx+bo, y+\ (14-self.bead_count[i]+b)*BHEIGHT*\ self.abacus.scale, self.black)) | def draw_rods_and_beads(self, x, y): """ Override default in order to make a short rod """ rod_colors = ["#006ffe", "#007ee7", "#0082c4", "#0089ab", "#008c8b", "#008e68", "#008e4c", "#008900", "#5e7700", "#787000", "#876a00", "#986200", "#ab5600", "#d60000", "#e30038"] |
def set_rod_value(self, r, v): """ Move beads on rod r to represent value v """ o = self.bot_beads - self.bead_count[r] + 2 for i in range(beads): if self.beads[bead_index+i].state: self.beads[bead_index+i].move((0, o*BHEIGHT*self.abacus.scale)) self.beads[bead_index+i].state = 0 for i in range(v): self.beads[bead_... | def value(self, count_beads=False): """ Override to account for fractions """ string = '' v = [] value = 0 for r in range(self.num_rods+1): # +1 for overflow v.append(0) | |
v = 0 | v = [] for r in range(self.num_rods+1): v.append(0) | def value(self): # TODO: cascade and account for short rod """ Return a string with the value of each rod. """ string = '' v = 0 for i, b in enumerate(self.beads): if b.state == 1: v += 1 if i%self.bot_beads == self.bot_beads-1: if string != '' or v > 0: string += str(v) v = 0 return(string) |
if b.state == 1: v += 1 if i%self.bot_beads == self.bot_beads-1: if string != '' or v > 0: string += str(v) v = 0 | if i < 100: r = i/self.bot_beads if b.state == 1: v[r+1] += 1 elif i < 104: r = 10 if b.state == 1: v[r+1] += 2.5 else: r = (i+6)/self.bot_beads if b.state == 1: v[r+1] += 1 if v[11] == 10: v[10] += 1 else: v[12] += int(v[11]) v[13] += int(10*v[11]-10*int(v[11])) for j in range(4): if v[len(v)-j-1] > 9: v[len(v)-... | def value(self): # TODO: cascade and account for short rod """ Return a string with the value of each rod. """ string = '' v = 0 for i, b in enumerate(self.beads): if b.state == 1: v += 1 if i%self.bot_beads == self.bot_beads-1: if string != '' or v > 0: string += str(v) v = 0 return(string) |
self.beads[i+ii].set_color(self.colors[3]) | if bead.max_fade_level > 0: self.beads[i+ii].set_color(self.colors[3]) | def move_bead(self, sprite, dy): """ Move a bead (or beads) up or down a rod. """ |
self.beads[i-ii].set_color(self.colors[3]) | if bead.max_fade_level > 0: self.beads[i-ii].set_color(self.colors[3]) | def move_bead(self, sprite, dy): """ Move a bead (or beads) up or down a rod. """ |
rnd_choice= 3 | if len(males) > 0 and len(females) > 0: rnd_choice= 3 else: rnd_choice= 4 | def extract_or_create(base_set, gender, pedigree, fathers, mothers, genders): if len(base_set) == 0: ind= create_founder(gender, pedigree, fathers, mothers, genders) else: ind= base_set.pop() return ind |
father= extract_or_create(males, 1, pedigree, fathers, mothers, genders) mother= extract_or_create(females, 2, pedigree, fathers, mothers, genders) | father= last_father mother= last_mother | def extract_or_create(base_set, gender, pedigree, fathers, mothers, genders): if len(base_set) == 0: ind= create_founder(gender, pedigree, fathers, mothers, genders) else: ind= base_set.pop() return ind |
datafile = codecs.open(datapath, 'r', encoding='ascii') parse(data, datafile) | with codecs.open(datapath, 'r', encoding='ascii') as datafile: parse(data, datafile) | def read_data_from_nearby_file(data): datapath = os.path.join(os.path.dirname(__file__), 'advent.dat') datafile = codecs.open(datapath, 'r', encoding='ascii') parse(data, datafile) |
for obj2 in self.object_list: for i, r in enumerate(obj2.rooms): if r is oldroom1 or r is oldroom2: obj2.rooms[i] = newroom self.move_to() | for oldroom in (oldroom1, oldroom2): for o in self.objects_at(oldroom): o.drop(newroom) self.move_to(newroom) | def callback(yes): self.write(obj.messages[1]) obj.prop = 2 obj.is_fixed = True oldroom1 = obj.rooms[0] oldroom2 = obj.rooms[1] newroom = self.rooms[ (oldroom1.n + oldroom2.n) // 2 ] obj.drop(newroom) self.rug.prop = 0 self.rug.is_fixed = False self.rug.drop(newroom) for obj2 in self.object_list: for i, r in enumerate(... |
if re.search('^[a-z0-9-_]+$', customfield['name']) == None: | if re.search('^[a-z][a-z0-9_]+$', customfield['name']) == None: | def verify_custom_field(self, customfield, create=True): """ Basic validation of the input for modifying or creating custom fields. """ # Name, Type and Label is required if not (customfield.get('name') and customfield.get('type') \ and customfield.get('label')): raise TracError("Custom field needs at least a name, typ... |
if fnmatch(nick, s): | if fnmatch(nick, s.lower()): | def nickMatch(nick, pattern): """Checks if a given nick matches a pattern or in a list of patterns.""" if isinstance(pattern, str): pattern = [pattern] nick = nick.lower() for s in pattern: if fnmatch(nick, s): return True return False |
if (ircutils.strEqual(target, irc.nick) or 'Evilrockbot' in formatText) and random.uniform(0,100) < 25): | if (ircutils.strEqual(target, irc.nick) or 'Evilrockbot' in formatText) and random.uniform(0,100) < 25: | def lart(self, irc, msg, args, channel, id, text): """[<channel>] [<id>] <who|what> [for <reason>] |
pattern = "$".join(pattern.split('$')[:-1]) | pattern = pattern[:pattern.rfind('$')] | def hostmaskPatternEqual(pattern, hostmask): if pattern.count('!') != 1 or pattern.count('@') != 1: return False if pattern.count('$') == 1: pattern = "$".join(pattern.split('$')[:-1]) if pattern[0] == '%': pattern = pattern[1:] return ircutils.hostmaskPatternEqual(pattern, hostmask) |
user = ircdb.users.getUser(msg.prefix[:msg.prefix.find('!')].lower()) | user = ircdb.users.getUser(msg.prefix) | def check_auth(self, irc, msg, args, cap='bantracker'): hasIRCLogin = False for cb in self.callPrecedence(irc)[0]: if cb.name() == "IRCLogin": hasIRCLogin = True if hasIRCLogin and not msg.tagged('identified'): irc.error(conf.supybot.replies.incorrectAuthentication()) return False try: user = ircdb.users.getUser(msg.pr... |
self.feedBan('dude', mode='p') | self.feedBan('dude!dude@trollpit.com', mode='p') | def testComment(self): pluginConf.request.setValue(True) # test bans self.feedBan('asd!*@*') msg = self.irc.takeMsg() self.assertEqual(str(msg).strip(), "PRIVMSG op :Please comment on the ban of asd!*@* in #test, use: @comment 1" " <comment>") # test quiets self.feedBan('dude!*@*', mode='q') msg = self.irc.takeMsg() se... |
registry.String('Maveric', "Current development release")) | registry.String('Maverick', "Current development release")) | def configure(advanced): from supybot.questions import yn, something, anything, output from supybot.utils.str import format import sqlite import re Encyclopedia = conf.registerPlugin('Encyclopedia', True) enabled = yn("Enable Encyclopedia for all channels?", default=Encyclopedia.enabled._default) if advanced: datadir ... |
registry.String('Maveric Meercat', "Current development release")) | registry.String('Maverick Meerkat', "Current development release")) | def configure(advanced): from supybot.questions import yn, something, anything, output from supybot.utils.str import format import sqlite import re Encyclopedia = conf.registerPlugin('Encyclopedia', True) enabled = yn("Enable Encyclopedia for all channels?", default=Encyclopedia.enabled._default) if advanced: datadir ... |
if not msg.args[1].startswith('requested by'): | if len(msg.args) < 2 or not msg.args[1].startswith('requested by'): | def doPart(self, irc, msg): if not msg.args[1].startswith('requested by'): return |
pluginConf.commentRequest.ignore.set('*') | pluginConf.request.ignore.set('*') pluginConf.request.forward.set('') | def setUp(self): super(BantrackerTestCase, self).setUp() self.setDb() pluginConf.commentRequest.ignore.set('*') # disable comments |
pluginConf.commentRequest.ignore.set('') | pluginConf.request.ignore.set('') | def testCommentRequest(self): pluginConf.commentRequest.ignore.set('') # test bans self.feedBan('asd!*@*') msg = self.irc.takeMsg() self.assertEqual(str(msg).strip(), "PRIVMSG op :Please comment on the ban of asd!*@* in #test, use: @comment 1" " <comment>") # test quiets self.feedBan('dude!*@*', mode='q') msg = self.ir... |
def testReviewResquest(self): pluginConf.commentRequest.ignore.set('') | self.feedBan('dude', mode='k') msg = self.irc.takeMsg() self.assertEqual(str(msg).strip(), "PRIVMSG op :Please comment on the removal of dude in " <comment>") self.feedBan('dude', mode='p') msg = self.irc.takeMsg() self.assertEqual(str(msg).strip(), "PRIVMSG op :Please comment on the removal of dude in " <comment>") p... | def testCommentRequest(self): pluginConf.commentRequest.ignore.set('') # test bans self.feedBan('asd!*@*') msg = self.irc.takeMsg() self.assertEqual(str(msg).strip(), "PRIVMSG op :Please comment on the ban of asd!*@* in #test, use: @comment 1" " <comment>") # test quiets self.feedBan('dude!*@*', mode='q') msg = self.ir... |
pluginConf.reviewAfterTime.setValue(1.0/84600) | pluginConf.request.review.setValue(1.0/86400) | def testReviewResquest(self): pluginConf.commentRequest.ignore.set('') cb = self.getCallback() self.feedBan('asd!*@*') self.irc.takeMsg() # ignore comment request comment pluginConf.reviewAfterTime.setValue(1.0/84600) # one second cb.reviewBans() self.assertFalse(cb.pendingReviews) print 'waiting 4 secs..' time.sleep(2... |
def testKick(self): self.feedBan('troll', mode='k') fetch = self.query("SELECT id,channel,mask,operator FROM bans") self.assertEqual((1, ' def testPart(self): self.feedBan('troll!user@trollpit.net', mode='p') fetch = self.query("SELECT id,channel,mask,operator FROM bans") self.assertEqual((1, ' | def testQuiet(self): self.feedBan('asd!*@*', mode='q') fetch = self.query("SELECT id,channel,mask,operator FROM bans") self.assertEqual((1, '#test', '%asd!*@*', 'op'), fetch[0]) | |
if not capab(msg.prefix, 'editfactoids') and \ channel not in self.registryValue('editchannel'): | if not (capab(msg.prefix, 'editfactoids') \ or channel in self.registryValue('editchannel') \ and capab(msg.prefix, 'restricted-editor')): | def beginswith(text, strings): for string in strings: if text.startswith(string): return True return False |
queue(irc, args[0], reply) | queue(irc, msg.args[0], reply) | def real_info(self, irc, msg, args, package, release): """<package> [<release>] |
r"""\b(?P<bt>(([a-z0-9]+)?\s+bugs?|[a-z0-9]+))\s+ | r"""\b(?P<bt>(([a-z0-9]+)?\s+bugs?|[a-z0-9]+):?)\s+ | def bugSnarfer(self, irc, msg, match): r"""\b(?P<bt>(([a-z0-9]+)?\s+bugs?|[a-z0-9]+))\s+#?(?P<bug>\d+(?!\d*[\-\.]\d+)((,|\s*(and|en|et|und|ir))\s*#?\d+(?!\d*[\-\.]\d+))*)""" if msg.args[0][0] == '#' and not self.registryValue('bugSnarfer', msg.args[0]): return nbugs = msg.tagged('nbugs') if not nbugs: nbugs = 0 if nbug... |
if bugid == 1 and tracker == self.db["lp"]: irc.reply("https://bugs.launchpad.net/ubuntu/+bug/1 (Not reporting large bug)") continue | def bugSnarfer(self, irc, msg, match): r"""\b(?P<bt>(([a-z0-9]+)?\s+bugs?|[a-z0-9]+):?)\s+#?(?P<bug>\d+(?!\d*[\-\.]\d+)((,|\s*(and|en|et|und|ir))\s*#?\d+(?!\d*[\-\.]\d+))*)""" if msg.args[0][0] == '#' and not self.registryValue('bugSnarfer', msg.args[0]): return nbugs = msg.tagged('nbugs') if not nbugs: nbugs = 0 if nb... | |
statuses = ['Rejected', 'Fix Released', 'Fix Committed', 'Unconfirmed','Needs Info','Confirmed','In Progress'] severities = ['Undecided', 'Wishlist', 'Minor', 'Low', 'Normal', 'Medium', 'Major', 'High', 'Critical'] | statuses = ["Unknown", "Invalid", "Won't fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] severities = ["Unknown", "Undecided", "Wishlist", "Low", "Medium", "High", "Critical"] | def _sort(self, task1, task2): # Status sort: try: statuses = ['Rejected', 'Fix Released', 'Fix Committed', 'Unconfirmed','Needs Info','Confirmed','In Progress'] severities = ['Undecided', 'Wishlist', 'Minor', 'Low', 'Normal', 'Medium', 'Major', 'High', 'Critical'] if task1['status'] not in statuses and task2['status... |
try: | if self.lp: return self.get_bug_new(id) return self.get_bug_old(id) def get_bug_new(self, id): def _sort(task1, task2): statuses = ["Unknown", "Invalid", "Won't fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] severities = ["Unknown", "Undecided", "Wishlist", "Low", "M... | def get_bug(self, id): try: |
if pattern.count('!') not in (1, 2) or pattern.count('@') != 1: | if pattern.count('!') != 1 or pattern.count('@') != 1: | def hostmaskPatternEqual(pattern, hostmask): if pattern.count('!') not in (1, 2) or pattern.count('@') != 1: return False if pattern.count('!') == 2: pattern = "!".join(pattern.split('!')[:-1]) if pattern[0] == '%': pattern = pattern[1:] return ircutils.hostmaskPatternEqual(pattern, hostmask) |
if pattern.count('!') == 2: pattern = "!".join(pattern.split('!')[:-1]) | if pattern.count('$') == 1: pattern = "$".join(pattern.split('$')[:-1]) | def hostmaskPatternEqual(pattern, hostmask): if pattern.count('!') not in (1, 2) or pattern.count('@') != 1: return False if pattern.count('!') == 2: pattern = "!".join(pattern.split('!')[:-1]) if pattern[0] == '%': pattern = pattern[1:] return ircutils.hostmaskPatternEqual(pattern, hostmask) |
self.doKickban(irc, channel, args[2], msg.prefix, ' '.join(args[3:]).strip(), extra_comment=msg.prefix) | self.doKickban(irc, channel, args[2], msg.nick, ' '.join(args[3:]).strip(), extra_comment=msg.prefix) | def doPart(self, irc, msg): for channel in msg.args[0].split(','): self.doLog(irc, channel, '*** %s (%s) has left %s (%s)\n' % (msg.nick, msg.prefix, channel, len(msg.args) > 1 and msg.args[1] or '')) if len(msg.args) > 1 and msg.args[1].startswith('requested by'): args = msg.args[1].split() self.doKickban(irc, channel... |
statuses = ["Unknown", "Invalid", "Won't fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] | statuses = ["Unknown", "Invalid", "Won't Fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] | def _sort(self, task1, task2): # Status sort: try: statuses = ["Unknown", "Invalid", "Won't fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] severities = ["Unknown", "Undecided", "Wishlist", "Low", "Medium", "High", "Critical"] if task1['status'] not in statuses and tas... |
statuses = ["Unknown", "Invalid", "Won't fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] | statuses = ["Unknown", "Invalid", "Won't Fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] | def _sort(task1, task2): statuses = ["Unknown", "Invalid", "Won't fix", "Fix Released", "Fix Committed", "New", "Incomplete", "Confirmed", "Triaged", "In Progress"] severities = ["Unknown", "Undecided", "Wishlist", "Low", "Medium", "High", "Critical"] task1_status = task1.status task1_importance = task1.importance task... |
n = 0 | def _banreviewfix(self): # FIXME workaround until proper fix is done. bag = set() nodups = set() n = 0 for host, reviews in self.pendingReviews.iteritems(): n += len(reviews) for nick, msg in reviews: if nick == 'Automated-Addition': continue chan, m = msg.args[0], msg.args[1] s = m.rpartition(' ')[0] #remove the url i... | |
n += len(reviews) | def _banreviewfix(self): # FIXME workaround until proper fix is done. bag = set() nodups = set() n = 0 for host, reviews in self.pendingReviews.iteritems(): n += len(reviews) for nick, msg in reviews: if nick == 'Automated-Addition': continue chan, m = msg.args[0], msg.args[1] s = m.rpartition(' ')[0] #remove the url i... | |
self.setDb() | def setUp(self): super(BantrackerTestCase, self).setUp() pluginConf.request.setValue(False) # disable comments pluginConf.request.ignore.set('') pluginConf.request.forward.set('') pluginConf.request.review.setValue(1.0/86400) # one second self.setDb() # Bantracker for some reason doesn't use Supybot's own methods for c... | |
n_tries = 0 | def db_run(self, query, parms, expect_result = False, expect_id = False): if not self.db: self.log.error("Bantracker database not open") return n_tries = 0 try: cur = self.db.cursor() cur.execute(query, parms) except: cur = None if n_tries > 5: print "Tried more than 5 times, aborting" raise n_tries += 1 time.sleep(1) ... | |
cur = None if n_tries > 5: print "Tried more than 5 times, aborting" raise n_tries += 1 time.sleep(1) | self.log.error("Error while trying to access the Bantracker database.") return None | def db_run(self, query, parms, expect_result = False, expect_id = False): if not self.db: self.log.error("Bantracker database not open") return n_tries = 0 try: cur = self.db.cursor() cur.execute(query, parms) except: cur = None if n_tries > 5: print "Tried more than 5 times, aborting" raise n_tries += 1 time.sleep(1) ... |
if user if not channel and text[0] == self.registryValue("prefixchar") | if user: if not channel and text[0] == self.registryValue("prefixchar"): | def inFilter(self, irc, msg): if msg.command != "PRIVMSG": return msg if not conf.supybot.defaultIgnore(): return msg text = msg.args[1].strip() if len(text) < 6: return msg user = get_user(msg) channel = self.__getChannel(msg.args[0]) reply_chars = tuple([self.registryValue("prefixchar", channel)] + list(conf.supybot.... |
if user and text[0] in str(conf.supybot.reply.whenAddressedBy.get('chars')): | if user and text[0] in list(conf.supybot.reply.whenAddressedBy.chars()): | def privmsg(self, irc, msg, user): channel = self.__getChannel(msg.args[0]) text = self.space_re.subn(' ', msg.args[1].strip())[0] if text[0] == self.registryValue("prefixchar"): text = text[1:].strip() if user and text[0] in str(conf.supybot.reply.whenAddressedBy.get('chars')): return (cmd, rest) = (text.split(' ', 1)... |
if cmd not in ("find", "info"): | if cmd not in my_commands: | def privmsg(self, irc, msg, user): channel = self.__getChannel(msg.args[0]) text = self.space_re.subn(' ', msg.args[1].strip())[0] if text[0] == self.registryValue("prefixchar"): text = text[1:].strip() if user and text[0] in str(conf.supybot.reply.whenAddressedBy.get('chars')): return (cmd, rest) = (text.split(' ', 1)... |
if cmd not in ("find", "info"): | if cmd not in my_commands: | def chanmsg(self, irc, msg, user): channel = self.__getChannel(msg.args[0]) text = self.space_re.subn(' ', msg.args[1].strip())[0] if text[0] != self.registryValue("prefixchar", channel): return text = text[1:] (cmd, rest) = (text.split(' ', 1) + [None])[:2] if cmd not in ("find", "info"): return if not rest: return (t... |
if user: return msg channel = self.__getChannel(msg.args[0]) | channel = self.__getChannel(msg.args[0]) reply_chars = tuple([self.registryValue("prefixchar", channel)] + list(conf.supybot.reply.whenAddressedBy.chars.get(channel))) my_commands = self.listCommands() if user if not channel and text[0] == self.registryValue("prefixchar") msg.args = (msg.args[0], text[1:]) return msg | def inFilter(self, irc, msg): if msg.command != "PRIVMSG": return msg if not conf.supybot.defaultIgnore(): return msg text = msg.args[1].strip() if len(text) < 6: return msg user = get_user(msg) if user: return msg channel = self.__getChannel(msg.args[0]) if channel: if text[0] not in ('!', '@'): return msg if not text... |
if text[0] not in ('!', '@'): | if text[0] not in reply_chars: | def inFilter(self, irc, msg): if msg.command != "PRIVMSG": return msg if not conf.supybot.defaultIgnore(): return msg text = msg.args[1].strip() if len(text) < 6: return msg user = get_user(msg) if user: return msg channel = self.__getChannel(msg.args[0]) if channel: if text[0] not in ('!', '@'): return msg if not text... |
if not text[1:5] in ("info", "find"): | if not text[1:5] in my_commands: | def inFilter(self, irc, msg): if msg.command != "PRIVMSG": return msg if not conf.supybot.defaultIgnore(): return msg text = msg.args[1].strip() if len(text) < 6: return msg user = get_user(msg) if user: return msg channel = self.__getChannel(msg.args[0]) if channel: if text[0] not in ('!', '@'): return msg if not text... |
if text[1] in ('!', '@'): if text[1:5] in ("info", "find"): | if text[1] in reply_chars: if text[1:5] in my_commands: | def inFilter(self, irc, msg): if msg.command != "PRIVMSG": return msg if not conf.supybot.defaultIgnore(): return msg text = msg.args[1].strip() if len(text) < 6: return msg user = get_user(msg) if user: return msg channel = self.__getChannel(msg.args[0]) if channel: if text[0] not in ('!', '@'): return msg if not text... |
elif text[:4] in ("info", "find"): | elif text[:4] in my_commands: | def inFilter(self, irc, msg): if msg.command != "PRIVMSG": return msg if not conf.supybot.defaultIgnore(): return msg text = msg.args[1].strip() if len(text) < 6: return msg user = get_user(msg) if user: return msg channel = self.__getChannel(msg.args[0]) if channel: if text[0] not in ('!', '@'): return msg if not text... |
self.log.debug('Except: %s' %e) | import traceback self.log.error('Except: %s' %e) self.log.error(traceback.format_exc()) | def reviewBans(self): try: reviewAfterTime = int(self.registryValue('reviewAfterTime') * 84600) if not reviewAfterTime: # time is zero, do nothing return self.log.debug('Checking for bans that need review ...') now = time.mktime(time.gmtime()) lastreview = self.registryValue('reviewTime') if not lastreview: # initializ... |
data = self.db_run("SELECT MAX(id) FROM bans WHERE mask=%s AND channel=%s", (mask, channel), True)[0] if not data[0]: | data = self.db_run("SELECT MAX(id) FROM bans WHERE mask=%s AND channel=%s", (mask, channel), True) if data: data = data[0] if not data or not data[0]: | def get_banId(self, mask, channel): data = self.db_run("SELECT MAX(id) FROM bans WHERE mask=%s AND channel=%s", (mask, channel), True)[0] if not data[0]: return return int(data[0]) |
supylog.error("Error accessing Launchapd API") | supylog.error("Error accessing Launchpad API") | def __init__(self, *args, **kwargs): IBugtracker.__init__(self, *args, **kwargs) self.lp = None |
aptdir = supybot.directories.data.dirize('aptdir') | aptdir = conf.supybot.directories.data.dirize('aptdir') | def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default) |
name=self.name) | name=self.name()) | def __init__(self, irc): self.__parent = super(Bantracker, self) self.__parent.__init__(irc) self.default_irc = irc self.lastMsgs = {} self.lastStates = {} self.replies = {} self.logs = {} self.nicks = {} self.hosts = {} self.bans = {} |
schedule.removeEvent(self.name) | schedule.removeEvent(self.name()) | def die(self): global queue if self.db: try: self.db.close() except: pass try: self.thread_timer.cancel() except: pass queue.clear() try: schedule.removeEvent(self.name) except: pass |
if nickMatch(op, self.registryValue('commentRequest.ignore'): | if nickMatch(op, self.registryValue('commentRequest.ignore')): | def reviewBans(self): try: self.log.debug('Checking for bans that need review ...') now = time.mktime(time.gmtime()) lastreview = self.registryValue('reviewTime') reviewAfterTime = self.registryValue('reviewAfterTime') * 60 # time in mins if not lastreview: # initialize last time reviewed timestamp lastreview = now - r... |
if not distro: distro = chkdistro | def info(self, pkg, chkdistro): if not pkg.strip(): return '' _pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-_+']) if len(pkg.strip().split()) > 1: distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum() or x in '-._+']) if not distro: distro = chkdistro if distro not... | |
return [i[0] for i in data if i[1] == None and "!" in i[0]] | L = [] for mask, removal in data: if removal is not None: continue elif not isUserHostmask(mask) and mask[0] != '$': continue L.append(mask) return L | def getBans(chan): data = self.db_run("SELECT mask, removal FROM bans WHERE channel=%s", chan, expect_result=True) return [i[0] for i in data if i[1] == None and "!" in i[0]] |
if self.alert and target[0] == ' | if self.alert and (target[0] == ' | def beginswith(text, strings): for string in strings: if text.startswith(string): return True return False |
pattern = pattern[:pattern.rfind('$')] if pattern[0] == '%': | pattern = pattern.split('$',1)[0] if pattern.startswith('%'): | def hostmaskPatternEqual(pattern, hostmask): if pattern.count('!') != 1 or pattern.count('@') != 1: return False if pattern.count('$') == 1: pattern = pattern[:pattern.rfind('$')] if pattern[0] == '%': pattern = pattern[1:] return ircutils.hostmaskPatternEqual(pattern, hostmask) |
self.director = gutils.trim(self.page, '<BR>Re\xbfyseria: ', '<BR>') if string.find(self.director, '-->') <> -1: self.director = gutils.after(self.director, '-->') self.director = gutils.before(self.director,"<!--") else: self.director = gutils.after(self.director, '<B>') self.director = gutils.before(self.d... | self.director = gutils.trim(self.page, u'<BR>Reżyseria: ', '<BR>') def get_screenplay(self): self.screenplay = gutils.trim(self.page, u'<BR>Scenariusz: ', 'więcej') | def get_director(self): self.director = gutils.trim(self.page, '<BR>Re\xbfyseria: ', '<BR>') if string.find(self.director, '-->') <> -1: self.director = gutils.after(self.director, '-->') self.director = gutils.before(self.director,"<!--") else: self.director = gutils.after(self.director, '<B>') self.directo... |
pos = string.find(self.page, '<TD class=tym>') if pos > 0: self.plot = self.page[pos:] self.plot = gutils.trim(self.plot, '<BR><DIV class=a2>', '</DIV>') return pos = string.find(self.page, '>Recenzje</font> ') if pos > 0: self.plot = self.page[pos:] self.plot = gutils.trim(self.plot, '<td class=a1 colspan=3>', '<... | self.plot = gutils.trim(self.page, u'class=tym>Treść', '</div><BR><TABLE') | def get_plot(self): pos = string.find(self.page, '<TD class=tym>') if pos > 0: self.plot = self.page[pos:] self.plot = gutils.trim(self.plot, '<BR><DIV class=a2>', '</DIV>') return pos = string.find(self.page, '>Recenzje</font> ') if pos > 0: self.plot = self.page[pos:] self.plot = gutils.trim(self.plot, '<td clas... |
self.rating = gutils.trim(self.page, '>Ocena filmu</TD>', 'g\xb3os\xf3w)') | self.rating = gutils.trim(self.page, '>Ocena filmu</TD>', 'głosów)') | def get_rating(self): self.rating = gutils.trim(self.page, '>Ocena filmu</TD>', 'g\xb3os\xf3w)') self.rating = gutils.after(self.rating, '<BR><B>') self.rating = gutils.before(self.rating, '/5</B>') if self.rating != '': self.rating = str( float(self.rating)*2 ) |
w['volume'].set_active(0) | w['collection'].set_active(0) | def set_details(self, item=None):#{{{ if item is None: item = {} if 'movie_id' in item and item['movie_id']: self._am_movie_id = item['movie_id'] else: self._am_movie_id = None w = self.widgets['add'] cast_buffer = w['cast'].get_buffer() notes_buffer = w['notes'].get_buffer() plot_buffer = w['plot'].get_buffer() if... |
'[0-9 ]+Views', '', re.sub( '[]', '-', | u'[]', '-', | def get_plot(self): self.plot = re.sub( '[0-9 ]+Views', '', re.sub( '[]', '-', re.sub( '[\x93]', '"', gutils.regextrim(self.page, 'showcover.php[^>]*>', '</td>')))) |
'[\x93]', '"', gutils.regextrim(self.page, 'showcover.php[^>]*>', '</td>')))) | u'[\x93]', '"', gutils.regextrim(self.page, '[0-9 ]+Views', '</td>'))) | def get_plot(self): self.plot = re.sub( '[0-9 ]+Views', '', re.sub( '[]', '-', re.sub( '[\x93]', '"', gutils.regextrim(self.page, 'showcover.php[^>]*>', '</td>')))) |
suspension_deflect = None steer = None x_force = None y_force = None vertical_load = None angular_velocity = None lean = None air_temp = None slip_fraction = None | def __str__(self): ''' Returns: A string representation of this lfs.StaticWheelInfo instance. ''' return self.__dict__.__str__() | |
def __str__(self): | def __repr__(self): | def __str__(self): ''' Returns: A string representation of this lfs.DynamicWheelInfo instance. ''' return self.__dict__.__str__() |
throttle = None brake = None input_steer = None clutch = None handbrake = None gear = None lateral_g = None forward_g = None upwards_g = None speed = None car_distance = None position_x = None position_y = None position_z = None engine_speed = None index_distance = None rx = None ry = None rz = None fx = None fy = None... | def __str__(self): ''' Returns: A string representation of this lfs.DynamicWheelInfo instance. ''' return self.__dict__.__str__() | |
def __str__(self): | def __repr__(self): | def __str__(self): '''Returns: A string representation of this lfs.DataBlock instance. ''' return self.__dict__.__str__() |
raf_version = None lfs_version = None update_interval = None short_track_name = None track_ruler_length = None player = None car = None track = None config = None weather = None player_flags = None num_wheels = None hlvc_legal = None num_splits = None splits = [] mass = None sprung_mass = None antiroll_rear = None anti... | def __str__(self): '''Returns: A string representation of this lfs.DataBlock instance. ''' return self.__dict__.__str__() | |
''' | ''' self.raf_version = None self.lfs_version = None self.update_interval = None self.short_track_name = None self.track_ruler_length = None self.player = None self.car = None self.track = None self.config = None self.weather = None self.player_flags = None self.num_wheels = None self.hlvc_legal = None self.num_splits =... | def __init__(self, path=None, **kwargs): '''Creates an instance of lfs.Replay. This constructor basically provides an alternative to calling lfs.Replay.from_file() with an open instance of file. Args: path The path to the Live For Speed RAF file to open. ''' if path: with open(path, 'rb') as f: self.__dict__.update(R... |
def __str__(self): | def __repr__(self): | def __str__(self): ''' Returns: A string representation of this lfs.Replay instance. ''' return '%s %s %s %s' % (self.player, self.car, self.track, self.config) |
return __wrapper | from sqlite3 import connect from tinu import load_using_args, Backend | def __wrapper(*args, **kwargs): raise NotImplementedError("Function %s is virtual" % func.__name__) |
def is_prefix(str, prefix, sep = '.'): if len(str) <= len(prefix): return False | from time import time | def is_prefix(str, prefix, sep = '.'): if len(str) <= len(prefix): return False return str[len(prefix)] == sep and str[:len(prefix)] == prefix |
return str[len(prefix)] == sep and str[:len(prefix)] == prefix | scripts = { 'tinu_run_versions' : '''CREATE TABLE tinu_run_versions ( id INTEGER PRIMARY KEY AUTOINCREMENT, create_time INTEGER )''', 'tinu_summary' : '''CREATE TABLE tinu_summary ( run_id INTEGER REFERENCES tinu_run_versions(id) ON DELETE CASCADE, passed INTEGER, failed INTEGER, segfault INTEGER )''', 'tinu_messages' ... | def is_prefix(str, prefix, sep = '.'): if len(str) <= len(prefix): return False return str[len(prefix)] == sep and str[:len(prefix)] == prefix |
class Summary(object): def __init__(self): self.passed = 0 self.failed = 0 self.segfault = 0 | class SqliteBackend(Backend): def __init__(self, db_name): self.db = None self.__check_database(db_name) | def is_prefix(str, prefix, sep = '.'): if len(str) <= len(prefix): return False return str[len(prefix)] == sep and str[:len(prefix)] == prefix |
def parse_item(self, key, value): if key == 'passed': self.passed = int(value) | self.run_id = self.__get_last_id('tinu_run_versions') | def parse_item(self, key, value): if key == 'passed': self.passed = int(value) |
elif key == 'failed': self.failed = int(value) | def __check_database(self, db_name): global scripts | def parse_item(self, key, value): if key == 'passed': self.passed = int(value) |
else: self.segfault = int(value) | self.db = connect(db_name) | def parse_item(self, key, value): if key == 'passed': self.passed = int(value) |
def load_backend(self, backend): self.passed, self.failed, self.segfault = backend.load_summary() | master = self.db.cursor() master.execute('SELECT * FROM sqlite_master') | def load_backend(self, backend): self.passed, self.failed, self.segfault = backend.load_summary() |
class Message(object): def __init__(self): self.msgcount = {} | found = [] missing = scripts.keys() for type, name, tbl_name, rootpage, sql in master: if not scripts.has_key(name): continue | def load_backend(self, backend): self.passed, self.failed, self.segfault = backend.load_summary() |
def parse_item(self, key, value): self.msgcount[key] = int(value) | del missing[missing.index(name)] | def parse_item(self, key, value): self.msgcount[key] = int(value) |
def __getitem__(self, key): return self.msgcount[key] | if sql != scripts[name]: raise Exception("Invalid sql file") | def __getitem__(self, key): return self.msgcount[key] |
def load_backend(self, backend): self.msgcount = backend.load_message_counts() | for name in missing: self.db.executescript(scripts[name] + ';') | def load_backend(self, backend): self.msgcount = backend.load_message_counts() |
class Asserts(object): def __init__(self): self.total = 0 self.passed = 0 | def __get_last_id(self, seq): cur = self.db.cursor() cur.execute('SELECT seq - 1 AS id FROM sqlite_sequence WHERE name = ?', (seq, )) res = cur.fetchone() if res is None: return None return res[0] | def load_backend(self, backend): self.msgcount = backend.load_message_counts() |
def parse_item(self, key, value): if key == 'passed': self.passed = int(value) | def __create_run_id(self): self.db.execute('INSERT INTO tinu_run_versions (create_time) VALUES (?)', (int(time()), )) self.run_id = self.__get_last_id('tinu_run_versions') | def parse_item(self, key, value): if key == 'passed': self.passed = int(value) |
else: self.total = int(value) | def set_id(self, id): self.run_id = id | def parse_item(self, key, value): if key == 'passed': self.passed = int(value) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.