code
stringlengths
51
2.34k
sequence
stringlengths
186
3.94k
docstring
stringlengths
11
171
def relpath(path): return os.path.normpath( os.path.join(os.path.abspath(os.path.dirname(__file__)), path) )
module function_definition identifier parameters identifier block return_statement call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier
Path helper, gives you a path relative to this file
def data_type(data, grouped=False, columns=None, key_on='idx', iter_idx=None): if iter_idx: return Data.from_mult_iters(idx=iter_idx, **data) if pd: if isinstance(data, (pd.Series, pd.DataFrame)): return Data.from_pandas(data, grouped=grouped, columns=columns, key_on=key_on) if isinstance(data, (list, tuple, dict)): return Data.from_iter(data) else: raise ValueError('This data type is not supported by Vincent.')
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier none default_parameter identifier string string_start string_content string_end default_parameter identifier none block if_statement identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier identifier dictionary_splat identifier if_statement identifier block if_statement call identifier argument_list identifier tuple attribute identifier identifier attribute identifier identifier block return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier if_statement call identifier argument_list identifier tuple identifier identifier identifier block return_statement call attribute identifier identifier argument_list identifier else_clause block raise_statement call identifier argument_list string string_start string_content string_end
Data type check for automatic import
def generate_file_name(self): if not self.project: raise UnderDefined("project name not given") out_data_dir = prms.Paths.outdatadir project_dir = os.path.join(out_data_dir, self.project) file_name = "cellpy_batch_%s.json" % self.name self.file_name = os.path.join(project_dir, file_name)
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment identifier attribute attribute identifier identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier attribute identifier identifier expression_statement assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier expression_statement assignment attribute identifier identifier call attribute attribute identifier identifier identifier argument_list identifier identifier
generate a suitable file name for the experiment
def _gregorian_to_ssweek(date_value): "Sundaystarting-week year, week and day for the given Gregorian calendar date" yearStart = _ssweek_year_start(date_value.year) weekNum = ((date_value - yearStart).days) // 7 + 1 dayOfWeek = date_value.weekday()+1 return (date_value.year, weekNum, dayOfWeek)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier expression_statement assignment identifier binary_operator binary_operator parenthesized_expression attribute parenthesized_expression binary_operator identifier identifier identifier integer integer expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list integer return_statement tuple attribute identifier identifier identifier identifier
Sundaystarting-week year, week and day for the given Gregorian calendar date
def run_continuous(self, scale): if scale == self.scale_in: raise ValueError("The scale must be different from the input scale") elif scale < self.scale_in: scale_min = scale scale_max = self.scale_in elif scale > self.scale_in: scale_max = scale scale_min = self.scale_in fun = rge.smeft_evolve_continuous(C_in=self.C_in, scale_in=self.scale_in, scale_out=scale) return wilson.classes.RGsolution(fun, scale_min, scale_max)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end elif_clause comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier keyword_argument identifier identifier return_statement call attribute attribute identifier identifier identifier argument_list identifier identifier identifier
Return a continuous solution to the RGE as `RGsolution` instance.
def refreshDetails( self ): tree = self.uiRecordsTREE tree.blockSignals(True) tree.setRecordSet(self.records()) tree.blockSignals(False)
module function_definition identifier parameters identifier block expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list true expression_statement call attribute identifier identifier argument_list call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list false
Refreshes the results for the details view of the browser.
def BrushForNode( self, node, depth=0 ): if node == self.selectedNode: color = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT) elif node == self.highlightedNode: color = wx.Colour( red=0, green=255, blue=0 ) else: color = self.adapter.background_color(node, depth) if not color: red = (depth * 10)%255 green = 255-((depth * 5)%255) blue = (depth * 25)%255 color = wx.Colour( red, green, blue ) return wx.Brush( color )
module function_definition identifier parameters identifier identifier default_parameter identifier integer block if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier integer keyword_argument identifier integer else_clause block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier binary_operator integer parenthesized_expression binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier integer integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier identifier return_statement call attribute identifier identifier argument_list identifier
Create brush to use to display the given node
def datetime64_to_datetime(dt): dt64 = np.datetime64(dt) ts = (dt64 - np.datetime64('1970-01-01T00:00:00')) / np.timedelta64(1, 's') return datetime.datetime.utcfromtimestamp(ts)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier binary_operator parenthesized_expression binary_operator identifier call attribute identifier identifier argument_list string string_start string_content string_end call attribute identifier identifier argument_list integer string string_start string_content string_end return_statement call attribute attribute identifier identifier identifier argument_list identifier
convert numpy's datetime64 to datetime
def kwds(self): return _kwds(base=self.base, item=self.item, leng=self.leng, refs=self.refs, both=self.both, kind=self.kind, type=self.type)
module function_definition identifier parameters identifier block return_statement call identifier argument_list keyword_argument identifier attribute 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 keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier
Return all attributes as keywords dict.
def handle_keypress(self): if self.numpress == 2: self.sig_double_tab_pressed.emit(True) self.numpress = 0
module function_definition identifier parameters identifier block if_statement comparison_operator attribute identifier identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list true expression_statement assignment attribute identifier identifier integer
When hitting tab, it handles if single or double tab
def xAxisIsMinor(self): return min(self.radius.x, self.radius.y) == self.radius.x
module function_definition identifier parameters identifier block return_statement comparison_operator call identifier argument_list attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier
Returns True if the minor axis is parallel to the X axis, boolean.
def _createFromRDD(self, rdd, schema, samplingRatio): if schema is None or isinstance(schema, (list, tuple)): struct = self._inferSchema(rdd, samplingRatio, names=schema) converter = _create_converter(struct) rdd = rdd.map(converter) if isinstance(schema, (list, tuple)): for i, name in enumerate(schema): struct.fields[i].name = name struct.names[i] = name schema = struct elif not isinstance(schema, StructType): raise TypeError("schema should be StructType or list or None, but got: %s" % schema) rdd = rdd.map(schema.toInternal) return rdd, schema
module function_definition identifier parameters identifier identifier identifier identifier block if_statement boolean_operator comparison_operator identifier none call identifier argument_list identifier tuple identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call identifier argument_list identifier tuple identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list identifier block expression_statement assignment attribute subscript attribute identifier identifier identifier identifier identifier expression_statement assignment subscript attribute identifier identifier identifier identifier expression_statement assignment identifier identifier elif_clause not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier return_statement expression_list identifier identifier
Create an RDD for DataFrame from an existing RDD, returns the RDD and schema.
def _old_run_cmd(self, cmd): try: proc = subprocess.Popen( cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE, ) data = proc.communicate() return data[0], data[1], proc.returncode except Exception: return ('local', 'Unknown Error', None)
module function_definition identifier parameters identifier identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier true keyword_argument identifier attribute identifier identifier keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list return_statement expression_list subscript identifier integer subscript identifier integer attribute identifier identifier except_clause identifier block return_statement tuple string string_start string_content string_end string string_start string_content string_end none
Cleanly execute the command string
def _process_pair(first_fn, second_fn, error_protocol): ebook = None metadata = None if _is_meta(first_fn) and not _is_meta(second_fn): logger.debug( "Parsed: '%s' as meta, '%s' as data." % (first_fn, second_fn) ) metadata, ebook = first_fn, second_fn elif not _is_meta(first_fn) and _is_meta(second_fn): logger.debug( "Parsed: '%s' as meta, '%s' as data." % (second_fn, first_fn) ) metadata, ebook = second_fn, first_fn elif _is_meta(first_fn) and _is_meta(second_fn): logger.debug( "Parsed: both '%s' and '%s' as meta." % (first_fn, second_fn) ) return [ _safe_read_meta_file(first_fn, error_protocol), _safe_read_meta_file(second_fn, error_protocol) ] else: logger.debug( "Parsed: both '%s' and '%s' as data." % (first_fn, second_fn) ) return [ EbookFile(first_fn), EbookFile(second_fn) ] pair = DataPair( metadata_file=_safe_read_meta_file(metadata, error_protocol), ebook_file=EbookFile(ebook) ) if not pair.metadata_file: logger.error( "Can't parse MetadataFile '%s'. Continuing with data file '%s'." % ( metadata, ebook ) ) return [pair.ebook_file] return [pair]
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier none expression_statement assignment identifier none if_statement boolean_operator call identifier argument_list identifier not_operator call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment pattern_list identifier identifier expression_list identifier identifier elif_clause boolean_operator not_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier expression_statement assignment pattern_list identifier identifier expression_list identifier identifier elif_clause boolean_operator call identifier argument_list identifier call identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement list call identifier argument_list identifier identifier call identifier argument_list identifier identifier else_clause block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement list call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list keyword_argument identifier call identifier argument_list identifier identifier keyword_argument identifier call identifier argument_list identifier if_statement not_operator attribute identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement list attribute identifier identifier return_statement list identifier
Look at given filenames, decide which is what and try to pair them.
def add(self, item): if not item in self.items: self.items.append(item)
module function_definition identifier parameters identifier identifier block if_statement not_operator comparison_operator identifier attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Add an item to the set.
def _timeout(self, timeout, handler, *args, **kw): t = spawn_thread(target=handler, args=args, kw=kw) t.daemon = True t.start() t.join(timeout) if not t.is_alive(): if t.exc_info: return t.exc_info return t.result else: try: msg = '[%s] Execution was forcefully terminated' raise RuntimeError(msg % t.name) except: return sys.exc_info()
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement assignment identifier call identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier expression_statement assignment attribute identifier identifier true expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier if_statement not_operator call attribute identifier identifier argument_list block if_statement attribute identifier identifier block return_statement attribute identifier identifier return_statement attribute identifier identifier else_clause block try_statement block expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list binary_operator identifier attribute identifier identifier except_clause block return_statement call attribute identifier identifier argument_list
Controls the time allocated for the execution of a method
def com_google_fonts_check_name_copyright_length(ttFont): from fontbakery.utils import get_name_entries failed = False for notice in get_name_entries(ttFont, NameID.COPYRIGHT_NOTICE): notice_str = notice.string.decode(notice.getEncoding()) if len(notice_str) > 500: failed = True yield FAIL, ("The length of the following copyright notice ({})" " exceeds 500 chars: '{}'" "").format(len(notice_str), notice_str) if not failed: yield PASS, ("All copyright notice name entries on the" " 'name' table are shorter than 500 characters.")
module function_definition identifier parameters identifier block import_from_statement dotted_name identifier identifier dotted_name identifier expression_statement assignment identifier false for_statement identifier call identifier argument_list identifier attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list if_statement comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier true expression_statement yield expression_list identifier call attribute parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end string string_start string_end identifier argument_list call identifier argument_list identifier identifier if_statement not_operator identifier block expression_statement yield expression_list identifier parenthesized_expression concatenated_string string string_start string_content string_end string string_start string_content string_end
Length of copyright notice must not exceed 500 characters.
def _compute_weight(powers, wg): pow1 = (powers[0], 0) pow2 = (0, powers[1]) cal1 = _compute_value(pow1, wg) cal2 = _compute_value(pow2, wg) return cal1 * cal2
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier tuple subscript identifier integer integer expression_statement assignment identifier tuple integer subscript identifier integer expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier return_statement binary_operator identifier identifier
Return the weight corresponding to given powers.
def find_project_by_short_name(short_name, pbclient, all=None): try: response = pbclient.find_project(short_name=short_name, all=all) check_api_error(response) if (len(response) == 0): msg = '%s not found! You can use the all=1 argument to \ search in all the server.' error = 'Project Not Found' raise ProjectNotFound(msg, error) return response[0] except exceptions.ConnectionError: raise except ProjectNotFound: raise
module function_definition identifier parameters identifier identifier default_parameter identifier none block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier expression_statement call identifier argument_list identifier if_statement parenthesized_expression comparison_operator call identifier argument_list identifier integer block expression_statement assignment identifier string string_start string_content escape_sequence string_end expression_statement assignment identifier string string_start string_content string_end raise_statement call identifier argument_list identifier identifier return_statement subscript identifier integer except_clause attribute identifier identifier block raise_statement except_clause identifier block raise_statement
Return project by short_name.
def type_and_times(type_: str, start: Timestamp, end: Timestamp, probability: Number = None) -> str: if not type_: return '' if type_ == 'BECMG': return f"At {start.dt.hour or 'midnight'} zulu becoming" ret = f"From {start.dt.hour or 'midnight'} to {end.dt.hour or 'midnight'} zulu," if probability and probability.value: ret += f" there's a {probability.value}% chance for" if type_ == 'INTER': ret += ' intermittent' elif type_ == 'TEMPO': ret += ' temporary' return ret
module function_definition identifier parameters typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_default_parameter identifier type identifier none type identifier block if_statement not_operator identifier block return_statement string string_start string_end if_statement comparison_operator identifier string string_start string_content string_end block return_statement string string_start string_content interpolation boolean_operator attribute attribute identifier identifier identifier string string_start string_content string_end string_content string_end expression_statement assignment identifier string string_start string_content interpolation boolean_operator attribute attribute identifier identifier identifier string string_start string_content string_end string_content interpolation boolean_operator attribute attribute identifier identifier identifier string string_start string_content string_end string_content string_end if_statement boolean_operator identifier attribute identifier identifier block expression_statement augmented_assignment identifier string string_start string_content interpolation attribute identifier identifier string_content string_end if_statement comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end elif_clause comparison_operator identifier string string_start string_content string_end block expression_statement augmented_assignment identifier string string_start string_content string_end return_statement identifier
Format line type and times into the beginning of a spoken line string
def CheckBlobsExist(self, blob_ids): result = {} for blob_id in blob_ids: result[blob_id] = blob_id in self.blobs return result
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier dictionary for_statement identifier identifier block expression_statement assignment subscript identifier identifier comparison_operator identifier attribute identifier identifier return_statement identifier
Checks if given blobs exit.
def check_bundler(self): def get_config(name): return name if self.config('bundler.' + name) else '' from pkg_resources import Requirement, resource_filename relative_path = os.path.join('PyGitUp', 'check-bundler.rb') bundler_script = resource_filename(Requirement.parse('git-up'), relative_path) assert os.path.exists(bundler_script), 'check-bundler.rb doesn\'t ' \ 'exist!' return_value = subprocess.call( ['ruby', bundler_script, get_config('autoinstall'), get_config('local'), get_config('rbenv')] ) if self.testing: assert return_value == 0, 'Errors while executing check-bundler.rb'
module function_definition identifier parameters identifier block function_definition identifier parameters identifier block return_statement conditional_expression identifier call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier string string_start string_end import_from_statement dotted_name identifier dotted_name identifier dotted_name identifier expression_statement assignment identifier call attribute attribute identifier 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 call attribute identifier identifier argument_list string string_start string_content string_end identifier assert_statement call attribute attribute identifier identifier identifier argument_list identifier concatenated_string string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list list string string_start string_content string_end identifier call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end call identifier argument_list string string_start string_content string_end if_statement attribute identifier identifier block assert_statement comparison_operator identifier integer string string_start string_content string_end
Run the bundler check.
def template(args): " Add or remove templates from site. " site = Site(args.PATH) if args.ACTION == "add": return site.add_template(args.TEMPLATE) return site.remove_template(args.TEMPLATE)
module function_definition identifier parameters identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list attribute identifier identifier if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list attribute identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier
Add or remove templates from site.
def should_copy_file(remote_storage, path, prefixed_path, source_storage): if has_matching_etag( remote_storage, source_storage, path, prefixed_path): logger.info("%s: Skipping based on matching file hashes" % path) return False destroy_etag(path) logger.info("%s: Hashes did not match" % path) return True
module function_definition identifier parameters identifier identifier identifier identifier block if_statement call identifier argument_list identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement false expression_statement call identifier argument_list identifier expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end identifier return_statement true
Returns True if the file should be copied, otherwise False.
def _get_command(classes): commands = {} setup_file = os.path.join( os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')), 'setup.cfg') for line in open(setup_file, 'r'): for cl in classes: if cl in line: commands[cl] = line.split(' = ')[0].strip().replace('_', ' ') return commands
module function_definition identifier parameters identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end for_statement identifier call identifier argument_list identifier string string_start string_content string_end block for_statement identifier identifier block if_statement comparison_operator identifier identifier block expression_statement assignment subscript identifier identifier call attribute call attribute subscript call attribute identifier identifier argument_list string string_start string_content string_end integer identifier argument_list identifier argument_list string string_start string_content string_end string string_start string_content string_end return_statement identifier
Associates each command class with command depending on setup.cfg
def show_plain_text(self, text): self.switch_to_plugin() self.switch_to_plain_text() self.set_plain_text(text, is_code=False)
module function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list identifier keyword_argument identifier false
Show text in plain mode
def validate(method): @wraps(method) def mod_run(self, rinput): self.validate_input(rinput) result = method(self, rinput) self.validate_result(result) return result return mod_run
module function_definition identifier parameters identifier block decorated_definition decorator call identifier argument_list identifier function_definition identifier parameters identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier return_statement identifier return_statement identifier
Decorate run method, inputs and outputs are validated
def append(self, entry): if not self.is_appendable(entry): raise ValueError('entry not appendable') self.data += entry.data
module function_definition identifier parameters identifier identifier block if_statement not_operator call attribute identifier identifier argument_list identifier block raise_statement call identifier argument_list string string_start string_content string_end expression_statement augmented_assignment attribute identifier identifier attribute identifier identifier
Append an entry to self
def search(self, term=None, category=None, pages=1, url=search_url, sort=None, order=None): if not self.current_url: self.current_url = url if self.current_url == Search.base_url: results = self._get_results(self.current_url) self._add_results(results) else: search = self._format_search(term, category) sorting = self._format_sort(sort, order) for i in range(pages): results = self._get_results(search + "/" + str(self._current_page) + "/" + sorting) self._add_results(results) self._current_page += 1 self._current_page -= 1
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none default_parameter identifier integer default_parameter identifier identifier default_parameter identifier none default_parameter identifier none block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier identifier if_statement comparison_operator attribute identifier identifier attribute identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier for_statement identifier call identifier argument_list identifier block expression_statement assignment identifier call attribute identifier identifier argument_list binary_operator binary_operator binary_operator binary_operator identifier string string_start string_content string_end call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement augmented_assignment attribute identifier identifier integer expression_statement augmented_assignment attribute identifier identifier integer
Search a given URL for torrent results.
def feedback_form_url(project, page): return FEEDBACK_FORM_FMT.format(pageid=quote("{}: {}".format(project, page)))
module function_definition identifier parameters identifier identifier block return_statement call attribute identifier identifier argument_list keyword_argument identifier call identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier identifier
Create a URL for feedback on a particular page in a project.
def build(target_python, requirements): if not requirements: return testapp = 'setup_testapp_python2.py' android_sdk_home = os.environ['ANDROID_SDK_HOME'] android_ndk_home = os.environ['ANDROID_NDK_HOME'] if target_python == TargetPython.python3: testapp = 'setup_testapp_python3_sqlite_openssl.py' requirements.add(target_python.name) requirements = ','.join(requirements) logger.info('requirements: {}'.format(requirements)) with current_directory('testapps/'): for line in sh.python( testapp, 'apk', '--sdk-dir', android_sdk_home, '--ndk-dir', android_ndk_home, '--bootstrap', 'sdl2', '--requirements', requirements, _err_to_out=True, _iter=True): print(line)
module function_definition identifier parameters identifier identifier block if_statement not_operator identifier block return_statement expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier subscript attribute identifier identifier string string_start string_content string_end if_statement comparison_operator identifier attribute identifier identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment identifier call attribute string string_start string_content string_end identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier with_statement with_clause with_item call identifier argument_list string string_start string_content string_end block for_statement identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end string string_start string_content string_end identifier string string_start string_content string_end identifier string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end identifier keyword_argument identifier true keyword_argument identifier true block expression_statement call identifier argument_list identifier
Builds an APK given a target Python and a set of requirements.
def transform(row, table): 'Extract links from "project" field and remove HTML from all' data = row._asdict() data["links"] = " ".join(extract_links(row.project)) for key, value in data.items(): if isinstance(value, six.text_type): data[key] = extract_text(value) return data
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end call attribute string string_start string_content string_end identifier argument_list call identifier argument_list attribute identifier identifier for_statement pattern_list identifier identifier call attribute identifier identifier argument_list block if_statement call identifier argument_list identifier attribute identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier return_statement identifier
Extract links from "project" field and remove HTML from all
def _serialiseExistingJob(self, jobGraph, jobStore, returnValues): self._serialiseJobGraph(jobGraph, jobStore, returnValues, False) jobGraph.command = None assert len(jobGraph.stack) >= 4 combinedChildren = jobGraph.stack[-1] + jobGraph.stack[-3] combinedFollowOns = jobGraph.stack[-2] + jobGraph.stack[-4] jobGraph.stack = jobGraph.stack[:-4] if len(combinedFollowOns) > 0: jobGraph.stack.append(combinedFollowOns) if len(combinedChildren) > 0: jobGraph.stack.append(combinedChildren)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement call attribute identifier identifier argument_list identifier identifier identifier false expression_statement assignment attribute identifier identifier none assert_statement comparison_operator call identifier argument_list attribute identifier identifier integer expression_statement assignment identifier binary_operator subscript attribute identifier identifier unary_operator integer subscript attribute identifier identifier unary_operator integer expression_statement assignment identifier binary_operator subscript attribute identifier identifier unary_operator integer subscript attribute identifier identifier unary_operator integer expression_statement assignment attribute identifier identifier subscript attribute identifier identifier slice unary_operator integer if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list identifier if_statement comparison_operator call identifier argument_list identifier integer block expression_statement call attribute attribute identifier identifier identifier argument_list identifier
Serialise an existing job.
def read(filename, paramfile, bdfdir, scan): filename = os.path.abspath(filename) scans = ps.read_scans(filename, bdfdir=bdfdir) logger.info('Scans, Target names:') logger.info('%s' % str([(ss, scans[ss]['source']) for ss in scans])) logger.info('Example pipeline:') state = rt.set_pipeline(filename, scan, paramfile=paramfile, logfile=False)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end call identifier argument_list list_comprehension tuple identifier subscript subscript identifier identifier string string_start string_content string_end for_in_clause identifier identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier keyword_argument identifier identifier keyword_argument identifier false
Simple parse and return metadata for pipeline for first scan
def efetch(self, db, id): db = db.lower() xml = self._qs.efetch({'db': db, 'id': str(id)}) doc = le.XML(xml) if db in ['gene']: return EntrezgeneSet(doc) if db in ['nuccore', 'nucest', 'protein']: return GBSet(doc) if db in ['pubmed']: return PubmedArticleSet(doc) if db in ['snp']: return ExchangeSet(xml) if db in ['pmc']: return PubmedCentralArticleSet(doc) raise EutilsError('database {db} is not currently supported by eutils'.format(db=db))
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list dictionary pair string string_start string_content string_end identifier pair string string_start string_content string_end call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier list string string_start string_content string_end block return_statement call identifier argument_list identifier if_statement 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 block return_statement call identifier argument_list identifier if_statement comparison_operator identifier list string string_start string_content string_end block return_statement call identifier argument_list identifier if_statement comparison_operator identifier list string string_start string_content string_end block return_statement call identifier argument_list identifier if_statement comparison_operator identifier list string string_start string_content string_end block return_statement call identifier argument_list identifier raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list keyword_argument identifier identifier
query the efetch endpoint
def createDocument(self, initDict = None) : if initDict is not None : return self.createDocument_(initDict) else : if self._validation["on_load"] : self._validation["on_load"] = False return self.createDocument_(self.defaultDocument) self._validation["on_load"] = True else : return self.createDocument_(self.defaultDocument)
module function_definition identifier parameters identifier default_parameter identifier none block if_statement comparison_operator identifier none block return_statement call attribute identifier identifier argument_list identifier else_clause block if_statement subscript attribute identifier identifier string string_start string_content string_end block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end false return_statement call attribute identifier identifier argument_list attribute identifier identifier expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end true else_clause block return_statement call attribute identifier identifier argument_list attribute identifier identifier
create and returns a document populated with the defaults or with the values in initDict
def flush(self): self.__flushLevel(0) if self.__lastImport is not None: self.imports.append(self.__lastImport)
module function_definition identifier parameters identifier block expression_statement call attribute identifier identifier argument_list integer if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier
Flushes the collected information
def send(self, msg): with self._pub_lock: self.publish.send_string(msg) return self
module function_definition identifier parameters identifier identifier block with_statement with_clause with_item attribute identifier identifier block expression_statement call attribute attribute identifier identifier identifier argument_list identifier return_statement identifier
Send the given message.
def register_route(self, app): if "url" not in self.params["options"]: raise Exception("Component does not have a URL property") if not hasattr(self.route_func, "__call__"): raise Exception("No app route function supplied") app.add_url_rule(self.params["options"]["url"], self.params["options"]["url"], self.route_func)
module function_definition identifier parameters identifier identifier block if_statement comparison_operator string string_start string_content string_end subscript attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end if_statement not_operator call identifier argument_list attribute identifier identifier string string_start string_content string_end block raise_statement call identifier argument_list string string_start string_content string_end expression_statement call attribute identifier identifier argument_list subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end subscript subscript attribute identifier identifier string string_start string_content string_end string string_start string_content string_end attribute identifier identifier
Register the api route function with the app.
def _build_fields(self): declared_fields = self.solr._send_request('get', ADMIN_URL) result = decoder.decode(declared_fields) self.field_list = self._parse_fields(result, 'fields') self._dynamic_field_regexes = [] for wc_pattern in self._parse_fields(result, 'dynamicFields'): if wc_pattern[0] == "*": self._dynamic_field_regexes.append( re.compile(".*%s\Z" % wc_pattern[1:])) elif wc_pattern[-1] == "*": self._dynamic_field_regexes.append( re.compile("\A%s.*" % wc_pattern[:-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 identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end expression_statement assignment attribute identifier identifier list for_statement identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end block if_statement comparison_operator subscript identifier integer string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier slice integer elif_clause comparison_operator subscript identifier unary_operator integer string string_start string_content string_end block expression_statement call attribute attribute identifier identifier identifier argument_list call attribute identifier identifier argument_list binary_operator string string_start string_content string_end subscript identifier slice unary_operator integer
Builds a list of valid fields
def changes_found(self): if self.dest is None: warnings.warn("dest directory not found!") if self.src is None: warnings.warn("src directory not found!") if self.src is None or self.dest is None: return False dest_mtime = -1 src_mtime = os.path.getmtime(self.src) if os.path.exists(self.dest): dest_mtime = os.path.getmtime(self.dest) if src_mtime >= dest_mtime: return True for folder, _, files in os.walk(self.src): for filename in fnmatch.filter(files, '*.scss'): src_path = os.path.join(folder, filename) if os.path.getmtime(src_path) >= dest_mtime: return True return False
module function_definition identifier parameters identifier 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 if_statement comparison_operator attribute identifier identifier none block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator attribute identifier identifier none comparison_operator attribute identifier identifier none block return_statement false expression_statement assignment identifier unary_operator integer expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier if_statement comparison_operator identifier identifier block return_statement true for_statement pattern_list identifier identifier identifier call attribute identifier identifier argument_list attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier if_statement comparison_operator call attribute attribute identifier identifier identifier argument_list identifier identifier block return_statement true return_statement false
Returns True if the target folder is older than the source folder.
def _string_generator(descriptor, max_length=0, limit=0): 'Helper to create a string generator' vals = list(values.get_strings(max_length, limit)) return gen.IterValueGenerator(descriptor.name, vals)
module function_definition identifier parameters identifier default_parameter identifier integer default_parameter identifier integer block expression_statement string string_start string_content string_end expression_statement assignment identifier call identifier argument_list call attribute identifier identifier argument_list identifier identifier return_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Helper to create a string generator
def pretty_printer_factory(p_todolist, p_additional_filters=None): p_additional_filters = p_additional_filters or [] printer = PrettyPrinter() printer.add_filter(PrettyPrinterNumbers(p_todolist)) for ppf in p_additional_filters: printer.add_filter(ppf) printer.add_filter(PrettyPrinterColorFilter()) return printer
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier boolean_operator identifier list expression_statement assignment identifier call identifier argument_list expression_statement call attribute identifier identifier argument_list call identifier argument_list identifier for_statement identifier identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list call identifier argument_list return_statement identifier
Returns a pretty printer suitable for the ls and dep subcommands.
def OnPadIntCtrl(self, event): self.attrs["pad"] = event.GetValue() post_command_event(self, self.DrawChartMsg)
module function_definition identifier parameters identifier identifier block expression_statement assignment subscript attribute identifier identifier string string_start string_content string_end call attribute identifier identifier argument_list expression_statement call identifier argument_list identifier attribute identifier identifier
Pad IntCtrl event handler
def keys(self, namespace, prefix=None, limit=None, offset=None): params = [namespace] query = 'SELECT key FROM gauged_keys WHERE namespace = %s' if prefix is not None: query += ' AND key LIKE %s' params.append(prefix + '%') if limit is not None: query += ' LIMIT %s' params.append(limit) if offset is not None: query += ' OFFSET %s' params.append(offset) cursor = self.cursor cursor.execute(query, params) return [key for key, in cursor]
module function_definition identifier parameters identifier identifier default_parameter identifier none default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier list identifier expression_statement assignment identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier none block expression_statement augmented_assignment identifier string string_start string_content string_end expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement list_comprehension identifier for_in_clause pattern_list identifier identifier
Get keys from a namespace
def clear_cache(self): self.logger.debug("Clearing cache") if os.path.isdir(self.songcache_dir): for filename in os.listdir(self.songcache_dir): file_path = os.path.join(self.songcache_dir, filename) try: if os.path.isfile(file_path): os.unlink(file_path) except PermissionError: pass except Exception as e: logger.exception(e) self.logger.debug("Cache cleared")
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement call attribute attribute identifier identifier identifier argument_list attribute identifier identifier block for_statement identifier call attribute identifier identifier argument_list attribute identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list attribute identifier identifier identifier try_statement block if_statement call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement except_clause as_pattern identifier as_pattern_target identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end
Removes all files from the songcache dir
def from_data(cls, data): if len(data) == 0: raise ValueError("data array is empty.") dim_x, dim_y = len(data[0][0]), len(data[0][1]) dataset = cls(dim_x, dim_y) for x, y in data: assert len(x) == dim_x and len(y) == dim_y dataset.add_xy(x, y) return dataset
module function_definition identifier parameters identifier identifier block if_statement comparison_operator call identifier argument_list identifier integer block raise_statement call identifier argument_list string string_start string_content string_end expression_statement assignment pattern_list identifier identifier expression_list call identifier argument_list subscript subscript identifier integer integer call identifier argument_list subscript subscript identifier integer integer expression_statement assignment identifier call identifier argument_list identifier identifier for_statement pattern_list identifier identifier identifier block assert_statement boolean_operator comparison_operator call identifier argument_list identifier identifier comparison_operator call identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier return_statement identifier
Create a dataset from an array of data, infering the dimension from the datapoint
def dispatch_operation(self, operation, request, path_args): try: for middleware in self.middleware.pre_dispatch: middleware(request, path_args) resource = operation(request, path_args) for middleware in self.middleware.post_dispatch: resource = middleware(request, resource) except ImmediateHttpResponse as e: return e.resource, e.status, e.headers except ValidationError as e: if hasattr(e, 'message_dict'): resource = Error.from_status(HTTPStatus.BAD_REQUEST, 0, "Failed validation", meta=e.message_dict) else: resource = Error.from_status(HTTPStatus.BAD_REQUEST, 0, str(e)) return resource, resource.status, None except NotImplementedError: resource = Error.from_status(HTTPStatus.NOT_IMPLEMENTED, 0, "The method has not been implemented") return resource, resource.status, None except Exception as e: if self.debug_enabled: raise resource = None if resource is None: resource = self.handle_500(request, e) return resource, resource.status, None else: return resource, None, None
module function_definition identifier parameters identifier identifier identifier identifier block try_statement block for_statement identifier attribute attribute identifier identifier identifier block expression_statement call identifier argument_list identifier identifier expression_statement assignment identifier call identifier argument_list identifier identifier for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment identifier call identifier argument_list identifier identifier except_clause as_pattern identifier as_pattern_target identifier block return_statement expression_list attribute identifier identifier attribute identifier identifier attribute identifier identifier except_clause as_pattern identifier as_pattern_target identifier block if_statement call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier integer string string_start string_content string_end keyword_argument identifier attribute identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier integer call identifier argument_list identifier return_statement expression_list identifier attribute identifier identifier none except_clause identifier block expression_statement assignment identifier call attribute identifier identifier argument_list attribute identifier identifier integer string string_start string_content string_end return_statement expression_list identifier attribute identifier identifier none except_clause as_pattern identifier as_pattern_target identifier block if_statement attribute identifier identifier block raise_statement expression_statement assignment identifier none if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier return_statement expression_list identifier attribute identifier identifier none else_clause block return_statement expression_list identifier none none
Dispatch and handle exceptions from operation.
def install_PMK(self): self.pmk = PBKDF2HMAC( algorithm=hashes.SHA1(), length=32, salt=self.ssid.encode(), iterations=4096, backend=default_backend(), ).derive(self.passphrase.encode())
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute call identifier argument_list keyword_argument identifier call attribute identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier integer keyword_argument identifier call identifier argument_list identifier argument_list call attribute attribute identifier identifier identifier argument_list
Compute and install the PMK
def scoped_timeline(self, *id, **kwargs): self._validate_loaded() params = {'user_id': id} params.update(kwargs) resource = self.SCOPED_TIMELINE.format(id=self.id) response = Request(self.client, 'get', resource, params=params).perform() return response.body['data']
module function_definition identifier parameters identifier list_splat_pattern identifier dictionary_splat_pattern identifier block expression_statement call attribute identifier identifier argument_list expression_statement assignment identifier dictionary pair string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier attribute identifier identifier expression_statement assignment identifier call attribute call identifier argument_list attribute identifier identifier string string_start string_content string_end identifier keyword_argument identifier identifier identifier argument_list return_statement subscript attribute identifier identifier string string_start string_content string_end
Returns the most recent promotable Tweets created by the specified Twitter user.
def string_matches_sans_whitespace(self, str1, str2_fuzzy_whitespace): str2_fuzzy_whitespace = re.sub('\s+', '\s*', str2_fuzzy_whitespace) return re.search(str2_fuzzy_whitespace, str1) is not None
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_content string_end identifier return_statement comparison_operator call attribute identifier identifier argument_list identifier identifier none
Check if two strings match, modulo their whitespace.
def register_or_check(klass, finish, mean, between, refresh_presision, configuration): m, created = klass.objects.get_or_create(finish=finish, configuration=configuration) if created: m.mean=mean m.between=between m.refresh_presision=refresh_presision m.save() else: diff = abs(float(m.mean) - mean) if not(diff < 0.006 and m.between == between and m.refresh_presision == refresh_presision): raise InvalidMeasurementError("There are diferents values for the same measurement.") return m
module function_definition identifier parameters identifier identifier identifier identifier identifier identifier block expression_statement assignment pattern_list identifier identifier call attribute attribute identifier identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier if_statement identifier block expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier expression_statement call attribute identifier identifier argument_list else_clause block expression_statement assignment identifier call identifier argument_list binary_operator call identifier argument_list attribute identifier identifier identifier if_statement not_operator parenthesized_expression boolean_operator boolean_operator comparison_operator identifier float comparison_operator attribute identifier identifier identifier comparison_operator attribute identifier identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end return_statement identifier
Return the active configurations.
def dump_engines(target=sys.stderr): print("Available templating engines:", file=target) width = max(len(engine) for engine in engines.engines) for handle, engine in sorted(engines.engines.items()): description = engine.__doc__.split('\n', 0)[0] print(" %-*s - %s" % (width, handle, description), file=target)
module function_definition identifier parameters default_parameter identifier attribute identifier identifier block expression_statement call identifier argument_list string string_start string_content string_end keyword_argument identifier identifier expression_statement assignment identifier call identifier generator_expression call identifier argument_list identifier for_in_clause identifier attribute identifier identifier for_statement pattern_list identifier identifier call identifier argument_list call attribute attribute identifier identifier identifier argument_list block expression_statement assignment identifier subscript call attribute attribute identifier identifier identifier argument_list string string_start string_content escape_sequence string_end integer integer expression_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier identifier keyword_argument identifier identifier
Print successfully imported templating engines.
def channel_is_closed( self, participant1: Address, participant2: Address, block_identifier: BlockSpecification, channel_identifier: ChannelID, ) -> bool: try: channel_state = self._get_channel_state( participant1=participant1, participant2=participant2, block_identifier=block_identifier, channel_identifier=channel_identifier, ) except RaidenRecoverableError: return False return channel_state == ChannelState.CLOSED
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type identifier block try_statement block expression_statement assignment identifier call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier except_clause identifier block return_statement false return_statement comparison_operator identifier attribute identifier identifier
Returns true if the channel is in a closed state, false otherwise.
def ungroupslice(groups,gslice): 'this is a helper for contigsub.' 'coordinate transform: takes a match from seqingroups() and transforms to ungrouped coordinates' eltsbefore=0 for i in range(gslice[0]): eltsbefore+=len(groups[i])-1 x=eltsbefore+gslice[1]; return [x-1,x+gslice[2]-1]
module function_definition identifier parameters identifier identifier block expression_statement string string_start string_content string_end expression_statement string string_start string_content string_end expression_statement assignment identifier integer for_statement identifier call identifier argument_list subscript identifier integer block expression_statement augmented_assignment identifier binary_operator call identifier argument_list subscript identifier identifier integer expression_statement assignment identifier binary_operator identifier subscript identifier integer return_statement list binary_operator identifier integer binary_operator binary_operator identifier subscript identifier integer integer
this is a helper for contigsub.
def _get_enum(self, source, bitarray): raw_value = self._get_raw(source, bitarray) value_desc = source.find('item', {'value': str(raw_value)}) or self._get_rangeitem(source, raw_value) return { source['shortcut']: { 'description': source.get('description'), 'unit': source.get('unit', ''), 'value': value_desc['description'].format(value=raw_value), 'raw_value': raw_value, } }
module function_definition identifier parameters identifier identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier boolean_operator call attribute identifier identifier argument_list string string_start string_content string_end dictionary pair string string_start string_content string_end call identifier argument_list identifier call attribute identifier identifier argument_list identifier identifier return_statement dictionary pair subscript identifier string string_start string_content string_end dictionary pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end pair string string_start string_content string_end call attribute identifier identifier argument_list string string_start string_content string_end string string_start string_end pair string string_start string_content string_end call attribute subscript identifier string string_start string_content string_end identifier argument_list keyword_argument identifier identifier pair string string_start string_content string_end identifier
Get enum value, based on the data in XML
def resize(self, new_size): if new_size == len(self): return else: self._saved = LimitedSizeDict(size_limit=2**5) new_arr = zeros(new_size, dtype=self.dtype) if len(self) <= new_size: new_arr[0:len(self)] = self else: new_arr[:] = self[0:new_size] self._data = new_arr._data
module function_definition identifier parameters identifier identifier block if_statement comparison_operator identifier call identifier argument_list identifier block return_statement else_clause block expression_statement assignment attribute identifier identifier call identifier argument_list keyword_argument identifier binary_operator integer integer expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier attribute identifier identifier if_statement comparison_operator call identifier argument_list identifier identifier block expression_statement assignment subscript identifier slice integer call identifier argument_list identifier identifier else_clause block expression_statement assignment subscript identifier slice subscript identifier slice integer identifier expression_statement assignment attribute identifier identifier attribute identifier identifier
Resize self to new_size
def warn_on_deprecated_args(self, args): if getattr(args, "private", None) is not None and \ (os.path.exists(os.path.join(args.private, "setup.py")) or os.path.exists(os.path.join(args.private, "pyproject.toml")) ): if not getattr(args, "use_setup_py", False) and \ not getattr(args, "ignore_setup_py", False): warning(" **** FUTURE BEHAVIOR CHANGE WARNING ****") warning("Your project appears to contain a setup.py file.") warning("Currently, these are ignored by default.") warning("This will CHANGE in an upcoming version!") warning("") warning("To ensure your setup.py is ignored, please specify:") warning(" --ignore-setup-py") warning("") warning("To enable what will some day be the default, specify:") warning(" --use-setup-py") if args.ndk_version is not None: warning('--ndk-version is deprecated and no longer necessary, ' 'the value you passed is ignored') if 'ANDROIDNDKVER' in environ: warning('$ANDROIDNDKVER is deprecated and no longer necessary, ' 'the value you set is ignored')
module function_definition identifier parameters identifier identifier block if_statement boolean_operator comparison_operator call identifier argument_list identifier string string_start string_content string_end none none line_continuation parenthesized_expression boolean_operator 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 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 block if_statement boolean_operator not_operator call identifier argument_list identifier string string_start string_content string_end false line_continuation not_operator call identifier argument_list identifier string string_start string_content string_end false block expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_end expression_statement call identifier argument_list string string_start string_content string_end expression_statement call identifier argument_list string string_start string_content string_end if_statement comparison_operator attribute identifier identifier none block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator string string_start string_content string_end identifier block expression_statement call identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content string_end
Print warning messages for any deprecated arguments that were passed.
def hash(self): h = hash_pandas_object(self, index=True) return hashlib.md5(h.values.tobytes()).hexdigest()
module function_definition identifier parameters identifier block expression_statement assignment identifier call identifier argument_list identifier keyword_argument identifier true return_statement call attribute call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier argument_list
Generate a hash value.
def delete(self): res = self.rest_client.session.delete(self.rest_self) _handle_http_errors(res)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute attribute attribute identifier identifier identifier identifier argument_list attribute identifier identifier expression_statement call identifier argument_list identifier
Delete this application configuration.
def decompress(self, value): if value: return [value.get(field.name, None) for field in self.fields] return [field.field.initial for field in self.fields]
module function_definition identifier parameters identifier identifier block if_statement identifier block return_statement list_comprehension call attribute identifier identifier argument_list attribute identifier identifier none for_in_clause identifier attribute identifier identifier return_statement list_comprehension attribute attribute identifier identifier identifier for_in_clause identifier attribute identifier identifier
Retreieve each field value or provide the initial values
def storage(self): annotation = self.get_annotation() if annotation.get(ATTACHMENTS_STORAGE) is None: annotation[ATTACHMENTS_STORAGE] = OOBTree() return annotation[ATTACHMENTS_STORAGE]
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator call attribute identifier identifier argument_list identifier none block expression_statement assignment subscript identifier identifier call identifier argument_list return_statement subscript identifier identifier
A storage which keeps configuration settings for attachments
def fullName(self): if self.parentName and self.name: return self.parentName + '_' + self.name return self.name or self.parentName
module function_definition identifier parameters identifier block if_statement boolean_operator attribute identifier identifier attribute identifier identifier block return_statement binary_operator binary_operator attribute identifier identifier string string_start string_content string_end attribute identifier identifier return_statement boolean_operator attribute identifier identifier attribute identifier identifier
A full name, intended to uniquely identify a parameter
def __insert_frond_RF(d_w, d_u, dfs_data): dfs_data['RF'].append( (d_w, d_u) ) dfs_data['FG']['r'] += 1 dfs_data['last_inserted_side'] = 'RF'
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute subscript identifier string string_start string_content string_end identifier argument_list tuple identifier identifier expression_statement augmented_assignment subscript subscript identifier string string_start string_content string_end string string_start string_content string_end integer expression_statement assignment subscript identifier string string_start string_content string_end string string_start string_content string_end
Encapsulates the process of inserting a frond uw into the right side frond group.
def _create_tc_dirs(self): tc_log_path = self.profile.get('args', {}).get('tc_log_path') if tc_log_path is not None and not os.path.isdir(tc_log_path): os.makedirs(tc_log_path) tc_out_path = self.profile.get('args', {}).get('tc_out_path') if tc_out_path is not None and not os.path.isdir(tc_out_path): os.makedirs(tc_out_path) tc_tmp_path = self.profile.get('args', {}).get('tc_tmp_path') if tc_tmp_path is not None and not os.path.isdir(tc_tmp_path): os.makedirs(tc_tmp_path)
module function_definition identifier parameters identifier block expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end if_statement boolean_operator comparison_operator identifier none not_operator call attribute attribute identifier identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier
Create app directories for logs and data files.
def write(self, learn:Learner, trn_batch:Tuple, val_batch:Tuple, iteration:int, tbwriter:SummaryWriter)->None: "Writes training and validation batch images to Tensorboard." self._write_for_dstype(learn=learn, batch=val_batch, iteration=iteration, tbwriter=tbwriter, ds_type=DatasetType.Valid) self._write_for_dstype(learn=learn, batch=trn_batch, iteration=iteration, tbwriter=tbwriter, ds_type=DatasetType.Train)
module function_definition identifier parameters identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier typed_parameter identifier type identifier type none block expression_statement string string_start string_content string_end expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier identifier keyword_argument identifier attribute identifier identifier
Writes training and validation batch images to Tensorboard.
def _is_at_ref_end(self, nucmer_hit): hit_coords = nucmer_hit.ref_coords() return hit_coords.end >= nucmer_hit.ref_length - self.ref_end_tolerance
module function_definition identifier parameters identifier identifier block expression_statement assignment identifier call attribute identifier identifier argument_list return_statement comparison_operator attribute identifier identifier binary_operator attribute identifier identifier attribute identifier identifier
Returns True iff the hit is "close enough" to the end of the reference sequence
def validate(self): if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if self.location.field: raise ValueError(u'Expected location to point to a vertex, ' u'but found a field: {}'.format(self.location))
module function_definition identifier parameters identifier block if_statement not_operator call identifier argument_list attribute identifier identifier identifier block raise_statement call identifier argument_list call attribute string string_start string_content string_end identifier argument_list attribute call identifier argument_list attribute identifier identifier identifier attribute identifier identifier if_statement attribute attribute identifier identifier identifier block raise_statement call identifier argument_list call attribute concatenated_string string string_start string_content string_end string string_start string_content string_end identifier argument_list attribute identifier identifier
Validate that the ContextFieldExistence is correctly representable.
def saltpath(): salt_path = os.path.abspath(os.path.join(__file__, os.path.pardir)) return {'saltpath': os.path.dirname(salt_path)}
module function_definition identifier parameters block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier attribute attribute identifier identifier identifier return_statement dictionary pair string string_start string_content string_end call attribute attribute identifier identifier identifier argument_list identifier
Return the path of the salt module
def find_min_required(path): found_min_required = '' for filename in glob.glob(os.path.join(path, '*.tf')): with open(filename, 'r') as stream: tf_config = hcl.load(stream) if tf_config.get('terraform', {}).get('required_version'): found_min_required = tf_config.get('terraform', {}).get('required_version') break if found_min_required: if re.match(r'^!=.+', found_min_required): LOGGER.error('Min required Terraform version is a negation (%s) ' '- unable to determine required version', found_min_required) sys.exit(1) else: found_min_required = re.search(r'[0-9]*\.[0-9]*(?:\.[0-9]*)?', found_min_required).group(0) LOGGER.debug("Detected minimum terraform version is %s", found_min_required) return found_min_required LOGGER.error('Terraform version specified as min-required, but unable to ' 'find a specified version requirement in this module\'s tf ' 'files') sys.exit(1)
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end for_statement identifier call attribute identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier string string_start string_content string_end block with_statement with_clause with_item as_pattern call identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block expression_statement assignment identifier call attribute identifier identifier argument_list identifier if_statement call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end dictionary identifier argument_list string string_start string_content string_end break_statement if_statement identifier block if_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier block expression_statement call attribute identifier identifier argument_list 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 integer else_clause block expression_statement assignment identifier call attribute call attribute identifier identifier argument_list string string_start string_content string_end identifier identifier argument_list integer expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier return_statement identifier expression_statement call attribute identifier identifier argument_list concatenated_string string string_start string_content string_end string string_start string_content escape_sequence string_end string string_start string_content string_end expression_statement call attribute identifier identifier argument_list integer
Inspect terraform files and find minimum version.
def _service_heartbeat_if_due(self): due = False if self._service_registry: if not hasattr(self, "status_info"): due = True else: d = doublethink.utcnow() - self.status_info["last_heartbeat"] due = d.total_seconds() > self.HEARTBEAT_INTERVAL if due: self._service_heartbeat()
module function_definition identifier parameters identifier block expression_statement assignment identifier false if_statement attribute identifier identifier block if_statement not_operator call identifier argument_list identifier string string_start string_content string_end block expression_statement assignment identifier true else_clause block expression_statement assignment identifier binary_operator call attribute identifier identifier argument_list subscript attribute identifier identifier string string_start string_content string_end expression_statement assignment identifier comparison_operator call attribute identifier identifier argument_list attribute identifier identifier if_statement identifier block expression_statement call attribute identifier identifier argument_list
Sends service registry heartbeat if due
def _escapeText(text): output = "" index = 0 match = reCharsToEscape.search(text, index) while match: output = output + text[index:match.start()] + '\\' + text[match.start()] index = match.end() match = reCharsToEscape.search(text, index) output = output + text[index:] return output
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_end expression_statement assignment identifier integer expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier while_statement identifier block expression_statement assignment identifier binary_operator binary_operator binary_operator identifier subscript identifier slice identifier call attribute identifier identifier argument_list string string_start string_content escape_sequence string_end subscript identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier binary_operator identifier subscript identifier slice identifier return_statement identifier
Adds backslash-escapes to property value characters that need them.
def sub_split_values(self, sub): for i, arr in enumerate(self.splits): self.split_map[i] = [sub.get(x, x) for x in arr] for split in self.surrogates: split.sub_split_values(sub)
module function_definition identifier parameters identifier identifier block for_statement pattern_list identifier identifier call identifier argument_list attribute identifier identifier block expression_statement assignment subscript attribute identifier identifier identifier list_comprehension call attribute identifier identifier argument_list identifier identifier for_in_clause identifier identifier for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list identifier
Substitutes the splits with other values into the split_map
def rollback(self): self._state_machine.transition_to_rollback() for action in reversed(self._executed_actions): try: self.execute_with_retries(action, lambda a: a.rollback()) except: pass self._state_machine.transition_to_rollback_complete()
module function_definition identifier parameters identifier block expression_statement call attribute attribute identifier identifier identifier argument_list for_statement identifier call identifier argument_list attribute identifier identifier block try_statement block expression_statement call attribute identifier identifier argument_list identifier lambda lambda_parameters identifier call attribute identifier identifier argument_list except_clause block pass_statement expression_statement call attribute attribute identifier identifier identifier argument_list
Call rollback on executed actions.
def _eta_from_phi(self): self.eta = scipy.ndarray(N_NT - 1, dtype='float') etaprod = 1.0 for w in range(N_NT - 1): self.eta[w] = 1.0 - self.phi[w] / etaprod etaprod *= self.eta[w] _checkParam('eta', self.eta, self.PARAMLIMITS, self.PARAMTYPES)
module function_definition identifier parameters identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list binary_operator identifier integer keyword_argument identifier string string_start string_content string_end expression_statement assignment identifier float for_statement identifier call identifier argument_list binary_operator identifier integer block expression_statement assignment subscript attribute identifier identifier identifier binary_operator float binary_operator subscript attribute identifier identifier identifier identifier expression_statement augmented_assignment identifier subscript attribute identifier identifier identifier expression_statement call identifier argument_list string string_start string_content string_end attribute identifier identifier attribute identifier identifier attribute identifier identifier
Update `eta` using current `phi`.
def as_data_frame(self) -> pandas.DataFrame: header_gene = {} header_multiplex = {} headr_transitions = {} for gene in self.influence_graph.genes: header_gene[gene] = repr(gene) header_multiplex[gene] = f"active multiplex on {gene!r}" headr_transitions[gene] = f"K_{gene!r}" columns = defaultdict(list) for state in self.table.keys(): for gene in self.influence_graph.genes: columns[header_gene[gene]].append(state[gene]) columns[header_multiplex[gene]].append(self._repr_multiplexes(gene, state)) columns[headr_transitions[gene]].append(self._repr_transition(gene, state)) header = list(header_gene.values()) + list(header_multiplex.values()) + list(headr_transitions.values()) return pandas.DataFrame(columns, columns=header)
module function_definition identifier parameters identifier type attribute identifier identifier block expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary expression_statement assignment identifier dictionary for_statement identifier attribute attribute identifier identifier identifier block expression_statement assignment subscript identifier identifier call identifier argument_list identifier expression_statement assignment subscript identifier identifier string string_start string_content interpolation identifier type_conversion string_end expression_statement assignment subscript identifier identifier string string_start string_content interpolation identifier type_conversion string_end expression_statement assignment identifier call identifier argument_list identifier for_statement identifier call attribute attribute identifier identifier identifier argument_list block for_statement identifier attribute attribute identifier identifier identifier block expression_statement call attribute subscript identifier subscript identifier identifier identifier argument_list subscript identifier identifier expression_statement call attribute subscript identifier subscript identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement call attribute subscript identifier subscript identifier identifier identifier argument_list call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier binary_operator binary_operator call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list call identifier argument_list call attribute identifier identifier argument_list return_statement call attribute identifier identifier argument_list identifier keyword_argument identifier identifier
Create a panda DataFrame representation of the resource table.
def Publish(self, request, context): LOG.debug("Publish called") try: self.plugin.publish( [Metric(pb=m) for m in request.Metrics], ConfigMap(pb=request.Config) ) return ErrReply() except Exception as err: msg = "message: {}\n\nstack trace: {}".format( err, traceback.format_exc()) return ErrReply(error=msg)
module function_definition identifier parameters identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end try_statement block expression_statement call attribute attribute identifier identifier identifier argument_list list_comprehension call identifier argument_list keyword_argument identifier identifier for_in_clause identifier attribute identifier identifier call identifier argument_list keyword_argument identifier attribute identifier identifier return_statement call identifier argument_list except_clause as_pattern identifier as_pattern_target identifier block expression_statement assignment identifier call attribute string string_start string_content escape_sequence escape_sequence string_end identifier argument_list identifier call attribute identifier identifier argument_list return_statement call identifier argument_list keyword_argument identifier identifier
Dispatches the request to the plugins publish method
def log_error(self, error, message, detail=None, strip=4): "Add an error message and optional user message to the error list" if message: msg = message + ": " + error else: msg = error tb = traceback.format_stack() if sys.version_info >= (3, 0): tb = tb[:-strip] else: tb = tb[strip:] self.errors.append({ 'message': msg, 'traceback': tb, 'detail': detail })
module function_definition identifier parameters identifier identifier identifier default_parameter identifier none default_parameter identifier integer block expression_statement string string_start string_content string_end if_statement identifier block expression_statement assignment identifier binary_operator binary_operator identifier string string_start string_content string_end identifier else_clause block expression_statement assignment identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list if_statement comparison_operator attribute identifier identifier tuple integer integer block expression_statement assignment identifier subscript identifier slice unary_operator identifier else_clause block expression_statement assignment identifier subscript identifier slice identifier expression_statement call attribute attribute identifier 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
Add an error message and optional user message to the error list
def base36encode(number): ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz" base36 = '' sign = '' if number < 0: sign = '-' number = -number if 0 <= number < len(ALPHABET): return sign + ALPHABET[number] while number != 0: number, i = divmod(number, len(ALPHABET)) base36 = ALPHABET[i] + base36 return sign + base36
module function_definition identifier parameters identifier block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier string string_start string_end expression_statement assignment identifier string string_start string_end if_statement comparison_operator identifier integer block expression_statement assignment identifier string string_start string_content string_end expression_statement assignment identifier unary_operator identifier if_statement comparison_operator integer identifier call identifier argument_list identifier block return_statement binary_operator identifier subscript identifier identifier while_statement comparison_operator identifier integer block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier call identifier argument_list identifier expression_statement assignment identifier binary_operator subscript identifier identifier identifier return_statement binary_operator identifier identifier
Converts an integer into a base36 string.
def dataframe(self, dtype=False, parse_dates=True, *args, **kwargs): import pandas as pd rg = self.row_generator t = self.resolved_url.get_resource().get_target() if t.target_format == 'csv': return self.read_csv(dtype, parse_dates, *args, **kwargs) try: return rg.dataframe( *args, **kwargs) except AttributeError: pass headers = next(islice(self, 0, 1)) data = islice(self, 1, None) df = pd.DataFrame(list(data), columns=headers, *args, **kwargs) self.errors = df.metatab_errors = rg.errors if hasattr(rg, 'errors') and rg.errors else {} return df
module function_definition identifier parameters identifier default_parameter identifier false default_parameter identifier true list_splat_pattern identifier dictionary_splat_pattern identifier block import_statement aliased_import dotted_name identifier identifier expression_statement assignment identifier attribute identifier identifier expression_statement assignment identifier call attribute call attribute attribute identifier identifier identifier argument_list identifier argument_list if_statement comparison_operator attribute identifier identifier string string_start string_content string_end block return_statement call attribute identifier identifier argument_list identifier identifier list_splat identifier dictionary_splat identifier try_statement block return_statement call attribute identifier identifier argument_list list_splat identifier dictionary_splat identifier except_clause identifier block pass_statement expression_statement assignment identifier call identifier argument_list call identifier argument_list identifier integer integer expression_statement assignment identifier call identifier argument_list identifier integer none expression_statement assignment identifier call attribute identifier identifier argument_list call identifier argument_list identifier keyword_argument identifier identifier list_splat identifier dictionary_splat identifier expression_statement assignment attribute identifier identifier assignment attribute identifier identifier conditional_expression attribute identifier identifier boolean_operator call identifier argument_list identifier string string_start string_content string_end attribute identifier identifier dictionary return_statement identifier
Return a pandas datafrome from the resource
def cfg_lldp_interface(self, protocol_interface, phy_interface=None): if phy_interface is None: phy_interface = protocol_interface self.create_attr_obj(protocol_interface, phy_interface) ret = self.pub_lldp.enable_lldp(protocol_interface) attr_obj = self.get_attr_obj(protocol_interface) attr_obj.update_lldp_status(ret)
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block expression_statement assignment identifier identifier expression_statement call attribute identifier identifier argument_list identifier identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier
Cfg LLDP on interface and create object.
def __NormalizeStartEnd(self, start, end=None): if end is not None: if start < 0: raise exceptions.TransferInvalidError( 'Cannot have end index with negative start index ' + '[start=%d, end=%d]' % (start, end)) elif start >= self.total_size: raise exceptions.TransferInvalidError( 'Cannot have start index greater than total size ' + '[start=%d, total_size=%d]' % (start, self.total_size)) end = min(end, self.total_size - 1) if end < start: raise exceptions.TransferInvalidError( 'Range requested with end[%s] < start[%s]' % (end, start)) return start, end else: if start < 0: start = max(0, start + self.total_size) return start, self.total_size - 1
module function_definition identifier parameters identifier identifier default_parameter identifier none block if_statement comparison_operator identifier none block if_statement comparison_operator identifier integer block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier identifier elif_clause comparison_operator identifier attribute identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end binary_operator string string_start string_content string_end tuple identifier attribute identifier identifier expression_statement assignment identifier call identifier argument_list identifier binary_operator attribute identifier identifier integer if_statement comparison_operator identifier identifier block raise_statement call attribute identifier identifier argument_list binary_operator string string_start string_content string_end tuple identifier identifier return_statement expression_list identifier identifier else_clause block if_statement comparison_operator identifier integer block expression_statement assignment identifier call identifier argument_list integer binary_operator identifier attribute identifier identifier return_statement expression_list identifier binary_operator attribute identifier identifier integer
Normalizes start and end values based on total size.
def ping(self, timeout=0, **kwargs): def rand_id(size=8, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) payload = rand_id() self.ws.ping(payload) opcode, data = self.recv_raw(timeout, [websocket.ABNF.OPCODE_PONG], **kwargs) if data != payload: raise IOError("Pinged server but did not receive correct pong")
module function_definition identifier parameters identifier default_parameter identifier integer dictionary_splat_pattern identifier block function_definition identifier parameters default_parameter identifier integer default_parameter identifier binary_operator attribute identifier identifier attribute identifier identifier block return_statement call attribute string string_start string_end identifier generator_expression call attribute identifier identifier argument_list identifier for_in_clause identifier call identifier argument_list identifier expression_statement assignment identifier call identifier argument_list expression_statement call attribute attribute identifier identifier identifier argument_list identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier list attribute attribute identifier identifier identifier dictionary_splat identifier if_statement comparison_operator identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end
THIS DOES NOT WORK, UWSGI DOES NOT RESPOND TO PINGS
def cost_zerg_corrected(self) -> "Cost": if self.race == Race.Zerg and Attribute.Structure.value in self.attributes: return Cost( self._proto.mineral_cost - 50, self._proto.vespene_cost, self._proto.build_time ) else: return self.cost
module function_definition identifier parameters identifier type string string_start string_content string_end block if_statement boolean_operator comparison_operator attribute identifier identifier attribute identifier identifier comparison_operator attribute attribute identifier identifier identifier attribute identifier identifier block return_statement call identifier argument_list binary_operator attribute attribute identifier identifier identifier integer attribute attribute identifier identifier identifier attribute attribute identifier identifier identifier else_clause block return_statement attribute identifier identifier
This returns 25 for extractor and 200 for spawning pool instead of 75 and 250 respectively
def remove(in_bam): if utils.file_exists(in_bam): utils.remove_safe(in_bam) if utils.file_exists(in_bam + ".bai"): utils.remove_safe(in_bam + ".bai")
module function_definition identifier parameters identifier block if_statement call attribute identifier identifier argument_list identifier block expression_statement call attribute identifier identifier argument_list identifier if_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end block expression_statement call attribute identifier identifier argument_list binary_operator identifier string string_start string_content string_end
remove bam file and the index if exists
def location(self) -> Optional[PostLocation]: loc = self._field("location") if self._location or not loc: return self._location location_id = int(loc['id']) if any(k not in loc for k in ('name', 'slug', 'has_public_page', 'lat', 'lng')): loc = self._context.get_json("explore/locations/{0}/".format(location_id), params={'__a': 1})['graphql']['location'] self._location = PostLocation(location_id, loc['name'], loc['slug'], loc['has_public_page'], loc['lat'], loc['lng']) return self._location
module function_definition identifier parameters identifier type generic_type identifier type_parameter type identifier block expression_statement assignment identifier call attribute identifier identifier argument_list string string_start string_content string_end if_statement boolean_operator attribute identifier identifier not_operator identifier block return_statement attribute identifier identifier expression_statement assignment identifier call identifier argument_list subscript identifier string string_start string_content string_end if_statement call identifier generator_expression comparison_operator identifier identifier for_in_clause identifier tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end block expression_statement assignment identifier subscript subscript call attribute attribute identifier identifier identifier argument_list call attribute string string_start string_content string_end identifier argument_list identifier keyword_argument identifier dictionary pair string string_start string_content string_end integer string string_start string_content string_end string string_start string_content string_end expression_statement assignment attribute identifier identifier call identifier argument_list identifier subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end subscript identifier string string_start string_content string_end return_statement attribute identifier identifier
If the Post has a location, returns PostLocation namedtuple with fields 'id', 'lat' and 'lng' and 'name'.
def normalize_date_format(date_str, default_time="00:00:00"): ret_code, ret_data = check_date_str_format(date_str, default_time) if ret_code != RET_OK: return ret_code, ret_data return RET_OK, ret_data.strftime("%Y-%m-%d %H:%M:%S")
module function_definition identifier parameters identifier default_parameter identifier string string_start string_content string_end block expression_statement assignment pattern_list identifier identifier call identifier argument_list identifier identifier if_statement comparison_operator identifier identifier block return_statement expression_list identifier identifier return_statement expression_list identifier call attribute identifier identifier argument_list string string_start string_content string_end
normalize the format of data
def compile(self, node, *args, **kwargs): if isinstance(node, WhereNode): return where_node_as_ldap(node, self, self.connection) return super(SQLCompiler, self).compile(node, *args, **kwargs)
module function_definition identifier parameters identifier identifier list_splat_pattern identifier dictionary_splat_pattern identifier block if_statement call identifier argument_list identifier identifier block return_statement call identifier argument_list identifier identifier attribute identifier identifier return_statement call attribute call identifier argument_list identifier identifier identifier argument_list identifier list_splat identifier dictionary_splat identifier
Parse a WhereNode to a LDAP filter string.
def subscribe(self, id, name, port): sub = gntp.core.GNTPSubscribe() sub.add_header('Subscriber-ID', id) sub.add_header('Subscriber-Name', name) sub.add_header('Subscriber-Port', port) if self.password: sub.set_password(self.password, self.passwordHash) self.add_origin_info(sub) self.subscribe_hook(sub) return self._send('subscribe', sub)
module function_definition identifier parameters identifier identifier identifier identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier if_statement attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier attribute identifier identifier expression_statement call attribute identifier identifier argument_list identifier expression_statement call attribute identifier identifier argument_list identifier return_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier
Send a Subscribe request to a remote machine
def _get_prtflds(self): ntflds = self.gosubdag.prt_attr['flds'] prt_flds = self.kws.get('prt_flds') if prt_flds: return prt_flds.intersection(ntflds) exclude = set() if self.gosubdag.relationships: exclude.add('level') return set(f for f in ntflds if f not in exclude)
module function_definition identifier parameters identifier block expression_statement assignment identifier subscript attribute attribute identifier identifier identifier string string_start string_content string_end expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list string string_start string_content string_end if_statement identifier block return_statement call attribute identifier identifier argument_list identifier expression_statement assignment identifier call identifier argument_list if_statement attribute attribute identifier identifier identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end return_statement call identifier generator_expression identifier for_in_clause identifier identifier if_clause comparison_operator identifier identifier
Get print fields for GO header.
def _create_binary_mathfunction(name, doc=""): def _(col1, col2): sc = SparkContext._active_spark_context if isinstance(col1, Column): arg1 = col1._jc elif isinstance(col1, basestring): arg1 = _create_column_from_name(col1) else: arg1 = float(col1) if isinstance(col2, Column): arg2 = col2._jc elif isinstance(col2, basestring): arg2 = _create_column_from_name(col2) else: arg2 = float(col2) jc = getattr(sc._jvm.functions, name)(arg1, arg2) return Column(jc) _.__name__ = name _.__doc__ = doc return _
module function_definition identifier parameters identifier default_parameter identifier string string_start string_end block function_definition identifier parameters identifier identifier block expression_statement assignment identifier attribute identifier identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier if_statement call identifier argument_list identifier identifier block expression_statement assignment identifier attribute identifier identifier elif_clause call identifier argument_list identifier identifier block expression_statement assignment identifier call identifier argument_list identifier else_clause block expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call call identifier argument_list attribute attribute identifier identifier identifier identifier argument_list identifier identifier return_statement call identifier argument_list identifier expression_statement assignment attribute identifier identifier identifier expression_statement assignment attribute identifier identifier identifier return_statement identifier
Create a binary mathfunction by name
def compose_capability(base, *classes): if _debug: compose_capability._debug("compose_capability %r %r", base, classes) if not issubclass(base, Collector): raise TypeError("base must be a subclass of Collector") for cls in classes: if not issubclass(cls, Capability): raise TypeError("%s is not a Capability subclass" % (cls,)) bases = (base,) + classes name = base.__name__ for cls in classes: name += '+' + cls.__name__ return type(name, bases, {})
module function_definition identifier parameters identifier list_splat_pattern identifier block if_statement identifier block expression_statement call attribute identifier identifier argument_list string string_start string_content string_end identifier 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 for_statement identifier identifier block if_statement not_operator call identifier argument_list identifier identifier block raise_statement call identifier argument_list binary_operator string string_start string_content string_end tuple identifier expression_statement assignment identifier binary_operator tuple identifier identifier expression_statement assignment identifier attribute identifier identifier for_statement identifier identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end attribute identifier identifier return_statement call identifier argument_list identifier identifier dictionary
Create a new class starting with the base and adding capabilities.
def _evaluate(self): if not self.__retrieved: self._elements = self._retrieve_revisions() self.__retrieved = True return super(RevisionCursor, self)._evaluate()
module function_definition identifier parameters identifier block if_statement not_operator attribute identifier identifier block expression_statement assignment attribute identifier identifier call attribute identifier identifier argument_list expression_statement assignment attribute identifier identifier true return_statement call attribute call identifier argument_list identifier identifier identifier argument_list
Lazily retrieves, caches, and returns the list of record _revisions
def comp_listing(request, directory_slug=None): context = {} working_dir = settings.COMPS_DIR if directory_slug: working_dir = os.path.join(working_dir, directory_slug) dirnames = [] templates = [] items = os.listdir(working_dir) templates = [x for x in items if os.path.splitext(x)[1] == '.html'] dirnames = [x for x in items if \ not os.path.isfile(os.path.join(working_dir, x))] templates.sort() dirnames.sort() context['directories'] = dirnames context['templates'] = templates context['subdirectory'] = directory_slug return render(request, "comps/comp_listing.html", context)
module function_definition identifier parameters identifier default_parameter identifier none block expression_statement assignment identifier dictionary expression_statement assignment identifier attribute identifier identifier if_statement identifier block expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement assignment identifier list expression_statement assignment identifier list expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause comparison_operator subscript call attribute attribute identifier identifier identifier argument_list identifier integer string string_start string_content string_end expression_statement assignment identifier list_comprehension identifier for_in_clause identifier identifier if_clause line_continuation not_operator call attribute attribute identifier identifier identifier argument_list call attribute attribute identifier identifier identifier argument_list identifier identifier expression_statement call attribute identifier identifier argument_list expression_statement call attribute identifier identifier argument_list expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier expression_statement assignment subscript identifier string string_start string_content string_end identifier return_statement call identifier argument_list identifier string string_start string_content string_end identifier
Output the list of HTML templates and subdirectories in the COMPS_DIR
def add_function(self, func): for block in func.blocks: self.add_obj(block.addr, block)
module function_definition identifier parameters identifier identifier block for_statement identifier attribute identifier identifier block expression_statement call attribute identifier identifier argument_list attribute identifier identifier identifier
Add a function `func` and all blocks of this function to the blanket.
def _find(self, spec): if spec.template_path is not None: return spec.template_path dir_path, file_name = self._find_relative(spec) locator = self.loader._make_locator() if dir_path is None: path = locator.find_object(spec, self.loader.search_dirs, file_name=file_name) else: obj_dir = locator.get_object_directory(spec) path = os.path.join(obj_dir, dir_path, file_name) return path
module function_definition identifier parameters identifier identifier block if_statement comparison_operator attribute identifier identifier none block return_statement attribute identifier identifier expression_statement assignment pattern_list identifier identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list if_statement comparison_operator identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute attribute identifier identifier identifier keyword_argument identifier identifier else_clause block expression_statement assignment identifier call attribute identifier identifier argument_list identifier expression_statement assignment identifier call attribute attribute identifier identifier identifier argument_list identifier identifier identifier return_statement identifier
Find and return the path to the template associated to the instance.
def download_gcs_file(path, out_fname=None, prefix_filter=None): url = posixpath.join(GCS_BUCKET, path) if prefix_filter: url += "?prefix=%s" % prefix_filter stream = bool(out_fname) resp = requests.get(url, stream=stream) if not resp.ok: raise ValueError("GCS bucket inaccessible") if out_fname: with tf.io.gfile.GFile(out_fname, "wb") as f: for chunk in resp.iter_content(1024): f.write(chunk) else: return resp.content
module function_definition identifier parameters identifier default_parameter identifier none default_parameter identifier none block expression_statement assignment identifier call attribute identifier identifier argument_list identifier identifier if_statement identifier block expression_statement augmented_assignment identifier binary_operator string string_start string_content string_end identifier expression_statement assignment identifier call identifier argument_list identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier keyword_argument identifier identifier if_statement not_operator attribute identifier identifier block raise_statement call identifier argument_list string string_start string_content string_end if_statement identifier block with_statement with_clause with_item as_pattern call attribute attribute attribute identifier identifier identifier identifier argument_list identifier string string_start string_content string_end as_pattern_target identifier block for_statement identifier call attribute identifier identifier argument_list integer block expression_statement call attribute identifier identifier argument_list identifier else_clause block return_statement attribute identifier identifier
Download a file from GCS, optionally to a file.
def usn_v4_record(header, record): length, major_version, minor_version = header fields = V4_RECORD.unpack_from(record, RECORD_HEADER.size) raise NotImplementedError('Not implemented')
module function_definition identifier parameters identifier identifier block expression_statement assignment pattern_list identifier identifier identifier identifier expression_statement assignment identifier call attribute identifier identifier argument_list identifier attribute identifier identifier raise_statement call identifier argument_list string string_start string_content string_end
Extracts USN V4 record information.
def completedefault(self, text, line, *_): tokens = line.split() try: before = tokens[-2] complete = before.lower() in ("from", "update", "table", "into") if tokens[0].lower() == "dump": complete = True if complete: return [ t + " " for t in self.engine.cached_descriptions if t.startswith(text) ] except KeyError: pass
module function_definition identifier parameters identifier identifier identifier list_splat_pattern identifier block expression_statement assignment identifier call attribute identifier identifier argument_list try_statement block expression_statement assignment identifier subscript identifier unary_operator integer expression_statement assignment identifier comparison_operator call attribute identifier identifier argument_list tuple string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end string string_start string_content string_end if_statement comparison_operator call attribute subscript identifier integer identifier argument_list string string_start string_content string_end block expression_statement assignment identifier true if_statement identifier block return_statement list_comprehension binary_operator identifier string string_start string_content string_end for_in_clause identifier attribute attribute identifier identifier identifier if_clause call attribute identifier identifier argument_list identifier except_clause identifier block pass_statement
Autocomplete table names in queries
def _round(num): deci = num - math.floor(num) if deci > 0.8: return int(math.floor(num) + 1) else: return int(math.floor(num))
module function_definition identifier parameters identifier block expression_statement assignment identifier binary_operator identifier call attribute identifier identifier argument_list identifier if_statement comparison_operator identifier float block return_statement call identifier argument_list binary_operator call attribute identifier identifier argument_list identifier integer else_clause block return_statement call identifier argument_list call attribute identifier identifier argument_list identifier
A custom rounding function that's a bit more 'strict'.