repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
gholt/swiftly
swiftly/client/client.py
https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/client/client.py#L457-L486
def put_container(self, container, headers=None, query=None, cdn=False, body=None): """ PUTs the container and returns the results. This is usually done to create new containers and can also be used to set X-Container-Meta-xxx headers. Note that if the container ...
[ "def", "put_container", "(", "self", ",", "container", ",", "headers", "=", "None", ",", "query", "=", "None", ",", "cdn", "=", "False", ",", "body", "=", "None", ")", ":", "path", "=", "self", ".", "_container_path", "(", "container", ")", "return", ...
PUTs the container and returns the results. This is usually done to create new containers and can also be used to set X-Container-Meta-xxx headers. Note that if the container already exists, any existing X-Container-Meta-xxx headers will remain untouched. To remove an X-Container-Meta-xx...
[ "PUTs", "the", "container", "and", "returns", "the", "results", ".", "This", "is", "usually", "done", "to", "create", "new", "containers", "and", "can", "also", "be", "used", "to", "set", "X", "-", "Container", "-", "Meta", "-", "xxx", "headers", ".", ...
python
test
49.433333
MartinThoma/hwrt
hwrt/datasets/crohme_convert.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/datasets/crohme_convert.py#L58-L75
def read_folder(folder): """ Parameters ---------- folder : str Returns ------- list of HandwrittenData objects """ hwr_objects = [] for filepath in natsort.natsorted(glob.glob("%s/*.inkml" % folder)): tmp = inkml.read(filepath) for hwr in tmp.to_single_symbol_li...
[ "def", "read_folder", "(", "folder", ")", ":", "hwr_objects", "=", "[", "]", "for", "filepath", "in", "natsort", ".", "natsorted", "(", "glob", ".", "glob", "(", "\"%s/*.inkml\"", "%", "folder", ")", ")", ":", "tmp", "=", "inkml", ".", "read", "(", "...
Parameters ---------- folder : str Returns ------- list of HandwrittenData objects
[ "Parameters", "----------", "folder", ":", "str" ]
python
train
24.555556
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_qos.py#L719-L731
def qos_queue_scheduler_strict_priority_dwrr_traffic_class_last(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") qos = ET.SubElement(config, "qos", xmlns="urn:brocade.com:mgmt:brocade-qos") queue = ET.SubElement(qos, "queue") scheduler = ET.SubEle...
[ "def", "qos_queue_scheduler_strict_priority_dwrr_traffic_class_last", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "qos", "=", "ET", ".", "SubElement", "(", "config", ",", "\"qos\"", ",", "xmlns",...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
50.923077
AlecAivazis/graphql-over-kafka
nautilus/conventions/api.py
https://github.com/AlecAivazis/graphql-over-kafka/blob/70e2acef27a2f87355590be1a6ca60ce3ab4d09c/nautilus/conventions/api.py#L134-L147
def _summarize_o_mutation_type(model): """ This function create the actual mutation io summary corresponding to the model """ from nautilus.api.util import summarize_mutation_io # compute the appropriate name for the object object_type_name = get_model_string(model) # return a mutation ...
[ "def", "_summarize_o_mutation_type", "(", "model", ")", ":", "from", "nautilus", ".", "api", ".", "util", "import", "summarize_mutation_io", "# compute the appropriate name for the object", "object_type_name", "=", "get_model_string", "(", "model", ")", "# return a mutation...
This function create the actual mutation io summary corresponding to the model
[ "This", "function", "create", "the", "actual", "mutation", "io", "summary", "corresponding", "to", "the", "model" ]
python
train
32.428571
dpkp/kafka-python
kafka/producer/sender.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/producer/sender.py#L255-L261
def _can_retry(self, batch, error): """ We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed """ return (batch.attempts < self.config['retries'] and getattr(error, 'retriable', False))
[ "def", "_can_retry", "(", "self", ",", "batch", ",", "error", ")", ":", "return", "(", "batch", ".", "attempts", "<", "self", ".", "config", "[", "'retries'", "]", "and", "getattr", "(", "error", ",", "'retriable'", ",", "False", ")", ")" ]
We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed
[ "We", "can", "retry", "a", "send", "if", "the", "error", "is", "transient", "and", "the", "number", "of", "attempts", "taken", "is", "fewer", "than", "the", "maximum", "allowed" ]
python
train
42
blockcypher/blockcypher-python
blockcypher/api.py
https://github.com/blockcypher/blockcypher-python/blob/7601ea21916957ff279384fd699527ff9c28a56e/blockcypher/api.py#L641-L646
def get_merkle_root(block_representation, coin_symbol='btc', api_key=None): ''' Takes a block_representation and returns the merkle root ''' return get_block_overview(block_representation=block_representation, coin_symbol=coin_symbol, txn_limit=1, api_key=api_key)['mrkl_root']
[ "def", "get_merkle_root", "(", "block_representation", ",", "coin_symbol", "=", "'btc'", ",", "api_key", "=", "None", ")", ":", "return", "get_block_overview", "(", "block_representation", "=", "block_representation", ",", "coin_symbol", "=", "coin_symbol", ",", "tx...
Takes a block_representation and returns the merkle root
[ "Takes", "a", "block_representation", "and", "returns", "the", "merkle", "root" ]
python
train
50
zarr-developers/zarr
zarr/convenience.py
https://github.com/zarr-developers/zarr/blob/fb8e6d5ea6bc26e451e5cf0eaaee36977556d5b5/zarr/convenience.py#L105-L143
def save_array(store, arr, **kwargs): """Convenience function to save a NumPy array to the local file system, following a similar API to the NumPy save() function. Parameters ---------- store : MutableMapping or string Store or path to directory in file system or name of zip file. arr :...
[ "def", "save_array", "(", "store", ",", "arr", ",", "*", "*", "kwargs", ")", ":", "may_need_closing", "=", "isinstance", "(", "store", ",", "str", ")", "store", "=", "normalize_store_arg", "(", "store", ",", "clobber", "=", "True", ")", "try", ":", "_c...
Convenience function to save a NumPy array to the local file system, following a similar API to the NumPy save() function. Parameters ---------- store : MutableMapping or string Store or path to directory in file system or name of zip file. arr : ndarray NumPy array with data to sav...
[ "Convenience", "function", "to", "save", "a", "NumPy", "array", "to", "the", "local", "file", "system", "following", "a", "similar", "API", "to", "the", "NumPy", "save", "()", "function", "." ]
python
train
33.74359
angr/claripy
claripy/vsa/strided_interval.py
https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/vsa/strided_interval.py#L2565-L2611
def sign_extend(self, new_length): """ Unary operation: SignExtend :param new_length: New length after sign-extension :return: A new StridedInterval """ msb = self.extract(self.bits - 1, self.bits - 1).eval(2) if msb == [ 0 ]: # All positive numbers ...
[ "def", "sign_extend", "(", "self", ",", "new_length", ")", ":", "msb", "=", "self", ".", "extract", "(", "self", ".", "bits", "-", "1", ",", "self", ".", "bits", "-", "1", ")", ".", "eval", "(", "2", ")", "if", "msb", "==", "[", "0", "]", ":"...
Unary operation: SignExtend :param new_length: New length after sign-extension :return: A new StridedInterval
[ "Unary", "operation", ":", "SignExtend" ]
python
train
34.978723
latchset/jwcrypto
jwcrypto/jws.py
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L156-L167
def verify(self, signature): """Verifies a signature :raises InvalidJWSSignature: if the verification fails. """ try: payload = self._payload() sigin = b'.'.join([self.protected.encode('utf-8'), payload]) self.engine.verify(self.key, sigin, signature)...
[ "def", "verify", "(", "self", ",", "signature", ")", ":", "try", ":", "payload", "=", "self", ".", "_payload", "(", ")", "sigin", "=", "b'.'", ".", "join", "(", "[", "self", ".", "protected", ".", "encode", "(", "'utf-8'", ")", ",", "payload", "]",...
Verifies a signature :raises InvalidJWSSignature: if the verification fails.
[ "Verifies", "a", "signature" ]
python
train
38.5
cons3rt/pycons3rt
pycons3rt/slack.py
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/slack.py#L293-L340
def main(): """Handles external calling for this module Execute this python module and provide the args shown below to external call this module to send Slack messages with attachments! :return: None """ log = logging.getLogger(mod_logger + '.main') parser = argparse.ArgumentParser(descrip...
[ "def", "main", "(", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "mod_logger", "+", "'.main'", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'This Python module allows '", "'sending Slack messages.'", ")", "parser", ...
Handles external calling for this module Execute this python module and provide the args shown below to external call this module to send Slack messages with attachments! :return: None
[ "Handles", "external", "calling", "for", "this", "module" ]
python
train
43.645833
nugget/python-anthemav
anthemav/protocol.py
https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L122-L136
def poweron_refresh(self): """Keep requesting all attributes until it works. Immediately after a power on event (POW1) the AVR is inconsistent with which attributes can be successfully queried. When we detect that power has just been turned on, we loop every second making a bulk ...
[ "def", "poweron_refresh", "(", "self", ")", ":", "if", "self", ".", "_poweron_refresh_successful", ":", "return", "else", ":", "self", ".", "refresh_all", "(", ")", "self", ".", "_loop", ".", "call_later", "(", "2", ",", "self", ".", "poweron_refresh", ")"...
Keep requesting all attributes until it works. Immediately after a power on event (POW1) the AVR is inconsistent with which attributes can be successfully queried. When we detect that power has just been turned on, we loop every second making a bulk query for every known attribute. Th...
[ "Keep", "requesting", "all", "attributes", "until", "it", "works", "." ]
python
train
45.4
johnwmillr/LyricsGenius
lyricsgenius/song.py
https://github.com/johnwmillr/LyricsGenius/blob/e36482f7c42235037f3b9b7013edcd54141124e3/lyricsgenius/song.py#L100-L149
def save_lyrics(self, filename=None, extension='json', verbose=True, overwrite=None, binary_encoding=False): """Allows user to save song lyrics from Song object to a .json or .txt file.""" extension = extension.lstrip(".") assert (extension == 'json') or (extension == 'txt'),...
[ "def", "save_lyrics", "(", "self", ",", "filename", "=", "None", ",", "extension", "=", "'json'", ",", "verbose", "=", "True", ",", "overwrite", "=", "None", ",", "binary_encoding", "=", "False", ")", ":", "extension", "=", "extension", ".", "lstrip", "(...
Allows user to save song lyrics from Song object to a .json or .txt file.
[ "Allows", "user", "to", "save", "song", "lyrics", "from", "Song", "object", "to", "a", ".", "json", "or", ".", "txt", "file", "." ]
python
train
40.88
lehins/django-smartfields
smartfields/managers.py
https://github.com/lehins/django-smartfields/blob/23d4b0b18352f4f40ce8c429735e673ba5191502/smartfields/managers.py#L193-L201
def get_status(self, instance): """Retrives a status of a field from cache. Fields in state 'error' and 'complete' will not retain the status after the call. """ status_key, status = self._get_status(instance) if status['state'] in ['complete', 'error']: cache.delete...
[ "def", "get_status", "(", "self", ",", "instance", ")", ":", "status_key", ",", "status", "=", "self", ".", "_get_status", "(", "instance", ")", "if", "status", "[", "'state'", "]", "in", "[", "'complete'", ",", "'error'", "]", ":", "cache", ".", "dele...
Retrives a status of a field from cache. Fields in state 'error' and 'complete' will not retain the status after the call.
[ "Retrives", "a", "status", "of", "a", "field", "from", "cache", ".", "Fields", "in", "state", "error", "and", "complete", "will", "not", "retain", "the", "status", "after", "the", "call", "." ]
python
train
38.444444
peterjc/flake8-rst-docstrings
flake8_rst_docstrings.py
https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L727-L760
def parse_all(self): """Parse the __all__ definition in a module.""" assert self.current.value == "__all__" self.consume(tk.NAME) if self.current.value != "=": raise AllError("Could not evaluate contents of __all__. ") self.consume(tk.OP) if self.current.value...
[ "def", "parse_all", "(", "self", ")", ":", "assert", "self", ".", "current", ".", "value", "==", "\"__all__\"", "self", ".", "consume", "(", "tk", ".", "NAME", ")", "if", "self", ".", "current", ".", "value", "!=", "\"=\"", ":", "raise", "AllError", ...
Parse the __all__ definition in a module.
[ "Parse", "the", "__all__", "definition", "in", "a", "module", "." ]
python
valid
38.147059
ynop/audiomate
audiomate/utils/units.py
https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/utils/units.py#L117-L124
def frame_to_sample(self, frame_index): """ Return a tuple containing the indices of the sample which are the first sample and the end (exclusive) of the frame with the given index. """ start = frame_index * self.hop_size end = start + self.frame_size return start...
[ "def", "frame_to_sample", "(", "self", ",", "frame_index", ")", ":", "start", "=", "frame_index", "*", "self", ".", "hop_size", "end", "=", "start", "+", "self", ".", "frame_size", "return", "start", ",", "end" ]
Return a tuple containing the indices of the sample which are the first sample and the end (exclusive) of the frame with the given index.
[ "Return", "a", "tuple", "containing", "the", "indices", "of", "the", "sample", "which", "are", "the", "first", "sample", "and", "the", "end", "(", "exclusive", ")", "of", "the", "frame", "with", "the", "given", "index", "." ]
python
train
39.75
idank/bashlex
bashlex/parser.py
https://github.com/idank/bashlex/blob/800cb7e3c634eaa3c81f8a8648fd7fd4e27050ac/bashlex/parser.py#L148-L161
def p_simple_command_element(p): '''simple_command_element : WORD | ASSIGNMENT_WORD | redirection''' if isinstance(p[1], ast.node): p[0] = [p[1]] return parserobj = p.context p[0] = [_expandword(parserobj, p.slice[1])] # c...
[ "def", "p_simple_command_element", "(", "p", ")", ":", "if", "isinstance", "(", "p", "[", "1", "]", ",", "ast", ".", "node", ")", ":", "p", "[", "0", "]", "=", "[", "p", "[", "1", "]", "]", "return", "parserobj", "=", "p", ".", "context", "p", ...
simple_command_element : WORD | ASSIGNMENT_WORD | redirection
[ "simple_command_element", ":", "WORD", "|", "ASSIGNMENT_WORD", "|", "redirection" ]
python
train
32.571429
PmagPy/PmagPy
pmagpy/ipmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/ipmag.py#L7097-L7456
def pmag_results_extract(res_file="pmag_results.txt", crit_file="", spec_file="", age_file="", latex=False, grade=False, WD="."): """ Generate tab delimited output file(s) with result data. Save output files and return True if successful. Possible output files: Directions, Inten...
[ "def", "pmag_results_extract", "(", "res_file", "=", "\"pmag_results.txt\"", ",", "crit_file", "=", "\"\"", ",", "spec_file", "=", "\"\"", ",", "age_file", "=", "\"\"", ",", "latex", "=", "False", ",", "grade", "=", "False", ",", "WD", "=", "\".\"", ")", ...
Generate tab delimited output file(s) with result data. Save output files and return True if successful. Possible output files: Directions, Intensities, SiteNfo, Criteria, Specimens Optional Parameters (defaults are used if not specified) ---------- res_file : name of pma...
[ "Generate", "tab", "delimited", "output", "file", "(", "s", ")", "with", "result", "data", ".", "Save", "output", "files", "and", "return", "True", "if", "successful", ".", "Possible", "output", "files", ":", "Directions", "Intensities", "SiteNfo", "Criteria",...
python
train
45.894444
lrq3000/pyFileFixity
pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/sortedcontainers/sortedlistwithkey.py#L178-L214
def discard(self, val): """ Remove the first occurrence of *val*. If *val* is not a member, does nothing. """ _maxes = self._maxes if not _maxes: return key = self._key(val) pos = bisect_left(_maxes, key) if pos == len(_maxes): ...
[ "def", "discard", "(", "self", ",", "val", ")", ":", "_maxes", "=", "self", ".", "_maxes", "if", "not", "_maxes", ":", "return", "key", "=", "self", ".", "_key", "(", "val", ")", "pos", "=", "bisect_left", "(", "_maxes", ",", "key", ")", "if", "p...
Remove the first occurrence of *val*. If *val* is not a member, does nothing.
[ "Remove", "the", "first", "occurrence", "of", "*", "val", "*", "." ]
python
train
23.405405
aleju/imgaug
imgaug/augmentables/heatmaps.py
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/heatmaps.py#L556-L566
def deepcopy(self): """ Create a deep copy of the Heatmaps object. Returns ------- imgaug.HeatmapsOnImage Deep copy. """ return HeatmapsOnImage(self.get_arr(), shape=self.shape, min_value=self.min_value, max_value=self.max_value)
[ "def", "deepcopy", "(", "self", ")", ":", "return", "HeatmapsOnImage", "(", "self", ".", "get_arr", "(", ")", ",", "shape", "=", "self", ".", "shape", ",", "min_value", "=", "self", ".", "min_value", ",", "max_value", "=", "self", ".", "max_value", ")"...
Create a deep copy of the Heatmaps object. Returns ------- imgaug.HeatmapsOnImage Deep copy.
[ "Create", "a", "deep", "copy", "of", "the", "Heatmaps", "object", "." ]
python
valid
26.272727
biocore/burrito-fillings
bfillings/seqprep.py
https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/seqprep.py#L135-L143
def _unassembled_reads2_out_file_name(self): """Checks if file name is set for reads2 output. Returns absolute path.""" if self.Parameters['-2'].isOn(): unassembled_reads2 = self._absolute( str(self.Parameters['-2'].Value)) else: raise ValueErro...
[ "def", "_unassembled_reads2_out_file_name", "(", "self", ")", ":", "if", "self", ".", "Parameters", "[", "'-2'", "]", ".", "isOn", "(", ")", ":", "unassembled_reads2", "=", "self", ".", "_absolute", "(", "str", "(", "self", ".", "Parameters", "[", "'-2'", ...
Checks if file name is set for reads2 output. Returns absolute path.
[ "Checks", "if", "file", "name", "is", "set", "for", "reads2", "output", ".", "Returns", "absolute", "path", "." ]
python
train
43.555556
pseudonym117/Riot-Watcher
src/riotwatcher/_apis/MatchApiV4.py
https://github.com/pseudonym117/Riot-Watcher/blob/21ab12453a0d824d67e30f5514d02a5c5a411dea/src/riotwatcher/_apis/MatchApiV4.py#L32-L88
def matchlist_by_account( self, region, encrypted_account_id, queue=None, begin_time=None, end_time=None, begin_index=None, end_index=None, season=None, champion=None, ): """ Get matchlist for ranked games played on give...
[ "def", "matchlist_by_account", "(", "self", ",", "region", ",", "encrypted_account_id", ",", "queue", "=", "None", ",", "begin_time", "=", "None", ",", "end_time", "=", "None", ",", "begin_index", "=", "None", ",", "end_index", "=", "None", ",", "season", ...
Get matchlist for ranked games played on given account ID and platform ID and filtered using given filter parameters, if any A number of optional parameters are provided for filtering. It is up to the caller to ensure that the combination of filter parameters provided is valid for the requested...
[ "Get", "matchlist", "for", "ranked", "games", "played", "on", "given", "account", "ID", "and", "platform", "ID", "and", "filtered", "using", "given", "filter", "parameters", "if", "any" ]
python
train
44.947368
pywbem/pywbem
pywbem/cim_obj.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem/cim_obj.py#L2865-L2875
def iteritems(self): """ Iterate through the property names and values of this CIM instance. Each iteration item is a tuple of the property name (in the original lexical case) and the property value. The order of properties is preserved. """ for key, val in self...
[ "def", "iteritems", "(", "self", ")", ":", "for", "key", ",", "val", "in", "self", ".", "properties", ".", "iteritems", "(", ")", ":", "yield", "(", "key", ",", "val", ".", "value", ")" ]
Iterate through the property names and values of this CIM instance. Each iteration item is a tuple of the property name (in the original lexical case) and the property value. The order of properties is preserved.
[ "Iterate", "through", "the", "property", "names", "and", "values", "of", "this", "CIM", "instance", "." ]
python
train
33.545455
mozilla/treeherder
treeherder/client/thclient/client.py
https://github.com/mozilla/treeherder/blob/cc47bdec872e5c668d0f01df89517390a164cda3/treeherder/client/thclient/client.py#L142-L149
def get_jobs(self, project, **params): """ Gets jobs from project, filtered by parameters :param project: project (repository name) to query data for :param params: keyword arguments to filter results """ return self._get_json_list(self.JOBS_ENDPOINT, project, **params)
[ "def", "get_jobs", "(", "self", ",", "project", ",", "*", "*", "params", ")", ":", "return", "self", ".", "_get_json_list", "(", "self", ".", "JOBS_ENDPOINT", ",", "project", ",", "*", "*", "params", ")" ]
Gets jobs from project, filtered by parameters :param project: project (repository name) to query data for :param params: keyword arguments to filter results
[ "Gets", "jobs", "from", "project", "filtered", "by", "parameters" ]
python
train
39
sassoftware/saspy
saspy/sasViyaML.py
https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasViyaML.py#L122-L146
def fastknn(self, data: ['SASdata', str] = None, display: str = None, displayout: str = None, id: str = None, input: [str, list, dict] = None, output: [str, bool, 'SASdata'] = None, procopts: str = None, stmt...
[ "def", "fastknn", "(", "self", ",", "data", ":", "[", "'SASdata'", ",", "str", "]", "=", "None", ",", "display", ":", "str", "=", "None", ",", "displayout", ":", "str", "=", "None", ",", "id", ":", "str", "=", "None", ",", "input", ":", "[", "s...
Python method to call the FASTKNN procedure Documentation link: https://go.documentation.sas.com/?docsetId=casml&docsetTarget=casml_fastknn_toc.htm&docsetVersion=8.3&locale=en :param data: SASdata object or string. This parameter is required. :parm display: The display variable can onl...
[ "Python", "method", "to", "call", "the", "FASTKNN", "procedure" ]
python
train
57.2
bwohlberg/sporco
sporco/admm/cbpdntv.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/admm/cbpdntv.py#L511-L518
def cnst_AT(self, X): r"""Compute :math:`A^T \mathbf{x}` where :math:`A \mathbf{x}` is a component of ADMM problem constraint. In this case :math:`A^T \mathbf{x} = (\Gamma_0^T \;\; \Gamma_1^T \;\; \ldots \;\; I) \mathbf{x}`. """ return np.sum(self.cnst_A0T(X), axis=-1) +...
[ "def", "cnst_AT", "(", "self", ",", "X", ")", ":", "return", "np", ".", "sum", "(", "self", ".", "cnst_A0T", "(", "X", ")", ",", "axis", "=", "-", "1", ")", "+", "self", ".", "cnst_A1T", "(", "X", ")" ]
r"""Compute :math:`A^T \mathbf{x}` where :math:`A \mathbf{x}` is a component of ADMM problem constraint. In this case :math:`A^T \mathbf{x} = (\Gamma_0^T \;\; \Gamma_1^T \;\; \ldots \;\; I) \mathbf{x}`.
[ "r", "Compute", ":", "math", ":", "A^T", "\\", "mathbf", "{", "x", "}", "where", ":", "math", ":", "A", "\\", "mathbf", "{", "x", "}", "is", "a", "component", "of", "ADMM", "problem", "constraint", ".", "In", "this", "case", ":", "math", ":", "A^...
python
train
41.25
timkpaine/pyEX
pyEX/stocks.py
https://github.com/timkpaine/pyEX/blob/91cf751dafdb208a0c8b5377945e5808b99f94ba/pyEX/stocks.py#L484-L500
def companyDF(symbol, token='', version=''): '''Company reference data https://iexcloud.io/docs/api/#company Updates at 4am and 5am UTC every day Args: symbol (string); Ticker to request token (string); Access token version (string); API version Returns: DataFrame:...
[ "def", "companyDF", "(", "symbol", ",", "token", "=", "''", ",", "version", "=", "''", ")", ":", "c", "=", "company", "(", "symbol", ",", "token", ",", "version", ")", "df", "=", "_companyToDF", "(", "c", ")", "return", "df" ]
Company reference data https://iexcloud.io/docs/api/#company Updates at 4am and 5am UTC every day Args: symbol (string); Ticker to request token (string); Access token version (string); API version Returns: DataFrame: result
[ "Company", "reference", "data" ]
python
valid
23.411765
digidotcom/python-devicecloud
devicecloud/file_system_service.py
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L174-L197
def list_contents(self): """List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.lis...
[ "def", "list_contents", "(", "self", ")", ":", "target", "=", "DeviceTarget", "(", "self", ".", "device_id", ")", "return", "self", ".", "_fssapi", ".", "list_files", "(", "target", ",", "self", ".", "path", ")", "[", "self", ".", "device_id", "]" ]
List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.list_contents() if isinstan...
[ "List", "the", "contents", "of", "this", "directory" ]
python
train
43.25
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L93-L126
def _get_value_from_match(self, key, match): """ Gets the value of the property in the given MatchObject. Args: key (str): Key of the property looked-up. match (MatchObject): The matched property. Return: The discovered value, as a string o...
[ "def", "_get_value_from_match", "(", "self", ",", "key", ",", "match", ")", ":", "value", "=", "match", ".", "groups", "(", "1", ")", "[", "0", "]", "clean_value", "=", "str", "(", "value", ")", ".", "lstrip", "(", ")", ".", "rstrip", "(", ")", "...
Gets the value of the property in the given MatchObject. Args: key (str): Key of the property looked-up. match (MatchObject): The matched property. Return: The discovered value, as a string or boolean.
[ "Gets", "the", "value", "of", "the", "property", "in", "the", "given", "MatchObject", "." ]
python
train
31.647059
bovee/Aston
aston/tracefile/inficon.py
https://github.com/bovee/Aston/blob/007630fdf074690373d03398fe818260d3d3cf5a/aston/tracefile/inficon.py#L12-L51
def _ions(self, f): """ This is a generator that returns the mzs being measured during each time segment, one segment at a time. """ outside_pos = f.tell() doff = find_offset(f, 4 * b'\xff' + 'HapsSearch'.encode('ascii')) # actual end of prev section is 34 bytes b...
[ "def", "_ions", "(", "self", ",", "f", ")", ":", "outside_pos", "=", "f", ".", "tell", "(", ")", "doff", "=", "find_offset", "(", "f", ",", "4", "*", "b'\\xff'", "+", "'HapsSearch'", ".", "encode", "(", "'ascii'", ")", ")", "# actual end of prev sectio...
This is a generator that returns the mzs being measured during each time segment, one segment at a time.
[ "This", "is", "a", "generator", "that", "returns", "the", "mzs", "being", "measured", "during", "each", "time", "segment", "one", "segment", "at", "a", "time", "." ]
python
train
43.875
NoviceLive/pat
pat/pat.py
https://github.com/NoviceLive/pat/blob/bd223fc5e758213662befbebdf9538f3fbf58ad6/pat/pat.py#L63-L72
def create(self, count): """Create a pattern of the specified length.""" space, self.space = tee(self.space) limit = reduce(mul, map(len, self.sets)) * self.position logging.debug('limit: %s', limit) if limit >= count: return ''.join(islice(space, count)) else...
[ "def", "create", "(", "self", ",", "count", ")", ":", "space", ",", "self", ".", "space", "=", "tee", "(", "self", ".", "space", ")", "limit", "=", "reduce", "(", "mul", ",", "map", "(", "len", ",", "self", ".", "sets", ")", ")", "*", "self", ...
Create a pattern of the specified length.
[ "Create", "a", "pattern", "of", "the", "specified", "length", "." ]
python
train
42.3
alexanderlukanin13/coolname
coolname/impl.py
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/impl.py#L306-L321
def generate(self, pattern=None): """ Generates and returns random name as a list of strings. """ lst = self._lists[pattern] while True: result = lst[self._randrange(lst.length)] # 1. Check that there are no duplicates # 2. Check that there are...
[ "def", "generate", "(", "self", ",", "pattern", "=", "None", ")", ":", "lst", "=", "self", ".", "_lists", "[", "pattern", "]", "while", "True", ":", "result", "=", "lst", "[", "self", ".", "_randrange", "(", "lst", ".", "length", ")", "]", "# 1. Ch...
Generates and returns random name as a list of strings.
[ "Generates", "and", "returns", "random", "name", "as", "a", "list", "of", "strings", "." ]
python
train
44.875
sarenji/pyrc
pyrc/bots.py
https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L173-L179
def _connect(self): "Connects a socket to the server using options defined in `config`." self.socket = socket.socket() self.socket.connect((self.config['host'], self.config['port'])) self.cmd("NICK %s" % self.config['nick']) self.cmd("USER %s %s bla :%s" % (self.c...
[ "def", "_connect", "(", "self", ")", ":", "self", ".", "socket", "=", "socket", ".", "socket", "(", ")", "self", ".", "socket", ".", "connect", "(", "(", "self", ".", "config", "[", "'host'", "]", ",", "self", ".", "config", "[", "'port'", "]", "...
Connects a socket to the server using options defined in `config`.
[ "Connects", "a", "socket", "to", "the", "server", "using", "options", "defined", "in", "config", "." ]
python
train
53.714286
not-na/peng3d
peng3d/window.py
https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/window.py#L255-L277
def dispatch_event(self,event_type,*args): """ Internal event handling method. This method extends the behavior inherited from :py:meth:`pyglet.window.Window.dispatch_event()` by calling the various :py:meth:`handleEvent()` methods. By default, :py:meth:`Peng.handleEven...
[ "def", "dispatch_event", "(", "self", ",", "event_type", ",", "*", "args", ")", ":", "super", "(", "PengWindow", ",", "self", ")", ".", "dispatch_event", "(", "event_type", ",", "*", "args", ")", "try", ":", "p", "=", "self", ".", "peng", "m", "=", ...
Internal event handling method. This method extends the behavior inherited from :py:meth:`pyglet.window.Window.dispatch_event()` by calling the various :py:meth:`handleEvent()` methods. By default, :py:meth:`Peng.handleEvent()`\ , :py:meth:`handleEvent()` and :py:meth:`Menu.handleEvent...
[ "Internal", "event", "handling", "method", ".", "This", "method", "extends", "the", "behavior", "inherited", "from", ":", "py", ":", "meth", ":", "pyglet", ".", "window", ".", "Window", ".", "dispatch_event", "()", "by", "calling", "the", "various", ":", "...
python
test
44.043478
ska-sa/purr
Purr/Editors.py
https://github.com/ska-sa/purr/blob/4c848768d0485d0f88b30850d0d5372221b21b66/Purr/Editors.py#L805-L817
def resolveFilenameConflicts(self, dialog=True): """Goes through list of DPs to make sure that their destination names do not clash. Applies new names. Returns True if some conflicts were resolved. If dialog is True, shows confirrmation dialog.""" resolved = self.wdplv.resolveFilenameCon...
[ "def", "resolveFilenameConflicts", "(", "self", ",", "dialog", "=", "True", ")", ":", "resolved", "=", "self", ".", "wdplv", ".", "resolveFilenameConflicts", "(", ")", "if", "resolved", "and", "dialog", ":", "QMessageBox", ".", "warning", "(", "self", ",", ...
Goes through list of DPs to make sure that their destination names do not clash. Applies new names. Returns True if some conflicts were resolved. If dialog is True, shows confirrmation dialog.
[ "Goes", "through", "list", "of", "DPs", "to", "make", "sure", "that", "their", "destination", "names", "do", "not", "clash", ".", "Applies", "new", "names", ".", "Returns", "True", "if", "some", "conflicts", "were", "resolved", ".", "If", "dialog", "is", ...
python
train
57.692308
saltstack/salt
salt/modules/tuned.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/tuned.py#L94-L109
def profile(profile_name): ''' Activate specified profile CLI Example: .. code-block:: bash salt '*' tuned.profile virtual-guest ''' # run tuned-adm with the profile specified result = __salt__['cmd.retcode']('tuned-adm profile {0}'.format(profile_name)) if int(result) != 0: ...
[ "def", "profile", "(", "profile_name", ")", ":", "# run tuned-adm with the profile specified", "result", "=", "__salt__", "[", "'cmd.retcode'", "]", "(", "'tuned-adm profile {0}'", ".", "format", "(", "profile_name", ")", ")", "if", "int", "(", "result", ")", "!="...
Activate specified profile CLI Example: .. code-block:: bash salt '*' tuned.profile virtual-guest
[ "Activate", "specified", "profile" ]
python
train
22.6875
lensacom/sparkit-learn
splearn/decomposition/truncated_svd.py
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/decomposition/truncated_svd.py#L283-L308
def fit_transform(self, Z): """Fit LSI model to X and perform dimensionality reduction on X. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. Returns ------- X_new : array, shape (n_samples, n_compon...
[ "def", "fit_transform", "(", "self", ",", "Z", ")", ":", "X", "=", "Z", "[", ":", ",", "'X'", "]", "if", "isinstance", "(", "Z", ",", "DictRDD", ")", "else", "Z", "check_rdd", "(", "X", ",", "(", "sp", ".", "spmatrix", ",", "np", ".", "ndarray"...
Fit LSI model to X and perform dimensionality reduction on X. Parameters ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. Returns ------- X_new : array, shape (n_samples, n_components) Reduced version of X....
[ "Fit", "LSI", "model", "to", "X", "and", "perform", "dimensionality", "reduction", "on", "X", "." ]
python
test
38.5
scikit-learn-contrib/categorical-encoding
category_encoders/utils.py
https://github.com/scikit-learn-contrib/categorical-encoding/blob/5e9e803c9131b377af305d5302723ba2415001da/category_encoders/utils.py#L105-L129
def get_generated_cols(X_original, X_transformed, to_transform): """ Returns a list of the generated/transformed columns. Arguments: X_original: df the original (input) DataFrame. X_transformed: df the transformed (current) DataFrame. to_transform: [str] ...
[ "def", "get_generated_cols", "(", "X_original", ",", "X_transformed", ",", "to_transform", ")", ":", "original_cols", "=", "list", "(", "X_original", ".", "columns", ")", "if", "len", "(", "to_transform", ")", ">", "0", ":", "[", "original_cols", ".", "remov...
Returns a list of the generated/transformed columns. Arguments: X_original: df the original (input) DataFrame. X_transformed: df the transformed (current) DataFrame. to_transform: [str] a list of columns that were transformed (as in the original DataFrame...
[ "Returns", "a", "list", "of", "the", "generated", "/", "transformed", "columns", "." ]
python
valid
31.48
ros-infrastructure/ros_buildfarm
ros_buildfarm/common.py
https://github.com/ros-infrastructure/ros_buildfarm/blob/c63ad85b21470f3262086fcd987528a0efc0cf6d/ros_buildfarm/common.py#L434-L466
def write_groovy_script_and_configs( filename, content, job_configs, view_configs=None): """Write out the groovy script and configs to file. This writes the reconfigure script to the file location and places the expanded configs in subdirectories 'view_configs' / 'job_configs' that the script c...
[ "def", "write_groovy_script_and_configs", "(", "filename", ",", "content", ",", "job_configs", ",", "view_configs", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "h", ":", "h", ".", "write", "(", "content", ")", "if", "vi...
Write out the groovy script and configs to file. This writes the reconfigure script to the file location and places the expanded configs in subdirectories 'view_configs' / 'job_configs' that the script can then access when run.
[ "Write", "out", "the", "groovy", "script", "and", "configs", "to", "file", "." ]
python
valid
42.090909
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L5030-L5054
def et2utc(et, formatStr, prec, lenout=_default_len_out): """ Convert an input time from ephemeris seconds past J2000 to Calendar, Day-of-Year, or Julian Date format, UTC. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/et2utc_c.html :param et: Input epoch, given in ephemeris seconds past ...
[ "def", "et2utc", "(", "et", ",", "formatStr", ",", "prec", ",", "lenout", "=", "_default_len_out", ")", ":", "et", "=", "ctypes", ".", "c_double", "(", "et", ")", "prec", "=", "ctypes", ".", "c_int", "(", "prec", ")", "lenout", "=", "ctypes", ".", ...
Convert an input time from ephemeris seconds past J2000 to Calendar, Day-of-Year, or Julian Date format, UTC. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/et2utc_c.html :param et: Input epoch, given in ephemeris seconds past J2000. :type et: float :param formatStr: Format of output epoc...
[ "Convert", "an", "input", "time", "from", "ephemeris", "seconds", "past", "J2000", "to", "Calendar", "Day", "-", "of", "-", "Year", "or", "Julian", "Date", "format", "UTC", "." ]
python
train
36.32
daviddrysdale/python-phonenumbers
python/phonenumbers/phonenumberutil.py
https://github.com/daviddrysdale/python-phonenumbers/blob/9cc5bb4ab5e661e70789b4c64bf7a9383c7bdc20/python/phonenumbers/phonenumberutil.py#L2704-L2717
def _check_region_for_parsing(number, default_region): """Checks to see that the region code used is valid, or if it is not valid, that the number to parse starts with a + symbol so that we can attempt to infer the region from the number. Returns False if it cannot use the region provided and the regio...
[ "def", "_check_region_for_parsing", "(", "number", ",", "default_region", ")", ":", "if", "not", "_is_valid_region_code", "(", "default_region", ")", ":", "# If the number is None or empty, we can't infer the region.", "if", "number", "is", "None", "or", "len", "(", "nu...
Checks to see that the region code used is valid, or if it is not valid, that the number to parse starts with a + symbol so that we can attempt to infer the region from the number. Returns False if it cannot use the region provided and the region cannot be inferred.
[ "Checks", "to", "see", "that", "the", "region", "code", "used", "is", "valid", "or", "if", "it", "is", "not", "valid", "that", "the", "number", "to", "parse", "starts", "with", "a", "+", "symbol", "so", "that", "we", "can", "attempt", "to", "infer", ...
python
train
46
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/base.py
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/base.py#L158-L171
def start(self, request, application, extra_roles=None): """ Continue the state machine at first state. """ # Get the authentication of the current user roles = self._get_roles_for_request(request, application) if extra_roles is not None: roles.update(extra_roles) # ...
[ "def", "start", "(", "self", ",", "request", ",", "application", ",", "extra_roles", "=", "None", ")", ":", "# Get the authentication of the current user", "roles", "=", "self", ".", "_get_roles_for_request", "(", "request", ",", "application", ")", "if", "extra_r...
Continue the state machine at first state.
[ "Continue", "the", "state", "machine", "at", "first", "state", "." ]
python
train
46.5
orlnub123/cleverbot.py
cleverbot/migrations.py
https://github.com/orlnub123/cleverbot.py/blob/83aa45fc2582c30d8646372d9e09756525af931f/cleverbot/migrations.py#L65-L72
def migrator(state): """Tweaks will be lost for Cleverbot and its conversations.""" for tweak in ('tweak1', 'tweak2', 'tweak3'): del state[0][tweak] for convo in state[1]: if tweak in convo: del convo[tweak] return state
[ "def", "migrator", "(", "state", ")", ":", "for", "tweak", "in", "(", "'tweak1'", ",", "'tweak2'", ",", "'tweak3'", ")", ":", "del", "state", "[", "0", "]", "[", "tweak", "]", "for", "convo", "in", "state", "[", "1", "]", ":", "if", "tweak", "in"...
Tweaks will be lost for Cleverbot and its conversations.
[ "Tweaks", "will", "be", "lost", "for", "Cleverbot", "and", "its", "conversations", "." ]
python
train
33.625
armstrong/armstrong.apps.related_content
armstrong/apps/related_content/admin.py
https://github.com/armstrong/armstrong.apps.related_content/blob/f57b6908d3c76c4a44b2241c676ab5d86391106c/armstrong/apps/related_content/admin.py#L46-L68
def formfield_for_foreignkey_helper(inline, *args, **kwargs): """ The implementation for ``RelatedContentInline.formfield_for_foreignkey`` This takes the takes all of the ``args`` and ``kwargs`` from the call to ``formfield_for_foreignkey`` and operates on this. It returns the updated ``args`` and...
[ "def", "formfield_for_foreignkey_helper", "(", "inline", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "db_field", "=", "args", "[", "0", "]", "if", "db_field", ".", "name", "!=", "\"related_type\"", ":", "return", "args", ",", "kwargs", "initial_fi...
The implementation for ``RelatedContentInline.formfield_for_foreignkey`` This takes the takes all of the ``args`` and ``kwargs`` from the call to ``formfield_for_foreignkey`` and operates on this. It returns the updated ``args`` and ``kwargs`` to be passed on to ``super``. This is solely an implement...
[ "The", "implementation", "for", "RelatedContentInline", ".", "formfield_for_foreignkey" ]
python
train
40.652174
idlesign/uwsgiconf
uwsgiconf/config.py
https://github.com/idlesign/uwsgiconf/blob/475407acb44199edbf7e0a66261bfeb51de1afae/uwsgiconf/config.py#L595-L607
def _validate_sections(cls, sections): """Validates sections types and uniqueness.""" names = [] for section in sections: if not hasattr(section, 'name'): raise ConfigurationError('`sections` attribute requires a list of Section') name = section.name ...
[ "def", "_validate_sections", "(", "cls", ",", "sections", ")", ":", "names", "=", "[", "]", "for", "section", "in", "sections", ":", "if", "not", "hasattr", "(", "section", ",", "'name'", ")", ":", "raise", "ConfigurationError", "(", "'`sections` attribute r...
Validates sections types and uniqueness.
[ "Validates", "sections", "types", "and", "uniqueness", "." ]
python
train
34.615385
openstack/proliantutils
proliantutils/redfish/resources/update_service.py
https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/redfish/resources/update_service.py#L45-L56
def _get_firmware_update_element(self): """Get the url for firmware update :returns: firmware update url :raises: Missing resource error on missing url """ fw_update_action = self._actions.update_firmware if not fw_update_action: raise (sushy.exceptions. ...
[ "def", "_get_firmware_update_element", "(", "self", ")", ":", "fw_update_action", "=", "self", ".", "_actions", ".", "update_firmware", "if", "not", "fw_update_action", ":", "raise", "(", "sushy", ".", "exceptions", ".", "MissingActionError", "(", "action", "=", ...
Get the url for firmware update :returns: firmware update url :raises: Missing resource error on missing url
[ "Get", "the", "url", "for", "firmware", "update" ]
python
train
39.333333
plivo/plivohelper-python
plivohelper.py
https://github.com/plivo/plivohelper-python/blob/a2f706d69e2138fbb973f792041341f662072d26/plivohelper.py#L181-L186
def hangup_all_calls(self): """REST Hangup All Live Calls Helper """ path = '/' + self.api_version + '/HangupAllCalls/' method = 'POST' return self.request(path, method)
[ "def", "hangup_all_calls", "(", "self", ")", ":", "path", "=", "'/'", "+", "self", ".", "api_version", "+", "'/HangupAllCalls/'", "method", "=", "'POST'", "return", "self", ".", "request", "(", "path", ",", "method", ")" ]
REST Hangup All Live Calls Helper
[ "REST", "Hangup", "All", "Live", "Calls", "Helper" ]
python
valid
34
log2timeline/plaso
plaso/lib/objectfilter.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/lib/objectfilter.py#L835-L844
def HexEscape(self, string, match, **unused_kwargs): """Converts a hex escaped string.""" logging.debug('HexEscape matched {0:s}.'.format(string)) hex_string = match.group(1) try: hex_string = binascii.unhexlify(hex_string) hex_string = codecs.decode(hex_string, 'utf-8') self.string +=...
[ "def", "HexEscape", "(", "self", ",", "string", ",", "match", ",", "*", "*", "unused_kwargs", ")", ":", "logging", ".", "debug", "(", "'HexEscape matched {0:s}.'", ".", "format", "(", "string", ")", ")", "hex_string", "=", "match", ".", "group", "(", "1"...
Converts a hex escaped string.
[ "Converts", "a", "hex", "escaped", "string", "." ]
python
train
44
peepall/FancyLogger
FancyLogger/__init__.py
https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L376-L385
def warning(self, text): """ Posts a warning message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but the...
[ "def", "warning", "(", "self", ",", "text", ")", ":", "self", ".", "queue", ".", "put", "(", "dill", ".", "dumps", "(", "LogMessageCommand", "(", "text", "=", "text", ",", "level", "=", "logging", ".", "WARNING", ")", ")", ")" ]
Posts a warning message adding a timestamp and logging level to it for both file and console handlers. Logger uses a redraw rate because of console flickering. That means it will not draw new messages or progress at the very time they are being logged but their timestamp will be captured at the right ti...
[ "Posts", "a", "warning", "message", "adding", "a", "timestamp", "and", "logging", "level", "to", "it", "for", "both", "file", "and", "console", "handlers", ".", "Logger", "uses", "a", "redraw", "rate", "because", "of", "console", "flickering", ".", "That", ...
python
train
72
RiotGames/cloud-inquisitor
plugins/public/cinq-collector-aws/cinq_collector_aws/region.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/plugins/public/cinq-collector-aws/cinq_collector_aws/region.py#L651-L730
def update_rds_databases(self): """Update list of RDS Databases for the account / region Returns: `None` """ self.log.info('Updating RDS Databases for {} / {}'.format( self.account, self.region )) # All RDS resources are polled via a Lambda collec...
[ "def", "update_rds_databases", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "'Updating RDS Databases for {} / {}'", ".", "format", "(", "self", ".", "account", ",", "self", ".", "region", ")", ")", "# All RDS resources are polled via a Lambda collect...
Update list of RDS Databases for the account / region Returns: `None`
[ "Update", "list", "of", "RDS", "Databases", "for", "the", "account", "/", "region" ]
python
train
50.8
Erotemic/utool
utool/util_str.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L720-L778
def func_str(func, args=[], kwargs={}, type_aliases=[], packed=False, packkw=None, truncate=False): """ string representation of function definition Returns: str: a representation of func with args, kwargs, and type_aliases Args: func (function): args (list): argum...
[ "def", "func_str", "(", "func", ",", "args", "=", "[", "]", ",", "kwargs", "=", "{", "}", ",", "type_aliases", "=", "[", "]", ",", "packed", "=", "False", ",", "packkw", "=", "None", ",", "truncate", "=", "False", ")", ":", "import", "utool", "as...
string representation of function definition Returns: str: a representation of func with args, kwargs, and type_aliases Args: func (function): args (list): argument values (default = []) kwargs (dict): kwargs values (default = {}) type_aliases (list): (default = []) ...
[ "string", "representation", "of", "function", "definition" ]
python
train
32.610169
danfairs/django-lazysignup
lazysignup/models.py
https://github.com/danfairs/django-lazysignup/blob/cfe77e12976d439e1a5aae4387531b2f0f835c6a/lazysignup/models.py#L67-L76
def generate_username(self, user_class): """ Generate a new username for a user """ m = getattr(user_class, 'generate_username', None) if m: return m() else: max_length = user_class._meta.get_field( self.username_field).max_length ...
[ "def", "generate_username", "(", "self", ",", "user_class", ")", ":", "m", "=", "getattr", "(", "user_class", ",", "'generate_username'", ",", "None", ")", "if", "m", ":", "return", "m", "(", ")", "else", ":", "max_length", "=", "user_class", ".", "_meta...
Generate a new username for a user
[ "Generate", "a", "new", "username", "for", "a", "user" ]
python
train
35
howie6879/ruia
ruia/spider.py
https://github.com/howie6879/ruia/blob/2dc5262fc9c3e902a8faa7d5fa2f046f9d9ee1fa/ruia/spider.py#L265-L283
async def async_start( cls, middleware: typing.Union[typing.Iterable, Middleware] = None, loop=None, after_start=None, before_stop=None, **kwargs): """ Start an async spider :param middleware: customize middleware or a list ...
[ "async", "def", "async_start", "(", "cls", ",", "middleware", ":", "typing", ".", "Union", "[", "typing", ".", "Iterable", ",", "Middleware", "]", "=", "None", ",", "loop", "=", "None", ",", "after_start", "=", "None", ",", "before_stop", "=", "None", ...
Start an async spider :param middleware: customize middleware or a list of middleware :param loop: :param after_start: hook :param before_stop: hook :return:
[ "Start", "an", "async", "spider", ":", "param", "middleware", ":", "customize", "middleware", "or", "a", "list", "of", "middleware", ":", "param", "loop", ":", ":", "param", "after_start", ":", "hook", ":", "param", "before_stop", ":", "hook", ":", "return...
python
test
34.421053
materialsproject/pymatgen
pymatgen/io/abinit/pseudos.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/pseudos.py#L565-L615
def _dict_from_lines(lines, key_nums, sep=None): """ Helper function to parse formatted text structured like: value1 value2 ... sep key1, key2 ... key_nums is a list giving the number of keys for each line. 0 if line should be skipped. sep is a string denoting the character that separates the keys...
[ "def", "_dict_from_lines", "(", "lines", ",", "key_nums", ",", "sep", "=", "None", ")", ":", "if", "is_string", "(", "lines", ")", ":", "lines", "=", "[", "lines", "]", "if", "not", "isinstance", "(", "key_nums", ",", "collections", ".", "abc", ".", ...
Helper function to parse formatted text structured like: value1 value2 ... sep key1, key2 ... key_nums is a list giving the number of keys for each line. 0 if line should be skipped. sep is a string denoting the character that separates the keys from the value (None if no separator is present). R...
[ "Helper", "function", "to", "parse", "formatted", "text", "structured", "like", ":" ]
python
train
30.647059
pysathq/pysat
pysat/solvers.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L1550-L1568
def new(self, bootstrap_with=None, use_timer=False, with_proof=False): """ Actual constructor of the solver. """ if not self.lingeling: self.lingeling = pysolvers.lingeling_new() if bootstrap_with: for clause in bootstrap_with: ...
[ "def", "new", "(", "self", ",", "bootstrap_with", "=", "None", ",", "use_timer", "=", "False", ",", "with_proof", "=", "False", ")", ":", "if", "not", "self", ".", "lingeling", ":", "self", ".", "lingeling", "=", "pysolvers", ".", "lingeling_new", "(", ...
Actual constructor of the solver.
[ "Actual", "constructor", "of", "the", "solver", "." ]
python
train
35.736842
twilio/twilio-python
twilio/rest/video/v1/composition/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/video/v1/composition/__init__.py#L104-L139
def page(self, status=values.unset, date_created_after=values.unset, date_created_before=values.unset, room_sid=values.unset, page_token=values.unset, page_number=values.unset, page_size=values.unset): """ Retrieve a single page of CompositionInstance records from ...
[ "def", "page", "(", "self", ",", "status", "=", "values", ".", "unset", ",", "date_created_after", "=", "values", ".", "unset", ",", "date_created_before", "=", "values", ".", "unset", ",", "room_sid", "=", "values", ".", "unset", ",", "page_token", "=", ...
Retrieve a single page of CompositionInstance records from the API. Request is executed immediately :param CompositionInstance.Status status: Only show Compositions with the given status. :param datetime date_created_after: Only show Compositions created on or after this ISO8601 date-time with ...
[ "Retrieve", "a", "single", "page", "of", "CompositionInstance", "records", "from", "the", "API", ".", "Request", "is", "executed", "immediately" ]
python
train
46.138889
riga/scinum
scinum.py
https://github.com/riga/scinum/blob/55eb6d8aa77beacee5a07443392954b8a0aad8cb/scinum.py#L1537-L1620
def round_value(val, unc=None, unc_down=None, method="publication"): """ Rounds a number *val* with a single symmetric uncertainty *unc* or asymmetric uncertainties *unc* (interpreted as *up*) and *unc_down*, and calculates the orders of their magnitudes. They both can be a float or a list of floats for...
[ "def", "round_value", "(", "val", ",", "unc", "=", "None", ",", "unc_down", "=", "None", ",", "method", "=", "\"publication\"", ")", ":", "if", "isinstance", "(", "val", ",", "Number", ")", ":", "unc", ",", "unc_down", "=", "val", ".", "get_uncertainty...
Rounds a number *val* with a single symmetric uncertainty *unc* or asymmetric uncertainties *unc* (interpreted as *up*) and *unc_down*, and calculates the orders of their magnitudes. They both can be a float or a list of floats for simultaneous evaluation. When *val* is a :py:class:`Number` instance, its co...
[ "Rounds", "a", "number", "*", "val", "*", "with", "a", "single", "symmetric", "uncertainty", "*", "unc", "*", "or", "asymmetric", "uncertainties", "*", "unc", "*", "(", "interpreted", "as", "*", "up", "*", ")", "and", "*", "unc_down", "*", "and", "calc...
python
train
42.559524
intelsdi-x/snap-plugin-lib-py
snap_plugin/v1/config_map.py
https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/snap_plugin/v1/config_map.py#L190-L193
def items(self): "Returns a list of (key, value) pairs as 2-tuples." return (list(self._pb.IntMap.items()) + list(self._pb.StringMap.items()) + list(self._pb.FloatMap.items()) + list(self._pb.BoolMap.items()))
[ "def", "items", "(", "self", ")", ":", "return", "(", "list", "(", "self", ".", "_pb", ".", "IntMap", ".", "items", "(", ")", ")", "+", "list", "(", "self", ".", "_pb", ".", "StringMap", ".", "items", "(", ")", ")", "+", "list", "(", "self", ...
Returns a list of (key, value) pairs as 2-tuples.
[ "Returns", "a", "list", "of", "(", "key", "value", ")", "pairs", "as", "2", "-", "tuples", "." ]
python
train
59.5
danilobellini/audiolazy
audiolazy/lazy_midi.py
https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_midi.py#L45-L60
def str2midi(note_string): """ Given a note string name (e.g. "Bb4"), returns its MIDI pitch number. """ if note_string == "?": return nan data = note_string.strip().lower() name2delta = {"c": -9, "d": -7, "e": -5, "f": -4, "g": -2, "a": 0, "b": 2} accident2delta = {"b": -1, "#": 1, "x": 2} accident...
[ "def", "str2midi", "(", "note_string", ")", ":", "if", "note_string", "==", "\"?\"", ":", "return", "nan", "data", "=", "note_string", ".", "strip", "(", ")", ".", "lower", "(", ")", "name2delta", "=", "{", "\"c\"", ":", "-", "9", ",", "\"d\"", ":", ...
Given a note string name (e.g. "Bb4"), returns its MIDI pitch number.
[ "Given", "a", "note", "string", "name", "(", "e", ".", "g", ".", "Bb4", ")", "returns", "its", "MIDI", "pitch", "number", "." ]
python
train
37.25
gbowerman/azurerm
azurerm/storagerp.py
https://github.com/gbowerman/azurerm/blob/79d40431d3b13f8a36aadbff5029888383d72674/azurerm/storagerp.py#L115-L131
def list_storage_accounts_rg(access_token, subscription_id, rgname): '''List the storage accounts in the specified resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. Re...
[ "def", "list_storage_accounts_rg", "(", "access_token", ",", "subscription_id", ",", "rgname", ")", ":", "endpoint", "=", "''", ".", "join", "(", "[", "get_rm_endpoint", "(", ")", ",", "'/subscriptions/'", ",", "subscription_id", ",", "'/resourcegroups/'", ",", ...
List the storage accounts in the specified resource group. Args: access_token (str): A valid Azure authentication token. subscription_id (str): Azure subscription id. rgname (str): Azure resource group name. Returns: HTTP response. JSON body list of storage accounts.
[ "List", "the", "storage", "accounts", "in", "the", "specified", "resource", "group", "." ]
python
train
41.235294
hsolbrig/PyShEx
pyshex/prefixlib.py
https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/prefixlib.py#L72-L80
def add_bindings(self, g: Graph) -> "PrefixLibrary": """ Add bindings in the library to the graph :param g: graph to add prefixes to :return: PrefixLibrary object """ for prefix, namespace in self: g.bind(prefix.lower(), namespace) return self
[ "def", "add_bindings", "(", "self", ",", "g", ":", "Graph", ")", "->", "\"PrefixLibrary\"", ":", "for", "prefix", ",", "namespace", "in", "self", ":", "g", ".", "bind", "(", "prefix", ".", "lower", "(", ")", ",", "namespace", ")", "return", "self" ]
Add bindings in the library to the graph :param g: graph to add prefixes to :return: PrefixLibrary object
[ "Add", "bindings", "in", "the", "library", "to", "the", "graph" ]
python
train
32.888889
saltstack/salt
salt/modules/state.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/state.py#L1966-L1988
def id_exists(ids, mods, test=None, queue=False, **kwargs): ''' Tests for the existence of a specific ID or list of IDs within the specified SLS file(s). Similar to :py:func:`state.sls_exists <salt.modules.state.sls_exists>`, returns True or False. The default environment is base``, use ``saltenv`` ...
[ "def", "id_exists", "(", "ids", ",", "mods", ",", "test", "=", "None", ",", "queue", "=", "False", ",", "*", "*", "kwargs", ")", ":", "ids", "=", "salt", ".", "utils", ".", "args", ".", "split_input", "(", "ids", ")", "ids", "=", "set", "(", "i...
Tests for the existence of a specific ID or list of IDs within the specified SLS file(s). Similar to :py:func:`state.sls_exists <salt.modules.state.sls_exists>`, returns True or False. The default environment is base``, use ``saltenv`` to specify a different environment. .. versionadded:: 2019.2.0 ...
[ "Tests", "for", "the", "existence", "of", "a", "specific", "ID", "or", "list", "of", "IDs", "within", "the", "specified", "SLS", "file", "(", "s", ")", ".", "Similar", "to", ":", "py", ":", "func", ":", "state", ".", "sls_exists", "<salt", ".", "modu...
python
train
36.086957
mozilla/funfactory
funfactory/helpers.py
https://github.com/mozilla/funfactory/blob/c9bbf1c534eaa15641265bc75fa87afca52b7dd6/funfactory/helpers.py#L55-L60
def _urlencode(items): """A Unicode-safe URLencoder.""" try: return urllib.urlencode(items) except UnicodeEncodeError: return urllib.urlencode([(k, smart_str(v)) for k, v in items])
[ "def", "_urlencode", "(", "items", ")", ":", "try", ":", "return", "urllib", ".", "urlencode", "(", "items", ")", "except", "UnicodeEncodeError", ":", "return", "urllib", ".", "urlencode", "(", "[", "(", "k", ",", "smart_str", "(", "v", ")", ")", "for"...
A Unicode-safe URLencoder.
[ "A", "Unicode", "-", "safe", "URLencoder", "." ]
python
train
34
TUNE-Archive/freight_forwarder
freight_forwarder/utils/utils.py
https://github.com/TUNE-Archive/freight_forwarder/blob/6ea4a49f474ec04abb8bb81b175c774a16b5312f/freight_forwarder/utils/utils.py#L159-L204
def parse_stream(response): """ take stream from docker-py lib and display it to the user. this also builds a stream list and returns it. """ stream_data = [] stream = stdout for data in response: if data: try: data = data.decode('utf-8') exc...
[ "def", "parse_stream", "(", "response", ")", ":", "stream_data", "=", "[", "]", "stream", "=", "stdout", "for", "data", "in", "response", ":", "if", "data", ":", "try", ":", "data", "=", "data", ".", "decode", "(", "'utf-8'", ")", "except", "AttributeE...
take stream from docker-py lib and display it to the user. this also builds a stream list and returns it.
[ "take", "stream", "from", "docker", "-", "py", "lib", "and", "display", "it", "to", "the", "user", "." ]
python
train
30.23913
gwastro/pycbc
pycbc/conversions.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/conversions.py#L685-L692
def _optimal_orientation_from_detector(detector_name, tc): """ Low-level function to be called from _optimal_dec_from_detector and _optimal_ra_from_detector""" d = Detector(detector_name) ra, dec = d.optimal_orientation(tc) return ra, dec
[ "def", "_optimal_orientation_from_detector", "(", "detector_name", ",", "tc", ")", ":", "d", "=", "Detector", "(", "detector_name", ")", "ra", ",", "dec", "=", "d", ".", "optimal_orientation", "(", "tc", ")", "return", "ra", ",", "dec" ]
Low-level function to be called from _optimal_dec_from_detector and _optimal_ra_from_detector
[ "Low", "-", "level", "function", "to", "be", "called", "from", "_optimal_dec_from_detector", "and", "_optimal_ra_from_detector" ]
python
train
31.625
johnnoone/json-spec
src/jsonspec/validators/draft04.py
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/validators/draft04.py#L394-L423
def validate_format(self, obj, pointer=None): """ ================= ============ Expected draft04 Alias of ----------------- ------------ date-time rfc3339.datetime email email hostname hostname ipv4 ipv4 ...
[ "def", "validate_format", "(", "self", ",", "obj", ",", "pointer", "=", "None", ")", ":", "if", "'format'", "in", "self", ".", "attrs", ":", "substituted", "=", "{", "'date-time'", ":", "'rfc3339.datetime'", ",", "'email'", ":", "'email'", ",", "'hostname'...
================= ============ Expected draft04 Alias of ----------------- ------------ date-time rfc3339.datetime email email hostname hostname ipv4 ipv4 ipv6 ipv6 uri uri =====...
[ "=================", "============", "Expected", "draft04", "Alias", "of", "-----------------", "------------", "date", "-", "time", "rfc3339", ".", "datetime", "email", "email", "hostname", "hostname", "ipv4", "ipv4", "ipv6", "ipv6", "uri", "uri", "================="...
python
train
33.833333
PmagPy/PmagPy
dialogs/grid_frame3.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/dialogs/grid_frame3.py#L293-L302
def on_key_down(self, event): """ If user does command v, re-size window in case pasting has changed the content size. """ keycode = event.GetKeyCode() meta_down = event.MetaDown() or event.GetCmdDown() if keycode == 86 and meta_down: # treat it as if ...
[ "def", "on_key_down", "(", "self", ",", "event", ")", ":", "keycode", "=", "event", ".", "GetKeyCode", "(", ")", "meta_down", "=", "event", ".", "MetaDown", "(", ")", "or", "event", ".", "GetCmdDown", "(", ")", "if", "keycode", "==", "86", "and", "me...
If user does command v, re-size window in case pasting has changed the content size.
[ "If", "user", "does", "command", "v", "re", "-", "size", "window", "in", "case", "pasting", "has", "changed", "the", "content", "size", "." ]
python
train
36.8
lensacom/sparkit-learn
splearn/pipeline.py
https://github.com/lensacom/sparkit-learn/blob/0498502107c1f7dcf33cda0cdb6f5ba4b42524b7/splearn/pipeline.py#L115-L123
def fit_transform(self, Z, **fit_params): """Fit all the transforms one after the other and transform the data, then use fit_transform on transformed data using the final estimator.""" Zt, fit_params = self._pre_transform(Z, **fit_params) if hasattr(self.steps[-1][-1], 'fit_trans...
[ "def", "fit_transform", "(", "self", ",", "Z", ",", "*", "*", "fit_params", ")", ":", "Zt", ",", "fit_params", "=", "self", ".", "_pre_transform", "(", "Z", ",", "*", "*", "fit_params", ")", "if", "hasattr", "(", "self", ".", "steps", "[", "-", "1"...
Fit all the transforms one after the other and transform the data, then use fit_transform on transformed data using the final estimator.
[ "Fit", "all", "the", "transforms", "one", "after", "the", "other", "and", "transform", "the", "data", "then", "use", "fit_transform", "on", "transformed", "data", "using", "the", "final", "estimator", "." ]
python
test
53
projectatomic/atomic-reactor
atomic_reactor/util.py
https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/util.py#L1004-L1018
def get_manifest_list(image, registry, insecure=False, dockercfg_path=None): """Return manifest list for image. :param image: ImageName, the remote image to inspect :param registry: str, URI for registry, if URI schema is not provided, https:// will be used :param insecure: bo...
[ "def", "get_manifest_list", "(", "image", ",", "registry", ",", "insecure", "=", "False", ",", "dockercfg_path", "=", "None", ")", ":", "version", "=", "'v2_list'", "registry_session", "=", "RegistrySession", "(", "registry", ",", "insecure", "=", "insecure", ...
Return manifest list for image. :param image: ImageName, the remote image to inspect :param registry: str, URI for registry, if URI schema is not provided, https:// will be used :param insecure: bool, when True registry's cert is not verified :param dockercfg_path: str, dirnam...
[ "Return", "manifest", "list", "for", "image", "." ]
python
train
45.466667
pyQode/pyqode.core
pyqode/core/widgets/output_window.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/output_window.py#L1161-L1182
def _init_formats(self): """ Initialise default formats. """ theme = self._color_scheme # normal message format fmt = QtGui.QTextCharFormat() fmt.setForeground(theme.foreground) fmt.setBackground(theme.background) self._formats[OutputFormat.NormalM...
[ "def", "_init_formats", "(", "self", ")", ":", "theme", "=", "self", ".", "_color_scheme", "# normal message format", "fmt", "=", "QtGui", ".", "QTextCharFormat", "(", ")", "fmt", ".", "setForeground", "(", "theme", ".", "foreground", ")", "fmt", ".", "setBa...
Initialise default formats.
[ "Initialise", "default", "formats", "." ]
python
train
33.045455
Jajcus/pyxmpp2
pyxmpp2/ext/component.py
https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/component.py#L138-L143
def _compute_handshake(self): """Compute the authentication handshake value. :return: the computed hash value. :returntype: `str`""" return hashlib.sha1(to_utf8(self.stream_id)+to_utf8(self.secret)).hexdigest()
[ "def", "_compute_handshake", "(", "self", ")", ":", "return", "hashlib", ".", "sha1", "(", "to_utf8", "(", "self", ".", "stream_id", ")", "+", "to_utf8", "(", "self", ".", "secret", ")", ")", ".", "hexdigest", "(", ")" ]
Compute the authentication handshake value. :return: the computed hash value. :returntype: `str`
[ "Compute", "the", "authentication", "handshake", "value", "." ]
python
valid
39.666667
crunchyroll/ef-open
efopen/ef_utils.py
https://github.com/crunchyroll/ef-open/blob/59fff3761af07a59f8f1c1682f2be004bdac15f7/efopen/ef_utils.py#L267-L282
def get_env_short(env): """ Given an env, return <env_short> if env is valid Args: env: an environment, such as "prod", "staging", "proto<N>", "mgmt.<account_alias>" Returns: the shortname of the env, such as "prod", "staging", "proto", "mgmt" Raises: ValueError if env is misformatted or doesn't n...
[ "def", "get_env_short", "(", "env", ")", ":", "env_valid", "(", "env", ")", "if", "env", ".", "find", "(", "\".\"", ")", ">", "-", "1", ":", "env_short", ",", "ext", "=", "env", ".", "split", "(", "\".\"", ")", "else", ":", "env_short", "=", "env...
Given an env, return <env_short> if env is valid Args: env: an environment, such as "prod", "staging", "proto<N>", "mgmt.<account_alias>" Returns: the shortname of the env, such as "prod", "staging", "proto", "mgmt" Raises: ValueError if env is misformatted or doesn't name a known environment
[ "Given", "an", "env", "return", "<env_short", ">", "if", "env", "is", "valid", "Args", ":", "env", ":", "an", "environment", "such", "as", "prod", "staging", "proto<N", ">", "mgmt", ".", "<account_alias", ">", "Returns", ":", "the", "shortname", "of", "t...
python
train
30
qubell/contrib-python-qubell-client
qubell/api/private/instance.py
https://github.com/qubell/contrib-python-qubell-client/blob/4586ea11d5103c2ff9607d3ed922b5a0991b8845/qubell/api/private/instance.py#L508-L522
def get_most_recent_update_time(self): """ Indicated most recent update of the instance, assumption based on: - if currentWorkflow exists, its startedAt time is most recent update. - else max of workflowHistory startedAt is most recent update. """ def parse_time(t): ...
[ "def", "get_most_recent_update_time", "(", "self", ")", ":", "def", "parse_time", "(", "t", ")", ":", "if", "t", ":", "return", "time", ".", "gmtime", "(", "t", "/", "1000", ")", "return", "None", "try", ":", "max_wf_started_at", "=", "max", "(", "[", ...
Indicated most recent update of the instance, assumption based on: - if currentWorkflow exists, its startedAt time is most recent update. - else max of workflowHistory startedAt is most recent update.
[ "Indicated", "most", "recent", "update", "of", "the", "instance", "assumption", "based", "on", ":", "-", "if", "currentWorkflow", "exists", "its", "startedAt", "time", "is", "most", "recent", "update", ".", "-", "else", "max", "of", "workflowHistory", "started...
python
train
39.066667
raphaelm/django-i18nfield
i18nfield/strings.py
https://github.com/raphaelm/django-i18nfield/blob/fb707931e4498ab1b609eaa0323bb5c3d5f7c7e7/i18nfield/strings.py#L48-L81
def localize(self, lng: str) -> str: """ Evaluate the given string with respect to the locale defined by ``lng``. If no string is available in the currently active language, this will give you the string in the system's default language. If this is unavailable as well, it will g...
[ "def", "localize", "(", "self", ",", "lng", ":", "str", ")", "->", "str", ":", "if", "self", ".", "data", "is", "None", ":", "return", "\"\"", "if", "isinstance", "(", "self", ".", "data", ",", "dict", ")", ":", "firstpart", "=", "lng", ".", "spl...
Evaluate the given string with respect to the locale defined by ``lng``. If no string is available in the currently active language, this will give you the string in the system's default language. If this is unavailable as well, it will give you the string in the first language available. ...
[ "Evaluate", "the", "given", "string", "with", "respect", "to", "the", "locale", "defined", "by", "lng", "." ]
python
train
44.529412
vatlab/SoS
src/sos/section_analyzer.py
https://github.com/vatlab/SoS/blob/6b60ed0770916d135e17322e469520d778e9d4e7/src/sos/section_analyzer.py#L138-L165
def get_changed_vars(section: SoS_Step): '''changed vars are variables that are "shared" and therefore "provides" to others ''' if 'shared' not in section.options: return set() changed_vars = set() svars = section.options['shared'] if isinstance(svars, str): changed_vars.add(sva...
[ "def", "get_changed_vars", "(", "section", ":", "SoS_Step", ")", ":", "if", "'shared'", "not", "in", "section", ".", "options", ":", "return", "set", "(", ")", "changed_vars", "=", "set", "(", ")", "svars", "=", "section", ".", "options", "[", "'shared'"...
changed vars are variables that are "shared" and therefore "provides" to others
[ "changed", "vars", "are", "variables", "that", "are", "shared", "and", "therefore", "provides", "to", "others" ]
python
train
36.892857
SFDO-Tooling/CumulusCI
cumulusci/robotframework/utils.py
https://github.com/SFDO-Tooling/CumulusCI/blob/e19047921ca771a297e045f22f0bb201651bb6f7/cumulusci/robotframework/utils.py#L137-L202
def selenium_retry(target=None, retry=True): """Decorator to turn on automatic retries of flaky selenium failures. Decorate a robotframework library class to turn on retries for all selenium calls from that library: @selenium_retry class MyLibrary(object): # Decorate a method ...
[ "def", "selenium_retry", "(", "target", "=", "None", ",", "retry", "=", "True", ")", ":", "if", "isinstance", "(", "target", ",", "bool", ")", ":", "# Decorator was called with a single boolean argument", "retry", "=", "target", "target", "=", "None", "def", "...
Decorator to turn on automatic retries of flaky selenium failures. Decorate a robotframework library class to turn on retries for all selenium calls from that library: @selenium_retry class MyLibrary(object): # Decorate a method to turn it back off for that method @sel...
[ "Decorator", "to", "turn", "on", "automatic", "retries", "of", "flaky", "selenium", "failures", "." ]
python
train
31.378788
gofed/gofedlib
gofedlib/repository/gitlocalclient.py
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/gitlocalclient.py#L16-L31
def branches(self): """Return a list of branches for given repository :return: [str] """ # get all remote branches refs = filter(lambda l: isinstance(l, git.RemoteReference), self.repo.references) # filter out HEAD branch refs = filter(lambda l: l.name != "origin/HEAD", refs) # filter out all branches ...
[ "def", "branches", "(", "self", ")", ":", "# get all remote branches", "refs", "=", "filter", "(", "lambda", "l", ":", "isinstance", "(", "l", ",", "git", ".", "RemoteReference", ")", ",", "self", ".", "repo", ".", "references", ")", "# filter out HEAD branc...
Return a list of branches for given repository :return: [str]
[ "Return", "a", "list", "of", "branches", "for", "given", "repository" ]
python
train
32.25
cga-harvard/Hypermap-Registry
hypermap/context_processors.py
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/context_processors.py#L7-L19
def resource_urls(request): """Global values to pass to templates""" url_parsed = urlparse(settings.SEARCH_URL) defaults = dict( APP_NAME=__description__, APP_VERSION=__version__, SITE_URL=settings.SITE_URL.rstrip('/'), SEARCH_TYPE=settings.SEARCH_TYPE, SEARCH_URL=se...
[ "def", "resource_urls", "(", "request", ")", ":", "url_parsed", "=", "urlparse", "(", "settings", ".", "SEARCH_URL", ")", "defaults", "=", "dict", "(", "APP_NAME", "=", "__description__", ",", "APP_VERSION", "=", "__version__", ",", "SITE_URL", "=", "settings"...
Global values to pass to templates
[ "Global", "values", "to", "pass", "to", "templates" ]
python
train
34.076923
saltstack/salt
salt/modules/win_useradd.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_useradd.py#L922-L952
def list_users(): ''' Return a list of all users on Windows Returns: list: A list of all users on the system CLI Example: .. code-block:: bash salt '*' user.list_users ''' res = 0 user_list = [] dowhile = True try: while res or dowhile: dow...
[ "def", "list_users", "(", ")", ":", "res", "=", "0", "user_list", "=", "[", "]", "dowhile", "=", "True", "try", ":", "while", "res", "or", "dowhile", ":", "dowhile", "=", "False", "(", "users", ",", "_", ",", "res", ")", "=", "win32net", ".", "Ne...
Return a list of all users on Windows Returns: list: A list of all users on the system CLI Example: .. code-block:: bash salt '*' user.list_users
[ "Return", "a", "list", "of", "all", "users", "on", "Windows" ]
python
train
21.709677
dnanexus/dx-toolkit
src/python/dxpy/api.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/api.py#L1164-L1170
def record_set_properties(object_id, input_params={}, always_retry=True, **kwargs): """ Invokes the /record-xxxx/setProperties API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Properties#API-method%3A-%2Fclass-xxxx%2FsetProperties """ return DXHTTPRequest('/%s/setP...
[ "def", "record_set_properties", "(", "object_id", ",", "input_params", "=", "{", "}", ",", "always_retry", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "DXHTTPRequest", "(", "'/%s/setProperties'", "%", "object_id", ",", "input_params", ",", "alway...
Invokes the /record-xxxx/setProperties API method. For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Properties#API-method%3A-%2Fclass-xxxx%2FsetProperties
[ "Invokes", "the", "/", "record", "-", "xxxx", "/", "setProperties", "API", "method", "." ]
python
train
55.428571
saltstack/salt
salt/modules/systemd_service.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/systemd_service.py#L272-L291
def _get_service_exec(): ''' Returns the path to the sysv service manager (either update-rc.d or chkconfig) ''' contextkey = 'systemd._get_service_exec' if contextkey not in __context__: executables = ('update-rc.d', 'chkconfig') for executable in executables: service...
[ "def", "_get_service_exec", "(", ")", ":", "contextkey", "=", "'systemd._get_service_exec'", "if", "contextkey", "not", "in", "__context__", ":", "executables", "=", "(", "'update-rc.d'", ",", "'chkconfig'", ")", "for", "executable", "in", "executables", ":", "ser...
Returns the path to the sysv service manager (either update-rc.d or chkconfig)
[ "Returns", "the", "path", "to", "the", "sysv", "service", "manager", "(", "either", "update", "-", "rc", ".", "d", "or", "chkconfig", ")" ]
python
train
34.55
yyuu/botornado
boto/ec2/autoscale/__init__.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/ec2/autoscale/__init__.py#L440-L471
def get_all_policies(self, as_group=None, policy_names=None, max_records=None, next_token=None): """ Returns descriptions of what each policy does. This action supports pagination. If the response includes a token, there are more records available. To get the add...
[ "def", "get_all_policies", "(", "self", ",", "as_group", "=", "None", ",", "policy_names", "=", "None", ",", "max_records", "=", "None", ",", "next_token", "=", "None", ")", ":", "params", "=", "{", "}", "if", "as_group", ":", "params", "[", "'AutoScalin...
Returns descriptions of what each policy does. This action supports pagination. If the response includes a token, there are more records available. To get the additional records, repeat the request with the response token as the NextToken parameter. If no group name or list of policy na...
[ "Returns", "descriptions", "of", "what", "each", "policy", "does", ".", "This", "action", "supports", "pagination", ".", "If", "the", "response", "includes", "a", "token", "there", "are", "more", "records", "available", ".", "To", "get", "the", "additional", ...
python
train
40.40625
tamasgal/km3pipe
km3pipe/io/clb.py
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/clb.py#L153-L166
def _parse_byte_data(self, byte_data): """Extract the values from byte string.""" self.data_type = b''.join(unpack('cccc', byte_data[:4])).decode() self.run = unpack('>i', byte_data[4:8])[0] self.udp_sequence = unpack('>i', byte_data[8:12])[0] self.timestamp, self.ns_ticks = unpa...
[ "def", "_parse_byte_data", "(", "self", ",", "byte_data", ")", ":", "self", ".", "data_type", "=", "b''", ".", "join", "(", "unpack", "(", "'cccc'", ",", "byte_data", "[", ":", "4", "]", ")", ")", ".", "decode", "(", ")", "self", ".", "run", "=", ...
Extract the values from byte string.
[ "Extract", "the", "values", "from", "byte", "string", "." ]
python
train
47.571429
PyCQA/astroid
astroid/objects.py
https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/objects.py#L77-L113
def super_mro(self): """Get the MRO which will be used to lookup attributes in this super.""" if not isinstance(self.mro_pointer, scoped_nodes.ClassDef): raise exceptions.SuperError( "The first argument to super must be a subtype of " "type, not {mro_pointer}....
[ "def", "super_mro", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "mro_pointer", ",", "scoped_nodes", ".", "ClassDef", ")", ":", "raise", "exceptions", ".", "SuperError", "(", "\"The first argument to super must be a subtype of \"", "\"type, no...
Get the MRO which will be used to lookup attributes in this super.
[ "Get", "the", "MRO", "which", "will", "be", "used", "to", "lookup", "attributes", "in", "this", "super", "." ]
python
train
38.27027
incf-nidash/nidmresults
nidmresults/exporter.py
https://github.com/incf-nidash/nidmresults/blob/438f7cce6abc4a4379b629bd76f4d427891e033f/nidmresults/exporter.py#L148-L532
def export(self): """ Generate a NIDM-Results export. """ try: if not os.path.isdir(self.export_dir): os.mkdir(self.export_dir) # Initialise main bundle self._create_bundle(self.version) self.add_object(self.software) ...
[ "def", "export", "(", "self", ")", ":", "try", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "export_dir", ")", ":", "os", ".", "mkdir", "(", "self", ".", "export_dir", ")", "# Initialise main bundle", "self", ".", "_create_bundl...
Generate a NIDM-Results export.
[ "Generate", "a", "NIDM", "-", "Results", "export", "." ]
python
train
52.093506
Parsely/probably
probably/hll.py
https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/hll.py#L47-L60
def add(self, uuid): """ Adds a key to the HyperLogLog """ if uuid: # Computing the hash try: x = hash64(uuid) except UnicodeEncodeError: x = hash64(uuid.encode('ascii', 'ignore')) # Finding the register to update by using t...
[ "def", "add", "(", "self", ",", "uuid", ")", ":", "if", "uuid", ":", "# Computing the hash", "try", ":", "x", "=", "hash64", "(", "uuid", ")", "except", "UnicodeEncodeError", ":", "x", "=", "hash64", "(", "uuid", ".", "encode", "(", "'ascii'", ",", "...
Adds a key to the HyperLogLog
[ "Adds", "a", "key", "to", "the", "HyperLogLog" ]
python
train
40.857143
Stranger6667/postmarker
postmarker/django/backend.py
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/django/backend.py#L76-L85
def raise_for_response(self, responses): """ Constructs appropriate exception from list of responses and raises it. """ exception_messages = [self.client.format_exception_message(response) for response in responses] if len(exception_messages) == 1: message = exception...
[ "def", "raise_for_response", "(", "self", ",", "responses", ")", ":", "exception_messages", "=", "[", "self", ".", "client", ".", "format_exception_message", "(", "response", ")", "for", "response", "in", "responses", "]", "if", "len", "(", "exception_messages",...
Constructs appropriate exception from list of responses and raises it.
[ "Constructs", "appropriate", "exception", "from", "list", "of", "responses", "and", "raises", "it", "." ]
python
train
44.1
googlefonts/fontbakery
Lib/fontbakery/profiles/googlefonts.py
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L799-L830
def com_google_fonts_check_name_license(ttFont, license): """Check copyright namerecords match license file.""" from fontbakery.constants import PLACEHOLDER_LICENSING_TEXT failed = False placeholder = PLACEHOLDER_LICENSING_TEXT[license] entry_found = False for i, nameRecord in enumerate(ttFont["name"].names...
[ "def", "com_google_fonts_check_name_license", "(", "ttFont", ",", "license", ")", ":", "from", "fontbakery", ".", "constants", "import", "PLACEHOLDER_LICENSING_TEXT", "failed", "=", "False", "placeholder", "=", "PLACEHOLDER_LICENSING_TEXT", "[", "license", "]", "entry_f...
Check copyright namerecords match license file.
[ "Check", "copyright", "namerecords", "match", "license", "file", "." ]
python
train
48.59375
mabuchilab/QNET
docs/_extensions/graphviz_ext.py
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/docs/_extensions/graphviz_ext.py#L210-L267
def render_dot(self, code, options, format, prefix='graphviz'): # type: (nodes.NodeVisitor, unicode, Dict, unicode, unicode) -> Tuple[unicode, unicode] """Render graphviz code into a PNG or PDF output file.""" graphviz_dot = options.get('graphviz_dot', self.builder.config.graphviz_dot) hashkey = (code +...
[ "def", "render_dot", "(", "self", ",", "code", ",", "options", ",", "format", ",", "prefix", "=", "'graphviz'", ")", ":", "# type: (nodes.NodeVisitor, unicode, Dict, unicode, unicode) -> Tuple[unicode, unicode]", "graphviz_dot", "=", "options", ".", "get", "(", "'graphv...
Render graphviz code into a PNG or PDF output file.
[ "Render", "graphviz", "code", "into", "a", "PNG", "or", "PDF", "output", "file", "." ]
python
train
43.758621
epfl-lts2/pygsp
pygsp/learning.py
https://github.com/epfl-lts2/pygsp/blob/8ce5bde39206129287375af24fdbcd7edddca8c5/pygsp/learning.py#L254-L368
def regression_tikhonov(G, y, M, tau=0): r"""Solve a regression problem on graph via Tikhonov minimization. The function solves .. math:: \operatorname*{arg min}_x \| M x - y \|_2^2 + \tau \ x^T L x if :math:`\tau > 0`, and .. math:: \operatorname*{arg min}_x x^T L x \ \text{ s. t. } \ y = M x ...
[ "def", "regression_tikhonov", "(", "G", ",", "y", ",", "M", ",", "tau", "=", "0", ")", ":", "if", "tau", ">", "0", ":", "y", "[", "M", "==", "False", "]", "=", "0", "if", "sparse", ".", "issparse", "(", "G", ".", "L", ")", ":", "def", "Op",...
r"""Solve a regression problem on graph via Tikhonov minimization. The function solves .. math:: \operatorname*{arg min}_x \| M x - y \|_2^2 + \tau \ x^T L x if :math:`\tau > 0`, and .. math:: \operatorname*{arg min}_x x^T L x \ \text{ s. t. } \ y = M x otherwise. Parameters ----------...
[ "r", "Solve", "a", "regression", "problem", "on", "graph", "via", "Tikhonov", "minimization", "." ]
python
train
27.495652
Chilipp/psy-simple
psy_simple/plotters.py
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/plotters.py#L3350-L3352
def ycoord(self): """The y coordinate :class:`xarray.Variable`""" return self.decoder.get_y(self.data, coords=self.data.coords)
[ "def", "ycoord", "(", "self", ")", ":", "return", "self", ".", "decoder", ".", "get_y", "(", "self", ".", "data", ",", "coords", "=", "self", ".", "data", ".", "coords", ")" ]
The y coordinate :class:`xarray.Variable`
[ "The", "y", "coordinate", ":", "class", ":", "xarray", ".", "Variable" ]
python
train
47
wavycloud/pyboto3
pyboto3/snowball.py
https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/snowball.py#L1077-L1184
def update_job(JobId=None, RoleARN=None, Notification=None, Resources=None, AddressId=None, ShippingOption=None, Description=None, SnowballCapacityPreference=None, ForwardingAddressId=None): """ While a job's JobState value is New , you can update some of the information associated with a job. Once the job chan...
[ "def", "update_job", "(", "JobId", "=", "None", ",", "RoleARN", "=", "None", ",", "Notification", "=", "None", ",", "Resources", "=", "None", ",", "AddressId", "=", "None", ",", "ShippingOption", "=", "None", ",", "Description", "=", "None", ",", "Snowba...
While a job's JobState value is New , you can update some of the information associated with a job. Once the job changes to a different job state, usually within 60 minutes of the job being created, this action is no longer available. See also: AWS API Documentation Examples This action allows you to u...
[ "While", "a", "job", "s", "JobState", "value", "is", "New", "you", "can", "update", "some", "of", "the", "information", "associated", "with", "a", "job", ".", "Once", "the", "job", "changes", "to", "a", "different", "job", "state", "usually", "within", "...
python
train
54.416667
ronaldguillen/wave
wave/authentication.py
https://github.com/ronaldguillen/wave/blob/20bb979c917f7634d8257992e6d449dc751256a9/wave/authentication.py#L132-L139
def enforce_csrf(self, request): """ Enforce CSRF validation for session based authentication. """ reason = CSRFCheck().process_view(request, None, (), {}) if reason: # CSRF failed, bail with explicit error message raise exceptions.PermissionDenied('CSRF F...
[ "def", "enforce_csrf", "(", "self", ",", "request", ")", ":", "reason", "=", "CSRFCheck", "(", ")", ".", "process_view", "(", "request", ",", "None", ",", "(", ")", ",", "{", "}", ")", "if", "reason", ":", "# CSRF failed, bail with explicit error message", ...
Enforce CSRF validation for session based authentication.
[ "Enforce", "CSRF", "validation", "for", "session", "based", "authentication", "." ]
python
train
41.625
henriquebastos/django-aggregate-if
aggregate_if.py
https://github.com/henriquebastos/django-aggregate-if/blob/588c1487bc88a8996d4ee9c2c9d50fa4a4484872/aggregate_if.py#L54-L75
def _condition_as_sql(self, qn, connection): ''' Return sql for condition. ''' def escape(value): if isinstance(value, bool): value = str(int(value)) if isinstance(value, six.string_types): # Escape params used with LIKE ...
[ "def", "_condition_as_sql", "(", "self", ",", "qn", ",", "connection", ")", ":", "def", "escape", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "value", "=", "str", "(", "int", "(", "value", ")", ")", "if", "isins...
Return sql for condition.
[ "Return", "sql", "for", "condition", "." ]
python
train
34.409091
chaoss/grimoirelab-sortinghat
sortinghat/parsing/eclipse.py
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parsing/eclipse.py#L83-L147
def __parse_identities(self, json): """Parse identities using Eclipse format. The Eclipse identities format is a JSON document under the "commiters" key. The document should follow the next schema: { 'committers' : { 'john': { 'affiliations': {...
[ "def", "__parse_identities", "(", "self", ",", "json", ")", ":", "try", ":", "for", "committer", "in", "json", "[", "'committers'", "]", ".", "values", "(", ")", ":", "name", "=", "self", ".", "__encode", "(", "committer", "[", "'first'", "]", "+", "...
Parse identities using Eclipse format. The Eclipse identities format is a JSON document under the "commiters" key. The document should follow the next schema: { 'committers' : { 'john': { 'affiliations': { '1': { ...
[ "Parse", "identities", "using", "Eclipse", "format", "." ]
python
train
37.353846
pkkid/python-plexapi
plexapi/server.py
https://github.com/pkkid/python-plexapi/blob/9efbde96441c2bfbf410eacfb46e811e108e8bbc/plexapi/server.py#L403-L417
def transcodeImage(self, media, height, width, opacity=100, saturation=100): """ Returns the URL for a transcoded image from the specified media object. Returns None if no media specified (needed if user tries to pass thumb or art directly). Parameters: heigh...
[ "def", "transcodeImage", "(", "self", ",", "media", ",", "height", ",", "width", ",", "opacity", "=", "100", ",", "saturation", "=", "100", ")", ":", "if", "media", ":", "transcode_url", "=", "'/photo/:/transcode?height=%s&width=%s&opacity=%s&saturation=%s&url=%s'",...
Returns the URL for a transcoded image from the specified media object. Returns None if no media specified (needed if user tries to pass thumb or art directly). Parameters: height (int): Height to transcode the image to. width (int): Width to transcod...
[ "Returns", "the", "URL", "for", "a", "transcoded", "image", "from", "the", "specified", "media", "object", ".", "Returns", "None", "if", "no", "media", "specified", "(", "needed", "if", "user", "tries", "to", "pass", "thumb", "or", "art", "directly", ")", ...
python
train
54.6
mattupstate/cubric
cubric/tasks.py
https://github.com/mattupstate/cubric/blob/a648ce00e4467cd14d71e754240ef6c1f87a34b5/cubric/tasks.py#L11-L17
def create_server(initialize=True): """Create a server""" with provider() as p: host_string = p.create_server() if initialize: env.host_string = host_string initialize_server()
[ "def", "create_server", "(", "initialize", "=", "True", ")", ":", "with", "provider", "(", ")", "as", "p", ":", "host_string", "=", "p", ".", "create_server", "(", ")", "if", "initialize", ":", "env", ".", "host_string", "=", "host_string", "initialize_ser...
Create a server
[ "Create", "a", "server" ]
python
train
31.142857
majerteam/deform_extensions
deform_extensions/__init__.py
https://github.com/majerteam/deform_extensions/blob/fdad612e4889a40f1944611264b943866a3cb96e/deform_extensions/__init__.py#L508-L551
def accordions(self, form): """ return the chlidren of the given form in a dict allowing to render them in accordions with a grid layout :param form: the form object """ fixed = [] accordions = OrderedDict() for child in form.children: section...
[ "def", "accordions", "(", "self", ",", "form", ")", ":", "fixed", "=", "[", "]", "accordions", "=", "OrderedDict", "(", ")", "for", "child", "in", "form", ".", "children", ":", "section", "=", "getattr", "(", "child", ".", "schema", ",", "'section'", ...
return the chlidren of the given form in a dict allowing to render them in accordions with a grid layout :param form: the form object
[ "return", "the", "chlidren", "of", "the", "given", "form", "in", "a", "dict", "allowing", "to", "render", "them", "in", "accordions", "with", "a", "grid", "layout", ":", "param", "form", ":", "the", "form", "object" ]
python
train
34.022727
MonashBI/arcana
arcana/pipeline/base.py
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/pipeline/base.py#L173-L281
def add(self, name, interface, inputs=None, outputs=None, requirements=None, wall_time=None, annotations=None, **kwargs): """ Adds a processing Node to the pipeline Parameters ---------- name : str Name for the node interface : nipype.Interface ...
[ "def", "add", "(", "self", ",", "name", ",", "interface", ",", "inputs", "=", "None", ",", "outputs", "=", "None", ",", "requirements", "=", "None", ",", "wall_time", "=", "None", ",", "annotations", "=", "None", ",", "*", "*", "kwargs", ")", ":", ...
Adds a processing Node to the pipeline Parameters ---------- name : str Name for the node interface : nipype.Interface The interface to use for the node inputs : dict[str, (str, FileFormat) | (Node, str)] Connections from inputs of the pipelin...
[ "Adds", "a", "processing", "Node", "to", "the", "pipeline" ]
python
train
49.522936
csparpa/pyowm
pyowm/utils/xmlutils.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/utils/xmlutils.py#L8-L32
def create_DOM_node_from_dict(d, name, parent_node): """ Dumps dict data to an ``xml.etree.ElementTree.SubElement`` DOM subtree object and attaches it to the specified DOM parent node. The created subtree object is named after the specified name. If the supplied dict is ``None`` no DOM node is creat...
[ "def", "create_DOM_node_from_dict", "(", "d", ",", "name", ",", "parent_node", ")", ":", "if", "d", "is", "not", "None", ":", "root_dict_node", "=", "ET", ".", "SubElement", "(", "parent_node", ",", "name", ")", "for", "key", ",", "value", "in", "d", "...
Dumps dict data to an ``xml.etree.ElementTree.SubElement`` DOM subtree object and attaches it to the specified DOM parent node. The created subtree object is named after the specified name. If the supplied dict is ``None`` no DOM node is created for it as well as no DOM subnodes are generated for event...
[ "Dumps", "dict", "data", "to", "an", "xml", ".", "etree", ".", "ElementTree", ".", "SubElement", "DOM", "subtree", "object", "and", "attaches", "it", "to", "the", "specified", "DOM", "parent", "node", ".", "The", "created", "subtree", "object", "is", "name...
python
train
42.48
Fizzadar/pyinfra
pyinfra/modules/server.py
https://github.com/Fizzadar/pyinfra/blob/006f751f7db2e07d32522c0285160783de2feb79/pyinfra/modules/server.py#L79-L95
def script_template(state, host, template_filename, chdir=None, **data): ''' Generate, upload and execute a local script template on the remote host. + template_filename: local script template filename + chdir: directory to cd into before executing the script ''' temp_file = state.get_temp_fil...
[ "def", "script_template", "(", "state", ",", "host", ",", "template_filename", ",", "chdir", "=", "None", ",", "*", "*", "data", ")", ":", "temp_file", "=", "state", ".", "get_temp_filename", "(", "template_filename", ")", "yield", "files", ".", "template", ...
Generate, upload and execute a local script template on the remote host. + template_filename: local script template filename + chdir: directory to cd into before executing the script
[ "Generate", "upload", "and", "execute", "a", "local", "script", "template", "on", "the", "remote", "host", "." ]
python
train
31.882353