code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def _get_child(self, children, index):
try:
return children[index]
except IndexError:
raise WSDLParseError("Non existing item in tag '%s'" %
self._schema.tag) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_child'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Return the child with the given index. |
def markWatched(self):
key = '/:/scrobble?key=%s&identifier=com.plexapp.plugins.library' % self.ratingKey
self._server.query(key)
self.reload() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'markWatched'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Mark video as watched. |
def delete_service_key(self, service_name, key_name):
key = self.get_service_key(service_name, key_name)
logging.info("Deleting service key %s for service %s" % (key, service_name))
return self.api.delete(key['metadata']['url']) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delete_service_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': []... | Delete a service key for the given service. |
def process_shells_parallel(self, shells):
output = []
success = True
with closing(multiprocessing.Pool(multiprocessing.cpu_count())) as pool:
for result in [Adapter(entry) for entry in pool.map(worker, [shell for shell in shells])]:
output += result.output
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_shells_parallel'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Processing a list of shells parallel. |
def load_state_from_disk():
if is_there_state():
with open('data.json', 'r') as f:
data = json.load(f)
return data
else:
return False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_state_from_disk'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5'... | loads the state from a local data.json file |
def chunk_count(self):
c = 0
for r in self.iter_regions():
c += r.chunk_count()
return c | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'chunk_count'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Return a count of the chunks in this world folder. |
def setup_other_windows(self):
self.toolbar_list = ((_("File toolbar"), "file_toolbar",
self.main.file_toolbar_actions),
(_("Search toolbar"), "search_toolbar",
self.main.search_menu_actions),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_other_windows'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Setup toolbars and menus for 'New window' instances |
def validate_field_matches_type(field, value, field_type, select_items=None, _min=None, _max=None):
if (field_type == defs.TEXT_TYPE and not isinstance(value, six.string_types)) or \
(field_type == defs.STRING_TYPE and not isinstance(value, six.string_types)) or \
(field_type == defs.BOOLEAN_TYPE and ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_field_matches_type'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': '... | Validate a config field against a specific type. |
def assignment_call_node(self, left_hand_label, ast_node):
self.undecided = True
call = self.visit(ast_node.value)
call_label = call.left_hand_side
call_assignment = AssignmentCallNode(
left_hand_label + ' = ' + call_label,
left_hand_label,
ast_node,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'assignment_call_node'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': ... | Handle assignments that contain a function call on its right side. |
def instruction_path(cls, project, instruction):
return google.api_core.path_template.expand(
"projects/{project}/instructions/{instruction}",
project=project,
instruction=instruction,
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'instruction_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Return a fully-qualified instruction string. |
def login(self, username, password):
"Login to the database and store cookies for upcoming requests."
log.debug("Logging in to the DB")
opener = self._build_opener()
values = {'usr': username, 'pwd': password}
req = self._make_request(self._login_url, values)
try:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'login'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Login to the database and store cookies for upcoming requests. |
def document(self, result):
self._add_meta(result)
walker = JsonWalker(JsonWalker.value_json, JsonWalker.dict_expand)
r = walker.walk(result)
return r | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'document'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Build dict for MongoDB, expanding result keys as we go. |
async def send(self, config, entry):
if self.endpoint:
LOGGER.debug("%s -> %s", entry.url, self.url)
try:
await self.endpoint.send(config, entry.url, self.url)
except Exception as err:
LOGGER.warning("Ping %s: got %s: %s",
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Send a webmention to this target from the specified entry |
def create(self, attributes=None, **kwargs):
return super(WebhooksProxy, self).create(resource_id=None, attributes=attributes) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Creates a webhook with given attributes. |
def setup_exceptions():
global _print_traceback, _drill
local_print_traceback = os.getenv("PYLOGCONF_PRINT_TRACEBACK")
if local_print_traceback is not None:
_print_traceback = _str2bool(local_print_traceback)
local_drill = os.getenv("PYLOGCONF_DRILL")
if local_drill is not None:
_dri... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_exceptions'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '8', '17', '29',... | Only print the heart of the exception and not the stack trace |
def logout(self):
if self._logged_in is True:
self.si.flush_cache()
self.sc.sessionManager.Logout()
self._logged_in = False | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logout'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Logout of a vSphere server. |
def _build_action_bound_constraints_table(self):
self.action_lower_bound_constraints = {}
self.action_upper_bound_constraints = {}
for name, preconds in self.local_action_preconditions.items():
for precond in preconds:
expr_type = precond.etype
expr_ar... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_action_bound_constraints_table'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'chil... | Builds the lower and upper action bound constraint expressions. |
def create_release_settings_action(target, source, env):
with open(str(source[0]), "r") as fileobj:
settings = json.load(fileobj)
settings['release'] = True
settings['release_date'] = datetime.datetime.utcnow().isoformat()
settings['dependency_versions'] = {}
for dep in env['TILE'].dependenc... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_release_settings_action'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'c... | Copy module_settings.json and add release and build information |
def release(self):
if not self.acquired:
raise threading.ThreadError("Unable to release an unacquired"
" lock")
try:
self.unlock()
except IOError:
self.logger.exception("Could not unlock the acquired lock opened"
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'release'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Release the previously acquired lock. |
def load_var_file(filename, obj):
rendered = render(filename, obj)
ext = os.path.splitext(filename)[1][1:]
v_obj = dict()
if ext == 'json':
v_obj = json.loads(rendered)
elif ext == 'yaml' or ext == 'yml':
v_obj = yaml.safe_load(rendered)
else:
LOG.warning("assuming yaml f... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_var_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Loads a varible file, processing it as a template |
def update_bucket_size(f):
@wraps(f)
def inner(self, *args, **kwargs):
res = f(self, *args, **kwargs)
self.bucket.size += self.file.size
return res
return inner | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_bucket_size'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Decorate to update bucket size after operation. |
def close(self, notes=None):
self.set_status(self._redmine.ISSUE_STATUS_ID_CLOSED, notes=notes) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Save all changes and close this issue |
def add_alternate_formats(self, filename):
with open(filename, "r") as infile:
xtree = etree.parse(infile)
self.alt_territory = {}
xterritories = xtree.find(TOP_XPATH)
for xterritory in xterritories:
if xterritory.tag == TERRITORY_TAG:
terrobj = XA... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_alternate_formats'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Add phone number alternate format metadata retrieved from XML |
def remove(self, addon, dev=False):
dependencies = self.get_dependency_manager(dev=dev)
other_dependencies = self.get_dependency_manager(dev=not dev)
self.stdout.write(style.format_command('Removing', addon))
removed = dependencies.remove(addon, warn=False)
if not removed:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Remove a dependency and uninstall it. |
def _create_window_function(name, doc=''):
def _():
sc = SparkContext._active_spark_context
jc = getattr(sc._jvm.functions, name)()
return Column(jc)
_.__name__ = name
_.__doc__ = 'Window function: ' + doc
return _ | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_window_function'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Create a window function by name |
def write(self, data):
self._file.write('<cml>')
self.__write(data)
self.write = self.__write | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | write single molecule or reaction into file |
def load_file(client, bucket, data_file):
logger.debug('Loading item from s3. Bucket: {bucket} Key: {key}'.format(
bucket=bucket,
key=data_file
))
try:
data = _get_from_s3(client, bucket, data_file)
except ClientError as ce:
if ce.response['Error']['Code'] == 'NoSuchKey':... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Tries to load JSON data from S3. |
def rest_del(self, url, params=None, auth=None, verify=True, cert=None):
res = requests.delete(url, params=params, auth=auth, verify=verify, cert=cert)
return res.text, res.status_code | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rest_del'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'child... | Perform a DELETE request to url with optional authentication |
def load_yaml_from_url(ont_url):
res = requests.get(ont_url)
if res.status_code != 200:
raise Exception('Could not load ontology from %s' % ont_url)
root = yaml.load(res.content)
return root | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_yaml_from_url'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Return a YAML object loaded from a YAML file URL. |
def listflat(path, ext=None):
if os.path.isdir(path):
if ext:
if ext == 'tif' or ext == 'tiff':
files = glob.glob(os.path.join(path, '*.tif'))
files = files + glob.glob(os.path.join(path, '*.tiff'))
else:
files = glob.glob(os.path.join(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'listflat'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pat... | List files without recursion |
def _process_place(self, place: dict, is_platform: bool) -> None:
place_id = place['id']
self.info[place_id] = Place(place, is_platform) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_process_place'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9']}; {'id': '4', 'type': 'identifier', 'children':... | Extract information from place dictionary. |
def from_rgb(cls, r: int, g: int, b: int) -> 'ColorCode':
c = cls()
c._init_rgb(r, g, b)
return c | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17', '19']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_rgb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13']}; {'id': '4', 'type': 'identifier', 'children':... | Return a ColorCode from a RGB tuple. |
def _generate_request(self, callname, request):
schema = self.api.request_schema()
schema.context['callname'] = callname
return schema.dump(request).data.get("payload") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_request'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | Generate a request object for delivery to the API |
def _is_defaultexit_direct_jump(self):
if not (self.jumpkind == 'Ijk_InvalICache' or self.jumpkind == 'Ijk_Boring' or self.jumpkind == 'Ijk_Call'):
return False
target = self.default_exit_target
return target is not None | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_defaultexit_direct_jump'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [],... | Checks if the default of this IRSB a direct jump or not. |
def as_es2_command(command):
if command[0] == 'FUNC':
return (command[0], re.sub(r'^gl([A-Z])',
lambda m: m.group(1).lower(), command[1])) + command[2:]
if command[0] == 'SHADERS':
return command[:2] + convert_shaders('es2', command[2:])
if command[0] == 'UNIFORM':
re... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_es2_command'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'co... | Modify a desktop command so it works on es2. |
def sync_out(self, release):
if release.get('rsync_out_objs'):
tree = release['canonical_dir']
if not os.path.isdir(tree):
self.log.info('Creating %s', tree)
os.makedirs(tree)
self.call(release['rsync_out_objs'])
self.call(release['... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sync_out'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Sync our tree to the canonical location |
def wikidata(self, title, wikibase=None):
self.domain = 'www.wikidata.org'
self.uri = self.wiki_uri(self.domain)
query = self.WIKIDATA.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
LANG=self.variant or self.lang,
PROPS="aliases|info|claims|des... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wikidata'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Returns Wikidata query string |
def _read(self, limit=1000):
for sock in self.socket():
if sock is None:
return []
try:
packet = sock.recv(4096)
except socket.timeout:
return []
except socket.error as exc:
if exc.args[0] in self.WOU... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Return all the responses read |
def order_to_dict(order):
default = Order()
return {field: val for field, val in vars(order).items() if val != getattr(default, field, None)} | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'order_to_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ord... | Convert an IBPy Order object to a dict containing any non-default values. |
def add_accounts_to_project(accounts_query, project):
query = accounts_query.filter(date_deleted__isnull=True)
for account in query:
add_account_to_project(account, project) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_accounts_to_project'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Add accounts to project. |
def AmericanDateToEpoch(self, date_str):
try:
epoch = time.strptime(date_str, "%m/%d/%Y")
return int(calendar.timegm(epoch)) * 1000000
except ValueError:
return 0 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'AmericanDateToEpoch'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Take a US format date and return epoch. |
def mod_issquare(a, p):
if not a:
return True
p1 = p // 2
p2 = pow(a, p1, p)
return p2 == 1 | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mod_issquare'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Returns whether `a' is a square modulo p |
def narrow_to(self, featuremap):
shape2d = tf.shape(featuremap)[2:]
slice3d = tf.concat([shape2d, [-1]], axis=0)
slice4d = tf.concat([shape2d, [-1, -1]], axis=0)
boxes = tf.slice(self.boxes, [0, 0, 0, 0], slice4d)
gt_labels = tf.slice(self.gt_labels, [0, 0, 0], slice3d)
g... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'narrow_to'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Slice anchors to the spatial size of this featuremap. |
def _convert_todo(p_todo):
creation_date = p_todo.creation_date()
completion_date = p_todo.completion_date()
result = {
'source': p_todo.source(),
'text': p_todo.text(),
'priority': p_todo.priority(),
'completed': p_todo.is_completed(),
'tags': p_todo.tags(),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_todo'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'p_t... | Converts a Todo instance to a dictionary. |
def openMaskFile(filename):
dirname, basename = os.path.split(filename)
newbasename = '_%s_.sbm' % (basename,)
maskfname = os.path.join(dirname, newbasename)
maskfile = openReadWrite(maskfname)
return maskfile | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'openMaskFile'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'file... | Open the bitmask file sitting next to a file in the filesystem. |
def X_length(self, new_window_length):
self.parent.value('window_length', new_window_length)
self.parent.overview.update_position() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'X_length'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Use presets for length of the window. |
def add(self, model):
def foo(m, p, i):
if m[i][0].name == model.name:
raise ValueError("Model already exists")
return
self.foreach(foo)
self.append((model,))
return | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; ... | raises an exception if the model cannot be added |
def playlist(netease, name, id):
if name:
netease.download_playlist_by_search(name)
if id:
netease.download_playlist_by_id(id, 'playlist'+str(id)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'playlist'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Download a playlist's songs by id. |
def clean_var(text):
text = re_invalid_var.sub('', text)
text = re_invalid_start.sub('', text)
return text | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_var'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'};... | Turn text into a valid python classname or variable |
def load_markov(argv, stdin):
if len(argv) > 3:
with open(argv[3]) as input_file:
return Algorithm(input_file.readlines())
else:
return Algorithm(stdin.readlines()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_markov'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Load and return markov algorithm. |
def _logger_stream(self):
sh = logging.StreamHandler()
sh.set_name('sh')
sh.setLevel(logging.INFO)
sh.setFormatter(self._logger_formatter)
self.log.addHandler(sh) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_logger_stream'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Add stream logging handler. |
def update_health(self, reporter, info):
with self.changes_squashed:
alarm = info.alarm
if alarm.is_ok():
self._faults.pop(reporter, None)
else:
self._faults[reporter] = alarm
if self._faults:
faults = sorted(self._f... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_health'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Set the health attribute. Called from part |
def _missing_value_message(self, parent):
if self._attribute is None:
message = 'Missing required value for element "{}"'.format(self.element_path)
else:
if self.element_path == '.':
parent_name = parent.tag
else:
parent_name = self.ele... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_missing_value_message'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],... | Return the message to report that the value needed for serialization is missing. |
def _WorkerCommand_launcher(self):
return [
self.workersArguments.pythonExecutable,
'-m',
'scoop.launch.__main__',
str(self.workerAmount),
str(self.workersArguments.verbose),
] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_WorkerCommand_launcher'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Return list commands to start the bootstrap process |
def normalize_bearing(bearing, check_hex=False):
if bearing > 360 and check_hex:
bearing = bin(int(bearing))[2:]
bearing = ''.join([str(int(int(a) == 0)) for a in bearing])
bearing = -float(int(bearing, 2))
bearing %= 360
return bearing | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_bearing'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Normalize bearing and convert from hex if |
def sqlvm_aglistener_create(client, cmd, availability_group_listener_name, sql_virtual_machine_group_name,
resource_group_name, availability_group_name, ip_address, subnet_resource_id,
load_balancer_resource_id, probe_port, sql_virtual_machine_instances, port=1433... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sqlvm_aglistener_create'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14',... | Creates an availability group listener |
def resolve_real_bind_addr(socket_):
bind_addr = socket_.getsockname()
if socket_.family in (
socket.AF_INET,
socket.AF_INET6,
):
return bind_addr[:2]
return bind_addr | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve_real_bind_addr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Retrieve actual bind addr from bound socket. |
def _WriteStorageMetadata(self):
self._cursor.execute(self._CREATE_METADATA_TABLE_QUERY)
query = 'INSERT INTO metadata (key, value) VALUES (?, ?)'
key = 'format_version'
value = '{0:d}'.format(self._FORMAT_VERSION)
self._cursor.execute(query, (key, value))
key = 'compression_format'
value = ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_WriteStorageMetadata'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Writes the storage metadata. |
def exists(self, path):
(bucket, key) = self._path_to_bucket_and_key(path)
if self._is_root(key):
return True
if self._exists(bucket, key):
return True
if self.isdir(path):
return True
logger.debug('Path %s does not exist', path)
return... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Does provided path exist on S3? |
def add_tokens_for_group(self, with_pass=False):
kls = self.groups.super_kls
name = self.groups.kls_name
self.reset_indentation('')
self.result.extend(self.tokens.make_describe(kls, name))
if with_pass:
self.add_tokens_for_pass()
self.groups.finish_signature() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_tokens_for_group'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Add the tokens for the group signature |
def run(self):
self.loop = asyncio.new_event_loop()
self.loop.run_until_complete(self.open_async()) | {'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'... | Makes pump sync so that it can be run in a thread. |
def _run_concat_variant_files_bcftools(in_list, out_file, config, naive=False):
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
bcftools = config_utils.get_program("bcftools", config)
output_type = "z" if out_file.endswith(".gz") else "v"
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_run_concat_variant_files_bcftools'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'ident... | Concatenate variant files using bcftools concat, potentially using the fast naive option. |
def format (self, record):
record.hostname = self.hostname
return logging.Formatter.format(self, record) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Returns the given LogRecord as formatted text. |
def check_status(self, job_id):
response, http_response = self._client.jobs.get_job(job_id=job_id).\
result()
if http_response.status_code == 404:
raise HTTPNotFound('The given job ID was not found. Error: {}'.
format(http_response.data))
re... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_status'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Check status of a job. |
def arg_to_soql(arg):
conversion = sql_conversions.get(type(arg))
if conversion:
return conversion(arg)
for type_ in subclass_conversions:
if isinstance(arg, type_):
return sql_conversions[type_](arg)
return sql_conversions[str](arg) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'arg_to_soql'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arg'}... | Perform necessary SOQL quoting on the arg. |
def nvecs(X, n, rank, do_flipsign=True, dtype=np.float):
Xn = X.unfold(n)
if issparse_mat(Xn):
Xn = csr_matrix(Xn, dtype=dtype)
Y = Xn.dot(Xn.T)
_, U = eigsh(Y, rank, which='LM')
else:
Y = Xn.dot(Xn.T)
N = Y.shape[0]
_, U = eigh(Y, eigvals=(N - rank, N - 1))
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nvecs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10']}; {'id': '4', 'type': 'identifier', 'children': [],... | Eigendecomposition of mode-n unfolding of a tensor |
def load_file_as_string(self, file_string, filename=''):
load_data.load_file_as_string(self, file_string, filename=filename) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_file_as_string'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [... | Load file as a string. |
def show_lbaas_pool(self, lbaas_pool, **_params):
return self.get(self.lbaas_pool_path % (lbaas_pool),
params=_params) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_lbaas_pool'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Fetches information for a lbaas_pool. |
def to_ufo_family_user_data(self, ufo):
if not self.use_designspace:
ufo.lib[FONT_USER_DATA_KEY] = dict(self.font.userData) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_ufo_family_user_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': []... | Set family-wide user data as Glyphs does. |
def repoExitError(message):
wrapper = textwrap.TextWrapper(
break_on_hyphens=False, break_long_words=False)
formatted = wrapper.fill("{}: error: {}".format(sys.argv[0], message))
sys.exit(formatted) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'repoExitError'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mes... | Exits the repo manager with error status. |
def start_blocking(self):
self._cav_started.clear()
self.start()
self._cav_started.wait() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start_blocking'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Start the advertiser in the background, but wait until it is ready |
def MatrixTriangularSolve(a, rhs, lower, adj):
trans = 0 if not adj else 2
r = np.empty(rhs.shape).astype(a.dtype)
for coord in np.ndindex(a.shape[:-2]):
pos = coord + (Ellipsis,)
r[pos] = sp.linalg.solve_triangular(a[pos] if not adj else np.conj(a[pos]), rhs[pos],
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'MatrixTriangularSolve'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'child... | Matrix triangular solve op. |
def BinaryOperator(self, string=None, **unused_kwargs):
self.stack.append(self.binary_expression_cls(string)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'BinaryOperator'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Set the binary operator. |
def _harvest_lost_resources(self):
with self._lock:
for i in self._unavailable_range():
rtracker = self._reference_queue[i]
if rtracker is not None and rtracker.available():
self.put_resource(rtracker.resource) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_harvest_lost_resources'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'va... | Return lost resources to pool. |
async def connect(self):
if isinstance(self.connection, dict):
kwargs = self.connection.copy()
address = (
kwargs.pop('host', 'localhost'),
kwargs.pop('port', 6379)
)
redis_kwargs = kwargs
elif isinstance(self.connection, ai... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Get an connection for the self instance |
def create_cache(self, **kwargs):
cache = predix.admin.cache.Cache(**kwargs)
cache.create(**kwargs)
cache.add_to_manifest(self)
return cache | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_cache'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Creates an instance of the Cache Service. |
def vn(x):
if x == []:
return None
if isinstance(x, list):
return '|'.join(x)
if isinstance(x, datetime):
return x.isoformat()
return x | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'vn'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '5... | value or none, returns none if x is an empty list |
def handle_transform(self, task):
self.transformed += 1
file = task.result()
if file:
self.next.append_file(file)
self.flush_if_ended() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_transform'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Handle a 'transform' callback. |
def nodePop(ctxt):
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
ret = libxml2mod.nodePop(ctxt__o)
if ret is None:raise treeError('nodePop() failed')
return xmlNode(_obj=ret) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'nodePop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ctxt'}; {... | Pops the top element node from the node stack |
def do_print(self,args):
parser = CommandArgumentParser("print")
parser.add_argument('-r','--refresh',dest='refresh',action='store_true',help='refresh view of the current stack')
parser.add_argument('-i','--include',dest='include',default=None,nargs='+',help='resource types to include')
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_print'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Print the current stack. print -h for detailed help |
def run(files, temp_folder):
"Check frosted errors in the code base."
try:
import frosted
except ImportError:
return NO_FROSTED_MSG
py_files = filter_python_files(files)
cmd = 'frosted {0}'.format(' '.join(py_files))
return bash(cmd).value() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'files'};... | Check frosted errors in the code base. |
def rollback(self, transaction = None):
if not self.in_transaction:
raise NotInTransaction
for collection, store in self.stores.items():
store.rollback()
indexes = self.indexes[collection]
indexes_to_rebuild = []
for key, index in indexes.items... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rollback'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Roll back a transaction. |
def consume(self, kind):
next_token = self.stream.move()
if next_token.kind != kind:
raise UnexpectedTokenError(token=next_token, expected_kind=kind) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'consume'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Consume one token and verify it is of the expected kind. |
def update_attributes(self, **original_kwargs):
def update_attrs(layout_object):
kwargs = original_kwargs.copy()
if hasattr(layout_object, 'attrs'):
if 'css_class' in kwargs:
if 'class' in layout_object.attrs:
layout_object.attr... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_attributes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Updates attributes of every layout object pointed in `self.slice` using kwargs |
def generate(self, overwrite=False):
super(Upstart, self).generate(overwrite=overwrite)
svc_file_template = self.template_prefix + '.conf'
self.svc_file_path = self.generate_into_prefix + '.conf'
self.generate_file_from_template(svc_file_template, self.svc_file_path)
return self.... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Generate a config file for an upstart service. |
def name_replace(self, to_replace, replacement):
self.name = self.name.replace(to_replace, replacement) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'name_replace'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Replaces part of tag name with new value |
def _color(self, msg, color):
kwargs = {'fg': color}
return click.style(msg, **kwargs) if self.colorize else msg | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_color'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Internal helper method to add colors to input |
def _record_first_run():
info = {'pid': _get_shell_pid(),
'time': time.time()}
mode = 'wb' if six.PY2 else 'w'
with _get_not_configured_usage_tracker_path().open(mode) as tracker:
json.dump(info, tracker) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_record_first_run'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '21', '30']}; {... | Records shell pid to tracker file. |
def shuffle_into_deck(self):
return self.game.cheat_action(self, [actions.Shuffle(self.controller, self)]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'shuffle_into_deck'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Shuffle the card into the controller's deck |
def _domain_event_device_removal_failed_cb(conn, domain, dev, opaque):
_salt_send_domain_event(opaque, conn, domain, opaque['event'], {
'dev': dev
}) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_domain_event_device_removal_failed_cb'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'id... | Domain device removal failure events handler |
async def reboot():
async with aiohttp.ClientSession() as session:
ghlocalapi = DeviceSettings(LOOP, session, IPADDRESS)
result = await ghlocalapi.reboot()
print("Reboot info:", result) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reboot'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5']}; {'id': '5', 'type': 'wit... | Reboot a Google Home unit. |
def logout(self):
self.transfers_complete
payload = {
'apikey': self.config.get('apikey'),
'logintoken': self.session.cookies.get('logintoken')
}
method, url = get_URL('logout')
res = getattr(self.session, method)(url, params=payload)
if res.st... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logout'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Logout of filemail and closing the session. |
def dummy_image(filetype='gif'):
GIF = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
tmp_file = tempfile.NamedTemporaryFile(suffix='.%s' % filetype)
tmp_file.write(base64.b64decode(GIF))
return open(tmp_file.name, 'rb') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dummy_image'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']};... | Generate empty image in temporary file for testing |
def _put_bucket_cors(self):
if self.s3props['cors']['enabled'] and self.s3props['website']['enabled']:
cors_config = {}
cors_rules = []
for each_rule in self.s3props['cors']['cors_rules']:
cors_rules.append({
'AllowedHeaders': each_rule['co... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_put_bucket_cors'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Adds bucket cors configuration. |
def _snpeff_args_from_config(data):
config = data["config"]
args = ["-hgvs"]
resources = config_utils.get_resources("snpeff", config)
if resources.get("options"):
args += [str(x) for x in resources.get("options", [])]
if vcfutils.get_paired_phenotype(data):
args += ["-cancer"]
ef... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_snpeff_args_from_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Retrieve snpEff arguments supplied through input configuration. |
def _as_list(obj):
if obj is None:
return None
elif isinstance(obj, string_types):
return [obj]
elif isinstance(obj, tuple):
return list(obj)
elif not hasattr(obj, '__len__'):
return [obj]
else:
return obj | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_as_list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj'}; {... | Ensure an object is a list. |
def list_members(context, request):
members = context.members()
return {
'users': [{
'username': m.identifier,
'userid': m.userid,
'roles': context.get_member_roles(m.userid),
'links': [rellink(m, request)]
} for m in members]
} | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_members'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Return the list of users in the group. |
def to_jd(year, month, day):
legal_date(year, month, day)
gyear = year + YEAR_EPOCH - 1
return (
gregorian.EPOCH - 1 + (365 * (gyear - 1)) +
floor((gyear - 1) / 4) + (-floor((gyear - 1) / 100)) +
floor((gyear - 1) / 400) + (month - 1) * 28 + day
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_jd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'y... | Convert a Positivist date to Julian day count. |
def _validate(self):
if self.data_format is FormatType.PYTHON:
self.data = self.raw_data
elif self.data_format is FormatType.JSON:
self._validate_json()
elif self.data_format is FormatType.YAML:
self._validate_yaml() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Validate the input data. |
def step(self, amt=1):
"Make a frame of the animation"
self.move_particles()
if self.has_moving_emitters:
self.move_emitters()
self.start_new_particles()
self.render_particles()
if self.emitters == [] and self.particles == []:
self.completed = True | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'step'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Make a frame of the animation |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.