code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
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)
module function_definition identifier parameters identifier identifier identifier block try_statement block return_statement subscript identifier identifier except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute attribute identifier identifier identifier
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()
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
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'])
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list subscript subscript identifier string string_start string_content string_end string string_start string_content string_end
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 the_shell = [shell for shell in shells if shell['id'] == result.id][0] self.__handle_variable(the_shell['entry'], result.output) if not result.success: success = False if success: self.logger.info("Parallel Processing Bash code: finished") return {'success': True, 'output': output} for line in self.run_cleanup(shells[0]['env'], 99): output.append(line) self.logger.error("Pipeline has failed: immediately leaving!") self.event.failed() return {'success': False, 'output': output}
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list expression_statement assignment identifier true with_statement with_clause with_item as_pattern call identifier argument_list call attribute identifier identifier argument_list call attribute identifier identifier argument_list as_pattern_target identifier block for_statement identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list identifier list_comprehension identifier for_in_clause identifier identifier block expression_statement augmented_assignment identifier attribute identifier identifier expression_statement assignment identifier subscript list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier integer expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end attribute identifier identifier if_statement not_operator attribute identifier identifier block expression_statement assignment identifier false if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end return_statement dictionary pair string string_start string_content string_end true pair string string_start string_content string_end identifier for_statement identifier call attribute identifier identifier argument_list subscript subscript identifier integer string string_start string_content string_end integer block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list return_statement dictionary pair string string_start string_content string_end false pair string string_start string_content string_end identifier
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
module function_definition identifier parameters block if_statement call identifier argument_list block with_statement with_clause with_item as_pattern call identifier argument_list string string_start string_content string_end string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier else_clause block return_statement false
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
module function_definition identifier parameters identifier block expression_statement assignment identifier integer for_statement identifier call attribute identifier identifier argument_list block expression_statement augmented_assignment identifier call attribute identifier identifier argument_list return_statement identifier
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), (_("Source toolbar"), "source_toolbar", self.main.source_toolbar_actions), (_("Run toolbar"), "run_toolbar", self.main.run_toolbar_actions), (_("Debug toolbar"), "debug_toolbar", self.main.debug_toolbar_actions), (_("Edit toolbar"), "edit_toolbar", self.main.edit_toolbar_actions)) self.menu_list = ((_("&File"), self.main.file_menu_actions), (_("&Edit"), self.main.edit_menu_actions), (_("&Search"), self.main.search_menu_actions), (_("Sour&ce"), self.main.source_menu_actions), (_("&Run"), self.main.run_menu_actions), (_("&Tools"), self.main.tools_menu_actions), (_("&View"), []), (_("&Help"), self.main.help_menu_actions)) for layout_settings in self.editorwindows_to_be_created: win = self.create_new_window() win.set_layout_settings(layout_settings)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier tuple tuple call identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end string string_start string_content string_end attribute attribute identifier identifier identifier expression_statement assignment attribute identifier identifier tuple tuple call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier tuple call identifier argument_list string string_start string_content string_end list tuple call identifier argument_list string string_start string_content string_end attribute attribute identifier identifier identifier for_statement identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier
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 not isinstance(value, bool)) or \ (field_type == defs.INTEGER_TYPE and not isinstance(value, int)): raise exceptions.ConfigFieldTypeMismatch(field, value, field_type) if field_type == defs.INTEGER_TYPE: if _min and value < _min: raise exceptions.ConfigFieldTypeMismatch(field, value, "must be higher than {}".format(_min)) if _max and value > _max: raise exceptions.ConfigFieldTypeMismatch(field, value, "must be lower than {}".format(_max)) if field_type == defs.SELECT_TYPE: from honeycomb.utils.plugin_utils import get_select_items items = get_select_items(select_items) if value not in items: raise exceptions.ConfigFieldTypeMismatch(field, value, "one of: {}".format(", ".join(items)))
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement boolean_operator boolean_operator boolean_operator parenthesized_expression boolean_operator comparison_operator identifier attribute identifier identifier not_operator call identifier argument_list identifier attribute identifier identifier line_continuation parenthesized_expression boolean_operator comparison_operator identifier attribute identifier identifier not_operator call identifier argument_list identifier attribute identifier identifier line_continuation parenthesized_expression boolean_operator comparison_operator identifier attribute identifier identifier not_operator call identifier argument_list identifier identifier line_continuation parenthesized_expression boolean_operator comparison_operator identifier attribute identifier identifier not_operator call identifier argument_list identifier identifier block raise_statement call attribute identifier identifier argument_list identifier identifier identifier if_statement comparison_operator identifier attribute identifier identifier block if_statement boolean_operator identifier comparison_operator identifier identifier block raise_statement call attribute identifier identifier argument_list identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement boolean_operator identifier comparison_operator identifier identifier block raise_statement call attribute identifier identifier argument_list identifier identifier call attribute string string_start string_content string_end identifier argument_list identifier if_statement comparison_operator identifier attribute identifier identifier block import_from_statement dotted_name identifier identifier identifier dotted_name identifier expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block raise_statement call attribute identifier identifier argument_list identifier identifier call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier
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, [call.left_hand_side], line_number=ast_node.lineno, path=self.filenames[-1], call_node=call ) call.connect(call_assignment) self.nodes.append(call_assignment) self.undecided = False return call_assignment
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier true expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list binary_operator binary_operator identifier string string_start string_content string_end identifier identifier identifier list attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier subscript attribute identifier identifier unary_operator integer keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier false return_statement identifier
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, )
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end keyword_argument identifier identifier keyword_argument identifier identifier
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: log.debug("Sending login request") f = opener.open(req) except URLError as e: log.error("Failed to connect to the database -> probably down!") log.error("Error from database server:\n {0}".format(e)) return False html = f.read() failed_auth_message = 'Bad username or password' if failed_auth_message in str(html): log.error(failed_auth_message) return False return True
module function_definition identifier parameters identifier identifier identifier block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier identifier try_statement block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list identifier return_statement false expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement false return_statement true
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
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
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", self.url, err.__class__.__name__, err)
module function_definition identifier parameters identifier identifier identifier block if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier try_statement block expression_statement await call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end attribute identifier identifier attribute attribute identifier identifier identifier identifier
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)
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block return_statement call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier none keyword_argument identifier identifier
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: _drill = _str2bool(local_drill) sys.excepthook = _excepthook
module function_definition identifier parameters block global_statement identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier
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
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier true block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier false
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_args = precond.args bounds_expr = None if expr_type == ('aggregation', 'forall'): inner_expr = expr_args[1] if inner_expr.etype[0] == 'relational': bounds_expr = inner_expr elif expr_type[0] == 'relational': bounds_expr = precond if bounds_expr: bound = self._extract_lower_bound(name, bounds_expr) if bound is not None: self.action_lower_bound_constraints[name] = bound else: bound = self._extract_upper_bound(name, bounds_expr) if bound is not None: self.action_upper_bound_constraints[name] = bound
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier dictionary expression_statement assignment attribute identifier identifier dictionary for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block for_statement identifier identifier block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier none if_statement comparison_operator identifier tuple string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript identifier integer if_statement comparison_operator subscript attribute identifier identifier integer string string_start string_content string_end block expression_statement assignment identifier identifier elif_clause comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier identifier if_statement identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement comparison_operator identifier none block expression_statement assignment subscript attribute identifier identifier identifier identifier
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'].dependencies: tile = IOTile(os.path.join('build', 'deps', dep['unique_id'])) settings['dependency_versions'][dep['unique_id']] = str(tile.parsed_version) with open(str(target[0]), "w") as fileobj: json.dump(settings, fileobj, indent=4)
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list call identifier argument_list subscript identifier integer string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment subscript identifier string string_start string_content string_end true expression_statement assignment subscript identifier string string_start string_content string_end call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end dictionary for_statement identifier attribute subscript identifier string string_start string_content string_end identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier with_statement with_clause with_item as_pattern call identifier argument_list call identifier argument_list subscript identifier integer string string_start string_content string_end as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier integer
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" " on `%s`", self.path) else: self.acquired = False try: self._do_close() except IOError: self.logger.exception("Could not close the file handle" " opened on `%s`", self.path) else: self.logger.log(_utils.BLATHER, "Unlocked and closed file lock open on" " `%s`", self.path)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier else_clause block expression_statement assignment attribute identifier identifier false try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute attribute identifier identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier concatenated_string string string_start string_content string_end string string_start string_content string_end attribute identifier identifier
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 for unrecognized extension %s", ext) v_obj = yaml.safe_load(rendered) return v_obj
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier subscript subscript call attribute attribute identifier identifier identifier argument_list identifier integer slice integer expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier elif_clause boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier return_statement identifier
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
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list identifier list_splat identifier dictionary_splat identifier expression_statement augmented_assignment attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier return_statement identifier return_statement identifier
Decorate to update bucket size after operation.
def close(self, notes=None): self.set_status(self._redmine.ISSUE_STATUS_ID_CLOSED, notes=notes)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement call attribute identifier identifier argument_list attribute attribute identifier identifier identifier keyword_argument identifier identifier
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 = XAlternateTerritory(xterritory) id = str(terrobj.country_code) if id in self.alt_territory: raise Exception("Duplicate entry for %s" % id) self.alt_territory[id] = terrobj else: raise Exception("Unexpected element %s found" % xterritory.tag)
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier dictionary expression_statement assignment identifier call attribute identifier identifier argument_list identifier for_statement identifier identifier block if_statement comparison_operator attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment subscript attribute identifier identifier identifier identifier else_clause block raise_statement call identifier argument_list binary_operator string string_start string_content string_end attribute identifier identifier
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: removed = other_dependencies.remove(addon, warn=False) if removed: self.build() else: exception = '%s is not installed.' % Dependency(addon).to_stdout() self.stdout.write(style.red(exception))
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier not_operator identifier expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false if_statement not_operator identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier false if_statement identifier block expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier binary_operator string string_start string_content string_end call attribute call identifier argument_list identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier
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 _
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call call identifier argument_list attribute attribute identifier identifier identifier identifier argument_list return_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier binary_operator string string_start string_content string_end identifier return_statement identifier
Create a window function by name
def write(self, data): self._file.write('<cml>') self.__write(data) self.write = self.__write
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
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': return {} else: raise ce if sys.version_info > (3,): data = data.decode('utf-8') return json.loads(data)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block return_statement dictionary else_clause block raise_statement identifier if_statement comparison_operator attribute identifier identifier tuple integer block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement call attribute identifier identifier argument_list identifier
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
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier true default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement expression_list attribute identifier identifier attribute identifier identifier
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
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement identifier
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(path, '*.' + ext)) else: files = [os.path.join(path, fname) for fname in os.listdir(path)] else: files = glob.glob(path) files = [fpath for fpath in files if not isinstance(fpath, list) and not os.path.isdir(fpath)] return sorted(files)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement call attribute attribute identifier identifier identifier argument_list identifier block if_statement identifier block if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier binary_operator string string_start string_content string_end identifier else_clause block expression_statement assignment identifier list_comprehension call attribute attribute identifier identifier identifier argument_list identifier identifier for_in_clause identifier call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause boolean_operator not_operator call identifier argument_list identifier identifier not_operator call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list identifier
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)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list identifier identifier
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
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type string string_start string_content string_end block expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier identifier identifier return_statement identifier
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")
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end identifier return_statement call attribute attribute call attribute identifier identifier argument_list identifier identifier identifier argument_list string string_start string_content string_end
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
module function_definition identifier parameters identifier block if_statement not_operator parenthesized_expression boolean_operator boolean_operator comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement false expression_statement assignment identifier attribute identifier identifier return_statement comparison_operator identifier none
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': return command[:-1] + (command[-1].tolist(),) return command
module function_definition identifier parameters identifier block if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement binary_operator tuple subscript identifier integer call attribute identifier identifier argument_list string string_start string_content string_end lambda lambda_parameters identifier call attribute call attribute identifier identifier argument_list integer identifier argument_list subscript identifier integer subscript identifier slice integer if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement binary_operator subscript identifier slice integer call identifier argument_list string string_start string_content string_end subscript identifier slice integer if_statement comparison_operator subscript identifier integer string string_start string_content string_end block return_statement binary_operator subscript identifier slice unary_operator integer tuple call attribute subscript identifier unary_operator integer identifier argument_list return_statement identifier
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['rsync_out_rest'])
module function_definition identifier parameters identifier identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list subscript identifier string string_start string_content string_end
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|descriptions|labels|sitelinks") if wikibase: query += "&ids=%s" % wikibase elif title: title = safequote(title) query += "&sites=%swiki" % self.lang query += "&titles=%s" % title self.set_status('wikidata', wikibase or title) return query
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier attribute identifier identifier keyword_argument identifier string string_start string_content string_end if_statement identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier elif_clause identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end boolean_operator identifier identifier return_statement identifier
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.WOULD_BLOCK_ERRS: return [] else: raise self._buffer += packet responses = [] total = 0 buf = self._buffer remaining = len(buf) while limit and (remaining >= 4): size = struct.unpack('>l', buf[total:(total + 4)])[0] if (remaining - 4) >= size: responses.append(Response.from_raw( self, buf[(total + 4):(total + size + 4)])) total += (size + 4) remaining -= (size + 4) limit -= 1 else: break self._buffer = self._buffer[total:] return responses
module function_definition identifier parameters identifier default_parameter identifier integer block for_statement identifier call attribute identifier identifier argument_list block if_statement comparison_operator identifier none block return_statement list try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list integer except_clause attribute identifier identifier block return_statement list except_clause as_pattern attribute identifier identifier as_pattern_target identifier block if_statement comparison_operator subscript attribute identifier identifier integer attribute identifier identifier block return_statement list else_clause block raise_statement expression_statement augmented_assignment attribute identifier identifier identifier expression_statement assignment identifier list expression_statement assignment identifier integer expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier while_statement boolean_operator identifier parenthesized_expression comparison_operator identifier integer block expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier slice identifier parenthesized_expression binary_operator identifier integer integer if_statement comparison_operator parenthesized_expression binary_operator identifier integer identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier subscript identifier slice parenthesized_expression binary_operator identifier integer parenthesized_expression binary_operator binary_operator identifier identifier integer expression_statement augmented_assignment identifier parenthesized_expression binary_operator identifier integer expression_statement augmented_assignment identifier parenthesized_expression binary_operator identifier integer expression_statement augmented_assignment identifier integer else_clause block break_statement expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice identifier return_statement identifier
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)}
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list return_statement dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute call identifier argument_list identifier identifier argument_list if_clause comparison_operator identifier call identifier argument_list identifier identifier none
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)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier true for_statement identifier identifier block expression_statement call identifier argument_list identifier identifier
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
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end return_statement binary_operator call identifier argument_list call attribute identifier identifier argument_list identifier integer except_clause identifier block return_statement integer
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
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement true expression_statement assignment identifier binary_operator identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier identifier return_statement comparison_operator identifier integer
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) gt_boxes = tf.slice(self.gt_boxes, [0, 0, 0, 0], slice4d) return RPNAnchors(boxes, gt_labels, gt_boxes)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list identifier slice integer expression_statement assignment identifier call attribute identifier identifier argument_list list identifier list unary_operator integer keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list list identifier list unary_operator integer unary_operator integer keyword_argument identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier list integer integer integer integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier list integer integer integer identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier list integer integer integer integer identifier return_statement call identifier argument_list identifier identifier identifier
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(), 'projects': list(p_todo.projects()), 'contexts': list(p_todo.contexts()), 'creation_date': creation_date.isoformat() if creation_date else None, 'completion_date': completion_date.isoformat() if completion_date else None } return result
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list pair string string_start string_content string_end call identifier argument_list call attribute identifier identifier argument_list pair string string_start string_content string_end conditional_expression call attribute identifier identifier argument_list identifier none pair string string_start string_content string_end conditional_expression call attribute identifier identifier argument_list identifier none return_statement identifier
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
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
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()
module function_definition identifier parameters identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute attribute attribute identifier identifier identifier identifier argument_list
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
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator attribute subscript subscript identifier identifier integer identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list tuple identifier return_statement
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))
module function_definition identifier parameters identifier identifier identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier binary_operator string string_start string_content string_end call identifier argument_list identifier
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
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_end identifier return_statement identifier
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())
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block with_statement with_clause with_item as_pattern call identifier argument_list subscript identifier integer as_pattern_target identifier block return_statement call identifier argument_list call attribute identifier identifier argument_list else_clause block return_statement call identifier argument_list call attribute identifier identifier argument_list
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)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
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._faults.values(), key=lambda a: a.severity.value) alarm = faults[-1] text = faults[-1].message else: alarm = None text = "OK" self.health.set_value(text, alarm=alarm)
module function_definition identifier parameters identifier identifier identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement call attribute identifier identifier argument_list block expression_statement call attribute attribute identifier identifier identifier argument_list identifier none else_clause block expression_statement assignment subscript attribute identifier identifier identifier identifier if_statement attribute identifier identifier block expression_statement assignment identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list keyword_argument identifier lambda lambda_parameters identifier attribute attribute identifier identifier identifier expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier attribute subscript identifier unary_operator integer identifier else_clause block expression_statement assignment identifier none expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier
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.element_path message = 'Missing required value for attribute "{}" on element "{}"'.format( self._attribute, parent_name) return message
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier else_clause block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block expression_statement assignment identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier identifier return_statement identifier
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), ]
module function_definition identifier parameters identifier block return_statement list attribute attribute identifier identifier identifier string string_start string_content string_end string string_start string_content string_end call identifier argument_list attribute identifier identifier call identifier argument_list attribute attribute identifier identifier identifier
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
module function_definition identifier parameters identifier default_parameter identifier false block if_statement boolean_operator comparison_operator identifier integer identifier block expression_statement assignment identifier subscript call identifier argument_list call identifier argument_list identifier slice integer expression_statement assignment identifier call attribute string string_start string_end identifier argument_list list_comprehension call identifier argument_list call identifier argument_list comparison_operator call identifier argument_list identifier integer for_in_clause identifier identifier expression_statement assignment identifier unary_operator call identifier argument_list call identifier argument_list identifier integer expression_statement augmented_assignment identifier integer return_statement identifier
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, public_ip_address_resource_id=None): if not is_valid_resource_id(subnet_resource_id): raise CLIError("Invalid subnet resource id.") if not is_valid_resource_id(load_balancer_resource_id): raise CLIError("Invalid load balancer resource id.") if public_ip_address_resource_id and not is_valid_resource_id(public_ip_address_resource_id): raise CLIError("Invalid public IP address resource id.") for sqlvm in sql_virtual_machine_instances: if not is_valid_resource_id(sqlvm): raise CLIError("Invalid SQL virtual machine resource id.") private_ip_object = PrivateIPAddress(ip_address=ip_address, subnet_resource_id=subnet_resource_id if is_valid_resource_id(subnet_resource_id) else None) load_balancer_object = LoadBalancerConfiguration(private_ip_address=private_ip_object, public_ip_address_resource_id=public_ip_address_resource_id, load_balancer_resource_id=load_balancer_resource_id, probe_port=probe_port, sql_virtual_machine_instances=sql_virtual_machine_instances) ag_listener_object = AvailabilityGroupListener(availability_group_name=availability_group_name, load_balancer_configurations=load_balancer_object, port=port) LongRunningOperation(cmd.cli_ctx)(sdk_no_wait(False, client.create_or_update, resource_group_name, sql_virtual_machine_group_name, availability_group_listener_name, ag_listener_object)) return client.get(resource_group_name, sql_virtual_machine_group_name, availability_group_listener_name)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier identifier default_parameter identifier integer default_parameter identifier none block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement boolean_operator identifier not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier conditional_expression identifier call identifier argument_list identifier none expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call call identifier argument_list attribute identifier identifier argument_list call identifier argument_list false attribute identifier identifier identifier identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier identifier identifier
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
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier tuple attribute identifier identifier attribute identifier identifier block return_statement subscript identifier slice integer return_statement identifier
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 = self.compression_format self._cursor.execute(query, (key, value)) key = 'serialization_format' value = self.serialization_format self._cursor.execute(query, (key, value)) key = 'storage_type' value = self.storage_type self._cursor.execute(query, (key, value))
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier tuple identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier tuple identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier tuple identifier identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier tuple identifier identifier
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 False
module function_definition identifier parameters identifier identifier block expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list identifier block return_statement true if_statement call attribute identifier identifier argument_list identifier identifier block return_statement true if_statement call attribute identifier identifier argument_list identifier block return_statement true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement false
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()
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Add the tokens for the group signature
def run(self): self.loop = asyncio.new_event_loop() self.loop.run_until_complete(self.open_async())
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list
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" if naive: args = "--naive" else: args = "--allow-overlaps" cmd = "{bcftools} concat {args} -O {output_type} --file-list {in_list} -o {tx_out_file}" do.run(cmd.format(**locals()), "bcftools concat variants") if out_file.endswith(".gz"): bgzip_and_index(out_file, config) return out_file
module function_definition identifier parameters identifier identifier identifier default_parameter identifier false block if_statement not_operator call attribute identifier identifier argument_list identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement assignment identifier conditional_expression string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end if_statement identifier block expression_statement assignment identifier string string_start string_content string_end else_clause block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list dictionary_splat call identifier argument_list string string_start string_content string_end if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement call identifier argument_list identifier identifier return_statement identifier
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)
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier
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)) return response
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute call attribute attribute attribute identifier identifier identifier identifier argument_list keyword_argument identifier identifier line_continuation identifier argument_list if_statement comparison_operator attribute identifier identifier integer block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier return_statement identifier
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)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier if_statement identifier block return_statement call identifier argument_list identifier for_statement identifier identifier block if_statement call identifier argument_list identifier identifier block return_statement call subscript identifier identifier argument_list identifier return_statement call subscript identifier identifier argument_list identifier
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)) U = array(U[:, ::-1]) if do_flipsign: U = flipsign(U) return U
module function_definition identifier parameters identifier identifier identifier default_parameter identifier true default_parameter identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier keyword_argument identifier string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier subscript attribute identifier identifier integer expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier keyword_argument identifier tuple binary_operator identifier identifier binary_operator identifier integer expression_statement assignment identifier call identifier argument_list subscript identifier slice slice unary_operator integer if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier return_statement identifier
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)
module function_definition identifier parameters identifier identifier default_parameter identifier string string_start string_end block expression_statement call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier
Load file as a string.
def show_lbaas_pool(self, lbaas_pool, **_params): return self.get(self.lbaas_pool_path % (lbaas_pool), params=_params)
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block return_statement call attribute identifier identifier argument_list binary_operator attribute identifier identifier parenthesized_expression identifier keyword_argument identifier identifier
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)
module function_definition identifier parameters identifier identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier call identifier argument_list attribute attribute identifier identifier identifier
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)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier false keyword_argument identifier false expression_statement assignment identifier call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier integer identifier expression_statement call attribute identifier identifier argument_list identifier
Exits the repo manager with error status.
def start_blocking(self): self._cav_started.clear() self.start() self._cav_started.wait()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
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], trans=trans, lower=lower) return r,
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier conditional_expression integer not_operator identifier integer expression_statement assignment identifier call attribute call attribute identifier identifier argument_list attribute identifier identifier identifier argument_list attribute identifier identifier for_statement identifier call attribute identifier identifier argument_list subscript attribute identifier identifier slice unary_operator integer block expression_statement assignment identifier binary_operator identifier tuple identifier expression_statement assignment subscript identifier identifier call attribute attribute identifier identifier identifier argument_list conditional_expression subscript identifier identifier not_operator identifier call attribute identifier identifier argument_list subscript identifier identifier subscript identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement expression_list identifier
Matrix triangular solve op.
def BinaryOperator(self, string=None, **unused_kwargs): self.stack.append(self.binary_expression_cls(string))
module function_definition identifier parameters identifier default_parameter identifier none dictionary_splat_pattern identifier block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier
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)
module function_definition identifier parameters identifier block with_statement with_clause with_item attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list block expression_statement assignment identifier subscript attribute identifier identifier identifier if_statement boolean_operator comparison_operator identifier none call attribute identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list attribute identifier identifier
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, aioredis.Redis): self._pool = self.connection else: address = self.connection redis_kwargs = {} if self._pool is None: async with self._lock: if self._pool is None: self.log.debug('Connecting %s', repr(self)) self._pool = await self._create_redis_pool( address, **redis_kwargs, minsize=1, maxsize=100) return await self._pool
module function_definition identifier parameters identifier block if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier tuple call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement assignment identifier identifier elif_clause call identifier argument_list attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier dictionary if_statement comparison_operator attribute identifier identifier none block with_statement with_clause with_item attribute identifier identifier block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end call identifier argument_list identifier expression_statement assignment attribute identifier identifier await call attribute identifier identifier argument_list identifier dictionary_splat identifier keyword_argument identifier integer keyword_argument identifier integer return_statement await attribute identifier identifier
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
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list dictionary_splat identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
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
module function_definition identifier parameters identifier block if_statement comparison_operator identifier list block return_statement none if_statement call identifier argument_list identifier identifier block return_statement call attribute string string_start string_content string_end identifier argument_list identifier if_statement call identifier argument_list identifier identifier block return_statement call attribute identifier identifier argument_list return_statement identifier
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()
module function_definition identifier parameters identifier identifier block expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list
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)
module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block expression_statement assignment identifier none else_clause block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block raise_statement call identifier argument_list string string_start string_content string_end return_statement call identifier argument_list keyword_argument identifier identifier
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') parser.add_argument(dest='filters',nargs='*',default=["*"],help='Filter stacks'); args = vars(parser.parse_args(args)) if args['refresh']: self.do_refresh('') self.printStack(self.wrappedStack,args['include'],args['filters'])
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier none keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier string string_start string_content string_end keyword_argument identifier string string_start string_content string_end keyword_argument identifier list string string_start string_content string_end keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier if_statement subscript identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list string string_start string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end
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()
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end try_statement block import_statement dotted_name identifier except_clause identifier block return_statement identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement call attribute call identifier argument_list identifier identifier argument_list
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(): try: index.rollback() except NotInTransaction: indexes_to_rebuild.append(key) if indexes_to_rebuild: self.rebuild_indexes(collection, indexes_to_rebuild) self.in_transaction = False
module function_definition identifier parameters identifier default_parameter identifier none block if_statement not_operator attribute identifier identifier block raise_statement identifier for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier subscript attribute identifier identifier identifier expression_statement assignment identifier list for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block try_statement block expression_statement call attribute identifier identifier argument_list except_clause identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment attribute identifier identifier false
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)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier
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.attrs['class'] += " %s" % kwargs.pop('css_class') else: layout_object.attrs['class'] = kwargs.pop('css_class') layout_object.attrs.update(kwargs) self.map(update_attrs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement call identifier argument_list identifier string string_start string_content string_end block if_statement comparison_operator string string_start string_content string_end identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement augmented_assignment subscript attribute identifier identifier string string_start string_content string_end binary_operator string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end else_clause block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
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.files
module function_definition identifier parameters identifier default_parameter identifier false block expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier binary_operator attribute identifier identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier return_statement attribute identifier identifier
Generate a config file for an upstart service.
def name_replace(self, to_replace, replacement): self.name = self.name.replace(to_replace, replacement)
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier
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
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier return_statement conditional_expression call attribute identifier identifier argument_list identifier dictionary_splat identifier attribute identifier identifier identifier
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)
module function_definition identifier parameters block expression_statement assignment identifier dictionary pair string string_start string_content string_end call identifier argument_list pair string string_start string_content string_end call attribute identifier identifier argument_list expression_statement assignment identifier conditional_expression string string_start string_content string_end attribute identifier identifier string string_start string_content string_end with_statement with_clause with_item as_pattern call attribute call identifier argument_list identifier argument_list identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier identifier
Records shell pid to tracker file.
def shuffle_into_deck(self): return self.game.cheat_action(self, [actions.Shuffle(self.controller, self)])
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list identifier list call attribute identifier identifier argument_list attribute identifier identifier identifier
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 })
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end identifier
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)
module function_definition identifier parameters block with_statement with_clause with_item as_pattern call attribute identifier identifier argument_list as_pattern_target identifier block expression_statement assignment identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier await call attribute identifier identifier argument_list expression_statement call identifier argument_list string string_start string_content string_end identifier
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.status_code == 200: self.session.cookies['logintoken'] = None return True hellraiser(res)
module function_definition identifier parameters identifier block expression_statement attribute identifier identifier expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list string string_start string_content string_end expression_statement assignment identifier call call identifier argument_list attribute identifier identifier identifier argument_list identifier keyword_argument identifier identifier if_statement comparison_operator attribute identifier identifier integer block expression_statement assignment subscript attribute attribute identifier identifier identifier string string_start string_content string_end none return_statement true expression_statement call identifier argument_list identifier
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')
module function_definition identifier parameters default_parameter identifier string string_start string_content string_end block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier binary_operator string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list identifier return_statement call identifier argument_list attribute identifier identifier string string_start string_content string_end
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['cors_headers'], 'AllowedMethods': each_rule['cors_methods'], 'AllowedOrigins': each_rule['cors_origins'], 'ExposeHeaders': each_rule['cors_expose_headers'], 'MaxAgeSeconds': each_rule['cors_max_age'] }) cors_config = { 'CORSRules': cors_rules } LOG.debug(cors_config) _response = self.s3client.put_bucket_cors(Bucket=self.bucket, CORSConfiguration=cors_config) else: _response = self.s3client.delete_bucket_cors(Bucket=self.bucket) LOG.debug('Response setting up S3 CORS: %s', _response) LOG.info('S3 CORS configuration updated')
module function_definition identifier parameters identifier block if_statement boolean_operator subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier dictionary expression_statement assignment identifier list for_statement identifier subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end pair string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
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"] effects_transcripts = dd.get_effects_transcripts(data) if effects_transcripts in set(["canonical_cancer"]): _, snpeff_base_dir = get_db(data) canon_list_file = os.path.join(snpeff_base_dir, "transcripts", "%s.txt" % effects_transcripts) if not utils.file_exists(canon_list_file): raise ValueError("Cannot find expected file for effects_transcripts: %s" % canon_list_file) args += ["-canonList", canon_list_file] elif effects_transcripts == "canonical" or tz.get_in(("config", "algorithm", "clinical_reporting"), data): args += ["-canon"] return args
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier list_comprehension call identifier argument_list identifier for_in_clause identifier call attribute identifier identifier argument_list string string_start string_content string_end list if_statement call attribute identifier identifier argument_list identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier call identifier argument_list list string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end binary_operator string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement augmented_assignment identifier list string string_start string_content string_end identifier elif_clause boolean_operator comparison_operator identifier string string_start string_content string_end call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier block expression_statement augmented_assignment identifier list string string_start string_content string_end return_statement identifier
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
module function_definition identifier parameters identifier block if_statement comparison_operator identifier none block return_statement none elif_clause call identifier argument_list identifier identifier block return_statement list identifier elif_clause call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier elif_clause not_operator call identifier argument_list identifier string string_start string_content string_end block return_statement list identifier else_clause block return_statement identifier
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] }
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement dictionary pair string string_start string_content string_end list_comprehension dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end call attribute identifier identifier argument_list attribute identifier identifier pair string string_start string_content string_end list call identifier argument_list identifier identifier for_in_clause identifier identifier
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 )
module function_definition identifier parameters identifier identifier identifier block expression_statement call identifier argument_list identifier identifier identifier expression_statement assignment identifier binary_operator binary_operator identifier identifier integer return_statement parenthesized_expression binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator attribute identifier identifier integer parenthesized_expression binary_operator integer parenthesized_expression binary_operator identifier integer call identifier argument_list binary_operator parenthesized_expression binary_operator identifier integer integer parenthesized_expression unary_operator call identifier argument_list binary_operator parenthesized_expression binary_operator identifier integer integer call identifier argument_list binary_operator parenthesized_expression binary_operator identifier integer integer binary_operator parenthesized_expression binary_operator identifier integer integer identifier
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()
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list
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
module function_definition identifier parameters identifier default_parameter identifier integer block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement boolean_operator comparison_operator attribute identifier identifier list comparison_operator attribute identifier identifier list block expression_statement assignment attribute identifier identifier true
Make a frame of the animation