code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def _get_domain_id(self, domain_text_element): try: tr_anchor = domain_text_element.parent.parent.parent td_anchor = tr_anchor.find('td', {'class': 'td_2'}) link = td_anchor.find('a')['href'] domain_id = link.rsplit('/', 1)[-1] return domain_id except Exception as error: errmsg = ('Cannot get the domain id even though the domain seems ' 'to exist (%s).', error) LOGGER.warning(errmsg) raise AssertionError(errmsg)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier attribute attribute attribute identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier subscript call attribute identifier identifier argument_list string string_start string_content string_end integer unary_operator integer return_statement identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier tuple concatenated_string string string_start string_content string_end string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list identifier
Return the easyname id of the domain.
def _get_end_event(parser, tagName): (event, node) = six.next(parser) if event != pulldom.END_ELEMENT or node.tagName != tagName: raise ParseError( 'Expecting %s end tag, got %s %s' % (tagName, event, node.tagName))
module function_definition identifier parameters identifier identifier block expression_statement assignment tuple_pattern identifier identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator comparison_operator identifier attribute identifier identifier comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier attribute identifier identifier
Check that the next event is the end of a particular XML tag.
def image(self): image_id = self.attrs.get('ImageID', self.attrs['Image']) if image_id is None: return None return self.client.images.get(image_id.split(':')[1])
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier none block return_statement none return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list subscript call attribute identifier identifier argument_list string string_start string_content string_end integer
The image of the container.
def accounts(self): return account.HPEAccountCollection( self._conn, utils.get_subresource_path_by(self, 'Accounts'), redfish_version=self.redfish_version)
module function_definition identifier parameters identifier block return_statement call attribute identifier identifier argument_list attribute identifier identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end keyword_argument identifier attribute identifier identifier
Property to provide instance of HPEAccountCollection
def plotly_app_identifier(name=None, slug=None, da=None, postfix=None): 'Return a slug-friendly identifier' da, app = _locate_daapp(name, slug, da) slugified_id = app.slugified_id() if postfix: return "%s-%s" %(slugified_id, postfix) return slugified_id
module function_definition identifier parameters default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement identifier block return_statement binary_operator string string_start string_content string_end tuple identifier identifier return_statement identifier
Return a slug-friendly identifier
def textslice(self, start, end): return self._select(self._pointer.textslice(start, end))
module function_definition identifier parameters identifier identifier identifier block return_statement call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier
Return a chunk referencing a slice of a scalar text value.
def print_traceback(self): traceback.print_exception(self.etype, self.value, self.traceback)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier
Print the traceback of the exception wrapped by the AbbreviatedException.
def runSearchReferenceSets(self, request): return self.runSearchRequest( request, protocol.SearchReferenceSetsRequest, protocol.SearchReferenceSetsResponse, self.referenceSetsGenerator)
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier
Runs the specified SearchReferenceSetsRequest.
def path(filename): filename = unmap_file(filename) if filename not in file_cache: return None return file_cache[filename].path
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement comparison_operator identifier identifier block return_statement none return_statement attribute subscript identifier identifier identifier
Return full filename path for filename
def _set_labels(node, apiserver_url, labels): url = "{0}/api/v1/nodes/{1}".format(apiserver_url, node) data = [{"op": "replace", "path": "/metadata/labels", "value": labels}] ret = _kpatch(url, data) if ret.get("status") == 404: return "Node {0} doesn't exist".format(node) return ret
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier list dictionary pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end string string_start string_content string_end pair string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier identifier if_statement comparison_operator call attribute identifier identifier argument_list string string_start string_content string_end integer block return_statement call attribute string string_start string_content string_end identifier argument_list identifier return_statement identifier
Replace labels dict by a new one
def append_code_expr(self, code): if isinstance(code, str) and not isinstance(code, unicode): code = unicode(code) if not isinstance(code, unicode): raise TypeError("string expected") log.debug("compiling code %s...", code) try: code_obj = compile(code, '<string>', 'eval') self.code_objs[code] = code_obj except SyntaxError as syntax_err: log.error("cannot compile %s: %s", code, syntax_err) raise log.debug("compiled code %s", code)
module function_definition identifier parameters identifier identifier block if_statement boolean_operator call identifier argument_list identifier identifier not_operator call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator call identifier argument_list identifier identifier block raise_statement 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 identifier try_statement block expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end expression_statement assignment subscript attribute identifier identifier 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 identifier identifier raise_statement expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Compile argument and adds it to the list of code objects.
def dict(self): if self._dict: return self._dict values = OrderedDict(self.parse()) self._dict = resolve_nested_variables(values) return self._dict
module function_definition identifier parameters identifier block if_statement attribute identifier identifier block return_statement attribute identifier identifier expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier call identifier argument_list identifier return_statement attribute identifier identifier
Return dotenv as dict
def get(self): return {k:v for k,v in list(self.options.items()) if k in self._allowed_axes}
module function_definition identifier parameters identifier block return_statement dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator identifier attribute identifier identifier
Retrieve options set by user.
def _get_bottom_line_coordinates(self): rect_x, rect_y, rect_width, rect_height = self.rect start_point = rect_x, rect_y + rect_height end_point = rect_x + rect_width, rect_y + rect_height return start_point, end_point
module function_definition identifier parameters identifier block expression_statement assignment pattern_list identifier identifier identifier identifier attribute identifier identifier expression_statement assignment identifier expression_list identifier binary_operator identifier identifier expression_statement assignment identifier expression_list binary_operator identifier identifier binary_operator identifier identifier return_statement expression_list identifier identifier
Returns start and stop coordinates of bottom line
def communityvisibilitystate(self): if self._communityvisibilitystate == None: return None elif self._communityvisibilitystate in self.VisibilityState: return self.VisibilityState[self._communityvisibilitystate] else: return None
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier none block return_statement none elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block return_statement subscript attribute identifier identifier attribute identifier identifier else_clause block return_statement none
Return the Visibility State of the Users Profile
def set(self, instance, value, **kw): if value: try: value = DateTime(value) except SyntaxError: logger.warn("Value '{}' is not a valid DateTime string" .format(value)) return False self._set(instance, value, **kw)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block if_statement identifier block try_statement block expression_statement assignment identifier call identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier return_statement false expression_statement call attribute identifier identifier argument_list identifier identifier dictionary_splat identifier
Converts the value into a DateTime object before setting.
def RDirs(self, pathlist): cwd = self.cwd or self.fs._cwd return cwd.Rfindalldirs(pathlist)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier boolean_operator attribute identifier identifier attribute attribute identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier
Search for a list of directories in the Repository list.
def dump_commands(self, commands): directory = os.path.join(os.path.dirname(self.sql_script), 'fails') fname = os.path.basename(self.sql_script.rsplit('.')[0]) return dump_commands(commands, directory, fname)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end integer return_statement call identifier argument_list identifier identifier identifier
Dump commands wrapper for external access.
def getch(): if sys.platform in ['darwin', 'linux']: import termios import tty file_descriptor = sys.stdin.fileno() settings = termios.tcgetattr(file_descriptor) try: tty.setraw(file_descriptor) return sys.stdin.read(1) finally: termios.tcsetattr(file_descriptor, termios.TCSADRAIN, settings) elif sys.platform in ['cygwin', 'win32']: import msvcrt return msvcrt.getwch()
module function_definition identifier parameters block if_statement comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block import_statement dotted_name identifier import_statement dotted_name identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier try_statement block expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute attribute identifier identifier identifier argument_list integer finally_clause block expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier identifier elif_clause comparison_operator attribute identifier identifier list string string_start string_content string_end string string_start string_content string_end block import_statement dotted_name identifier return_statement call attribute identifier identifier argument_list
Request a single character input from the user.
def format_status(self, width=None, label_width=None, progress_width=None, summary_width=None): if width is None: width = shutil.get_terminal_size()[0] if label_width is None: label_width = len(self.label) if summary_width is None: summary_width = self.summary_width() if progress_width is None: progress_width = width - label_width - summary_width - 2 if len(self.label) > label_width: label = self.label[:label_width - 3] + "..." else: label_format = "{{label:{fill_char}<{width}}}".format( width=label_width, fill_char=self.fill_char) label = label_format.format(label=self.label) summary_format = "{{:>{width}}}".format(width=summary_width) summary = summary_format.format(self._progress.format_summary()) progress = self._progress.format_progress(width=progress_width) return "{label} {progress} {summary}".format( label=label, progress=progress, summary=summary )
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer if_statement comparison_operator identifier none block expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier binary_operator binary_operator binary_operator identifier identifier identifier integer if_statement comparison_operator call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier binary_operator subscript attribute identifier identifier slice binary_operator identifier integer string string_start string_content string_end else_clause block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier return_statement call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Generate the formatted status bar string.
def to_string(self): buff = u"" for child in self.content.iter(): if child.tag in [self.qn('text:p'), self.qn('text:h')]: buff += self.text_to_string(child) + "\n" if buff: buff = buff[:-1] return buff
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call attribute attribute identifier identifier identifier argument_list block if_statement comparison_operator attribute identifier identifier list call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier binary_operator call attribute identifier identifier argument_list identifier string string_start string_content escape_sequence string_end if_statement identifier block expression_statement assignment identifier subscript identifier slice unary_operator integer return_statement identifier
Converts the document to a string.
def savetostr(self, sortkey = True): return ''.join(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey))
module function_definition identifier parameters identifier default_parameter identifier true block return_statement call attribute string string_start string_end identifier generator_expression binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list identifier string string_start string_content escape_sequence string_end for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list identifier
Save configurations to a single string
def complete_wrap(self, func, *args, **kwargs): termcols = shutil.get_terminal_size()[0] readline.parse_and_bind('set completion-display-width %d' % termcols) try: return func(*args, **kwargs) except: traceback.print_exc() raise
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier subscript call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier try_statement block return_statement call identifier argument_list list_splat identifier dictionary_splat identifier except_clause block expression_statement call attribute identifier identifier argument_list raise_statement
Readline eats exceptions raised by completer functions.
def addFrame(self): fr = "/tmp/vpvid/" + str(len(self.frames)) + ".png" screenshot(fr) self.frames.append(fr)
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator binary_operator string string_start string_content string_end call identifier argument_list call identifier argument_list attribute identifier identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add frame to current video.
def _get_namespaces(apiserver_url, name=""): url = "{0}/api/v1/namespaces/{1}".format(apiserver_url, name) ret = http.query(url) if ret.get("body"): return salt.utils.json.loads(ret.get("body")) else: return None
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block return_statement call attribute attribute attribute identifier identifier identifier identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end else_clause block return_statement none
Get namespace is namespace is defined otherwise return all namespaces
def revoke_tokens(self): self.is_active = False self.save() self.refresh_token.revoke_tokens()
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false expression_statement call attribute identifier identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list
Revoke the authorization token and all tokens that were generated using it.
def check_error(res, error_enum): if res.HasField("error"): enum_name = error_enum.DESCRIPTOR.full_name error_name = error_enum.Name(res.error) details = getattr(res, "error_details", "<none>") raise RequestError("%s.%s: '%s'" % (enum_name, error_name, details), res) return res
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 attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier identifier return_statement identifier
Raise if the result has an error, otherwise return the result.
def flat(self, obj, mask=0): s = self.base if self.leng and self.item > 0: s += self.leng(obj) * self.item if _getsizeof: s = _getsizeof(obj, s) if mask: s = (s + mask) & ~mask return s
module function_definition identifier parameters identifier identifier default_parameter identifier integer block expression_statement assignment identifier attribute identifier identifier if_statement boolean_operator attribute identifier identifier comparison_operator attribute identifier identifier integer block expression_statement augmented_assignment identifier binary_operator call attribute identifier identifier argument_list identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list identifier identifier if_statement identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier identifier unary_operator identifier return_statement identifier
Return the aligned flat size.
def finalize_backreferences(seen_backrefs, gallery_conf): logger = sphinx_compatibility.getLogger('sphinx-gallery') if gallery_conf['backreferences_dir'] is None: return for backref in seen_backrefs: path = os.path.join(gallery_conf['src_dir'], gallery_conf['backreferences_dir'], '%s.examples.new' % backref) if os.path.isfile(path): _replace_md5(path) else: level = gallery_conf['log_level'].get('backreference_missing', 'warning') func = getattr(logger, level) func('Could not find backreferences file: %s' % (path,)) func('The backreferences are likely to be erroneous ' 'due to file system case insensitivity.')
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement comparison_operator subscript identifier string string_start string_content string_end none block return_statement for_statement identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end identifier if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end
Replace backref files only if necessary.
def openOrders(self) -> List[Order]: return [trade.order for trade in self.wrapper.trades.values() if trade.orderStatus.status not in OrderStatus.DoneStates]
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block return_statement list_comprehension attribute identifier identifier for_in_clause identifier call attribute attribute attribute identifier identifier identifier identifier argument_list if_clause comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier
List of all open orders.
def svevent_reader(in_file): with open(in_file) as in_handle: while 1: line = next(in_handle) if line.startswith(">"): break header = line[1:].rstrip().split("\t") reader = csv.reader(in_handle, dialect="excel-tab") for parts in reader: out = {} for h, p in zip(header, parts): out[h] = p yield out
module function_definition identifier parameters identifier block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block while_statement integer block expression_statement assignment identifier call identifier argument_list identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end block break_statement expression_statement assignment identifier call attribute call attribute subscript identifier slice integer identifier argument_list identifier argument_list string string_start string_content escape_sequence string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end for_statement identifier identifier block expression_statement assignment identifier dictionary for_statement pattern_list identifier identifier call identifier argument_list identifier identifier block expression_statement assignment subscript identifier identifier identifier expression_statement yield identifier
Lazy generator of SV events, returned as dictionary of parts.
def taxonomy(value): try: value.encode('ascii') except UnicodeEncodeError: raise ValueError('tag %r is not ASCII' % value) if re.search(r'\s', value): raise ValueError('The taxonomy %r contains whitespace chars' % value) return value
module function_definition identifier parameters identifier block try_statement block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end except_clause identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier return_statement identifier
Any ASCII character goes into a taxonomy, except spaces.
def on_resize(self, *args): self.screen.style.name_len = min(self.screen.style.name_len, self.term.width - 15) assert self.term.width >= self.screen.hint_width, ( 'Screen to small {}, must be at least {}'.format( self.term.width, self.screen.hint_width)) self._set_lastpage() self.dirty = self.STATE_REFRESH
module function_definition identifier parameters identifier list_splat_pattern identifier block expression_statement assignment attribute attribute attribute identifier identifier identifier identifier call identifier argument_list attribute attribute attribute identifier identifier identifier identifier binary_operator attribute attribute identifier identifier identifier integer assert_statement comparison_operator attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier parenthesized_expression call attribute string string_start string_content string_end identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier attribute identifier identifier
Signal handler callback for SIGWINCH.
def on_open(self, info): self.ip = info.ip self.request = info self.open()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list
sockjs-tornado on_open handler
def save(self, **kwargs): try: return super().save(**kwargs) except SlugError as error: raise ParseError(error)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block try_statement block return_statement call attribute call identifier argument_list identifier argument_list dictionary_splat identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list identifier
Override save method to catch handled errors and repackage them as 400 errors.
def write_to_path(self, path=None): if path is None: path = self.path f = GitFile(path, 'wb') try: self.write_to_file(f) finally: f.close()
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier string string_start string_content string_end try_statement block expression_statement call attribute identifier identifier argument_list identifier finally_clause block expression_statement call attribute identifier identifier argument_list
Write configuration to a file on disk.
def predefinedEntity(name): ret = libxml2mod.xmlGetPredefinedEntity(name) if ret is None:raise treeError('xmlGetPredefinedEntity() failed') return xmlEntity(_obj=ret)
module function_definition identifier parameters identifier block 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
Check whether this name is an predefined entity.
def path_helper(self, operations, view, **kwargs): operations.update(yaml_utils.load_operations_from_docstring(view.__doc__)) app = kwargs.get('app', _default_app) route = self._route_for_view(app, view) return self.bottle_path_to_openapi(route.rule)
module function_definition identifier parameters identifier identifier identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier 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 identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier
Path helper that allows passing a bottle view function.
def _update_streams(self): content = self._db._get_content("streamds") self._stream_df = read_csv(content).sort_values("STREAM") self._streams = None for stream in self.streams: setattr(self, stream, self.__getattr__(stream))
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute call identifier argument_list identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier none for_statement identifier attribute identifier identifier block expression_statement call identifier argument_list identifier identifier call attribute identifier identifier argument_list identifier
Update the list of available straems
def load_task_definition_file(task_def_file): try: with open(task_def_file) as f: task_def = yaml.safe_load(f) except OSError as e: raise BenchExecException("Cannot open task-definition file: " + str(e)) except yaml.YAMLError as e: raise BenchExecException("Invalid task definition: " + str(e)) if str(task_def.get("format_version")) not in ["0.1", "1.0"]: raise BenchExecException( "Task-definition file {} specifies invalid format_version '{}'." .format(task_def_file, task_def.get("format_version"))) return task_def
module function_definition identifier parameters identifier block try_statement block with_statement with_clause with_item as_pattern call identifier argument_list identifier as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier except_clause as_pattern identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier except_clause as_pattern attribute identifier identifier as_pattern_target identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier if_statement comparison_operator call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end list string string_start string_content string_end string string_start string_content string_end block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier call attribute identifier identifier argument_list string string_start string_content string_end return_statement identifier
Open and parse a task-definition file in YAML format.
def commit(self): self._transaction = False try: self._con.commit() except self._failures as error: try: con = self._create() except Exception: pass else: self._close() self._store(con) raise error
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier false try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list except_clause as_pattern attribute identifier identifier as_pattern_target identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list except_clause identifier block pass_statement else_clause block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier raise_statement identifier
Commit any pending transaction.
def _default_headers(self): headers = { "Authorization": 'Bearer {}'.format(self.api_key), "User-agent": self.useragent, "Accept": 'application/json' } if self.impersonate_subuser: headers['On-Behalf-Of'] = self.impersonate_subuser return headers
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary pair string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end string string_start string_content string_end if_statement attribute identifier identifier block expression_statement assignment subscript identifier string string_start string_content string_end attribute identifier identifier return_statement identifier
Set the default header for a Twilio SendGrid v3 API call
def _configure_endpoint(self, endpoint): if not endpoint.startswith('http'): endpoint = 'https://' + endpoint if not endpoint.endswith('/'): endpoint += '/' return endpoint
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement assignment identifier binary_operator string string_start string_content string_end identifier if_statement not_operator call attribute identifier identifier argument_list string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier
Configure the endpoint with a schema and end slash.
def schema_complete(): return Schema({ 'stage': And(str, len), 'status': And(str, lambda s: s in ['started', 'succeeded', 'failed']), Optional('events', default=[]): And(len, [CollectorStage.schema_event_items()]) })
module function_definition identifier parameters block return_statement call identifier argument_list dictionary pair string string_start string_content string_end call identifier argument_list identifier identifier pair string string_start string_content string_end call identifier argument_list identifier lambda lambda_parameters identifier comparison_operator identifier list string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end pair call identifier argument_list string string_start string_content string_end keyword_argument identifier list call identifier argument_list identifier list call attribute identifier identifier argument_list
Schema for data in CollectorStage.
def uniqueify(my_list: Any) -> List[Any]: if sys.version_info >= (3, 6): return list(dict.fromkeys(my_list)) seen = set() return [x for x in my_list if x not in seen and not seen.add(x)]
module function_definition identifier parameters typed_parameter identifier type identifier type generic_type identifier type_parameter type identifier block if_statement comparison_operator attribute identifier identifier tuple integer integer block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list return_statement list_comprehension identifier for_in_clause identifier identifier if_clause boolean_operator comparison_operator identifier identifier not_operator call attribute identifier identifier argument_list identifier
Remove duplicate entries in a list retaining order.
async def get_json(self, encoding='utf-8'): return (await self.get(encoding=encoding, decoder=json.loads))
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block return_statement parenthesized_expression await call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Shortcut to get JSON messages.
def on_welcome(self, connection, event): connection.join(self.channel, key=settings.IRC_CHANNEL_KEY or "")
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier boolean_operator attribute identifier identifier string string_start string_end
Join the channel once connected to the IRC server.
def clean_account(self): account = self.cleaned_data['account'] if not account: return if account.type != Account.TYPES.income: raise ValidationError('Account must be an income account') try: account.housemate except Housemate.DoesNotExist: pass else: raise ValidationError('Account already has a housemate') return account
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement not_operator identifier block return_statement if_statement comparison_operator attribute identifier identifier attribute attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end try_statement block expression_statement attribute identifier identifier except_clause attribute identifier identifier block pass_statement else_clause block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Ensure this is an income account
def angle(self, other): return math.acos(self.dot(other) / (self.magnitude() * other.magnitude()))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list identifier parenthesized_expression binary_operator call attribute identifier identifier argument_list call attribute identifier identifier argument_list
Return the angle to the vector other
def write_tex(): datadir = livvkit.index_dir outdir = os.path.join(datadir, "tex") print(outdir) data_files = glob.glob(datadir + "/**/*.json", recursive=True) for each in data_files: data = functions.read_json(each) tex = translate_page(data) outfile = os.path.join(outdir, os.path.basename(each).replace('json', 'tex')) with open(outfile, 'w') as f: f.write(tex)
module function_definition identifier parameters block expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end expression_statement call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end keyword_argument identifier true for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end 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 call attribute identifier identifier argument_list identifier
Finds all of the output data files, and writes them out to .tex
def StartElement(self, name, attributes): if name == 'hierarchy': pass elif name == 'node': attributes['uniqueId'] = 'id/no_id/%d' % self.idCount bounds = re.split('[\][,]', attributes['bounds']) attributes['bounds'] = ((int(bounds[1]), int(bounds[2])), (int(bounds[4]), int(bounds[5]))) if DEBUG_BOUNDS: print >> sys.stderr, "bounds=", attributes['bounds'] self.idCount += 1 child = View.factory(attributes, self.device, version=self.version, uiAutomatorHelper=self.uiAutomatorHelper) self.views.append(child) if not self.nodeStack: self.root = child else: self.parent = self.nodeStack[-1] self.parent.add(child) self.nodeStack.append(child)
module function_definition identifier parameters identifier identifier identifier block if_statement comparison_operator identifier string string_start string_content string_end block pass_statement elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement assignment subscript identifier string string_start string_content string_end binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement assignment subscript identifier string string_start string_content string_end tuple tuple call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer tuple call identifier argument_list subscript identifier integer call identifier argument_list subscript identifier integer if_statement identifier block print_statement chevron attribute identifier identifier string string_start string_content string_end subscript identifier string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier else_clause block expression_statement assignment attribute identifier identifier subscript attribute identifier identifier unary_operator integer expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Expat start element event handler
def rebuildButtons(self): for btn in self.findChildren(XAdvancedButton): btn.close() btn.setParent(None) btn.deleteLater() for standard, advanced in self._advancedMap.items(): rect = self.actionGeometry(standard) btn = XAdvancedButton(self) btn.setFixedWidth(22) btn.setFixedHeight(rect.height()) btn.setDefaultAction(advanced) btn.setAutoRaise(True) btn.move(rect.right() + 1, rect.top()) btn.show() if btn.icon().isNull(): btn.setIcon(QIcon(resources.find('img/advanced.png'))) btn.clicked.connect(self.acceptAdvanced)
module function_definition identifier parameters identifier block for_statement identifier call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list none expression_statement call attribute identifier identifier argument_list for_statement pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list binary_operator call attribute identifier identifier argument_list integer call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list if_statement call attribute call attribute identifier identifier argument_list identifier argument_list block expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Rebuilds the buttons for the advanced actions.
def create_api_key(self): apikeys = self.client.get_api_keys() for key in apikeys['items']: if key['name'] == self.app_name: self.log.info("Key %s already exists", self.app_name) break else: self.client.create_api_key( name=self.app_name, enabled=True, stageKeys=[{ 'restApiId': self.api_id, 'stageName': self.env }]) self.log.info("Successfully created API Key %s. Look in the AWS console for the key", self.app_name)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list for_statement identifier subscript identifier string string_start string_content string_end block if_statement comparison_operator subscript identifier string string_start string_content string_end attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier break_statement else_clause block expression_statement call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier true keyword_argument identifier list dictionary pair string string_start string_content string_end attribute identifier identifier pair string string_start string_content string_end attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end attribute identifier identifier
Create API Key for API access.
def snip_this(tag="",write_date=True): snip(tag=tag,start=-1,write_date=write_date)
module function_definition identifier parameters default_parameter identifier string string_start string_end default_parameter identifier true block expression_statement call identifier argument_list keyword_argument identifier identifier keyword_argument identifier unary_operator integer keyword_argument identifier identifier
When this function is invoced in a notebook cell, the cell is snipped.
def create_attributes(klass, attributes, previous_object=None): result = super(Webhook, klass).create_attributes(attributes, previous_object) if 'topics' not in result: raise Exception("Topics ('topics') must be provided for this operation.") return result
module function_definition identifier parameters identifier identifier default_parameter identifier none block expression_statement assignment identifier call attribute call identifier argument_list identifier identifier identifier argument_list identifier identifier if_statement comparison_operator string string_start string_content string_end identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Attributes for webhook creation.
def _write(self, value): if ' ' in value: s = inspect.stack() fn = s[1].function super().write('%%DEBUG {} %%'.format(fn)) super().write(value)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier attribute subscript identifier integer identifier expression_statement call attribute call identifier argument_list identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute call identifier argument_list identifier argument_list identifier
rename to write and import inspect to debut the callstack
def deploy_ext(self): if self.mods.get('file'): self.shell.send( self.mods['file'], os.path.join(self.thin_dir, 'salt-ext_mods.tgz'), ) return True
module function_definition identifier parameters identifier block if_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list attribute identifier identifier string string_start string_content string_end return_statement true
Deploy the ext_mods tarball
def filter_queryset(self, request, queryset, view): if request.user.is_superuser: return queryset return queryset.filter(status__user=request.user)
module function_definition identifier parameters identifier identifier identifier identifier block if_statement attribute attribute identifier identifier identifier block return_statement identifier return_statement call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier
Filter out any artifacts which the requesting user does not have permission to view.
def canonicalize(interval, lower_inc=True, upper_inc=False): if not interval.discrete: raise TypeError('Only discrete ranges can be canonicalized') if interval.empty: return interval lower, lower_inc = canonicalize_lower(interval, lower_inc) upper, upper_inc = canonicalize_upper(interval, upper_inc) return interval.__class__( [lower, upper], lower_inc=lower_inc, upper_inc=upper_inc, )
module function_definition identifier parameters identifier default_parameter identifier true default_parameter identifier false block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block return_statement identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list list identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier
Convert equivalent discrete intervals to different representations.
def editableFields(self, instance, visible_only=False): ret = [] portal = getToolByName(instance, 'portal_url').getPortalObject() for field in self.fields(): if field.writeable(instance, debug=False) and \ (not visible_only or field.widget.isVisible( instance, mode='edit', field=field) != 'invisible') and \ field.widget.testCondition(instance.aq_parent, portal, instance): ret.append(field) return ret
module function_definition identifier parameters identifier identifier default_parameter identifier false block expression_statement assignment identifier list expression_statement assignment identifier call attribute call identifier argument_list identifier string string_start string_content string_end identifier argument_list for_statement identifier call attribute identifier identifier argument_list block if_statement boolean_operator boolean_operator call attribute identifier identifier argument_list identifier keyword_argument identifier false line_continuation parenthesized_expression boolean_operator not_operator identifier comparison_operator call attribute attribute identifier identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end keyword_argument identifier identifier string string_start string_content string_end line_continuation call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Returns a list of editable fields for the given instance
def on_import1(self, event): pmag_menu_dialogs.MoveFileIntoWD(self.parent, self.parent.WD)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute attribute identifier identifier identifier
initialize window to import an arbitrary file into the working directory
def _clean(self, value): if value is None: return None elif self.type_ is None: return value elif self.check_type(value): return value elif self.is_type_castable: return self.type_(value) error_fmt = "%s must be a %s, not a %s" error = error_fmt % (self.name, self.type_, type(value)) raise TypeError(error)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier none block return_statement none elif_clause comparison_operator attribute identifier identifier none block return_statement identifier elif_clause call attribute identifier identifier argument_list identifier block return_statement identifier elif_clause attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier binary_operator identifier tuple attribute identifier identifier attribute identifier identifier call identifier argument_list identifier raise_statement call identifier argument_list identifier
Validate and clean a candidate value for this field.
def runserver(ctx, conf, port, foreground): config = read_config(conf) debug = config['conf'].get('debug', False) click.echo('Debug mode {0}.'.format('on' if debug else 'off')) port = port or config['conf']['server']['port'] app_settings = { 'debug': debug, 'auto_reload': config['conf']['server'].get('auto_reload', False), } handlers_settings = __create_handler_settings(config) if foreground: click.echo('Requested mode: foreground') start_app(port, app_settings, handlers_settings) else: click.echo('Requested mode: background') raise NotImplementedError
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute subscript identifier string string_start string_content string_end identifier argument_list string string_start string_content string_end false expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list conditional_expression string string_start string_content string_end identifier string string_start string_content string_end expression_statement assignment identifier boolean_operator identifier subscript subscript subscript identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call attribute subscript subscript identifier string string_start string_content string_end string string_start string_content string_end identifier argument_list string string_start string_content string_end false expression_statement assignment identifier call identifier argument_list identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list identifier identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end raise_statement identifier
Run the fnExchange server
def updateWeather(self): yql = _YQL_WEATHER.format(self._woeid, self._unit) tmpData = _yql_query(yql) if tmpData is not None and "channel" in tmpData: self._data = tmpData["channel"] return True _LOGGER.error("Fetch no weather data Yahoo!") self._data = {} return False
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier if_statement boolean_operator comparison_operator identifier none comparison_operator string string_start string_content string_end identifier block expression_statement assignment attribute identifier identifier subscript identifier string string_start string_content string_end return_statement true expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier dictionary return_statement false
Fetch weather data from Yahoo! True if success.
def cli(obj, username, scopes, duration, text, customer, delete): client = obj['client'] if delete: client.delete_key(delete) else: try: expires = datetime.utcnow() + timedelta(seconds=duration) if duration else None key = client.create_key(username, scopes, expires, text, customer) except Exception as e: click.echo('ERROR: {}'.format(e)) sys.exit(1) click.echo(key.key)
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier identifier block expression_statement assignment identifier subscript identifier string string_start string_content string_end if_statement identifier block expression_statement call attribute identifier identifier argument_list identifier else_clause block try_statement block expression_statement assignment identifier conditional_expression binary_operator call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier identifier identifier none expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier identifier identifier except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list attribute identifier identifier
Create or delete an API key.
def end_comma(self, value): if not isinstance(value, bool): raise TypeError('end_comma attribute must be a logical type.') self._end_comma = value
module function_definition identifier parameters identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier identifier
Validate and set the comma termination flag.
def top(self) -> "InstanceNode": inst = self while inst.parinst: inst = inst.up() return inst
module function_definition identifier parameters identifier type string string_start string_content string_end block expression_statement assignment identifier identifier while_statement attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement identifier
Return an instance node corresponding to the root of the data tree.
def _netmiko_open(self, device_type, netmiko_optional_args=None): if netmiko_optional_args is None: netmiko_optional_args = {} try: self._netmiko_device = ConnectHandler( device_type=device_type, host=self.hostname, username=self.username, password=self.password, timeout=self.timeout, **netmiko_optional_args ) except NetMikoTimeoutException: raise ConnectionException("Cannot connect to {}".format(self.hostname)) self._netmiko_device.enable() return self._netmiko_device
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier dictionary try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier dictionary_splat identifier except_clause identifier block raise_statement call identifier argument_list 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 return_statement attribute identifier identifier
Standardized method of creating a Netmiko connection using napalm attributes.
def populateFromRow(self, ontologyRecord): self._id = ontologyRecord.id self._dataUrl = ontologyRecord.dataurl self._readFile()
module function_definition identifier parameters identifier identifier block expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement assignment attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list
Populates this Ontology using values in the specified DB row.
def teardown(self): self.monitor_thread.stop() self.monitor_thread = None super(BaseMonitor, self).teardown()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list expression_statement assignment attribute identifier identifier none expression_statement call attribute call identifier argument_list identifier identifier identifier argument_list
cleanup the monitor data and
def parametererror(self): for parametergroup, parameters in self.parameters: for parameter in parameters: if parameter.error: return parameter.error return False
module function_definition identifier parameters identifier block for_statement pattern_list identifier identifier attribute identifier identifier block for_statement identifier identifier block if_statement attribute identifier identifier block return_statement attribute identifier identifier return_statement false
Return the first parameter error, or False if there is none
def xml(self, indent = ""): xml = indent + "<provenance type=\"clam\" id=\""+self.serviceid+"\" name=\"" +self.servicename+"\" url=\"" + self.serviceurl+"\" outputtemplate=\""+self.outputtemplate_id+"\" outputtemplatelabel=\""+self.outputtemplate_label+"\" timestamp=\""+str(self.timestamp)+"\">" for filename, metadata in self.inputfiles: xml += indent + " <inputfile name=\"" + clam.common.util.xmlescape(filename) + "\">" xml += metadata.xml(indent + " ") + "\n" xml += indent + " </inputfile>\n" if self.parameters: xml += indent + " <parameters>\n" if isinstance(self.parameters, dict): parameters = self.parameters.values() elif isinstance(self.parameters, list): parameters = self.parameters for parameter in parameters: xml += parameter.xml(indent +" ") + "\n" xml += indent + " </parameters>\n" xml += indent + "</provenance>" return xml
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block expression_statement assignment identifier binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content escape_sequence escape_sequence escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence escape_sequence string_end attribute identifier identifier string string_start string_content escape_sequence escape_sequence string_end call identifier argument_list attribute identifier identifier string string_start string_content escape_sequence string_end for_statement pattern_list identifier identifier attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator binary_operator binary_operator identifier string string_start string_content escape_sequence string_end call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier binary_operator call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content escape_sequence string_end if_statement attribute identifier identifier block expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content escape_sequence string_end if_statement call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list elif_clause call identifier argument_list attribute identifier identifier identifier block expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content escape_sequence string_end expression_statement augmented_assignment identifier binary_operator identifier string string_start string_content string_end return_statement identifier
Serialise provenance data to XML. This is included in CLAM Metadata files
def upset_union(self, featuresets): concepts = (f.concept for f in featuresets) indexes = (c.index for c in self.lattice.upset_union(concepts)) return map(self._featuresets.__getitem__, indexes)
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier generator_expression attribute identifier identifier for_in_clause identifier identifier expression_statement assignment identifier generator_expression attribute identifier identifier for_in_clause identifier call attribute attribute identifier identifier identifier argument_list identifier return_statement call identifier argument_list attribute attribute identifier identifier identifier identifier
Yield all featuresets that subsume any of the given ones.
def NoSuchEntityOk(f): def ExceptionFilter(*args): try: return f(*args) except boto.exception.BotoServerError as e: if e.error_code == 'NoSuchEntity': pass else: raise except: raise return False return ExceptionFilter
module function_definition identifier parameters identifier block function_definition identifier parameters list_splat_pattern identifier block try_statement block return_statement call identifier argument_list list_splat identifier except_clause as_pattern attribute attribute identifier identifier identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block pass_statement else_clause block raise_statement except_clause block raise_statement return_statement false return_statement identifier
Decorator to remove NoSuchEntity exceptions, and raises all others.
def _get_dependency_specification(dep_spec: typing.List[tuple]) -> str: return ",".join(dep_range[0] + dep_range[1] for dep_range in dep_spec)
module function_definition identifier parameters typed_parameter identifier type subscript attribute identifier identifier identifier type identifier block return_statement call attribute string string_start string_content string_end identifier generator_expression binary_operator subscript identifier integer subscript identifier integer for_in_clause identifier identifier
Get string representation of dependency specification as provided by PythonDependencyParser.
def resize_image(self, data, size): from machina.core.compat import PILImage as Image image = Image.open(BytesIO(data)) image.thumbnail(size, Image.ANTIALIAS) string = BytesIO() image.save(string, format='PNG') return string.getvalue()
module function_definition identifier parameters identifier identifier identifier block import_from_statement dotted_name identifier identifier identifier aliased_import dotted_name identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier string string_start string_content string_end return_statement call attribute identifier identifier argument_list
Resizes the given image to fit inside a box of the given size.
def deregister(self, subscriber): try: logger.debug('Subscriber left') self.subscribers.remove(subscriber) except KeyError: logger.debug( 'Error removing subscriber: ' + str(subscriber))
module function_definition identifier parameters identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute attribute identifier identifier identifier argument_list identifier except_clause identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list identifier
Stop publishing to a subscriber.
def filter_by_folder(self, include=None, exclude=None): "Only keep filenames in `include` folder or reject the ones in `exclude`." include,exclude = listify(include),listify(exclude) def _inner(o): if isinstance(o, Path): n = o.relative_to(self.path).parts[0] else: n = o.split(os.path.sep)[len(str(self.path).split(os.path.sep))] if include and not n in include: return False if exclude and n in exclude: return False return True return self.filter_by_func(_inner)
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement string string_start string_content string_end expression_statement assignment pattern_list identifier identifier expression_list call identifier argument_list identifier call identifier argument_list identifier function_definition identifier parameters identifier block if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier subscript attribute call attribute identifier identifier argument_list attribute identifier identifier identifier integer else_clause block expression_statement assignment identifier subscript call attribute identifier identifier argument_list attribute attribute identifier identifier identifier call identifier argument_list call attribute call identifier argument_list attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier if_statement boolean_operator identifier not_operator comparison_operator identifier identifier block return_statement false if_statement boolean_operator identifier comparison_operator identifier identifier block return_statement false return_statement true return_statement call attribute identifier identifier argument_list identifier
Only keep filenames in `include` folder or reject the ones in `exclude`.
def _get_word_ngrams(n, sentences): assert len(sentences) > 0 assert n > 0 words = _split_into_words(sentences) return _get_ngrams(n, words)
module function_definition identifier parameters identifier identifier block assert_statement comparison_operator call identifier argument_list identifier integer assert_statement comparison_operator identifier integer expression_statement assignment identifier call identifier argument_list identifier return_statement call identifier argument_list identifier identifier
Calculates word n-grams for multiple sentences.
def end_log_output(self, **kwargs): kwargs.update(dict( downloaded_bytes=self.downloaded_bytes, num_urls = len(self.result_cache), )) self.logger.end_log_output(**kwargs)
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier expression_statement call attribute attribute identifier identifier identifier argument_list dictionary_splat identifier
Print ending output to log.
def parse_value(self): try: if self.value is None: log.warning("Cannot parse dataset. No value specified.") return None data = six.text_type(self.value) if data.upper().strip() in ("NULL", ""): return "NULL" data = data[0:100] log.info("[Dataset.parse_value] Parsing %s (%s)", data, type(data)) return HydraObjectFactory.valueFromDataset(self.type, self.value, self.get_metadata_as_dict()) except Exception as e: log.exception(e) raise HydraError("Error parsing value %s: %s"%(self.value, e))
module function_definition identifier parameters identifier block try_statement block if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier if_statement comparison_operator call attribute call attribute identifier identifier argument_list identifier argument_list tuple string string_start string_content string_end string string_start string_end block return_statement string string_start string_content string_end expression_statement assignment identifier subscript identifier slice integer integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier call identifier argument_list identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier call attribute identifier identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple attribute identifier identifier identifier
Turn the value of an incoming dataset into a hydra-friendly value.
def checkout(accountable, issue_key): issue = accountable.checkout(issue_key) headers = issue.keys() rows = [headers, [v for k, v in issue.items()]] print_table(SingleTable(rows))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier list identifier list_comprehension identifier for_in_clause pattern_list identifier identifier call attribute identifier identifier argument_list expression_statement call identifier argument_list call identifier argument_list identifier
Checkout a new branch or checkout to a branch for a given issue.
def yes_or_no(message): while True: print message, '(yes/no)', line = raw_input() if line is None: return None line = line.lower() if line == 'y' or line == 'ye' or line == 'yes': return True if line == 'n' or line == 'no': return False
module function_definition identifier parameters identifier block while_statement true block print_statement identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list if_statement comparison_operator identifier none block return_statement none expression_statement assignment identifier call attribute identifier identifier argument_list if_statement boolean_operator boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content string_end block return_statement true 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 return_statement false
Gets user input and returns True for yes and False for no.
def ends(self, layer): ends = [] for data in self[layer]: ends.append(data[END]) return ends
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier list for_statement identifier subscript identifier identifier block expression_statement call attribute identifier identifier argument_list subscript identifier identifier return_statement identifier
Retrieve end positions of elements if given layer.
def _numbered_style(): style = ListStyle(name='_numbered_list') lls = ListLevelStyleNumber(level=1) lls.setAttribute('displaylevels', 1) lls.setAttribute('numsuffix', '. ') lls.setAttribute('numformat', '1') llp = ListLevelProperties() llp.setAttribute('listlevelpositionandspacemode', 'label-alignment') llla = ListLevelLabelAlignment(labelfollowedby='listtab') llla.setAttribute('listtabstopposition', '1.27cm') llla.setAttribute('textindent', '-0.635cm') llla.setAttribute('marginleft', '1.27cm') llp.addElement(llla) lls.addElement(llp) style.addElement(lls) return style
module function_definition identifier parameters block expression_statement assignment identifier call identifier argument_list keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier call identifier argument_list keyword_argument identifier integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end 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 expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call identifier argument_list 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 expression_statement call attribute identifier identifier argument_list string string_start string_content string_end 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 expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier
Create a numbered list style.
def mapping(self, kdims=None, vdims=None, **kwargs): "Deprecated method to convert data to dictionary" if config.future_deprecations: self.param.warning( "The mapping method is deprecated and should no " "longer be used. Use another one of the common " "formats instead, e.g. .dframe, .array or .columns.") length = len(self) if not kdims: kdims = self.kdims if kdims: keys = zip(*[self.dimension_values(dim.name) for dim in self.kdims]) else: keys = [()]*length if not vdims: vdims = self.vdims if vdims: values = zip(*[self.dimension_values(dim.name) for dim in vdims]) else: values = [()]*length return OrderedDict(zip(keys, values))
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none dictionary_splat_pattern identifier block expression_statement string string_start string_content string_end if_statement attribute identifier 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 string string_start string_content string_end expression_statement assignment identifier call identifier argument_list identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list list_splat list_comprehension call attribute identifier identifier argument_list attribute identifier identifier for_in_clause identifier attribute identifier identifier else_clause block expression_statement assignment identifier binary_operator list tuple identifier if_statement not_operator identifier block expression_statement assignment identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call identifier argument_list list_splat list_comprehension call attribute identifier identifier argument_list attribute identifier identifier for_in_clause identifier identifier else_clause block expression_statement assignment identifier binary_operator list tuple identifier return_statement call identifier argument_list call identifier argument_list identifier identifier
Deprecated method to convert data to dictionary
def call_env_doctree_read(cls, kb_app, sphinx_app: Sphinx, doctree: doctree): for callback in EventAction.get_callbacks(kb_app, SphinxEvent.DREAD): callback(kb_app, sphinx_app, doctree)
module function_definition identifier parameters identifier identifier typed_parameter identifier type identifier typed_parameter identifier type identifier block for_statement identifier call attribute identifier identifier argument_list identifier attribute identifier identifier block expression_statement call identifier argument_list identifier identifier identifier
On doctree-read, do callbacks
def classifymetagenome(self): logging.info('Classifying metagenomes') self.classifycall = 'cd {} && ./classify_metagenome.sh -O {} -R {} -n {} --light'\ .format(self.clarkpath, self.filelist, self.reportlist, self.cpus) classify = True for sample in self.runmetadata.samples: try: sample.general.classification = sample.general.combined.split('.')[0] + '.csv' if os.path.isfile(sample.general.classification): classify = False except KeyError: pass if classify: subprocess.call(self.classifycall, shell=True, stdout=self.devnull, stderr=self.devnull)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment attribute identifier identifier call attribute string string_start string_content string_end line_continuation identifier argument_list attribute identifier identifier attribute identifier identifier attribute identifier identifier attribute identifier identifier expression_statement assignment identifier true for_statement identifier attribute attribute identifier identifier identifier block try_statement block expression_statement assignment attribute attribute identifier identifier identifier binary_operator subscript call attribute attribute attribute identifier identifier identifier identifier argument_list string string_start string_content string_end integer string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list attribute attribute identifier identifier identifier block expression_statement assignment identifier false except_clause identifier block pass_statement if_statement identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Run the classify metagenome of the CLARK package on the samples
def tokenize(self, text): start = -1 tokens = [] for i, character in enumerate(text): if character == ' ' or character == '\t': if start >= 0: word = text[start:i] tokens.append({ 'word': word, 'original_text': word, 'char_begin': start, 'char_end': i}) start = -1 else: if start < 0: start = i if start >= 0: tokens.append({ 'word': text[start:len(text)], 'original_text': text[start:len(text)], 'char_begin': start, 'char_end': len(text) }) return tokens
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier unary_operator integer expression_statement assignment identifier list for_statement pattern_list identifier identifier call identifier argument_list identifier block if_statement boolean_operator comparison_operator identifier string string_start string_content string_end comparison_operator identifier string string_start string_content escape_sequence string_end block if_statement comparison_operator identifier integer block expression_statement assignment identifier subscript identifier slice identifier identifier expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end identifier expression_statement assignment identifier unary_operator integer else_clause block if_statement comparison_operator identifier integer block expression_statement assignment identifier identifier if_statement comparison_operator identifier integer block expression_statement call attribute identifier identifier argument_list dictionary pair string string_start string_content string_end subscript identifier slice identifier call identifier argument_list identifier pair string string_start string_content string_end subscript identifier slice identifier call identifier argument_list identifier pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier return_statement identifier
tokenize function in Tokenizer.
def stop_trace(self, frame=None): self.tracing = False self.full = False frame = frame or sys._getframe().f_back while frame: del frame.f_trace frame = frame.f_back sys.settrace(None) log.info('Stopping trace')
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment attribute identifier identifier false expression_statement assignment attribute identifier identifier false expression_statement assignment identifier boolean_operator identifier attribute call attribute identifier identifier argument_list identifier while_statement identifier block delete_statement attribute identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Stop tracing from here
def request(func=None, timeout=600): if func is None: return partial(request, timeout=timeout) @wraps(func) def wrapper(self, *args, **kwargs): params = func(self, *args, **kwargs) self = params.pop('self', None) entity = params.pop('entity', None) app_name = params.pop('app_name', None) request_id = unique_hex() params['request_id'] = request_id future = self._send_request(app_name, endpoint=func.__name__, entity=entity, params=params, timeout=timeout) return future wrapper.is_request = True return wrapper
module function_definition identifier parameters default_parameter identifier none default_parameter identifier integer block if_statement comparison_operator identifier none block return_statement call identifier argument_list identifier keyword_argument identifier identifier 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 assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end none expression_statement assignment identifier call identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier return_statement identifier expression_statement assignment attribute identifier identifier true return_statement identifier
use to request an api call from a specific endpoint
def instance_path_for(name, identifier_type, identifier_key=None): return "/{}/<{}:{}>".format( name_for(name), identifier_type, identifier_key or "{}_id".format(name_for(name)), )
module function_definition identifier parameters identifier identifier default_parameter identifier none block return_statement call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier identifier boolean_operator identifier call attribute string string_start string_content string_end identifier argument_list call identifier argument_list identifier
Get a path for thing.
def construct_channel(self, **kwargs): channel = self.get_channel(**kwargs) json_tree_path = self.get_json_tree_path(**kwargs) json_tree = read_tree_from_json(json_tree_path) build_tree_from_json(channel, json_tree['children']) raise_for_invalid_channel(channel) return channel
module function_definition identifier parameters identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier call attribute identifier identifier argument_list dictionary_splat identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call identifier argument_list identifier subscript identifier string string_start string_content string_end expression_statement call identifier argument_list identifier return_statement identifier
Build the channel tree by adding TopicNodes and ContentNode children.
def prt_objdesc(self, prt): txt = "INITIALIZING GoSubDag: {N:3} sources in {M:3} GOs rcnt({R}). {A} alt GO IDs\n" alt2obj = {go:o for go, o in self.go2obj.items() if go != o.id} prt.write(txt.format( N=len(self.go_sources), M=len(self.go2obj), R=self.rcntobj is not None, A=len(alt2obj))) prt.write(" GoSubDag: namedtuple fields: {FLDS}\n".format( FLDS=" ".join(self.prt_attr['flds']))) prt.write(" GoSubDag: relationships: {RELS}\n".format(RELS=self.relationships))
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier dictionary_comprehension pair identifier identifier for_in_clause pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list if_clause comparison_operator identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier call identifier argument_list attribute identifier identifier keyword_argument identifier comparison_operator attribute identifier identifier none keyword_argument identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content escape_sequence string_end identifier argument_list keyword_argument identifier call attribute string string_start string_content string_end identifier argument_list subscript attribute identifier identifier 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 keyword_argument identifier attribute identifier identifier
Return description of this GoSubDag object.
def minify_js_files(): for k, v in JS_FILE_MAPPING.items(): input_files = " ".join(v["input_files"]) output_file = v["output_file"] uglifyjs_command = "uglifyjs {input_files} -o {output_file}".format( input_files=input_files, output_file=output_file ) local(uglifyjs_command)
module function_definition identifier parameters block for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list subscript identifier string string_start string_content string_end expression_statement assignment identifier subscript identifier string string_start string_content string_end expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier
This command minified js files with UglifyJS
def exists(self, key, **opts): key, store = self._expand_opts(key, opts) data = store.get(key) if not data or self._has_expired(data, opts): return False return True
module function_definition identifier parameters identifier identifier dictionary_splat_pattern identifier block expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement boolean_operator not_operator identifier call attribute identifier identifier argument_list identifier identifier block return_statement false return_statement true
Return if a key exists in the cache.
def _connect(self, config): if 'connection_timeout' not in self._config: self._config['connection_timeout'] = 480 try: self._cnx = connect(**config) self._cursor = self._cnx.cursor() self._printer('\tMySQL DB connection established with db', config['database']) except Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: print("Something is wrong with your user name or password") elif err.errno == errorcode.ER_BAD_DB_ERROR: print("Database does not exist") raise err
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end integer try_statement block expression_statement assignment attribute identifier identifier call identifier argument_list dictionary_splat identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end subscript identifier string string_start string_content string_end except_clause as_pattern identifier as_pattern_target identifier block if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end elif_clause comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end raise_statement identifier
Establish a connection with a MySQL database.
def _distribute_save_datasets(self, scenes_iter, client, batch_size=1, **kwargs): def load_data(q): idx = 0 while True: future_list = q.get() if future_list is None: break for future in future_list: future.result() log.info("Finished saving %d scenes", idx) idx += 1 q.task_done() input_q = Queue(batch_size if batch_size is not None else 1) load_thread = Thread(target=load_data, args=(input_q,)) load_thread.start() for scene in scenes_iter: delayed = scene.save_datasets(compute=False, **kwargs) if isinstance(delayed, (list, tuple)) and len(delayed) == 2: raise NotImplementedError("Distributed save_datasets does not support writers " "that return (source, target) combinations at this time. Use " "the non-distributed save_datasets instead.") future = client.compute(delayed) input_q.put(future) input_q.put(None) log.debug("Waiting for child thread to get saved results...") load_thread.join() log.debug("Child thread died successfully")
module function_definition identifier parameters identifier identifier identifier default_parameter identifier integer dictionary_splat_pattern identifier block function_definition identifier parameters identifier block expression_statement assignment identifier integer while_statement true block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator identifier none block break_statement for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement augmented_assignment identifier integer expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call identifier argument_list conditional_expression identifier comparison_operator identifier none integer expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier tuple identifier expression_statement call attribute identifier identifier argument_list for_statement identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier false dictionary_splat identifier if_statement boolean_operator call identifier argument_list identifier tuple identifier identifier comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list none expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end
Distribute save_datasets across a cluster.
def _reflow_lines(parsed_tokens, indentation, max_line_length, start_on_prefix_line): if unicode(parsed_tokens[0]) == 'def': continued_indent = indentation + ' ' * 2 * DEFAULT_INDENT_SIZE else: continued_indent = indentation + ' ' * DEFAULT_INDENT_SIZE break_after_open_bracket = not start_on_prefix_line lines = ReformattedLines(max_line_length) lines.add_indent(len(indentation.lstrip('\r\n'))) if not start_on_prefix_line: first_token = get_item(parsed_tokens, 0) second_token = get_item(parsed_tokens, 1) if ( first_token and second_token and unicode(second_token)[0] == '(' and len(indentation) + len(first_token) + 1 == len(continued_indent) ): return None for item in parsed_tokens: lines.add_space_if_needed(unicode(item), equal=True) save_continued_indent = continued_indent if start_on_prefix_line and isinstance(item, Container): start_on_prefix_line = False continued_indent = ' ' * (lines.current_size() + 1) item.reflow(lines, continued_indent, break_after_open_bracket) continued_indent = save_continued_indent return lines.emit()
module function_definition identifier parameters identifier identifier identifier identifier block if_statement comparison_operator call identifier argument_list subscript identifier integer string string_start string_content string_end block expression_statement assignment identifier binary_operator identifier binary_operator binary_operator string string_start string_content string_end integer identifier else_clause block expression_statement assignment identifier binary_operator identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier not_operator identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list string string_start string_content escape_sequence escape_sequence string_end if_statement not_operator identifier block expression_statement assignment identifier call identifier argument_list identifier integer expression_statement assignment identifier call identifier argument_list identifier integer if_statement parenthesized_expression boolean_operator boolean_operator boolean_operator identifier identifier comparison_operator subscript call identifier argument_list identifier integer string string_start string_content string_end comparison_operator binary_operator binary_operator call identifier argument_list identifier call identifier argument_list identifier integer call identifier argument_list identifier block return_statement none for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier true expression_statement assignment identifier identifier if_statement boolean_operator identifier call identifier argument_list identifier identifier block expression_statement assignment identifier false expression_statement assignment identifier binary_operator string string_start string_content string_end parenthesized_expression binary_operator call attribute identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list identifier identifier identifier expression_statement assignment identifier identifier return_statement call attribute identifier identifier argument_list
Reflow the lines so that it looks nice.
def monitor(self, timeout): def check(self, timeout): time.sleep(timeout) self.stop() wather = threading.Thread(target=check) wather.setDaemon(True) wather.start()
module function_definition identifier parameters identifier identifier block function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list
Monitor the process, check whether it runs out of time.