rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return timedelta(0) | return datetime.timedelta(0) | def dst(self, dt): return timedelta(0) |
print ' ' + content_type | def _convert_to_mbox_msg(self, msg): file_ids = list(msg.objectIds('File')) encoding = "utf-8" | |
subject = decode_header(header.get('subject')) | subject = header.get("subject") try: subject = decode_header(subject) except UnicodeDecodeError: subject = subject.decode("utf-8", 'replace') | def _get_pending_list(self, pending_list): list_out = [] for user_email in pending_list.get_user_emails(): posts = pending_list.get_posts(user_email) user_name = pending_list.get_user_name(user_email) + ' <' + user_email + '>' for post in posts: header = post['header'] body = post['body'] subject = decode_header(header... |
>>> cons = DigestConstructor(mail_list) | >>> mail_list = mail_list.__of__(self.portal) >>> cons = DigestConstructor(mail_list.__of__(self.portal)) | def consume_digest(self): digest = list(self.digest) del self.digest[:] return digest |
DUMMY DIGEST FOR ... Messages in this digest:... | ...DUMMY DIGEST FOR ... ...Messages in this digest:... | def consume_digest(self): digest = list(self.digest) del self.digest[:] return digest |
<html>... | <html... | def consume_digest(self): digest = list(self.digest) del self.digest[:] return digest |
table)) | self.getDBTablePrefix() + table)) | def saveTable(self, table, outfile): """Dump a table from the current DB with mysqldump, save to a gzipped sql file.""" command = "mysqldump -h %s -u %s %s --extended-insert --skip-opt --quick --create-options --add-drop-table --extended-insert --set-charset --quote-names %s %s | gzip" % shellEscape(( self.dbServer, ... |
flaggedRevsFile = conf.get("wiki", "flaggedrevs") | flaggedRevsFile = conf.get("wiki", "flaggedrevslist") | def __init__(self): home = os.path.dirname(sys.argv[0]) files = [ os.path.join(home, "wikidump.conf"), "/etc/wikidump.conf", os.path.join(os.getenv("HOME"), ".wikidump.conf")] defaults = { #"wiki": { "dblist": "", "privatelist": "", "biglist": "", "dir": "", "forcenormal": "0", "halt": "0", #"output": { "public": "/dum... |
retrn self.dbName in self.config.flaggedRevsList | return self.dbName in self.config.flaggedRevsList | def hasFlaggedRevs(self): retrn self.dbName in self.config.flaggedRevsList |
PublicTable( "flaggedpages", "This contains a row for each flagged article, containing the stable revision ID, if the lastest edit was flagged, and how long edits have been pending." ), | PublicTable( "flaggedpages", "This contains a row for each flagged article, containing the stable revision ID, if the lastest edit was flagged, and how long edits have been pending." )) self.items.append( | def run(self): self.makeDir(join(self.wiki.publicDir(), self.date)) self.makeDir(join(self.wiki.privateDir(), self.date)) self.status("Cleaning up old dumps for %s" % self.dbName) self.cleanOldDumps() self.status("Starting backup of %s" % self.dbName) self.selectDatabaseServer() self.items = [PrivateTable("user", "U... |
readme = readme.replace('example.png', 'http://packages.python.org/imgdiff/example.png') | readme = readme.replace('.. figure:: ', '.. figure:: http://packages.python.org/imgdiff/') | def get_description(): readme = read('README.txt') readme = readme.replace('example.png', 'http://packages.python.org/imgdiff/example.png') changelog = read('CHANGES.txt') return readme + '\n\n\n' + changelog |
mask1 = Image.new('L', img1.size) mask2 = Image.new('L', img2.size) | mask1 = Image.new('L', img1.size, opts.opacity) mask2 = Image.new('L', img2.size, opts.opacity) | def simple_highlight(img1, img2, opts): """Try to align the two images to minimize pixel differences. Produces two masks for img1 and img2. """ diff, ((x1, y1), (x2, y2)) = best_diff(img1, img2) diff = tweak_diff(diff, opts.opacity) diff = diff.filter(ImageFilter.MaxFilter(9)) mask1 = Image.new('L', img1.size) mask2 =... |
w, h = min(w1, w2), min(h1, h2) diff, ((x1, y1), (x2, y2)) = best_diff(img1, img2) diff = diff.point(lambda i: 64 + i * 2 // 3) diff = diff.filter(ImageFilter.MaxFilter(9)) mask1 = Image.new('L', img1.size) mask2 = Image.new('L', img2.size) mask1.paste(diff, (x1, y1)) mask2.paste(diff, (x2, y2)) img.paste(img1, pos1, m... | diff1, diff2 = best_diff(img1, img2, bgcolor) img.paste(img1, pos1, diff1) img.paste(img2, pos2, diff2) | def main(): parser = optparse.OptionParser('%prog image1 image2', description='Compare two images side-by-side') parser.add_option('-o', dest='outfile', help='write the combined image to a file' ' instead of showing it') parser.add_option('--viewer', default='builtin', help='use an external program to view an image' ' ... |
img.paste(img1, pos1, img1) img.paste(img2, pos2, img2) | img.paste(img1, pos1) img.paste(img2, pos2) | def main(): parser = optparse.OptionParser('%prog image1 image2', description='Compare two images side-by-side') parser.add_option('-o', dest='outfile', help='write the combined image to a file' ' instead of showing it') parser.add_option('--viewer', default='builtin', help='use an external program to view an image' ' ... |
def best_diff(img1, img2): | def best_diff(img1, img2, bgcolor): | def best_diff(img1, img2): w1, h1 = img1.size w2, h2 = img2.size w, h = min(w1, w2), min(h1, h2) best = None best_value = 255 * w * h + 1 for x in range(abs(w1 - w2) + 1): if w1 > w2: x1, x2 = x, 0 else: x1, x2 = 0, x for y in range(abs(h1 - h2) + 1): if h1 > h2: y1, y2 = y, 0 else: y1, y2 = 0, y this = diff(img1, img2... |
w, h = min(w1, w2), min(h1, h2) best = None best_value = 255 * w * h + 1 for x in range(abs(w1 - w2) + 1): | W, H = max(w1, w2), max(h1, h2) pimg1 = Image.new('RGB', (W, H), bgcolor) pimg2 = Image.new('RGB', (W, H), bgcolor) pimg1.paste(img1, (0, 0)) pimg2.paste(img2, (0, 0)) diff = Image.new('L', (W, H), 255) xr = abs(w1 - w2) + 1 yr = abs(h1 - h2) + 1 for x in range(xr): for y in range(yr): this = ImageChops.difference... | def best_diff(img1, img2): w1, h1 = img1.size w2, h2 = img2.size w, h = min(w1, w2), min(h1, h2) best = None best_value = 255 * w * h + 1 for x in range(abs(w1 - w2) + 1): if w1 > w2: x1, x2 = x, 0 else: x1, x2 = 0, x for y in range(abs(h1 - h2) + 1): if h1 > h2: y1, y2 = y, 0 else: y1, y2 = 0, y this = diff(img1, img2... |
x1, x2 = x, 0 | pimg2 = ImageChops.offset(pimg2, 1, 0) | def best_diff(img1, img2): w1, h1 = img1.size w2, h2 = img2.size w, h = min(w1, w2), min(h1, h2) best = None best_value = 255 * w * h + 1 for x in range(abs(w1 - w2) + 1): if w1 > w2: x1, x2 = x, 0 else: x1, x2 = 0, x for y in range(abs(h1 - h2) + 1): if h1 > h2: y1, y2 = y, 0 else: y1, y2 = 0, y this = diff(img1, img2... |
x1, x2 = 0, x for y in range(abs(h1 - h2) + 1): if h1 > h2: y1, y2 = y, 0 else: y1, y2 = 0, y this = diff(img1, img2, (x1, y1), (x2, y2)) this_value = diff_badness(this) if this_value < best_value: best = this best_value = this_value best_pos = (x1, y1), (x2, y2) return best, best_pos | pimg1 = ImageChops.offset(pimg1, 1, 0) diff1 = diff.crop((0, 0, w1, h1)) diff2 = diff.crop((0, 0, w2, h2)) return tweak_diff(diff1), tweak_diff(diff2) | def best_diff(img1, img2): w1, h1 = img1.size w2, h2 = img2.size w, h = min(w1, w2), min(h1, h2) best = None best_value = 255 * w * h + 1 for x in range(abs(w1 - w2) + 1): if w1 > w2: x1, x2 = x, 0 else: x1, x2 = 0, x for y in range(abs(h1 - h2) + 1): if h1 > h2: y1, y2 = y, 0 else: y1, y2 = 0, y this = diff(img1, img2... |
def escape(code): if code == u">": return ">" elif code == u"<": return "<" else: return code.encode("UTF-8") | def tochar(number): s = chr(int(number[2:], 16))+chr(int(number[:2], 16)) return s.decode('UTF-16') | |
f.write("\t<accent base=\"%s\" accent=\"%s\" char=\"%s\" />\n" % (escape(base), escape(accent), escape(char))) | f.write("\t<accent base=%s accent=%s char=%s />\n" % (q(base), q(accent), q(char))) | def write_accent(f, s): try: char = s.split(';')[0] if len(char) > 4: return try: char = tochar(char) except UnicodeError: return accent = unicodedata.decomposition(char) if len(accent) != 9: return base, accent = accent.split(' ') bases = find_chars(tochar(base)) accents = find_accents(tochar(accent)) for base in ba... |
os.chdir(self.subdir) | def _compile_latex(self): os.chdir(self.subdir) o = Popen(self.LATEX_CMD_P % self.name, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) outdata, errdata = o.communicate() returncode = o.wait() assert returncode == 0 | |
def _check_result(self): | def _get_result(self): | def _check_result(self): return self.output |
return self._check_result() | return self._get_result() | def __call__(self): try: self._make_source() self._compile_latex() self._compile_lxir() return self._check_result() finally: self._cleanup() |
def _check_result(self): | IMAGE_CMD_LIST = [ "dvips -q {0} -o {0}.ps", "ps2eps -P -l -H -f -q {0}.ps", "gs -dEPSCrop -dSAFER -dBATCH -dNOPAUSE -r250 -sDEVICE=pngalpha -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=../{0}.png {0}.eps" ] def __init__(self, name, src): Test.__init__(self, name, src) self.compile_image = False def _compile_im... | def _check_result(self): doc = NonvalidatingReader.parseString(self.output, self.URI_P % self.name) ctxt = Context(doc, processorNss=NSS) nodes = Evaluate("//mml:math", context=ctxt) assert len(nodes) == 1 node = nodes[0] node.removeAttributeNS(None, u'begin-id') node.removeAttributeNS(None, u'end-id') o = StringIO.Str... |
o.write("\\RequirePackage{lxir}") | o.write("\\RequirePackage{lxir}\n") | def genLaTeXSource(self, formula, file, lxir): o = open(file, "w") if lxir: o.write("\\RequirePackage{lxir}") o.write("\\documentclass" + self.className + "\n") for symbol in self.symbols: o.write("\\usepackage{" + symbol + "}\n") if symbol == "amsmath" and not lxir: o.write("""%% The following force equation numbers N... |
return formula | return formula, label | def _makeMathML(self, formula): prefix = os.path.join(self.base_path, "img" + str(self.index) + "_lxir") remove(prefix + ".tex", True) remove(prefix + ".aux", True) remove(prefix + ".log", True) remove(prefix + ".dvi", True) remove(prefix + ".xhtml", True) self.genLaTeXSource(formula, prefix + ".tex", True) self.system... |
self.images[formula] = False | self.images[formula] = None | def makeImage(self, formula): if not self.images.has_key(formula): try: img = self._makeImage(formula) self.images[formula] = relativePath(self.base_path, img) except: print "Generation of Image for formula '%s' failed: %s" % (self.index, traceback.format_exc()) self.images[formula] = False try: self.mathml[formula] = ... |
self.mathml[formula] = self._makeMathML(formula) | mathml, label = self._makeMathML(formula) self.mathml[formula] = mathml self.labels[formula] = label | def makeImage(self, formula): if not self.images.has_key(formula): try: img = self._makeImage(formula) self.images[formula] = relativePath(self.base_path, img) except: print "Generation of Image for formula '%s' failed: %s" % (self.index, traceback.format_exc()) self.images[formula] = False try: self.mathml[formula] = ... |
self.mathml[formula] = False | self.mathml[formula] = None self.labels[formula] = None | def makeImage(self, formula): if not self.images.has_key(formula): try: img = self._makeImage(formula) self.images[formula] = relativePath(self.base_path, img) except: print "Generation of Image for formula '%s' failed: %s" % (self.index, traceback.format_exc()) self.images[formula] = False try: self.mathml[formula] = ... |
return self.images[formula], self.mathml[formula] | return self.images[formula], self.mathml[formula], self.labels[formula] | def makeImage(self, formula): if not self.images.has_key(formula): try: img = self._makeImage(formula) self.images[formula] = relativePath(self.base_path, img) except: print "Generation of Image for formula '%s' failed: %s" % (self.index, traceback.format_exc()) self.images[formula] = False try: self.mathml[formula] = ... |
image, mathml = None, None | image, mathml, label = None, None, None | def insert_math_images(file): file = os.path.abspath(file) doc = NonvalidatingReader.parseUri(file) ctxt = Context(doc, processorNss=NSS) # Check that verbatim math is used for node in Evaluate("//xhtml:span[@class='verbatimmath']/@lxir:value", context=ctxt): verbatimmath = node.value assert verbatimmath == u'true', "... |
image, mathml = gen.makeImage(formula) | image, mathml, label = gen.makeImage(formula) | def insert_math_images(file): file = os.path.abspath(file) doc = NonvalidatingReader.parseUri(file) ctxt = Context(doc, processorNss=NSS) # Check that verbatim math is used for node in Evaluate("//xhtml:span[@class='verbatimmath']/@lxir:value", context=ctxt): verbatimmath = node.value assert verbatimmath == u'true', "... |
poster = thread.xpath('//dt[contains(@class, op)]//text()')[0] | poster = thread.xpath('//dt[contains(@class, author)]//text()')[0] | def forum_link(inp, bot=None): if 'sa_user' not in bot.config or \ 'sa_password' not in bot.config: return login(bot.config['sa_user'], bot.config['sa_password']) thread = http.get_html(showthread, threadid=inp.group(1), perpage='1', cookies=True) breadcrumbs = thread.xpath('//div[@class="breadcrumbs"]//a/text()') ... |
def open(url, query_params={}, user_agent=user_agent, post_data=None, | def open(url, query_params=None, user_agent=user_agent, post_data=None, | def open(url, query_params={}, user_agent=user_agent, post_data=None, get_method=None, cookies=False, **kwargs): query_params.update(kwargs) url = prepare_url(url, query_params) request = urllib2.Request(url, post_data) if get_method is not None: request.get_method = lambda: get_method request.add_header('User-Agen... |
global t t=text.find('b') | def mtg(inp): url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.find('p') type = text.text global t t=text.find('b') text = text.find('b... | |
global printing | def mtg(inp): url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.find('p') type = text.text global t t=text.find('b') text = text.find('b... | |
printings = re.findall(r'\s*(.*?) \((.*?)\)', ' '.join(printings.split())) | printings = re.findall(r'\s*(.+?(?: \([^)]+\))*) \((.*?)\)', ' '.join(printings.split())) | def mtg(inp): url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.find('p') type = text.text global t t=text.find('b') text = text.find('b... |
name = h.find('/body/table/tr/td/table/tr/td/h1') | name = h.find('/body/table/tr/td/span/a') | def mtg(inp): ".mtg <name> -- gets information about Magic the Gathering card <name>" url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.f... |
card = name.getparent() text = card.find('p') | card = name.getparent().getparent().getparent() | def mtg(inp): ".mtg <name> -- gets information about Magic the Gathering card <name>" url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.f... |
type = text.text text = text.find('b').text_content() | type = card.find('td/p').text.replace('\n', '') text = html.tostring(card.xpath("//p[@class='ctext']/b")[0]) text = text.replace('<br>', '$') text = html.fromstring(text).text_content() text = re.sub(r'(\w+\s*)\$+(\s*\w+)', r'\1. \2', text) text = text.replace('$', ' ') | def mtg(inp): ".mtg <name> -- gets information about Magic the Gathering card <name>" url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.f... |
printings = card.find('table/tr/td/img').getparent().text_content() | printings = card.find('td/small').text_content() printings = re.search(r'Editions:(.*)Languages:', printings).group(1) | def mtg(inp): ".mtg <name> -- gets information about Magic the Gathering card <name>" url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.f... |
link = name.find('a').attrib['href'] | link = name.attrib['href'] | def mtg(inp): ".mtg <name> -- gets information about Magic the Gathering card <name>" url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.f... |
'Beatdown': 'BD', | 'Battle Royale Box Set': 'BRB', 'Beatdown': 'BTD', 'Beatdown Box Set': 'BTD', | def mtg(inp): ".mtg <name> -- gets information about Magic the Gathering card <name>" url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.f... |
'Limited Edition (Alpha)': 'AL', 'Limited Edition (Beta)': 'BE', | 'Limited Edition (Alpha)': 'LEA', 'Limited Edition (Beta)': 'LEB', 'Limited Edition Alpha': 'LEA', 'Limited Edition Beta': 'LEB', | def mtg(inp): ".mtg <name> -- gets information about Magic the Gathering card <name>" url = 'http://magiccards.info/query.php?cardname=' url += urllib2.quote(inp, safe='') h = html.parse(url) name = h.find('/body/table/tr/td/table/tr/td/h1') if name is None: return "no cards found" card = name.getparent() text = card.f... |
if autohelp and args.get('autohelp', True) and not input.inp: | if autohelp and args.get('autohelp', True) and not input.inp \ and func.__doc__ is not None: | def dispatch(input, kind, func, args, autohelp=False): for sieve, in bot.plugs['sieve']: input = do_sieve(sieve, bot, input, func, kind, args) if input == None: return if autohelp and args.get('autohelp', True) and not input.inp: input.reply(func.__doc__) return if func._thread: bot.threads[func].put(input) else: thr... |
if fragment in short.split(): | if fragment in short.lower().split(): | def match_language(fragment): fragment = fragment.lower() for short, _ in lang_pairs: if fragment in short.split(): return short.split()[0] for short, full in lang_pairs: if fragment in full.lower(): return short.split()[0] return None |
("zh-CN", "Chinese"), | ("zh-CN zh", "Chinese"), | def babelext(inp): ".babelext <sentence> -- like .babel, but with more detailed output" try: babels = list(babel_gen(inp)) except IOError, e: return e out = u'' for lang, trans, text in babels: out += '%s:"%s", ' % (lang, text.decode('utf8')) out += 'en:"' + babels[-1][2].decode('utf8') + '"' if len(out) > 300: out... |
("ja jpn", "Japanese"), | ("ja jp jpn", "Japanese"), | def babelext(inp): ".babelext <sentence> -- like .babel, but with more detailed output" try: babels = list(babel_gen(inp)) except IOError, e: return e out = u'' for lang, trans, text in babels: out += '%s:"%s", ' % (lang, text.decode('utf8')) out += 'en:"' + babels[-1][2].decode('utf8') + '"' if len(out) > 300: out... |
print vid | def get_video_description(vid): print vid j = json.load(urllib2.urlopen(url % vid)) if j.get('error'): return j = j['data'] out = '\x02%s\x02' % j['title'] out += ' - length \x02' length = j['duration'] if length / 3600: # > 1 hour out += '%dh ' % (length / 3600) if length / 60: out += '%dm ' % (length / 60 % 60) o... | |
print inp | def youtube_url(inp): print inp m = youtube_re.search(inp) if m: return get_video_description(m.group(1)) | |
@hook.command(hook=r'(.*)', prefix=False, ignorebots=True) | @hook.command(hook=r'^(?!\.showtells)(.*)', prefix=False, ignorebots=True) | def adapt_datetime(ts): return time.mktime(ts.timetuple()) |
reply += " (+%(more)d more, to view say .showtells)" % {"more": more} | reply += " (+%(more)d more, to view use .showtells)" % {"more": more} | def tellinput(bot, input): dbpath = os.path.join(bot.persist_dir, dbname) conn = dbconnect(dbpath) cursor = conn.cursor() command = "select count(name) from tell where name LIKE ? and chan = ?" results = cursor.execute(command, (input.nick, input.chan)).fetchone() if results[0] > 0: command = "select id, user_from, ... |
input.msg(input.nick, '%(teller)s said %(time)s ago: %(quote)s' % {'teller': tell[1], 'quote': tell[2], 'time': reltime}) | input.pm('%(teller)s said %(time)s ago: %(quote)s' % \ {'teller': tell[1], 'quote': tell[2], 'time': reltime}) | def showtells(bot, input): ".showtells -- view all pending tell messages (sent in PM)." dbpath = os.path.join(bot.persist_dir, dbname) conn = dbconnect(dbpath) cursor = conn.cursor() command = "SELECT id, user_from, quote, date FROM tell " \ "WHERE name LIKE ? and chan = ?" tells = cursor.execute(command, (input.nick... |
if reply_name, reply_id: | if reply_name and reply_id: | def find_reply(reply_name): for name, id in history: if name == reply_name: return id return None |
def get_history(db, chan, url, duration): | def get_history_duration(db, chan, url, duration): | def get_history(db, chan, url, duration): db.execute("delete from urlhistory where time < ?", (time.time() - duration,)) return db.execute("select nick, time from urlhistory where " "chan=? and url=? order by time desc", (chan, url)).fetchall() |
return get_history(db, chan, url, expiration_period) | return get_history_duration(db, chan, url, expiration_period) | def get_history(db, chan, url): return get_history(db, chan, url, expiration_period) |
return len(get_history(db, chan, url, rate_limit_period)) | return len(get_history_duration(db, chan, url, rate_limit_period)) | def get_recent_links_count(db, chan, url): return len(get_history(db, chan, url, rate_limit_period)) |
return row[0].encode('utf8') | return row[0] | def get_memory(db, chan, word): row = db.execute("select data from memory where chan=? and word=lower(?)", (chan, word)).fetchone() if row: return row[0].encode('utf8') else: return None |
return 'forgetting that %r, remembering this instead.' % data | return 'forgetting "%s", remembering this instead.' % \ data.replace('"', "''") | def remember(inp, nick='', chan='', db=None): ".remember <word> <data> -- maps word to data in the memory" db_init(db) try: head, tail = inp.split(None, 1) except ValueError: return remember.__doc__ data = get_memory(db, chan, head) db.execute("replace into memory(chan, word, data, nick) values" " (?,lower(?),?,?)", ... |
db.execute("delete from urlhistory where time < ?", (time.time() - duration,)) | def get_history_duration(db, chan, url, duration): db.execute("delete from urlhistory where time < ?", (time.time() - duration,)) return db.execute("select nick, time from urlhistory where " "chan=? and url=? order by time desc", (chan, url)).fetchall() | |
self.__dict__ = self | def __getattr__(self, key): return self[key] def __setattr__(self, key value): self[key] = value | def pm(msg): conn.msg(nick, msg) |
print 'Normalized %s to %s' % (url, norm.normalize(m)) | def clean(string): string=unicode(unquote(string), 'utf-8', 'replace') return unicodedata.normalize('NFC', string).encode('utf-8') | |
print 'Normalized %s to %s' % (url, normal_url) | def clean(string): string=unicode(unquote(string), 'utf-8', 'replace') return unicodedata.normalize('NFC', string).encode('utf-8') | |
return 'nicks tagged %r: ' % subject + ', '.join(nicks) | return 'nicks tagged "%s": ' % subject + ', '.join(nicks) | def get_nicks_by_tag(db, chan, subject): nicks = db.execute("select nick from tag where lower(subject)=lower(?)" " and chan=?" " order by lower(nick)", (subject, chan)).fetchall() nicks = [munge(x[0], 3) for x in nicks] if not nicks: return 'tag not found' return 'nicks tagged %r: ' % subject + ', '.join(nicks) |
tells = get_tells(db, nick, chan) | tells = get_tells(db, nick) | def showtells(inp, nick='', chan='', pm=None, db=None): ".showtells -- view all pending tell messages (sent in PM)." db_init(db) tells = get_tells(db, nick, chan) if not tells: pm("You have no pending tells.") return for tell in tells: user_from, message, time, chan = tell reltime = timesince.timesince(time) pm("%s... |
(nick, chan)) | (nick,)) | def showtells(inp, nick='', chan='', pm=None, db=None): ".showtells -- view all pending tell messages (sent in PM)." db_init(db) tells = get_tells(db, nick, chan) if not tells: pm("You have no pending tells.") return for tell in tells: user_from, message, time, chan = tell reltime = timesince.timesince(time) pm("%s... |
@hook.regex(r'\?(.+)') | @hook.regex(r'^\?(.+)') | def forget(inp, chan='', db=None): ".forget <word> -- forgets the mapping that word had" if not inp: return forget.__doc__ db_init(db) data = get_memory(db, chan, inp) if not chan.startswith('#'): return "I won't forget anything in private." if data: db.execute("delete from memory where chan=? and word=lower(?)", (c... |
conn.msg(chan, nick + ': ' + msg) | if chan == nick: conn.msg(chan, msg) else: conn.msg(chan, nick + ': ' + msg) | def reply(msg): conn.msg(chan, nick + ': ' + msg) |
elif prefix: | elif prefix and command not in prefix: | def match_command(command): commands = list(bot.commands) # do some fuzzy matching prefix = filter(lambda x: x.startswith(command), commands) if len(prefix) == 1: return prefix[0] elif prefix: return prefix return command |
delete = re.match(r'd(?:el(?:ete)?)? (\S+) (.+)', inp) retrieve = re.match(r'l(?:ist)(?: (\S+))?$', inp) | delete = re.match(r'd(?:el(?:ete)?)? (\S+) (.+)\s*$', inp) retrieve = re.match(r'l(?:ist)(?: (.+))?\s*$', inp) | def tag(inp, chan='', db=None): '.tag <nick>/[add|del] <nick> <tag>/list [tag] -- get list of tags on ' \ '<nick>/(un)marks <nick> as <tag>/gets list of tags/nicks marked as [tag]' db.execute('create table if not exists tag(chan, subject, nick)') add = re.match(r'(?:a(?:dd)? )?(\S+) (.+)', inp) delete = re.match(r'd(... |
poster = thread.xpath('//dt[@class="author"]/text()')[0] | poster = thread.xpath('//dt[contains(@class, op)]//text()')[0] | def forum_link(inp, bot=None): if 'sa_user' not in bot.config or \ 'sa_password' not in bot.config: return login(bot.config['sa_user'], bot.config['sa_password']) thread = http.get_html(showthread, threadid=inp.group(1), perpage='1', cookies=True) breadcrumbs = thread.xpath('//div[@class="breadcrumbs"]//a/text()') ... |
chan = paraml[0].lower() if chan == conn.nick: | chan = paraml[0] if chan.lower() == conn.nick.lower(): | def __init__(self, conn, raw, prefix, command, params, nick, user, host, paraml, msg): |
self.cmd("PONG", [params]) | self.cmd("PONG", paramlist) | def parse_loop(self): while True: msg = self.conn.iqueue.get() |
row = db.execute("select data from memory where chan=? and word=lower(?)", | row = db.execute("select data from memory where chan=lower(?) and word=lower(?)", | def get_memory(db, chan, word): row = db.execute("select data from memory where chan=? and word=lower(?)", (chan, word)).fetchone() if row: return row[0] else: return None |
query = query.filter(Hebergement.heb_etat == '1') | query = query.filter(Hebergement.heb_site_public == '1') | def getLastHebergements(self): wrapper = getSAWrapper('gites_wallons') session = wrapper.session Hebergement = wrapper.getMapper('hebergement') query = session.query(Hebergement) query = query.filter(Hebergement.heb_etat == '1') query = query.order_by(desc(Hebergement.heb_pk)) query = query.limit(10) results = [heberge... |
msg = QString( "The following files does added to shapefile because of errors: <br><br>" ).append( errorsList.join( "<br><br>" ) ) | msg = QString( "The following files were not added to shapefile because of errors: <br><br>" ).append( errorsList.join( "<br><br>" ) ) | def processingFinished( self, errorsList ): self.stopProcessing() |
-1, "&Rate", self._rateMenu) | -1, "&Rate", self._rightClickRateMenu) | def _initCreateTrackRightClickMenu(self): self._logger.debug("Creating track right click menu.") self._trackRightClickMenu = wx.Menu() menuTrackRightClickRateUp = self._trackRightClickMenu.Append( -1, "Rate &Up", " Increase the score of the current track by one") menuTrackRightClickRateDown = self._trackRightClickMenu.... |
track = AudioTrack(db, path) | track = AudioTrack(db, path, self._logger) | def getTrackFromPathNoID(self, db, path): try: track = AudioTrack(db, path) except UnknownTrackType: return None except NoMetadataError: return None |
def __init__(self, db, path): | def __init__(self, db, path, logger): | def __init__(self, db, path): self.path = os.path.abspath(path) self.db = db self.id = None |
def __init__(self, db, path): Track.__init__(self, db, path) | def __init__(self, db, path, logger): Track.__init__(self, db, path, logger) | def __init__(self, db, path): Track.__init__(self, db, path) path = self.getPath() try: if self._debugMode == True: self._logger.debug("Creating track from \'"+path+"\'.") self.track = mutagen.File(path, easy=True) except mutagen.mp3.HeaderNotFoundError: self._logger.error("File has no metadata.") raise NoMetadataError... |
if self._debugMode == True: self._logger.debug("Creating track from \'"+path+"\'.") | self._logger.debug("Creating track from \'"+path+"\'.") | def __init__(self, db, path): Track.__init__(self, db, path) path = self.getPath() try: if self._debugMode == True: self._logger.debug("Creating track from \'"+path+"\'.") self.track = mutagen.File(path, easy=True) except mutagen.mp3.HeaderNotFoundError: self._logger.error("File has no metadata.") raise NoMetadataError... |
if self._debugMode == True: self._logger.debug("Track created.") | self._logger.debug("Track created.") | def __init__(self, db, path): Track.__init__(self, db, path) path = self.getPath() try: if self._debugMode == True: self._logger.debug("Creating track from \'"+path+"\'.") self.track = mutagen.File(path, easy=True) except mutagen.mp3.HeaderNotFoundError: self._logger.error("File has no metadata.") raise NoMetadataError... |
defaultHaveLogPanel=False): | defaultHaveLogPanel=True): | def __init__(self, parent, db, randomizer, player, trackFactory, system, loggerFactory, prefsFactory, configParser, title="NQr", restorePlaylist=False, enqueueOnStartup=True, rescanOnStartup=False, defaultPlaylistLength=11, defaultPlayDelay=4000, defaultInactivityTime=30000, wildcards="Music files (*.mp3;*.mp4)|*.mp3;*... |
redirect = RedirectText(self._logPanel) sys.stdout = redirect sys.stderr = redirect | self._redirect = RedirectText(self._logPanel) sys.stdout = self._redirect sys.stderr = self._redirect | def _initCreateLogPanel(self): self._logger.debug("Creating log panel.") self._logPanel = wx.TextCtrl(self._panel, -1, style=wx.TE_READONLY| wx.TE_MULTILINE|wx.TE_DONTWRAP, size=(-1,80)) |
self._logger.debug("Winamp has been launched.") | self._logger.info("Winamp has been launched.") | def launchBackground(self): if self._winamp.getRunning() == False: PIPE = subprocess.PIPE subprocess.Popen("start winamp", stdout=PIPE, shell=True) while True: time.sleep(.25) if self._winamp.getRunning() == True: self._logger.debug("Winamp has been launched.") |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() self._logger.info("Adding \'"+filepath+"\' to playlist.") | def addTrack(self, filepath): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.enqueue(filepath) |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() self._logger.debug("Moving to next track in playlist.") | def nextTrack(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.next() |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() self._logger.debug("Pausing playback.") | def pause(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.pause() |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() self._logger.debug("Resuming playback or restarting current track.") | def play(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.play() |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() self._logger.debug("Moving to previous track in playlist.") | def previousTrack(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.previous() |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() self._logger.debug("Stopping playback.") | def stop(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.fadeStop() |
if status == True: | self._logger.debug("Setting shuffle status.") if status == True or status == 1: | def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status) |
if status == False: | self._logger.info("Shuffle turned on.") if status == False or status == 0: | def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status) |
else: self._winamp.setShuffle(status) | self._logger.info("Shuffle turned off.") | def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status) |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() self._logger.debug("Retrieving playlist length.") | def getPlaylistLength(self): if self._winamp.getRunning() == False: self.launchBackground() playlistLength = self._winamp.doIpcCommand(IPC_GETLISTLENGTH) return playlistLength |
if self._winamp.getRunning() == False: self.launchBackground() | self.launchBackground() | def getCurrentTrackPos(self): if self._winamp.getRunning() == False: self.launchBackground() trackPosition = self._winamp.getCurrentTrack() return trackPosition |
print "Playlist is empty." | self._logger.error("Playlist is empty.") | def getTrackPathAtPos(self, trackPosition): |
for s in rawPath: | self._logger.warning("Found bad characters. Attempting to resolve.") for char in rawPath: | def getTrackPathAtPos(self, trackPosition): |
path += unicode(s) | path += unicode(char) | def getTrackPathAtPos(self, trackPosition): |
if self._oldPlaylist != None and self._restorePlaylist == True: | if self._restorePlaylist == True and self._oldPlaylist != None: | def _onToggleNQr(self, e=None): self._logger.debug("Toggling NQr.") if self.menuToggleNQr.IsChecked() == False: self.toggleNQr = False self._logger.info("Restoring shuffle status.") self._player.setShuffle(self._oldShuffleStatus) if self._oldPlaylist != None and self._restorePlaylist == True: self._player.loadPlaylist(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.