bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def describe_category(self, event, terms): categories, features = self._get_features() termset = frozenset(self.stemmer.stemWord(term) for term in terms.lower().split()) | def describe_category(self, event, terms): categories, features = self._get_features() termset = frozenset(self.stemmer.stemWord(term) for term in terms.lower().split()) | 453,200 |
def airport_search(query, search_loc = True): if not airports: read_data() if search_loc: ids = airport_search(query, False) if len(ids) == 1: return ids query = [unicode(q) for q in query.lower().split(' ') if q] else: query = [unicode(query.lower())] ids = [] for id, airport in airports.items(): if search_loc: data =... | def airport_search(query, search_loc = True): if not airports: read_data() if search_loc: ids = airport_search(query, False) if len(ids) == 1: return ids query = [unicode(q) for q in query.lower().split(' ') if q] else: query = [unicode(query.lower())] ids = [] for id, airport in airports.items(): if search_loc: data =... | 453,201 |
def repr_airport(id): airport = airports[id] code = '' if airport[3] or airport[4]: code = ' (%s)' % u'/'.join(filter(lambda c: c, airport[3:5])) return '%s%s' % (airport[0], code) | def repr_airport(id): airport = airports[id] code = '' if airport[3] or airport[4]: code = ' (%s)' % u'/'.join(filter(lambda c: c, airport[3:5])) return '%s%s' % (airport[0], code) | 453,202 |
def int_duration(self): hours, minutes = 0, 0 match = re.search(r'(\d+)hr', self.duration) if match: hours = int(match.group(1)) match = re.search(r'(\d+)min', self.duration) if match: minutes = int(match.group(1)) return int(hours)*60 + int(minutes) | def int_duration(self): hours, minutes = 0, 0 match = re.search(r'(\d+)hr', self.duration) if match: hours = int(match.group(1)) match = re.search(r'(\d+)min', self.duration) if match: minutes = int(match.group(1)) return int(hours)*60 + int(minutes) | 453,203 |
def redirect(self, event): if 'redirect_target' in event: responses = [] for response in event.responses: if isinstance(response, basestring): response = {'reply': response, 'target': event.redirect_target} if 'redirect_source' in event: response['source'] = event.redirect_source responses.append(response) event.respon... | def redirect(self, event): if 'redirect_target' in event: responses = [] for response in event.responses: response['target'] = event.redirect_target if 'redirect_source' in event: response['source'] = event.redirect_source responses.append(response) event.responses = responses | 453,204 |
def swear(self, event, insultee): swearage = [] for i in range(self.swearlength): if random() > 0.7: swearage.append(choice(self.loneadjectives)) else: swearage.append(choice(self.swearnouns) + choice(self.swearadjectives)) if insultee is not None: swearage.append(insultee) else: swearage.append(choice(self.swearnouns)... | def swear(self, event, insultee): swearage = [] for i in range(self.swearlength): if random() > 0.7: swearage.append(choice(self.loneadjectives)) else: swearage.append(choice(self.swearnouns) + choice(self.swearadjectives)) if insultee is not None: swearage.append(insultee) else: swearage.append(choice(self.swearnouns)... | 453,205 |
def swear(self, event, insultee): swearage = [] for i in range(self.swearlength): if random() > 0.7: swearage.append(choice(self.loneadjectives)) else: swearage.append(choice(self.swearnouns) + choice(self.swearadjectives)) if insultee is not None: swearage.append(insultee) else: swearage.append(choice(self.swearnouns)... | def swear(self, event, insultee): swearage = [] for i in range(self.swearlength): if random() > 0.7: swearage.append(choice(self.loneadjectives)) else: swearage.append(choice(self.swearnouns) + choice(self.swearadjectives)) if insultee is not None: swearage.append(insultee) else: swearage.append(choice(self.swearnouns)... | 453,206 |
def have(self, event, determiner, object): if event.type == 'action' or \ event.message['deaddressed'] == event.message['raw']: return False return self.exchange(event, determiner, object) | def have(self, event, determiner, object): if event.type == 'action' or \ event.message['deaddressed'] == event.message['raw']: return False return self.exchange(event, determiner, object) | 453,207 |
def query_carrying(self, event): if event.type == 'action' or \ event.message['deaddressed'] == event.message['raw']: return False | def query_carrying(self, event): if event.type == 'action' or \ event.message['deaddressed'] == event.message['raw']: return False | 453,208 |
def query_carrying(self, event): if event.type == 'action' or \ event.message['deaddressed'] == event.message['raw']: return False | def query_carrying(self, event): if event.type == 'action' or \ event.message['deaddressed'] == event.message['raw']: return False | 453,209 |
def __init__(self, url, channel, identity_id): self.url = url self.channel = channel self.identity_id = identity_id self.time = datetime.utcnow() | def __init__(self, url, channel, identity_id): self.url = url self.channel = channel self.identity_id = identity_id self.time = datetime.utcnow() | 453,210 |
def host_scan(self, event, host): if host.startswith('127.0.0.') or host.lower().startswith('localhost'): event.addresponse(u"I'm not allowed to inspect my host's internal interface.") return | def host_scan(self, event, host): if host.startswith('127.0.0.') or host.lower().startswith('localhost'): event.addresponse(u"I'm not allowed to inspect my host's internal interface.") return | 453,211 |
def airport_search(self, event, query): ids = self._airport_search(query) if len(ids) == 0: event.addresponse(u"Sorry, I don't know that airport") elif len(ids) == 1: id = ids[0] airport = self.airports[id] code = 'unknown code' if airport[4] and airport[5]: code = 'codes %s and %s' % (airport[3], airport[4]) elif airp... | def airport_search(self, event, query): ids = self._airport_search(query) if len(ids) == 0: event.addresponse(u"Sorry, I don't know that airport") elif len(ids) == 1: id = ids[0] airport = self.airports[id] code = 'unknown code' if airport[3] and airport[4]: code = 'codes %s and %s' % (airport[3], airport[4]) elif airp... | 453,212 |
def airport_search(self, event, query): ids = self._airport_search(query) if len(ids) == 0: event.addresponse(u"Sorry, I don't know that airport") elif len(ids) == 1: id = ids[0] airport = self.airports[id] code = 'unknown code' if airport[4] and airport[5]: code = 'codes %s and %s' % (airport[3], airport[4]) elif airp... | def airport_search(self, event, query): ids = self._airport_search(query) if len(ids) == 0: event.addresponse(u"Sorry, I don't know that airport") elif len(ids) == 1: id = ids[0] airport = self.airports[id] code = 'unknown code' if airport[4] and airport[5]: code = 'codes %s and %s' % (airport[3], airport[4]) elif airp... | 453,213 |
def test_complex_dict_response(self): ev = self._ev() self.assertEqual([], ev.responses) ev.addresponse({'reply': 'r1', 'target': 't1', 'source': 's1', 'address': 'a1', 'conflate': 'c1'}) ev.addresponse({'reply': 'r1', 'target': 't1', 'source': 's1', 'address': 'a1', 'conflate': 'c1'}, reply='r2', target='t2', source='... | def test_complex_dict_with_kwargs_response(self): "Keyword arguments to addresponse override response dict values." ev = self._ev() self.assertEqual([], ev.responses) ev.addresponse({'reply': 'r1', 'target': 't1', 'source': 's1', 'address': 'a1', 'conflate': 'c1'}) ev.addresponse({'reply': 'r1', 'target': 't1', 'source... | 453,214 |
def _isitup(self, url): valid_url = self._makeurl(url) if Resolver is not None: r = Resolver() host = urlparse(valid_url).netloc.split(':')[0] try: response = r.query(host) except NoAnswer: return False, u'No DNS A/CNAME-records for that domain' except NXDOMAIN: return False, u'No such domain' | def _isitup(self, url): valid_url = self._makeurl(url) if Resolver is not None: r = Resolver() host = urlparse(valid_url).netloc.split(':')[0] try: response = r.query(host) except NoAnswer: return False, u'No DNS A/CNAME-records for that domain' except NXDOMAIN: return False, u'No such domain' | 453,215 |
def remote_forecast(self, place): soup = self._get_page(place) forecasts = [] table = [table for table in soup.findAll('table') if table.findAll('td', align='left')][0] | def remote_forecast(self, place): soup = self._get_page(place) forecasts = [] table = [table for table in soup.findAll('table') if table.findAll('td', align='left')][0] | 453,216 |
def weather(self, event, place): try: values = self.remote_weather(place) event.addresponse(u'In %(place)s at %(time)s: %(temp)s; Humidity: %(humidity)s; Wind: %(wind)s; Conditions: %(conditions)s; Sunrise/set: %(sunrise)s/%(sunset)s; Moonrise/set: %(moonrise)s/%(moonset)s', values) except Weather.TooManyPlacesExceptio... | def weather(self, event, place): try: values = self.remote_weather(place) event.addresponse(u'In %(place)s at %(time)s: %(temp)s; Humidity: %(humidity)s; Wind: %(wind)s; Conditions: %(conditions)s; Sunrise/set: %(sunrise)s/%(sunset)s; Moonrise/set: %(moonrise)s/%(moonset)s', values) except Weather.TooManyPlacesExceptio... | 453,217 |
def update(self, event, service_name, id): service = self.services[service_name.lower()] try: event.addresponse(u'%(screen_name)s: "%(text)s"', self.remote_update(service, int(id))) except HTTPError, e: if e.code in (401, 403): event.addresponse(u'That %s is private', service['name']) elif e.code == 404: event.addrespo... | def update(self, event, service_name, id): service = self.services[service_name.lower()] try: event.addresponse(u'%(screen_name)s: "%(text)s"', self.remote_update(service, int(id))) except HTTPError, e: if e.code in (401, 403): event.addresponse(u'That %s is private', service['name']) elif e.code == 404: event.addrespo... | 453,218 |
def _whensitup(self, event, url, delay, total_delay = 0): up, _, _ = self._isitup(url) if up: event.addresponse(u'%s is now up', self._makeurl(url)) return total_delay += delay if total_delay >= self.whensitup_maxperiod * 60 * 60: event.addresponse(u"Sorry, it appears %s is never coming up. I'm not going to check any m... | def _whensitup(self, event, url, delay, total_delay = 0): up, _ = self._isitup(url) if up: event.addresponse(u'%s is now up', self._makeurl(url)) return total_delay += delay if total_delay >= self.whensitup_maxperiod * 60 * 60: event.addresponse(u"Sorry, it appears %s is never coming up. I'm not going to check any more... | 453,219 |
def whensitup(self, event, url): if self._isitup(url): event.addresponse(u'%s is up right now', self._makeurl(url)) return ibid.dispatcher.call_later(self.whensitup_delay, self._whensitup, event, url, self.whensitup_delay) event.addresponse(u"I'll let you know when %s is up", url) | def whensitup(self, event, url): up, _ = self._isitup(self._makeurl(url)) if up: event.addresponse(u'%s is up right now', self._makeurl(url)) return ibid.dispatcher.call_later(self.whensitup_delay, self._whensitup, event, url, self.whensitup_delay) event.addresponse(u"I'll let you know when %s is up", url) | 453,220 |
def exception(self, event, kind): exc_event = last_exc_event if exc_event is None: event.addresponse(choice((u'Are you *looking* for trouble?', u"I'll make an exception for you."))) else: if kind.lower() == 'exception': try: lines = [u'%(type)s event "%(message)s" triggered ' % {'type': exc_event.type, 'message': exc_e... | def exception(self, event, kind): exc_event = last_exc_event if exc_event is None: event.addresponse(choice((u'Are you *looking* for trouble?', u"I'll make an exception for you."))) else: if kind.lower() == 'exception': try: lines = [u'%(type)s event "%(message)s" triggered ' % {'type': exc_event.type, 'message': exc_e... | 453,221 |
def process(self, event): global last_exc_info | def process(self, event): global last_exc_info | 453,222 |
def setup(self): names = '|'.join(re.escape(x) for x in self.names) verbs = '|'.join(re.escape(x) for x in self.verbs) self.patterns = [ re.compile(r'^(%s)(?:[:;.?>!,-]|\s)+' % names, re.I | re.DOTALL), # "hello there, bot"-style addressing. But we want to be sure that # there wasn't normal addressing too: re.compile(r... | def setup(self): names = '|'.join(re.escape(x) for x in self.names) verbs = '|'.join(re.escape(x) for x in self.verbs) self.patterns = [ re.compile(r'^(?P<nick>%s)(?:[:;.?>!,-]|\s)+(?P<body>.*)' % names, re.I | re.DOTALL), # "hello there, bot"-style addressing. But we want to be sure that # there wasn't normal addressi... | 453,223 |
def setup(self): names = '|'.join(re.escape(x) for x in self.names) verbs = '|'.join(re.escape(x) for x in self.verbs) self.patterns = [ re.compile(r'^(%s)(?:[:;.?>!,-]|\s)+' % names, re.I | re.DOTALL), # "hello there, bot"-style addressing. But we want to be sure that # there wasn't normal addressing too: re.compile(r... | def setup(self): names = '|'.join(re.escape(x) for x in self.names) verbs = '|'.join(re.escape(x) for x in self.verbs) self.patterns = [ re.compile(r'^(%s)(?:[:;.?>!,-]|\s)+' % names, re.I | re.DOTALL), # "hello there, bot"-style addressing. But we want to be sure that # there wasn't normal addressing too: re.compile(r... | 453,224 |
def handle_addressed(self, event): if 'addressed' not in event: event.addressed = False | def handle_addressed(self, event): if 'addressed' not in event: event.addressed = False | 453,225 |
def handle_addressed(self, event): if 'addressed' not in event: event.addressed = False | def handle_addressed(self, event): if 'addressed' not in event: event.addressed = False | 453,226 |
def announce(self, event, who, what, from_who, from_when): """This handler gets called after the timeout and will notice the user.""" | def announce(self, event, who, what, from_who, from_when): """This handler gets called after the timeout and will notice the user.""" | 453,227 |
def announce(self, event, who, what, from_who, from_when): """This handler gets called after the timeout and will notice the user.""" | def announce(self, event, who, what, from_who, from_when): """This handler gets called after the timeout and will notice the user.""" | 453,228 |
def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,229 |
def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,230 |
def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,231 |
def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """This is the main handler that gets called on the above @match. This parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,232 |
def bnet_players(self, gametype): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((self.bnet_host, self.bnet_port)) s.settimeout(5) s.send('\03%s\n%s\n/con\n/quit\n' % (self.bnet_user, self.bnet_pass)) | def bnet_players(self, gametype): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((self.bnet_host, self.bnet_port)) s.settimeout(5) s.send('\03%s\n%s\n/con\n/quit\n' % (self.bnet_user, self.bnet_pass)) | 453,233 |
def __unicode__(self): return unicode(self.msg) | def __unicode__(self): return unicode(self.msg) | 453,234 |
def _add_user(self, monitor_url, user): matches = re.search(r'a=(.+)&', monitor_url) auth = matches.group(1) params = urlencode({'STUDENTID': user.econde('utf-8'), 'ADD': 'ADD STUDENT', 'a': auth.encode('utf-8'), 'monitor': '1'}) etree = get_html_parse_tree(monitor_url, treetype=u'etree', data=params) for font in etree... | def _add_user(self, monitor_url, user): matches = re.search(r'a=(.+)&', monitor_url) auth = matches.group(1) params = urlencode({'STUDENTID': user.encode('utf-8'), 'ADD': 'ADD STUDENT', 'a': auth.encode('utf-8'), 'monitor': '1'}) etree = get_html_parse_tree(monitor_url, treetype=u'etree', data=params) for font in etree... | 453,235 |
def _add_user(self, monitor_url, user): matches = re.search(r'a=(.+)&', monitor_url) auth = matches.group(1) params = urlencode({'STUDENTID': user.econde('utf-8'), 'ADD': 'ADD STUDENT', 'a': auth.encode('utf-8'), 'monitor': '1'}) etree = get_html_parse_tree(monitor_url, treetype=u'etree', data=params) for font in etree... | def _add_user(self, monitor_url, user): matches = re.search(r'a=(.+)&', monitor_url) auth = matches.group(1) params = urlencode({'STUDENTID': user.econde('utf-8'), 'ADD': 'ADD STUDENT', 'a': auth.encode('utf-8'), 'monitor': '1'}) etree = get_html_parse_tree(monitor_url, treetype=u'etree', data=params) for font in etree... | 453,236 |
def summon(self, event, who, source): if not source: source = self.default_source | def summon(self, event, who, source): if not source: source = self.default_source | 453,237 |
def load(self, name): uri = ibid.config.databases[name] echo = ibid.config.debugging.get(u'sqlalchemy_echo', False) | def load(self, name): uri = ibid.config.databases[name] echo = ibid.config.debugging.get(u'sqlalchemy_echo', False) | 453,238 |
def load(self, name): uri = ibid.config.databases[name] echo = ibid.config.debugging.get(u'sqlalchemy_echo', False) | def load(self, name): uri = ibid.config.databases[name] echo = ibid.config.debugging.get(u'sqlalchemy_echo', False) | 453,239 |
def connect(self, dbapi_con, con_record): dbapi_con.set_sql_mode("ANSI") mysql_engine = ibid.config.get('mysql_engine', 'InnoDB') c = dbapi_con.cursor() c.execute("SET storage_engine=%s;" % mysql_engine) c.execute("SET time_zone='+0:00';") c.close() | def connect(self, dbapi_con, con_record): mysql_engine = ibid.config.get('mysql_engine', 'InnoDB') c = dbapi_con.cursor() c.execute("SET storage_engine=%s;" % mysql_engine) c.execute("SET time_zone='+0:00';") c.close() | 453,240 |
def connect(self, dbapi_con, con_record): dbapi_con.set_sql_mode("ANSI") mysql_engine = ibid.config.get('mysql_engine', 'InnoDB') c = dbapi_con.cursor() c.execute("SET storage_engine=%s;" % mysql_engine) c.execute("SET time_zone='+0:00';") c.close() | def connect(self, dbapi_con, con_record): dbapi_con.set_sql_mode("ANSI") mysql_engine = ibid.config.get('mysql_engine', 'InnoDB') c = dbapi_con.cursor() c.execute("SET SESSION storage_engine=%s;" % mysql_engine) c.execute("SET SESSION time_zone='+0:00';") c.close() | 453,241 |
def connect(self, dbapi_con, con_record): dbapi_con.set_sql_mode("ANSI") mysql_engine = ibid.config.get('mysql_engine', 'InnoDB') c = dbapi_con.cursor() c.execute("SET storage_engine=%s;" % mysql_engine) c.execute("SET time_zone='+0:00';") c.close() | def connect(self, dbapi_con, con_record): dbapi_con.set_sql_mode("ANSI") mysql_engine = ibid.config.get('mysql_engine', 'InnoDB') c = dbapi_con.cursor() c.execute("SET storage_engine=%s;" % mysql_engine) c.execute("SET time_zone='+0:00';") c.close() | 453,242 |
def __init__ (self, char): self.char = char url = 'http://www.unicode.org/cgi-bin/GetUnihanData.pl?' params = {'codepoint': self.char.encode('utf8'), 'useuft8': 'true'} self.soup = get_html_parse_tree(url + urlencode(params), treetype='html5lib-beautifulsoup') self.phonetic = self.soup.find(text='Phonetic Data') \ .fin... | def __init__(self, char): self.char = char url = 'http://www.unicode.org/cgi-bin/GetUnihanData.pl?' params = {'codepoint': self.char.encode('utf8'), 'useuft8': 'true'} self.soup = get_html_parse_tree(url + urlencode(params), treetype='html5lib-beautifulsoup') self.phonetic = self.soup.find(text='Phonetic Data') \ .find... | 453,243 |
def pinyin (self): return map(fix_pinyin_tone, self.phonetic[1].contents[0].lower().split()) | def pinyin(self): return map(fix_pinyin_tone, self.phonetic[1].contents[0].lower().split()) | 453,244 |
def hangul (self): return self.other_data['kHangul'].split() | def hangul(self): return self.other_data['kHangul'].split() | 453,245 |
def korean_yale (self): return self.phonetic[5].contents[0].lower().split() | def korean_yale(self): return self.phonetic[5].contents[0].lower().split() | 453,246 |
def korean (self): return [u'%s [%s]' % (h, y) for h, y in zip(self.hangul(), self.korean_yale())] | def korean(self): return [u'%s [%s]' % (h, y) for h, y in zip(self.hangul(), self.korean_yale())] | 453,247 |
def japanese_on (self): return self.phonetic[3].contents[0].lower().split() | def japanese_on(self): return self.phonetic[3].contents[0].lower().split() | 453,248 |
def japanese_kun (self): return self.phonetic[4].contents[0].lower().split() | def japanese_kun(self): return self.phonetic[4].contents[0].lower().split() | 453,249 |
def definition (self): return self.defn | def definition(self): return self.defn | 453,250 |
def variant (self): if self.variants is None: return [] | def variant(self): if self.variants is None: return [] | 453,251 |
def variant (self): if self.variants is None: return [] | def variant (self): if self.variants is None: return [] | 453,252 |
def __unicode__ (self): msgs = [] if self.definition(): msgs = [u'it means %s' % self.definition()] | def __unicode__(self): msgs = [] if self.definition(): msgs = [u'it means %s' % self.definition()] | 453,253 |
def unichr (self, event, hexcode, hexcode2, deccode): if hexcode or hexcode2: code = int(hexcode or hexcode2, 16) else: code = int(deccode) | def unichr(self, event, hexcode, hexcode2, deccode): if hexcode or hexcode2: code = int(hexcode or hexcode2, 16) else: code = int(deccode) | 453,254 |
def ord (self, event, char): try: info = self.info(char) except UnassignedCharacter: event.addresponse(u"That character isn't in Unicode. " u"Where did you even find it?") else: if info['example']: info['example'] = "'" + info['example'] + "'" else: info['example'] = 'That' event.addresponse(u"%(example)s is %(name)s (... | def ord(self, event, char): try: info = self.info(char) except UnassignedCharacter: event.addresponse(u"That character isn't in Unicode. " u"Where did you even find it?") else: if info['example']: info['example'] = "'" + info['example'] + "'" else: info['example'] = 'That' event.addresponse(u"%(example)s is %(name)s (U... | 453,255 |
def fromname (self, event, name): try: char = unicodedata.lookup(name.upper()) except KeyError: event.addresponse(u"I couldn't find a character with that name") else: info = self.info(char) if info['example']: info['example'] = ' (' + info['example'] + ')' event.addresponse(u"%(name)s is U+%(code)s%(example)s, " u"%(ca... | def fromname(self, event, name): try: char = unicodedata.lookup(name.upper()) except KeyError: event.addresponse(u"I couldn't find a character with that name") else: info = self.info(char) if info['example']: info['example'] = ' (' + info['example'] + ')' event.addresponse(u"%(name)s is U+%(code)s%(example)s, " u"%(cat... | 453,256 |
def characters (self, event, string): event.addresponse(human_join('U+%(code)s %(name)s' % self.info(c) for c in string)) | def characters(self, event, string): event.addresponse(human_join('U+%(code)s %(name)s' % self.info(c) for c in string)) | 453,257 |
def info (self, char): cat = unicodedata.category(char) if cat == 'Cn': raise UnassignedCharacter | def info(self, char): cat = unicodedata.category(char) if cat == 'Cn': raise UnassignedCharacter | 453,258 |
def handle_man(self, event, section, page): command = [self.man, page] if section: command.insert(1, section) | def handle_man(self, event, section, page): command = [self.man, page] if section: command.insert(1, section) | 453,259 |
def flight_search(self, event, dpt, to): airport_dpt = airport_search(dpt) airport_to = airport_search(to) if len(airport_dpt) == 0: event.addresponse(u"Sorry, I don't know the airport you want to leave from") return if len(airport_to) == 0: event.addresponse(u"Sorry, I don't know the airport you want to fly to") retur... | def flight_search(self, event, dpt, to): airport_dpt = airport_search(dpt) airport_to = airport_search(to) if len(airport_dpt) == 0: event.addresponse(u"Sorry, I don't know the airport you want to leave from") return if len(airport_to) == 0: event.addresponse(u"Sorry, I don't know the airport you want to fly to") retur... | 453,260 |
def give(self, event, receiver, determiner, object): if determiner is None: determiner = '' | def give(self, event, receiver, determiner, object): if determiner is None: determiner = '' | 453,261 |
def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,262 |
def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,263 |
def test_non_messages(self): for event_type in [u'timer', u'rpc']: event = self.create_event(u'bot: foo', event_type) self.processor.process(event) self.assertFalse(hasattr(event, u'addressed')) self.assertEqual(event.message['deaddressed'], u'bot: foo') | def test_non_messages(self): for event_type in [u'timer', u'rpc']: event = self.create_event(u'bot: foo', event_type) self.processor.process(event) self.assertFalse(hasattr(event, u'addressed')) self.assertEqual(event.message['deaddressed'], u'bot: foo') | 453,264 |
def test_happy_prefix_names(self): for prefix in self.happy_prefixes: event = self.create_event(u'%s%sfoo' % prefix) self.processor.process(event) self.assert_addressed(event, prefix[0], u'foo') | def test_happy_prefix_names(self): for prefix in self.happy_prefixes: event = self.create_event((prefix[1] % prefix[0]) + u'foo') self.processor.process(event) self.assert_addressed(event, prefix[0], u'foo') | 453,265 |
def _process(self, event): for processor in ibid.processors: try: processor.process(event) except Exception, e: self.log.exception( u'Exception occured in %s processor of %s plugin.\n' u'Event: %s', processor.__class__.__name__, processor.name, event) event.complain = isinstance(e, (IOError, socket.error, JSONException... | def _process(self, event): for processor in ibid.processors: try: processor.process(event) except Exception, e: self.log.exception( u'Exception occured in %s processor of %s plugin.\n' u'Event: %s', processor.__class__.__name__, processor.name, event) event.complain = isinstance(e, (IOError, socket.error, JSONException... | 453,266 |
def setup(self): # When not addressed, match karma changes in any text if self.addressed: matchpat = r'^(.+?)\s*(%s)\s*(?:[[{(]+\s*(.+?)\s*[\]})]+)?$' else: matchpat = r'(\S+?)\s*(%s)\s*(?:[[{(]+\s*(.+?)\s*[\]})]+)?' | def setup(self): # When not addressed, match karma changes in any text if self.addressed: matchpat = r'^(.+?)\s*(%s)\s*(?:[[{(]+\s*(.+?)\s*[\]})]+)?$' else: matchpat = r'(\S+?)\s*(%s)\s*(?:[[{(]+\s*(.+?)\s*[\]})]+)?' | 453,267 |
def set(self, event, subject, adjust, reason): if self.public and not event.public: event.addresponse(u'Karma must be done in public') return | def set(self, event, subject, adjust, reason = None): if self.public and not event.public: event.addresponse(u'Karma must be done in public') return | 453,268 |
def set(self, event, subject, adjust, reason): if self.public and not event.public: event.addresponse(u'Karma must be done in public') return | def set(self, event, subject, adjust, reason): if self.public and not event.public: event.addresponse(u'Karma must be done in public') return | 453,269 |
def indefinite_article(noun_phrase): # algorithm adapted from CPAN package Lingua-EN-Inflect-1.891 by Damian Conway m = re.search('\w+', noun_phrase) if m: word = m.group(0) else: return 'an' wordi = word.lower() for anword in ("euler", "heir", "honest", "hono"): if wordi.startswith(anword): return 'an' if wordi.star... | def indefinite_article(noun_phrase): # algorithm adapted from CPAN package Lingua-EN-Inflect-1.891 by Damian Conway m = re.search('\w+', noun_phrase) if m: word = m.group(0) else: return 'an' wordi = word.lower() for anword in ("euler", "heir", "honest", "hono"): if wordi.startswith(anword): return 'an' if wordi.star... | 453,270 |
def _load_services(self): if self.protocols: return | def _load_services(self): if self.protocols: return | 453,271 |
def _load_services(self): if self.protocols: return | def _load_services(self): if self.protocols: return | 453,272 |
def _login(self, user, password): params = urlencode({u'NAME': user.encode('utf-8'), u'PASSWORD': password.encode('utf-8')}) etree = get_html_parse_tree(u'http://ace.delos.com/usacogate', data=params, treetype=u'etree') for font in etree.getiterator(u'font'): if font.text and 'Please try again' in font.text: return Non... | def _login(self, user, password): params = urlencode({'NAME': user.encode('utf-8'), 'PASSWORD': password.encode('utf-8')}) etree = get_html_parse_tree(u'http://ace.delos.com/usacogate', data=params, treetype=u'etree') for font in etree.getiterator(u'font'): if font.text and 'Please try again' in font.text: return None ... | 453,273 |
def _login(self, user, password): params = urlencode({u'NAME': user.encode('utf-8'), u'PASSWORD': password.encode('utf-8')}) etree = get_html_parse_tree(u'http://ace.delos.com/usacogate', data=params, treetype=u'etree') for font in etree.getiterator(u'font'): if font.text and 'Please try again' in font.text: return Non... | def _login(self, user, password): params = urlencode({u'NAME': user.encode('utf-8'), u'PASSWORD': password.encode('utf-8')}) etree = get_html_parse_tree(u'http://ace.delos.com/usacogate', data=params, treetype=u'etree') for font in etree.getiterator(u'font'): if font.text and u'Please try again' in font.text: return No... | 453,274 |
def _add_user(self, monitor_url, user): matches = re.search(r'a=(.+)&', monitor_url) auth = matches.group(1) params = urlencode({u'STUDENTID': user.econde('utf-8'), 'ADD': 'ADD STUDENT', u'a': auth.encode('utf-8'), u'monitor': u'1'}) etree = get_html_parse_tree(monitor_url, treetype=u'etree', data=params) for font in e... | def _add_user(self, monitor_url, user): matches = re.search(r'a=(.+)&', monitor_url) auth = matches.group(1) params = urlencode({'STUDENTID': user.econde('utf-8'), 'ADD': 'ADD STUDENT', 'a': auth.encode('utf-8'), 'monitor': '1'}) etree = get_html_parse_tree(monitor_url, treetype=u'etree', data=params) for font in etree... | 453,275 |
def get_division(self, event, user): try: usaco_user = self._get_usaco_user(event, user) except UsacoException, e: event.addresponse(e) return | def get_division(self, event, user): try: usaco_user = self._get_usaco_user(event, user) except UsacoException, e: event.addresponse(e) return | 453,276 |
def plural(count, singular, plural): "Return sigular or plural depending on count" if count == 1: return singular return plural | def plural(count, singular, plural): "Return singular or plural depending on count" if abs(count) == 1: return singular return plural | 453,277 |
def test_call_later_no_args(self): "Calling later should call stuff later." ev = self._ev() ev.channel = None ev.public = None dfr = defer.Deferred() tm = datetime.now() def _cl(_ev): _ev.did_stuff = True dfr.callback(_ev) def _cb(_ev, _self, _oev): _self.assertTrue(tm + timedelta(seconds=0.01) < datetime.now()) _self.... | def test_call_later_no_args(self): "Calling later calls stuff later." ev = self._ev() ev.channel = None ev.public = None dfr = defer.Deferred() tm = datetime.now() def _cl(_ev): _ev.did_stuff = True dfr.callback(_ev) def _cb(_ev, _self, _oev): _self.assertTrue(tm + timedelta(seconds=0.01) < datetime.now()) _self.assert... | 453,278 |
def test_call_later_args(self): "Calling later should call stuff later." ev = self._ev() ev.channel = None ev.public = None dfr = defer.Deferred() tm = datetime.now() def _cl(_ev, val): _ev.did_stuff = val dfr.callback(_ev) def _cb(_ev, _self, _oev): _self.assertTrue(tm + timedelta(seconds=0.01) < datetime.now()) _self... | def test_call_later_args(self): "Calling later with args calls stuff later." ev = self._ev() ev.channel = None ev.public = None dfr = defer.Deferred() tm = datetime.now() def _cl(_ev, val): _ev.did_stuff = val dfr.callback(_ev) def _cb(_ev, _self, _oev): _self.assertTrue(tm + timedelta(seconds=0.01) < datetime.now()) _... | 453,279 |
def test_call_later_kwargs(self): "Calling later should call stuff later." ev = self._ev() ev.channel = None ev.public = None dfr = defer.Deferred() tm = datetime.now() def _cl(_ev, val='default'): _ev.did_stuff = val dfr.callback(_ev) def _cb(_ev, _self, _oev): _self.assertTrue(tm + timedelta(seconds=0.01) < datetime.... | def test_call_later_kwargs(self): "Calling later with kwargs calls stuff later." ev = self._ev() ev.channel = None ev.public = None dfr = defer.Deferred() tm = datetime.now() def _cl(_ev, val='default'): _ev.did_stuff = val dfr.callback(_ev) def _cb(_ev, _self, _oev): _self.assertTrue(tm + timedelta(seconds=0.01) < dat... | 453,280 |
def draw(self, event, url, colour, width, height): if not urlparse(url).netloc: url = 'http://' + url if urlparse(url).netloc != 'file': event.addresponse(u'Are you trying to haxor me?') return if not urlparse(url).path: url += '/' | def draw(self, event, url, colour, width, height): if not urlparse(url).netloc: url = 'http://' + url if urlparse(url).scheme == 'file': event.addresponse(u'Are you trying to haxor me?') return if not urlparse(url).path: url += '/' | 453,281 |
def ladder(self, event, reverse): karmas = event.session.query(Karma) if reverse: karmas = karmas.order_by(Karma.value.asc()) else: karmas = karmas.order_by(Karma.value.desc()) karmas = karmas.limit(30).all() | def ladder(self, event, reverse): karmas = event.session.query(Karma) if reverse: karmas = karmas.order_by(Karma.value.asc()) else: karmas = karmas.order_by(Karma.value.desc()) karmas = karmas.limit(30).all() | 453,282 |
def get_logfile(self, event): self.lock.acquire() try: when = event.time if not self.date_utc: when = when.replace(tzinfo=tzutc()).astimezone(tzlocal()) | def get_logfile(self, event): self.lock.acquire() try: when = event.time if not self.date_utc: when = when.replace(tzinfo=tzutc()).astimezone(tzlocal()) | 453,283 |
def coffee_accept(self, event): if (event.source, event.channel) not in self.pots: event.addresponse(u"There isn't a pot on") | def coffee_accept(self, event): if (event.source, event.channel) not in self.pots: event.addresponse(u"There isn't a pot on") | 453,284 |
def announce(self, event, who, what, from_who, from_when): """handler that gets called after the timeout""" | def announce(self, event, who, what, from_who, from_when): """handler that gets called after the timeout""" | 453,285 |
def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,286 |
def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,287 |
def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,288 |
def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,289 |
def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | def remind(self, event, who, at, when, how, what): """main handler this parses the date and sets up the "announce" function to be fired when the time is up.""" | 453,290 |
def setup(self): self.patterns = [ re.compile(r'^(%s)([:;.?>!,-]+)*\s*' % '|'.join(self.names), re.I | re.DOTALL), # "hello there, bot"-style addressing. But we want to be sure that # there wasn't normal addressing too: re.compile(r'^(?:\S+:.*|.*,\s*(%s))\s*$' % '|'.join(self.names), re.I | re.DOTALL) ] | def setup(self): self.patterns = [ re.compile(r'^(%s)([:;.?>!,-]+)?\s*' % '|'.join(self.names), re.I | re.DOTALL), # "hello there, bot"-style addressing. But we want to be sure that # there wasn't normal addressing too: re.compile(r'^(?:\S+:.*|.*,\s*(%s))\s*$' % '|'.join(self.names), re.I | re.DOTALL) ] | 453,291 |
def __init__(self, from_id, to_id, memo, private=False): self.from_id = from_id self.to_id = to_id self.memo = memo self.private = private self.delivered = False self.time = datetime.utcnow() | def __init__(self, from_id, to_id, memo, private=False): self.from_id = from_id self.to_id = to_id self.memo = memo self.private = private self.delivered = False self.time = datetime.utcnow() | 453,292 |
def dinner (self, who, event, veg): url = 'http://www.whatthefuckshouldimakefordinner.com/' if veg: url += 'veg.php' | def dinner (self, event, who, veg): url = 'http://www.whatthefuckshouldimakefordinner.com/' if veg: url += 'veg.php' | 453,293 |
def _interpolate(message, event): "Expand factoid variables" utcnow = datetime.utcnow() now = utcnow.replace(tzinfo=tzutc()).astimezone(tzlocal()) substitutions = [(u'who', event.sender['nick']), (u'channel', event.channel), (u'source', event.source), (u'year', unicode(now.year)), (u'month2', u'%02i' % now.month), (u'... | def _interpolate(message, event): "Expand factoid variables" utcnow = datetime.utcnow() now = utcnow.replace(tzinfo=tzutc()).astimezone(tzlocal()) substitutions = [(u'who', event.sender['nick']), (u'channel', event.channel), (u'source', event.source), (u'year', unicode(now.year)), (u'month2', u'%02i' % now.month), (u'... | 453,294 |
def _post_url(self, event, url=None): "Posts a URL to delicious.com" | def _post_url(self, event, url=None): "Posts a URL to delicious.com" | 453,295 |
def int_duration(self): hours, minutes = 0, 0 match = re.search(r'(\d+)hr', self.duration) if match: hours = int(match.group(1)) match = re.search(r'(\d+)min', self.duration) if match: minutes = int(match.group(1)) return int(hours)*60 + int(minutes) | def int_duration(self): hours, minutes = 0, 0 match = re.search(r'(\d+)hr', self.duration) if match: hours = int(match.group(1)) match = re.search(r'(\d+)min', self.duration) if match: minutes = int(match.group(1)) return int(hours)*60 + int(minutes) | 453,296 |
def int_duration(self): hours, minutes = 0, 0 match = re.search(r'(\d+)hr', self.duration) if match: hours = int(match.group(1)) match = re.search(r'(\d+)min', self.duration) if match: minutes = int(match.group(1)) return int(hours)*60 + int(minutes) | def int_duration(self): hours, minutes = 0, 0 match = re.search(r'(\d+)hr', self.duration) if match: hours = int(match.group(1)) match = re.search(r'(\d+)min', self.duration) if match: minutes = int(match.group(1)) return int(hours)*60 + int(minutes) | 453,297 |
def coffee_accept(self, event): if (event.source, event.channel) not in self.pots: event.addresponse(u"There isn't a pot on") | def coffee_accept(self, event): if (event.source, event.channel) not in self.pots: event.addresponse(u"There isn't a pot on") | 453,298 |
def setup(self): # When not addressed, match karma changes in any text if self.addressed: matchpat = r'^(.+?)\s*(%s)\s*(?:[[{(]+\s*(.+?)\s*[\]})]+)?$' else: matchpat = r'(\S+?)\s*(%s)' | def setup(self): # When not addressed, match karma changes in any text if self.addressed: matchpat = r'^(.+?)\s*(%s)\s*(?:[[{(]+\s*(.+?)\s*[\]})]+)?$' else: matchpat = r'(\S+?)\s*(%s)' | 453,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.