repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
yougov/pmxbot
pmxbot/commands.py
urbandict
def urbandict(rest): "Define a word with Urban Dictionary" word = rest.strip() definition = util.urban_lookup(word) if not definition: return "Arg! I didn't find a definition for that." return 'Urban Dictionary says {word}: {definition}'.format(**locals())
python
def urbandict(rest): "Define a word with Urban Dictionary" word = rest.strip() definition = util.urban_lookup(word) if not definition: return "Arg! I didn't find a definition for that." return 'Urban Dictionary says {word}: {definition}'.format(**locals())
Define a word with Urban Dictionary
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L732-L738
yougov/pmxbot
pmxbot/commands.py
acit
def acit(rest): "Look up an acronym" word = rest.strip() res = util.lookup_acronym(word) if res is None: return "Arg! I couldn't expand that..." else: return ' | '.join(res)
python
def acit(rest): "Look up an acronym" word = rest.strip() res = util.lookup_acronym(word) if res is None: return "Arg! I couldn't expand that..." else: return ' | '.join(res)
Look up an acronym
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L742-L749
yougov/pmxbot
pmxbot/commands.py
fight
def fight(nick, rest): "Pit two sworn enemies against each other (separate with 'vs.')" if rest: vtype = random.choice(phrases.fight_victories) fdesc = random.choice(phrases.fight_descriptions) # valid separators are vs., v., and vs pattern = re.compile('(.*) (?:vs[.]?|v[.]) (.*)') matcher = pattern.match(r...
python
def fight(nick, rest): "Pit two sworn enemies against each other (separate with 'vs.')" if rest: vtype = random.choice(phrases.fight_victories) fdesc = random.choice(phrases.fight_descriptions) # valid separators are vs., v., and vs pattern = re.compile('(.*) (?:vs[.]?|v[.]) (.*)') matcher = pattern.match(r...
Pit two sworn enemies against each other (separate with 'vs.')
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L753-L770
yougov/pmxbot
pmxbot/commands.py
progress
def progress(rest): "Display the progress of something: start|end|percent" if rest: left, right, amount = [piece.strip() for piece in rest.split('|')] ticks = min(int(round(float(amount) / 10)), 10) bar = "=" * ticks return "%s [%-10s] %s" % (left, bar, right)
python
def progress(rest): "Display the progress of something: start|end|percent" if rest: left, right, amount = [piece.strip() for piece in rest.split('|')] ticks = min(int(round(float(amount) / 10)), 10) bar = "=" * ticks return "%s [%-10s] %s" % (left, bar, right)
Display the progress of something: start|end|percent
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L774-L780
yougov/pmxbot
pmxbot/commands.py
nastygram
def nastygram(nick, rest): """ A random passive-agressive comment, optionally directed toward some(one|thing). """ recipient = "" if rest: recipient = rest.strip() karma.Karma.store.change(recipient, -1) return util.passagg(recipient, nick.lower())
python
def nastygram(nick, rest): """ A random passive-agressive comment, optionally directed toward some(one|thing). """ recipient = "" if rest: recipient = rest.strip() karma.Karma.store.change(recipient, -1) return util.passagg(recipient, nick.lower())
A random passive-agressive comment, optionally directed toward some(one|thing).
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L784-L793
yougov/pmxbot
pmxbot/commands.py
meaculpa
def meaculpa(nick, rest): "Sincerely apologize" if rest: rest = rest.strip() if rest: return random.choice(phrases.direct_apologies) % dict(a=nick, b=rest) else: return random.choice(phrases.apologies) % dict(a=nick)
python
def meaculpa(nick, rest): "Sincerely apologize" if rest: rest = rest.strip() if rest: return random.choice(phrases.direct_apologies) % dict(a=nick, b=rest) else: return random.choice(phrases.apologies) % dict(a=nick)
Sincerely apologize
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L835-L843
yougov/pmxbot
pmxbot/commands.py
version
def version(rest): "Get the version of pmxbot or one of its plugins" pkg = rest.strip() or 'pmxbot' if pkg.lower() == 'python': return sys.version.split()[0] return importlib_metadata.version(pkg)
python
def version(rest): "Get the version of pmxbot or one of its plugins" pkg = rest.strip() or 'pmxbot' if pkg.lower() == 'python': return sys.version.split()[0] return importlib_metadata.version(pkg)
Get the version of pmxbot or one of its plugins
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L847-L852
yougov/pmxbot
pmxbot/commands.py
timezone
def timezone(rest): """Convert date between timezones. Example: > !tz 11:00am UTC in PDT 11:00 UTC -> 4:00 PDT UTC is implicit > !tz 11:00am in PDT 11:00 UTC -> 4:00 PDT > !tz 11:00am PDT 11:00 PDT -> 18:00 UTC """ if ' in ' in rest: dstr, tzname = rest.split(' in ', 1) else: dstr, tzname = rest, ...
python
def timezone(rest): """Convert date between timezones. Example: > !tz 11:00am UTC in PDT 11:00 UTC -> 4:00 PDT UTC is implicit > !tz 11:00am in PDT 11:00 UTC -> 4:00 PDT > !tz 11:00am PDT 11:00 PDT -> 18:00 UTC """ if ' in ' in rest: dstr, tzname = rest.split(' in ', 1) else: dstr, tzname = rest, ...
Convert date between timezones. Example: > !tz 11:00am UTC in PDT 11:00 UTC -> 4:00 PDT UTC is implicit > !tz 11:00am in PDT 11:00 UTC -> 4:00 PDT > !tz 11:00am PDT 11:00 PDT -> 18:00 UTC
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/commands.py#L898-L927
yougov/pmxbot
pmxbot/storage.py
SelectableStorage.finalize
def finalize(cls): "Delete the various persistence objects" for finalizer in cls._finalizers: try: finalizer() except Exception: log.exception("Error in finalizer %s", finalizer)
python
def finalize(cls): "Delete the various persistence objects" for finalizer in cls._finalizers: try: finalizer() except Exception: log.exception("Error in finalizer %s", finalizer)
Delete the various persistence objects
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/storage.py#L51-L57
yougov/pmxbot
pmxbot/system.py
help
def help(rest): """Help (this command)""" rs = rest.strip() if rs: # give help for matching commands for handler in Handler._registry: if handler.name == rs.lower(): yield '!%s: %s' % (handler.name, handler.doc) break else: yield "command not found" return # give help for all commands def mk...
python
def help(rest): """Help (this command)""" rs = rest.strip() if rs: # give help for matching commands for handler in Handler._registry: if handler.name == rs.lower(): yield '!%s: %s' % (handler.name, handler.doc) break else: yield "command not found" return # give help for all commands def mk...
Help (this command)
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/system.py#L17-L49
yougov/pmxbot
pmxbot/web/viewer.py
pmon
def pmon(month): """ P the month >>> print(pmon('2012-08')) August, 2012 """ year, month = month.split('-') return '{month_name}, {year}'.format( month_name=calendar.month_name[int(month)], year=year, )
python
def pmon(month): """ P the month >>> print(pmon('2012-08')) August, 2012 """ year, month = month.split('-') return '{month_name}, {year}'.format( month_name=calendar.month_name[int(month)], year=year, )
P the month >>> print(pmon('2012-08')) August, 2012
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/web/viewer.py#L54-L65
yougov/pmxbot
pmxbot/web/viewer.py
pday
def pday(dayfmt): """ P the day >>> print(pday('2012-08-24')) Friday the 24th """ year, month, day = map(int, dayfmt.split('-')) return '{day} the {number}'.format( day=calendar.day_name[calendar.weekday(year, month, day)], number=inflect.engine().ordinal(day), )
python
def pday(dayfmt): """ P the day >>> print(pday('2012-08-24')) Friday the 24th """ year, month, day = map(int, dayfmt.split('-')) return '{day} the {number}'.format( day=calendar.day_name[calendar.weekday(year, month, day)], number=inflect.engine().ordinal(day), )
P the day >>> print(pday('2012-08-24')) Friday the 24th
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/web/viewer.py#L68-L80
yougov/pmxbot
pmxbot/web/viewer.py
patch_compat
def patch_compat(config): """ Support older config values. """ if 'web_host' in config: config['host'] = config.pop('web_host') if 'web_port' in config: config['port'] = config.pop('web_port')
python
def patch_compat(config): """ Support older config values. """ if 'web_host' in config: config['host'] = config.pop('web_host') if 'web_port' in config: config['port'] = config.pop('web_port')
Support older config values.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/web/viewer.py#L305-L312
yougov/pmxbot
pmxbot/web/viewer.py
resolve_file
def resolve_file(mgr, filename): """ Given a file manager (ExitStack), load the filename and set the exit stack to clean up. See https://importlib-resources.readthedocs.io/en/latest/migration.html#pkg-resources-resource-filename for more details. """ path = importlib_resources.path('pmxbot.web.templates', filena...
python
def resolve_file(mgr, filename): """ Given a file manager (ExitStack), load the filename and set the exit stack to clean up. See https://importlib-resources.readthedocs.io/en/latest/migration.html#pkg-resources-resource-filename for more details. """ path = importlib_resources.path('pmxbot.web.templates', filena...
Given a file manager (ExitStack), load the filename and set the exit stack to clean up. See https://importlib-resources.readthedocs.io/en/latest/migration.html#pkg-resources-resource-filename for more details.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/web/viewer.py#L339-L347
yougov/pmxbot
pmxbot/web/viewer.py
ChannelPage.date_key
def date_key(cls, month_string): """ Return a key suitable for sorting by month. >>> k1 = ChannelPage.date_key('September, 2012') >>> k2 = ChannelPage.date_key('August, 2013') >>> k2 > k1 True """ month, year = month_string.split(',') month_ord = cls.month_ordinal[month] return year, month_ord
python
def date_key(cls, month_string): """ Return a key suitable for sorting by month. >>> k1 = ChannelPage.date_key('September, 2012') >>> k2 = ChannelPage.date_key('August, 2013') >>> k2 > k1 True """ month, year = month_string.split(',') month_ord = cls.month_ordinal[month] return year, month_ord
Return a key suitable for sorting by month. >>> k1 = ChannelPage.date_key('September, 2012') >>> k2 = ChannelPage.date_key('August, 2013') >>> k2 > k1 True
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/web/viewer.py#L110-L121
yougov/pmxbot
pmxbot/web/viewer.py
LegacyPage.forward
def forward(self, channel, date_s, fragment): """ Given an HREF in the legacy timezone, redirect to an href for UTC. """ time_s, sep, nick = fragment.rpartition('.') time = datetime.datetime.strptime(time_s, '%H.%M.%S') date = datetime.datetime.strptime(date_s, '%Y-%m-%d') dt = datetime.datetime.combine(d...
python
def forward(self, channel, date_s, fragment): """ Given an HREF in the legacy timezone, redirect to an href for UTC. """ time_s, sep, nick = fragment.rpartition('.') time = datetime.datetime.strptime(time_s, '%H.%M.%S') date = datetime.datetime.strptime(date_s, '%Y-%m-%d') dt = datetime.datetime.combine(d...
Given an HREF in the legacy timezone, redirect to an href for UTC.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/web/viewer.py#L256-L272
yougov/pmxbot
pmxbot/logging.py
parse_date
def parse_date(record): "Parse a date from sqlite. Assumes the date is in US/Pacific time zone." dt = record.pop('datetime') fmts = [ '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M:%S', ] for fmt in fmts: try: dt = datetime.datetime.strptime(dt, fmt) break except ValueError: pass else: raise tz = pyt...
python
def parse_date(record): "Parse a date from sqlite. Assumes the date is in US/Pacific time zone." dt = record.pop('datetime') fmts = [ '%Y-%m-%d %H:%M:%S.%f', '%Y-%m-%d %H:%M:%S', ] for fmt in fmts: try: dt = datetime.datetime.strptime(dt, fmt) break except ValueError: pass else: raise tz = pyt...
Parse a date from sqlite. Assumes the date is in US/Pacific time zone.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/logging.py#L219-L237
yougov/pmxbot
pmxbot/logging.py
strike
def strike(channel, nick, rest): "Strike last <n> statements from the record" yield NoLog rest = rest.strip() if not rest: count = 1 else: if not rest.isdigit(): yield "Strike how many? Argument must be a positive integer." raise StopIteration count = int(rest) try: struck = Logger.store.strike(cha...
python
def strike(channel, nick, rest): "Strike last <n> statements from the record" yield NoLog rest = rest.strip() if not rest: count = 1 else: if not rest.isdigit(): yield "Strike how many? Argument must be a positive integer." raise StopIteration count = int(rest) try: struck = Logger.store.strike(cha...
Strike last <n> statements from the record
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/logging.py#L468-L488
yougov/pmxbot
pmxbot/logging.py
where
def where(channel, nick, rest): "When did pmxbot last see <nick> speak?" onick = rest.strip() last = Logger.store.last_seen(onick) if last: tm, chan = last tmpl = "I last saw {onick} speak at {tm} in channel #{chan}" return tmpl.format(tm=tm, chan=chan, onick=onick) else: return "Sorry! I don't have any r...
python
def where(channel, nick, rest): "When did pmxbot last see <nick> speak?" onick = rest.strip() last = Logger.store.last_seen(onick) if last: tm, chan = last tmpl = "I last saw {onick} speak at {tm} in channel #{chan}" return tmpl.format(tm=tm, chan=chan, onick=onick) else: return "Sorry! I don't have any r...
When did pmxbot last see <nick> speak?
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/logging.py#L492-L501
yougov/pmxbot
pmxbot/logging.py
logs
def logs(channel): "Where can one find the logs?" default_url = 'http://' + socket.getfqdn() base = pmxbot.config.get('logs URL', default_url) logged_channel = channel in pmxbot.config.log_channels path = '/channel/' + channel.lstrip('#') if logged_channel else '/' return urllib.parse.urljoin(base, path)
python
def logs(channel): "Where can one find the logs?" default_url = 'http://' + socket.getfqdn() base = pmxbot.config.get('logs URL', default_url) logged_channel = channel in pmxbot.config.log_channels path = '/channel/' + channel.lstrip('#') if logged_channel else '/' return urllib.parse.urljoin(base, path)
Where can one find the logs?
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/logging.py#L524-L530
yougov/pmxbot
pmxbot/logging.py
log
def log(channel, rest): """ Enable or disable logging for a channel; use 'please' to start logging and 'stop please' to stop. """ words = [s.lower() for s in rest.split()] if 'please' not in words: return include = 'stop' not in rest existing = set(pmxbot.config.log_channels) # add the channel if include, ot...
python
def log(channel, rest): """ Enable or disable logging for a channel; use 'please' to start logging and 'stop please' to stop. """ words = [s.lower() for s in rest.split()] if 'please' not in words: return include = 'stop' not in rest existing = set(pmxbot.config.log_channels) # add the channel if include, ot...
Enable or disable logging for a channel; use 'please' to start logging and 'stop please' to stop.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/logging.py#L534-L546
yougov/pmxbot
pmxbot/logging.py
MongoDBLogger._add_recent
def _add_recent(self, doc, logged_id): "Keep a tab on the most recent message for each channel" spec = dict(channel=doc['channel']) doc['ref'] = logged_id doc.pop('_id') self._recent.replace_one(spec, doc, upsert=True)
python
def _add_recent(self, doc, logged_id): "Keep a tab on the most recent message for each channel" spec = dict(channel=doc['channel']) doc['ref'] = logged_id doc.pop('_id') self._recent.replace_one(spec, doc, upsert=True)
Keep a tab on the most recent message for each channel
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/logging.py#L256-L261
yougov/pmxbot
pmxbot/logging.py
FullTextMongoDBLogger._has_fulltext
def _has_fulltext(cls, uri): """ Enable full text search on the messages if possible and return True. If the full text search cannot be enabled, then return False. """ coll = cls._get_collection(uri) with ExceptionTrap(storage.pymongo.errors.OperationFailure) as trap: coll.create_index([('message', 'text...
python
def _has_fulltext(cls, uri): """ Enable full text search on the messages if possible and return True. If the full text search cannot be enabled, then return False. """ coll = cls._get_collection(uri) with ExceptionTrap(storage.pymongo.errors.OperationFailure) as trap: coll.create_index([('message', 'text...
Enable full text search on the messages if possible and return True. If the full text search cannot be enabled, then return False.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/logging.py#L422-L430
yougov/pmxbot
pmxbot/slack.py
Bot._find_user_channel
def _find_user_channel(self, username): """ Use slacker to resolve the username to an opened IM channel """ user_id = self.slacker.users.get_user_id(username) im = user_id and self.slacker.im.open(user_id).body['channel']['id'] return im and self.slack.server.channels.find(im)
python
def _find_user_channel(self, username): """ Use slacker to resolve the username to an opened IM channel """ user_id = self.slacker.users.get_user_id(username) im = user_id and self.slacker.im.open(user_id).body['channel']['id'] return im and self.slack.server.channels.find(im)
Use slacker to resolve the username to an opened IM channel
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/slack.py#L65-L71
yougov/pmxbot
pmxbot/slack.py
Bot.transmit
def transmit(self, channel, message): """ Send the message to Slack. :param channel: channel or user to whom the message should be sent. If a ``thread`` attribute is present, that thread ID is used. :param str message: message to send. """ target = ( self.slack.server.channels.find(channel) or sel...
python
def transmit(self, channel, message): """ Send the message to Slack. :param channel: channel or user to whom the message should be sent. If a ``thread`` attribute is present, that thread ID is used. :param str message: message to send. """ target = ( self.slack.server.channels.find(channel) or sel...
Send the message to Slack. :param channel: channel or user to whom the message should be sent. If a ``thread`` attribute is present, that thread ID is used. :param str message: message to send.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/slack.py#L73-L87
yougov/pmxbot
pmxbot/util.py
wchoice
def wchoice(d): """ Given a dictionary of word: proportion, return a word randomly selected from the keys weighted by proportion. >>> wchoice({'a': 0, 'b': 1}) 'b' >>> choices = [wchoice({'a': 1, 'b': 2}) for x in range(1000)] Statistically speaking, choices should be .5 a:b >>> ratio = choices.count('a') / c...
python
def wchoice(d): """ Given a dictionary of word: proportion, return a word randomly selected from the keys weighted by proportion. >>> wchoice({'a': 0, 'b': 1}) 'b' >>> choices = [wchoice({'a': 1, 'b': 2}) for x in range(1000)] Statistically speaking, choices should be .5 a:b >>> ratio = choices.count('a') / c...
Given a dictionary of word: proportion, return a word randomly selected from the keys weighted by proportion. >>> wchoice({'a': 0, 'b': 1}) 'b' >>> choices = [wchoice({'a': 1, 'b': 2}) for x in range(1000)] Statistically speaking, choices should be .5 a:b >>> ratio = choices.count('a') / choices.count('b') >>>...
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/util.py#L20-L41
yougov/pmxbot
pmxbot/util.py
splitem
def splitem(query): """ Split a query into choices >>> splitem('dog, cat') ['dog', 'cat'] Disregards trailing punctuation. >>> splitem('dogs, cats???') ['dogs', 'cats'] >>> splitem('cats!!!') ['cats'] Allow or >>> splitem('dogs, cats or prarie dogs?') ['dogs', 'cats', 'prarie dogs'] Honors serial comm...
python
def splitem(query): """ Split a query into choices >>> splitem('dog, cat') ['dog', 'cat'] Disregards trailing punctuation. >>> splitem('dogs, cats???') ['dogs', 'cats'] >>> splitem('cats!!!') ['cats'] Allow or >>> splitem('dogs, cats or prarie dogs?') ['dogs', 'cats', 'prarie dogs'] Honors serial comm...
Split a query into choices >>> splitem('dog, cat') ['dog', 'cat'] Disregards trailing punctuation. >>> splitem('dogs, cats???') ['dogs', 'cats'] >>> splitem('cats!!!') ['cats'] Allow or >>> splitem('dogs, cats or prarie dogs?') ['dogs', 'cats', 'prarie dogs'] Honors serial commas >>> splitem('dogs, cat...
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/util.py#L44-L75
yougov/pmxbot
pmxbot/util.py
lookup
def lookup(word): ''' Get a definition for a word (uses Wordnik) ''' _patch_wordnik() # Jason's key - do not abuse key = 'edc4b9b94b341eeae350e087c2e05d2f5a2a9e0478cefc6dc' client = wordnik.swagger.ApiClient(key, 'http://api.wordnik.com/v4') words = wordnik.WordApi.WordApi(client) definitions = words.getDefini...
python
def lookup(word): ''' Get a definition for a word (uses Wordnik) ''' _patch_wordnik() # Jason's key - do not abuse key = 'edc4b9b94b341eeae350e087c2e05d2f5a2a9e0478cefc6dc' client = wordnik.swagger.ApiClient(key, 'http://api.wordnik.com/v4') words = wordnik.WordApi.WordApi(client) definitions = words.getDefini...
Get a definition for a word (uses Wordnik)
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/util.py#L107-L120
yougov/pmxbot
pmxbot/util.py
urban_lookup
def urban_lookup(word): ''' Return a Urban Dictionary definition for a word or None if no result was found. ''' url = "http://api.urbandictionary.com/v0/define" params = dict(term=word) resp = requests.get(url, params=params) resp.raise_for_status() res = resp.json() if not res['list']: return return res['...
python
def urban_lookup(word): ''' Return a Urban Dictionary definition for a word or None if no result was found. ''' url = "http://api.urbandictionary.com/v0/define" params = dict(term=word) resp = requests.get(url, params=params) resp.raise_for_status() res = resp.json() if not res['list']: return return res['...
Return a Urban Dictionary definition for a word or None if no result was found.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/util.py#L126-L138
yougov/pmxbot
pmxbot/util.py
passagg
def passagg(recipient, sender): """ Generate a passive-aggressive statement to recipient from sender. """ adj = random.choice(pmxbot.phrases.adjs) if random.choice([False, True]): # address the recipient last lead = "" trail = recipient if not recipient else ", %s" % recipient else: # address the recipien...
python
def passagg(recipient, sender): """ Generate a passive-aggressive statement to recipient from sender. """ adj = random.choice(pmxbot.phrases.adjs) if random.choice([False, True]): # address the recipient last lead = "" trail = recipient if not recipient else ", %s" % recipient else: # address the recipien...
Generate a passive-aggressive statement to recipient from sender.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/util.py#L165-L183
yougov/pmxbot
pmxbot/config_.py
config
def config(client, event, channel, nick, rest): "Change the running config, something like a=b or a+=b or a-=b" pattern = re.compile(r'(?P<key>\w+)\s*(?P<op>[+-]?=)\s*(?P<value>.*)$') match = pattern.match(rest) if not match: return "Command not recognized" res = match.groupdict() key = res['key'] op = res['op...
python
def config(client, event, channel, nick, rest): "Change the running config, something like a=b or a+=b or a-=b" pattern = re.compile(r'(?P<key>\w+)\s*(?P<op>[+-]?=)\s*(?P<value>.*)$') match = pattern.match(rest) if not match: return "Command not recognized" res = match.groupdict() key = res['key'] op = res['op...
Change the running config, something like a=b or a+=b or a-=b
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/config_.py#L10-L33
yougov/pmxbot
pmxbot/itertools.py
trap_exceptions
def trap_exceptions(results, handler, exceptions=Exception): """ Iterate through the results, but if an exception occurs, stop processing the results and instead replace the results with the output from the exception handler. """ try: for result in results: yield result except exceptions as exc: for resul...
python
def trap_exceptions(results, handler, exceptions=Exception): """ Iterate through the results, but if an exception occurs, stop processing the results and instead replace the results with the output from the exception handler. """ try: for result in results: yield result except exceptions as exc: for resul...
Iterate through the results, but if an exception occurs, stop processing the results and instead replace the results with the output from the exception handler.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/itertools.py#L13-L24
yougov/pmxbot
pmxbot/quotes.py
quote
def quote(rest): """ If passed with nothing then get a random quote. If passed with some string then search for that. If prepended with "add:" then add it to the db, eg "!quote add: drivers: I only work here because of pmxbot!". Delete an individual quote by prepending "del:" and passing a search matching exactly...
python
def quote(rest): """ If passed with nothing then get a random quote. If passed with some string then search for that. If prepended with "add:" then add it to the db, eg "!quote add: drivers: I only work here because of pmxbot!". Delete an individual quote by prepending "del:" and passing a search matching exactly...
If passed with nothing then get a random quote. If passed with some string then search for that. If prepended with "add:" then add it to the db, eg "!quote add: drivers: I only work here because of pmxbot!". Delete an individual quote by prepending "del:" and passing a search matching exactly one query.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/quotes.py#L199-L220
yougov/pmxbot
pmxbot/quotes.py
MongoDBQuotes.delete
def delete(self, lookup): """ If exactly one quote matches, delete it. Otherwise, raise a ValueError. """ lookup, num = self.split_num(lookup) if num: result = self.find_matches(lookup)[num - 1] else: result, = self.find_matches(lookup) self.db.delete_one(result)
python
def delete(self, lookup): """ If exactly one quote matches, delete it. Otherwise, raise a ValueError. """ lookup, num = self.split_num(lookup) if num: result = self.find_matches(lookup)[num - 1] else: result, = self.find_matches(lookup) self.db.delete_one(result)
If exactly one quote matches, delete it. Otherwise, raise a ValueError.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/quotes.py#L153-L163
yougov/pmxbot
pmxbot/stack.py
parse_index
def parse_index(index, items): """Return a list of 0-based index numbers from a (1-based) `index` str. * A single item index, like `[3]`. Negative indices count backward from the bottom; that is, the bottom-most item in a 3-item stack can be identified by `[3]` or `[-1]`. * A slice, shorthand f...
python
def parse_index(index, items): """Return a list of 0-based index numbers from a (1-based) `index` str. * A single item index, like `[3]`. Negative indices count backward from the bottom; that is, the bottom-most item in a 3-item stack can be identified by `[3]` or `[-1]`. * A slice, shorthand f...
Return a list of 0-based index numbers from a (1-based) `index` str. * A single item index, like `[3]`. Negative indices count backward from the bottom; that is, the bottom-most item in a 3-item stack can be identified by `[3]` or `[-1]`. * A slice, shorthand for the entire inclusive range between ...
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/stack.py#L214-L281
yougov/pmxbot
pmxbot/stack.py
stack
def stack(nick, rest): 'Manage short lists in pmxbot. See !stack help for more info' atoms = [atom.strip() for atom in rest.split(' ', 1) if atom.strip()] if len(atoms) == 0: subcommand = "show" rest = "" elif len(atoms) == 1: subcommand = atoms[0] rest = "" else: ...
python
def stack(nick, rest): 'Manage short lists in pmxbot. See !stack help for more info' atoms = [atom.strip() for atom in rest.split(' ', 1) if atom.strip()] if len(atoms) == 0: subcommand = "show" rest = "" elif len(atoms) == 1: subcommand = atoms[0] rest = "" else: ...
Manage short lists in pmxbot. See !stack help for more info
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/stack.py#L293-L393
yougov/pmxbot
pmxbot/irc.py
LoggingCommandBot._get_wrapper
def _get_wrapper(): """ Get a socket wrapper based on SSL config. """ if not pmxbot.config.get('use_ssl', False): return lambda x: x return importlib.import_module('ssl').wrap_socket
python
def _get_wrapper(): """ Get a socket wrapper based on SSL config. """ if not pmxbot.config.get('use_ssl', False): return lambda x: x return importlib.import_module('ssl').wrap_socket
Get a socket wrapper based on SSL config.
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/irc.py#L79-L85
yougov/pmxbot
pmxbot/irc.py
LoggingCommandBot.transmit
def transmit(self, channel, msg): r""" Transmit the message (or action) and return what was transmitted. >>> ap = LoggingCommandBot.action_pattern >>> ap.match('foo').groups() (None, 'foo') >>> ap.match('foo\nbar\n').group(2) 'foo\nbar\n' >>> is_action, msg = ap.match('/me is feeling fine today').grou...
python
def transmit(self, channel, msg): r""" Transmit the message (or action) and return what was transmitted. >>> ap = LoggingCommandBot.action_pattern >>> ap.match('foo').groups() (None, 'foo') >>> ap.match('foo\nbar\n').group(2) 'foo\nbar\n' >>> is_action, msg = ap.match('/me is feeling fine today').grou...
r""" Transmit the message (or action) and return what was transmitted. >>> ap = LoggingCommandBot.action_pattern >>> ap.match('foo').groups() (None, 'foo') >>> ap.match('foo\nbar\n').group(2) 'foo\nbar\n' >>> is_action, msg = ap.match('/me is feeling fine today').groups() >>> bool(is_action) True ...
https://github.com/yougov/pmxbot/blob/5da84a3258a0fd73cb35b60e39769a5d7bfb2ba7/pmxbot/irc.py#L89-L117
MeaningCloud/meaningcloud-python
meaningcloud/Response.py
Response.getStatusCode
def getStatusCode(self): """ Returns the code of the status or None if it does not exist :return: Status code of the response """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('code' in self._response['status'].keys...
python
def getStatusCode(self): """ Returns the code of the status or None if it does not exist :return: Status code of the response """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('code' in self._response['status'].keys...
Returns the code of the status or None if it does not exist :return: Status code of the response
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Response.py#L37-L52
MeaningCloud/meaningcloud-python
meaningcloud/Response.py
Response.getStatusMsg
def getStatusMsg(self): """ Returns the message of the status or an empty string if it does not exist :return: Status message of the response """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('msg' in self._response...
python
def getStatusMsg(self): """ Returns the message of the status or an empty string if it does not exist :return: Status message of the response """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('msg' in self._response...
Returns the message of the status or an empty string if it does not exist :return: Status message of the response
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Response.py#L54-L66
MeaningCloud/meaningcloud-python
meaningcloud/Response.py
Response.getConsumedCredits
def getConsumedCredits(self): """ Returns the credit consumed by the request made :return: String with the number of credits consumed """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('credits' in self._response['st...
python
def getConsumedCredits(self): """ Returns the credit consumed by the request made :return: String with the number of credits consumed """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('credits' in self._response['st...
Returns the credit consumed by the request made :return: String with the number of credits consumed
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Response.py#L68-L85
MeaningCloud/meaningcloud-python
meaningcloud/Response.py
Response.getRemainingCredits
def getRemainingCredits(self): """ Returns the remaining credits for the license key used after the request was made :return: String with remaining credits """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('remainin...
python
def getRemainingCredits(self): """ Returns the remaining credits for the license key used after the request was made :return: String with remaining credits """ if 'status' in self._response.keys(): if (self._response['status'] is not None) and ('remainin...
Returns the remaining credits for the license key used after the request was made :return: String with remaining credits
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Response.py#L87-L104
MeaningCloud/meaningcloud-python
meaningcloud/Response.py
Response.getResults
def getResults(self): """ Returns the results from the API without the status of the request :return: Dictionary with the results """ results = self._response.copy() if 'status' in self._response.keys(): if results['status'] is not None: ...
python
def getResults(self): """ Returns the results from the API without the status of the request :return: Dictionary with the results """ results = self._response.copy() if 'status' in self._response.keys(): if results['status'] is not None: ...
Returns the results from the API without the status of the request :return: Dictionary with the results
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Response.py#L106-L120
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_forces
def get_forces(self): """ Get a list of all police forces. Uses the forces_ API call. .. _forces: https://data.police.uk/docs/method/forces/ :rtype: list :return: A list of :class:`forces.Force` objects (one for each police force represented in the API) ...
python
def get_forces(self): """ Get a list of all police forces. Uses the forces_ API call. .. _forces: https://data.police.uk/docs/method/forces/ :rtype: list :return: A list of :class:`forces.Force` objects (one for each police force represented in the API) ...
Get a list of all police forces. Uses the forces_ API call. .. _forces: https://data.police.uk/docs/method/forces/ :rtype: list :return: A list of :class:`forces.Force` objects (one for each police force represented in the API)
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L31-L45
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_neighbourhoods
def get_neighbourhoods(self, force): """ Get a list of all neighbourhoods for a force. Uses the neighbourhoods_ API call. .. _neighbourhoods: https://data.police.uk/docs/method/neighbourhoods/ :param force: The force to get neighbourhoods for (either by ID or ...
python
def get_neighbourhoods(self, force): """ Get a list of all neighbourhoods for a force. Uses the neighbourhoods_ API call. .. _neighbourhoods: https://data.police.uk/docs/method/neighbourhoods/ :param force: The force to get neighbourhoods for (either by ID or ...
Get a list of all neighbourhoods for a force. Uses the neighbourhoods_ API call. .. _neighbourhoods: https://data.police.uk/docs/method/neighbourhoods/ :param force: The force to get neighbourhoods for (either by ID or :class:`forces.Force` object) :type force: st...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L60-L82
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_neighbourhood
def get_neighbourhood(self, force, id, **attrs): """ Get a specific neighbourhood. Uses the neighbourhood_ API call. .. _neighbourhood: https://data.police.uk/docs/method/neighbourhood/ :param force: The force within which the neighbourhood resides (either by ID o...
python
def get_neighbourhood(self, force, id, **attrs): """ Get a specific neighbourhood. Uses the neighbourhood_ API call. .. _neighbourhood: https://data.police.uk/docs/method/neighbourhood/ :param force: The force within which the neighbourhood resides (either by ID o...
Get a specific neighbourhood. Uses the neighbourhood_ API call. .. _neighbourhood: https://data.police.uk/docs/method/neighbourhood/ :param force: The force within which the neighbourhood resides (either by ID or :class:`forces.Force` object) :type force: str or Force ...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L84-L101
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.locate_neighbourhood
def locate_neighbourhood(self, lat, lng): """ Find a neighbourhood by location. Uses the locate-neighbourhood_ API call. .. _locate-neighbourhood: https://data.police.uk/docs/method/neighbourhood-locate/ :param lat: The latitude of the location. :type lat: f...
python
def locate_neighbourhood(self, lat, lng): """ Find a neighbourhood by location. Uses the locate-neighbourhood_ API call. .. _locate-neighbourhood: https://data.police.uk/docs/method/neighbourhood-locate/ :param lat: The latitude of the location. :type lat: f...
Find a neighbourhood by location. Uses the locate-neighbourhood_ API call. .. _locate-neighbourhood: https://data.police.uk/docs/method/neighbourhood-locate/ :param lat: The latitude of the location. :type lat: float or str :param lng: The longitude of the location....
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L103-L127
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_crime_categories
def get_crime_categories(self, date=None): """ Get a list of crime categories, valid for a particular date. Uses the crime-categories_ API call. .. _crime-categories: https://data.police.uk/docs/method/crime-categories/ :rtype: list :param date: The date of ...
python
def get_crime_categories(self, date=None): """ Get a list of crime categories, valid for a particular date. Uses the crime-categories_ API call. .. _crime-categories: https://data.police.uk/docs/method/crime-categories/ :rtype: list :param date: The date of ...
Get a list of crime categories, valid for a particular date. Uses the crime-categories_ API call. .. _crime-categories: https://data.police.uk/docs/method/crime-categories/ :rtype: list :param date: The date of the crime categories to get. :type date: str or None ...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L171-L187
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_crime_category
def get_crime_category(self, id, date=None): """ Get a particular crime category by ID, valid at a particular date. Uses the crime-categories_ API call. :rtype: CrimeCategory :param str id: The ID of the crime category to get. :param date: The date that the given crime c...
python
def get_crime_category(self, id, date=None): """ Get a particular crime category by ID, valid at a particular date. Uses the crime-categories_ API call. :rtype: CrimeCategory :param str id: The ID of the crime category to get. :param date: The date that the given crime c...
Get a particular crime category by ID, valid at a particular date. Uses the crime-categories_ API call. :rtype: CrimeCategory :param str id: The ID of the crime category to get. :param date: The date that the given crime category is valid for (the latest date is use...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L189-L207
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_crime
def get_crime(self, persistent_id): """ Get a particular crime by persistent ID. Uses the outcomes-for-crime_ API call. .. _outcomes-for-crime: https://data.police.uk/docs/method/outcomes-for-crime/ :rtype: Crime :param str persistent_id: The persistent ID o...
python
def get_crime(self, persistent_id): """ Get a particular crime by persistent ID. Uses the outcomes-for-crime_ API call. .. _outcomes-for-crime: https://data.police.uk/docs/method/outcomes-for-crime/ :rtype: Crime :param str persistent_id: The persistent ID o...
Get a particular crime by persistent ID. Uses the outcomes-for-crime_ API call. .. _outcomes-for-crime: https://data.police.uk/docs/method/outcomes-for-crime/ :rtype: Crime :param str persistent_id: The persistent ID of the crime to get. :return: The ``Crime`` with ...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L209-L233
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_crimes_point
def get_crimes_point(self, lat, lng, date=None, category=None): """ Get crimes within a 1-mile radius of a location. Uses the crime-street_ API call. .. _crime-street: https//data.police.uk/docs/method/crime-street/ :rtype: list :param lat: The latitude of the location....
python
def get_crimes_point(self, lat, lng, date=None, category=None): """ Get crimes within a 1-mile radius of a location. Uses the crime-street_ API call. .. _crime-street: https//data.police.uk/docs/method/crime-street/ :rtype: list :param lat: The latitude of the location....
Get crimes within a 1-mile radius of a location. Uses the crime-street_ API call. .. _crime-street: https//data.police.uk/docs/method/crime-street/ :rtype: list :param lat: The latitude of the location. :type lat: float or str :param lng: The longitude of the location. ...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L235-L270
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_crimes_area
def get_crimes_area(self, points, date=None, category=None): """ Get crimes within a custom area. Uses the crime-street_ API call. .. _crime-street: https//data.police.uk/docs/method/crime-street/ :rtype: list :param list points: A ``list`` of ``(lat, lng)`` tuples. :pa...
python
def get_crimes_area(self, points, date=None, category=None): """ Get crimes within a custom area. Uses the crime-street_ API call. .. _crime-street: https//data.police.uk/docs/method/crime-street/ :rtype: list :param list points: A ``list`` of ``(lat, lng)`` tuples. :pa...
Get crimes within a custom area. Uses the crime-street_ API call. .. _crime-street: https//data.police.uk/docs/method/crime-street/ :rtype: list :param list points: A ``list`` of ``(lat, lng)`` tuples. :param date: The month in which the crimes were reported in the format ...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L272-L302
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_crimes_location
def get_crimes_location(self, location_id, date=None): """ Get crimes at a particular snap-point location. Uses the crimes-at-location_ API call. .. _crimes-at-location: https://data.police.uk/docs/method/crimes-at-location/ :rtype: list :param int location_...
python
def get_crimes_location(self, location_id, date=None): """ Get crimes at a particular snap-point location. Uses the crimes-at-location_ API call. .. _crimes-at-location: https://data.police.uk/docs/method/crimes-at-location/ :rtype: list :param int location_...
Get crimes at a particular snap-point location. Uses the crimes-at-location_ API call. .. _crimes-at-location: https://data.police.uk/docs/method/crimes-at-location/ :rtype: list :param int location_id: The ID of the location to get crimes for. :param date: The mont...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L304-L329
rkhleics/police-api-client-python
police_api/__init__.py
PoliceAPI.get_crimes_no_location
def get_crimes_no_location(self, force, date=None, category=None): """ Get crimes with no location for a force. Uses the crimes-no-location_ API call. .. _crimes-no-location: https://data.police.uk/docs/method/crimes-no-location/ :rtype: list :param force: T...
python
def get_crimes_no_location(self, force, date=None, category=None): """ Get crimes with no location for a force. Uses the crimes-no-location_ API call. .. _crimes-no-location: https://data.police.uk/docs/method/crimes-no-location/ :rtype: list :param force: T...
Get crimes with no location for a force. Uses the crimes-no-location_ API call. .. _crimes-no-location: https://data.police.uk/docs/method/crimes-no-location/ :rtype: list :param force: The force to get no-location crimes for. :type force: str or Force :para...
https://github.com/rkhleics/police-api-client-python/blob/b5c1e493487eb2409e2c04ed9fbd304f73d89fdc/police_api/__init__.py#L331-L368
MeaningCloud/meaningcloud-python
meaningcloud/SentimentResponse.py
SentimentResponse.scoreTagToString
def scoreTagToString(self, scoreTag): """ :param scoreTag: :return: """ scoreTagToString = "" if scoreTag == "P+": scoreTagToString = 'strong positive' elif scoreTag == "P": scoreTagToString = 'positive' elif scoreTag == "NEU": ...
python
def scoreTagToString(self, scoreTag): """ :param scoreTag: :return: """ scoreTagToString = "" if scoreTag == "P+": scoreTagToString = 'strong positive' elif scoreTag == "P": scoreTagToString = 'positive' elif scoreTag == "NEU": ...
:param scoreTag: :return:
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/SentimentResponse.py#L177-L197
MaxStrange/retrowrapper
retrowrapper.py
_retrocom
def _retrocom(rx, tx, game, kwargs): """ This function is the target for RetroWrapper's internal process and does all the work of communicating with the environment. """ env = RetroWrapper.retro_make_func(game, **kwargs) # Sit around on the queue, waiting for calls from RetroWrapper whi...
python
def _retrocom(rx, tx, game, kwargs): """ This function is the target for RetroWrapper's internal process and does all the work of communicating with the environment. """ env = RetroWrapper.retro_make_func(game, **kwargs) # Sit around on the queue, waiting for calls from RetroWrapper whi...
This function is the target for RetroWrapper's internal process and does all the work of communicating with the environment.
https://github.com/MaxStrange/retrowrapper/blob/f9a112e07ee432d5f34b3a167902e808cfb0e84f/retrowrapper.py#L13-L38
MaxStrange/retrowrapper
retrowrapper.py
RetroWrapper._ask_if_attr_is_callable
def _ask_if_attr_is_callable(self, attr): """ Returns whether or not the attribute is a callable. """ self._tx.put((RetroWrapper.symbol, attr, {})) return self._rx.get()
python
def _ask_if_attr_is_callable(self, attr): """ Returns whether or not the attribute is a callable. """ self._tx.put((RetroWrapper.symbol, attr, {})) return self._rx.get()
Returns whether or not the attribute is a callable.
https://github.com/MaxStrange/retrowrapper/blob/f9a112e07ee432d5f34b3a167902e808cfb0e84f/retrowrapper.py#L133-L138
MaxStrange/retrowrapper
retrowrapper.py
RetroWrapper.close
def close(self): """ Shutdown the environment. """ if "_tx" in self.__dict__ and "_proc" in self.__dict__: self._tx.put(("close", (), {})) self._proc.join()
python
def close(self): """ Shutdown the environment. """ if "_tx" in self.__dict__ and "_proc" in self.__dict__: self._tx.put(("close", (), {})) self._proc.join()
Shutdown the environment.
https://github.com/MaxStrange/retrowrapper/blob/f9a112e07ee432d5f34b3a167902e808cfb0e84f/retrowrapper.py#L140-L146
MeaningCloud/meaningcloud-python
meaningcloud/Request.py
Request.addParam
def addParam(self, paramName, paramValue): """ Add a parameter to the request :param paramName: Name of the parameter :param paramValue: Value of the parameter """ if not paramName: raise ValueError('paramName cannot be empty') ...
python
def addParam(self, paramName, paramValue): """ Add a parameter to the request :param paramName: Name of the parameter :param paramValue: Value of the parameter """ if not paramName: raise ValueError('paramName cannot be empty') ...
Add a parameter to the request :param paramName: Name of the parameter :param paramValue: Value of the parameter
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Request.py#L37-L49
MeaningCloud/meaningcloud-python
meaningcloud/Request.py
Request.setContent
def setContent(self, type_, value): """ Sets the content that's going to be sent to analyze according to its type :param type_: Type of the content (text, file or url) :param value: Value of the content """ if type_ in [self.CONTENT_TYPE_TXT, sel...
python
def setContent(self, type_, value): """ Sets the content that's going to be sent to analyze according to its type :param type_: Type of the content (text, file or url) :param value: Value of the content """ if type_ in [self.CONTENT_TYPE_TXT, sel...
Sets the content that's going to be sent to analyze according to its type :param type_: Type of the content (text, file or url) :param value: Value of the content
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Request.py#L51-L67
MeaningCloud/meaningcloud-python
meaningcloud/Request.py
Request.sendRequest
def sendRequest(self, extraHeaders=""): """ Sends a request to the URL specified and returns a response only if the HTTP code returned is OK :param extraHeaders: Allows to configure additional headers in the request :return: Response object set to None if there ...
python
def sendRequest(self, extraHeaders=""): """ Sends a request to the URL specified and returns a response only if the HTTP code returned is OK :param extraHeaders: Allows to configure additional headers in the request :return: Response object set to None if there ...
Sends a request to the URL specified and returns a response only if the HTTP code returned is OK :param extraHeaders: Allows to configure additional headers in the request :return: Response object set to None if there is an error
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/Request.py#L99-L130
MeaningCloud/meaningcloud-python
meaningcloud/ParserResponse.py
ParserResponse.getLemmatization
def getLemmatization(self, fullPOSTag=False): """ This function obtains the lemmas and PoS for the text sent :param fullPOSTag: Set to true to obtain the complete PoS tag :return: Dictionary of tokens from the syntactic tree with their lemmas and PoS """ ...
python
def getLemmatization(self, fullPOSTag=False): """ This function obtains the lemmas and PoS for the text sent :param fullPOSTag: Set to true to obtain the complete PoS tag :return: Dictionary of tokens from the syntactic tree with their lemmas and PoS """ ...
This function obtains the lemmas and PoS for the text sent :param fullPOSTag: Set to true to obtain the complete PoS tag :return: Dictionary of tokens from the syntactic tree with their lemmas and PoS
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/ParserResponse.py#L22-L44
MeaningCloud/meaningcloud-python
meaningcloud/TopicsResponse.py
TopicsResponse.getTypeLastNode
def getTypeLastNode(self, type_): """ Obtains the last node or leaf of the type specified :param type_: Type we want to analize (sementity, semtheme) :return: Last node of the type """ lastNode = "" if type_ and (type(type_) is not list) ...
python
def getTypeLastNode(self, type_): """ Obtains the last node or leaf of the type specified :param type_: Type we want to analize (sementity, semtheme) :return: Last node of the type """ lastNode = "" if type_ and (type(type_) is not list) ...
Obtains the last node or leaf of the type specified :param type_: Type we want to analize (sementity, semtheme) :return: Last node of the type
https://github.com/MeaningCloud/meaningcloud-python/blob/1dd76ecabeedd80c9bb14a1716d39657d645775f/meaningcloud/TopicsResponse.py#L161-L175
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.__conn_listener
def __conn_listener(self, state): """ Connection event listener :param state: The new connection state """ if state == KazooState.CONNECTED: self.__online = True if not self.__connected: self.__connected = True self._logger...
python
def __conn_listener(self, state): """ Connection event listener :param state: The new connection state """ if state == KazooState.CONNECTED: self.__online = True if not self.__connected: self.__connected = True self._logger...
Connection event listener :param state: The new connection state
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L135-L160
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.start
def start(self): """ Starts the connection """ self.__stop = False self._queue.start() self._zk.start()
python
def start(self): """ Starts the connection """ self.__stop = False self._queue.start() self._zk.start()
Starts the connection
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L162-L168
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.stop
def stop(self): """ Stops the connection """ self.__stop = True self._queue.stop() self._zk.stop()
python
def stop(self): """ Stops the connection """ self.__stop = True self._queue.stop() self._zk.stop()
Stops the connection
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L170-L176
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.__path
def __path(self, path): """ Adds the prefix to the given path :param path: Z-Path :return: Prefixed Z-Path """ if path.startswith(self.__prefix): return path return "{}{}".format(self.__prefix, path)
python
def __path(self, path): """ Adds the prefix to the given path :param path: Z-Path :return: Prefixed Z-Path """ if path.startswith(self.__prefix): return path return "{}{}".format(self.__prefix, path)
Adds the prefix to the given path :param path: Z-Path :return: Prefixed Z-Path
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L192-L202
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.create
def create(self, path, data, ephemeral=False, sequence=False): """ Creates a ZooKeeper node :param path: Z-Path :param data: Node Content :param ephemeral: Ephemeral flag :param sequence: Sequential flag """ return self._zk.create( self.__path...
python
def create(self, path, data, ephemeral=False, sequence=False): """ Creates a ZooKeeper node :param path: Z-Path :param data: Node Content :param ephemeral: Ephemeral flag :param sequence: Sequential flag """ return self._zk.create( self.__path...
Creates a ZooKeeper node :param path: Z-Path :param data: Node Content :param ephemeral: Ephemeral flag :param sequence: Sequential flag
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L204-L215
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.get
def get(self, path, watch=None): """ Gets the content of a ZooKeeper node :param path: Z-Path :param watch: Watch method """ return self._zk.get(self.__path(path), watch=watch)
python
def get(self, path, watch=None): """ Gets the content of a ZooKeeper node :param path: Z-Path :param watch: Watch method """ return self._zk.get(self.__path(path), watch=watch)
Gets the content of a ZooKeeper node :param path: Z-Path :param watch: Watch method
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L225-L232
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.get_children
def get_children(self, path, watch=None): """ Gets the list of children of a node :param path: Z-Path :param watch: Watch method """ return self._zk.get_children(self.__path(path), watch=watch)
python
def get_children(self, path, watch=None): """ Gets the list of children of a node :param path: Z-Path :param watch: Watch method """ return self._zk.get_children(self.__path(path), watch=watch)
Gets the list of children of a node :param path: Z-Path :param watch: Watch method
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L234-L241
tcalmant/ipopo
pelix/remote/discovery/zookeeper.py
ZooKeeperClient.set
def set(self, path, data): """ Sets the content of a ZooKeeper node :param path: Z-Path :param data: New content """ return self._zk.set(self.__path(path), data)
python
def set(self, path, data): """ Sets the content of a ZooKeeper node :param path: Z-Path :param data: New content """ return self._zk.set(self.__path(path), data)
Sets the content of a ZooKeeper node :param path: Z-Path :param data: New content
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/remote/discovery/zookeeper.py#L243-L250
tcalmant/ipopo
pelix/ipopo/constants.py
get_ipopo_svc_ref
def get_ipopo_svc_ref(bundle_context): # type: (BundleContext) -> Optional[Tuple[ServiceReference, Any]] """ Retrieves a tuple containing the service reference to iPOPO and the service itself :param bundle_context: The calling bundle context :return: The reference to the iPOPO service and the s...
python
def get_ipopo_svc_ref(bundle_context): # type: (BundleContext) -> Optional[Tuple[ServiceReference, Any]] """ Retrieves a tuple containing the service reference to iPOPO and the service itself :param bundle_context: The calling bundle context :return: The reference to the iPOPO service and the s...
Retrieves a tuple containing the service reference to iPOPO and the service itself :param bundle_context: The calling bundle context :return: The reference to the iPOPO service and the service itself, None if not available
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/constants.py#L189-L212
tcalmant/ipopo
pelix/ipopo/constants.py
use_ipopo
def use_ipopo(bundle_context): # type: (BundleContext) -> Any """ Utility context to use the iPOPO service safely in a "with" block. It looks after the the iPOPO service and releases its reference when exiting the context. :param bundle_context: The calling bundle context :return: The iPOPO...
python
def use_ipopo(bundle_context): # type: (BundleContext) -> Any """ Utility context to use the iPOPO service safely in a "with" block. It looks after the the iPOPO service and releases its reference when exiting the context. :param bundle_context: The calling bundle context :return: The iPOPO...
Utility context to use the iPOPO service safely in a "with" block. It looks after the the iPOPO service and releases its reference when exiting the context. :param bundle_context: The calling bundle context :return: The iPOPO service :raise BundleException: Service not found
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/constants.py#L216-L241
tcalmant/ipopo
pelix/ipopo/constants.py
use_waiting_list
def use_waiting_list(bundle_context): # type: (BundleContext) -> Any """ Utility context to use the iPOPO waiting list safely in a "with" block. It looks after the the iPOPO waiting list service and releases its reference when exiting the context. :param bundle_context: The calling bundle conte...
python
def use_waiting_list(bundle_context): # type: (BundleContext) -> Any """ Utility context to use the iPOPO waiting list safely in a "with" block. It looks after the the iPOPO waiting list service and releases its reference when exiting the context. :param bundle_context: The calling bundle conte...
Utility context to use the iPOPO waiting list safely in a "with" block. It looks after the the iPOPO waiting list service and releases its reference when exiting the context. :param bundle_context: The calling bundle context :return: The iPOPO waiting list service :raise BundleException: Service no...
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/constants.py#L245-L270
tcalmant/ipopo
pelix/misc/jabsorb.py
_compute_jsonclass
def _compute_jsonclass(obj): """ Compute the content of the __jsonclass__ field for the given object :param obj: An object :return: The content of the __jsonclass__ field """ # It's not a standard type, so it needs __jsonclass__ module_name = inspect.getmodule(obj).__name__ json_class =...
python
def _compute_jsonclass(obj): """ Compute the content of the __jsonclass__ field for the given object :param obj: An object :return: The content of the __jsonclass__ field """ # It's not a standard type, so it needs __jsonclass__ module_name = inspect.getmodule(obj).__name__ json_class =...
Compute the content of the __jsonclass__ field for the given object :param obj: An object :return: The content of the __jsonclass__ field
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/jabsorb.py#L141-L154
tcalmant/ipopo
pelix/misc/jabsorb.py
_is_builtin
def _is_builtin(obj): """ Checks if the type of the given object is a built-in one or not :param obj: An object :return: True if the object is of a built-in type """ module_ = inspect.getmodule(obj) if module_ in (None, builtins): return True return module_.__name__ in ("", "__...
python
def _is_builtin(obj): """ Checks if the type of the given object is a built-in one or not :param obj: An object :return: True if the object is of a built-in type """ module_ = inspect.getmodule(obj) if module_ in (None, builtins): return True return module_.__name__ in ("", "__...
Checks if the type of the given object is a built-in one or not :param obj: An object :return: True if the object is of a built-in type
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/jabsorb.py#L157-L168
tcalmant/ipopo
pelix/misc/jabsorb.py
_is_converted_class
def _is_converted_class(java_class): """ Checks if the given Java class is one we *might* have set up """ if not java_class: return False return ( JAVA_MAPS_PATTERN.match(java_class) is not None or JAVA_LISTS_PATTERN.match(java_class) is not None or JAVA_SETS_PATTERN...
python
def _is_converted_class(java_class): """ Checks if the given Java class is one we *might* have set up """ if not java_class: return False return ( JAVA_MAPS_PATTERN.match(java_class) is not None or JAVA_LISTS_PATTERN.match(java_class) is not None or JAVA_SETS_PATTERN...
Checks if the given Java class is one we *might* have set up
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/jabsorb.py#L171-L182
tcalmant/ipopo
pelix/misc/jabsorb.py
to_jabsorb
def to_jabsorb(value): """ Adds information for Jabsorb, if needed. Converts maps and lists to a jabsorb form. Keeps tuples as is, to let them be considered as arrays. :param value: A Python result to send to Jabsorb :return: The result in a Jabsorb map format (not a JSON object) """ #...
python
def to_jabsorb(value): """ Adds information for Jabsorb, if needed. Converts maps and lists to a jabsorb form. Keeps tuples as is, to let them be considered as arrays. :param value: A Python result to send to Jabsorb :return: The result in a Jabsorb map format (not a JSON object) """ #...
Adds information for Jabsorb, if needed. Converts maps and lists to a jabsorb form. Keeps tuples as is, to let them be considered as arrays. :param value: A Python result to send to Jabsorb :return: The result in a Jabsorb map format (not a JSON object)
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/jabsorb.py#L188-L277
tcalmant/ipopo
pelix/misc/jabsorb.py
from_jabsorb
def from_jabsorb(request, seems_raw=False): """ Transforms a jabsorb request into a more Python data model (converts maps and lists) :param request: Data coming from Jabsorb :param seems_raw: Set it to True if the given data seems to already have been parsed (no Java class hin...
python
def from_jabsorb(request, seems_raw=False): """ Transforms a jabsorb request into a more Python data model (converts maps and lists) :param request: Data coming from Jabsorb :param seems_raw: Set it to True if the given data seems to already have been parsed (no Java class hin...
Transforms a jabsorb request into a more Python data model (converts maps and lists) :param request: Data coming from Jabsorb :param seems_raw: Set it to True if the given data seems to already have been parsed (no Java class hint). If True, the lists will be kep...
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/jabsorb.py#L280-L352
tcalmant/ipopo
pelix/ipopo/contexts.py
Requirement.copy
def copy(self): # type: () -> Requirement """ Returns a copy of this instance :return: A copy of this instance """ return Requirement( self.specification, self.aggregate, self.optional, self.__original_filter, s...
python
def copy(self): # type: () -> Requirement """ Returns a copy of this instance :return: A copy of this instance """ return Requirement( self.specification, self.aggregate, self.optional, self.__original_filter, s...
Returns a copy of this instance :return: A copy of this instance
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L146-L159
tcalmant/ipopo
pelix/ipopo/contexts.py
Requirement.set_filter
def set_filter(self, props_filter): """ Changes the current filter for the given one :param props_filter: The new requirement filter on service properties :raise TypeError: Unknown filter type """ if props_filter is not None and not ( is_string(props_filter) ...
python
def set_filter(self, props_filter): """ Changes the current filter for the given one :param props_filter: The new requirement filter on service properties :raise TypeError: Unknown filter type """ if props_filter is not None and not ( is_string(props_filter) ...
Changes the current filter for the given one :param props_filter: The new requirement filter on service properties :raise TypeError: Unknown filter type
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L195-L227
tcalmant/ipopo
pelix/ipopo/contexts.py
FactoryContext._deepcopy
def _deepcopy(self, data): """ Deep copies the given object :param data: Data to copy :return: A copy of the data, if supported, else the data itself """ if isinstance(data, dict): # Copy dictionary values return {key: self._deepcopy(value) for ke...
python
def _deepcopy(self, data): """ Deep copies the given object :param data: Data to copy :return: A copy of the data, if supported, else the data itself """ if isinstance(data, dict): # Copy dictionary values return {key: self._deepcopy(value) for ke...
Deep copies the given object :param data: Data to copy :return: A copy of the data, if supported, else the data itself
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L318-L337
tcalmant/ipopo
pelix/ipopo/contexts.py
FactoryContext.copy
def copy(self, inheritance=False): # type: (bool) -> FactoryContext """ Returns a deep copy of the current FactoryContext instance :param inheritance: If True, current handlers configurations are stored as inherited ones """ # Create a new fac...
python
def copy(self, inheritance=False): # type: (bool) -> FactoryContext """ Returns a deep copy of the current FactoryContext instance :param inheritance: If True, current handlers configurations are stored as inherited ones """ # Create a new fac...
Returns a deep copy of the current FactoryContext instance :param inheritance: If True, current handlers configurations are stored as inherited ones
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L339-L363
tcalmant/ipopo
pelix/ipopo/contexts.py
FactoryContext.inherit_handlers
def inherit_handlers(self, excluded_handlers): # type: (Iterable[str]) -> None """ Merges the inherited configuration with the current ones :param excluded_handlers: Excluded handlers """ if not excluded_handlers: excluded_handlers = tuple() for hand...
python
def inherit_handlers(self, excluded_handlers): # type: (Iterable[str]) -> None """ Merges the inherited configuration with the current ones :param excluded_handlers: Excluded handlers """ if not excluded_handlers: excluded_handlers = tuple() for hand...
Merges the inherited configuration with the current ones :param excluded_handlers: Excluded handlers
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L365-L397
tcalmant/ipopo
pelix/ipopo/contexts.py
FactoryContext.add_instance
def add_instance(self, name, properties): # type: (str, dict) -> None """ Stores the description of a component instance. The given properties are stored as is. :param name: Instance name :param properties: Instance properties :raise NameError: Already known inst...
python
def add_instance(self, name, properties): # type: (str, dict) -> None """ Stores the description of a component instance. The given properties are stored as is. :param name: Instance name :param properties: Instance properties :raise NameError: Already known inst...
Stores the description of a component instance. The given properties are stored as is. :param name: Instance name :param properties: Instance properties :raise NameError: Already known instance name
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L399-L413
tcalmant/ipopo
pelix/ipopo/contexts.py
ComponentContext.get_field_callback
def get_field_callback(self, field, event): # type: (str, str) -> Optional[Tuple[Callable, bool]] """ Retrieves the registered method for the given event. Returns None if not found :param field: Name of the dependency field :param event: A component life cycle event ...
python
def get_field_callback(self, field, event): # type: (str, str) -> Optional[Tuple[Callable, bool]] """ Retrieves the registered method for the given event. Returns None if not found :param field: Name of the dependency field :param event: A component life cycle event ...
Retrieves the registered method for the given event. Returns None if not found :param field: Name of the dependency field :param event: A component life cycle event :return: A 2-tuple containing the callback associated to the given event and flag indicating if the callb...
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L546-L561
tcalmant/ipopo
pelix/ipopo/contexts.py
ComponentContext.grab_hidden_properties
def grab_hidden_properties(self): # type: () -> dict """ A one-shot access to hidden properties (the field is then destroyed) :return: A copy of the hidden properties dictionary on the first call :raise AttributeError: On any call after the first one """ # Copy p...
python
def grab_hidden_properties(self): # type: () -> dict """ A one-shot access to hidden properties (the field is then destroyed) :return: A copy of the hidden properties dictionary on the first call :raise AttributeError: On any call after the first one """ # Copy p...
A one-shot access to hidden properties (the field is then destroyed) :return: A copy of the hidden properties dictionary on the first call :raise AttributeError: On any call after the first one
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/contexts.py#L590-L604
tcalmant/ipopo
pelix/ipopo/handlers/properties.py
PropertiesHandler._field_property_generator
def _field_property_generator(self, public_properties): """ Generates the methods called by the injected class properties :param public_properties: If True, create a public property accessor, else an hidden property accessor :return: getter and setter m...
python
def _field_property_generator(self, public_properties): """ Generates the methods called by the injected class properties :param public_properties: If True, create a public property accessor, else an hidden property accessor :return: getter and setter m...
Generates the methods called by the injected class properties :param public_properties: If True, create a public property accessor, else an hidden property accessor :return: getter and setter methods
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/properties.py#L116-L166
tcalmant/ipopo
pelix/ipopo/handlers/properties.py
PropertiesHandler.get_methods_names
def get_methods_names(public_properties): """ Generates the names of the fields where to inject the getter and setter methods :param public_properties: If True, returns the names of public property accessors, else of hidden property ones :return...
python
def get_methods_names(public_properties): """ Generates the names of the fields where to inject the getter and setter methods :param public_properties: If True, returns the names of public property accessors, else of hidden property ones :return...
Generates the names of the fields where to inject the getter and setter methods :param public_properties: If True, returns the names of public property accessors, else of hidden property ones :return: getter and a setter field names
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/properties.py#L169-L186
tcalmant/ipopo
pelix/ipopo/handlers/properties.py
PropertiesHandler.manipulate
def manipulate(self, stored_instance, component_instance): """ Manipulates the component instance :param stored_instance: The iPOPO component StoredInstance :param component_instance: The component instance """ # Store the stored instance self._ipopo_instance = s...
python
def manipulate(self, stored_instance, component_instance): """ Manipulates the component instance :param stored_instance: The iPOPO component StoredInstance :param component_instance: The component instance """ # Store the stored instance self._ipopo_instance = s...
Manipulates the component instance :param stored_instance: The iPOPO component StoredInstance :param component_instance: The component instance
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/properties.py#L188-L215
tcalmant/ipopo
pelix/rsa/shell.py
_full_class_name
def _full_class_name(obj): """ Returns the full name of the class of the given object :param obj: Any Python object :return: The full name of the class of the object (if possible) """ module = obj.__class__.__module__ if module is None or module == str.__class__.__module__: return o...
python
def _full_class_name(obj): """ Returns the full name of the class of the given object :param obj: Any Python object :return: The full name of the class of the object (if possible) """ module = obj.__class__.__module__ if module is None or module == str.__class__.__module__: return o...
Returns the full name of the class of the given object :param obj: Any Python object :return: The full name of the class of the object (if possible)
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/rsa/shell.py#L87-L97
tcalmant/ipopo
pelix/shell/beans.py
IOHandler._prompt
def _prompt(self, prompt=None): """ Reads a line written by the user :param prompt: An optional prompt message :return: The read line, after a conversion to str """ if prompt: # Print the prompt self.write(prompt) self.output.flush() ...
python
def _prompt(self, prompt=None): """ Reads a line written by the user :param prompt: An optional prompt message :return: The read line, after a conversion to str """ if prompt: # Print the prompt self.write(prompt) self.output.flush() ...
Reads a line written by the user :param prompt: An optional prompt message :return: The read line, after a conversion to str
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/beans.py#L195-L208
tcalmant/ipopo
pelix/shell/beans.py
IOHandler._write_bytes
def _write_bytes(self, data): """ Converts the given data then writes it :param data: Data to be written :return: The result of ``self.output.write()`` """ with self.__lock: self.output.write(to_bytes(data, self.encoding))
python
def _write_bytes(self, data): """ Converts the given data then writes it :param data: Data to be written :return: The result of ``self.output.write()`` """ with self.__lock: self.output.write(to_bytes(data, self.encoding))
Converts the given data then writes it :param data: Data to be written :return: The result of ``self.output.write()``
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/beans.py#L210-L218
tcalmant/ipopo
pelix/shell/beans.py
IOHandler._write_str
def _write_str(self, data): """ Converts the given data then writes it :param data: Data to be written :return: The result of ``self.output.write()`` """ with self.__lock: self.output.write( to_str(data, self.encoding) .encode(...
python
def _write_str(self, data): """ Converts the given data then writes it :param data: Data to be written :return: The result of ``self.output.write()`` """ with self.__lock: self.output.write( to_str(data, self.encoding) .encode(...
Converts the given data then writes it :param data: Data to be written :return: The result of ``self.output.write()``
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/beans.py#L220-L232
tcalmant/ipopo
pelix/shell/beans.py
IOHandler.write_line
def write_line(self, line=None, *args, **kwargs): """ Formats and writes a line to the output """ if line is None: # Empty line self.write("\n") else: # Format the line, if arguments have been given if args or kwargs: ...
python
def write_line(self, line=None, *args, **kwargs): """ Formats and writes a line to the output """ if line is None: # Empty line self.write("\n") else: # Format the line, if arguments have been given if args or kwargs: ...
Formats and writes a line to the output
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/beans.py#L234-L257
tcalmant/ipopo
pelix/shell/beans.py
IOHandler.write_line_no_feed
def write_line_no_feed(self, line=None, *args, **kwargs): """ Formats and writes a line to the output """ if line is None: # Empty line line = "" else: # Format the line, if arguments have been given if args or kwargs: ...
python
def write_line_no_feed(self, line=None, *args, **kwargs): """ Formats and writes a line to the output """ if line is None: # Empty line line = "" else: # Format the line, if arguments have been given if args or kwargs: ...
Formats and writes a line to the output
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/beans.py#L259-L277
tcalmant/ipopo
samples/handler/logger.py
_LoggerHandlerFactory.get_handlers
def get_handlers(self, component_context, instance): """ Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component ...
python
def get_handlers(self, component_context, instance): """ Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component ...
Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component (never None)
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/samples/handler/logger.py#L100-L121
tcalmant/ipopo
samples/handler/logger.py
_LoggerHandler.manipulate
def manipulate(self, stored_instance, component_instance): """ Called by iPOPO right after the instantiation of the component. This is the last chance to manipulate the component before the other handlers start. :param stored_instance: The iPOPO component StoredInstance ...
python
def manipulate(self, stored_instance, component_instance): """ Called by iPOPO right after the instantiation of the component. This is the last chance to manipulate the component before the other handlers start. :param stored_instance: The iPOPO component StoredInstance ...
Called by iPOPO right after the instantiation of the component. This is the last chance to manipulate the component before the other handlers start. :param stored_instance: The iPOPO component StoredInstance :param component_instance: The component instance
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/samples/handler/logger.py#L140-L153
tcalmant/ipopo
samples/handler/logger.py
_LoggerHandler.clear
def clear(self): """ Cleans up the handler. The handler can't be used after this method has been called """ self._logger.debug("Component handlers are cleared") # Clean up everything to avoid stale references, ... self._field = None self._name = None ...
python
def clear(self): """ Cleans up the handler. The handler can't be used after this method has been called """ self._logger.debug("Component handlers are cleared") # Clean up everything to avoid stale references, ... self._field = None self._name = None ...
Cleans up the handler. The handler can't be used after this method has been called
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/samples/handler/logger.py#L189-L199
tcalmant/ipopo
pelix/shell/completion/core.py
completion_hints
def completion_hints(config, prompt, session, context, current, arguments): # type: (CompletionInfo, str, ShellSession, BundleContext, str, List[str]) -> List[str] """ Returns the possible completions of the current argument :param config: Configuration of the current completion :param prompt: The ...
python
def completion_hints(config, prompt, session, context, current, arguments): # type: (CompletionInfo, str, ShellSession, BundleContext, str, List[str]) -> List[str] """ Returns the possible completions of the current argument :param config: Configuration of the current completion :param prompt: The ...
Returns the possible completions of the current argument :param config: Configuration of the current completion :param prompt: The shell prompt string :param session: Current shell session :param context: Context of the shell UI bundle :param current: Current argument (to be completed) :param a...
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/completion/core.py#L105-L163