text
stringlengths
0
828
label | <str>
""""""
if label:
self._labels[value] = label
else:
self._labels.pop(value, None)"
1716,"def text(self, value, default=''):
""""""
Returns the text for the inputted value.
:return <str>
""""""
for key, val in self.items():
if val == value:
return key
return default"
1717,"def toSet(self, flags):
""""""
Generates a flag value based on the given set of values.
:param values: <set>
:return: <int>
""""""
return {key for key, value in self.items() if value & flags}"
1718,"def valueByLabel(self, label):
""""""
Determine a given value based on the inputted label.
:param label <str>
:return <int>
""""""
keys = self.keys()
labels = [text.pretty(key) for key in keys]
if label in labels:
return self[keys[labels.index(label)]]
return 0"
1719,"def cli(ctx, name,all):
""""""Show example for doing some task in bubble(experimental)""""""
ctx.gbc.say('all_example_functions',stuff=all_examples_functions, verbosity=1000)
for example in all_examples_functions:
if all or (name and example['name'] == name):
if all:
ctx.gbc.say('example',stuff=example, verbosity=100)
name = example['name']
#click.echo_via_pager(example['fun']())
click.echo(""#""*80)
click.echo(""### start of bubble example: ""+name)
click.echo(""#""*80)
click.echo(example['fun']())
click.echo(""#""*80)
click.echo(""### end of bubble example: ""+name)
click.echo(""#""*80)
click.echo()
else:
click.echo(""available example: "" + example['name'])"
1720,"def check_if_alive(self):
""""""Check if the content is available on the host server. Returns `True` if available, else `False`.
This method is `lazy`-evaluated or only executes when called.
:rtype: bool
""""""
try:
from urllib2 import urlopen, URLError, HTTPError
except ImportError:
from urllib.request import urlopen, URLError, HTTPError
if len(self.instance.STATUS_LINK):
check_url = self.instance.STATUS_LINK % ({'content_uid': self.get_content_uid()})
else:
# fallback
check_url = self.instance.url
try:
response = urlopen(check_url)
except (HTTPError, URLError):
return False
except ValueError:
raise URLError('Invalid URL: %s'.format(check_url))
else:
return True if response.code == 200 else False"
1721,"def load_config_file(self):
""""""Parse configuration file and get config values.""""""
config_parser = SafeConfigParser()
config_parser.read(self.CONFIG_FILE)
if config_parser.has_section('handlers'):
self._config['handlers_package'] = config_parser.get('handlers', 'package')
if config_parser.has_section('auth'):
self._config['consumer_key'] = config_parser.get('auth', 'consumer_key')
self._config['consumer_secret'] = config_parser.get('auth', 'consumer_secret')
self._config['token_key'] = config_parser.get('auth', 'token_key')
self._config['token_secret'] = config_parser.get('auth', 'token_secret')
if config_parser.has_section('stream'):