code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def pretty_unicode(string):
if isinstance(string, six.text_type):
return string
try:
return string.decode("utf8")
except UnicodeDecodeError:
return string.decode('Latin-1').encode('unicode_escape').decode("utf8") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pretty_unicode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'st... | Make sure string is unicode, try to decode with utf8, or unicode escaped string if failed. |
def default_endpoint(ctx, param, value):
if ctx.resilient_parsing:
return
config = ctx.obj['config']
endpoint = default_endpoint_from_config(config, option=value)
if endpoint is None:
raise click.UsageError('No default endpoint found.')
return endpoint | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'default_endpoint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Return default endpoint if specified. |
def imethodcallPayload(self, methodname, localnsp, **kwargs):
param_list = [pywbem.IPARAMVALUE(x[0], pywbem.tocimxml(x[1]))
for x in kwargs.items()]
payload = cim_xml.CIM(
cim_xml.MESSAGE(
cim_xml.SIMPLEREQ(
cim_xml.IMETHODCALL(
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'imethodcallPayload'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children... | Generate the XML payload for an intrinsic methodcall. |
def _find_value(key, *args):
for arg in args:
v = _get_value(arg, key)
if v is not None:
return v | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Find a value for 'key' in any of the objects given as 'args |
def _on_state_changed(self):
raw_state, generation = self.state.raw_state_and_generation
if generation != self._last_generation:
self._last_generation = generation
self._send_update(raw_state, generation) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_on_state_changed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Invoked when the viewer state changes. |
def write_sampler_metadata(self, sampler):
super(EmceePTFile, self).write_sampler_metadata(sampler)
self[self.sampler_group].attrs["betas"] = sampler.betas | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_sampler_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | Adds writing betas to MultiTemperedMCMCIO. |
def hostname(self):
from six.moves.urllib.parse import urlparse
return urlparse(self._base_url).netloc.split(':', 1)[0] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hostname'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Get the hostname that this connection is associated with |
def _make_c_string(string):
if isinstance(string, bytes):
try:
_utf_8_decode(string, None, True)
return string + b"\x00"
except UnicodeError:
raise InvalidStringData("strings in documents must be valid "
"UTF-8: %r" % string)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_c_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'st... | Make a 'C' string. |
def _add_to_checksum(self, checksum, value):
checksum = self._byte_rot_left(checksum, 1)
checksum = checksum + value
if (checksum > 255):
checksum = checksum - 255
self._debug(PROP_LOGLEVEL_TRACE, "C: " + str(checksum) + " V: " + str(value))
return checksum | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_to_checksum'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Add a byte to the checksum. |
def register_builtin_message_types():
from .plain import PlainTextMessage
from .email import EmailTextMessage, EmailHtmlMessage
register_message_types(PlainTextMessage, EmailTextMessage, EmailHtmlMessage) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_builtin_message_types'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '1... | Registers the built-in message types. |
def load(self, rel_path=None):
for k, v in self.layer.iteritems():
self.add(k, v['module'], v.get('package'))
filename = v.get('filename')
path = v.get('path')
if filename:
warnings.warn(DeprecationWarning(SIMFILE_LOAD_WARNING))
if ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Add sim_src to layer. |
def rename_page(self, old_slug, new_title):
p = s2page.Page(self, old_slug, isslug=True)
p.rename(new_title) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rename_page'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Load the page corresponding to the slug, and rename it. |
def _ssh_master_cmd(addr, user, command, local_key=None):
ssh_call = ['ssh', '-qNfL%d:127.0.0.1:12042' % find_port(addr, user),
'-o', 'ControlPath=~/.ssh/unixpipe_%%r@%%h_%d' %
find_port(addr, user),
'-O', command, '%s@%s' % (user, addr,)]
if local_key:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ssh_master_cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children':... | Exit or check ssh mux |
def find_by_reference_ids(reference_ids, _connection=None, page_size=100,
page_number=0, sort_by=enums.DEFAULT_SORT_BY,
sort_order=enums.DEFAULT_SORT_ORDER):
if not isinstance(reference_ids, (list, tuple)):
err = "Video.find_by_reference_ids expects an iterable argument"
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_by_reference_ids'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '19']}; {'id': '4', 'type': 'ident... | List all videos identified by a list of reference ids |
def FDMT_params(f_min, f_max, maxDT, inttime):
maxDM = inttime*maxDT/(4.1488e-3 * (1/f_min**2 - 1/f_max**2))
logger.info('Freqs from {0}-{1}, MaxDT {2}, Int time {3} => maxDM {4}'.format(f_min, f_max, maxDT, inttime, maxDM)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'FDMT_params'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Summarize DM grid and other parameters. |
def cli(env, identifier):
vsi = SoftLayer.VSManager(env.client)
vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
instance = vsi.get_instance(vs_id)
table = formatting.Table(['username', 'password'])
for item in instance['operatingSystem']['passwords']:
table.add_row([item['usern... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {... | List virtual server credentials. |
def middleware(func):
@wraps(func)
def parse(*args, **kwargs):
middleware = copy.deepcopy(kwargs['middleware'])
kwargs.pop('middleware')
if request.method == "OPTIONS":
return JsonResponse(200)
if middleware is None:
return func(*args, **kwargs)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'middleware'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}... | Executes routes.py route middleware |
def format_platforms(cls, platforms):
lines = []
if platforms:
lines.append('This DAP is only supported on the following platforms:')
lines.extend([' * ' + platform for platform in platforms])
return lines | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_platforms'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Formats supported platforms in human readable form |
def _load_file(self, f):
try:
with open(f, 'r') as _fo:
_seria_in = seria.load(_fo)
_y = _seria_in.dump('yaml')
except IOError:
raise FiggypyError("could not open configuration file")
self.values.update(yaml.load(_y)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Get values from config file |
def _init_ca(self):
if not exists(path_join(self.ca_dir, 'ca.cnf')):
with open(path_join(self.ca_dir, 'ca.cnf'), 'w') as fh:
fh.write(
CA_CONF_TEMPLATE % (self.get_conf_variables()))
if not exists(path_join(self.ca_dir, 'signing.cnf')):
with op... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_ca'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | Generate the root ca's cert and key. |
def refresh(self):
for cbar in self.colorbars:
cbar.draw_all()
self.canvas.draw() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refresh'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Refresh the current figure |
def validate_schedule():
all_items = prefetch_schedule_items()
errors = []
for validator, _type, msg in SCHEDULE_ITEM_VALIDATORS:
if validator(all_items):
errors.append(msg)
all_slots = prefetch_slots()
for validator, _type, msg in SLOT_VALIDATORS:
if validator(all_slots)... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_schedule'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '15', '35... | Helper routine to report issues with the schedule |
def constant_jump_targets_and_jumpkinds(self):
exits = dict()
if self.exit_statements:
for _, _, stmt_ in self.exit_statements:
exits[stmt_.dst.value] = stmt_.jumpkind
default_target = self.default_exit_target
if default_target is not None:
exits[d... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'constant_jump_targets_and_jumpkinds'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'childr... | A dict of the static jump targets of the basic block to their jumpkind. |
def cli_main():
SearchContext.commit()
args = parser.parse_args()
firefox_remote = Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.FIREFOX)
with contextlib.closing(firefox_remote):
context = SearchContext.from_instances([FastSearch(), Browser(firefox_remote)])
search = Search(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli_main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '19', '29']}; {'id... | cli entrypoitns, sets up everything needed |
def install_package_command(package_name):
if sys.platform == "win32":
cmds = 'python -m pip install --user {0}'.format(package_name)
else:
cmds = 'python3 -m pip install --user {0}'.format(package_name)
call(cmds, shell=True) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'install_package_command'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | install python package from pip |
def _add_comments(
self,
comments: Optional[Sequence[str]],
original_string: str = ""
) -> str:
if self.config['ignore_comments']:
return self._strip_comments(original_string)[0]
if not comments:
return original_string
else:
return ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_comments'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '17']}; {'id': '4', 'type': 'identifier', 'children':... | Returns a string with comments added if ignore_comments is not set. |
def add(self, name, obj=None):
if obj:
text = '\n::\n\n' + indent(str(obj))
else:
text = views.view(name, self.dstore)
if text:
title = self.title[name]
line = '-' * len(title)
self.text += '\n'.join(['\n\n' + title, line, text]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Add the view named `name` to the report text |
def api_routes(self, callsign: str) -> Tuple[Airport, ...]:
from .. import airports
c = requests.get(
f"https://opensky-network.org/api/routes?callsign={callsign}"
)
if c.status_code == 404:
raise ValueError("Unknown callsign")
if c.status_code != 200:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'api_routes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Returns the route associated to a callsign. |
def getSearch(self):
return Search(self.getColumns(), Sitools2Abstract.getBaseUrl(self) + self.getUri()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getSearch'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Returns the search capability. |
def logFile(fileName, printFunction=logger.info):
printFunction("Reporting file: %s" % fileName)
shortName = fileName.split("/")[-1]
fileHandle = open(fileName, 'r')
line = fileHandle.readline()
while line != '':
if line[-1] == '\n':
line = line[:-1]
printFunction("%s:\t%... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logFile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fil... | Writes out a formatted version of the given log file |
def _initialize_logging():
if sys.stdout.isatty() or platform.system() in ("Darwin", "Linux"):
RuntimeGlobals.logging_console_handler = foundations.verbose.get_logging_console_handler()
RuntimeGlobals.logging_formatters = {"Default": foundations.verbose.LOGGING_DEFAULT_FORMATTER,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_initialize_logging'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '36']}; {'id'... | Initializes the Application logging. |
def remove(self, list):
xml = SP.DeleteList(SP.listName(list.id))
self.opener.post_soap(LIST_WEBSERVICE, xml,
soapaction='http://schemas.microsoft.com/sharepoint/soap/DeleteList')
self.all_lists.remove(list) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Removes a list from the site. |
def gan_critic(n_channels:int=3, nf:int=128, n_blocks:int=3, p:int=0.15):
"Critic to train a `GAN`."
layers = [
_conv(n_channels, nf, ks=4, stride=2),
nn.Dropout2d(p/2),
res_block(nf, dense=True,**_conv_args)]
nf *= 2
for i in range(n_blocks):
layers += [
nn.D... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gan_critic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '9', '14', '19']}; {'id': '4', 'type': 'typed_default_parameter', '... | Critic to train a `GAN`. |
def collection_year(soup):
pub_date = first(raw_parser.pub_date(soup, pub_type="collection"))
if not pub_date:
pub_date = first(raw_parser.pub_date(soup, date_type="collection"))
if not pub_date:
return None
year = None
year_tag = raw_parser.year(pub_date)
if year_tag:
ye... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'collection_year'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Pub date of type collection will hold a year element for VOR articles |
def do_visualize(self, line):
if not self.current:
self._help_noontology()
return
line = line.split()
try:
from ..ontodocs.builder import action_visualize
except:
self._print("This command requires the ontodocs package: `pip install ontodoc... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_visualize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Visualize an ontology - ie wrapper for export command |
def _print_bar(self):
self._print('[')
for position in range(self._bar_width):
position_fraction = position / (self._bar_width - 1)
position_bytes = position_fraction * self.max_value
if position_bytes < (self.continue_value or 0):
self._print('+')
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_print_bar'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Print a progress bar. |
def run(self):
luigi.LocalTarget(path=self.fixture).copy(self.output().path) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | Just copy the fixture, so we have some output. |
def parse_name(parser):
token = expect(parser, TokenKind.NAME)
return ast.Name(value=token.value, loc=loc(parser, token.start)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'parser... | Converts a name lex token into a name parse node. |
def _repr_html_(self, **kwargs):
html = self.render(**kwargs)
html = "data:text/html;charset=utf-8;base64," + base64.b64encode(html.encode('utf8')).decode('utf8')
if self.height is None:
iframe = (
'<div style="width:{width};">'
'<div style="position:relative;... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_repr_html_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Displays the Figure in a Jupyter notebook. |
def attach_method(self, resource_id):
try:
_response = self.client.put_method(
restApiId=self.api_id,
resourceId=resource_id,
httpMethod=self.trigger_settings['method'],
authorizationType="NONE",
apiKeyRequired=False, )
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'attach_method'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Attach the defined method. |
def create_dm_pkg(secret,username):
secret = tools.EncodeString(secret)
username = tools.EncodeString(username)
pkg_format = '>HHHH32sHH32s'
pkg_vals = [
IK_RAD_PKG_VER,
IK_RAD_PKG_AUTH,
IK_RAD_PKG_USR_PWD_TAG,
len(secret),
secret.ljust(32,'\x00'),
IK_RAD_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_dm_pkg'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | create ikuai dm message |
def savetofile(self, filelike, sortkey = True):
filelike.writelines(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'savetofile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Save configurations to a file-like object which supports `writelines` |
def secret_key_bytes(self):
if not hasattr(self, '_secret_key_bytes'):
key = self.secret_key()
if key is None:
self._secret_key_bytes = None
else:
self._secret_key_bytes = codecs.encode(key, "utf-8")
return self._secret_key_bytes | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'secret_key_bytes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Return the secret_key, converted to bytes and cached. |
def _update_method(self, oldmeth, newmeth):
if hasattr(oldmeth, 'im_func') and hasattr(newmeth, 'im_func'):
self._update(None, None, oldmeth.im_func, newmeth.im_func)
elif hasattr(oldmeth, '__func__') and hasattr(newmeth, '__func__'):
self._update(None, None, oldmeth.__func__, ne... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_method'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Update a method object. |
def _load_mol2(self, mol2_lines, mol2_code, columns):
if columns is None:
col_names = COLUMN_NAMES
col_types = COLUMN_TYPES
else:
col_names, col_types = [], []
for i in range(len(columns)):
col_names.append(columns[i][0])
co... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_mol2'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Load mol2 contents into assert_raise_message instance |
def filter_tasks(self, request, context):
_log_request(request, context)
tasks_pattern, tasks_negate = PATTERN_PARAMS_OP(request.tasks_filter)
state_pattern = request.state_pattern
limit, reverse = request.limit, request.reverse
pregex = re.compile(tasks_pattern)
sregex =... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_tasks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Filter tasks by matching patterns to name, routing key and state. |
async def send_and_receive(self, message,
generate_identifier=True, timeout=5):
await self._connect_and_encrypt()
if generate_identifier:
identifier = str(uuid.uuid4())
message.identifier = identifier
else:
identifier = 'type_' +... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_and_receive'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children'... | Send a message and wait for a response. |
def _keys_to_lower(self):
for k in list(self.keys()):
val = super(CaseInsensitiveDict, self).__getitem__(k)
super(CaseInsensitiveDict, self).__delitem__(k)
self.__setitem__(CaseInsensitiveStr(k), val) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_keys_to_lower'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Convert key set to lowercase. |
def _icon_by_painter(self, painter, options):
engine = CharIconEngine(self, painter, options)
return QIcon(engine) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_icon_by_painter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Return the icon corresponding to the given painter. |
def validate(self, value, model_instance, **kwargs):
self.get_choices_form_class().validate(value, model_instance, **kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | This follows the validate rules for choices_form_class field used. |
def _fill_capture_regions(data):
special_targets = {"sv_regions": ("exons", "transcripts")}
ref_file = dd.get_ref_file(data)
for target in ["variant_regions", "sv_regions", "coverage"]:
val = tz.get_in(["config", "algorithm", target], data)
if val and not os.path.exists(val) and not objectst... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_fill_capture_regions'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Fill short-hand specification of BED capture regions. |
def structured_iterator(failure_lines):
summary = partial(failure_line_summary, TbplFormatter())
for failure_line in failure_lines:
repr_str = summary(failure_line)
if repr_str:
yield failure_line, repr_str
while True:
yield None, None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'structured_iterator'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Create FailureLine, Tbpl-formatted-string tuples. |
def _next(self, request, application, roles, next_config):
if request.method == "POST":
key = None
while True:
assert next_config['type'] in ['goto', 'transition']
while next_config['type'] == 'goto':
key = next_config['key']
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_next'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Continue the state machine at given state. |
def request_uri(self):
uri = self.path or '/'
if self.query is not None:
uri += '?' + self.query
return uri | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'request_uri'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Absolute path including the query string. |
def pack(field: str, kwargs: Dict[str, Any],
default: Optional[Any] = None, sep: str=',') -> str:
if default is not None:
value = kwargs.get(field, default)
else:
value = kwargs[field]
if isinstance(value, str):
return value
elif isinstance(value, collections.abc.Iterabl... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32', '34']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pack'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '18', '27']}; {'id': '4', 'type': 'typed_parameter', 'children... | Util for joining multiple fields with commas |
def _from_dict(cls, _dict):
args = {}
if 'trait_id' in _dict:
args['trait_id'] = _dict.get('trait_id')
else:
raise ValueError(
'Required property \'trait_id\' not present in Trait JSON')
if 'name' in _dict:
args['name'] = _dict.get('nam... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c... | Initialize a Trait object from a json dictionary. |
def _key_to_address(key):
key_parts = key.split('.', maxsplit=_MAX_KEY_PARTS - 1)
key_parts.extend([''] * (_MAX_KEY_PARTS - len(key_parts)))
return SETTINGS_NAMESPACE + ''.join(_short_hash(x) for x in key_parts) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_key_to_address'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'k... | Creates the state address for a given setting key. |
def _yql_query(yql):
url = _YAHOO_BASE_URL.format(urlencode({'q': yql}))
_LOGGER.debug("Send request to url: %s", url)
try:
request = urlopen(url)
rawData = request.read()
data = json.loads(rawData.decode("utf-8"))
_LOGGER.debug("Query data from yahoo: %s", str(data))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_yql_query'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'yql'};... | Fetch data from Yahoo! Return a dict if successfull or None. |
def uninstall(
ctx,
state,
all_dev=False,
all=False,
**kwargs
):
from ..core import do_uninstall
retcode = do_uninstall(
packages=state.installstate.packages,
editable_packages=state.installstate.editables,
three=state.three,
python=state.python,
syste... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'uninstall'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children':... | Un-installs a provided package and removes it from Pipfile. |
def addPathVariables(self, pathvars):
if type(pathvars) is dict:
self._pathvars = merge(self._pathvars, pathvars) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'addPathVariables'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Adds path variables to the pathvars map property |
def gen_sub(src1, src2, dst):
assert src1.size == src2.size
return ReilBuilder.build(ReilMnemonic.SUB, src1, src2, dst) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gen_sub'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Return a SUB instruction. |
def _on_new_location(self, form):
self._desired_longitude = float(form.data["long"])
self._desired_latitude = float(form.data["lat"])
self._desired_zoom = 13
self._screen.force_update() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_on_new_location'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Set a new desired location entered in the pop-up form. |
def indent(self, levels, first_line=None):
self._indentation_levels.append(levels)
self._indent_first_line.append(first_line) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'indent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Increase indentation by ``levels`` levels. |
def files(self):
if self._files is None:
self._files = SeriesZipTifPhasics._index_files(self.path)
return self._files | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'files'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'i... | List of Phasics tif file names in the input zip file |
def update_source(ident, data):
source = get_source(ident)
source.modify(**data)
signals.harvest_source_updated.send(source)
return source | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Update an harvest source |
def strip_ansi(state):
stu_res = _strip_ansi(state.student_result)
return state.to_child(student_result = stu_res) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'strip_ansi'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'state'... | Remove ANSI escape codes from student result. |
def init_epoch(self):
if self._restored_from_state:
self.random_shuffler.random_state = self._random_state_this_epoch
else:
self._random_state_this_epoch = self.random_shuffler.random_state
self.create_batches()
if self._restored_from_state:
self._rest... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init_epoch'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Set up the batch generator for a new epoch. |
def use_plenary_repository_view(self):
self._repository_view = PLENARY
for session in self._get_provider_sessions():
try:
session.use_plenary_repository_view()
except AttributeError:
pass | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'use_plenary_repository_view'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],... | Pass through to provider AssetRepositorySession.use_plenary_repository_view |
def connect(self, address):
'connects to the address and wraps the connection in an SSL context'
tout = _timeout(self.gettimeout())
while 1:
self._wait_event(tout.now, write=True)
err = self._connect(address, tout.now)
if err in (errno.EINPROGRESS, errno.EALRE... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | connects to the address and wraps the connection in an SSL context |
def knob_subgroup(self, cutoff=7.0):
if cutoff > self.cutoff:
raise ValueError("cutoff supplied ({0}) cannot be greater than self.cutoff ({1})".format(cutoff,
self.cutoff))
return KnobGroup(m... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'knob_subgroup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | KnobGroup where all KnobsIntoHoles have max_kh_distance <= cutoff. |
def make_middleware(app=None, *args, **kw):
app = iWSGIMiddleware(app, *args, **kw)
return app | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_middleware'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '9']}; {'id': '4', 'type': 'default_parameter', 'children... | Given an app, return that app wrapped in iWSGIMiddleware |
def put_blob(self, field: str, fileobj: BinaryIO,
filename: str,
mimetype: Optional[str] = None,
size: Optional[int] = None,
encoding: Optional[str] = None) -> IBlob:
raise NotImplementedError | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '44', '46']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'put_blob'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13', '17', '26', '35']}; {'id': '4', 'type': 'identi... | Receive and store blob object |
def read_point_prop(self, device_name, point):
with open("%s.bin" % device_name, "rb") as file:
return pickle.load(file)["points"][point] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_point_prop'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Points properties retrieved from pickle |
def publish_data(self):
self.publish_device_stats()
publish = self.publish
for node in self.nodes:
try:
if node.has_update():
for data in node.get_data():
publish(*data)
except NotImplementedError:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'publish_data'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | publish node data if node has updates |
def validate_network_topology(network_id,**kwargs):
user_id = kwargs.get('user_id')
try:
net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
net_i.check_write_permission(user_id=user_id)
except NoResultFound:
raise ResourceNotFoundError("Network %s not found"%(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_network_topology'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ... | Check for the presence of orphan nodes in a network. |
def mask_umi(umi, umi_quals, quality_encoding, quality_filter_threshold):
below_threshold = get_below_threshold(
umi_quals, quality_encoding, quality_filter_threshold)
new_umi = ""
for base, test in zip(umi, below_threshold):
if test:
new_umi += "N"
else:
new... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mask_umi'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Mask all positions where quals < threshold with "N" |
def decode_endpoint_props(input_props):
ed_props = decode_osgi_props(input_props)
ed_props[ECF_ENDPOINT_CONTAINERID_NAMESPACE] = input_props[
ECF_ENDPOINT_CONTAINERID_NAMESPACE
]
ed_props[ECF_RSVC_ID] = int(input_props[ECF_RSVC_ID])
ed_props[ECF_ENDPOINT_ID] = input_props[ECF_ENDPOINT_ID]
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'decode_endpoint_props'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Decodes the endpoint properties from the given dictionary |
def database_root_path(cls, project, database):
return google.api_core.path_template.expand(
"projects/{project}/databases/{database}",
project=project,
database=database,
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'database_root_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | Return a fully-qualified database_root string. |
def range_metadata(start, end, dst_folder, num_worker_threads=0, writers=[file_writer], geometry_check=None):
assert isinstance(start, date)
assert isinstance(end, date)
delta = end - start
dates = []
for i in range(delta.days + 1):
dates.append(start + timedelta(days=i))
days = len(date... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'range_metadata'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '14']}; {'id': '4', 'type': 'identifier', ... | Extra metadata for all products in a date range |
def sh(args, **kwargs):
if isinstance(args, str):
args = args.split()
if not args:
return
click.echo('$ {0}'.format(' '.join(args)))
try:
return subprocess.check_call(args, **kwargs)
except subprocess.CalledProcessError as exc:
click.secho('run error {}'.format(exc))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sh'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'}; {... | runs the given cmd as shell command |
def reservoir_sample(stream, num_items, item_parser=lambda x: x):
kept = []
for index, item in enumerate(stream):
if index < num_items:
kept.append(item_parser(item))
else:
r = random.randint(0, index)
if r < num_items:
kept[r] = item_parser(it... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reservoir_sample'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | samples num_items from the stream keeping each with equal probability |
def do_ultracache(parser, token):
nodelist = parser.parse(("endultracache",))
parser.delete_first_token()
tokens = token.split_contents()
if len(tokens) < 3:
raise TemplateSyntaxError(""%r" tag requires at least 2 arguments." % tokens[0])
return UltraCacheNode(nodelist,
parser.compil... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_ultracache'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Based on Django's default cache template tag |
def _delete_uncompressed(
collection_name, spec, safe, last_error_args, opts, flags=0):
op_delete, max_bson_size = _delete(collection_name, spec, opts, flags)
rid, msg = __pack_message(2006, op_delete)
if safe:
rid, gle, _ = __last_error(collection_name, last_error_args)
return rid, ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_delete_uncompressed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifie... | Internal delete message helper. |
def _serialize(self, value, attr, obj):
if isinstance(value, arrow.arrow.Arrow):
value = value.datetime
return super(ArrowField, self)._serialize(value, attr, obj) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_serialize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Convert the Arrow object into a string. |
def plotly_direct(context, name=None, slug=None, da=None):
'Direct insertion of a Dash app'
da, app = _locate_daapp(name, slug, da)
view_func = app.locate_endpoint_function()
eh = context.request.dpd_content_handler.embedded_holder
app.set_embedded(eh)
try:
resp = view_func()
finally... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'plotly_direct'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': ... | Direct insertion of a Dash app |
def _readfloatle(self, length, start):
startbyte, offset = divmod(start + self._offset, 8)
if not offset:
if length == 32:
f, = struct.unpack('<f', bytes(self._datastore.getbyteslice(startbyte, startbyte + 4)))
elif length == 64:
f, = struct.unpack... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_readfloatle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Read bits and interpret as a little-endian float. |
def _set_timeouts(self, timeouts):
(send_timeout, recv_timeout) = (None, None)
try:
(send_timeout, recv_timeout) = timeouts
except TypeError:
raise EndpointError(
'`timeouts` must be a pair of numbers (2, 3) which represent '
'the timeout v... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_timeouts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Set socket timeouts for send and receive respectively |
def load_zipfile(self, path):
zin = zipfile.ZipFile(path)
for zinfo in zin.infolist():
name = zinfo.filename
if name.endswith("/"):
self.mkdir(name)
else:
content = zin.read(name)
self.touch(name, content) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_zipfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | import contents of a zipfile |
def _CreateRequest(self, url, data=None):
logging.debug("Creating request for: '%s' with payload:\n%s", url, data)
req = urllib2.Request(url, data=data)
if self.host_override:
req.add_header("Host", self.host_override)
for key, value in self.extra_headers.iteritems():
req.add_header(key, value)
return r... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_CreateRequest'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Creates a new urllib request. |
def _has_exclusive_option(cls, options):
return any([getattr(options, opt) is not None for opt in
cls.BASE_ERROR_SELECTION_OPTIONS]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_has_exclusive_option'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Return `True` iff one or more exclusive options were selected. |
def gencode(self):
ledict = requests.get(self.api_url).json()
ledict = self.dotopdict(ledict)
out = self.dodict(ledict)
self._code = out | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'gencode'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Run this to generate the code |
def initWithComplexQuery(query):
q = QueryEvents()
if isinstance(query, ComplexEventQuery):
q._setVal("query", json.dumps(query.getQuery()))
elif isinstance(query, six.string_types):
foo = json.loads(query)
q._setVal("query", query)
elif isinstance(que... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initWithComplexQuery'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | create a query using a complex event query |
def init_argparser_source_registry(
self, argparser, default=None, help=(
'comma separated list of registries to use for gathering '
'JavaScript sources from the given Python packages'
)):
argparser.add_argument(
'--source-registry', default=de... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init_argparser_source_registry'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifie... | For setting up the source registry flag. |
def _reg_sighandlers(self):
_handler = lambda signo, frame: self.shutdown()
signal.signal(signal.SIGCHLD, _handler)
signal.signal(signal.SIGTERM, _handler) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_reg_sighandlers'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Registers signal handlers to this class. |
def version_ok(self, version):
return self.attribute is None or self.format is None or \
str(version) != "unknown" and version >= self.requested_version | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'version_ok'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Is 'version' sufficiently up-to-date? |
def _getActivePassive(obj1, obj2):
speed1 = abs(obj1.lonspeed) if obj1.isPlanet() else -1.0
speed2 = abs(obj2.lonspeed) if obj2.isPlanet() else -1.0
if speed1 > speed2:
return {
'active': obj1,
'passive': obj2
}
else:
return {
'active': obj2,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_getActivePassive'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Returns which is the active and the passive objects. |
def list_databases(self, limit=None, marker=None):
return self._database_manager.list(limit=limit, marker=marker) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_databases'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Returns a list of the names of all databases for this instance. |
def act(self):
g = get_root(self).globals
g.ipars.unfreeze()
g.rpars.unfreeze()
g.observe.load.enable()
self.disable() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'act'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | Carries out the action associated with the Unfreeze button |
def read_14c(fl):
indata = pd.read_csv(fl, index_col=None, skiprows=11, header=None,
names=['calbp', 'c14age', 'error', 'delta14c', 'sigma'])
outcurve = CalibCurve(calbp=indata['calbp'],
c14age=indata['c14age'],
error=indata['error'],
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_14c'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fl'}; {'... | Create CalibCurve instance from Bacon curve file |
def logging_decorator(func):
def you_will_never_see_this_name(*args, **kwargs):
print('calling %s ...' % func.__name__)
result = func(*args, **kwargs)
print('completed: %s' % func.__name__)
return result
return you_will_never_see_this_name | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logging_decorator'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Allow logging function calls |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.