bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
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...
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...
445,300
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] = ...
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] = None try: self.mathml[formula] = s...
445,301
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] = ...
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: mathml, label = self._m...
445,302
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] = ...
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] = ...
445,303
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] = ...
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] = ...
445,304
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', "...
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', "...
445,305
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', "...
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', "...
445,306
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 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()') ...
445,307
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...
def open(url, query_params=None, 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-Ag...
445,308
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...
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 text = text.find('b').text_content() text = r...
445,309
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...
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...
445,310
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...
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...
445,311
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...
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/span/a') if name is None: return "no cards found" card = name.getparent() text = card.find('p'...
445,312
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...
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().getparent().g...
445,313
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...
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...
445,314
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...
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...
445,315
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...
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...
445,316
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...
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...
445,317
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...
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...
445,318
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...
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 \ and func.__doc__ is not None: input.reply(func.__doc__) return if func._thread: bot.thr...
445,319
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
def match_language(fragment): fragment = fragment.lower() for short, _ in lang_pairs: if fragment in short.lower().split(): return short.split()[0] for short, full in lang_pairs: if fragment in full.lower(): return short.split()[0] return None
445,320
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...
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...
445,321
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...
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...
445,322
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...
def get_video_description(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) out += "%ds...
445,323
def youtube_url(inp): print inp m = youtube_re.search(inp) if m: return get_video_description(m.group(1))
def youtube_url(inp): m = youtube_re.search(inp) if m: return get_video_description(m.group(1))
445,324
def adapt_datetime(ts): return time.mktime(ts.timetuple())
def adapt_datetime(ts): return time.mktime(ts.timetuple())
445,325
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, ...
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, ...
445,326
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...
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...
445,327
def find_reply(reply_name): for name, id in history: if name == reply_name: return id return None
def find_reply(reply_name): for name, id in history: if name == reply_name: return id return None
445,328
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()
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()
445,329
def get_history(db, chan, url): return get_history(db, chan, url, expiration_period)
def get_history(db, chan, url): return get_history_duration(db, chan, url, expiration_period)
445,330
def get_recent_links_count(db, chan, url): return len(get_history(db, chan, url, rate_limit_period))
def get_recent_links_count(db, chan, url): return len(get_history_duration(db, chan, url, rate_limit_period))
445,331
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
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
445,332
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(?),?,?)", ...
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(?),?,?)", ...
445,333
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()
def get_history_duration(db, chan, url, duration): return db.execute("select nick, time from urlhistory where " "chan=? and url=? order by time desc", (chan, url)).fetchall()
445,334
def pm(msg): conn.msg(nick, msg)
def pm(msg): conn.msg(nick, msg)
445,335
def clean(string): string=unicode(unquote(string), 'utf-8', 'replace') return unicodedata.normalize('NFC', string).encode('utf-8')
def clean(string): string=unicode(unquote(string), 'utf-8', 'replace') return unicodedata.normalize('NFC', string).encode('utf-8')
445,336
def clean(string): string=unicode(unquote(string), 'utf-8', 'replace') return unicodedata.normalize('NFC', string).encode('utf-8')
def clean(string): string=unicode(unquote(string), 'utf-8', 'replace') return unicodedata.normalize('NFC', string).encode('utf-8')
445,337
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)
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 "%s": ' % subject + ', '.join(nicks)
445,338
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...
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) 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 said ...
445,339
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...
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...
445,340
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...
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...
445,341
def reply(msg): conn.msg(chan, nick + ': ' + msg)
def reply(msg): conn.msg(chan, nick + ': ' + msg)
445,342
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
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 and command not in prefix: return prefix return command
445,343
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(...
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(...
445,344
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 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()') ...
445,345
def __init__(self, conn, raw, prefix, command, params, nick, user, host, paraml, msg):
def __init__(self, conn, raw, prefix, command, params, nick, user, host, paraml, msg):
445,346
def parse_loop(self): while True: msg = self.conn.iqueue.get()
def parse_loop(self): while True: msg = self.conn.iqueue.get()
445,347
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
def get_memory(db, chan, word): row = db.execute("select data from memory where chan=lower(?) and word=lower(?)", (chan, word)).fetchone() if row: return row[0] else: return None
445,348
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...
def getLastHebergements(self): wrapper = getSAWrapper('gites_wallons') session = wrapper.session Hebergement = wrapper.getMapper('hebergement') query = session.query(Hebergement) query = query.filter(Hebergement.heb_site_public == '1') query = query.order_by(desc(Hebergement.heb_pk)) query = query.limit(10) results = [...
445,349
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...
def getLastHebergements(self): wrapper = getSAWrapper('gites_wallons') session = wrapper.session Hebergement = wrapper.getMapper('hebergement') query = session.query(Hebergement) query = query.filter(Hebergement.heb_site_public == '1') query = query.order_by(desc(Hebergement.heb_pk)) query = query.limit(10) results = [...
445,350
def processingFinished( self, errorsList ): self.stopProcessing()
def processingFinished( self, errorsList ): self.stopProcessing()
445,351
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....
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....
445,352
def getTrackFromPathNoID(self, db, path): try: track = AudioTrack(db, path) except UnknownTrackType: return None except NoMetadataError: return None
def getTrackFromPathNoID(self, db, path): try: track = AudioTrack(db, path, self._logger) except UnknownTrackType: return None except NoMetadataError: return None
445,353
def __init__(self, db, path): self.path = os.path.abspath(path) self.db = db self.id = None
def __init__(self, db, path, logger): self.path = os.path.abspath(path) self.db = db self.id = None
445,354
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...
def __init__(self, db, path, logger): Track.__init__(self, db, path, logger) 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...
445,355
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...
def __init__(self, db, path): Track.__init__(self, db, path) path = self.getPath() try: 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.track is None: self...
445,356
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...
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...
445,357
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;*...
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;*...
445,358
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))
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))
445,359
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.")
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.")
445,360
def addTrack(self, filepath): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.enqueue(filepath)
def addTrack(self, filepath): self.launchBackground() self._logger.info("Adding \'"+filepath+"\' to playlist.") self._winamp.enqueue(filepath)
445,361
def nextTrack(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.next()
def nextTrack(self): self.launchBackground() self._logger.debug("Moving to next track in playlist.") self._winamp.next()
445,362
def pause(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.pause()
def pause(self): self.launchBackground() self._logger.debug("Pausing playback.") self._winamp.pause()
445,363
def play(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.play()
def play(self): self.launchBackground() self._logger.debug("Resuming playback or restarting current track.") self._winamp.play()
445,364
def previousTrack(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.previous()
def previousTrack(self): self.launchBackground() self._logger.debug("Moving to previous track in playlist.") self._winamp.previous()
445,365
def stop(self): if self._winamp.getRunning() == False: self.launchBackground() self._winamp.fadeStop()
def stop(self): self.launchBackground() self._logger.debug("Stopping playback.") self._winamp.fadeStop()
445,366
def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status)
def setShuffle(self, status): self._logger.debug("Setting shuffle status.") if status == True or status == 1: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status)
445,367
def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status)
def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) self._logger.info("Shuffle turned on.") if status == False or status == 0: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status)
445,368
def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status)
def setShuffle(self, status): if status == True: self._winamp.setShuffle(1) if status == False: self._winamp.setShuffle(0) else: self._winamp.setShuffle(status)
445,369
def getPlaylistLength(self): if self._winamp.getRunning() == False: self.launchBackground() playlistLength = self._winamp.doIpcCommand(IPC_GETLISTLENGTH) return playlistLength
def getPlaylistLength(self): self.launchBackground() self._logger.debug("Retrieving playlist length.") playlistLength = self._winamp.doIpcCommand(IPC_GETLISTLENGTH) return playlistLength
445,370
def getCurrentTrackPos(self): if self._winamp.getRunning() == False: self.launchBackground() trackPosition = self._winamp.getCurrentTrack() return trackPosition
def getCurrentTrackPos(self): self.launchBackground() trackPosition = self._winamp.getCurrentTrack() return trackPosition
445,371
def getTrackPathAtPos(self, trackPosition):
def getTrackPathAtPos(self, trackPosition):
445,372
def getTrackPathAtPos(self, trackPosition):
def getTrackPathAtPos(self, trackPosition):
445,373
def getTrackPathAtPos(self, trackPosition):
def getTrackPathAtPos(self, trackPosition):
445,374
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(...
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._restorePlaylist == True and self._oldPlaylist != None: self._player.loadPlaylist(...
445,375
def savePlaylist(self): playlist = [] for trackPosition in range(self.getPlaylistLength()): playlist.append(self.getTrackPathAtPos(trackPosition)) return playlist
def savePlaylist(self): playlist = [] for trackPosition in range(self.getPlaylistLength()): playlist.append(self.getTrackPathAtPos(trackPosition)) return playlist
445,376
def __init__(self): wx.App.__init__(self, False) self._prefsFile = "settings"
def __init__(self): wx.App.__init__(self, False) self._prefsFile = "settings"
445,377
def run(self): # Do platform-dependent imports, and choose a player type. For # now, we just choose it based on the platform... system = platform.system() self._logger.debug("Running on "+system+".") player = None if system == 'Windows': self._logger.debug("Loading Winamp module.") import WinampWindows player = WinampW...
def run(self): # Do platform-dependent imports, and choose a player type. For # now, we just choose it based on the platform... system = platform.system() self._logger.debug("Running on "+system+".") player = None if system == 'Windows': self._logger.debug("Loading Winamp module.") import WinampWindows player = WinampW...
445,378
def run(self): # Do platform-dependent imports, and choose a player type. For # now, we just choose it based on the platform... system = platform.system() self._logger.debug("Running on "+system+".") player = None if system == 'Windows': self._logger.debug("Loading Winamp module.") import WinampWindows player = WinampW...
def run(self): # Do platform-dependent imports, and choose a player type. For # now, we just choose it based on the platform... system = platform.system() self._logger.debug("Running on "+system+".") player = None if system == 'Windows': self._logger.debug("Loading Winamp module.") import WinampWindows player = WinampW...
445,379
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self._trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self._trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
445,380
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self._trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self._trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
445,381
def _onScoreSliderMove(self, e): self.resetInactivityTimer() try: self._logger.debug("Score slider has been moved."\ +" Retrieving new score.") score = self._scoreSlider.GetValue() self._track.setScore(score) self.refreshSelectedTrackScore() ## causes second scoring except AttributeError as err: if str(err) != "'MainWi...
def _onScoreSliderMove(self, e): self.resetInactivityTimer() try: self._logger.debug("Score slider has been moved."\ +" Retrieving new score.") score = self._scoreSlider.GetValue() if self._track.getScore() != score: self._track.setScore(score) self.refreshSelectedTrackScore() ## causes second scoring except AttributeE...
445,382
def _exceptHook(self, type, value, traceBack): try: if value.trace != None: self._logger.critical("Uncaught exception:\n\nTraceback (most "\ +"recent call last):\n"+"".join([ line for line in traceback.format_list(value.trace)\ +traceback.format_exception_only(type, value)])) else: self._logger.critical("Uncaught excep...
def _exceptHook(self, type, value, traceBack): try: if value.trace != None: self._logger.critical( "Uncaught exception:\n\nTraceback (most recent call last):"\ +"\n"+"".join([ line for line in traceback.format_list(value.trace)\ +traceback.format_exception_only(type, value)])) else: self._logger.critical("Uncaught exce...
445,383
def _exceptHook(self, type, value, traceBack): try: if value.trace != None: self._logger.critical("Uncaught exception:\n\nTraceback (most "\ +"recent call last):\n"+"".join([ line for line in traceback.format_list(value.trace)\ +traceback.format_exception_only(type, value)])) else: self._logger.critical("Uncaught excep...
def _exceptHook(self, type, value, traceBack): try: if value.trace != None: self._logger.critical("Uncaught exception:\n\nTraceback (most "\ +"recent call last):\n"+"".join([ line for line in traceback.format_list(value.trace)\ +traceback.format_exception_only(type, value)])) else: self._logger.critical("Uncaught excep...
445,384
def _updateTrackDetails(self, track): path = track.getPath() self._logger.debug("Updating \'"+path+"\' in the library.") c = self._conn.cursor() trackID = self._getTrackID(track) if trackID != None: c.execute("""update tracks set path = ?, artist = ?, album = ?, title = ?, tracknumber = ?, length = ?, bpm = ? where tra...
def _updateTrackDetails(self, track): path = track.getPath() self._logger.debug("Updating \'"+path+"\' in the library.") c = self._conn.cursor() trackID = self._getTrackID(track) if trackID != None: c.execute("""update tracks set path = ?, artist = ?, album = ?, title = ?, tracknumber = ?, length = ?, bpm = ? where tra...
445,385
def _addTrackAtPosCompletion(self, index, track, isScored, lastPlayed, score, scoreValue, trackID, select=False): self._logger.debug("Adding track to track playlist.") if isScored == False: score = "("+str(scoreValue)+")" else: score = str(score) ## should be time from last play? if lastPlayed == None: lastPlayed = "-"...
def _addTrackAtPosCompletion(self, index, track, isScored, lastPlayed, score, scoreValue, trackID, select=False): self._logger.debug("Adding track to track playlist.") if isScored == False: score = "("+str(scoreValue)+")" else: score = str(score) ## should be time from last play? if lastPlayed == None: lastPlayed = "-"...
445,386
def _onClose(self, e): self._optionsMenu.Check(self._ID_TOGGLENQR, False) if self._trackMonitor: self._trackMonitor.abort() self._inactivityTimer.Stop() self._refreshTimer.Stop() sys.stdout = self._stdout sys.stderr = self._stderr self._redirect.flush() self.Destroy()
def _onClose(self, e): self._optionsMenu.Check(self._ID_TOGGLENQR, False) if self._trackMonitor: self._trackMonitor.abort() self._inactivityTimer.Stop() self._refreshTimer.Stop() sys.stdout = self._stdout sys.stderr = self._stderr self.Destroy()
445,387
def _onRequeue(self, e): self.resetInactivityTimer() try: self._logger.info("Requeueing track.") self._player.addTrack(self._track.getPath()) except AttributeError as err: if str(err) != "'MainWindow' object has no attribute '_track'": raise err self._logger.error("No track selected.") return
def_onRequeue(self,e):self.resetInactivityTimer()try:self._logger.info("Requeueingtrack.")self._player.addTrack(self._track.getPath())exceptAttributeErroraserr:ifstr(err)!="'MainWindow'objecthasnoattribute'_track'":raiseerrself._logger.error("Notrackselected.")return
445,388
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self.trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self._trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
445,389
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self.trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
def addTrackToCache(self, track): self._logger.debug("Adding track to cache.") if len(self._trackCache) > 10000: del self._trackCache[self.trackIDList.pop(0)] id = track.getID() self._trackCache[id] = track self._trackIDList.append(id)
445,390
def _getAttribute(self, attr): try: attribute = self._track[attr][0] return attribute except KeyError as err: # if 'artist' is thrown then the track doesn't have any ID3 # which is an error we should not accept - so for now, die ## poss should die on no title not no artist? ## what is key for artist? if str(err) not in...
def _getAttribute(self, attr): try: attribute = self._track[attr][0] return attribute except KeyError as err: # if 'artist' is thrown then the track doesn't have any ID3 # which is an error we should not accept - so for now, die ## poss should die on no title not no artist? ## what is key for artist? if str(err) not in...
445,391
def getTrackFromCache(self, trackID): try: return self._trackCache[trackID] except KeyError as err: ## FIXME: should only except errors where err is integer return None
def getTrackFromCache(self, trackID): try: return self._trackCache[trackID] except KeyError as err: ## FIXME: should only except errors where err is integer return None
445,392
def getboolean(self, section, option): result = self.get(section, option) try: trues = ["1", "yes", "true", "on"] falses = ["0", "no", "false", "off"] if result in trues: return True if result in falses: return False except AttributeError as err: if str(err) == "\'bool\' object has no attribute \'lower\'": return resul...
def getboolean(self, section, option): result = self.get(section, option) try: trues = ["1", "yes", "true", "on"] falses = ["0", "no", "false", "off"] if result.lower() in trues: return True if result in falses: return False except AttributeError as err: if str(err) == "\'bool\' object has no attribute \'lower\'": retu...
445,393
def getboolean(self, section, option): result = self.get(section, option) try: trues = ["1", "yes", "true", "on"] falses = ["0", "no", "false", "off"] if result in trues: return True if result in falses: return False except AttributeError as err: if str(err) == "\'bool\' object has no attribute \'lower\'": return resul...
def getboolean(self, section, option): result = self.get(section, option) try: trues = ["1", "yes", "true", "on"] falses = ["0", "no", "false", "off"] if result in trues: return True elif result.lower() in falses: return False except AttributeError as err: if str(err) == "\'bool\' object has no attribute \'lower\'": re...
445,394
def createLists(self): rawTrackIDList = self.db.getAllTrackIDs() if rawTrackIDList == None: raise EmptyDatabaseError trackWeightList = [] totalWeight = 0 for (trackID, ) in rawTrackIDList: time = self.db.getSecondsSinceLastPlayedFromID(trackID) score = self.db.getScoreValueFromID(trackID) + 11 ## creates a positive sco...
def createLists(self): rawTrackIDList = self.db.getAllTrackIDs() if rawTrackIDList == []: raise EmptyDatabaseError trackWeightList = [] totalWeight = 0 for (trackID, ) in rawTrackIDList: time = self.db.getSecondsSinceLastPlayedFromID(trackID) score = self.db.getScoreValueFromID(trackID) + 11 ## creates a positive score...
445,395
def run(self): self._logger.info("Starting \'"+self._name+"\' thread.") conn = sqlite3.connect(self._databasePath) cursor = conn.cursor() while True: try: got = self._queue.get_nowait() except Queue.Empty: if self._abortFlag == True: conn.commit() self._logger.info("Stopping \'"+self._name+"\' thread.") return self._ra...
def run(self): self._logger.info("Starting \'"+self._name+"\' thread.") conn = sqlite3.connect(self._databasePath) cursor = conn.cursor() while True: try: got = self._queue.get_nowait() except Queue.Empty: if self._abortFlag == True: self._commit(conn) self._logger.info("Stopping \'"+self._name+"\' thread.") return sel...
445,396
def run(self): self._logger.info("Starting \'"+self._name+"\' thread.") conn = sqlite3.connect(self._databasePath) cursor = conn.cursor() while True: try: got = self._queue.get_nowait() except Queue.Empty: if self._abortFlag == True: conn.commit() self._logger.info("Stopping \'"+self._name+"\' thread.") return self._ra...
def run(self): self._logger.info("Starting \'"+self._name+"\' thread.") conn = sqlite3.connect(self._databasePath) cursor = conn.cursor() while True: try: got = self._queue.get_nowait() except Queue.Empty: if self._abortFlag == True: self._commit(conn) def _commit(self, conn): try: conn.commit() except sqlite3.Operati...
445,397
def initScoreSlider(self): self.scoreSlider = wx.Slider(self, self.ID_SCORESLIDER, 0, -10, 10, style=wx.SL_RIGHT|wx.SL_LABELS| wx.SL_INVERSE)
def initScoreSlider(self): self.scoreSlider = wx.Slider(self, self.ID_SCORESLIDER, 0, -10, 10, style=wx.SL_VERTICAL|wx.SL_LABELS| wx.SL_INVERSE)
445,398
def addTrack(self, path, hasTrackID=True): self._logger.debug("Adding \'"+path+"\' to the library.") track = self._trackFactory.getTrackFromPathNoID(self, path) if track == None: self._logger.debug("\'"+path+"\' is an invalid file.") return None c = self._conn.cursor() trackID = None if hasTrackID == True: trackID = se...
def addTrack(self, path, hasTrackID=True): self._logger.debug("Adding \'"+path+"\' to the library.") track = self._trackFactory.getTrackFromPathNoID(self, path) if track == None: self._logger.debug("\'"+path+"\' is an invalid file.") return None c = self._conn.cursor() trackID = None if hasTrackID == True: trackID = se...
445,399