text
stringlengths
75
104k
code_tokens
list
avg_line_len
float64
7.91
980
score
float64
0
0.18
def raw_row_generator(self): """Like rowgenerator, but does not try to create a row processor table""" from rowgenerators import get_generator self.doc.set_sys_path() # Set sys path to package 'lib' dir in case of python function generator ru = self.resolved_url try: ...
[ "def", "raw_row_generator", "(", "self", ")", ":", "from", "rowgenerators", "import", "get_generator", "self", ".", "doc", ".", "set_sys_path", "(", ")", "# Set sys path to package 'lib' dir in case of python function generator", "ru", "=", "self", ".", "resolved_url", ...
30.129032
0.006224
def push_images(): # type: () -> None """ Push all project docker images to a remote registry. """ registry = conf.get('docker.registry') docker_images = conf.get('docker.images', []) if registry is None: log.err("You must define docker.registry conf variable to push images") sys.ex...
[ "def", "push_images", "(", ")", ":", "# type: () -> None", "registry", "=", "conf", ".", "get", "(", "'docker.registry'", ")", "docker_images", "=", "conf", ".", "get", "(", "'docker.images'", ",", "[", "]", ")", "if", "registry", "is", "None", ":", "log",...
32
0.002532
def import_attribute(name): """ Return an attribute from a dotted path name (e.g. "path.to.func"). Copied from nvie's rq https://github.com/nvie/rq/blob/master/rq/utils.py """ if hasattr(name, '__call__'): return name module_name, attribute = name.rsplit('.', 1) module = importlib.im...
[ "def", "import_attribute", "(", "name", ")", ":", "if", "hasattr", "(", "name", ",", "'__call__'", ")", ":", "return", "name", "module_name", ",", "attribute", "=", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "module", "=", "importlib", ".", "imp...
37.3
0.002618
def countedArray( expr, intExpr=None ): """Helper to define a counted list of expressions. This helper defines a pattern of the form:: integer expr expr expr... where the leading integer tells how many expr expressions follow. The matched tokens returns the array of expr tokens ...
[ "def", "countedArray", "(", "expr", ",", "intExpr", "=", "None", ")", ":", "arrayExpr", "=", "Forward", "(", ")", "def", "countFieldParseAction", "(", "s", ",", "l", ",", "t", ")", ":", "n", "=", "t", "[", "0", "]", "arrayExpr", "<<", "(", "n", "...
42.421053
0.01335
def get_projects(self, **kwargs): """Get a user's project. :param str login: User's login (Default: self._login) :return: JSON """ _login = kwargs.get('login', self._login) search_url = SEARCH_URL.format(login=_login) return self._request_api(url=search_url).jso...
[ "def", "get_projects", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "self", ".", "_login", ")", "search_url", "=", "SEARCH_URL", ".", "format", "(", "login", "=", "_login", ")", "return", "...
31.4
0.006192
def auto_watering(self): """Return if zone is configured to automatic watering.""" value = "zone{}".format(self.id) return find_program_status(self._parent.html['home'], value)
[ "def", "auto_watering", "(", "self", ")", ":", "value", "=", "\"zone{}\"", ".", "format", "(", "self", ".", "id", ")", "return", "find_program_status", "(", "self", ".", "_parent", ".", "html", "[", "'home'", "]", ",", "value", ")" ]
49.25
0.01
def validate_tempi(tempi, reference=True): """Checks that there are two non-negative tempi. For a reference value, at least one tempo has to be greater than zero. Parameters ---------- tempi : np.ndarray length-2 array of tempo, in bpm reference : bool indicates a reference val...
[ "def", "validate_tempi", "(", "tempi", ",", "reference", "=", "True", ")", ":", "if", "tempi", ".", "size", "!=", "2", ":", "raise", "ValueError", "(", "'tempi must have exactly two values'", ")", "if", "not", "np", ".", "all", "(", "np", ".", "isfinite", ...
30.73913
0.001372
def _contentful_user_agent(self): """ Sets the X-Contentful-User-Agent header. """ header = {} from . import __version__ header['sdk'] = { 'name': 'contentful-management.py', 'version': __version__ } header['app'] = { 'n...
[ "def", "_contentful_user_agent", "(", "self", ")", ":", "header", "=", "{", "}", "from", ".", "import", "__version__", "header", "[", "'sdk'", "]", "=", "{", "'name'", ":", "'contentful-management.py'", ",", "'version'", ":", "__version__", "}", "header", "[...
30.166667
0.001338
def create(self, request, *args, **kwargs): """ Run **POST** against */api/alerts/* to create or update alert. If alert with posted scope and alert_type already exists - it will be updated. Only users with staff privileges can create alerts. Request example: .. code-block:: jav...
[ "def", "create", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "AlertViewSet", ",", "self", ")", ".", "create", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
36.913043
0.005741
def Floor(input_vertex: vertex_constructor_param_types, label: Optional[str]=None) -> Vertex: """ Applies the Floor operator to a vertex. This maps a vertex to the biggest integer less than or equal to its value :param input_vertex: the vertex to be floor'd """ return Double(context.jvm_vie...
[ "def", "Floor", "(", "input_vertex", ":", "vertex_constructor_param_types", ",", "label", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Vertex", ":", "return", "Double", "(", "context", ".", "jvm_view", "(", ")", ".", "FloorVertex", ",", "labe...
46.625
0.015789
def timeid(self, data: ['SASdata', str] = None, by: str = None, id: str = None, out: [str, 'SASdata'] = None, procopts: str = None, stmtpassthrough: str = None, **kwargs: dict) -> 'SASresults': """ Python method to...
[ "def", "timeid", "(", "self", ",", "data", ":", "[", "'SASdata'", ",", "str", "]", "=", "None", ",", "by", ":", "str", "=", "None", ",", "id", ":", "str", "=", "None", ",", "out", ":", "[", "str", ",", "'SASdata'", "]", "=", "None", ",", "pro...
49.714286
0.010338
def yoffset(self, value): """gets/sets the yoffset""" if self._yoffset != value and \ isinstance(value, (int, float, long)): self._yoffset = value
[ "def", "yoffset", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_yoffset", "!=", "value", "and", "isinstance", "(", "value", ",", "(", "int", ",", "float", ",", "long", ")", ")", ":", "self", ".", "_yoffset", "=", "value" ]
36.2
0.010811
def exec_cluster(config_file, cmd, docker, screen, tmux, stop, start, override_cluster_name, port_forward): """Runs a command on the specified cluster. Arguments: config_file: path to the cluster yaml cmd: command to run docker: whether to run command in docker containe...
[ "def", "exec_cluster", "(", "config_file", ",", "cmd", ",", "docker", ",", "screen", ",", "tmux", ",", "stop", ",", "start", ",", "override_cluster_name", ",", "port_forward", ")", ":", "assert", "not", "(", "screen", "and", "tmux", ")", ",", "\"Can specif...
36.35
0.000335
def swap(self): '''Swap stereo channels. If the input is not stereo, pairs of channels are swapped, and a possible odd last channel passed through. E.g., for seven channels, the output order will be 2, 1, 4, 3, 6, 5, 7. See Also ---------- remix ''' eff...
[ "def", "swap", "(", "self", ")", ":", "effect_args", "=", "[", "'swap'", "]", "self", ".", "effects", ".", "extend", "(", "effect_args", ")", "self", ".", "effects_log", ".", "append", "(", "'swap'", ")", "return", "self" ]
26.625
0.004535
def set_sensor_thresholds(self, sensor_number, lun=0, unr=None, ucr=None, unc=None, lnc=None, lcr=None, lnr=None): """Set the sensor thresholds that are not 'None' `sensor_number` `unr` for upper non-recoverable `ucr` for upper...
[ "def", "set_sensor_thresholds", "(", "self", ",", "sensor_number", ",", "lun", "=", "0", ",", "unr", "=", "None", ",", "ucr", "=", "None", ",", "unc", "=", "None", ",", "lnc", "=", "None", ",", "lcr", "=", "None", ",", "lnr", "=", "None", ")", ":...
35.961538
0.004167
def __get_features_for_observation(self, data_frame=None, observation='LA-LL', skip_id=None, last_column_is_id=False): """ Extract the features for a given observation from a data frame :param data_frame: data frame to get features from ...
[ "def", "__get_features_for_observation", "(", "self", ",", "data_frame", "=", "None", ",", "observation", "=", "'LA-LL'", ",", "skip_id", "=", "None", ",", "last_column_is_id", "=", "False", ")", ":", "try", ":", "features", "=", "np", ".", "array", "(", "...
42.45
0.004606
def pow2_quantized_convolution(inp, outmaps, kernel, pad=None, stride=None, dilation=None, group=1, w_init=None, b_init=None, base_axis=1, fix_parameters=False, rng=None, with_bias=True, quantize_...
[ "def", "pow2_quantized_convolution", "(", "inp", ",", "outmaps", ",", "kernel", ",", "pad", "=", "None", ",", "stride", "=", "None", ",", "dilation", "=", "None", ",", "group", "=", "1", ",", "w_init", "=", "None", ",", "b_init", "=", "None", ",", "b...
51.899083
0.004337
def descr_prototype(self, buf): """ Describe the prototype ("head") of the function. """ state = "define" if self.blocks else "declare" ret = self.return_value args = ", ".join(str(a) for a in self.args) name = self.get_reference() attrs = self.attributes ...
[ "def", "descr_prototype", "(", "self", ",", "buf", ")", ":", "state", "=", "\"define\"", "if", "self", ".", "blocks", "else", "\"declare\"", "ret", "=", "self", ".", "return_value", "args", "=", "\", \"", ".", "join", "(", "str", "(", "a", ")", "for", ...
41.428571
0.003371
def _get_first_import(node, context, name, base, level, alias): """return the node where [base.]<name> is imported or None if not found """ fullname = "%s.%s" % (base, name) if base else name first = None found = False for first in context.body: if first is node: continue ...
[ "def", "_get_first_import", "(", "node", ",", "context", ",", "name", ",", "base", ",", "level", ",", "alias", ")", ":", "fullname", "=", "\"%s.%s\"", "%", "(", "base", ",", "name", ")", "if", "base", "else", "name", "first", "=", "None", "found", "=...
36.882353
0.001554
def _getPastEvents(self, request): """Return the past events in this site.""" home = request.site.root_page return getAllPastEvents(request, home=home)
[ "def", "_getPastEvents", "(", "self", ",", "request", ")", ":", "home", "=", "request", ".", "site", ".", "root_page", "return", "getAllPastEvents", "(", "request", ",", "home", "=", "home", ")" ]
43
0.011429
def dump_to_string(self, cnf, **kwargs): """ Dump config 'cnf' to a string. :param cnf: Configuration data to dump :param kwargs: optional keyword parameters to be sanitized :: dict :return: Dict-like object holding config parameters """ stream = anyconfig.compa...
[ "def", "dump_to_string", "(", "self", ",", "cnf", ",", "*", "*", "kwargs", ")", ":", "stream", "=", "anyconfig", ".", "compat", ".", "StringIO", "(", ")", "self", ".", "dump_to_stream", "(", "cnf", ",", "stream", ",", "*", "*", "kwargs", ")", "return...
33.75
0.004808
def initial(self, request, *args, **kwargs): """ Custom initial method: * ensure node exists and store it in an instance attribute * change queryset to return only devices of current node """ super(NodeDeviceList, self).initial(request, *args, **kwargs) #...
[ "def", "initial", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "NodeDeviceList", ",", "self", ")", ".", "initial", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", "# ensure node exist...
40.043478
0.003181
def main(argString=None): """Check for duplicated samples in a tfam/tped file. :param argString: the options :type argString: list Here are the steps for the duplicated samples step. 1. Prints the options. 2. Reads the ``tfam`` file (:py:func:`readTFAM`). 3. Separate the duplicated sa...
[ "def", "main", "(", "argString", "=", "None", ")", ":", "# Getting and checking the options", "args", "=", "parseArgs", "(", "argString", ")", "checkArgs", "(", "args", ")", "logger", ".", "info", "(", "\"Options used:\"", ")", "for", "key", ",", "value", "i...
40.266187
0.000174
def citedReferencesRetrieve(self, queryId, count=100, offset=1, retrieveParameters=None): """The citedReferencesRetrieve operation submits a query returned by a previous citedReferences operation. This operation is useful for overcoming the retrieval limit of 100...
[ "def", "citedReferencesRetrieve", "(", "self", ",", "queryId", ",", "count", "=", "100", ",", "offset", "=", "1", ",", "retrieveParameters", "=", "None", ")", ":", "return", "self", ".", "_search", ".", "service", ".", "citedReferencesRetrieve", "(", "queryI...
50.035714
0.002101
def load_library(self,libname): """Given the name of a library, load it.""" paths = self.getpaths(libname) for path in paths: if os.path.exists(path): return self.load(path) raise ImportError("%s not found." % libname)
[ "def", "load_library", "(", "self", ",", "libname", ")", ":", "paths", "=", "self", ".", "getpaths", "(", "libname", ")", "for", "path", "in", "paths", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "self", ".", "load...
30.222222
0.010714
def on_fork(): """ Should be called by any program integrating Mitogen each time the process is forked, in the context of the new child. """ reset_logging_framework() # Must be first! fixup_prngs() mitogen.core.Latch._on_fork() mitogen.core.Side._on_fork() mitogen.core.ExternalConte...
[ "def", "on_fork", "(", ")", ":", "reset_logging_framework", "(", ")", "# Must be first!", "fixup_prngs", "(", ")", "mitogen", ".", "core", ".", "Latch", ".", "_on_fork", "(", ")", "mitogen", ".", "core", ".", "Side", ".", "_on_fork", "(", ")", "mitogen", ...
34.642857
0.002008
def finish_parse(self, last_lineno_seen): """Clean-up/summary tasks run at the end of parsing.""" if self.state == self.STATES['step_in_progress']: # We've reached the end of the log without seeing the final "step finish" # marker, which would normally have triggered updating the...
[ "def", "finish_parse", "(", "self", ",", "last_lineno_seen", ")", ":", "if", "self", ".", "state", "==", "self", ".", "STATES", "[", "'step_in_progress'", "]", ":", "# We've reached the end of the log without seeing the final \"step finish\"", "# marker, which would normall...
64.8
0.009132
def p_Exception(p): """Exception : exception IDENTIFIER Inheritance "{" ExceptionMembers "}" ";" """ p[0] = model.Exception(name=p[2], parent=p[3], members=p[5])
[ "def", "p_Exception", "(", "p", ")", ":", "p", "[", "0", "]", "=", "model", ".", "Exception", "(", "name", "=", "p", "[", "2", "]", ",", "parent", "=", "p", "[", "3", "]", ",", "members", "=", "p", "[", "5", "]", ")" ]
41
0.017964
def runCommandSplits(splits, silent=False, shell=False): """ Run a shell command given the command's parsed command line """ try: if silent: with open(os.devnull, 'w') as devnull: subprocess.check_call( splits, stdout=devnull, stderr=devnull, shell...
[ "def", "runCommandSplits", "(", "splits", ",", "silent", "=", "False", ",", "shell", "=", "False", ")", ":", "try", ":", "if", "silent", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "devnull", ":", "subprocess", ".", "check_...
35.294118
0.001623
def get_range_response(self, range_start, range_end, sort_order=None, sort_target='key', **kwargs): """Get a range of keys.""" range_request = self._build_get_range_request( key=range_start, range_end=range_end, sort_order=sort_order, ...
[ "def", "get_range_response", "(", "self", ",", "range_start", ",", "range_end", ",", "sort_order", "=", "None", ",", "sort_target", "=", "'key'", ",", "*", "*", "kwargs", ")", ":", "range_request", "=", "self", ".", "_build_get_range_request", "(", "key", "=...
32.058824
0.005348
def detect_erc20_unindexed_event_params(contract): """ Detect un-indexed ERC20 event parameters in a given contract. :param contract: The contract to check ERC20 events for un-indexed parameters in. :return: A list of tuple(event, parameter) of parameters which should be indexed. ...
[ "def", "detect_erc20_unindexed_event_params", "(", "contract", ")", ":", "# Create our result array", "results", "=", "[", "]", "# If this contract isn't an ERC20 token, we return our empty results.", "if", "not", "contract", ".", "is_erc20", "(", ")", ":", "return", "resul...
41.3
0.003943
def result_report_class_wise(self): """Report class-wise results Returns ------- str result report in string format """ results = self.results_class_wise_metrics() output = self.ui.section_header('Class-wise metrics', indent=2) + '\n' outp...
[ "def", "result_report_class_wise", "(", "self", ")", ":", "results", "=", "self", ".", "results_class_wise_metrics", "(", ")", "output", "=", "self", ".", "ui", ".", "section_header", "(", "'Class-wise metrics'", ",", "indent", "=", "2", ")", "+", "'\\n'", "...
28.757576
0.002039
def _import(klass): '''1) Get a reference to the module 2) Check the file that module's imported from 3) If that file's been updated, force a reload of that module return it''' mod = __import__(klass.rpartition('.')[0]) for segment in klass.split('.')[1:-1]:...
[ "def", "_import", "(", "klass", ")", ":", "mod", "=", "__import__", "(", "klass", ".", "rpartition", "(", "'.'", ")", "[", "0", "]", ")", "for", "segment", "in", "klass", ".", "split", "(", "'.'", ")", "[", "1", ":", "-", "1", "]", ":", "mod", ...
41.695652
0.003058
def overview(self, tag=None, fromdate=None, todate=None): """ Gets a brief overview of statistics for all of your outbound email. """ return self.call("GET", "/stats/outbound", tag=tag, fromdate=fromdate, todate=todate)
[ "def", "overview", "(", "self", ",", "tag", "=", "None", ",", "fromdate", "=", "None", ",", "todate", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"GET\"", ",", "\"/stats/outbound\"", ",", "tag", "=", "tag", ",", "fromdate", "=", "fro...
49.4
0.011952
def get_hook_model(): """ Returns the Custom Hook model if defined in settings, otherwise the default Hook model. """ from rest_hooks.models import Hook HookModel = Hook if getattr(settings, 'HOOK_CUSTOM_MODEL', None): HookModel = get_module(settings.HOOK_CUSTOM_MODEL) return Hoo...
[ "def", "get_hook_model", "(", ")", ":", "from", "rest_hooks", ".", "models", "import", "Hook", "HookModel", "=", "Hook", "if", "getattr", "(", "settings", ",", "'HOOK_CUSTOM_MODEL'", ",", "None", ")", ":", "HookModel", "=", "get_module", "(", "settings", "."...
31.7
0.003067
def subkeys(self, path): """ A generalized form that can return multiple subkeys. """ for _ in subpaths_for_path_range(path, hardening_chars="'pH"): yield self.subkey(_)
[ "def", "subkeys", "(", "self", ",", "path", ")", ":", "for", "_", "in", "subpaths_for_path_range", "(", "path", ",", "hardening_chars", "=", "\"'pH\"", ")", ":", "yield", "self", ".", "subkey", "(", "_", ")" ]
34.666667
0.00939
def img_src_finder(pipeline_index, soup, finder_image_urls=[], *args, **kwargs): """ Find image URL in <img>'s src attribute """ now_finder_image_urls = [] for img in soup.find_all('img'): src = img.get('src', None) if src: ...
[ "def", "img_src_finder", "(", "pipeline_index", ",", "soup", ",", "finder_image_urls", "=", "[", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "now_finder_image_urls", "=", "[", "]", "for", "img", "in", "soup", ".", "find_all", "(", "'img'", ...
26.772727
0.001639
def addPolicyURI(self, policy_uri): """Add a authentication policy to this response This method is intended to be used by the provider to add a policy that the provider conformed to when authenticating the user. @param policy_uri: The identifier for the preferred type of au...
[ "def", "addPolicyURI", "(", "self", ",", "policy_uri", ")", ":", "if", "policy_uri", "not", "in", "self", ".", "auth_policies", ":", "self", ".", "auth_policies", ".", "append", "(", "policy_uri", ")" ]
45.416667
0.005396
def filter_desc(self, graintype=None, group=None, reference=None, size=None, phase=None): ''' This routine is to filter for description elements. You can check what is available in the description by running, >>> i.header_desc() where i is the instance you ...
[ "def", "filter_desc", "(", "self", ",", "graintype", "=", "None", ",", "group", "=", "None", ",", "reference", "=", "None", ",", "size", "=", "None", ",", "phase", "=", "None", ")", ":", "# filter for graintype", "if", "graintype", "!=", "None", ":", "...
38.159091
0.003289
def set_property_filter(filter_proto, name, op, value): """Set property filter contraint in the given datastore.Filter proto message. Args: filter_proto: datastore.Filter proto message name: property name op: datastore.PropertyFilter.Operation value: property value Returns: the same datastor...
[ "def", "set_property_filter", "(", "filter_proto", ",", "name", ",", "op", ",", "value", ")", ":", "filter_proto", ".", "Clear", "(", ")", "pf", "=", "filter_proto", ".", "property_filter", "pf", ".", "property", ".", "name", "=", "name", "pf", ".", "op"...
26.818182
0.013093
def _font_name(self, ufo): """Generate a postscript-style font name.""" family_name = ( ufo.info.familyName.replace(" ", "") if ufo.info.familyName is not None else "None" ) style_name = ( ufo.info.styleName.replace(" ", "") if ...
[ "def", "_font_name", "(", "self", ",", "ufo", ")", ":", "family_name", "=", "(", "ufo", ".", "info", ".", "familyName", ".", "replace", "(", "\" \"", ",", "\"\"", ")", "if", "ufo", ".", "info", ".", "familyName", "is", "not", "None", "else", "\"None\...
32.846154
0.004556
def wv45(msg): """Wake vortex. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[12] == '0': return None ws = bin2int(d[13:15]) return ws
[ "def", "wv45", "(", "msg", ")", ":", "d", "=", "hex2bin", "(", "data", "(", "msg", ")", ")", "if", "d", "[", "12", "]", "==", "'0'", ":", "return", "None", "ws", "=", "bin2int", "(", "d", "[", "13", ":", "15", "]", ")", "return", "ws" ]
18.125
0.003279
def fake2db_couchdb_initiator(self, number_of_rows, name=None, custom=None): '''Main handler for the operation ''' rows = number_of_rows db = self.database_caller_creator(name) if custom: self.custom_db_creator(rows, db, custom) sys.exit(0) ...
[ "def", "fake2db_couchdb_initiator", "(", "self", ",", "number_of_rows", ",", "name", "=", "None", ",", "custom", "=", "None", ")", ":", "rows", "=", "number_of_rows", "db", "=", "self", ".", "database_caller_creator", "(", "name", ")", "if", "custom", ":", ...
36.6
0.005329
async def get_all_tracks(self) -> List[PlaylistTrack]: """Get all playlist tracks from the playlist. Returns ------- tracks : List[PlaylistTrack] The playlists tracks. """ if isinstance(self._tracks, PartialTracks): return await self._tracks.build...
[ "async", "def", "get_all_tracks", "(", "self", ")", "->", "List", "[", "PlaylistTrack", "]", ":", "if", "isinstance", "(", "self", ".", "_tracks", ",", "PartialTracks", ")", ":", "return", "await", "self", ".", "_tracks", ".", "build", "(", ")", "_tracks...
33.380952
0.005548
def ekrcec(handle, segno, recno, column, lenout, nelts=_SPICE_EK_EKRCEX_ROOM_DEFAULT): """ Read data from a character column in a specified EK record. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ekrcec_c.html :param handle: Handle attached to EK file. :type handle: int :param segno...
[ "def", "ekrcec", "(", "handle", ",", "segno", ",", "recno", ",", "column", ",", "lenout", ",", "nelts", "=", "_SPICE_EK_EKRCEX_ROOM_DEFAULT", ")", ":", "handle", "=", "ctypes", ".", "c_int", "(", "handle", ")", "segno", "=", "ctypes", ".", "c_int", "(", ...
39.142857
0.002849
def setPageCount( self, pageCount ): """ Sets the number of pages that this widget holds. :param pageCount | <int> """ if ( pageCount == self._pageCount ): return pageCount = max(1, pageCount) self._pageCount ...
[ "def", "setPageCount", "(", "self", ",", "pageCount", ")", ":", "if", "(", "pageCount", "==", "self", ".", "_pageCount", ")", ":", "return", "pageCount", "=", "max", "(", "1", ",", "pageCount", ")", "self", ".", "_pageCount", "=", "pageCount", "self", ...
33.269231
0.021348
def determine_reference_direction_fast(nickname, server, possible_autonomous_profiles=None, possible_component_profiles=None): """ Determine CIM_ReferenceProfile Antecedent/Dependent direction from server data and a list of known ...
[ "def", "determine_reference_direction_fast", "(", "nickname", ",", "server", ",", "possible_autonomous_profiles", "=", "None", ",", "possible_component_profiles", "=", "None", ")", ":", "def", "_determine_type", "(", "profilepaths", ",", "v0_dict", ",", "v1_dict", ","...
41.306306
0.000426
def summary_permutation(context_counts, context_to_mut, seq_context, gene_seq, score_dir, num_permutations=10000, min_frac=0.0, min_recur=2, ...
[ "def", "summary_permutation", "(", "context_counts", ",", "context_to_mut", ",", "seq_context", ",", "gene_seq", ",", "score_dir", ",", "num_permutations", "=", "10000", ",", "min_frac", "=", "0.0", ",", "min_recur", "=", "2", ",", "drop_silent", "=", "False", ...
40.012821
0.000938
def patch_namespaced_pod_template(self, name, namespace, body, **kwargs): # noqa: E501 """patch_namespaced_pod_template # noqa: E501 partially update the specified PodTemplate # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, ...
[ "def", "patch_namespaced_pod_template", "(", "self", ",", "name", ",", "namespace", ",", "body", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", "...
61.68
0.001277
def get_hist(rfile, histname, get_overflow=False): """Read a 1D Histogram.""" import root_numpy as rnp rfile = open_rfile(rfile) hist = rfile[histname] xlims = np.array(list(hist.xedges())) bin_values = rnp.hist2array(hist, include_overflow=get_overflow) rfile.close() return bin_values,...
[ "def", "get_hist", "(", "rfile", ",", "histname", ",", "get_overflow", "=", "False", ")", ":", "import", "root_numpy", "as", "rnp", "rfile", "=", "open_rfile", "(", "rfile", ")", "hist", "=", "rfile", "[", "histname", "]", "xlims", "=", "np", ".", "arr...
31.7
0.003067
def subcmd_bootstrap_parser(subcmd): """ bootstrap subcommand """ subcmd.add_argument( '--broker', action='store', dest='broker', help=u'Route to the Ansible Service Broker' ) subcmd.add_argument( '--secure', action='store_true', dest='verify', ...
[ "def", "subcmd_bootstrap_parser", "(", "subcmd", ")", ":", "subcmd", ".", "add_argument", "(", "'--broker'", ",", "action", "=", "'store'", ",", "dest", "=", "'broker'", ",", "help", "=", "u'Route to the Ansible Service Broker'", ")", "subcmd", ".", "add_argument"...
26.415094
0.001377
def parse_html(html): """ Create an lxml.html.HtmlElement from a string with html. XXX: mostly copy-pasted from parsel.selector.create_root_node """ body = html.strip().replace('\x00', '').encode('utf8') or b'<html/>' parser = lxml.html.HTMLParser(recover=True, encoding='utf8') root = lxml.etree...
[ "def", "parse_html", "(", "html", ")", ":", "body", "=", "html", ".", "strip", "(", ")", ".", "replace", "(", "'\\x00'", ",", "''", ")", ".", "encode", "(", "'utf8'", ")", "or", "b'<html/>'", "parser", "=", "lxml", ".", "html", ".", "HTMLParser", "...
44.4
0.002208
def _get_metadata(cls, request, response, head=None): """Parses out the head and link properties based on the HTTP Request from the client, and the Protobuf response from the validator. """ head = response.get('head_id', head) metadata = {'link': cls._build_url(request, head=head...
[ "def", "_get_metadata", "(", "cls", ",", "request", ",", "response", ",", "head", "=", "None", ")", ":", "head", "=", "response", ".", "get", "(", "'head_id'", ",", "head", ")", "metadata", "=", "{", "'link'", ":", "cls", ".", "_build_url", "(", "req...
40.3
0.004854
def make(parser): """DEPRECATED prepare OpenStack basic environment""" s = parser.add_subparsers( title='commands', metavar='COMMAND', help='description', ) def gen_pass_f(args): gen_pass() gen_pass_parser = s.add_parser('gen-pass', help='generate the passwor...
[ "def", "make", "(", "parser", ")", ":", "s", "=", "parser", ".", "add_subparsers", "(", "title", "=", "'commands'", ",", "metavar", "=", "'COMMAND'", ",", "help", "=", "'description'", ",", ")", "def", "gen_pass_f", "(", "args", ")", ":", "gen_pass", "...
37.578947
0.005464
def update(self, vrfs): """ Method to update vrf's :param vrfs: List containing vrf's desired to updated :return: None """ data = {'vrfs': vrfs} vrfs_ids = [str(vrf.get('id')) for vrf in vrfs] return super(ApiVrf, self).put('api/v3/vrf/%s/' % ...
[ "def", "update", "(", "self", ",", "vrfs", ")", ":", "data", "=", "{", "'vrfs'", ":", "vrfs", "}", "vrfs_ids", "=", "[", "str", "(", "vrf", ".", "get", "(", "'id'", ")", ")", "for", "vrf", "in", "vrfs", "]", "return", "super", "(", "ApiVrf", ",...
27.846154
0.005348
def make_log_record_output(category, level, message, format=None, datefmt=None, **kwargs): """ Create the output for a log record, like performed by :mod:`logging` module. :param category: Name of the logger (as string or None). :param level: Log level (as number). ...
[ "def", "make_log_record_output", "(", "category", ",", "level", ",", "message", ",", "format", "=", "None", ",", "datefmt", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "category", "or", "(", "category", "==", "\"__ROOT__\"", ")", ":", ...
42.333333
0.002567
def update_contact(self, um_from_user, um_to_user, message): """ Get or update a contacts information """ contact, created = self.get_or_create(um_from_user, um_to_user, message) # If the contact already...
[ "def", "update_contact", "(", "self", ",", "um_from_user", ",", "um_to_user", ",", "message", ")", ":", "contact", ",", "created", "=", "self", ".", "get_or_create", "(", "um_from_user", ",", "um_to_user", ",", "message", ")", "# If the contact already existed, up...
41.545455
0.004283
def controlprompt_cmd(self, cmd): """Perform a "controlpromptentry" command.""" data = tags.string_tag('cmbe', cmd) + tags.uint8_tag('cmcc', 0) return self.daap.post(_CTRL_PROMPT_CMD, data=data)
[ "def", "controlprompt_cmd", "(", "self", ",", "cmd", ")", ":", "data", "=", "tags", ".", "string_tag", "(", "'cmbe'", ",", "cmd", ")", "+", "tags", ".", "uint8_tag", "(", "'cmcc'", ",", "0", ")", "return", "self", ".", "daap", ".", "post", "(", "_C...
53.75
0.009174
def _apply_filters(self, p_todos): """ Applies the filters to the list of todo items. """ result = p_todos for _filter in sorted(self._filters, key=lambda f: f.order): result = _filter.filter(result) return result
[ "def", "_apply_filters", "(", "self", ",", "p_todos", ")", ":", "result", "=", "p_todos", "for", "_filter", "in", "sorted", "(", "self", ".", "_filters", ",", "key", "=", "lambda", "f", ":", "f", ".", "order", ")", ":", "result", "=", "_filter", ".",...
31.5
0.007722
def uninstall(path, restart=False): ''' Uninstall a specific KB. Args: path (str): The full path to the msu file to uninstall. This can also be just the name of the KB to uninstall restart (bool): ``True`` to force a restart if required by the installat...
[ "def", "uninstall", "(", "path", ",", "restart", "=", "False", ")", ":", "# Build the command", "cmd", "=", "[", "'wusa.exe'", ",", "'/uninstall'", ",", "'/quiet'", "]", "kb", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basen...
29.847458
0.00055
def _get_data_bounds(data_bounds, pos=None, length=None): """"Prepare data bounds, possibly using min/max of the data.""" if data_bounds is None or (isinstance(data_bounds, string_types) and data_bounds == 'auto'): if pos is not None and len(pos): m, M = pos.mi...
[ "def", "_get_data_bounds", "(", "data_bounds", ",", "pos", "=", "None", ",", "length", "=", "None", ")", ":", "if", "data_bounds", "is", "None", "or", "(", "isinstance", "(", "data_bounds", ",", "string_types", ")", "and", "data_bounds", "==", "'auto'", ")...
35.354839
0.000888
def validate(self): '''Validate required headers and validate notification headers''' for header in self._requiredHeaders: if not self.headers.get(header, False): raise errors.ParseError('Missing Registration Header: ' + header) for notice in self.notifications: for header in self._requiredNotificationH...
[ "def", "validate", "(", "self", ")", ":", "for", "header", "in", "self", ".", "_requiredHeaders", ":", "if", "not", "self", ".", "headers", ".", "get", "(", "header", ",", "False", ")", ":", "raise", "errors", ".", "ParseError", "(", "'Missing Registrati...
47.555556
0.022936
def signed_token_generator(private_pem, **kwargs): """ :param private_pem: """ def signed_token_generator(request): request.claims = kwargs return common.generate_signed_token(private_pem, request) return signed_token_generator
[ "def", "signed_token_generator", "(", "private_pem", ",", "*", "*", "kwargs", ")", ":", "def", "signed_token_generator", "(", "request", ")", ":", "request", ".", "claims", "=", "kwargs", "return", "common", ".", "generate_signed_token", "(", "private_pem", ",",...
28.444444
0.003788
def join_right_in(self, *objs): """ Create a join condition, connect B and C """ if not objs: return self.table.c[self.fielda]!=self.table.c[self.fielda] else: keys = get_objs_columns(objs, self.reference_fieldname) return (self.table.c[self.fi...
[ "def", "join_right_in", "(", "self", ",", "*", "objs", ")", ":", "if", "not", "objs", ":", "return", "self", ".", "table", ".", "c", "[", "self", ".", "fielda", "]", "!=", "self", ".", "table", ".", "c", "[", "self", ".", "fielda", "]", "else", ...
45.555556
0.009569
def selectize_tags_media(media_type='css',name=''): """ Usage: ------ To include css media: selectize_tags_media 'css' <theme> To include Selectize Scripts: selectize_tags_media 'js' To include Selectize Scripts and Jquery: selectize_tags_media 'js' 'jquery' """ if media_type=='js': str_script='<script s...
[ "def", "selectize_tags_media", "(", "media_type", "=", "'css'", ",", "name", "=", "''", ")", ":", "if", "media_type", "==", "'js'", ":", "str_script", "=", "'<script src=\"{url}\"></script>\\n'", "html", "=", "str_script", ".", "format", "(", "url", "=", "stat...
28.130435
0.044843
def get_service_regex(base_url, service_url, sub_service): """Get the regex for a given service. :param base_url: string - Base URI :param service_url: string - Service URI under the Base URI :param sub_service: boolean - is the Service URI for a sub-service? :returns: Python R...
[ "def", "get_service_regex", "(", "base_url", ",", "service_url", ",", "sub_service", ")", ":", "# if the specified service_url is already a regex", "# then just use. Otherwise create what we need", "if", "StackInABoxService", ".", "is_regex", "(", "service_url", ")", ":", "lo...
44.416667
0.001837
def fasta(self): """Generates sequence data for the protein in FASTA format.""" max_line_length = 79 fasta_str = '>{0}:{1}|PDBID|CHAIN|SEQUENCE\n'.format( self.parent.id.upper(), self.id) seq = self.sequence split_seq = [seq[i: i + max_line_length] ...
[ "def", "fasta", "(", "self", ")", ":", "max_line_length", "=", "79", "fasta_str", "=", "'>{0}:{1}|PDBID|CHAIN|SEQUENCE\\n'", ".", "format", "(", "self", ".", "parent", ".", "id", ".", "upper", "(", ")", ",", "self", ".", "id", ")", "seq", "=", "self", ...
42.454545
0.004193
async def run(self): """Entrypoint to route messages between plugins.""" logging.info('Starting message router...') coroutines = set() while True: coro = self._poll_channel() coroutines.add(coro) _, coroutines = await asyncio.wait(coroutines, timeout=...
[ "async", "def", "run", "(", "self", ")", ":", "logging", ".", "info", "(", "'Starting message router...'", ")", "coroutines", "=", "set", "(", ")", "while", "True", ":", "coro", "=", "self", ".", "_poll_channel", "(", ")", "coroutines", ".", "add", "(", ...
35.111111
0.006173
def _terminate_procs(procs): """ Terminate all processes in the process dictionary """ logging.warn("Stopping all remaining processes") for proc, g in procs.values(): logging.debug("[%s] SIGTERM", proc.pid) try: proc.terminate() except OSError as e: # ...
[ "def", "_terminate_procs", "(", "procs", ")", ":", "logging", ".", "warn", "(", "\"Stopping all remaining processes\"", ")", "for", "proc", ",", "g", "in", "procs", ".", "values", "(", ")", ":", "logging", ".", "debug", "(", "\"[%s] SIGTERM\"", ",", "proc", ...
31.642857
0.002193
def values(self, predicate=None): """ Returns a list clone of the values contained in this map or values of the entries which are filtered with the predicate if provided. **Warning: The list is NOT backed by the map, so changes to the map are NOT reflected in the list, and ...
[ "def", "values", "(", "self", ",", "predicate", "=", "None", ")", ":", "if", "predicate", ":", "predicate_data", "=", "self", ".", "_to_data", "(", "predicate", ")", "return", "self", ".", "_encode_invoke", "(", "map_values_with_predicate_codec", ",", "predica...
44.684211
0.009227
def clear_state(self, activity, agent, registration=None): """Clear state(s) with specified activity and agent :param activity: Activity object of state(s) to be deleted :type activity: :class:`tincan.activity.Activity` :param agent: Agent object of state(s) to be deleted :type ...
[ "def", "clear_state", "(", "self", ",", "activity", ",", "agent", ",", "registration", "=", "None", ")", ":", "return", "self", ".", "_delete_state", "(", "activity", "=", "activity", ",", "agent", "=", "agent", ",", "registration", "=", "registration", ")...
41.058824
0.002801
def register_rpc(name=None): """Decorator. Allows registering a function for RPC. * http://uwsgi.readthedocs.io/en/latest/RPC.html Example: .. code-block:: python @register_rpc() def expose_me(): do() :param str|unicode name: RPC function name to ass...
[ "def", "register_rpc", "(", "name", "=", "None", ")", ":", "def", "wrapper", "(", "func", ")", ":", "func_name", "=", "func", ".", "__name__", "rpc_name", "=", "name", "or", "func_name", "uwsgi", ".", "register_rpc", "(", "rpc_name", ",", "func", ")", ...
20.966667
0.00304
def find_project(self): # type: () -> List[str] """ Get all candidate projects :return: """ folders = [f for f in os.listdir(".") if os.path.isdir(f)] candidates = [] setup = self.setup_py_source() for folder in folders: if os.path.isfile(fol...
[ "def", "find_project", "(", "self", ")", ":", "# type: () -> List[str]", "folders", "=", "[", "f", "for", "f", "in", "os", ".", "listdir", "(", "\".\"", ")", "if", "os", ".", "path", ".", "isdir", "(", "f", ")", "]", "candidates", "=", "[", "]", "s...
34.3125
0.001328
def filter(self, query: Query, entity: type) -> Tuple[Query, Any]: """Apply the `_method` to all childs of the node. :param query: The sqlachemy query. :type query: Query :param entity: The entity model of the query. :type entity: type :return: A tuple with in ...
[ "def", "filter", "(", "self", ",", "query", ":", "Query", ",", "entity", ":", "type", ")", "->", "Tuple", "[", "Query", ",", "Any", "]", ":", "new_query", "=", "query", "c_filter_list", "=", "[", "]", "for", "child", "in", "self", ".", "_childs", "...
33.318182
0.003979
def get_modified_date(parsed, raw): 'Return best possible guess to post modification timestamp.' if parsed: return feedparser_ts(parsed) if not raw: return None # Parse weird timestamps that feedparser can't handle, e.g.: July 30, 2013 ts, val = None, raw.replace('_', ' ') if not ts: # coreutils' "date" parses...
[ "def", "get_modified_date", "(", "parsed", ",", "raw", ")", ":", "if", "parsed", ":", "return", "feedparser_ts", "(", "parsed", ")", "if", "not", "raw", ":", "return", "None", "# Parse weird timestamps that feedparser can't handle, e.g.: July 30, 2013", "ts", ",", "...
41.882353
0.026099
def np(numpy_feval, name=None, allow_extra_outputs=False): """Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy a...
[ "def", "np", "(", "numpy_feval", ",", "name", "=", "None", ",", "allow_extra_outputs", "=", "False", ")", ":", "def", "feval", "(", "label", ",", "pred", ")", ":", "\"\"\"Internal eval function.\"\"\"", "return", "numpy_feval", "(", "label", ",", "pred", ")"...
37.8125
0.004835
def _set_hundredgigabitethernet(self, v, load=False): """ Setter method for hundredgigabitethernet, mapped from YANG variable /interface/hundredgigabitethernet (list) If this variable is read-only (config: false) in the source YANG file, then _set_hundredgigabitethernet is considered as a private me...
[ "def", "_set_hundredgigabitethernet", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ...
145.870968
0.002636
def tokenize_words(self, text): """Tokenize an input string into a list of words (with punctuation removed).""" return [ self.strip_punctuation(word) for word in text.split(' ') if self.strip_punctuation(word) ]
[ "def", "tokenize_words", "(", "self", ",", "text", ")", ":", "return", "[", "self", ".", "strip_punctuation", "(", "word", ")", "for", "word", "in", "text", ".", "split", "(", "' '", ")", "if", "self", ".", "strip_punctuation", "(", "word", ")", "]" ]
42.333333
0.011583
def get(self): """ :return: response stats dict """ stats = {} if self.start_date is not None: stats["start_date"] = self.start_date if self.end_date is not None: stats["end_date"] = self.end_date if self.aggregated_by is not None: ...
[ "def", "get", "(", "self", ")", ":", "stats", "=", "{", "}", "if", "self", ".", "start_date", "is", "not", "None", ":", "stats", "[", "\"start_date\"", "]", "=", "self", ".", "start_date", "if", "self", ".", "end_date", "is", "not", "None", ":", "s...
38.695652
0.002193
def submit_registration_form(self, form): """Submit a registration form. [client only] :Parameters: - `form`: the filled-in form. When form is `None` or its type is "cancel" the registration is to be canceled. :Types: - `form`: `pyxmpp.jabber.data...
[ "def", "submit_registration_form", "(", "self", ",", "form", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "try", ":", "if", "form", "and", "form", ".", "type", "!=", "\"cancel\"", ":", "self", ".", "registration_form", "=", "form", "iq", "=...
34.347826
0.007389
def sendall(self, s): """ Send data to the channel, without allowing partial results. Unlike `send`, this method continues to send data from the given string until either all data has been sent or an error occurs. Nothing is returned. :param str s: data to send. :rais...
[ "def", "sendall", "(", "self", ",", "s", ")", ":", "while", "s", ":", "sent", "=", "self", ".", "send", "(", "s", ")", "s", "=", "s", "[", "sent", ":", "]", "return", "None" ]
38.363636
0.002312
def parse_coach_bsites_inf(infile): """Parse the Bsites.inf output file of COACH and return a list of rank-ordered binding site predictions Bsites.inf contains the summary of COACH clustering results after all other prediction algorithms have finished For each site (cluster), there are three lines: ...
[ "def", "parse_coach_bsites_inf", "(", "infile", ")", ":", "bsites_results", "=", "[", "]", "with", "open", "(", "infile", ")", "as", "pp", ":", "lines", "=", "list", "(", "filter", "(", "None", ",", "(", "line", ".", "rstrip", "(", ")", "for", "line"...
44.859155
0.004916
def SampleSum(dists, n): """Draws a sample of sums from a list of distributions. dists: sequence of Pmf or Cdf objects n: sample size returns: new Pmf of sums """ pmf = MakePmfFromList(RandomSum(dists) for i in xrange(n)) return pmf
[ "def", "SampleSum", "(", "dists", ",", "n", ")", ":", "pmf", "=", "MakePmfFromList", "(", "RandomSum", "(", "dists", ")", "for", "i", "in", "xrange", "(", "n", ")", ")", "return", "pmf" ]
25.3
0.003817
def download_s3(bucket_name, file_key, file_path, force=False): """Download a remote file from S3. """ file_path = path(file_path) bucket = open_s3(bucket_name) file_dir = file_path.dirname() file_dir.makedirs() s3_key = bucket.get_key(file_key) if file_path.exists(): file_data...
[ "def", "download_s3", "(", "bucket_name", ",", "file_key", ",", "file_path", ",", "force", "=", "False", ")", ":", "file_path", "=", "path", "(", "file_path", ")", "bucket", "=", "open_s3", "(", "bucket_name", ")", "file_dir", "=", "file_path", ".", "dirna...
33.833333
0.002736
def quick_url(comment): """Return the URL for the comment without fetching its submission.""" def to_id(fullname): return fullname.split('_', 1)[1] return ('http://www.reddit.com/r/{}/comments/{}/_/{}?context=3' .format(comment.subreddit.display_name, to_id(comment.link_id), ...
[ "def", "quick_url", "(", "comment", ")", ":", "def", "to_id", "(", "fullname", ")", ":", "return", "fullname", ".", "split", "(", "'_'", ",", "1", ")", "[", "1", "]", "return", "(", "'http://www.reddit.com/r/{}/comments/{}/_/{}?context=3'", ".", "format", "(...
47.714286
0.002941
def safe_joinall(greenlets, timeout=None, raise_error=False): """ Wrapper for gevent.joinall if the greenlet that waits for the joins is killed, it kills all the greenlets it joins for. """ greenlets = list(greenlets) try: gevent.joinall(greenlets, timeout=timeout, raise_error=raise_erro...
[ "def", "safe_joinall", "(", "greenlets", ",", "timeout", "=", "None", ",", "raise_error", "=", "False", ")", ":", "greenlets", "=", "list", "(", "greenlets", ")", "try", ":", "gevent", ".", "joinall", "(", "greenlets", ",", "timeout", "=", "timeout", ","...
37.833333
0.004301
def setup_versioneer(): """ Generate (temporarily) versioneer.py file in project root directory :return: """ try: # assume versioneer.py was generated using "versioneer install" command import versioneer versioneer.get_version() except ImportError: # it looks vers...
[ "def", "setup_versioneer", "(", ")", ":", "try", ":", "# assume versioneer.py was generated using \"versioneer install\" command", "import", "versioneer", "versioneer", ".", "get_version", "(", ")", "except", "ImportError", ":", "# it looks versioneer.py is missing", "# lets as...
43.906977
0.000518
def update(self, dtrain, iteration, fobj=None): """ Update for one iteration, with objective function calculated internally. Parameters ---------- dtrain : DMatrix Training data. iteration : int Current iteration number. fobj : function ...
[ "def", "update", "(", "self", ",", "dtrain", ",", "iteration", ",", "fobj", "=", "None", ")", ":", "if", "not", "isinstance", "(", "dtrain", ",", "DMatrix", ")", ":", "raise", "TypeError", "(", "'invalid training matrix: {}'", ".", "format", "(", "type", ...
34
0.006219
def _get_encrypted_credentials(self, context): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 5 https://msdn.microsoft.com/en-us/library/cc226791.aspx After the client has verified the server's authenticity, it encrypts the user's credentials with the authenti...
[ "def", "_get_encrypted_credentials", "(", "self", ",", "context", ")", ":", "ts_password", "=", "TSPasswordCreds", "(", ")", "ts_password", "[", "'domainName'", "]", "=", "context", ".", "domain", ".", "encode", "(", "'utf-16-le'", ")", "ts_password", "[", "'u...
45.107143
0.00155
def _exponentiate_general_case(pauli_term, param): """ Returns a Quil (Program()) object corresponding to the exponential of the pauli_term object, i.e. exp[-1.0j * param * pauli_term] :param PauliTerm pauli_term: A PauliTerm to exponentiate :param float param: scalar, non-complex, value :retur...
[ "def", "_exponentiate_general_case", "(", "pauli_term", ",", "param", ")", ":", "def", "reverse_hack", "(", "p", ")", ":", "# A hack to produce a *temporary* program which reverses p.", "revp", "=", "Program", "(", ")", "revp", ".", "inst", "(", "list", "(", "reve...
29.54
0.001311
def _check_disabled(self): """Check if health check is disabled. It logs a message if health check is disabled and it also adds an item to the action queue based on 'on_disabled' setting. Returns: True if check is disabled otherwise False. """ if self.confi...
[ "def", "_check_disabled", "(", "self", ")", ":", "if", "self", ".", "config", "[", "'check_disabled'", "]", ":", "if", "self", ".", "config", "[", "'on_disabled'", "]", "==", "'withdraw'", ":", "self", ".", "log", ".", "info", "(", "\"Check is disabled and...
41.269231
0.001821
def set_(key, value, setting=None, conf_file=_DEFAULT_CONF): ''' Set a new value for a specific configuration line. :param str key: The command or block to configure. :param str value: The command value or command of the block specified by the key parameter. :param str setting: The command value fo...
[ "def", "set_", "(", "key", ",", "value", ",", "setting", "=", "None", ",", "conf_file", "=", "_DEFAULT_CONF", ")", ":", "conf", "=", "_parse_conf", "(", "conf_file", ")", "for", "include", "in", "conf", "[", "'include files'", "]", ":", "if", "key", "i...
30.089109
0.001274
def sort(self, *args, **kwargs): """Sort the MultiMap. Takes the same arguments as list.sort, and operates on tuples of (key, value) pairs. >>> m = MutableMultiMap() >>> m['c'] = 1 >>> m['b'] = 3 >>> m['a'] = 2 >>> m.sort() >>> m....
[ "def", "sort", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_pairs", ".", "sort", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "_rebuild_key_ids", "(", ")" ]
25.5
0.009452
def uninstall(**kwargs): """Uninstall the current pre-commit hook.""" force = kwargs.get('force') restore_legacy = kwargs.get('restore_legacy') colorama.init(strip=kwargs.get('no_color')) git_dir = current_git_dir() if git_dir is None: output(NOT_GIT_REPO_MSG) exit(1) hoo...
[ "def", "uninstall", "(", "*", "*", "kwargs", ")", ":", "force", "=", "kwargs", ".", "get", "(", "'force'", ")", "restore_legacy", "=", "kwargs", ".", "get", "(", "'restore_legacy'", ")", "colorama", ".", "init", "(", "strip", "=", "kwargs", ".", "get",...
32
0.001784
def main(): """ The main function of the Andes command-line tool. This function executes the following workflow: * Parse the command line inputs * Show the tool preamble * Output the requested helps, edit/save configs or remove outputs. Exit the main program if any of the above is ex...
[ "def", "main", "(", ")", ":", "t0", ",", "s", "=", "elapsed", "(", ")", "# parser command line arguments", "args", "=", "vars", "(", "cli_new", "(", ")", ")", "# configure stream handler verbose level", "config_logger", "(", "log_path", "=", "misc", ".", "get_...
29.027778
0.000925
def _move_here(self): """Move the cursor to this item.""" cu = self.scraper.current_item # Already here? if self is cu: return # A child? if cu.items and self in cu.items: self.scraper.move_to(self) return # A parent? if...
[ "def", "_move_here", "(", "self", ")", ":", "cu", "=", "self", ".", "scraper", ".", "current_item", "# Already here?", "if", "self", "is", "cu", ":", "return", "# A child?", "if", "cu", ".", "items", "and", "self", "in", "cu", ".", "items", ":", "self"...
31.272727
0.002821
def do_up(self, arg): """Run up migration with name or numeric id matching arg""" print "running up migration" self.manager.run(arg, Direction.UP)
[ "def", "do_up", "(", "self", ",", "arg", ")", ":", "print", "\"running up migration\"", "self", ".", "manager", ".", "run", "(", "arg", ",", "Direction", ".", "UP", ")" ]
41.75
0.011765
def modified(self, base: pathlib.PurePath = pathlib.PurePath()) \ -> Iterator[str]: """ Find the paths of modified files. There is no option to include intermediate directories, as all files and directories exist in both the left and right trees. :param base: The bas...
[ "def", "modified", "(", "self", ",", "base", ":", "pathlib", ".", "PurePath", "=", "pathlib", ".", "PurePath", "(", ")", ")", "->", "Iterator", "[", "str", "]", ":", "# N.B. this method will only ever return files, as directories cannot", "# be \"modified\"", "if", ...
41.8
0.00312
def get_all( self, target_resource=None, target_resource_group=None, target_resource_type=None, monitor_service=None, monitor_condition=None, severity=None, smart_group_state=None, time_range=None, page_count=None, sort_by=None, sort_order=None, custom_headers=None, raw=False, **operation_config): "...
[ "def", "get_all", "(", "self", ",", "target_resource", "=", "None", ",", "target_resource_group", "=", "None", ",", "target_resource_type", "=", "None", ",", "monitor_service", "=", "None", ",", "monitor_condition", "=", "None", ",", "severity", "=", "None", "...
55.874016
0.002354
def random_outdir(): # type: () -> Text """ Return the random directory name chosen to use for tool / workflow output """ # compute this once and store it as a function attribute - each subsequent call will return the same value if not hasattr(random_outdir, 'outdir'): random_outdir.outdir = '/' + ...
[ "def", "random_outdir", "(", ")", ":", "# type: () -> Text", "# compute this once and store it as a function attribute - each subsequent call will return the same value", "if", "not", "hasattr", "(", "random_outdir", ",", "'outdir'", ")", ":", "random_outdir", ".", "outdir", "=...
72.666667
0.00907