text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
def get_cli(cls) -> click.Group: """Add a :mod:`click` main function to use as a command line interface.""" main = super().get_cli() cls._cli_add_flask(main) return main
[ "def", "get_cli", "(", "cls", ")", "->", "click", ".", "Group", ":", "main", "=", "super", "(", ")", ".", "get_cli", "(", ")", "cls", ".", "_cli_add_flask", "(", "main", ")", "return", "main" ]
28.285714
0.014706
def next(self, record, curInputBookmark): """ Return the next aggregated record, if any Parameters: ------------------------------------------------------------------------ record: The input record (values only) from the input source, or None if the input has reached EOF (th...
[ "def", "next", "(", "self", ",", "record", ",", "curInputBookmark", ")", ":", "# This will hold the aggregated record we return", "outRecord", "=", "None", "# This will hold the bookmark of the last input used within the", "# aggregated record we return.", "retInputBookmark", "=",...
34.133663
0.01212
def get_order(self): """ Return a list of dicionaries. See `set_order`. """ return [dict(reverse=r[0], key=r[1]) for r in self.get_model()]
[ "def", "get_order", "(", "self", ")", ":", "return", "[", "dict", "(", "reverse", "=", "r", "[", "0", "]", ",", "key", "=", "r", "[", "1", "]", ")", "for", "r", "in", "self", ".", "get_model", "(", ")", "]" ]
33.4
0.011696
def quit_banner(self) -> None: """ Print a banner for running the system """ print("=" * 80) print("Done.") print(dtm.datetime.now().strftime("%Y/%m/%d - %H:%M:%S")) print("=" * 80)
[ "def", "quit_banner", "(", "self", ")", "->", "None", ":", "print", "(", "\"=\"", "*", "80", ")", "print", "(", "\"Done.\"", ")", "print", "(", "dtm", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%Y/%m/%d - %H:%M:%S\"", ")", ")", "...
36
0.00905
def make_confidence_report(filepath, train_start=TRAIN_START, train_end=TRAIN_END, test_start=TEST_START, test_end=TEST_END, batch_size=BATCH_SIZE, which_set=WHICH_SET, mc_batch_size=MC_BATCH_SIZE, ...
[ "def", "make_confidence_report", "(", "filepath", ",", "train_start", "=", "TRAIN_START", ",", "train_end", "=", "TRAIN_END", ",", "test_start", "=", "TEST_START", ",", "test_end", "=", "TEST_END", ",", "batch_size", "=", "BATCH_SIZE", ",", "which_set", "=", "WH...
37.007576
0.009769
def __replace_nouns(sentence, counts): """Lets find and replace all instances of #NOUN :param _sentence: :param counts: """ if sentence is not None: while sentence.find('#NOUN') != -1: sentence = sentence.replace('#NOUN', str(__get_noun(counts)), 1) if sentence.find...
[ "def", "__replace_nouns", "(", "sentence", ",", "counts", ")", ":", "if", "sentence", "is", "not", "None", ":", "while", "sentence", ".", "find", "(", "'#NOUN'", ")", "!=", "-", "1", ":", "sentence", "=", "sentence", ".", "replace", "(", "'#NOUN'", ","...
25.75
0.002342
def get_correlated_report_ids(self, indicators): """ DEPRECATED! Retrieves a list of the IDs of all TruSTAR reports that contain the searched indicators. :param indicators: A list of indicator values to retrieve correlated reports for. :return: The list of IDs of reports that co...
[ "def", "get_correlated_report_ids", "(", "self", ",", "indicators", ")", ":", "params", "=", "{", "'indicators'", ":", "indicators", "}", "resp", "=", "self", ".", "_client", ".", "get", "(", "\"reports/correlate\"", ",", "params", "=", "params", ")", "retur...
38.111111
0.008535
def savePkeyPem(self, pkey, path): ''' Save a private key in PEM format to a file outside the certdir. ''' with s_common.genfile(path) as fd: fd.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey))
[ "def", "savePkeyPem", "(", "self", ",", "pkey", ",", "path", ")", ":", "with", "s_common", ".", "genfile", "(", "path", ")", "as", "fd", ":", "fd", ".", "write", "(", "crypto", ".", "dump_privatekey", "(", "crypto", ".", "FILETYPE_PEM", ",", "pkey", ...
40
0.008163
def _update_network_adapters(interface_old_new, parent): ''' Returns a list of vim.vm.device.VirtualDeviceSpec specifying configuration(s) for changed network adapters, the adapter type cannot be changed, as input the old and new configs are defined in a dictionary. interface_old_new Dictio...
[ "def", "_update_network_adapters", "(", "interface_old_new", ",", "parent", ")", ":", "network_changes", "=", "[", "]", "if", "interface_old_new", ":", "devs", "=", "[", "inter", "[", "'old'", "]", "[", "'mac'", "]", "for", "inter", "in", "interface_old_new", ...
44.948718
0.000558
def parse_style(document, xmlcontent): """Parse styles document. Styles are defined in file 'styles.xml'. """ styles = etree.fromstring(xmlcontent) _r = styles.xpath('.//w:rPrDefault', namespaces=NAMESPACES) if len(_r) > 0: rpr = _r[0].find(_name('{{{w}}}rPr')) if rpr is not...
[ "def", "parse_style", "(", "document", ",", "xmlcontent", ")", ":", "styles", "=", "etree", ".", "fromstring", "(", "xmlcontent", ")", "_r", "=", "styles", ".", "xpath", "(", "'.//w:rPrDefault'", ",", "namespaces", "=", "NAMESPACES", ")", "if", "len", "(",...
28.839286
0.000599
def _batch_json_to_instances(self, json_dicts: List[JsonDict]) -> List[Instance]: """ Converts a list of JSON objects into a list of :class:`~allennlp.data.instance.Instance`s. By default, this expects that a "batch" consists of a list of JSON blobs which would individually be predicted ...
[ "def", "_batch_json_to_instances", "(", "self", ",", "json_dicts", ":", "List", "[", "JsonDict", "]", ")", "->", "List", "[", "Instance", "]", ":", "instances", "=", "[", "]", "for", "json_dict", "in", "json_dicts", ":", "instances", ".", "append", "(", ...
56.230769
0.010767
def imagetransformer_b10l_4h_big_uncond_dr03_lr025_tpu(): """TPU related small model.""" hparams = imagetransformer_bas8l_8h_big_uncond_dr03_imgnet() update_hparams_for_tpu(hparams) hparams.batch_size = 4 hparams.num_heads = 4 # heads are expensive on tpu hparams.num_decoder_layers = 10 hparams.learning...
[ "def", "imagetransformer_b10l_4h_big_uncond_dr03_lr025_tpu", "(", ")", ":", "hparams", "=", "imagetransformer_bas8l_8h_big_uncond_dr03_imgnet", "(", ")", "update_hparams_for_tpu", "(", "hparams", ")", "hparams", ".", "batch_size", "=", "4", "hparams", ".", "num_heads", "=...
38.769231
0.025194
def densitybin(x, weight=None, binwidth=None, bins=None, rangee=None): """ Do density binning It does not collapse each bin with a count. Parameters ---------- x : array-like Numbers to bin weight : array-like Weights binwidth : numeric Size of the bins rang...
[ "def", "densitybin", "(", "x", ",", "weight", "=", "None", ",", "binwidth", "=", "None", ",", "bins", "=", "None", ",", "rangee", "=", "None", ")", ":", "if", "all", "(", "pd", ".", "isnull", "(", "x", ")", ")", ":", "return", "pd", ".", "DataF...
24.6875
0.000609
def on_resize(width, height): """Setup 3D projection""" glViewport(0, 0, width, height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(30, 1.0*width/height, 0.1, 1000.0) glMatrixMode(GL_MODELVIEW) glLoadIdentity()
[ "def", "on_resize", "(", "width", ",", "height", ")", ":", "glViewport", "(", "0", ",", "0", ",", "width", ",", "height", ")", "glMatrixMode", "(", "GL_PROJECTION", ")", "glLoadIdentity", "(", ")", "gluPerspective", "(", "30", ",", "1.0", "*", "width", ...
28.25
0.034335
def template_scheduler_yaml(cl_args, masters): ''' Template scheduler.yaml ''' single_master = masters[0] scheduler_config_actual = "%s/standalone/scheduler.yaml" % cl_args["config_path"] scheduler_config_template = "%s/standalone/templates/scheduler.template.yaml" \ % cl_args...
[ "def", "template_scheduler_yaml", "(", "cl_args", ",", "masters", ")", ":", "single_master", "=", "masters", "[", "0", "]", "scheduler_config_actual", "=", "\"%s/standalone/scheduler.yaml\"", "%", "cl_args", "[", "\"config_path\"", "]", "scheduler_config_template", "=",...
42.181818
0.016878
def packs(self): """List all (currently?) available packs.""" method = 'GET' url = 'store/purchaseGroup/cardpack' params = {'ppInfo': True} return self.__request__(method, url, params=params)
[ "def", "packs", "(", "self", ")", ":", "method", "=", "'GET'", "url", "=", "'store/purchaseGroup/cardpack'", "params", "=", "{", "'ppInfo'", ":", "True", "}", "return", "self", ".", "__request__", "(", "method", ",", "url", ",", "params", "=", "params", ...
32.285714
0.008621
def CV(self, days=45): """ Coefficient of Variation. 計算 days 日內之變異數,預設 45 日 """ if len(self.raw_data) >= days: data_avg = sum(self.raw_data[-days:]) / days return self.SD / data_avg else: return 0
[ "def", "CV", "(", "self", ",", "days", "=", "45", ")", ":", "if", "len", "(", "self", ".", "raw_data", ")", ">=", "days", ":", "data_avg", "=", "sum", "(", "self", ".", "raw_data", "[", "-", "days", ":", "]", ")", "/", "days", "return", "self",...
25.555556
0.016807
def toggle(self, index, n_cols=70): """ Toggle the state of the object at the given index. If it is a comment, pack it into a hidden comment. If it is a hidden comment, unpack it. If it is more comments, load the comments. """ data = self.get(index) if d...
[ "def", "toggle", "(", "self", ",", "index", ",", "n_cols", "=", "70", ")", ":", "data", "=", "self", ".", "get", "(", "index", ")", "if", "data", "[", "'type'", "]", "==", "'Submission'", ":", "# Can't hide the submission!", "pass", "elif", "data", "["...
34.571429
0.001148
def _bson_to_dict(data, opts): """Decode a BSON string to document_class.""" try: if _raw_document_class(opts.document_class): return opts.document_class(data, opts) _, end = _get_object_size(data, 0, len(data)) return _elements_to_dict(data, 4, end, opts) except InvalidB...
[ "def", "_bson_to_dict", "(", "data", ",", "opts", ")", ":", "try", ":", "if", "_raw_document_class", "(", "opts", ".", "document_class", ")", ":", "return", "opts", ".", "document_class", "(", "data", ",", "opts", ")", "_", ",", "end", "=", "_get_object_...
39.461538
0.001905
def get_qc_tools(data): """Retrieve a list of QC tools to use based on configuration and analysis type. Uses defaults if previously set. """ if dd.get_algorithm_qc(data): return dd.get_algorithm_qc(data) analysis = data["analysis"].lower() to_run = [] if tz.get_in(["config", "algori...
[ "def", "get_qc_tools", "(", "data", ")", ":", "if", "dd", ".", "get_algorithm_qc", "(", "data", ")", ":", "return", "dd", ".", "get_algorithm_qc", "(", "data", ")", "analysis", "=", "data", "[", "\"analysis\"", "]", ".", "lower", "(", ")", "to_run", "=...
39.695652
0.001069
def create(rawmessage): """Return an INSTEON message class based on a raw byte stream.""" rawmessage = _trim_buffer_garbage(rawmessage) if len(rawmessage) < 2: return (None, rawmessage) code = rawmessage[1] msgclass = _get_msg_class(code) msg = None remaining_data = rawmessage ...
[ "def", "create", "(", "rawmessage", ")", ":", "rawmessage", "=", "_trim_buffer_garbage", "(", "rawmessage", ")", "if", "len", "(", "rawmessage", ")", "<", "2", ":", "return", "(", "None", ",", "rawmessage", ")", "code", "=", "rawmessage", "[", "1", "]", ...
34.645161
0.000906
def init_run_context(self, raw=False): """ Sets the log context. """ self.raw = raw self._set_context(self)
[ "def", "init_run_context", "(", "self", ",", "raw", "=", "False", ")", ":", "self", ".", "raw", "=", "raw", "self", ".", "_set_context", "(", "self", ")" ]
23.666667
0.013605
def Input_dispatchMouseEvent(self, type, x, y, **kwargs): """ Function path: Input.dispatchMouseEvent Domain: Input Method name: dispatchMouseEvent Parameters: Required arguments: 'type' (type: string) -> Type of the mouse event. 'x' (type: number) -> X coordinate of the event relative to ...
[ "def", "Input_dispatchMouseEvent", "(", "self", ",", "type", ",", "x", ",", "y", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "type", ",", "(", "str", ",", ")", ")", ",", "\"Argument 'type' must be of type '['str']'. Received type: '%s'\"", ...
51.135593
0.035122
def Then5(self, f, arg1, arg2, arg3, arg4, *args, **kwargs): """ `Then5(f, ...)` is equivalent to `ThenAt(5, f, ...)`. Checkout `phi.builder.Builder.ThenAt` for more information. """ args = (arg1, arg2, arg3, arg4) + args return self.ThenAt(5, f, *args, **kwargs)
[ "def", "Then5", "(", "self", ",", "f", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args", "=", "(", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ")", "+", "args", "return", "self...
48.333333
0.010169
def allow_request(self, request, view): """ Throttle POST requests only. """ if request.method != 'POST': return True return super(PostRequestThrottleMixin, self).allow_request(request, view)
[ "def", "allow_request", "(", "self", ",", "request", ",", "view", ")", ":", "if", "request", ".", "method", "!=", "'POST'", ":", "return", "True", "return", "super", "(", "PostRequestThrottleMixin", ",", "self", ")", ".", "allow_request", "(", "request", "...
29.625
0.012295
def to_json_str(self): """Convert data to json string representation. Returns: json representation as string. """ _json = self.to_json() try: return json.dumps(_json, sort_keys=True, cls=JsonEncoder) except: logging.exception("Could not serialize JSON: %r", _json) raise
[ "def", "to_json_str", "(", "self", ")", ":", "_json", "=", "self", ".", "to_json", "(", ")", "try", ":", "return", "json", ".", "dumps", "(", "_json", ",", "sort_keys", "=", "True", ",", "cls", "=", "JsonEncoder", ")", "except", ":", "logging", ".", ...
25.666667
0.015674
def flush(self): """flush any buffered messages""" buf = self.buf self.buf = [] if buf: self._flush(buf)
[ "def", "flush", "(", "self", ")", ":", "buf", "=", "self", ".", "buf", "self", ".", "buf", "=", "[", "]", "if", "buf", ":", "self", ".", "_flush", "(", "buf", ")" ]
23.833333
0.013514
def env(): """Verify BOARD variables and construct exported variables""" if cij.ssh.env(): cij.err("board.env: invalid SSH environment") return 1 board = cij.env_to_dict(PREFIX, REQUIRED) # Verify REQUIRED variables if board is None: cij.err("board.env: invalid BOARD environm...
[ "def", "env", "(", ")", ":", "if", "cij", ".", "ssh", ".", "env", "(", ")", ":", "cij", ".", "err", "(", "\"board.env: invalid SSH environment\"", ")", "return", "1", "board", "=", "cij", ".", "env_to_dict", "(", "PREFIX", ",", "REQUIRED", ")", "# Veri...
30.333333
0.001776
def execute(self, triple_map, output, **kwargs): """Execute """ subjects = [] if NS_MGR.ql.JSON.rdflib in \ triple_map.logicalSource.reference_formulations: output_format = "json" else: output_format = "xml" if 'limit' not in kwargs: ...
[ "def", "execute", "(", "self", ",", "triple_map", ",", "output", ",", "*", "*", "kwargs", ")", ":", "subjects", "=", "[", "]", "if", "NS_MGR", ".", "ql", ".", "JSON", ".", "rdflib", "in", "triple_map", ".", "logicalSource", ".", "reference_formulations",...
46.02521
0.002145
def write_output(self): """Write all stored output data to storage.""" for data in self.output_data.values(): self.create_output(data.get('key'), data.get('value'), data.get('type'))
[ "def", "write_output", "(", "self", ")", ":", "for", "data", "in", "self", ".", "output_data", ".", "values", "(", ")", ":", "self", ".", "create_output", "(", "data", ".", "get", "(", "'key'", ")", ",", "data", ".", "get", "(", "'value'", ")", ","...
51.75
0.014286
def upgradeProcessor1to2(oldProcessor): """ Batch processors stopped polling at version 2, so they no longer needed the idleInterval attribute. They also gained a scheduled attribute which tracks their interaction with the scheduler. Since they stopped polling, we also set them up as a timed event...
[ "def", "upgradeProcessor1to2", "(", "oldProcessor", ")", ":", "newProcessor", "=", "oldProcessor", ".", "upgradeVersion", "(", "oldProcessor", ".", "typeName", ",", "1", ",", "2", ",", "busyInterval", "=", "oldProcessor", ".", "busyInterval", ")", "newProcessor", ...
39.636364
0.000746
def convert(model, name=None, initial_types=None, doc_string='', target_opset=None, targeted_onnx=onnx.__version__, custom_conversion_functions=None, custom_shape_calculators=None): """ :param model: a libsvm model :param initial_types: a python list. Each element is a tuple of a variable name a...
[ "def", "convert", "(", "model", ",", "name", "=", "None", ",", "initial_types", "=", "None", ",", "doc_string", "=", "''", ",", "target_opset", "=", "None", ",", "targeted_onnx", "=", "onnx", ".", "__version__", ",", "custom_conversion_functions", "=", "None...
56.875
0.008104
def is_hidden(path): """ Check whether a file is presumed hidden, either because the pathname starts with dot or because the platform indicates such. """ full_path = os.path.abspath(path) name = os.path.basename(full_path) def no(path): return False platform_hidden = globals().get('is_hidden_' + ...
[ "def", "is_hidden", "(", "path", ")", ":", "full_path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "name", "=", "os", ".", "path", ".", "basename", "(", "full_path", ")", "def", "no", "(", "path", ")", ":", "return", "False", "platfo...
30
0.029851
def upgrade_defaults(self): """Upgrade config file and reload. """ self.defaults.upgrade() self.reset_defaults(self.defaults.filename)
[ "def", "upgrade_defaults", "(", "self", ")", ":", "self", ".", "defaults", ".", "upgrade", "(", ")", "self", ".", "reset_defaults", "(", "self", ".", "defaults", ".", "filename", ")" ]
32.4
0.012048
def loads(content): """Load a Procfile from a string.""" lines = _group_lines(line for line in content.split('\n')) lines = [ (i, _parse_procfile_line(line)) for i, line in lines if line.strip() ] errors = [] # Reject files with duplicate process types (no sane default). dupl...
[ "def", "loads", "(", "content", ")", ":", "lines", "=", "_group_lines", "(", "line", "for", "line", "in", "content", ".", "split", "(", "'\\n'", ")", ")", "lines", "=", "[", "(", "i", ",", "_parse_procfile_line", "(", "line", ")", ")", "for", "i", ...
39.266667
0.000829
def reverse(view, *args, **kwargs): ''' User-friendly reverse. Pass arguments and keyword arguments to Django's `reverse` as `args` and `kwargs` arguments, respectively. The special optional keyword argument `query` is a dictionary of query (or GET) parameters that can be appended to the `reverse`d URL. Example...
[ "def", "reverse", "(", "view", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'query'", "in", "kwargs", ":", "query", "=", "kwargs", ".", "pop", "(", "'query'", ")", "else", ":", "query", "=", "None", "base", "=", "urlresolvers", ".", ...
27.884615
0.036
def get_profile_data(study_id, gene_list, profile_filter, case_set_filter=None): """Return dict of cases and genes and their respective values. Parameters ---------- study_id : str The ID of the cBio study. Example: 'cellline_ccle_broad' or 'paad_icgc' gene_list...
[ "def", "get_profile_data", "(", "study_id", ",", "gene_list", ",", "profile_filter", ",", "case_set_filter", "=", "None", ")", ":", "genetic_profiles", "=", "get_genetic_profiles", "(", "study_id", ",", "profile_filter", ")", "if", "genetic_profiles", ":", "genetic_...
36.482759
0.00046
def map_keys_deep(f, dct): """ Implementation of map that recurses. This tests the same keys at every level of dict and in lists :param f: 2-ary function expecting a key and value and returns a modified key :param dct: Dict for deep processing :return: Modified dct with matching props mapped """...
[ "def", "map_keys_deep", "(", "f", ",", "dct", ")", ":", "return", "_map_deep", "(", "lambda", "k", ",", "v", ":", "[", "f", "(", "k", ",", "v", ")", ",", "v", "]", ",", "dct", ")" ]
45.75
0.008043
def apply_chromatic_adaptation(val_x, val_y, val_z, orig_illum, targ_illum, observer='2', adaptation='bradford'): """ Applies a chromatic adaptation matrix to convert XYZ values between illuminants. It is important to recognize that color transformation results in color er...
[ "def", "apply_chromatic_adaptation", "(", "val_x", ",", "val_y", ",", "val_z", ",", "orig_illum", ",", "targ_illum", ",", "observer", "=", "'2'", ",", "adaptation", "=", "'bradford'", ")", ":", "# It's silly to have to do this, but some people may want to call this", "#...
43.860465
0.001556
def files(self): """ A list of input sources. Each item can be a file path, a glob path or URL. """ # If no files but a recursion option ==> use the current directory if not self.args.files and self.recursive: return ['.'] else: return self.args.fi...
[ "def", "files", "(", "self", ")", ":", "# If no files but a recursion option ==> use the current directory", "if", "not", "self", ".", "args", ".", "files", "and", "self", ".", "recursive", ":", "return", "[", "'.'", "]", "else", ":", "return", "self", ".", "a...
35
0.009288
def setVisible(self, state): """ Sets whether or not this toolbar is visible. If shown, it will rebuild. :param state | <bool> """ super(XDockToolbar, self).setVisible(state) if state: self.rebuild() self.setCurren...
[ "def", "setVisible", "(", "self", ",", "state", ")", ":", "super", "(", "XDockToolbar", ",", "self", ")", ".", "setVisible", "(", "state", ")", "if", "state", ":", "self", ".", "rebuild", "(", ")", "self", ".", "setCurrentAction", "(", "None", ")" ]
29.363636
0.015015
def tagsInString_process(self, d_DICOM, astr, *args, **kwargs): """ This method substitutes DICOM tags that are '%'-tagged in a string template with the actual tag lookup. For example, an output filename that is specified as the following string: %PatientAge-%Patien...
[ "def", "tagsInString_process", "(", "self", ",", "d_DICOM", ",", "astr", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "b_tagsFound", "=", "False", "str_replace", "=", "''", "# The lookup/processed tag value", "l_tags", "=", "[", "]", "# The input strin...
44.516854
0.009877
def from_file(cls, xml_path): """Parse .xml file and create a XmlParser object.""" try: parsed_xml = cls._parse(xml_path) except OSError as e: raise XmlParser.XmlError("Problem reading xml file at {}: {}".format(xml_path, e)) return cls(xml_path, parsed_xml)
[ "def", "from_file", "(", "cls", ",", "xml_path", ")", ":", "try", ":", "parsed_xml", "=", "cls", ".", "_parse", "(", "xml_path", ")", "except", "OSError", "as", "e", ":", "raise", "XmlParser", ".", "XmlError", "(", "\"Problem reading xml file at {}: {}\"", "...
40
0.013986
def render_to_string(template, extra=None): """ Renders the given template to a string. """ from jinja2 import Template extra = extra or {} final_fqfn = find_template(template) assert final_fqfn, 'Template not found: %s' % template template_content = open(final_fqfn, 'r').read() t = ...
[ "def", "render_to_string", "(", "template", ",", "extra", "=", "None", ")", ":", "from", "jinja2", "import", "Template", "extra", "=", "extra", "or", "{", "}", "final_fqfn", "=", "find_template", "(", "template", ")", "assert", "final_fqfn", ",", "'Template ...
31.555556
0.001709
def build_standard_field(self, field_name, model_field): """ Create regular model fields. """ field_mapping = ClassLookupDict(self.serializer_field_mapping) field_class = field_mapping[model_field] field_kwargs = get_field_kwargs(field_name, model_field) if 'cho...
[ "def", "build_standard_field", "(", "self", ",", "field_name", ",", "model_field", ")", ":", "field_mapping", "=", "ClassLookupDict", "(", "self", ".", "serializer_field_mapping", ")", "field_class", "=", "field_mapping", "[", "model_field", "]", "field_kwargs", "="...
46.021277
0.002263
def GetForwardedIps(self, interface, interface_ip=None): """Retrieve the list of configured forwarded IP addresses. Args: interface: string, the output device to query. interface_ip: string, current interface ip address. Returns: list, the IP address strings. """ try: ips =...
[ "def", "GetForwardedIps", "(", "self", ",", "interface", ",", "interface_ip", "=", "None", ")", ":", "try", ":", "ips", "=", "netifaces", ".", "ifaddresses", "(", "interface", ")", "ips", "=", "ips", "[", "netifaces", ".", "AF_INET", "]", "except", "(", ...
32.428571
0.008559
def xpathVariableLookupNS(self, name, ns_uri): """Search in the Variable array of the context for the given variable value. """ ret = libxml2mod.xmlXPathVariableLookupNS(self._o, name, ns_uri) if ret is None:raise xpathError('xmlXPathVariableLookupNS() failed') return xpathObj...
[ "def", "xpathVariableLookupNS", "(", "self", ",", "name", ",", "ns_uri", ")", ":", "ret", "=", "libxml2mod", ".", "xmlXPathVariableLookupNS", "(", "self", ".", "_o", ",", "name", ",", "ns_uri", ")", "if", "ret", "is", "None", ":", "raise", "xpathError", ...
54.333333
0.012085
def drop(self, ex): "helper for apply_sql in DropX case" # todo: factor out inheritance logic (for readability) if ex.name not in self: if ex.ifexists: return raise KeyError(ex.name) table_ = self[ex.name] parent = table_.parent_table if table_.child_tables: if not ex....
[ "def", "drop", "(", "self", ",", "ex", ")", ":", "# todo: factor out inheritance logic (for readability)\r", "if", "ex", ".", "name", "not", "in", "self", ":", "if", "ex", ".", "ifexists", ":", "return", "raise", "KeyError", "(", "ex", ".", "name", ")", "t...
36.285714
0.017274
def reverb(self, reverberance=50, high_freq_damping=50, room_scale=100, stereo_depth=100, pre_delay=0, wet_gain=0, wet_only=False): '''Add reverberation to the audio using the ‘freeverb’ algorithm. A reverberation effect is sometimes desirable for concert halls that are too small ...
[ "def", "reverb", "(", "self", ",", "reverberance", "=", "50", ",", "high_freq_damping", "=", "50", ",", "room_scale", "=", "100", ",", "stereo_depth", "=", "100", ",", "pre_delay", "=", "0", ",", "wet_gain", "=", "0", ",", "wet_only", "=", "False", ")"...
35.567568
0.001109
def update(pkg, slot=None, fromrepo=None, refresh=False, binhost=None, **kwargs): ''' .. versionchanged:: 2015.8.12,2016.3.3,2016.11.0 On minions running systemd>=205, `systemd-run(1)`_ is now used to isolate commands which modify installed packages from the ``salt-minion`` daemon's cont...
[ "def", "update", "(", "pkg", ",", "slot", "=", "None", ",", "fromrepo", "=", "None", ",", "refresh", "=", "False", ",", "binhost", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "salt", ".", "utils", ".", "data", ".", "is_true", "(", "refr...
34.010989
0.001884
def _get_name_and_version(name, version, for_filename=False): """Return the distribution name with version. If for_filename is true, return a filename-escaped form.""" if for_filename: # For both name and version any runs of non-alphanumeric or '.' # characters are replaced with a single '-...
[ "def", "_get_name_and_version", "(", "name", ",", "version", ",", "for_filename", "=", "False", ")", ":", "if", "for_filename", ":", "# For both name and version any runs of non-alphanumeric or '.'", "# characters are replaced with a single '-'. Additionally any", "# spaces in the...
47.363636
0.001883
def update_w_custom(config, lane_info): """Update the configuration for this lane if a custom analysis is specified. """ name_remaps = {"variant": ["SNP calling", "variant", "variant2"], "SNP calling": ["SNP calling", "variant", "variant2"], "variant2": ["SNP calling", ...
[ "def", "update_w_custom", "(", "config", ",", "lane_info", ")", ":", "name_remaps", "=", "{", "\"variant\"", ":", "[", "\"SNP calling\"", ",", "\"variant\"", ",", "\"variant2\"", "]", ",", "\"SNP calling\"", ":", "[", "\"SNP calling\"", ",", "\"variant\"", ",", ...
47.16
0.001663
def apply(self, func, args=(), **kwargs): """Apply a function over each Dataset in the group and concatenate them together into a new Dataset. `func` is called like `func(ds, *args, **kwargs)` for each dataset `ds` in this group. Apply uses heuristics (like `pandas.GroupBy.appl...
[ "def", "apply", "(", "self", ",", "func", ",", "args", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "pop", "(", "'shortcut'", ",", "None", ")", "# ignore shortcut if set (for now)", "applied", "=", "(", "func", "(", "ds", ",", "*"...
41.09375
0.001486
def load_conditions(self) -> None: """Save the initial conditions of the |Model| object handled by each |Element| object.""" for element in printtools.progressbar(self): element.model.sequences.load_conditions()
[ "def", "load_conditions", "(", "self", ")", "->", "None", ":", "for", "element", "in", "printtools", ".", "progressbar", "(", "self", ")", ":", "element", ".", "model", ".", "sequences", ".", "load_conditions", "(", ")" ]
48.6
0.008097
def delete_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE): """Delete the rdataset matching I{rdtype} and I{covers}, if it exists at the node specified by I{name}. The I{name}, I{rdtype}, and I{covers} parameters may be strings, in which case they will be converted to their prop...
[ "def", "delete_rdataset", "(", "self", ",", "name", ",", "rdtype", ",", "covers", "=", "dns", ".", "rdatatype", ".", "NONE", ")", ":", "name", "=", "self", ".", "_validate_name", "(", "name", ")", "if", "isinstance", "(", "rdtype", ",", "(", "str", "...
38.71875
0.002362
def _palette_cmd(self, event): """Respond to user click on a palette item.""" label = event.widget label.master.focus_set() label.master.configure(relief="sunken") r, g, b = self.winfo_rgb(label.cget("background")) r = round2(r * 255 / 65535) g = round2(g * 255 / ...
[ "def", "_palette_cmd", "(", "self", ",", "event", ")", ":", "label", "=", "event", ".", "widget", "label", ".", "master", ".", "focus_set", "(", ")", "label", ".", "master", ".", "configure", "(", "relief", "=", "\"sunken\"", ")", "r", ",", "g", ",",...
33.074074
0.002176
def run_query(self, cmd="", **kwargs): """ Remote Popen (actually execute the Spark-sql query) :param cmd: command to remotely execute :param kwargs: extra arguments to Popen (see subprocess.Popen) """ spark_sql_cmd = self._prepare_command(cmd) self._sp = subproc...
[ "def", "run_query", "(", "self", ",", "cmd", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "spark_sql_cmd", "=", "self", ".", "_prepare_command", "(", "cmd", ")", "self", ".", "_sp", "=", "subprocess", ".", "Popen", "(", "spark_sql_cmd", ",", "stdout...
34.791667
0.002331
def _GetMetadataRequest(self, metadata_url, params=None, timeout=None): """Performs a GET request with the metadata headers. Args: metadata_url: string, the URL to perform a GET request on. params: dictionary, the query parameters in the GET request. timeout: int, timeout in seconds for metad...
[ "def", "_GetMetadataRequest", "(", "self", ",", "metadata_url", ",", "params", "=", "None", ",", "timeout", "=", "None", ")", ":", "headers", "=", "{", "'Metadata-Flavor'", ":", "'Google'", "}", "params", "=", "urlparse", ".", "urlencode", "(", "params", "...
38.666667
0.001202
def definition(keyword, key=None): """Given a keyword and a key (optional), try to get a definition dict for it. .. versionadded:: 3.2 Definition dicts are defined in keywords.py. We try to return one if present, otherwise we return none. Using this method you can present rich metadata to the ...
[ "def", "definition", "(", "keyword", ",", "key", "=", "None", ")", ":", "for", "item", "in", "dir", "(", "definitions", ")", ":", "if", "not", "item", ".", "startswith", "(", "\"__\"", ")", ":", "var", "=", "getattr", "(", "definitions", ",", "item",...
30.484848
0.000963
def _make_write_pb(table, columns, values): """Helper for :meth:`Batch.insert` et aliae. :type table: str :param table: Name of the table to be modified. :type columns: list of str :param columns: Name of the table columns to be modified. :type values: list of lists :param values: Values ...
[ "def", "_make_write_pb", "(", "table", ",", "columns", ",", "values", ")", ":", "return", "Mutation", ".", "Write", "(", "table", "=", "table", ",", "columns", "=", "columns", ",", "values", "=", "_make_list_value_pbs", "(", "values", ")", ")" ]
30.111111
0.001789
def connectDb(engine = dbeng, user = dbuser, password = dbpwd, host = dbhost, port = dbport, database = dbname, params = "?charset=utf8&use_unicode=1", echoopt = False): """Connect to database utility ...
[ "def", "connectDb", "(", "engine", "=", "dbeng", ",", "user", "=", "dbuser", ",", "password", "=", "dbpwd", ",", "host", "=", "dbhost", ",", "port", "=", "dbport", ",", "database", "=", "dbname", ",", "params", "=", "\"?charset=utf8&use_unicode=1\"", ",", ...
35.133333
0.044362
def ply_ascii(elements, file_obj): """ Load data from an ASCII PLY file into an existing elements data structure. Parameters ------------ elements: OrderedDict object, populated from the file header. object will be modified to add data by this function. file_obj: open file object...
[ "def", "ply_ascii", "(", "elements", ",", "file_obj", ")", ":", "# get the file contents as a string", "text", "=", "str", "(", "file_obj", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", ")", "# split by newlines", "lines", "=", "str", ".", "spli...
34.396825
0.000449
def map_(function, *structures, **kwargs): # pylint: disable=differing-param-doc,missing-param-doc """Apply a function to every element in a nested structure. If multiple structures are provided as input, their structure must match and the function will be applied to corresponding groups of elements. The neste...
[ "def", "map_", "(", "function", ",", "*", "structures", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=differing-param-doc,missing-param-doc", "# Named keyword arguments are not allowed after *args in Python 2.", "flatten", "=", "kwargs", ".", "pop", "(", "'flatten'"...
41.326087
0.00925
def renderForSignal(self, stm: Union[HdlStatement, List[HdlStatement]], s: RtlSignalBase, connectOut) -> Optional[Tuple[LNode, Union[RtlSignalBase, LPort]]]: """ Walk statement and render nodes which are representing hardware components (MUX, LATCH...
[ "def", "renderForSignal", "(", "self", ",", "stm", ":", "Union", "[", "HdlStatement", ",", "List", "[", "HdlStatement", "]", "]", ",", "s", ":", "RtlSignalBase", ",", "connectOut", ")", "->", "Optional", "[", "Tuple", "[", "LNode", ",", "Union", "[", "...
37.607595
0.00164
def is_published(self): """stub""" if 'published' not in self.my_osid_object._my_map: return False return bool(self.my_osid_object._my_map['published'])
[ "def", "is_published", "(", "self", ")", ":", "if", "'published'", "not", "in", "self", ".", "my_osid_object", ".", "_my_map", ":", "return", "False", "return", "bool", "(", "self", ".", "my_osid_object", ".", "_my_map", "[", "'published'", "]", ")" ]
36.8
0.010638
def serialize_data(data, compression=False, encryption=False, public_key=None): """Serializes normal Python datatypes into plaintext using json. You may also choose to enable compression and encryption when serializing data to send over the network. Enabling one or both of these options will incur addi...
[ "def", "serialize_data", "(", "data", ",", "compression", "=", "False", ",", "encryption", "=", "False", ",", "public_key", "=", "None", ")", ":", "message", "=", "json", ".", "dumps", "(", "data", ")", "if", "compression", ":", "message", "=", "zlib", ...
32.636364
0.000902
def estimate_voc(photocurrent, saturation_current, nNsVth): """ Rough estimate of open circuit voltage useful for bounding searches for ``i`` of ``v`` when using :func:`~pvlib.pvsystem.singlediode`. Parameters ---------- photocurrent : numeric photo-generated current [A] saturation_...
[ "def", "estimate_voc", "(", "photocurrent", ",", "saturation_current", ",", "nNsVth", ")", ":", "return", "nNsVth", "*", "np", ".", "log", "(", "np", ".", "asarray", "(", "photocurrent", ")", "/", "saturation_current", "+", "1.0", ")" ]
32.388889
0.000833
def send_command(self, command, immediate=False, timeout=1.0, max_retries=0, eor=('\n', '\n- ')): """ Sends a single command to the drive and returns output. Takes a single given `command`, sanitizes it, sends it to the drive, reads the response, and returns the processed r...
[ "def", "send_command", "(", "self", ",", "command", ",", "immediate", "=", "False", ",", "timeout", "=", "1.0", ",", "max_retries", "=", "0", ",", "eor", "=", "(", "'\\n'", ",", "'\\n- '", ")", ")", ":", "# Execute the command till it either doesn't have an er...
43.592593
0.000623
async def run_jog(data): """ Allow the user to jog the selected pipette around the deck map :param data: Information obtained from a POST request. The content type is application/json The correct packet form should be as follows: { 'token': UUID token from current session start 'com...
[ "async", "def", "run_jog", "(", "data", ")", ":", "axis", "=", "data", ".", "get", "(", "'axis'", ")", "direction", "=", "data", ".", "get", "(", "'direction'", ")", "step", "=", "data", ".", "get", "(", "'step'", ")", "if", "axis", "not", "in", ...
30.261905
0.000762
def upgrade_file(path, multipoint): """Upgrade to the latest NRML version""" node0 = nrml.read(path, chatty=False)[0] shutil.copy(path, path + '.bak') # make a backup of the original file tag = striptag(node0.tag) gml = True if tag == 'vulnerabilityModel': vf_dict, cat_dict = get_vulner...
[ "def", "upgrade_file", "(", "path", ",", "multipoint", ")", ":", "node0", "=", "nrml", ".", "read", "(", "path", ",", "chatty", "=", "False", ")", "[", "0", "]", "shutil", ".", "copy", "(", "path", ",", "path", "+", "'.bak'", ")", "# make a backup of...
43.535714
0.000803
def get_events_by_tripI_and_dsut(self, trip_I, day_start_ut, start_ut=None, end_ut=None): """ Get trip data as a list of events (i.e. dicts). Parameters ---------- trip_I : int shorthand index of the trip. day_start_ut : i...
[ "def", "get_events_by_tripI_and_dsut", "(", "self", ",", "trip_I", ",", "day_start_ut", ",", "start_ut", "=", "None", ",", "end_ut", "=", "None", ")", ":", "# for checking input:", "assert", "day_start_ut", "<=", "start_ut", "assert", "day_start_ut", "<=", "end_ut...
35.774194
0.001316
def refresh(self): '''Refetch instance data from the API. ''' response = requests.get('%s/media/images/%s' % (API_BASE_URL, self.id)) attributes = response.json() #self.exif = attributes['exif'] self.height = attributes['height'] self.width = attributes['width'] #s...
[ "def", "refresh", "(", "self", ")", ":", "response", "=", "requests", ".", "get", "(", "'%s/media/images/%s'", "%", "(", "API_BASE_URL", ",", "self", ".", "id", ")", ")", "attributes", "=", "response", ".", "json", "(", ")", "#self.exif = attributes['exif']"...
37.15
0.031496
def jackknife_connectivity(measures, data, var, nfft=512, leaveout=1, n_jobs=1, verbose=0): """Calculate jackknife estimates of connectivity. For each jackknife estimate a block of trials is left out. This is repeated until each trial was left out exactly once. The number of esti...
[ "def", "jackknife_connectivity", "(", "measures", ",", "data", ",", "var", ",", "nfft", "=", "512", ",", "leaveout", "=", "1", ",", "n_jobs", "=", "1", ",", "verbose", "=", "0", ")", ":", "data", "=", "atleast_3d", "(", "data", ")", "t", ",", "m", ...
39.719298
0.001293
def files(xscript=0, yscript=1, eyscript=None, exscript=None, g=None, plotter=xy_databoxes, paths=None, **kwargs): """ This will load a bunch of data files, generate data based on the supplied scripts, and then plot this data using the specified databox plotter. xscript, yscript, eyscript, exscript ...
[ "def", "files", "(", "xscript", "=", "0", ",", "yscript", "=", "1", ",", "eyscript", "=", "None", ",", "exscript", "=", "None", ",", "g", "=", "None", ",", "plotter", "=", "xy_databoxes", ",", "paths", "=", "None", ",", "*", "*", "kwargs", ")", "...
40.964286
0.010221
def transacted(func): """ Return a callable which will invoke C{func} in a transaction using the C{store} attribute of the first parameter passed to it. Typically this is used to create Item methods which are automatically run in a transaction. The attributes of the returned callable will resemble...
[ "def", "transacted", "(", "func", ")", ":", "def", "transactionified", "(", "item", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "return", "item", ".", "store", ".", "transact", "(", "func", ",", "item", ",", "*", "a", ",", "*", "*", "kw", ")"...
47.333333
0.001727
def _router_removed(self, router_id, deconfigure=True): """Operations when a router is removed. Get the RouterInfo object corresponding to the router in the service helpers's router_info dict. If deconfigure is set to True, remove this router's configuration from the hosting device. ...
[ "def", "_router_removed", "(", "self", ",", "router_id", ",", "deconfigure", "=", "True", ")", ":", "ri", "=", "self", ".", "router_info", ".", "get", "(", "router_id", ")", "if", "ri", "is", "None", ":", "LOG", ".", "warning", "(", "\"Info for router %s...
51.703704
0.000703
def all_casings(input_string): """ Permute all casings of a given string. A pretty algorithm, via @Amber http://stackoverflow.com/questions/6792803/finding-all-possible-case-permutations-in-python """ if not input_string: yield "" else: first = input_string[:1] if fi...
[ "def", "all_casings", "(", "input_string", ")", ":", "if", "not", "input_string", ":", "yield", "\"\"", "else", ":", "first", "=", "input_string", "[", ":", "1", "]", "if", "first", ".", "lower", "(", ")", "==", "first", ".", "upper", "(", ")", ":", ...
33.722222
0.001603
def getColor(value, default=None): """ Convert to color value. This returns a Color object instance from a text bit. """ if isinstance(value, Color): return value value = str(value).strip().lower() if value == "transparent" or value == "none": return default if value in ...
[ "def", "getColor", "(", "value", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "Color", ")", ":", "return", "value", "value", "=", "str", "(", "value", ")", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", "va...
31.36
0.001238
def store(bank, key, data): ''' Store a key value. ''' _init_client() data = __context__['serial'].dumps(data) query = b"REPLACE INTO {0} (bank, etcd_key, data) values('{1}', '{2}', " \ b"'{3}')".format(_table_name, bank, key, ...
[ "def", "store", "(", "bank", ",", "key", ",", "data", ")", ":", "_init_client", "(", ")", "data", "=", "__context__", "[", "'serial'", "]", ".", "dumps", "(", "data", ")", "query", "=", "b\"REPLACE INTO {0} (bank, etcd_key, data) values('{1}', '{2}', \"", "b\"'{...
28.722222
0.001873
def args2body(self, parsed_args, body=None): """Add in conditional args and then return all conn info.""" if body is None: body = {} if parsed_args.dpd: vpn_utils.validate_dpd_dict(parsed_args.dpd) body['dpd'] = parsed_args.dpd if parsed_args.local_ep...
[ "def", "args2body", "(", "self", ",", "parsed_args", ",", "body", "=", "None", ")", ":", "if", "body", "is", "None", ":", "body", "=", "{", "}", "if", "parsed_args", ".", "dpd", ":", "vpn_utils", ".", "validate_dpd_dict", "(", "parsed_args", ".", "dpd"...
42.631579
0.002415
def lookup_document_pointer(ident_hash, cursor): """Lookup a document by id and version.""" id, version = split_ident_hash(ident_hash, split_version=True) stmt = "SELECT name FROM modules WHERE uuid = %s" args = [id] if version and version[0] is not None: operator = version[1] is None and 'i...
[ "def", "lookup_document_pointer", "(", "ident_hash", ",", "cursor", ")", ":", "id", ",", "version", "=", "split_ident_hash", "(", "ident_hash", ",", "split_version", "=", "True", ")", "stmt", "=", "\"SELECT name FROM modules WHERE uuid = %s\"", "args", "=", "[", "...
37.722222
0.001437
def get_time_rate(self): ''' getter Time rate. ''' if isinstance(self.__time_rate, float) is False: raise TypeError("The type of __time_rate must be float.") if self.__time_rate <= 0.0: raise ValueError("The value of __time_rate must be greater th...
[ "def", "get_time_rate", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "__time_rate", ",", "float", ")", "is", "False", ":", "raise", "TypeError", "(", "\"The type of __time_rate must be float.\"", ")", "if", "self", ".", "__time_rate", "<=", "0....
29.166667
0.00831
def raw(self): r"""Return the raw corpus. This is reconstructed by joining sub-components with the corpus' split characters Returns ------- str The raw corpus Example ------- >>> tqbf = 'The quick brown fox jumped over the lazy dog.\...
[ "def", "raw", "(", "self", ")", ":", "doc_list", "=", "[", "]", "for", "doc", "in", "self", ".", "corpus", ":", "sent_list", "=", "[", "]", "for", "sent", "in", "doc", ":", "sent_list", ".", "append", "(", "' '", ".", "join", "(", "sent", ")", ...
27.1875
0.00222
def steps(self): """Return a list of steps (statements that are not settings or comments)""" steps = [] for statement in self.statements: if ((not statement.is_comment()) and (not statement.is_setting())): steps.append(statement) return steps
[ "def", "steps", "(", "self", ")", ":", "steps", "=", "[", "]", "for", "statement", "in", "self", ".", "statements", ":", "if", "(", "(", "not", "statement", ".", "is_comment", "(", ")", ")", "and", "(", "not", "statement", ".", "is_setting", "(", "...
38.875
0.012579
def Kgrad_param_num(self,i,h=1e-4): """ check discrepancies between numerical and analytical gradients """ params = self.getParams() e = sp.zeros_like(params); e[i] = 1 self.setParams(params-h*e) C_L = self.K() self.setParams(params+h*e) C_R = self...
[ "def", "Kgrad_param_num", "(", "self", ",", "i", ",", "h", "=", "1e-4", ")", ":", "params", "=", "self", ".", "getParams", "(", ")", "e", "=", "sp", ".", "zeros_like", "(", "params", ")", "e", "[", "i", "]", "=", "1", "self", ".", "setParams", ...
30
0.012438
async def create_role(self, *, reason=None, **fields): """|coro| Creates a :class:`Role` for the guild. All fields are optional. You must have the :attr:`~Permissions.manage_roles` permission to do this. Parameters ----------- name: :class:`str` ...
[ "async", "def", "create_role", "(", "self", ",", "*", ",", "reason", "=", "None", ",", "*", "*", "fields", ")", ":", "try", ":", "perms", "=", "fields", ".", "pop", "(", "'permissions'", ")", "except", "KeyError", ":", "fields", "[", "'permissions'", ...
31.253731
0.001852
def processors(self): """The list of all processors (preprocessors, compilers, postprocessors) used to build asset. """ return self.preprocessors + list(reversed(self.compilers)) + self.postprocessors
[ "def", "processors", "(", "self", ")", ":", "return", "self", ".", "preprocessors", "+", "list", "(", "reversed", "(", "self", ".", "compilers", ")", ")", "+", "self", ".", "postprocessors" ]
45.6
0.012931
def _read_join_syn(self, bits, size, kind): """Read Join Connection option for Initial SYN. Positional arguments: * bits - str, 4-bit data * size - int, length of option * kind - int, 30 (Multipath TCP) Returns: * dict -- extracted Join Connectio...
[ "def", "_read_join_syn", "(", "self", ",", "bits", ",", "size", ",", "kind", ")", ":", "adid", "=", "self", ".", "_read_unpack", "(", "1", ")", "rtkn", "=", "self", ".", "_read_fileng", "(", "4", ")", "srno", "=", "self", ".", "_read_unpack", "(", ...
43.076923
0.002182
def setText( self, text ): """ Sets the text for this widget to the inputed text, converting it based \ on the current input format if necessary. :param text | <str> """ if text is None: text = '' super(XLineEdit, self)...
[ "def", "setText", "(", "self", ",", "text", ")", ":", "if", "text", "is", "None", ":", "text", "=", "''", "super", "(", "XLineEdit", ",", "self", ")", ".", "setText", "(", "projex", ".", "text", ".", "encoded", "(", "self", ".", "formatText", "(", ...
34.454545
0.023136
def save_model(self, model, meta_data=None, index_fields=None): """ model (instance): Model instance. meta (dict): JSON serializable meta data for logging of save operation. {'lorem': 'ipsum', 'dolar': 5} index_fields (list): Tuple list for indexing keys in ri...
[ "def", "save_model", "(", "self", ",", "model", ",", "meta_data", "=", "None", ",", "index_fields", "=", "None", ")", ":", "# if model:", "# self._model = model", "if", "settings", ".", "DEBUG", ":", "t1", "=", "time", ".", "time", "(", ")", "clean_val...
35.881356
0.002299
def read_python(path): '''Parses python scripts in a dictionary Parameters ---------- path: str Path to file to parse Returns ------- metadata: dictionary containing parsed file ''' from six import exec_ path = Path(path).absolute() assert path.is_file() ...
[ "def", "read_python", "(", "path", ")", ":", "from", "six", "import", "exec_", "path", "=", "Path", "(", "path", ")", ".", "absolute", "(", ")", "assert", "path", ".", "is_file", "(", ")", "with", "path", ".", "open", "(", "'r'", ")", "as", "f", ...
21.130435
0.001969
def zipdir(path, ziph, **kwargs): """ Zip up a directory. :param path: :param ziph: :param kwargs: :return: """ str_arcroot = "" for k, v in kwargs.items(): if k == 'arcroot': str_arcroot = v for root, dirs, files in os.walk(path): for file in files: ...
[ "def", "zipdir", "(", "path", ",", "ziph", ",", "*", "*", "kwargs", ")", ":", "str_arcroot", "=", "\"\"", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k", "==", "'arcroot'", ":", "str_arcroot", "=", "v", "for", "root"...
28.083333
0.008608
def find_DQ_extension(self): """ Return the suffix for the data quality extension and the name of the file which that DQ extension should be read from. """ dqfile = None dq_suffix=None if(self.maskExt is not None): for hdu in self._image: # Loo...
[ "def", "find_DQ_extension", "(", "self", ")", ":", "dqfile", "=", "None", "dq_suffix", "=", "None", "if", "(", "self", ".", "maskExt", "is", "not", "None", ")", ":", "for", "hdu", "in", "self", ".", "_image", ":", "# Look for DQ extension in input file", "...
39.066667
0.01
def list_group_events(self, group_url, upcoming=True): ''' a method to retrieve a list of upcoming events hosted by group :param group_url: string with meetup urlname field of group :param upcoming: [optional] boolean to filter list to only future events :return: dictionary with ...
[ "def", "list_group_events", "(", "self", ",", "group_url", ",", "upcoming", "=", "True", ")", ":", "# https://www.meetup.com/meetup_api/docs/:urlname/events/#list\r", "title", "=", "'%s.list_group_events'", "%", "self", ".", "__class__", ".", "__name__", "# validate input...
34.297872
0.002413
def list(self, path=None, with_metadata=False, include_partitions=False): """Combine a listing of all of the upstreams, and add a metadata item for the repo_id""" l = {} for upstream in [self.alternate, self.upstream]: for k, v in upstream.list(path, with_metadata, include_...
[ "def", "list", "(", "self", ",", "path", "=", "None", ",", "with_metadata", "=", "False", ",", "include_partitions", "=", "False", ")", ":", "l", "=", "{", "}", "for", "upstream", "in", "[", "self", ".", "alternate", ",", "self", ".", "upstream", "]"...
35.6
0.009124
def forwards(self, orm): "Perform a 'safe' load using Avocado's backup utilities." from avocado.core import backup backup.safe_load(u'0002_avocado_metadata', backup_path=None, using='default')
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "from", "avocado", ".", "core", "import", "backup", "backup", ".", "safe_load", "(", "u'0002_avocado_metadata'", ",", "backup_path", "=", "None", ",", "using", "=", "'default'", ")" ]
44.8
0.013158
def _combine_results(self, match_as_dict): '''Combine results from different parsed parts: we look for non-empty results in values like 'postal_code_b' or 'postal_code_c' and store them as main value. So 'postal_code_b':'123456' becomes: ...
[ "def", "_combine_results", "(", "self", ",", "match_as_dict", ")", ":", "keys", "=", "[", "]", "vals", "=", "[", "]", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "match_as_dict", ")", ":", "if", "k", "[", "-", "2", ":", "]", "in", ...
37.217391
0.002278
def get_all_user(self, **kwargs): # noqa: E501 """Get all users # noqa: E501 Returns all users # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_all_user(async_req=True) ...
[ "def", "get_all_user", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "get_all_user_with_http_info", ...
39.4
0.002478
def parseEnvVars(): """ Parse environment variables into a Python dictionary suitable for passing to the device client constructor as the `options` parameter - `WIOTP_IDENTITY_APPID` - `WIOTP_AUTH_KEY` - `WIOTP_AUTH_TOKEN` - `WIOTP_OPTIONS_DOMAIN` (optional) - `WIOTP_OPTIONS_LOGLEVEL` ...
[ "def", "parseEnvVars", "(", ")", ":", "# Auth", "authKey", "=", "os", ".", "getenv", "(", "\"WIOTP_AUTH_KEY\"", ",", "None", ")", "authToken", "=", "os", ".", "getenv", "(", "\"WIOTP_AUTH_TOKEN\"", ",", "None", ")", "# Also support WIOTP_API_KEY / WIOTP_API_TOKEN ...
37.602273
0.002356
def fill_window(self, seqNum): """This function sends all of the packets necessary to fill out the segmentation window.""" if _debug: SSM._debug("fill_window %r", seqNum) if _debug: SSM._debug(" - actualWindowSize: %r", self.actualWindowSize) for ix in range(self.actualWindow...
[ "def", "fill_window", "(", "self", ",", "seqNum", ")", ":", "if", "_debug", ":", "SSM", ".", "_debug", "(", "\"fill_window %r\"", ",", "seqNum", ")", "if", "_debug", ":", "SSM", ".", "_debug", "(", "\" - actualWindowSize: %r\"", ",", "self", ".", "actua...
35.625
0.008547