repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
mikedh/trimesh
trimesh/visual/color.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/visual/color.py#L703-L737
def interpolate(values, color_map=None, dtype=np.uint8): """ Given a 1D list of values, return interpolated colors for the range. Parameters --------------- values : (n, ) float Values to be interpolated over color_map : None, or str Key to a colormap contained in: matplot...
[ "def", "interpolate", "(", "values", ",", "color_map", "=", "None", ",", "dtype", "=", "np", ".", "uint8", ")", ":", "# get a color interpolation function", "if", "color_map", "is", "None", ":", "cmap", "=", "linear_color_map", "else", ":", "from", "matplotlib...
Given a 1D list of values, return interpolated colors for the range. Parameters --------------- values : (n, ) float Values to be interpolated over color_map : None, or str Key to a colormap contained in: matplotlib.pyplot.colormaps() e.g: 'viridis' Returns --------...
[ "Given", "a", "1D", "list", "of", "values", "return", "interpolated", "colors", "for", "the", "range", "." ]
python
train
SmokinCaterpillar/pypet
pypet/storageservice.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L2732-L2775
def _tree_load_link(self, new_traj_node, load_data, traj, as_new, hdf5_soft_link): """ Loads a link :param new_traj_node: Node in traj containing link :param load_data: How to load data in the linked node :param traj: The trajectory :param as_new: If data in linked node...
[ "def", "_tree_load_link", "(", "self", ",", "new_traj_node", ",", "load_data", ",", "traj", ",", "as_new", ",", "hdf5_soft_link", ")", ":", "try", ":", "linked_group", "=", "hdf5_soft_link", "(", ")", "link_name", "=", "hdf5_soft_link", ".", "_v_name", "if", ...
Loads a link :param new_traj_node: Node in traj containing link :param load_data: How to load data in the linked node :param traj: The trajectory :param as_new: If data in linked node should be loaded as new :param hdf5_soft_link: The hdf5 soft link
[ "Loads", "a", "link", ":", "param", "new_traj_node", ":", "Node", "in", "traj", "containing", "link", ":", "param", "load_data", ":", "How", "to", "load", "data", "in", "the", "linked", "node", ":", "param", "traj", ":", "The", "trajectory", ":", "param"...
python
test
apache/spark
python/pyspark/broadcast.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/broadcast.py#L135-L148
def value(self): """ Return the broadcasted value """ if not hasattr(self, "_value") and self._path is not None: # we only need to decrypt it here when encryption is enabled and # if its on the driver, since executor decryption is handled already if self._sc i...
[ "def", "value", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_value\"", ")", "and", "self", ".", "_path", "is", "not", "None", ":", "# we only need to decrypt it here when encryption is enabled and", "# if its on the driver, since executor decrypt...
Return the broadcasted value
[ "Return", "the", "broadcasted", "value" ]
python
train
SCIP-Interfaces/PySCIPOpt
examples/finished/piecewise.py
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/piecewise.py#L178-L217
def convex_comb_agg_log(model,a,b): """convex_comb_agg_log -- add piecewise relation with a logarithmic number of binary variables using the convex combination formulation -- non-disaggregated. Parameters: - model: a model where to include the piecewise linear relation - a[k]: x-coordinate o...
[ "def", "convex_comb_agg_log", "(", "model", ",", "a", ",", "b", ")", ":", "K", "=", "len", "(", "a", ")", "-", "1", "G", "=", "int", "(", "math", ".", "ceil", "(", "(", "math", ".", "log", "(", "K", ")", "/", "math", ".", "log", "(", "2", ...
convex_comb_agg_log -- add piecewise relation with a logarithmic number of binary variables using the convex combination formulation -- non-disaggregated. Parameters: - model: a model where to include the piecewise linear relation - a[k]: x-coordinate of the k-th point in the piecewise linear re...
[ "convex_comb_agg_log", "--", "add", "piecewise", "relation", "with", "a", "logarithmic", "number", "of", "binary", "variables", "using", "the", "convex", "combination", "formulation", "--", "non", "-", "disaggregated", ".", "Parameters", ":", "-", "model", ":", ...
python
train
python-openxml/python-docx
docx/image/png.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/image/png.py#L251-L258
def from_offset(cls, chunk_type, stream_rdr, offset): """ Return an _IHDRChunk instance containing the image dimensions extracted from the IHDR chunk in *stream* at *offset*. """ px_width = stream_rdr.read_long(offset) px_height = stream_rdr.read_long(offset, 4) r...
[ "def", "from_offset", "(", "cls", ",", "chunk_type", ",", "stream_rdr", ",", "offset", ")", ":", "px_width", "=", "stream_rdr", ".", "read_long", "(", "offset", ")", "px_height", "=", "stream_rdr", ".", "read_long", "(", "offset", ",", "4", ")", "return", ...
Return an _IHDRChunk instance containing the image dimensions extracted from the IHDR chunk in *stream* at *offset*.
[ "Return", "an", "_IHDRChunk", "instance", "containing", "the", "image", "dimensions", "extracted", "from", "the", "IHDR", "chunk", "in", "*", "stream", "*", "at", "*", "offset", "*", "." ]
python
train
symphonyoss/python-symphony
symphony/Pod/users.py
https://github.com/symphonyoss/python-symphony/blob/b939f35fbda461183ec0c01790c754f89a295be0/symphony/Pod/users.py#L28-L35
def get_user_id_by_user(self, username): ''' get user id by username ''' response, status_code = self.__pod__.Users.get_v2_user( sessionToken=self.__session__, username=username ).result() self.logger.debug('%s: %s' % (status_code, response)) return status...
[ "def", "get_user_id_by_user", "(", "self", ",", "username", ")", ":", "response", ",", "status_code", "=", "self", ".", "__pod__", ".", "Users", ".", "get_v2_user", "(", "sessionToken", "=", "self", ".", "__session__", ",", "username", "=", "username", ")", ...
get user id by username
[ "get", "user", "id", "by", "username" ]
python
train
openfisca/openfisca-core
openfisca_core/periods.py
https://github.com/openfisca/openfisca-core/blob/92ce9396e29ae5d9bac5ea604cfce88517c6b35c/openfisca_core/periods.py#L569-L575
def contains(self, other): """ Returns ``True`` if the period contains ``other``. For instance, ``period(2015)`` contains ``period(2015-01)`` """ if not isinstance(other, Period): other = period(other) return self.start <= other.start and self.stop >= other.stop
[ "def", "contains", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "Period", ")", ":", "other", "=", "period", "(", "other", ")", "return", "self", ".", "start", "<=", "other", ".", "start", "and", "self", ".", "s...
Returns ``True`` if the period contains ``other``. For instance, ``period(2015)`` contains ``period(2015-01)``
[ "Returns", "True", "if", "the", "period", "contains", "other", ".", "For", "instance", "period", "(", "2015", ")", "contains", "period", "(", "2015", "-", "01", ")" ]
python
train
rochacbruno/flasgger
flasgger/base.py
https://github.com/rochacbruno/flasgger/blob/fef154f61d7afca548067be0c758c3dd71cc4c97/flasgger/base.py#L620-L673
def validate( self, schema_id, validation_function=None, validation_error_handler=None): """ A decorator that is used to validate incoming requests data against a schema swagger = Swagger(app) @app.route('/pets', methods=['POST']) @sw...
[ "def", "validate", "(", "self", ",", "schema_id", ",", "validation_function", "=", "None", ",", "validation_error_handler", "=", "None", ")", ":", "if", "validation_function", "is", "None", ":", "validation_function", "=", "self", ".", "validation_function", "if",...
A decorator that is used to validate incoming requests data against a schema swagger = Swagger(app) @app.route('/pets', methods=['POST']) @swagger.validate('Pet') @swag_from("pet_post_endpoint.yml") def post(): return db.insert(reques...
[ "A", "decorator", "that", "is", "used", "to", "validate", "incoming", "requests", "data", "against", "a", "schema" ]
python
train
jrderuiter/pybiomart
src/pybiomart/server.py
https://github.com/jrderuiter/pybiomart/blob/7802d45fe88549ab0512d6f37f815fc43b172b39/src/pybiomart/server.py#L64-L76
def list_marts(self): """Lists available marts in a readable DataFrame format. Returns: pd.DataFrame: Frame listing available marts. """ def _row_gen(attributes): for attr in attributes.values(): yield (attr.name, attr.display_name) retu...
[ "def", "list_marts", "(", "self", ")", ":", "def", "_row_gen", "(", "attributes", ")", ":", "for", "attr", "in", "attributes", ".", "values", "(", ")", ":", "yield", "(", "attr", ".", "name", ",", "attr", ".", "display_name", ")", "return", "pd", "."...
Lists available marts in a readable DataFrame format. Returns: pd.DataFrame: Frame listing available marts.
[ "Lists", "available", "marts", "in", "a", "readable", "DataFrame", "format", "." ]
python
train
kyper-data/python-highcharts
highcharts/highmaps/highmaps.py
https://github.com/kyper-data/python-highcharts/blob/a4c488ae5c2e125616efad5a722f3dfd8a9bc450/highcharts/highmaps/highmaps.py#L201-L223
def add_data_set(self, data, series_type="map", name=None, is_coordinate = False, **kwargs): """set data for series option in highmaps """ self.data_set_count += 1 if not name: name = "Series %d" % self.data_set_count kwargs.update({'name':name}) if is_coord...
[ "def", "add_data_set", "(", "self", ",", "data", ",", "series_type", "=", "\"map\"", ",", "name", "=", "None", ",", "is_coordinate", "=", "False", ",", "*", "*", "kwargs", ")", ":", "self", ".", "data_set_count", "+=", "1", "if", "not", "name", ":", ...
set data for series option in highmaps
[ "set", "data", "for", "series", "option", "in", "highmaps" ]
python
train
jbrudvik/yahooscraper
yahooscraper/login.py
https://github.com/jbrudvik/yahooscraper/blob/e880323fea0dd25f03410eea9d088760ba7c3528/yahooscraper/login.py#L18-L37
def authenticated_session(username, password): """ Given username and password, return an authenticated Yahoo `requests` session that can be used for further scraping requests. Throw an AuthencationError if authentication fails. """ session = requests.Session() session.headers.update(header...
[ "def", "authenticated_session", "(", "username", ",", "password", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "session", ".", "headers", ".", "update", "(", "headers", "(", ")", ")", "response", "=", "session", ".", "get", "(", "url",...
Given username and password, return an authenticated Yahoo `requests` session that can be used for further scraping requests. Throw an AuthencationError if authentication fails.
[ "Given", "username", "and", "password", "return", "an", "authenticated", "Yahoo", "requests", "session", "that", "can", "be", "used", "for", "further", "scraping", "requests", "." ]
python
train
ttroy50/pyephember
pyephember/pyephember.py
https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L319-L332
def activate_boost_by_name(self, zone_name, target_temperature, num_hours=1): """ Activate boost by the name of the zone """ zone = self.get_zone(zone_name) if zone is None: ...
[ "def", "activate_boost_by_name", "(", "self", ",", "zone_name", ",", "target_temperature", ",", "num_hours", "=", "1", ")", ":", "zone", "=", "self", ".", "get_zone", "(", "zone_name", ")", "if", "zone", "is", "None", ":", "raise", "RuntimeError", "(", "\"...
Activate boost by the name of the zone
[ "Activate", "boost", "by", "the", "name", "of", "the", "zone" ]
python
train
bootphon/h5features
h5features/h5features.py
https://github.com/bootphon/h5features/blob/d5f95db0f1cee58ac1ba4575d1212e796c39e1f9/h5features/h5features.py#L161-L165
def simple_write(filename, group, times, features, properties=None, item='item', mode='a'): """Simplified version of `write()` when there is only one item.""" write(filename, group, [item], [times], [features], mode=mode, properties=[properties] if properties is not None else None)
[ "def", "simple_write", "(", "filename", ",", "group", ",", "times", ",", "features", ",", "properties", "=", "None", ",", "item", "=", "'item'", ",", "mode", "=", "'a'", ")", ":", "write", "(", "filename", ",", "group", ",", "[", "item", "]", ",", ...
Simplified version of `write()` when there is only one item.
[ "Simplified", "version", "of", "write", "()", "when", "there", "is", "only", "one", "item", "." ]
python
train
grycap/cpyutils
evaluate.py
https://github.com/grycap/cpyutils/blob/fa966fc6d2ae1e1e799e19941561aa79b617f1b1/evaluate.py#L616-L630
def p_term_var(self, p): ''' term : VAR ''' _LOGGER.debug("term -> VAR") # TODO: determine the type of the var if p[1] not in self._VAR_VALUES: if self._autodefine_vars: self._VAR_VALUES[p[1]] = TypedClass(None, TypedClass.UNKNOWN) ...
[ "def", "p_term_var", "(", "self", ",", "p", ")", ":", "_LOGGER", ".", "debug", "(", "\"term -> VAR\"", ")", "# TODO: determine the type of the var", "if", "p", "[", "1", "]", "not", "in", "self", ".", "_VAR_VALUES", ":", "if", "self", ".", "_autodefine_vars"...
term : VAR
[ "term", ":", "VAR" ]
python
train
scanny/python-pptx
pptx/dml/fill.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/dml/fill.py#L67-L78
def gradient(self): """Sets the fill type to gradient. If the fill is not already a gradient, a default gradient is added. The default gradient corresponds to the default in the built-in PowerPoint "White" template. This gradient is linear at angle 90-degrees (upward), with two ...
[ "def", "gradient", "(", "self", ")", ":", "gradFill", "=", "self", ".", "_xPr", ".", "get_or_change_to_gradFill", "(", ")", "self", ".", "_fill", "=", "_GradFill", "(", "gradFill", ")" ]
Sets the fill type to gradient. If the fill is not already a gradient, a default gradient is added. The default gradient corresponds to the default in the built-in PowerPoint "White" template. This gradient is linear at angle 90-degrees (upward), with two stops. The first stop is Accent...
[ "Sets", "the", "fill", "type", "to", "gradient", "." ]
python
train
jaraco/wolframalpha
wolframalpha/__init__.py
https://github.com/jaraco/wolframalpha/blob/50bf2e047b698e308a9a88770a23e7e210aa5bcb/wolframalpha/__init__.py#L206-L215
def results(self): """ The pods that hold the response to a simple, discrete query. """ return ( pod for pod in self.pods if pod.primary or pod.title == 'Result' )
[ "def", "results", "(", "self", ")", ":", "return", "(", "pod", "for", "pod", "in", "self", ".", "pods", "if", "pod", ".", "primary", "or", "pod", ".", "title", "==", "'Result'", ")" ]
The pods that hold the response to a simple, discrete query.
[ "The", "pods", "that", "hold", "the", "response", "to", "a", "simple", "discrete", "query", "." ]
python
test
SecurityInnovation/PGPy
pgpy/pgp.py
https://github.com/SecurityInnovation/PGPy/blob/f1c3d68e32c334f5aa14c34580925e97f17f4fde/pgpy/pgp.py#L172-L180
def is_expired(self): """ ``True`` if the signature has an expiration date, and is expired. Otherwise, ``False`` """ expires_at = self.expires_at if expires_at is not None and expires_at != self.created: return expires_at < datetime.utcnow() return False
[ "def", "is_expired", "(", "self", ")", ":", "expires_at", "=", "self", ".", "expires_at", "if", "expires_at", "is", "not", "None", "and", "expires_at", "!=", "self", ".", "created", ":", "return", "expires_at", "<", "datetime", ".", "utcnow", "(", ")", "...
``True`` if the signature has an expiration date, and is expired. Otherwise, ``False``
[ "True", "if", "the", "signature", "has", "an", "expiration", "date", "and", "is", "expired", ".", "Otherwise", "False" ]
python
train
smdabdoub/phylotoast
bin/filter_rep_set.py
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/filter_rep_set.py#L32-L47
def filter_rep_set(inF, otuSet): """ Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs """ seqs = [] for record ...
[ "def", "filter_rep_set", "(", "inF", ",", "otuSet", ")", ":", "seqs", "=", "[", "]", "for", "record", "in", "SeqIO", ".", "parse", "(", "inF", ",", "\"fasta\"", ")", ":", "if", "record", ".", "id", "in", "otuSet", ":", "seqs", ".", "append", "(", ...
Parse the rep set file and remove all sequences not associated with unique OTUs. :@type inF: file :@param inF: The representative sequence set :@rtype: list :@return: The set of sequences associated with unique OTUs
[ "Parse", "the", "rep", "set", "file", "and", "remove", "all", "sequences", "not", "associated", "with", "unique", "OTUs", "." ]
python
train
nitely/django-hooks
hooks/formhook.py
https://github.com/nitely/django-hooks/blob/26ea2150c9be110e90b9ee60fbfd1065ac30ab1d/hooks/formhook.py#L41-L53
def save(self, *args, **kwargs): """ Save all the forms :param \*args: Positional arguments passed to the forms :param \*\*kwargs: Keyword arguments passed to the forms :return: Sequence of returned values by all the forms as tuples of (instance, result) :rtype: list ...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "[", "(", "form", ",", "form", ".", "save", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", "for", "form", "in", "self", ".", "instances", "]" ]
Save all the forms :param \*args: Positional arguments passed to the forms :param \*\*kwargs: Keyword arguments passed to the forms :return: Sequence of returned values by all the forms as tuples of (instance, result) :rtype: list
[ "Save", "all", "the", "forms" ]
python
train
d0c-s4vage/pfp
pfp/interp.py
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L366-L373
def get_local(self, name, recurse=True): """Get the local field (search for it) from the scope stack. An alias for ``get_var`` :name: The name of the local field """ self._dlog("getting local '{}'".format(name)) return self._search("vars", name, recurse)
[ "def", "get_local", "(", "self", ",", "name", ",", "recurse", "=", "True", ")", ":", "self", ".", "_dlog", "(", "\"getting local '{}'\"", ".", "format", "(", "name", ")", ")", "return", "self", ".", "_search", "(", "\"vars\"", ",", "name", ",", "recurs...
Get the local field (search for it) from the scope stack. An alias for ``get_var`` :name: The name of the local field
[ "Get", "the", "local", "field", "(", "search", "for", "it", ")", "from", "the", "scope", "stack", ".", "An", "alias", "for", "get_var" ]
python
train
python-diamond/Diamond
src/collectors/nvidia_gpu/nvidia_gpu.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nvidia_gpu/nvidia_gpu.py#L81-L117
def collect_via_pynvml(self, stats_config): """ Use pynvml python binding to collect metrics :param stats_config: :return: """ try: NVML_TEMPERATURE_GPU = 0 pynvml.nvmlInit() device_count = pynvml.nvmlDeviceGetCount() for d...
[ "def", "collect_via_pynvml", "(", "self", ",", "stats_config", ")", ":", "try", ":", "NVML_TEMPERATURE_GPU", "=", "0", "pynvml", ".", "nvmlInit", "(", ")", "device_count", "=", "pynvml", ".", "nvmlDeviceGetCount", "(", ")", "for", "device_index", "in", "xrange...
Use pynvml python binding to collect metrics :param stats_config: :return:
[ "Use", "pynvml", "python", "binding", "to", "collect", "metrics", ":", "param", "stats_config", ":", ":", "return", ":" ]
python
train
cjdrake/pyeda
pyeda/parsing/pla.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/parsing/pla.py#L50-L151
def parse(s): """ Parse an input string in PLA format, and return an intermediate representation dict. Parameters ---------- s : str String containing a PLA. Returns ------- A dict with all PLA information: =============== ============ ===========================...
[ "def", "parse", "(", "s", ")", ":", "d", "=", "dict", "(", "ninputs", "=", "None", ",", "noutputs", "=", "None", ",", "input_labels", "=", "None", ",", "output_labels", "=", "None", ",", "intype", "=", "None", ",", "cover", "=", "set", "(", ")", ...
Parse an input string in PLA format, and return an intermediate representation dict. Parameters ---------- s : str String containing a PLA. Returns ------- A dict with all PLA information: =============== ============ ================================= Key ...
[ "Parse", "an", "input", "string", "in", "PLA", "format", "and", "return", "an", "intermediate", "representation", "dict", "." ]
python
train
pandas-dev/pandas
scripts/validate_docstrings.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/scripts/validate_docstrings.py#L599-L785
def get_validation_data(doc): """ Validate the docstring. Parameters ---------- doc : Docstring A Docstring object with the given function name. Returns ------- tuple errors : list of tuple Errors occurred during validation. warnings : list of tuple ...
[ "def", "get_validation_data", "(", "doc", ")", ":", "errs", "=", "[", "]", "wrns", "=", "[", "]", "if", "not", "doc", ".", "raw_doc", ":", "errs", ".", "append", "(", "error", "(", "'GL08'", ")", ")", "return", "errs", ",", "wrns", ",", "''", "if...
Validate the docstring. Parameters ---------- doc : Docstring A Docstring object with the given function name. Returns ------- tuple errors : list of tuple Errors occurred during validation. warnings : list of tuple Warnings occurred during valid...
[ "Validate", "the", "docstring", "." ]
python
train
merll/docker-map
dockermap/client/docker_util.py
https://github.com/merll/docker-map/blob/e14fe86a6ff5c33d121eb2f9157e9359cb80dd02/dockermap/client/docker_util.py#L57-L77
def primary_container_name(names, default=None, strip_trailing_slash=True): """ From the list of names, finds the primary name of the container. Returns the defined default value (e.g. the container id or ``None``) in case it cannot find any. :param names: List with name and aliases of the container. ...
[ "def", "primary_container_name", "(", "names", ",", "default", "=", "None", ",", "strip_trailing_slash", "=", "True", ")", ":", "if", "strip_trailing_slash", ":", "ex_names", "=", "[", "name", "[", "1", ":", "]", "for", "name", "in", "names", "if", "name",...
From the list of names, finds the primary name of the container. Returns the defined default value (e.g. the container id or ``None``) in case it cannot find any. :param names: List with name and aliases of the container. :type names: list[unicode | str] :param default: Default value. :param strip_...
[ "From", "the", "list", "of", "names", "finds", "the", "primary", "name", "of", "the", "container", ".", "Returns", "the", "defined", "default", "value", "(", "e", ".", "g", ".", "the", "container", "id", "or", "None", ")", "in", "case", "it", "cannot",...
python
train
Ouranosinc/xclim
xclim/run_length.py
https://github.com/Ouranosinc/xclim/blob/2080d139188bd8de2aeca097a025c2d89d6e0e09/xclim/run_length.py#L44-L63
def longest_run(da, dim='time'): """Return the length of the longest consecutive run of True values. Parameters ---------- arr : N-dimensional array (boolean) Input array dim : Xarray dimension (default = 'time') Dimension along which to calculate consecutive run...
[ "def", "longest_run", "(", "da", ",", "dim", "=", "'time'", ")", ":", "d", "=", "rle", "(", "da", ",", "dim", "=", "dim", ")", "rl_long", "=", "d", ".", "max", "(", "dim", "=", "dim", ")", "return", "rl_long" ]
Return the length of the longest consecutive run of True values. Parameters ---------- arr : N-dimensional array (boolean) Input array dim : Xarray dimension (default = 'time') Dimension along which to calculate consecutive run Returns ------- ...
[ "Return", "the", "length", "of", "the", "longest", "consecutive", "run", "of", "True", "values", "." ]
python
train
Miserlou/Zappa
zappa/cli.py
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2772-L2797
def handle(): # pragma: no cover """ Main program execution handler. """ try: cli = ZappaCLI() sys.exit(cli.handle()) except SystemExit as e: # pragma: no cover cli.on_exit() sys.exit(e.code) except KeyboardInterrupt: # pragma: no cover cli.on_exit() ...
[ "def", "handle", "(", ")", ":", "# pragma: no cover", "try", ":", "cli", "=", "ZappaCLI", "(", ")", "sys", ".", "exit", "(", "cli", ".", "handle", "(", ")", ")", "except", "SystemExit", "as", "e", ":", "# pragma: no cover", "cli", ".", "on_exit", "(", ...
Main program execution handler.
[ "Main", "program", "execution", "handler", "." ]
python
train
bmcfee/muda
muda/core.py
https://github.com/bmcfee/muda/blob/ff82efdfaeb98da0a9f9124845826eb20536a9ba/muda/core.py#L18-L65
def jam_pack(jam, **kwargs): '''Pack data into a jams sandbox. If not already present, this creates a `muda` field within `jam.sandbox`, along with `history`, `state`, and version arrays which are populated by deformation objects. Any additional fields can be added to the `muda` sandbox by supplyi...
[ "def", "jam_pack", "(", "jam", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "jam", ".", "sandbox", ",", "'muda'", ")", ":", "# If there's no mudabox, create one", "jam", ".", "sandbox", ".", "muda", "=", "jams", ".", "Sandbox", "(", ...
Pack data into a jams sandbox. If not already present, this creates a `muda` field within `jam.sandbox`, along with `history`, `state`, and version arrays which are populated by deformation objects. Any additional fields can be added to the `muda` sandbox by supplying keyword arguments. Param...
[ "Pack", "data", "into", "a", "jams", "sandbox", "." ]
python
valid
voronind/vk
vk/session.py
https://github.com/voronind/vk/blob/37f41c7634f67149d4dab8017be0adca5ea3dc24/vk/session.py#L77-L84
def on_api_error_14(self, request): """ 14. Captcha needed """ request.method_params['captcha_key'] = self.get_captcha_key(request) request.method_params['captcha_sid'] = request.api_error.captcha_sid return self.send(request)
[ "def", "on_api_error_14", "(", "self", ",", "request", ")", ":", "request", ".", "method_params", "[", "'captcha_key'", "]", "=", "self", ".", "get_captcha_key", "(", "request", ")", "request", ".", "method_params", "[", "'captcha_sid'", "]", "=", "request", ...
14. Captcha needed
[ "14", ".", "Captcha", "needed" ]
python
train
crossbario/txaio-etcd
txaioetcd/_client_tx.py
https://github.com/crossbario/txaio-etcd/blob/c9aebff7f288a0b219bffc9d2579d22cf543baa5/txaioetcd/_client_tx.py#L256-L291
def set(self, key, value, lease=None, return_previous=None, timeout=None): """ Set the value for the key in the key-value store. Setting a value on a key increments the revision of the key-value store and generates one event in the event history. :param key: key is the ...
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "lease", "=", "None", ",", "return_previous", "=", "None", ",", "timeout", "=", "None", ")", ":", "assembler", "=", "commons", ".", "PutRequestAssembler", "(", "self", ".", "_url", ",", "key", ...
Set the value for the key in the key-value store. Setting a value on a key increments the revision of the key-value store and generates one event in the event history. :param key: key is the key, in bytes, to put into the key-value store. :type key: bytes :...
[ "Set", "the", "value", "for", "the", "key", "in", "the", "key", "-", "value", "store", "." ]
python
train
pytest-dev/pluggy
scripts/release.py
https://github.com/pytest-dev/pluggy/blob/4de9e440eeadd9f0eb8c5232b349ef64e20e33fb/scripts/release.py#L36-L44
def pre_release(version): """Generates new docs, release announcements and creates a local tag.""" create_branch(version) changelog(version, write_out=True) check_call(["git", "commit", "-a", "-m", f"Preparing release {version}"]) print() print(f"{Fore.GREEN}Please push your branch to your for...
[ "def", "pre_release", "(", "version", ")", ":", "create_branch", "(", "version", ")", "changelog", "(", "version", ",", "write_out", "=", "True", ")", "check_call", "(", "[", "\"git\"", ",", "\"commit\"", ",", "\"-a\"", ",", "\"-m\"", ",", "f\"Preparing rele...
Generates new docs, release announcements and creates a local tag.
[ "Generates", "new", "docs", "release", "announcements", "and", "creates", "a", "local", "tag", "." ]
python
train
Garee/pytodoist
pytodoist/todoist.py
https://github.com/Garee/pytodoist/blob/3359cbff485ebdbbb4ffbd58d71e21a817874dd7/pytodoist/todoist.py#L515-L530
def get_uncompleted_tasks(self): """Return all of a user's uncompleted tasks. .. warning:: Requires Todoist premium. :return: A list of uncompleted tasks. :rtype: list of :class:`pytodoist.todoist.Task` >>> from pytodoist import todoist >>> user = todoist.login('john.d...
[ "def", "get_uncompleted_tasks", "(", "self", ")", ":", "tasks", "=", "(", "p", ".", "get_uncompleted_tasks", "(", ")", "for", "p", "in", "self", ".", "get_projects", "(", ")", ")", "return", "list", "(", "itertools", ".", "chain", ".", "from_iterable", "...
Return all of a user's uncompleted tasks. .. warning:: Requires Todoist premium. :return: A list of uncompleted tasks. :rtype: list of :class:`pytodoist.todoist.Task` >>> from pytodoist import todoist >>> user = todoist.login('john.doe@gmail.com', 'password') >>> uncom...
[ "Return", "all", "of", "a", "user", "s", "uncompleted", "tasks", "." ]
python
train
cackharot/suds-py3
suds/servicedefinition.py
https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/servicedefinition.py#L158-L170
def nextprefix(self): """ Get the next available prefix. This means a prefix starting with 'ns' with a number appended as (ns0, ns1, ..) that is not already defined on the wsdl document. """ used = [ns[0] for ns in self.prefixes] used += [ns[0] for ns in self.wsd...
[ "def", "nextprefix", "(", "self", ")", ":", "used", "=", "[", "ns", "[", "0", "]", "for", "ns", "in", "self", ".", "prefixes", "]", "used", "+=", "[", "ns", "[", "0", "]", "for", "ns", "in", "self", ".", "wsdl", ".", "root", ".", "nsprefixes", ...
Get the next available prefix. This means a prefix starting with 'ns' with a number appended as (ns0, ns1, ..) that is not already defined on the wsdl document.
[ "Get", "the", "next", "available", "prefix", ".", "This", "means", "a", "prefix", "starting", "with", "ns", "with", "a", "number", "appended", "as", "(", "ns0", "ns1", "..", ")", "that", "is", "not", "already", "defined", "on", "the", "wsdl", "document",...
python
train
mjirik/io3d
io3d/misc.py
https://github.com/mjirik/io3d/blob/ccaf3e378dcc967f2565d477fc27583fd0f61fcc/io3d/misc.py#L30-L58
def suggest_filename(file_path, exists=None): """ Try if exist path and append number to its end. For debug you can set as input if file exists or not. """ import os.path import re if not isinstance(exists, bool): exists = os.path.exists(file_path) if exists: file_path, ...
[ "def", "suggest_filename", "(", "file_path", ",", "exists", "=", "None", ")", ":", "import", "os", ".", "path", "import", "re", "if", "not", "isinstance", "(", "exists", ",", "bool", ")", ":", "exists", "=", "os", ".", "path", ".", "exists", "(", "fi...
Try if exist path and append number to its end. For debug you can set as input if file exists or not.
[ "Try", "if", "exist", "path", "and", "append", "number", "to", "its", "end", ".", "For", "debug", "you", "can", "set", "as", "input", "if", "file", "exists", "or", "not", "." ]
python
train
ChristianTremblay/BAC0
BAC0/core/utils/notes.py
https://github.com/ChristianTremblay/BAC0/blob/8d95b065ea068524a08f5b0c34322ebeeba95d06/BAC0/core/utils/notes.py#L44-L85
def update_log_level(level=None, *, file=None, stderr=None, stdout=None): """ Typical usage : Normal BAC0.log_level(file='warning', stdout='warning', stderr='error') Info on console....but not in file BAC0.log_level(file='warning', stdout='info', stderr='error') Debug ...
[ "def", "update_log_level", "(", "level", "=", "None", ",", "*", ",", "file", "=", "None", ",", "stderr", "=", "None", ",", "stdout", "=", "None", ")", ":", "if", "level", ":", "file", "=", "level", "stderr", "=", "level", "stdout", "=", "level", "f...
Typical usage : Normal BAC0.log_level(file='warning', stdout='warning', stderr='error') Info on console....but not in file BAC0.log_level(file='warning', stdout='info', stderr='error') Debug BAC0.log_level(file='debug', stdout='info', stderr='error')
[ "Typical", "usage", ":", "Normal", "BAC0", ".", "log_level", "(", "file", "=", "warning", "stdout", "=", "warning", "stderr", "=", "error", ")", "Info", "on", "console", "....", "but", "not", "in", "file", "BAC0", ".", "log_level", "(", "file", "=", "w...
python
train
openego/eTraGo
etrago/tools/utilities.py
https://github.com/openego/eTraGo/blob/2a8fc6d4368d0e9abe6fe0d0c39baf66ea0126b9/etrago/tools/utilities.py#L1652-L1755
def crossborder_capacity(network, method, capacity_factor): """ Adjust interconnector capacties. Parameters ---------- network : :class:`pypsa.Network Overall container of PyPSA method : string Method of correction. Options are 'ntc_acer' and 'thermal_acer'. 'ntc_acer' c...
[ "def", "crossborder_capacity", "(", "network", ",", "method", ",", "capacity_factor", ")", ":", "if", "method", "==", "'ntc_acer'", ":", "cap_per_country", "=", "{", "'AT'", ":", "4900", ",", "'CH'", ":", "2695", ",", "'CZ'", ":", "1301", ",", "'DK'", ":...
Adjust interconnector capacties. Parameters ---------- network : :class:`pypsa.Network Overall container of PyPSA method : string Method of correction. Options are 'ntc_acer' and 'thermal_acer'. 'ntc_acer' corrects all capacities according to values published by the ACE...
[ "Adjust", "interconnector", "capacties", "." ]
python
train
ethereum/web3.py
web3/_utils/decorators.py
https://github.com/ethereum/web3.py/blob/71b8bf03dc6d332dd97d8902a38ffab6f8b5a5ab/web3/_utils/decorators.py#L42-L59
def deprecated_for(replace_message): """ Decorate a deprecated function, with info about what to use instead, like: @deprecated_for("toBytes()") def toAscii(arg): ... """ def decorator(to_wrap): @functools.wraps(to_wrap) def wrapper(*args, **kwargs): warnings...
[ "def", "deprecated_for", "(", "replace_message", ")", ":", "def", "decorator", "(", "to_wrap", ")", ":", "@", "functools", ".", "wraps", "(", "to_wrap", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn"...
Decorate a deprecated function, with info about what to use instead, like: @deprecated_for("toBytes()") def toAscii(arg): ...
[ "Decorate", "a", "deprecated", "function", "with", "info", "about", "what", "to", "use", "instead", "like", ":" ]
python
train
sosreport/sos
sos/utilities.py
https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L50-L62
def convert_bytes(bytes_, K=1 << 10, M=1 << 20, G=1 << 30, T=1 << 40): """Converts a number of bytes to a shorter, more human friendly format""" fn = float(bytes_) if bytes_ >= T: return '%.1fT' % (fn / T) elif bytes_ >= G: return '%.1fG' % (fn / G) elif bytes_ >= M: return '...
[ "def", "convert_bytes", "(", "bytes_", ",", "K", "=", "1", "<<", "10", ",", "M", "=", "1", "<<", "20", ",", "G", "=", "1", "<<", "30", ",", "T", "=", "1", "<<", "40", ")", ":", "fn", "=", "float", "(", "bytes_", ")", "if", "bytes_", ">=", ...
Converts a number of bytes to a shorter, more human friendly format
[ "Converts", "a", "number", "of", "bytes", "to", "a", "shorter", "more", "human", "friendly", "format" ]
python
train
SwissDataScienceCenter/renku-python
renku/cli/move.py
https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/cli/move.py#L42-L132
def move(ctx, client, sources, destination): """Move files and check repository for potential problems.""" from renku.api._git import _expand_directories dst = Path(destination) def fmt_path(path): """Format path as relative to the client path.""" return str(Path(path).absolute().relat...
[ "def", "move", "(", "ctx", ",", "client", ",", "sources", ",", "destination", ")", ":", "from", "renku", ".", "api", ".", "_git", "import", "_expand_directories", "dst", "=", "Path", "(", "destination", ")", "def", "fmt_path", "(", "path", ")", ":", "\...
Move files and check repository for potential problems.
[ "Move", "files", "and", "check", "repository", "for", "potential", "problems", "." ]
python
train
sacrud/ps_alchemy
ps_alchemy/__init__.py
https://github.com/sacrud/ps_alchemy/blob/4f042329eb4643bf26fa2540df277fa94c5265ec/ps_alchemy/__init__.py#L15-L26
def models_preparing(app): """ Wrap all sqlalchemy model in settings. """ def wrapper(resource, parent): if isinstance(resource, DeclarativeMeta): resource = ListResource(resource) if not getattr(resource, '__parent__', None): resource.__parent__ = parent ret...
[ "def", "models_preparing", "(", "app", ")", ":", "def", "wrapper", "(", "resource", ",", "parent", ")", ":", "if", "isinstance", "(", "resource", ",", "DeclarativeMeta", ")", ":", "resource", "=", "ListResource", "(", "resource", ")", "if", "not", "getattr...
Wrap all sqlalchemy model in settings.
[ "Wrap", "all", "sqlalchemy", "model", "in", "settings", "." ]
python
valid
hsolbrig/PyShEx
pyshex/shape_expressions_language/p5_4_node_constraints.py
https://github.com/hsolbrig/PyShEx/blob/9d659cc36e808afd66d4a6d60e8ea21cb12eb744/pyshex/shape_expressions_language/p5_4_node_constraints.py#L20-L29
def satisfiesNodeConstraint(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _: DebugContext) -> bool: """ `5.4.1 Semantics <http://shex.io/shex-semantics/#node-constraint-semantics>`_ For a node n and constraint nc, satisfies2(n, nc) if and only if for every nodeKind, datatype, xsFacet and values constr...
[ "def", "satisfiesNodeConstraint", "(", "cntxt", ":", "Context", ",", "n", ":", "Node", ",", "nc", ":", "ShExJ", ".", "NodeConstraint", ",", "_", ":", "DebugContext", ")", "->", "bool", ":", "return", "nodeSatisfiesNodeKind", "(", "cntxt", ",", "n", ",", ...
`5.4.1 Semantics <http://shex.io/shex-semantics/#node-constraint-semantics>`_ For a node n and constraint nc, satisfies2(n, nc) if and only if for every nodeKind, datatype, xsFacet and values constraint value v present in nc nodeSatisfies(n, v). The following sections define nodeSatisfies for each of these...
[ "5", ".", "4", ".", "1", "Semantics", "<http", ":", "//", "shex", ".", "io", "/", "shex", "-", "semantics", "/", "#node", "-", "constraint", "-", "semantics", ">", "_" ]
python
train
gwastro/pycbc
pycbc/pool.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/pool.py#L91-L112
def map(self, func, items, chunksize=None): """ Catch keyboard interuppts to allow the pool to exit cleanly. Parameters ---------- func: function Function to call items: list of tuples Arguments to pass chunksize: int, Optional Number ...
[ "def", "map", "(", "self", ",", "func", ",", "items", ",", "chunksize", "=", "None", ")", ":", "results", "=", "self", ".", "map_async", "(", "func", ",", "items", ",", "chunksize", ")", "while", "True", ":", "try", ":", "return", "results", ".", "...
Catch keyboard interuppts to allow the pool to exit cleanly. Parameters ---------- func: function Function to call items: list of tuples Arguments to pass chunksize: int, Optional Number of calls for each process to handle at once
[ "Catch", "keyboard", "interuppts", "to", "allow", "the", "pool", "to", "exit", "cleanly", "." ]
python
train
saltstack/salt
salt/cloud/clouds/lxc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/lxc.py#L511-L570
def get_configured_provider(vm_=None): ''' Return the contextual provider of None if no configured one can be found. ''' if vm_ is None: vm_ = {} dalias, driver = __active_provider_name__.split(':') data = None tgt = 'unknown' img_provider = __opts__.get('list_images', '') ...
[ "def", "get_configured_provider", "(", "vm_", "=", "None", ")", ":", "if", "vm_", "is", "None", ":", "vm_", "=", "{", "}", "dalias", ",", "driver", "=", "__active_provider_name__", ".", "split", "(", "':'", ")", "data", "=", "None", "tgt", "=", "'unkno...
Return the contextual provider of None if no configured one can be found.
[ "Return", "the", "contextual", "provider", "of", "None", "if", "no", "configured", "one", "can", "be", "found", "." ]
python
train
polysquare/jobstamps
jobstamps/jobstamp.py
https://github.com/polysquare/jobstamps/blob/49b4dec93b38c9db55643226a9788c675a53ef25/jobstamps/jobstamp.py#L96-L105
def check_dependency(self, dependency_path): """Check if mtime of dependency_path is greater than stored mtime.""" stored_hash = self._stamp_file_hashes.get(dependency_path) # This file was newly added, or we don't have a file # with stored hashes yet. Assume out of date. if not...
[ "def", "check_dependency", "(", "self", ",", "dependency_path", ")", ":", "stored_hash", "=", "self", ".", "_stamp_file_hashes", ".", "get", "(", "dependency_path", ")", "# This file was newly added, or we don't have a file", "# with stored hashes yet. Assume out of date.", "...
Check if mtime of dependency_path is greater than stored mtime.
[ "Check", "if", "mtime", "of", "dependency_path", "is", "greater", "than", "stored", "mtime", "." ]
python
train
django-fluent/django-fluent-contents
fluent_contents/models/managers.py
https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/managers.py#L164-L196
def create_for_placeholder(self, placeholder, sort_order=1, language_code=None, **kwargs): """ Create a Content Item with the given parameters If the language_code is not provided, the language code of the parent will be used. This may perform an additional database query, unless ...
[ "def", "create_for_placeholder", "(", "self", ",", "placeholder", ",", "sort_order", "=", "1", ",", "language_code", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "language_code", "is", "None", ":", "# Could also use get_language() or appsettings.FLUENT_CONT...
Create a Content Item with the given parameters If the language_code is not provided, the language code of the parent will be used. This may perform an additional database query, unless the :class:`~fluent_contents.models.managers.PlaceholderManager` methods were used to construct the object, ...
[ "Create", "a", "Content", "Item", "with", "the", "given", "parameters" ]
python
train
saltstack/salt
salt/grains/napalm.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/napalm.py#L82-L95
def _retrieve_device_cache(proxy=None): ''' Loads the network device details if not cached already. ''' global DEVICE_CACHE if not DEVICE_CACHE: if proxy and salt.utils.napalm.is_proxy(__opts__): # if proxy var passed and is NAPALM-type proxy minion if 'napalm.get_dev...
[ "def", "_retrieve_device_cache", "(", "proxy", "=", "None", ")", ":", "global", "DEVICE_CACHE", "if", "not", "DEVICE_CACHE", ":", "if", "proxy", "and", "salt", ".", "utils", ".", "napalm", ".", "is_proxy", "(", "__opts__", ")", ":", "# if proxy var passed and ...
Loads the network device details if not cached already.
[ "Loads", "the", "network", "device", "details", "if", "not", "cached", "already", "." ]
python
train
nion-software/nionswift
nion/swift/Facade.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/Facade.py#L2491-L2505
def delete_library_value(self, key: str) -> None: """Delete the library value for the given key. Please consult the developer documentation for a list of valid keys. .. versionadded:: 1.0 Scriptable: Yes """ desc = Metadata.session_key_map.get(key) if desc is n...
[ "def", "delete_library_value", "(", "self", ",", "key", ":", "str", ")", "->", "None", ":", "desc", "=", "Metadata", ".", "session_key_map", ".", "get", "(", "key", ")", "if", "desc", "is", "not", "None", ":", "field_id", "=", "desc", "[", "'path'", ...
Delete the library value for the given key. Please consult the developer documentation for a list of valid keys. .. versionadded:: 1.0 Scriptable: Yes
[ "Delete", "the", "library", "value", "for", "the", "given", "key", "." ]
python
train
wesyoung/pyzyre
czmq/_czmq_ctypes.py
https://github.com/wesyoung/pyzyre/blob/22d4c757acefcfdb700d3802adaf30b402bb9eea/czmq/_czmq_ctypes.py#L1633-L1637
def locate(self, path): """ Find a config item along a path; leading slash is optional and ignored. """ return Zconfig(lib.zconfig_locate(self._as_parameter_, path), False)
[ "def", "locate", "(", "self", ",", "path", ")", ":", "return", "Zconfig", "(", "lib", ".", "zconfig_locate", "(", "self", ".", "_as_parameter_", ",", "path", ")", ",", "False", ")" ]
Find a config item along a path; leading slash is optional and ignored.
[ "Find", "a", "config", "item", "along", "a", "path", ";", "leading", "slash", "is", "optional", "and", "ignored", "." ]
python
train
jalanb/pysyte
pysyte/bash/git.py
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L217-L232
def log(args, number=None, oneline=False, quiet=False): """Run a "git log ..." command, and return stdout args is anything which can be added after a normal "git log ..." it can be blank number, if true-ish, will be added as a "-n" option oneline, if true-ish, will add the "--oneline" option ...
[ "def", "log", "(", "args", ",", "number", "=", "None", ",", "oneline", "=", "False", ",", "quiet", "=", "False", ")", ":", "options", "=", "' '", ".", "join", "(", "[", "number", "and", "str", "(", "'-n %s'", "%", "number", ")", "or", "''", ",", ...
Run a "git log ..." command, and return stdout args is anything which can be added after a normal "git log ..." it can be blank number, if true-ish, will be added as a "-n" option oneline, if true-ish, will add the "--oneline" option
[ "Run", "a", "git", "log", "...", "command", "and", "return", "stdout" ]
python
train
gem/oq-engine
openquake/calculators/extract.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/extract.py#L130-L136
def barray(iterlines): """ Array of bytes """ lst = [line.encode('utf-8') for line in iterlines] arr = numpy.array(lst) return arr
[ "def", "barray", "(", "iterlines", ")", ":", "lst", "=", "[", "line", ".", "encode", "(", "'utf-8'", ")", "for", "line", "in", "iterlines", "]", "arr", "=", "numpy", ".", "array", "(", "lst", ")", "return", "arr" ]
Array of bytes
[ "Array", "of", "bytes" ]
python
train
xeroc/python-graphenelib
graphenecommon/amount.py
https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenecommon/amount.py#L159-L166
def asset(self): """ Returns the asset as instance of :class:`.asset.Asset` """ if not self["asset"]: self["asset"] = self.asset_class( self["symbol"], blockchain_instance=self.blockchain ) return self["asset"]
[ "def", "asset", "(", "self", ")", ":", "if", "not", "self", "[", "\"asset\"", "]", ":", "self", "[", "\"asset\"", "]", "=", "self", ".", "asset_class", "(", "self", "[", "\"symbol\"", "]", ",", "blockchain_instance", "=", "self", ".", "blockchain", ")"...
Returns the asset as instance of :class:`.asset.Asset`
[ "Returns", "the", "asset", "as", "instance", "of", ":", "class", ":", ".", "asset", ".", "Asset" ]
python
valid
nagius/snmp_passpersist
example/settings.py
https://github.com/nagius/snmp_passpersist/blob/8cc584d2e90c920ae98a318164a55bde209a18f7/example/settings.py#L76-L82
def write(self): '''atomic writing''' tmp_file, tmp_fname = tempfile.mkstemp() os.close(tmp_file) shutil.copystat(self.file_name, tmp_fname) self.config.write(open(tmp_fname, 'w')) shutil.move(tmp_fname, self.file_name)
[ "def", "write", "(", "self", ")", ":", "tmp_file", ",", "tmp_fname", "=", "tempfile", ".", "mkstemp", "(", ")", "os", ".", "close", "(", "tmp_file", ")", "shutil", ".", "copystat", "(", "self", ".", "file_name", ",", "tmp_fname", ")", "self", ".", "c...
atomic writing
[ "atomic", "writing" ]
python
train
pypa/pipenv
pipenv/patched/notpip/_vendor/ipaddress.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/ipaddress.py#L1750-L1852
def _ip_int_from_string(cls, ip_str): """Turn an IPv6 ip_str into an integer. Args: ip_str: A string, the IPv6 ip_str. Returns: An int, the IPv6 address Raises: AddressValueError: if ip_str isn't a valid IPv6 Address. """ if not ip_...
[ "def", "_ip_int_from_string", "(", "cls", ",", "ip_str", ")", ":", "if", "not", "ip_str", ":", "raise", "AddressValueError", "(", "'Address cannot be empty'", ")", "parts", "=", "ip_str", ".", "split", "(", "':'", ")", "# An IPv6 address needs at least 2 colons (3 p...
Turn an IPv6 ip_str into an integer. Args: ip_str: A string, the IPv6 ip_str. Returns: An int, the IPv6 address Raises: AddressValueError: if ip_str isn't a valid IPv6 Address.
[ "Turn", "an", "IPv6", "ip_str", "into", "an", "integer", "." ]
python
train
Nic30/hwt
hwt/hdl/switchContainer.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/switchContainer.py#L253-L272
def isSame(self, other: HdlStatement) -> bool: """ Doc on parent class :meth:`HdlStatement.isSame` """ if self is other: return True if self.rank != other.rank: return False if isinstance(other, SwitchContainer) \ and isSameHVal(s...
[ "def", "isSame", "(", "self", ",", "other", ":", "HdlStatement", ")", "->", "bool", ":", "if", "self", "is", "other", ":", "return", "True", "if", "self", ".", "rank", "!=", "other", ".", "rank", ":", "return", "False", "if", "isinstance", "(", "othe...
Doc on parent class :meth:`HdlStatement.isSame`
[ "Doc", "on", "parent", "class", ":", "meth", ":", "HdlStatement", ".", "isSame" ]
python
test
Unidata/siphon
siphon/http_util.py
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L197-L226
def lonlat_box(self, west, east, south, north): """Add a latitude/longitude bounding box to the query. This adds a request for a spatial bounding box, bounded by ('north', 'south') for latitude and ('east', 'west') for the longitude. This modifies the query in-place, but returns `self` ...
[ "def", "lonlat_box", "(", "self", ",", "west", ",", "east", ",", "south", ",", "north", ")", ":", "self", ".", "_set_query", "(", "self", ".", "spatial_query", ",", "west", "=", "west", ",", "east", "=", "east", ",", "south", "=", "south", ",", "no...
Add a latitude/longitude bounding box to the query. This adds a request for a spatial bounding box, bounded by ('north', 'south') for latitude and ('east', 'west') for the longitude. This modifies the query in-place, but returns `self` so that multiple queries can be chained together on...
[ "Add", "a", "latitude", "/", "longitude", "bounding", "box", "to", "the", "query", "." ]
python
train
StackStorm/pybind
pybind/slxos/v17s_1_02/routing_system/interface/ve/ipv6/ipv6_nd_ra/ipv6_intf_cmds/nd/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/routing_system/interface/ve/ipv6/ipv6_nd_ra/ipv6_intf_cmds/nd/__init__.py#L616-L637
def _set_ra_domain_name(self, v, load=False): """ Setter method for ra_domain_name, mapped from YANG variable /routing_system/interface/ve/ipv6/ipv6_nd_ra/ipv6_intf_cmds/nd/ra_domain_name (list) If this variable is read-only (config: false) in the source YANG file, then _set_ra_domain_name is considered...
[ "def", "_set_ra_domain_name", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", ...
Setter method for ra_domain_name, mapped from YANG variable /routing_system/interface/ve/ipv6/ipv6_nd_ra/ipv6_intf_cmds/nd/ra_domain_name (list) If this variable is read-only (config: false) in the source YANG file, then _set_ra_domain_name is considered as a private method. Backends looking to populate thi...
[ "Setter", "method", "for", "ra_domain_name", "mapped", "from", "YANG", "variable", "/", "routing_system", "/", "interface", "/", "ve", "/", "ipv6", "/", "ipv6_nd_ra", "/", "ipv6_intf_cmds", "/", "nd", "/", "ra_domain_name", "(", "list", ")", "If", "this", "v...
python
train
Opentrons/opentrons
api/src/opentrons/system/nmcli.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/system/nmcli.py#L293-L322
async def connections( for_type: Optional[CONNECTION_TYPES] = None) -> List[Dict[str, str]]: """ Return the list of configured connections. This is all connections that nmcli knows about and manages. Each connection is a dict containing some basic information - the information retrievable from ...
[ "async", "def", "connections", "(", "for_type", ":", "Optional", "[", "CONNECTION_TYPES", "]", "=", "None", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "fields", "=", "[", "'name'", ",", "'type'", ",", "'active'", "]", "res...
Return the list of configured connections. This is all connections that nmcli knows about and manages. Each connection is a dict containing some basic information - the information retrievable from nmcli connection show. Further information should be queried on a connection by connection basis. If...
[ "Return", "the", "list", "of", "configured", "connections", "." ]
python
train
decryptus/sonicprobe
sonicprobe/libs/xys.py
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/xys.py#L618-L630
def _transschema(x): """ Transform a schema, once loaded from its YAML representation, to its final internal representation """ if isinstance(x, tuple): return x.__class__(_transschema(x[0]), *x[1:]) elif isinstance(x, dict): return dict((_qualify_map(key, _transschema(val)) for ...
[ "def", "_transschema", "(", "x", ")", ":", "if", "isinstance", "(", "x", ",", "tuple", ")", ":", "return", "x", ".", "__class__", "(", "_transschema", "(", "x", "[", "0", "]", ")", ",", "*", "x", "[", "1", ":", "]", ")", "elif", "isinstance", "...
Transform a schema, once loaded from its YAML representation, to its final internal representation
[ "Transform", "a", "schema", "once", "loaded", "from", "its", "YAML", "representation", "to", "its", "final", "internal", "representation" ]
python
train
nocarryr/python-dispatch
pydispatch/dispatch.py
https://github.com/nocarryr/python-dispatch/blob/7c5ca03835c922cbfdfd62772c9e560062c954c7/pydispatch/dispatch.py#L252-L267
def get_dispatcher_event(self, name): """Retrieves an Event object by name Args: name (str): The name of the :class:`Event` or :class:`~pydispatch.properties.Property` object to retrieve Returns: The :class:`Event` instance for the event or property defi...
[ "def", "get_dispatcher_event", "(", "self", ",", "name", ")", ":", "e", "=", "self", ".", "__property_events", ".", "get", "(", "name", ")", "if", "e", "is", "None", ":", "e", "=", "self", ".", "__events", "[", "name", "]", "return", "e" ]
Retrieves an Event object by name Args: name (str): The name of the :class:`Event` or :class:`~pydispatch.properties.Property` object to retrieve Returns: The :class:`Event` instance for the event or property definition .. versionadded:: 0.1.0
[ "Retrieves", "an", "Event", "object", "by", "name" ]
python
train
DistrictDataLabs/yellowbrick
yellowbrick/datasets/signature.py
https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/datasets/signature.py#L23-L34
def sha256sum(path, blocksize=65536): """ Computes the SHA256 signature of a file to verify that the file has not been modified in transit and that it is the correct version of the data. """ sig = hashlib.sha256() with open(path, 'rb') as f: buf = f.read(blocksize) while len(buf)...
[ "def", "sha256sum", "(", "path", ",", "blocksize", "=", "65536", ")", ":", "sig", "=", "hashlib", ".", "sha256", "(", ")", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "buf", "=", "f", ".", "read", "(", "blocksize", ")", "while"...
Computes the SHA256 signature of a file to verify that the file has not been modified in transit and that it is the correct version of the data.
[ "Computes", "the", "SHA256", "signature", "of", "a", "file", "to", "verify", "that", "the", "file", "has", "not", "been", "modified", "in", "transit", "and", "that", "it", "is", "the", "correct", "version", "of", "the", "data", "." ]
python
train
crypto101/merlyn
merlyn/exercise.py
https://github.com/crypto101/merlyn/blob/0f313210b9ea5385cc2e5b725dc766df9dc3284d/merlyn/exercise.py#L30-L37
def wasSolvedBy(self, user): """Checks if this exercise has previously been solved by the user. """ thisExercise = _Solution.what == self byThisUser = _Solution.who == user condition = q.AND(thisExercise, byThisUser) return self.store.query(_Solution, condition, limit=1)...
[ "def", "wasSolvedBy", "(", "self", ",", "user", ")", ":", "thisExercise", "=", "_Solution", ".", "what", "==", "self", "byThisUser", "=", "_Solution", ".", "who", "==", "user", "condition", "=", "q", ".", "AND", "(", "thisExercise", ",", "byThisUser", ")...
Checks if this exercise has previously been solved by the user.
[ "Checks", "if", "this", "exercise", "has", "previously", "been", "solved", "by", "the", "user", "." ]
python
train
scanny/python-pptx
pptx/compat/python3.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/compat/python3.py#L31-L39
def to_unicode(text): """ Return *text* as a unicode string. All text in Python 3 is unicode, so this just returns *text* unchanged. """ if not isinstance(text, str): tmpl = 'expected unicode string, got %s value %s' raise TypeError(tmpl % (type(text), text)) return text
[ "def", "to_unicode", "(", "text", ")", ":", "if", "not", "isinstance", "(", "text", ",", "str", ")", ":", "tmpl", "=", "'expected unicode string, got %s value %s'", "raise", "TypeError", "(", "tmpl", "%", "(", "type", "(", "text", ")", ",", "text", ")", ...
Return *text* as a unicode string. All text in Python 3 is unicode, so this just returns *text* unchanged.
[ "Return", "*", "text", "*", "as", "a", "unicode", "string", ".", "All", "text", "in", "Python", "3", "is", "unicode", "so", "this", "just", "returns", "*", "text", "*", "unchanged", "." ]
python
train
boundary/pulse-api-cli
boundary/metric_markdown.py
https://github.com/boundary/pulse-api-cli/blob/b01ca65b442eed19faac309c9d62bbc3cb2c098f/boundary/metric_markdown.py#L161-L170
def printFields(self, f, d): """ Prints out table rows based on the size of the data in columns """ for field in self.fields: fstr = field["title"] dstr = field["description"] flen = f - len(fstr) dlen = d - len(dstr) print("|{0...
[ "def", "printFields", "(", "self", ",", "f", ",", "d", ")", ":", "for", "field", "in", "self", ".", "fields", ":", "fstr", "=", "field", "[", "\"title\"", "]", "dstr", "=", "field", "[", "\"description\"", "]", "flen", "=", "f", "-", "len", "(", ...
Prints out table rows based on the size of the data in columns
[ "Prints", "out", "table", "rows", "based", "on", "the", "size", "of", "the", "data", "in", "columns" ]
python
test
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxproject.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxproject.py#L284-L339
def new(self, name, summary=None, description=None, protected=None, restricted=None, download_restricted=None, contains_phi=None, tags=None, properties=None, bill_to=None, **kwargs): """ :param name: The name of the project :type name: string :param summary: If pr...
[ "def", "new", "(", "self", ",", "name", ",", "summary", "=", "None", ",", "description", "=", "None", ",", "protected", "=", "None", ",", "restricted", "=", "None", ",", "download_restricted", "=", "None", ",", "contains_phi", "=", "None", ",", "tags", ...
:param name: The name of the project :type name: string :param summary: If provided, a short summary of what the project contains :type summary: string :param description: If provided, the new project description :type name: string :param protected: If provided, whether t...
[ ":", "param", "name", ":", "The", "name", "of", "the", "project", ":", "type", "name", ":", "string", ":", "param", "summary", ":", "If", "provided", "a", "short", "summary", "of", "what", "the", "project", "contains", ":", "type", "summary", ":", "str...
python
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L313-L320
def _get_property_values_with_defaults(self, classname, property_values): """Return the property values for the class, with default values applied where needed.""" # To uphold OrientDB semantics, make a new dict with all property values set # to their default values, which are None if no default...
[ "def", "_get_property_values_with_defaults", "(", "self", ",", "classname", ",", "property_values", ")", ":", "# To uphold OrientDB semantics, make a new dict with all property values set", "# to their default values, which are None if no default was set.", "# Then, overwrite its data with t...
Return the property values for the class, with default values applied where needed.
[ "Return", "the", "property", "values", "for", "the", "class", "with", "default", "values", "applied", "where", "needed", "." ]
python
train
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_comm.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_comm.py#L177-L184
def run_as_pydevd_daemon_thread(func, *args, **kwargs): ''' Runs a function as a pydevd daemon thread (without any tracing in place). ''' t = PyDBDaemonThread(target_and_args=(func, args, kwargs)) t.name = '%s (pydevd daemon thread)' % (func.__name__,) t.start() return t
[ "def", "run_as_pydevd_daemon_thread", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "t", "=", "PyDBDaemonThread", "(", "target_and_args", "=", "(", "func", ",", "args", ",", "kwargs", ")", ")", "t", ".", "name", "=", "'%s (pydevd daem...
Runs a function as a pydevd daemon thread (without any tracing in place).
[ "Runs", "a", "function", "as", "a", "pydevd", "daemon", "thread", "(", "without", "any", "tracing", "in", "place", ")", "." ]
python
train
bmcfee/muda
muda/base.py
https://github.com/bmcfee/muda/blob/ff82efdfaeb98da0a9f9124845826eb20536a9ba/muda/base.py#L327-L342
def transform(self, jam): '''Apply the sequence of transformations to a single jam object. Parameters ---------- jam : jams.JAMS The jam object to transform Yields ------ jam_out : jams.JAMS The jam objects produced by each member of the ...
[ "def", "transform", "(", "self", ",", "jam", ")", ":", "for", "output", "in", "self", ".", "__serial_transform", "(", "jam", ",", "self", ".", "steps", ")", ":", "yield", "output" ]
Apply the sequence of transformations to a single jam object. Parameters ---------- jam : jams.JAMS The jam object to transform Yields ------ jam_out : jams.JAMS The jam objects produced by each member of the union
[ "Apply", "the", "sequence", "of", "transformations", "to", "a", "single", "jam", "object", "." ]
python
valid
ArduPilot/MAVProxy
MAVProxy/modules/lib/MacOS/backend_wxagg.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wxagg.py#L145-L158
def _convert_agg_to_wx_bitmap(agg, bbox): """ Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance. """ if bbox is None: # agg => rgba buffer -> bitmap return w...
[ "def", "_convert_agg_to_wx_bitmap", "(", "agg", ",", "bbox", ")", ":", "if", "bbox", "is", "None", ":", "# agg => rgba buffer -> bitmap", "return", "wx", ".", "BitmapFromBufferRGBA", "(", "int", "(", "agg", ".", "width", ")", ",", "int", "(", "agg", ".", "...
Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If bbox is None, the entire buffer is converted. Note: agg must be a backend_agg.RendererAgg instance.
[ "Convert", "the", "region", "of", "the", "agg", "buffer", "bounded", "by", "bbox", "to", "a", "wx", ".", "Bitmap", ".", "If", "bbox", "is", "None", "the", "entire", "buffer", "is", "converted", "." ]
python
train
BernardFW/bernard
src/bernard/platforms/management.py
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L190-L199
def get_class(self, platform) -> Type[Platform]: """ For a given platform name, gets the matching class """ if platform in self._classes: return self._classes[platform] raise PlatformDoesNotExist('Platform "{}" is not in configuration' ...
[ "def", "get_class", "(", "self", ",", "platform", ")", "->", "Type", "[", "Platform", "]", ":", "if", "platform", "in", "self", ".", "_classes", ":", "return", "self", ".", "_classes", "[", "platform", "]", "raise", "PlatformDoesNotExist", "(", "'Platform ...
For a given platform name, gets the matching class
[ "For", "a", "given", "platform", "name", "gets", "the", "matching", "class" ]
python
train
NeilGirdhar/rectangle
rectangle/rectangle.py
https://github.com/NeilGirdhar/rectangle/blob/b0ca25e199cf6e331aef7fd99bda5ba10ae98753/rectangle/rectangle.py#L53-L67
def transformed(self, t): """ Transforms an m-dimensional Rect using t, an nxn matrix that can transform vectors in the form: [x, y, z, …, 1]. The Rect is padded to n dimensions. """ assert t.shape[0] == t.shape[1] extra_dimensions = t.shape[0] - self.dimensions -...
[ "def", "transformed", "(", "self", ",", "t", ")", ":", "assert", "t", ".", "shape", "[", "0", "]", "==", "t", ".", "shape", "[", "1", "]", "extra_dimensions", "=", "t", ".", "shape", "[", "0", "]", "-", "self", ".", "dimensions", "-", "1", "def...
Transforms an m-dimensional Rect using t, an nxn matrix that can transform vectors in the form: [x, y, z, …, 1]. The Rect is padded to n dimensions.
[ "Transforms", "an", "m", "-", "dimensional", "Rect", "using", "t", "an", "nxn", "matrix", "that", "can", "transform", "vectors", "in", "the", "form", ":", "[", "x", "y", "z", "…", "1", "]", ".", "The", "Rect", "is", "padded", "to", "n", "dimensions",...
python
train
timgabets/pynblock
pynblock/tools.py
https://github.com/timgabets/pynblock/blob/dbdb6d06bd7741e1138bed09d874b47b23d8d200/pynblock/tools.py#L194-L202
def parityOf(int_type): """ Calculates the parity of an integer, returning 0 if there are an even number of set bits, and -1 if there are an odd number. """ parity = 0 while (int_type): parity = ~parity int_type = int_type & (int_type - 1) return(parity)
[ "def", "parityOf", "(", "int_type", ")", ":", "parity", "=", "0", "while", "(", "int_type", ")", ":", "parity", "=", "~", "parity", "int_type", "=", "int_type", "&", "(", "int_type", "-", "1", ")", "return", "(", "parity", ")" ]
Calculates the parity of an integer, returning 0 if there are an even number of set bits, and -1 if there are an odd number.
[ "Calculates", "the", "parity", "of", "an", "integer", "returning", "0", "if", "there", "are", "an", "even", "number", "of", "set", "bits", "and", "-", "1", "if", "there", "are", "an", "odd", "number", "." ]
python
train
cackharot/suds-py3
suds/mx/literal.py
https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/mx/literal.py#L218-L240
def translate(self, content): """ Translate using the XSD type information. Python I{dict} is translated to a suds object. Most importantly, primative values are translated from python types to XML types using the XSD type. @param content: The content to translate. ...
[ "def", "translate", "(", "self", ",", "content", ")", ":", "v", "=", "content", ".", "value", "if", "v", "is", "None", ":", "return", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "cls", "=", "content", ".", "real", ".", "name", "content", ...
Translate using the XSD type information. Python I{dict} is translated to a suds object. Most importantly, primative values are translated from python types to XML types using the XSD type. @param content: The content to translate. @type content: L{Object} @return: self ...
[ "Translate", "using", "the", "XSD", "type", "information", ".", "Python", "I", "{", "dict", "}", "is", "translated", "to", "a", "suds", "object", ".", "Most", "importantly", "primative", "values", "are", "translated", "from", "python", "types", "to", "XML", ...
python
train
realestate-com-au/dashmat
dashmat/actions.py
https://github.com/realestate-com-au/dashmat/blob/433886e52698f0ddb9956f087b76041966c3bcd1/dashmat/actions.py#L68-L80
def requirements(collector): """Just print out the requirements""" out = sys.stdout artifact = collector.configuration['dashmat'].artifact if artifact not in (None, "", NotSpecified): if isinstance(artifact, six.string_types): out = open(artifact, 'w') else: out =...
[ "def", "requirements", "(", "collector", ")", ":", "out", "=", "sys", ".", "stdout", "artifact", "=", "collector", ".", "configuration", "[", "'dashmat'", "]", ".", "artifact", "if", "artifact", "not", "in", "(", "None", ",", "\"\"", ",", "NotSpecified", ...
Just print out the requirements
[ "Just", "print", "out", "the", "requirements" ]
python
train
pycontribs/pyrax
pyrax/clouddatabases.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L466-L472
def update_user(self, user, name=None, password=None, host=None): """ Allows you to change one or more of the user's username, password, or host. """ return self._user_manager.update(user, name=name, password=password, host=host)
[ "def", "update_user", "(", "self", ",", "user", ",", "name", "=", "None", ",", "password", "=", "None", ",", "host", "=", "None", ")", ":", "return", "self", ".", "_user_manager", ".", "update", "(", "user", ",", "name", "=", "name", ",", "password",...
Allows you to change one or more of the user's username, password, or host.
[ "Allows", "you", "to", "change", "one", "or", "more", "of", "the", "user", "s", "username", "password", "or", "host", "." ]
python
train
python-bonobo/bonobo
docs/_templates/alabaster/__init__.py
https://github.com/python-bonobo/bonobo/blob/70c8e62c4a88576976e5b52e58d380d6e3227ab4/docs/_templates/alabaster/__init__.py#L6-L11
def get_path(): """ Shortcut for users whose theme is next to their conf.py. """ # Theme directory is defined as our parent directory return os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
[ "def", "get_path", "(", ")", ":", "# Theme directory is defined as our parent directory", "return", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", ")" ]
Shortcut for users whose theme is next to their conf.py.
[ "Shortcut", "for", "users", "whose", "theme", "is", "next", "to", "their", "conf", ".", "py", "." ]
python
train
treycucco/bidon
lib/generate_models.py
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/lib/generate_models.py#L85-L88
def get_data_table(filename): """Returns a DataTable instance built from either the filename, or STDIN if filename is None.""" with get_file_object(filename, "r") as rf: return DataTable(list(csv.reader(rf)))
[ "def", "get_data_table", "(", "filename", ")", ":", "with", "get_file_object", "(", "filename", ",", "\"r\"", ")", "as", "rf", ":", "return", "DataTable", "(", "list", "(", "csv", ".", "reader", "(", "rf", ")", ")", ")" ]
Returns a DataTable instance built from either the filename, or STDIN if filename is None.
[ "Returns", "a", "DataTable", "instance", "built", "from", "either", "the", "filename", "or", "STDIN", "if", "filename", "is", "None", "." ]
python
train
pysathq/pysat
pysat/solvers.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L3056-L3062
def set_phases(self, literals=[]): """ Sets polarities of a given list of variables. """ if self.minisat: pysolvers.minisat22_setphases(self.minisat, literals)
[ "def", "set_phases", "(", "self", ",", "literals", "=", "[", "]", ")", ":", "if", "self", ".", "minisat", ":", "pysolvers", ".", "minisat22_setphases", "(", "self", ".", "minisat", ",", "literals", ")" ]
Sets polarities of a given list of variables.
[ "Sets", "polarities", "of", "a", "given", "list", "of", "variables", "." ]
python
train
rikrd/inspire
inspirespeech/__init__.py
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/__init__.py#L502-L508
def load_metadata(fileobj): """Load the submission from a file. :param filename: where to load the submission from """ with gzip.GzipFile(fileobj=fileobj, mode='r') as z: return json.loads(z.readline())
[ "def", "load_metadata", "(", "fileobj", ")", ":", "with", "gzip", ".", "GzipFile", "(", "fileobj", "=", "fileobj", ",", "mode", "=", "'r'", ")", "as", "z", ":", "return", "json", ".", "loads", "(", "z", ".", "readline", "(", ")", ")" ]
Load the submission from a file. :param filename: where to load the submission from
[ "Load", "the", "submission", "from", "a", "file", "." ]
python
train
bwohlberg/sporco
sporco/cdict.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cdict.py#L220-L246
def check(self, key, value): """Check whether key,value pair is allowed. The key is allowed if there is a corresponding key in the defaults class attribute dict. The value is not allowed if it is a dict in the defaults dict and not a dict in value. Parameters ---------- ...
[ "def", "check", "(", "self", ",", "key", ",", "value", ")", ":", "# This test necessary to avoid unpickling errors in Python 3", "if", "hasattr", "(", "self", ",", "'dflt'", ")", ":", "# Get corresponding node to self, as determined by pth", "# attribute, of the defaults dict...
Check whether key,value pair is allowed. The key is allowed if there is a corresponding key in the defaults class attribute dict. The value is not allowed if it is a dict in the defaults dict and not a dict in value. Parameters ---------- key : str or tuple of str ...
[ "Check", "whether", "key", "value", "pair", "is", "allowed", ".", "The", "key", "is", "allowed", "if", "there", "is", "a", "corresponding", "key", "in", "the", "defaults", "class", "attribute", "dict", ".", "The", "value", "is", "not", "allowed", "if", "...
python
train
PyCQA/pylint
pylint/checkers/typecheck.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/typecheck.py#L593-L627
def _infer_from_metaclass_constructor(cls, func): """Try to infer what the given *func* constructor is building :param astroid.FunctionDef func: A metaclass constructor. Metaclass definitions can be functions, which should accept three arguments, the name of the class, the bases of the ...
[ "def", "_infer_from_metaclass_constructor", "(", "cls", ",", "func", ")", ":", "context", "=", "astroid", ".", "context", ".", "InferenceContext", "(", ")", "class_bases", "=", "astroid", ".", "List", "(", ")", "class_bases", ".", "postinit", "(", "elts", "=...
Try to infer what the given *func* constructor is building :param astroid.FunctionDef func: A metaclass constructor. Metaclass definitions can be functions, which should accept three arguments, the name of the class, the bases of the class and the attributes. The function could retu...
[ "Try", "to", "infer", "what", "the", "given", "*", "func", "*", "constructor", "is", "building" ]
python
test
andymccurdy/redis-py
redis/connection.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/connection.py#L983-L1008
def get_connection(self, command_name, *keys, **options): "Get a connection from the pool" self._checkpid() try: connection = self._available_connections.pop() except IndexError: connection = self.make_connection() self._in_use_connections.add(connection) ...
[ "def", "get_connection", "(", "self", ",", "command_name", ",", "*", "keys", ",", "*", "*", "options", ")", ":", "self", ".", "_checkpid", "(", ")", "try", ":", "connection", "=", "self", ".", "_available_connections", ".", "pop", "(", ")", "except", "...
Get a connection from the pool
[ "Get", "a", "connection", "from", "the", "pool" ]
python
train
Stranger6667/postmarker
postmarker/models/emails.py
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L411-L449
def Email( self, From, To, Cc=None, Bcc=None, Subject=None, Tag=None, HtmlBody=None, TextBody=None, Metadata=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None", Attachments=None, ...
[ "def", "Email", "(", "self", ",", "From", ",", "To", ",", "Cc", "=", "None", ",", "Bcc", "=", "None", ",", "Subject", "=", "None", ",", "Tag", "=", "None", ",", "HtmlBody", "=", "None", ",", "TextBody", "=", "None", ",", "Metadata", "=", "None", ...
Constructs :py:class:`Email` instance. :return: :py:class:`Email`
[ "Constructs", ":", "py", ":", "class", ":", "Email", "instance", "." ]
python
train
alexprengere/currencyconverter
currency_converter/currency_converter.py
https://github.com/alexprengere/currencyconverter/blob/e3cb0d693819c0c824214225b23a47e9380f71df/currency_converter/currency_converter.py#L67-L72
def parse_date(s): """Fast %Y-%m-%d parsing.""" try: return datetime.date(int(s[:4]), int(s[5:7]), int(s[8:10])) except ValueError: # other accepted format used in one-day data set return datetime.datetime.strptime(s, '%d %B %Y').date()
[ "def", "parse_date", "(", "s", ")", ":", "try", ":", "return", "datetime", ".", "date", "(", "int", "(", "s", "[", ":", "4", "]", ")", ",", "int", "(", "s", "[", "5", ":", "7", "]", ")", ",", "int", "(", "s", "[", "8", ":", "10", "]", "...
Fast %Y-%m-%d parsing.
[ "Fast", "%Y", "-", "%m", "-", "%d", "parsing", "." ]
python
test
samuelcolvin/pydantic
pydantic/schema.py
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L287-L306
def get_field_schema_validations(field: Field) -> Dict[str, Any]: """ Get the JSON Schema validation keywords for a ``field`` with an annotation of a Pydantic ``Schema`` with validation arguments. """ f_schema: Dict[str, Any] = {} if lenient_issubclass(field.type_, (str, bytes)): for att...
[ "def", "get_field_schema_validations", "(", "field", ":", "Field", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "f_schema", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "if", "lenient_issubclass", "(", "field", ".", "type_", ",", ...
Get the JSON Schema validation keywords for a ``field`` with an annotation of a Pydantic ``Schema`` with validation arguments.
[ "Get", "the", "JSON", "Schema", "validation", "keywords", "for", "a", "field", "with", "an", "annotation", "of", "a", "Pydantic", "Schema", "with", "validation", "arguments", "." ]
python
train
creare-com/pydem
pydem/dem_processing.py
https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1846-L1908
def _mk_adjacency_matrix(self, section, proportion, flats, elev, mag, dX, dY): """ Calculates the adjacency of connectivity matrix. This matrix tells which pixels drain to which. For example, the pixel i, will recieve area from np.nonzero(A[i, :]) at the proportions given in A[i...
[ "def", "_mk_adjacency_matrix", "(", "self", ",", "section", ",", "proportion", ",", "flats", ",", "elev", ",", "mag", ",", "dX", ",", "dY", ")", ":", "shp", "=", "section", ".", "shape", "mat_data", "=", "np", ".", "row_stack", "(", "(", "proportion", ...
Calculates the adjacency of connectivity matrix. This matrix tells which pixels drain to which. For example, the pixel i, will recieve area from np.nonzero(A[i, :]) at the proportions given in A[i, :]. So, the row gives the pixel drain to, and the columns the pixels drained from.
[ "Calculates", "the", "adjacency", "of", "connectivity", "matrix", ".", "This", "matrix", "tells", "which", "pixels", "drain", "to", "which", "." ]
python
train
chainer/chainerui
chainerui/models/result.py
https://github.com/chainer/chainerui/blob/87ad25e875bc332bfdad20197fd3d0cb81a078e8/chainerui/models/result.py#L79-L96
def serialize_with_sampled_logs(self, logs_limit=-1): """serialize a result with up to `logs_limit` logs. If `logs_limit` is -1, this function will return a result with all its logs. """ return { 'id': self.id, 'pathName': self.path_name, 'na...
[ "def", "serialize_with_sampled_logs", "(", "self", ",", "logs_limit", "=", "-", "1", ")", ":", "return", "{", "'id'", ":", "self", ".", "id", ",", "'pathName'", ":", "self", ".", "path_name", ",", "'name'", ":", "self", ".", "name", ",", "'isUnregistered...
serialize a result with up to `logs_limit` logs. If `logs_limit` is -1, this function will return a result with all its logs.
[ "serialize", "a", "result", "with", "up", "to", "logs_limit", "logs", "." ]
python
train
seleniumbase/SeleniumBase
seleniumbase/fixtures/base_case.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L731-L743
def find_visible_elements(self, selector, by=By.CSS_SELECTOR, limit=0): """ Returns a list of matching WebElements that are visible. If "limit" is set and > 0, will only return that many elements. """ self.wait_for_ready_state_complete() if page_utils.is_xpath_selector(selector): ...
[ "def", "find_visible_elements", "(", "self", ",", "selector", ",", "by", "=", "By", ".", "CSS_SELECTOR", ",", "limit", "=", "0", ")", ":", "self", ".", "wait_for_ready_state_complete", "(", ")", "if", "page_utils", ".", "is_xpath_selector", "(", "selector", ...
Returns a list of matching WebElements that are visible. If "limit" is set and > 0, will only return that many elements.
[ "Returns", "a", "list", "of", "matching", "WebElements", "that", "are", "visible", ".", "If", "limit", "is", "set", "and", ">", "0", "will", "only", "return", "that", "many", "elements", "." ]
python
train
hollenstein/maspy
maspy/core.py
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/core.py#L259-L289
def getArrays(self, attr=None, specfiles=None, sort=False, reverse=False, selector=None, defaultValue=None): """Return a condensed array of data selected from :class:`Si` instances from ``self.sic`` for fast and convenient data processing. :param attr: list of :class:`Si` item...
[ "def", "getArrays", "(", "self", ",", "attr", "=", "None", ",", "specfiles", "=", "None", ",", "sort", "=", "False", ",", "reverse", "=", "False", ",", "selector", "=", "None", ",", "defaultValue", "=", "None", ")", ":", "selector", "=", "(", "lambda...
Return a condensed array of data selected from :class:`Si` instances from ``self.sic`` for fast and convenient data processing. :param attr: list of :class:`Si` item attributes that should be added to the returned array. The attributes "id" and "specfile" are always included, in...
[ "Return", "a", "condensed", "array", "of", "data", "selected", "from", ":", "class", ":", "Si", "instances", "from", "self", ".", "sic", "for", "fast", "and", "convenient", "data", "processing", "." ]
python
train
peri-source/peri
peri/logger.py
https://github.com/peri-source/peri/blob/61beed5deaaf978ab31ed716e8470d86ba639867/peri/logger.py#L90-L104
def add_handler(self, name='console-color', level='info', formatter='standard', **kwargs): """ Add another handler to the logging system if not present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log'] """ # make sure the the log file has ...
[ "def", "add_handler", "(", "self", ",", "name", "=", "'console-color'", ",", "level", "=", "'info'", ",", "formatter", "=", "'standard'", ",", "*", "*", "kwargs", ")", ":", "# make sure the the log file has a name", "if", "name", "==", "'rotating-log'", "and", ...
Add another handler to the logging system if not present already. Available handlers are currently: ['console-bw', 'console-color', 'rotating-log']
[ "Add", "another", "handler", "to", "the", "logging", "system", "if", "not", "present", "already", ".", "Available", "handlers", "are", "currently", ":", "[", "console", "-", "bw", "console", "-", "color", "rotating", "-", "log", "]" ]
python
valid
wbond/asn1crypto
asn1crypto/core.py
https://github.com/wbond/asn1crypto/blob/ecda20176f55d37021cbca1f6da9083a8e491197/asn1crypto/core.py#L4013-L4066
def _make_value(self, value): """ Constructs a _child_spec value from a native Python data type, or an appropriate Asn1Value object :param value: A native Python value, or some child of Asn1Value :return: An object of type _child_spec """ ...
[ "def", "_make_value", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "self", ".", "_child_spec", ")", ":", "new_value", "=", "value", "elif", "issubclass", "(", "self", ".", "_child_spec", ",", "Any", ")", ":", "if", "isins...
Constructs a _child_spec value from a native Python data type, or an appropriate Asn1Value object :param value: A native Python value, or some child of Asn1Value :return: An object of type _child_spec
[ "Constructs", "a", "_child_spec", "value", "from", "a", "native", "Python", "data", "type", "or", "an", "appropriate", "Asn1Value", "object" ]
python
train
diffeo/rejester
rejester/_task_master.py
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1113-L1146
def del_work_units(self, work_spec_name, work_unit_keys=None, state=None, all=False): '''Delete work units from a work spec. The parameters are considered in order as follows: * If `all` is :const:`True`, then all work units in `work_spec_name` are deleted; oth...
[ "def", "del_work_units", "(", "self", ",", "work_spec_name", ",", "work_unit_keys", "=", "None", ",", "state", "=", "None", ",", "all", "=", "False", ")", ":", "count", "=", "0", "if", "(", "state", "is", "None", ")", "or", "(", "state", "==", "AVAIL...
Delete work units from a work spec. The parameters are considered in order as follows: * If `all` is :const:`True`, then all work units in `work_spec_name` are deleted; otherwise * If `state` is not :const:`None`, then all work units in the named state are deleted; otherwis...
[ "Delete", "work", "units", "from", "a", "work", "spec", "." ]
python
train
rlabbe/filterpy
filterpy/leastsq/least_squares.py
https://github.com/rlabbe/filterpy/blob/8123214de798ffb63db968bb0b9492ee74e77950/filterpy/leastsq/least_squares.py#L157-L205
def errors(self): """ Computes and returns the error and standard deviation of the filter at this time step. Returns ------- error : np.array size 1xorder+1 std : np.array size 1xorder+1 """ n = self.n dt = self.dt order = self._...
[ "def", "errors", "(", "self", ")", ":", "n", "=", "self", ".", "n", "dt", "=", "self", ".", "dt", "order", "=", "self", ".", "_order", "sigma", "=", "self", ".", "sigma", "error", "=", "np", ".", "zeros", "(", "order", "+", "1", ")", "std", "...
Computes and returns the error and standard deviation of the filter at this time step. Returns ------- error : np.array size 1xorder+1 std : np.array size 1xorder+1
[ "Computes", "and", "returns", "the", "error", "and", "standard", "deviation", "of", "the", "filter", "at", "this", "time", "step", "." ]
python
train
bokeh/bokeh
bokeh/core/property/container.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/core/property/container.py#L124-L134
def wrap(cls, value): ''' Some property types need to wrap their values in special containers, etc. ''' if isinstance(value, list): if isinstance(value, PropertyValueList): return value else: return PropertyValueList(value) else: ...
[ "def", "wrap", "(", "cls", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "if", "isinstance", "(", "value", ",", "PropertyValueList", ")", ":", "return", "value", "else", ":", "return", "PropertyValueList", "(", "value",...
Some property types need to wrap their values in special containers, etc.
[ "Some", "property", "types", "need", "to", "wrap", "their", "values", "in", "special", "containers", "etc", "." ]
python
train
evolbioinfo/pastml
pastml/ml.py
https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L336-L375
def alter_zero_tip_allowed_states(tree, feature): """ Alters the bottom-up likelihood arrays for zero-distance tips to make sure they do not contradict with other zero-distance tip siblings. :param tree: ete3.Tree, the tree of interest :param feature: str, character for which the likelihood is alte...
[ "def", "alter_zero_tip_allowed_states", "(", "tree", ",", "feature", ")", ":", "zero_parent2tips", "=", "defaultdict", "(", "list", ")", "allowed_state_feature", "=", "get_personalized_feature_name", "(", "feature", ",", "ALLOWED_STATES", ")", "for", "tip", "in", "t...
Alters the bottom-up likelihood arrays for zero-distance tips to make sure they do not contradict with other zero-distance tip siblings. :param tree: ete3.Tree, the tree of interest :param feature: str, character for which the likelihood is altered :return: void, modifies the get_personalised_feature_n...
[ "Alters", "the", "bottom", "-", "up", "likelihood", "arrays", "for", "zero", "-", "distance", "tips", "to", "make", "sure", "they", "do", "not", "contradict", "with", "other", "zero", "-", "distance", "tip", "siblings", "." ]
python
train
mbedmicro/pyOCD
pyocd/target/pack/cmsis_pack.py
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/pack/cmsis_pack.py#L279-L341
def _build_memory_regions(self): """! @brief Creates memory region instances for the device. For each `<memory>` element in the device info, a memory region object is created and added to the `_regions` attribute. IROM or non-writable memories are created as RomRegions by this m...
[ "def", "_build_memory_regions", "(", "self", ")", ":", "for", "elem", "in", "self", ".", "_info", ".", "memories", ":", "try", ":", "# Get the region name, type, and access permissions.", "if", "'name'", "in", "elem", ".", "attrib", ":", "name", "=", "elem", "...
! @brief Creates memory region instances for the device. For each `<memory>` element in the device info, a memory region object is created and added to the `_regions` attribute. IROM or non-writable memories are created as RomRegions by this method. They will be converted to FlashRegion...
[ "!" ]
python
train
googleapis/google-cloud-python
bigtable/google/cloud/bigtable/table.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable/table.py#L712-L784
def _do_mutate_retryable_rows(self): """Mutate all the rows that are eligible for retry. A row is eligible for retry if it has not been tried or if it resulted in a transient error in a previous call. :rtype: list :return: The responses statuses, which is a list of ...
[ "def", "_do_mutate_retryable_rows", "(", "self", ")", ":", "retryable_rows", "=", "[", "]", "index_into_all_rows", "=", "[", "]", "for", "index", ",", "status", "in", "enumerate", "(", "self", ".", "responses_statuses", ")", ":", "if", "self", ".", "_is_retr...
Mutate all the rows that are eligible for retry. A row is eligible for retry if it has not been tried or if it resulted in a transient error in a previous call. :rtype: list :return: The responses statuses, which is a list of :class:`~google.rpc.status_pb2.Status`. ...
[ "Mutate", "all", "the", "rows", "that", "are", "eligible", "for", "retry", "." ]
python
train
has2k1/plotnine
doc/sphinxext/examples_and_gallery.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/doc/sphinxext/examples_and_gallery.py#L289-L315
def add_entries_to_gallery(app, doctree, docname): """ Add entries to the gallery node Should happen when all the doctrees have been read and the gallery entries have been collected. i.e at doctree-resolved time. """ if docname != 'gallery': return if not has_gallery(app.builde...
[ "def", "add_entries_to_gallery", "(", "app", ",", "doctree", ",", "docname", ")", ":", "if", "docname", "!=", "'gallery'", ":", "return", "if", "not", "has_gallery", "(", "app", ".", "builder", ".", "name", ")", ":", "return", "# Find gallery node", "try", ...
Add entries to the gallery node Should happen when all the doctrees have been read and the gallery entries have been collected. i.e at doctree-resolved time.
[ "Add", "entries", "to", "the", "gallery", "node" ]
python
train
ThreatResponse/margaritashotgun
margaritashotgun/repository.py
https://github.com/ThreatResponse/margaritashotgun/blob/6dee53ef267959b214953439968244cc46a19690/margaritashotgun/repository.py#L310-L329
def verify_module(self, filename, module, verify_signature): """ Verify kernel module checksum and signature :type filename: str :param filename: downloaded kernel module path :type module: dict :param module: kernel module metadata :type verify_signature: bool ...
[ "def", "verify_module", "(", "self", ",", "filename", ",", "module", ",", "verify_signature", ")", ":", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "module_data", "=", "f", ".", "read", "(", ")", "self", ".", "verify_checksum", "...
Verify kernel module checksum and signature :type filename: str :param filename: downloaded kernel module path :type module: dict :param module: kernel module metadata :type verify_signature: bool :param verify_signature: enable/disable signature verification
[ "Verify", "kernel", "module", "checksum", "and", "signature" ]
python
train
sporestack/bitcash
bitcash/wallet.py
https://github.com/sporestack/bitcash/blob/c7a18b9d82af98f1000c456dd06131524c260b7f/bitcash/wallet.py#L191-L198
def get_unspents(self): """Fetches all available unspent transaction outputs. :rtype: ``list`` of :class:`~bitcash.network.meta.Unspent` """ self.unspents[:] = NetworkAPI.get_unspent(self.address) self.balance = sum(unspent.amount for unspent in self.unspents) return sel...
[ "def", "get_unspents", "(", "self", ")", ":", "self", ".", "unspents", "[", ":", "]", "=", "NetworkAPI", ".", "get_unspent", "(", "self", ".", "address", ")", "self", ".", "balance", "=", "sum", "(", "unspent", ".", "amount", "for", "unspent", "in", ...
Fetches all available unspent transaction outputs. :rtype: ``list`` of :class:`~bitcash.network.meta.Unspent`
[ "Fetches", "all", "available", "unspent", "transaction", "outputs", "." ]
python
train
edoburu/django-tag-parser
tag_parser/parser.py
https://github.com/edoburu/django-tag-parser/blob/c24256cfdd0248434f2e3df3444ed9f945d4181f/tag_parser/parser.py#L36-L87
def parse_token_kwargs(parser, token, allowed_kwargs=None, compile_args=True, compile_kwargs=True): """ Allow the template tag arguments to be like a normal Python function, with *args and **kwargs. :param parser: The "parser" object that ``@register.tag`` provides. :type parser: :class:`~django.templa...
[ "def", "parse_token_kwargs", "(", "parser", ",", "token", ",", "allowed_kwargs", "=", "None", ",", "compile_args", "=", "True", ",", "compile_kwargs", "=", "True", ")", ":", "if", "isinstance", "(", "token", ",", "Token", ")", ":", "bits", "=", "token", ...
Allow the template tag arguments to be like a normal Python function, with *args and **kwargs. :param parser: The "parser" object that ``@register.tag`` provides. :type parser: :class:`~django.template.Parser` :param token: The "token" object that ``@register.tag`` provides. :type token: :class:`~djang...
[ "Allow", "the", "template", "tag", "arguments", "to", "be", "like", "a", "normal", "Python", "function", "with", "*", "args", "and", "**", "kwargs", "." ]
python
test
xav-b/pyconsul
pyconsul/utils.py
https://github.com/xav-b/pyconsul/blob/06ce3b921d01010c19643424486bea4b22196076/pyconsul/utils.py#L25-L43
def safe_request(fct): ''' Return json messages instead of raising errors ''' def inner(*args, **kwargs): ''' decorator ''' try: _data = fct(*args, **kwargs) except requests.exceptions.ConnectionError as error: return {'error': str(error), 'status': 404} ...
[ "def", "safe_request", "(", "fct", ")", ":", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "''' decorator '''", "try", ":", "_data", "=", "fct", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "requests", ".", "exce...
Return json messages instead of raising errors
[ "Return", "json", "messages", "instead", "of", "raising", "errors" ]
python
train