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
osrg/ryu
ryu/services/protocols/bgp/peer.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/peer.py#L1256-L1312
def _connect_loop(self, client_factory): """In the current greenlet we try to establish connection with peer. This greenlet will spin another greenlet to handle incoming data from the peer once connection is established. """ # If current configuration allow, enable active sessio...
[ "def", "_connect_loop", "(", "self", ",", "client_factory", ")", ":", "# If current configuration allow, enable active session establishment.", "if", "self", ".", "_neigh_conf", ".", "enabled", ":", "self", ".", "_connect_retry_event", ".", "set", "(", ")", "while", "...
In the current greenlet we try to establish connection with peer. This greenlet will spin another greenlet to handle incoming data from the peer once connection is established.
[ "In", "the", "current", "greenlet", "we", "try", "to", "establish", "connection", "with", "peer", "." ]
python
train
zetaops/zengine
zengine/management_commands.py
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L619-L639
def check_mq_connection(self): """ RabbitMQ checks the connection It displays on the screen whether or not you have a connection. """ import pika from zengine.client_queue import BLOCKING_MQ_PARAMS from pika.exceptions import ProbableAuthenticationError, Connectio...
[ "def", "check_mq_connection", "(", "self", ")", ":", "import", "pika", "from", "zengine", ".", "client_queue", "import", "BLOCKING_MQ_PARAMS", "from", "pika", ".", "exceptions", "import", "ProbableAuthenticationError", ",", "ConnectionClosed", "try", ":", "connection"...
RabbitMQ checks the connection It displays on the screen whether or not you have a connection.
[ "RabbitMQ", "checks", "the", "connection", "It", "displays", "on", "the", "screen", "whether", "or", "not", "you", "have", "a", "connection", "." ]
python
train
tadashi-aikawa/owlmixin
owlmixin/__init__.py
https://github.com/tadashi-aikawa/owlmixin/blob/7c4a042c3008abddc56a8e8e55ae930d276071f5/owlmixin/__init__.py#L455-L480
def from_json_to_list(cls, data: str, force_snake_case=True, force_cast: bool=False, restrict: bool=False) -> TList[T]: """From json string to list of instance :param data: Json string :param force_snake_case: Keys are transformed to snake case in order to compliant PE...
[ "def", "from_json_to_list", "(", "cls", ",", "data", ":", "str", ",", "force_snake_case", "=", "True", ",", "force_cast", ":", "bool", "=", "False", ",", "restrict", ":", "bool", "=", "False", ")", "->", "TList", "[", "T", "]", ":", "return", "cls", ...
From json string to list of instance :param data: Json string :param force_snake_case: Keys are transformed to snake case in order to compliant PEP8 if True :param force_cast: Cast forcibly if True :param restrict: Prohibit extra parameters if True :return: List of instance ...
[ "From", "json", "string", "to", "list", "of", "instance" ]
python
train
OpenHydrology/floodestimation
floodestimation/loaders.py
https://github.com/OpenHydrology/floodestimation/blob/782da7c5abd1348923129efe89fb70003ebb088c/floodestimation/loaders.py#L151-L176
def userdata_to_db(session, method='update', autocommit=False): """ Add catchments from a user folder to the database. The user folder is specified in the ``config.ini`` file like this:: [import] folder = path/to/import/folder If this configuration key does not exist this will be sile...
[ "def", "userdata_to_db", "(", "session", ",", "method", "=", "'update'", ",", "autocommit", "=", "False", ")", ":", "try", ":", "folder", "=", "config", "[", "'import'", "]", "[", "'folder'", "]", "except", "KeyError", ":", "return", "if", "folder", ":",...
Add catchments from a user folder to the database. The user folder is specified in the ``config.ini`` file like this:: [import] folder = path/to/import/folder If this configuration key does not exist this will be silently ignored. :param session: database session to use, typically `flood...
[ "Add", "catchments", "from", "a", "user", "folder", "to", "the", "database", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_threshold_monitor.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_threshold_monitor.py#L610-L627
def threshold_monitor_hidden_threshold_monitor_interface_policy_area_area_value(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") threshold_monitor_hidden = ET.SubElement(config, "threshold-monitor-hidden", xmlns="urn:brocade.com:mgmt:brocade-threshold-monitor") ...
[ "def", "threshold_monitor_hidden_threshold_monitor_interface_policy_area_area_value", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "threshold_monitor_hidden", "=", "ET", ".", "SubElement", "(", "config", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
atlassian-api/atlassian-python-api
atlassian/bitbucket.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/bitbucket.py#L81-L92
def project_users_with_administrator_permissions(self, key): """ Get project administrators for project :param key: project key :return: project administrators """ project_administrators = [user['user'] for user in self.project_users(key) ...
[ "def", "project_users_with_administrator_permissions", "(", "self", ",", "key", ")", ":", "project_administrators", "=", "[", "user", "[", "'user'", "]", "for", "user", "in", "self", ".", "project_users", "(", "key", ")", "if", "user", "[", "'permission'", "]"...
Get project administrators for project :param key: project key :return: project administrators
[ "Get", "project", "administrators", "for", "project", ":", "param", "key", ":", "project", "key", ":", "return", ":", "project", "administrators" ]
python
train
NoneGG/aredis
aredis/lock.py
https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/lock.py#L132-L138
async def release(self): "Releases the already acquired lock" expected_token = self.local.token if expected_token is None: raise LockError("Cannot release an unlocked lock") self.local.token = None await self.do_release(expected_token)
[ "async", "def", "release", "(", "self", ")", ":", "expected_token", "=", "self", ".", "local", ".", "token", "if", "expected_token", "is", "None", ":", "raise", "LockError", "(", "\"Cannot release an unlocked lock\"", ")", "self", ".", "local", ".", "token", ...
Releases the already acquired lock
[ "Releases", "the", "already", "acquired", "lock" ]
python
train
nion-software/nionswift
nion/swift/model/Utility.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/Utility.py#L182-L216
def clean_item_no_list(i): """ Return a json-clean item or None. Will log info message for failure. """ itype = type(i) if itype == dict: return clean_dict(i, clean_item_no_list) elif itype == list: return clean_tuple(i, clean_item_no_list) elif itype == tuple: re...
[ "def", "clean_item_no_list", "(", "i", ")", ":", "itype", "=", "type", "(", "i", ")", "if", "itype", "==", "dict", ":", "return", "clean_dict", "(", "i", ",", "clean_item_no_list", ")", "elif", "itype", "==", "list", ":", "return", "clean_tuple", "(", ...
Return a json-clean item or None. Will log info message for failure.
[ "Return", "a", "json", "-", "clean", "item", "or", "None", ".", "Will", "log", "info", "message", "for", "failure", "." ]
python
train
chainer/chainerui
chainerui/tasks/collect_results.py
https://github.com/chainer/chainerui/blob/87ad25e875bc332bfdad20197fd3d0cb81a078e8/chainerui/tasks/collect_results.py#L8-L18
def _list_result_paths(target_path, log_file_name='log'): """list_result_paths.""" result_list = [] for root, _dirs, _files in os.walk(os.path.abspath(target_path)): for name in _files: if name == log_file_name: result_list.append(root) return result_list
[ "def", "_list_result_paths", "(", "target_path", ",", "log_file_name", "=", "'log'", ")", ":", "result_list", "=", "[", "]", "for", "root", ",", "_dirs", ",", "_files", "in", "os", ".", "walk", "(", "os", ".", "path", ".", "abspath", "(", "target_path", ...
list_result_paths.
[ "list_result_paths", "." ]
python
train
MAVENSDC/PyTplot
pytplot/tplot_restore.py
https://github.com/MAVENSDC/PyTplot/blob/d76cdb95363a4bd4fea6bca7960f8523efa7fa83/pytplot/tplot_restore.py#L16-L114
def tplot_restore(filename): """ This function will restore tplot variables that have been saved with the "tplot_save" command. .. note:: This function is compatible with the IDL tplot_save routine. If you have a ".tplot" file generated from IDL, this procedure will restore the data c...
[ "def", "tplot_restore", "(", "filename", ")", ":", "#Error check", "if", "not", "(", "os", ".", "path", ".", "isfile", "(", "filename", ")", ")", ":", "print", "(", "\"Not a valid file name\"", ")", "return", "#Check if the restored file was an IDL file", "if", ...
This function will restore tplot variables that have been saved with the "tplot_save" command. .. note:: This function is compatible with the IDL tplot_save routine. If you have a ".tplot" file generated from IDL, this procedure will restore the data contained in the file. Not all plo...
[ "This", "function", "will", "restore", "tplot", "variables", "that", "have", "been", "saved", "with", "the", "tplot_save", "command", ".", "..", "note", "::", "This", "function", "is", "compatible", "with", "the", "IDL", "tplot_save", "routine", ".", "If", "...
python
train
cltrudeau/django-awl
awl/waelsteng.py
https://github.com/cltrudeau/django-awl/blob/70d469ef9a161c1170b53aa017cf02d7c15eb90c/awl/waelsteng.py#L135-L142
def initiate(self): """Sets up the :class:`AdminSite` and creates a user with the appropriate privileges. This should be called from the inheritor's :class:`TestCase.setUp` method. """ self.site = admin.sites.AdminSite() self.admin_user = create_admin(self.USERNAME, self...
[ "def", "initiate", "(", "self", ")", ":", "self", ".", "site", "=", "admin", ".", "sites", ".", "AdminSite", "(", ")", "self", ".", "admin_user", "=", "create_admin", "(", "self", ".", "USERNAME", ",", "self", ".", "EMAIL", ",", "self", ".", "PASSWOR...
Sets up the :class:`AdminSite` and creates a user with the appropriate privileges. This should be called from the inheritor's :class:`TestCase.setUp` method.
[ "Sets", "up", "the", ":", "class", ":", "AdminSite", "and", "creates", "a", "user", "with", "the", "appropriate", "privileges", ".", "This", "should", "be", "called", "from", "the", "inheritor", "s", ":", "class", ":", "TestCase", ".", "setUp", "method", ...
python
valid
tensorflow/probability
tensorflow_probability/python/mcmc/text_messages_hmc.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/mcmc/text_messages_hmc.py#L44-L61
def text_messages_joint_log_prob(count_data, lambda_1, lambda_2, tau): """Joint log probability function.""" alpha = (1. / tf.reduce_mean(input_tensor=count_data)) rv_lambda = tfd.Exponential(rate=alpha) rv_tau = tfd.Uniform() lambda_ = tf.gather( [lambda_1, lambda_2], indices=tf.cast( ...
[ "def", "text_messages_joint_log_prob", "(", "count_data", ",", "lambda_1", ",", "lambda_2", ",", "tau", ")", ":", "alpha", "=", "(", "1.", "/", "tf", ".", "reduce_mean", "(", "input_tensor", "=", "count_data", ")", ")", "rv_lambda", "=", "tfd", ".", "Expon...
Joint log probability function.
[ "Joint", "log", "probability", "function", "." ]
python
test
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/interactive.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/interactive.py#L1074-L1097
def do_shell(self, arg): """ ! - spawn a system shell shell - spawn a system shell ! <command> [arguments...] - execute a single shell command shell <command> [arguments...] - execute a single shell command """ if self.cmdprefix: raise CmdError("prefix...
[ "def", "do_shell", "(", "self", ",", "arg", ")", ":", "if", "self", ".", "cmdprefix", ":", "raise", "CmdError", "(", "\"prefix not allowed\"", ")", "# Try to use the environment to locate cmd.exe.", "# If not found, it's usually OK to just use the filename,", "# since cmd.exe...
! - spawn a system shell shell - spawn a system shell ! <command> [arguments...] - execute a single shell command shell <command> [arguments...] - execute a single shell command
[ "!", "-", "spawn", "a", "system", "shell", "shell", "-", "spawn", "a", "system", "shell", "!", "<command", ">", "[", "arguments", "...", "]", "-", "execute", "a", "single", "shell", "command", "shell", "<command", ">", "[", "arguments", "...", "]", "-"...
python
train
calmjs/calmjs
src/calmjs/base.py
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/base.py#L691-L700
def dump(self, blob, stream): """ Call json.dump with the attributes of this instance as arguments. """ json.dump( blob, stream, indent=self.indent, sort_keys=True, separators=self.separators, )
[ "def", "dump", "(", "self", ",", "blob", ",", "stream", ")", ":", "json", ".", "dump", "(", "blob", ",", "stream", ",", "indent", "=", "self", ".", "indent", ",", "sort_keys", "=", "True", ",", "separators", "=", "self", ".", "separators", ",", ")"...
Call json.dump with the attributes of this instance as arguments.
[ "Call", "json", ".", "dump", "with", "the", "attributes", "of", "this", "instance", "as", "arguments", "." ]
python
train
alephdata/memorious
memorious/logic/context.py
https://github.com/alephdata/memorious/blob/b4033c5064447ed5f696f9c2bbbc6c12062d2fa4/memorious/logic/context.py#L115-L136
def skip_incremental(self, *criteria): """Perform an incremental check on a set of criteria. This can be used to execute a part of a crawler only once per an interval (which is specified by the ``expire`` setting). If the operation has already been performed (and should thus be skipped)...
[ "def", "skip_incremental", "(", "self", ",", "*", "criteria", ")", ":", "if", "not", "self", ".", "incremental", ":", "return", "False", "# this is pure convenience, and will probably backfire at some point.", "key", "=", "make_key", "(", "*", "criteria", ")", "if",...
Perform an incremental check on a set of criteria. This can be used to execute a part of a crawler only once per an interval (which is specified by the ``expire`` setting). If the operation has already been performed (and should thus be skipped), this will return ``True``. If the operat...
[ "Perform", "an", "incremental", "check", "on", "a", "set", "of", "criteria", "." ]
python
train
saltstack/salt
salt/cloud/clouds/joyent.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/joyent.py#L325-L370
def create_node(**kwargs): ''' convenience function to make the rest api call for node creation. ''' name = kwargs['name'] size = kwargs['size'] image = kwargs['image'] location = kwargs['location'] networks = kwargs.get('networks') tag = kwargs.get('tag') locality = kwargs.get('...
[ "def", "create_node", "(", "*", "*", "kwargs", ")", ":", "name", "=", "kwargs", "[", "'name'", "]", "size", "=", "kwargs", "[", "'size'", "]", "image", "=", "kwargs", "[", "'image'", "]", "location", "=", "kwargs", "[", "'location'", "]", "networks", ...
convenience function to make the rest api call for node creation.
[ "convenience", "function", "to", "make", "the", "rest", "api", "call", "for", "node", "creation", "." ]
python
train
python-security/pyt
pyt/vulnerabilities/trigger_definitions_parser.py
https://github.com/python-security/pyt/blob/efc0cfb716e40e0c8df4098f1cc8cf43723cd31f/pyt/vulnerabilities/trigger_definitions_parser.py#L69-L82
def parse(trigger_word_file): """Parse the file for source and sink definitions. Returns: A definitions tuple with sources and sinks. """ with open(trigger_word_file) as fd: triggers_dict = json.load(fd) sources = [Source(s) for s in triggers_dict['sources']] sinks = [ Si...
[ "def", "parse", "(", "trigger_word_file", ")", ":", "with", "open", "(", "trigger_word_file", ")", "as", "fd", ":", "triggers_dict", "=", "json", ".", "load", "(", "fd", ")", "sources", "=", "[", "Source", "(", "s", ")", "for", "s", "in", "triggers_dic...
Parse the file for source and sink definitions. Returns: A definitions tuple with sources and sinks.
[ "Parse", "the", "file", "for", "source", "and", "sink", "definitions", "." ]
python
train
Azure/blobxfer
blobxfer/operations/download.py
https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/operations/download.py#L639-L657
def _finalize_chunk(self, dd, offsets): # type: (Downloader, blobxfer.models.download.Descriptor, # blobxfer.models.download.Offsets) -> None """Finalize written chunk :param Downloader self: this :param blobxfer.models.download.Descriptor dd: download descriptor :...
[ "def", "_finalize_chunk", "(", "self", ",", "dd", ",", "offsets", ")", ":", "# type: (Downloader, blobxfer.models.download.Descriptor,", "# blobxfer.models.download.Offsets) -> None", "if", "dd", ".", "entity", ".", "is_encrypted", ":", "dd", ".", "mark_unchecked_chu...
Finalize written chunk :param Downloader self: this :param blobxfer.models.download.Descriptor dd: download descriptor :param blobxfer.models.download.Offsets offsets: offsets
[ "Finalize", "written", "chunk", ":", "param", "Downloader", "self", ":", "this", ":", "param", "blobxfer", ".", "models", ".", "download", ".", "Descriptor", "dd", ":", "download", "descriptor", ":", "param", "blobxfer", ".", "models", ".", "download", ".", ...
python
train
openeemeter/eemeter
eemeter/io.py
https://github.com/openeemeter/eemeter/blob/e03b1cc5f4906e8f4f7fd16183bc037107d1dfa0/eemeter/io.py#L186-L215
def temperature_data_from_json(data, orient="list"): """ Load temperature data from json. (Must be given in degrees Fahrenheit). Default format:: [ ['2017-01-01T00:00:00+00:00', 3.5], ['2017-01-01T01:00:00+00:00', 5.4], ['2017-01-01T02:00:00+00:00', 7.4], ...
[ "def", "temperature_data_from_json", "(", "data", ",", "orient", "=", "\"list\"", ")", ":", "if", "orient", "==", "\"list\"", ":", "df", "=", "pd", ".", "DataFrame", "(", "data", ",", "columns", "=", "[", "\"dt\"", ",", "\"tempF\"", "]", ")", "series", ...
Load temperature data from json. (Must be given in degrees Fahrenheit). Default format:: [ ['2017-01-01T00:00:00+00:00', 3.5], ['2017-01-01T01:00:00+00:00', 5.4], ['2017-01-01T02:00:00+00:00', 7.4], ] Parameters ---------- data : :any:`list` ...
[ "Load", "temperature", "data", "from", "json", ".", "(", "Must", "be", "given", "in", "degrees", "Fahrenheit", ")", "." ]
python
train
pytroll/satpy
satpy/resample.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/resample.py#L233-L272
def resample(self, data, cache_dir=None, mask_area=None, **kwargs): """Resample `data` by calling `precompute` and `compute` methods. Only certain resampling classes may use `cache_dir` and the `mask` provided when `mask_area` is True. The return value of calling the `precompute` method...
[ "def", "resample", "(", "self", ",", "data", ",", "cache_dir", "=", "None", ",", "mask_area", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# default is to mask areas for SwathDefinitions", "if", "mask_area", "is", "None", "and", "isinstance", "(", "self", ...
Resample `data` by calling `precompute` and `compute` methods. Only certain resampling classes may use `cache_dir` and the `mask` provided when `mask_area` is True. The return value of calling the `precompute` method is passed as the `cache_id` keyword argument of the `compute` method, ...
[ "Resample", "data", "by", "calling", "precompute", "and", "compute", "methods", "." ]
python
train
hydpy-dev/hydpy
hydpy/core/devicetools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/devicetools.py#L814-L818
def prepare_allseries(self, ramflag: bool = True) -> None: """Call methods |Node.prepare_simseries| and |Node.prepare_obsseries|.""" self.prepare_simseries(ramflag) self.prepare_obsseries(ramflag)
[ "def", "prepare_allseries", "(", "self", ",", "ramflag", ":", "bool", "=", "True", ")", "->", "None", ":", "self", ".", "prepare_simseries", "(", "ramflag", ")", "self", ".", "prepare_obsseries", "(", "ramflag", ")" ]
Call methods |Node.prepare_simseries| and |Node.prepare_obsseries|.
[ "Call", "methods", "|Node", ".", "prepare_simseries|", "and", "|Node", ".", "prepare_obsseries|", "." ]
python
train
OnroerendErfgoed/crabpy
crabpy/gateway/crab.py
https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/crab.py#L128-L163
def get_gewest_by_id(self, id): ''' Get a `gewest` by id. :param integer id: The id of a `gewest`. :rtype: A :class:`Gewest`. ''' def creator(): nl = crab_gateway_request( self.client, 'GetGewestByGewestIdAndTaalCode', id, 'nl' ) ...
[ "def", "get_gewest_by_id", "(", "self", ",", "id", ")", ":", "def", "creator", "(", ")", ":", "nl", "=", "crab_gateway_request", "(", "self", ".", "client", ",", "'GetGewestByGewestIdAndTaalCode'", ",", "id", ",", "'nl'", ")", "fr", "=", "crab_gateway_reques...
Get a `gewest` by id. :param integer id: The id of a `gewest`. :rtype: A :class:`Gewest`.
[ "Get", "a", "gewest", "by", "id", "." ]
python
train
tgbugs/pyontutils
pyontutils/core.py
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/pyontutils/core.py#L250-L264
def add_op(self, id_, label=None, subPropertyOf=None, inverse=None, transitive=False, addPrefix=True): """ Add id_ as an owl:ObjectProperty""" self.add_trip(id_, rdf.type, owl.ObjectProperty) if inverse: self.add_trip(id_, owl.inverseOf, inverse) if subPropertyOf: ...
[ "def", "add_op", "(", "self", ",", "id_", ",", "label", "=", "None", ",", "subPropertyOf", "=", "None", ",", "inverse", "=", "None", ",", "transitive", "=", "False", ",", "addPrefix", "=", "True", ")", ":", "self", ".", "add_trip", "(", "id_", ",", ...
Add id_ as an owl:ObjectProperty
[ "Add", "id_", "as", "an", "owl", ":", "ObjectProperty" ]
python
train
wandb/client
wandb/summary.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/summary.py#L253-L269
def _decode(self, path, json_value): """Decode a `dict` encoded by `Summary._encode()`, loading h5 objects. h5 objects may be very large, so we won't have loaded them automatically. """ if isinstance(json_value, dict): if json_value.get("_type") in H5_TYPES: ...
[ "def", "_decode", "(", "self", ",", "path", ",", "json_value", ")", ":", "if", "isinstance", "(", "json_value", ",", "dict", ")", ":", "if", "json_value", ".", "get", "(", "\"_type\"", ")", "in", "H5_TYPES", ":", "return", "self", ".", "read_h5", "(", ...
Decode a `dict` encoded by `Summary._encode()`, loading h5 objects. h5 objects may be very large, so we won't have loaded them automatically.
[ "Decode", "a", "dict", "encoded", "by", "Summary", ".", "_encode", "()", "loading", "h5", "objects", "." ]
python
train
synw/dataswim
dataswim/data/transform/calculations.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/transform/calculations.py#L129-L150
def diffsp(self, col: str, serie: "iterable", name: str="Diff"): """ Add a diff column in percentage from a serie. The serie is an iterable of the same length than the dataframe :param col: column to diff :type col: str :param serie: serie to diff from :type ser...
[ "def", "diffsp", "(", "self", ",", "col", ":", "str", ",", "serie", ":", "\"iterable\"", ",", "name", ":", "str", "=", "\"Diff\"", ")", ":", "try", ":", "d", "=", "[", "]", "for", "i", ",", "row", "in", "self", ".", "df", ".", "iterrows", "(", ...
Add a diff column in percentage from a serie. The serie is an iterable of the same length than the dataframe :param col: column to diff :type col: str :param serie: serie to diff from :type serie: iterable :param name: name of the diff col, defaults to "Diff" :p...
[ "Add", "a", "diff", "column", "in", "percentage", "from", "a", "serie", ".", "The", "serie", "is", "an", "iterable", "of", "the", "same", "length", "than", "the", "dataframe" ]
python
train
marshallward/f90nml
f90nml/parser.py
https://github.com/marshallward/f90nml/blob/4932cabc5221afc844ee6a5b4a05ceb8bd4a2711/f90nml/parser.py#L852-L862
def merge_values(src, new): """Merge two lists or dicts into a single element.""" if isinstance(src, dict) and isinstance(new, dict): return merge_dicts(src, new) else: if not isinstance(src, list): src = [src] if not isinstance(new, list): new = [new] ...
[ "def", "merge_values", "(", "src", ",", "new", ")", ":", "if", "isinstance", "(", "src", ",", "dict", ")", "and", "isinstance", "(", "new", ",", "dict", ")", ":", "return", "merge_dicts", "(", "src", ",", "new", ")", "else", ":", "if", "not", "isin...
Merge two lists or dicts into a single element.
[ "Merge", "two", "lists", "or", "dicts", "into", "a", "single", "element", "." ]
python
train
shoebot/shoebot
lib/colors/__init__.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1552-L1582
def monochrome(clr): """ Returns colors in the same hue with varying brightness/saturation. """ def _wrap(x, min, threshold, plus): if x - min < threshold: return x + plus else: return x - min colors = colorlist(clr) c = clr.copy() c.brightness = _wr...
[ "def", "monochrome", "(", "clr", ")", ":", "def", "_wrap", "(", "x", ",", "min", ",", "threshold", ",", "plus", ")", ":", "if", "x", "-", "min", "<", "threshold", ":", "return", "x", "+", "plus", "else", ":", "return", "x", "-", "min", "colors", ...
Returns colors in the same hue with varying brightness/saturation.
[ "Returns", "colors", "in", "the", "same", "hue", "with", "varying", "brightness", "/", "saturation", "." ]
python
valid
michaelpb/omnic
omnic/conversion/graph.py
https://github.com/michaelpb/omnic/blob/1111cfd73c9dc1955afe42d9cf2a468c46f83cd6/omnic/conversion/graph.py#L74-L90
def _setup_profiles(self, conversion_profiles): ''' Add given conversion profiles checking for invalid profiles ''' # Check for invalid profiles for key, path in conversion_profiles.items(): if isinstance(path, str): path = (path, ) for lef...
[ "def", "_setup_profiles", "(", "self", ",", "conversion_profiles", ")", ":", "# Check for invalid profiles", "for", "key", ",", "path", "in", "conversion_profiles", ".", "items", "(", ")", ":", "if", "isinstance", "(", "path", ",", "str", ")", ":", "path", "...
Add given conversion profiles checking for invalid profiles
[ "Add", "given", "conversion", "profiles", "checking", "for", "invalid", "profiles" ]
python
train
skorch-dev/skorch
skorch/utils.py
https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/skorch/utils.py#L183-L217
def check_indexing(data): """Perform a check how incoming data should be indexed and return an appropriate indexing function with signature f(data, index). This is useful for determining upfront how data should be indexed instead of doing it repeatedly for each batch, thus saving some time. ""...
[ "def", "check_indexing", "(", "data", ")", ":", "if", "data", "is", "None", ":", "return", "_indexing_none", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "# dictionary of containers", "return", "_indexing_dict", "if", "isinstance", "(", "data", ",",...
Perform a check how incoming data should be indexed and return an appropriate indexing function with signature f(data, index). This is useful for determining upfront how data should be indexed instead of doing it repeatedly for each batch, thus saving some time.
[ "Perform", "a", "check", "how", "incoming", "data", "should", "be", "indexed", "and", "return", "an", "appropriate", "indexing", "function", "with", "signature", "f", "(", "data", "index", ")", "." ]
python
train
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/scrappers/cpress_cz.py
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/cpress_cz.py#L95-L129
def _parse_authors(html_chunk): """ Parse authors of the book. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: list: List of :class:`structures.Author` objects. Blank if no author \ found. """ authors_tags = html_chunk.match...
[ "def", "_parse_authors", "(", "html_chunk", ")", ":", "authors_tags", "=", "html_chunk", ".", "match", "(", "[", "\"div\"", ",", "{", "\"class\"", ":", "\"polozka_autor\"", "}", "]", ",", "\"a\"", ")", "authors", "=", "[", "]", "for", "author_tag", "in", ...
Parse authors of the book. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: list: List of :class:`structures.Author` objects. Blank if no author \ found.
[ "Parse", "authors", "of", "the", "book", "." ]
python
train
iotile/coretools
iotileship/iotile/ship/resources/hardware_manager.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/resources/hardware_manager.py#L46-L64
def open(self): """Open and potentially connect to a device.""" self.hwman = HardwareManager(port=self._port) self.opened = True if self._connection_string is not None: try: self.hwman.connect_direct(self._connection_string) except HardwareError:...
[ "def", "open", "(", "self", ")", ":", "self", ".", "hwman", "=", "HardwareManager", "(", "port", "=", "self", ".", "_port", ")", "self", ".", "opened", "=", "True", "if", "self", ".", "_connection_string", "is", "not", "None", ":", "try", ":", "self"...
Open and potentially connect to a device.
[ "Open", "and", "potentially", "connect", "to", "a", "device", "." ]
python
train
Julian/Ivoire
ivoire/transform.py
https://github.com/Julian/Ivoire/blob/5b8218cffa409ed733cf850a6fde16fafb8fc2af/ivoire/transform.py#L141-L152
def takes_only_self(self): """ Return an argument list node that takes only ``self``. """ return ast.arguments( args=[ast.arg(arg="self")], defaults=[], kw_defaults=[], kwonlyargs=[], )
[ "def", "takes_only_self", "(", "self", ")", ":", "return", "ast", ".", "arguments", "(", "args", "=", "[", "ast", ".", "arg", "(", "arg", "=", "\"self\"", ")", "]", ",", "defaults", "=", "[", "]", ",", "kw_defaults", "=", "[", "]", ",", "kwonlyargs...
Return an argument list node that takes only ``self``.
[ "Return", "an", "argument", "list", "node", "that", "takes", "only", "self", "." ]
python
test
ebu/PlugIt
plugit_proxy/views.py
https://github.com/ebu/PlugIt/blob/de5f1e870f67caaef7a4a58e4bb1ed54d9c5dc53/plugit_proxy/views.py#L1250-L1272
def api_send_mail(request, key=None, hproPk=None): """Send a email. Posts parameters are used""" if not check_api_key(request, key, hproPk): return HttpResponseForbidden sender = request.POST.get('sender', settings.MAIL_SENDER) dests = request.POST.getlist('dests') subject = request.POST['...
[ "def", "api_send_mail", "(", "request", ",", "key", "=", "None", ",", "hproPk", "=", "None", ")", ":", "if", "not", "check_api_key", "(", "request", ",", "key", ",", "hproPk", ")", ":", "return", "HttpResponseForbidden", "sender", "=", "request", ".", "P...
Send a email. Posts parameters are used
[ "Send", "a", "email", ".", "Posts", "parameters", "are", "used" ]
python
train
SecurityInnovation/PGPy
pgpy/pgp.py
https://github.com/SecurityInnovation/PGPy/blob/f1c3d68e32c334f5aa14c34580925e97f17f4fde/pgpy/pgp.py#L102-L108
def compprefs(self): """ A ``list`` of preferred compression algorithms specified in this signature, if any. Otherwise, an empty ``list``. """ if 'PreferredCompressionAlgorithms' in self._signature.subpackets: return next(iter(self._signature.subpackets['h_PreferredCompressio...
[ "def", "compprefs", "(", "self", ")", ":", "if", "'PreferredCompressionAlgorithms'", "in", "self", ".", "_signature", ".", "subpackets", ":", "return", "next", "(", "iter", "(", "self", ".", "_signature", ".", "subpackets", "[", "'h_PreferredCompressionAlgorithms'...
A ``list`` of preferred compression algorithms specified in this signature, if any. Otherwise, an empty ``list``.
[ "A", "list", "of", "preferred", "compression", "algorithms", "specified", "in", "this", "signature", "if", "any", ".", "Otherwise", "an", "empty", "list", "." ]
python
train
gem/oq-engine
openquake/baselib/__init__.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/__init__.py#L90-L99
def boolean(flag): """ Convert string in boolean """ s = flag.lower() if s in ('1', 'yes', 'true'): return True elif s in ('0', 'no', 'false'): return False raise ValueError('Unknown flag %r' % s)
[ "def", "boolean", "(", "flag", ")", ":", "s", "=", "flag", ".", "lower", "(", ")", "if", "s", "in", "(", "'1'", ",", "'yes'", ",", "'true'", ")", ":", "return", "True", "elif", "s", "in", "(", "'0'", ",", "'no'", ",", "'false'", ")", ":", "re...
Convert string in boolean
[ "Convert", "string", "in", "boolean" ]
python
train
angr/angr
angr/state_plugins/heap/heap_libc.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/heap/heap_libc.py#L27-L36
def calloc(self, sim_nmemb, sim_size): """ A somewhat faithful implementation of libc `calloc`. :param sim_nmemb: the number of elements to allocated :param sim_size: the size of each element (in bytes) :returns: the address of the allocation, or a NULL pointer if the a...
[ "def", "calloc", "(", "self", ",", "sim_nmemb", ",", "sim_size", ")", ":", "raise", "NotImplementedError", "(", "\"%s not implemented for %s\"", "%", "(", "self", ".", "calloc", ".", "__func__", ".", "__name__", ",", "self", ".", "__class__", ".", "__name__", ...
A somewhat faithful implementation of libc `calloc`. :param sim_nmemb: the number of elements to allocated :param sim_size: the size of each element (in bytes) :returns: the address of the allocation, or a NULL pointer if the allocation failed
[ "A", "somewhat", "faithful", "implementation", "of", "libc", "calloc", "." ]
python
train
rwl/pylon
pylon/util.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/util.py#L130-L140
def load(cls, filename, format=None): """ Return an instance of the class that is saved in the file with the given filename in the specified format. """ if format is None: # try to derive protocol from file extension format = format_from_extension(filename) ...
[ "def", "load", "(", "cls", ",", "filename", ",", "format", "=", "None", ")", ":", "if", "format", "is", "None", ":", "# try to derive protocol from file extension", "format", "=", "format_from_extension", "(", "filename", ")", "with", "file", "(", "filename", ...
Return an instance of the class that is saved in the file with the given filename in the specified format.
[ "Return", "an", "instance", "of", "the", "class", "that", "is", "saved", "in", "the", "file", "with", "the", "given", "filename", "in", "the", "specified", "format", "." ]
python
train
xolox/python-vcs-repo-mgr
vcs_repo_mgr/backends/git.py
https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/backends/git.py#L254-L264
def find_tags(self): """Find information about the tags in the repository.""" listing = self.context.capture('git', 'show-ref', '--tags', check=False) for line in listing.splitlines(): tokens = line.split() if len(tokens) >= 2 and tokens[1].startswith('refs/tags/'): ...
[ "def", "find_tags", "(", "self", ")", ":", "listing", "=", "self", ".", "context", ".", "capture", "(", "'git'", ",", "'show-ref'", ",", "'--tags'", ",", "check", "=", "False", ")", "for", "line", "in", "listing", ".", "splitlines", "(", ")", ":", "t...
Find information about the tags in the repository.
[ "Find", "information", "about", "the", "tags", "in", "the", "repository", "." ]
python
train
PythonCharmers/python-future
src/future/backports/xmlrpc/server.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/xmlrpc/server.py#L463-L532
def do_POST(self): """Handles the HTTP POST request. Attempts to interpret all HTTP POST requests as XML-RPC calls, which are forwarded to the server's _dispatch method for handling. """ # Check that the path is legal if not self.is_rpc_path_valid(): self.re...
[ "def", "do_POST", "(", "self", ")", ":", "# Check that the path is legal", "if", "not", "self", ".", "is_rpc_path_valid", "(", ")", ":", "self", ".", "report_404", "(", ")", "return", "try", ":", "# Get arguments by reading body of request.", "# We read this in chunks...
Handles the HTTP POST request. Attempts to interpret all HTTP POST requests as XML-RPC calls, which are forwarded to the server's _dispatch method for handling.
[ "Handles", "the", "HTTP", "POST", "request", "." ]
python
train
cokelaer/spectrum
src/spectrum/window.py
https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/window.py#L1304-L1326
def window_cauchy(N, alpha=3): r"""Cauchy tapering window :param int N: window length :param float alpha: parameter of the poisson window .. math:: w(n) = \frac{1}{1+\left(\frac{\alpha*n}{N/2}\right)**2} .. plot:: :width: 80% :include-source: from spectrum import window_v...
[ "def", "window_cauchy", "(", "N", ",", "alpha", "=", "3", ")", ":", "n", "=", "linspace", "(", "-", "N", "/", "2.", ",", "(", "N", ")", "/", "2.", ",", "N", ")", "w", "=", "1.", "/", "(", "1.", "+", "(", "alpha", "*", "n", "/", "(", "N"...
r"""Cauchy tapering window :param int N: window length :param float alpha: parameter of the poisson window .. math:: w(n) = \frac{1}{1+\left(\frac{\alpha*n}{N/2}\right)**2} .. plot:: :width: 80% :include-source: from spectrum import window_visu window_visu(64, 'cauchy...
[ "r", "Cauchy", "tapering", "window" ]
python
valid
inasafe/inasafe
safe/gui/tools/multi_exposure_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/multi_exposure_dialog.py#L277-L295
def _list_selection_changed(self): """Selection has changed in the list.""" items = self.list_layers_in_map_report.selectedItems() self.remove_layer.setEnabled(len(items) >= 1) if len(items) == 1 and self.list_layers_in_map_report.count() >= 2: index = self.list_layers_in_map...
[ "def", "_list_selection_changed", "(", "self", ")", ":", "items", "=", "self", ".", "list_layers_in_map_report", ".", "selectedItems", "(", ")", "self", ".", "remove_layer", ".", "setEnabled", "(", "len", "(", "items", ")", ">=", "1", ")", "if", "len", "("...
Selection has changed in the list.
[ "Selection", "has", "changed", "in", "the", "list", "." ]
python
train
CitrineInformatics/pypif
pypif/util/serializable.py
https://github.com/CitrineInformatics/pypif/blob/938348a8ff7b10b330770cccaaeb2109922f681b/pypif/util/serializable.py#L36-L49
def _get_object(class_, obj): """ Helper function that returns an object, or if it is a dictionary, initializes it from class_. :param class_: Class to use to instantiate object. :param obj: Object to process. :return: One or more objects. """ if isinstance(obj, ...
[ "def", "_get_object", "(", "class_", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "return", "[", "Serializable", ".", "_get_object", "(", "class_", ",", "i", ")", "for", "i", "in", "obj", "]", "elif", "isinstance", "("...
Helper function that returns an object, or if it is a dictionary, initializes it from class_. :param class_: Class to use to instantiate object. :param obj: Object to process. :return: One or more objects.
[ "Helper", "function", "that", "returns", "an", "object", "or", "if", "it", "is", "a", "dictionary", "initializes", "it", "from", "class_", "." ]
python
train
openstack/networking-cisco
networking_cisco/apps/saf/server/cisco_dfa_rest.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/cisco_dfa_rest.py#L392-L397
def _logout_request(self, url_logout): """Internal logout request to DCNM. """ requests.post(url_logout, headers=self._req_headers, timeout=self.timeout_resp, verify=False)
[ "def", "_logout_request", "(", "self", ",", "url_logout", ")", ":", "requests", ".", "post", "(", "url_logout", ",", "headers", "=", "self", ".", "_req_headers", ",", "timeout", "=", "self", ".", "timeout_resp", ",", "verify", "=", "False", ")" ]
Internal logout request to DCNM.
[ "Internal", "logout", "request", "to", "DCNM", "." ]
python
train
dpkp/kafka-python
kafka/coordinator/consumer.py
https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/coordinator/consumer.py#L379-L387
def refresh_committed_offsets_if_needed(self): """Fetch committed offsets for assigned partitions.""" if self._subscription.needs_fetch_committed_offsets: offsets = self.fetch_committed_offsets(self._subscription.assigned_partitions()) for partition, offset in six.iteritems(offse...
[ "def", "refresh_committed_offsets_if_needed", "(", "self", ")", ":", "if", "self", ".", "_subscription", ".", "needs_fetch_committed_offsets", ":", "offsets", "=", "self", ".", "fetch_committed_offsets", "(", "self", ".", "_subscription", ".", "assigned_partitions", "...
Fetch committed offsets for assigned partitions.
[ "Fetch", "committed", "offsets", "for", "assigned", "partitions", "." ]
python
train
tcalmant/ipopo
pelix/shell/parser.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/parser.py#L62-L79
def _find_assignment(arg_token): """ Find the first non-escaped assignment in the given argument token. Returns -1 if no assignment was found. :param arg_token: The argument token :return: The index of the first assignment, or -1 """ idx = arg_token.find("=") while idx != -1: if...
[ "def", "_find_assignment", "(", "arg_token", ")", ":", "idx", "=", "arg_token", ".", "find", "(", "\"=\"", ")", "while", "idx", "!=", "-", "1", ":", "if", "idx", "!=", "0", "and", "arg_token", "[", "idx", "-", "1", "]", "!=", "\"\\\\\"", ":", "# No...
Find the first non-escaped assignment in the given argument token. Returns -1 if no assignment was found. :param arg_token: The argument token :return: The index of the first assignment, or -1
[ "Find", "the", "first", "non", "-", "escaped", "assignment", "in", "the", "given", "argument", "token", ".", "Returns", "-", "1", "if", "no", "assignment", "was", "found", "." ]
python
train
openai/retro
retro/examples/brute.py
https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/brute.py#L144-L162
def update_tree(root, executed_acts, total_rew): """ Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree so that the path formed by the executed actions are all updated to the new reward. """ root.value = max(total_rew, root.value) root.visit...
[ "def", "update_tree", "(", "root", ",", "executed_acts", ",", "total_rew", ")", ":", "root", ".", "value", "=", "max", "(", "total_rew", ",", "root", ".", "value", ")", "root", ".", "visits", "+=", "1", "new_nodes", "=", "0", "node", "=", "root", "fo...
Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree so that the path formed by the executed actions are all updated to the new reward.
[ "Given", "the", "tree", "a", "list", "of", "actions", "that", "were", "executed", "before", "the", "game", "ended", "and", "a", "reward", "update", "the", "tree", "so", "that", "the", "path", "formed", "by", "the", "executed", "actions", "are", "all", "u...
python
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L141-L147
def get_cond_latents_at_level(cond_latents, level, hparams): """Returns a single or list of conditional latents at level 'level'.""" if cond_latents: if hparams.latent_dist_encoder in ["conv_net", "conv3d_net"]: return [cond_latent[level] for cond_latent in cond_latents] elif hparams.latent_dist_encod...
[ "def", "get_cond_latents_at_level", "(", "cond_latents", ",", "level", ",", "hparams", ")", ":", "if", "cond_latents", ":", "if", "hparams", ".", "latent_dist_encoder", "in", "[", "\"conv_net\"", ",", "\"conv3d_net\"", "]", ":", "return", "[", "cond_latent", "["...
Returns a single or list of conditional latents at level 'level'.
[ "Returns", "a", "single", "or", "list", "of", "conditional", "latents", "at", "level", "level", "." ]
python
train
mila-iqia/fuel
fuel/converters/binarized_mnist.py
https://github.com/mila-iqia/fuel/blob/1d6292dc25e3a115544237e392e61bff6631d23c/fuel/converters/binarized_mnist.py#L17-L71
def convert_binarized_mnist(directory, output_directory, output_filename='binarized_mnist.hdf5'): """Converts the binarized MNIST dataset to HDF5. Converts the binarized MNIST dataset used in R. Salakhutdinov's DBN paper [DBN] to an HDF5 dataset compatible with :class:`fuel....
[ "def", "convert_binarized_mnist", "(", "directory", ",", "output_directory", ",", "output_filename", "=", "'binarized_mnist.hdf5'", ")", ":", "output_path", "=", "os", ".", "path", ".", "join", "(", "output_directory", ",", "output_filename", ")", "h5file", "=", "...
Converts the binarized MNIST dataset to HDF5. Converts the binarized MNIST dataset used in R. Salakhutdinov's DBN paper [DBN] to an HDF5 dataset compatible with :class:`fuel.datasets.BinarizedMNIST`. The converted dataset is saved as 'binarized_mnist.hdf5'. This method assumes the existence of the...
[ "Converts", "the", "binarized", "MNIST", "dataset", "to", "HDF5", "." ]
python
train
inveniosoftware/invenio-github
invenio_github/utils.py
https://github.com/inveniosoftware/invenio-github/blob/ec42fd6a06079310dcbe2c46d9fd79d5197bbe26/invenio_github/utils.py#L44-L49
def parse_timestamp(x): """Parse ISO8601 formatted timestamp.""" dt = dateutil.parser.parse(x) if dt.tzinfo is None: dt = dt.replace(tzinfo=pytz.utc) return dt
[ "def", "parse_timestamp", "(", "x", ")", ":", "dt", "=", "dateutil", ".", "parser", ".", "parse", "(", "x", ")", "if", "dt", ".", "tzinfo", "is", "None", ":", "dt", "=", "dt", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")", "return",...
Parse ISO8601 formatted timestamp.
[ "Parse", "ISO8601", "formatted", "timestamp", "." ]
python
train
google/grr
grr/server/grr_response_server/databases/mysql_flows.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mysql_flows.py#L1437-L1463
def WriteFlowOutputPluginLogEntries(self, entries, cursor=None): """Writes flow output plugin log entries for a given flow.""" query = ("INSERT INTO flow_output_plugin_log_entries " "(client_id, flow_id, hunt_id, output_plugin_id, " "log_entry_type, message) " "VALUES ") ...
[ "def", "WriteFlowOutputPluginLogEntries", "(", "self", ",", "entries", ",", "cursor", "=", "None", ")", ":", "query", "=", "(", "\"INSERT INTO flow_output_plugin_log_entries \"", "\"(client_id, flow_id, hunt_id, output_plugin_id, \"", "\"log_entry_type, message) \"", "\"VALUES \"...
Writes flow output plugin log entries for a given flow.
[ "Writes", "flow", "output", "plugin", "log", "entries", "for", "a", "given", "flow", "." ]
python
train
UCL-INGI/INGInious
inginious/frontend/parsable_text.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/parsable_text.py#L168-L171
def html(cls, string, show_everything=False, translation=gettext.NullTranslations()): # pylint: disable=unused-argument """Parses HTML""" out, _ = tidylib.tidy_fragment(string) return out
[ "def", "html", "(", "cls", ",", "string", ",", "show_everything", "=", "False", ",", "translation", "=", "gettext", ".", "NullTranslations", "(", ")", ")", ":", "# pylint: disable=unused-argument", "out", ",", "_", "=", "tidylib", ".", "tidy_fragment", "(", ...
Parses HTML
[ "Parses", "HTML" ]
python
train
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1272-L1286
def getPeers(self): ''' getPeers - Get elements who share a parent with this element @return - TagCollection of elements ''' parentNode = self.parentNode # If no parent, no peers if not parentNode: return None peers = parentNode.child...
[ "def", "getPeers", "(", "self", ")", ":", "parentNode", "=", "self", ".", "parentNode", "# If no parent, no peers", "if", "not", "parentNode", ":", "return", "None", "peers", "=", "parentNode", ".", "children", "# Otherwise, get all children of parent excluding this nod...
getPeers - Get elements who share a parent with this element @return - TagCollection of elements
[ "getPeers", "-", "Get", "elements", "who", "share", "a", "parent", "with", "this", "element" ]
python
train
nion-software/nionswift
nion/swift/model/NDataHandler.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/NDataHandler.py#L444-L467
def write_properties(self, properties, file_datetime): """ Write properties to the ndata file specified by reference. :param reference: the reference to which to write :param properties: the dict to write to the file :param file_datetime: the datetime for the fil...
[ "def", "write_properties", "(", "self", ",", "properties", ",", "file_datetime", ")", ":", "with", "self", ".", "__lock", ":", "absolute_file_path", "=", "self", ".", "__file_path", "#logging.debug(\"WRITE properties %s for %s\", absolute_file_path, key)", "make_directory_i...
Write properties to the ndata file specified by reference. :param reference: the reference to which to write :param properties: the dict to write to the file :param file_datetime: the datetime for the file The properties param must not change during this method. Callers...
[ "Write", "properties", "to", "the", "ndata", "file", "specified", "by", "reference", "." ]
python
train
jkenlooper/chill
src/chill/api.py
https://github.com/jkenlooper/chill/blob/35360c17c2a3b769ecb5406c6dabcf4cc70bd76f/src/chill/api.py#L53-L97
def _query(_node_id, value=None, **kw): "Look up value by using Query table" query_result = [] try: query_result = db.execute(text(fetch_query_string('select_query_from_node.sql')), **kw).fetchall() except DatabaseError as err: current_app.logger.error("DatabaseError: %s, %s", err, kw) ...
[ "def", "_query", "(", "_node_id", ",", "value", "=", "None", ",", "*", "*", "kw", ")", ":", "query_result", "=", "[", "]", "try", ":", "query_result", "=", "db", ".", "execute", "(", "text", "(", "fetch_query_string", "(", "'select_query_from_node.sql'", ...
Look up value by using Query table
[ "Look", "up", "value", "by", "using", "Query", "table" ]
python
train
TheHive-Project/Cortex-Analyzers
analyzers/MaxMind/ipaddr.py
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/MaxMind/ipaddr.py#L648-L651
def overlaps(self, other): """Tell if self is partly contained in other.""" return self.network in other or self.broadcast in other or ( other.network in self or other.broadcast in self)
[ "def", "overlaps", "(", "self", ",", "other", ")", ":", "return", "self", ".", "network", "in", "other", "or", "self", ".", "broadcast", "in", "other", "or", "(", "other", ".", "network", "in", "self", "or", "other", ".", "broadcast", "in", "self", "...
Tell if self is partly contained in other.
[ "Tell", "if", "self", "is", "partly", "contained", "in", "other", "." ]
python
train
phoebe-project/phoebe2
phoebe/parameters/parameters.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/parameters/parameters.py#L3882-L3894
def expand_value(self, **kwargs): """ expand the selection to account for wildcards """ selection = [] for v in self.get_value(**kwargs): for choice in self.choices: if v==choice and choice not in selection: selection.append(choice)...
[ "def", "expand_value", "(", "self", ",", "*", "*", "kwargs", ")", ":", "selection", "=", "[", "]", "for", "v", "in", "self", ".", "get_value", "(", "*", "*", "kwargs", ")", ":", "for", "choice", "in", "self", ".", "choices", ":", "if", "v", "==",...
expand the selection to account for wildcards
[ "expand", "the", "selection", "to", "account", "for", "wildcards" ]
python
train
PMEAL/OpenPNM
openpnm/topotools/topotools.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/topotools/topotools.py#L1947-L2032
def plot_coordinates(network, pores=None, fig=None, **kwargs): r""" Produces a 3D plot showing specified pore coordinates as markers Parameters ---------- network : OpenPNM Network Object The network whose topological connections to plot pores : array_like (optional) The list o...
[ "def", "plot_coordinates", "(", "network", ",", "pores", "=", "None", ",", "fig", "=", "None", ",", "*", "*", "kwargs", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "from", "mpl_toolkits", ".", "mplot3d", "import", "Axes3D", "if", "pores...
r""" Produces a 3D plot showing specified pore coordinates as markers Parameters ---------- network : OpenPNM Network Object The network whose topological connections to plot pores : array_like (optional) The list of pores to plot if only a sub-sample is desired. This is u...
[ "r", "Produces", "a", "3D", "plot", "showing", "specified", "pore", "coordinates", "as", "markers" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py#L656-L674
def ip_rtm_config_route_static_route_oif_vrf_static_route_next_vrf_dest(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") ip = ET.SubElement(config, "ip", xmlns="urn:brocade.com:mgmt:brocade-common-def") rtm_config = ET.SubElement(ip, "rtm-config", xmlns="...
[ "def", "ip_rtm_config_route_static_route_oif_vrf_static_route_next_vrf_dest", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "ip", "=", "ET", ".", "SubElement", "(", "config", ",", "\"ip\"", ",", "x...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
citruz/beacontools
beacontools/parser.py
https://github.com/citruz/beacontools/blob/15a83e9750d0a4393f8a36868e07f6d9458253fe/beacontools/parser.py#L14-L19
def parse_packet(packet): """Parse a beacon advertisement packet.""" frame = parse_ltv_packet(packet) if frame is None: frame = parse_ibeacon_packet(packet) return frame
[ "def", "parse_packet", "(", "packet", ")", ":", "frame", "=", "parse_ltv_packet", "(", "packet", ")", "if", "frame", "is", "None", ":", "frame", "=", "parse_ibeacon_packet", "(", "packet", ")", "return", "frame" ]
Parse a beacon advertisement packet.
[ "Parse", "a", "beacon", "advertisement", "packet", "." ]
python
train
barryp/py-amqplib
amqplib/client_0_8/channel.py
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/channel.py#L2063-L2120
def basic_get(self, queue='', no_ack=False, ticket=None): """ direct access to a queue This method provides a direct access to the messages in a queue using a synchronous dialogue that is designed for specific types of application where synchronous functionality is more ...
[ "def", "basic_get", "(", "self", ",", "queue", "=", "''", ",", "no_ack", "=", "False", ",", "ticket", "=", "None", ")", ":", "args", "=", "AMQPWriter", "(", ")", "if", "ticket", "is", "not", "None", ":", "args", ".", "write_short", "(", "ticket", "...
direct access to a queue This method provides a direct access to the messages in a queue using a synchronous dialogue that is designed for specific types of application where synchronous functionality is more important than performance. PARAMETERS: queue: shortstr ...
[ "direct", "access", "to", "a", "queue" ]
python
train
lsst-epo/vela
astropixie-widgets/astropixie_widgets/science.py
https://github.com/lsst-epo/vela/blob/8e17ebec509be5c3cc2063f4645dfe9e26b49c18/astropixie-widgets/astropixie_widgets/science.py#L24-L41
def teff(cluster): """ Calculate Teff for main sequence stars ranging from Teff 3500K - 8000K. Use [Fe/H] of the cluster, if available. Returns a list of Teff values. """ b_vs, _ = cluster.stars() teffs = [] for b_v in b_vs: b_v -= cluster.eb_v if b_v > -0.04: ...
[ "def", "teff", "(", "cluster", ")", ":", "b_vs", ",", "_", "=", "cluster", ".", "stars", "(", ")", "teffs", "=", "[", "]", "for", "b_v", "in", "b_vs", ":", "b_v", "-=", "cluster", ".", "eb_v", "if", "b_v", ">", "-", "0.04", ":", "x", "=", "("...
Calculate Teff for main sequence stars ranging from Teff 3500K - 8000K. Use [Fe/H] of the cluster, if available. Returns a list of Teff values.
[ "Calculate", "Teff", "for", "main", "sequence", "stars", "ranging", "from", "Teff", "3500K", "-", "8000K", ".", "Use", "[", "Fe", "/", "H", "]", "of", "the", "cluster", "if", "available", "." ]
python
valid
DataONEorg/d1_python
client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/drivers/dokan/solrclient.py#L370-L377
def addDocs(self, docs): """docs is a list of fields that are a dictionary of name:value for a record.""" lst = ['<add>'] for fields in docs: self.__add(lst, fields) lst.append('</add>') xstr = ''.join(lst) return self.doUpdateXML(xstr)
[ "def", "addDocs", "(", "self", ",", "docs", ")", ":", "lst", "=", "[", "'<add>'", "]", "for", "fields", "in", "docs", ":", "self", ".", "__add", "(", "lst", ",", "fields", ")", "lst", ".", "append", "(", "'</add>'", ")", "xstr", "=", "''", ".", ...
docs is a list of fields that are a dictionary of name:value for a record.
[ "docs", "is", "a", "list", "of", "fields", "that", "are", "a", "dictionary", "of", "name", ":", "value", "for", "a", "record", "." ]
python
train
pysathq/pysat
pysat/solvers.py
https://github.com/pysathq/pysat/blob/522742e8f2d4c6ac50ecd9087f7a346206774c67/pysat/solvers.py#L2595-L2607
def add_clause(self, clause, no_return=True): """ Add a new clause to solver's internal formula. """ if self.maplesat: res = pysolvers.maplesat_add_cl(self.maplesat, clause) if res == False: self.status = False if not no_return: ...
[ "def", "add_clause", "(", "self", ",", "clause", ",", "no_return", "=", "True", ")", ":", "if", "self", ".", "maplesat", ":", "res", "=", "pysolvers", ".", "maplesat_add_cl", "(", "self", ".", "maplesat", ",", "clause", ")", "if", "res", "==", "False",...
Add a new clause to solver's internal formula.
[ "Add", "a", "new", "clause", "to", "solver", "s", "internal", "formula", "." ]
python
train
archman/beamline
beamline/simulation.py
https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/simulation.py#L92-L111
def _getOutputElegant(self, **kws): """ get results from elegant output according to the given keywords, input parameter format: key = sdds field name tuple, e.g.: available keywords are: - 'file': sdds fielname, file = test.sig - 'data': data array, data = (...
[ "def", "_getOutputElegant", "(", "self", ",", "*", "*", "kws", ")", ":", "datascript", "=", "\"sddsprintdata.sh\"", "datapath", "=", "self", ".", "sim_path", "trajparam_list", "=", "kws", "[", "'data'", "]", "sddsfile", "=", "os", ".", "path", ".", "expand...
get results from elegant output according to the given keywords, input parameter format: key = sdds field name tuple, e.g.: available keywords are: - 'file': sdds fielname, file = test.sig - 'data': data array, data = ('s','Sx') - 'dump': h5file name, if...
[ "get", "results", "from", "elegant", "output", "according", "to", "the", "given", "keywords", "input", "parameter", "format", ":", "key", "=", "sdds", "field", "name", "tuple", "e", ".", "g", ".", ":", "available", "keywords", "are", ":", "-", "file", ":...
python
train
konstantint/matplotlib-venn
matplotlib_venn/_arc.py
https://github.com/konstantint/matplotlib-venn/blob/c26796c9925bdac512edf48387452fbd1848c791/matplotlib_venn/_arc.py#L474-L483
def lies_on_circle(self, center, radius): '''Tests whether the arc circle's center and radius match the given ones within <tol> tolerance. >>> a = Arc((0, 0), 1, 0, 0, False) >>> a.lies_on_circle((tol/2, tol/2), 1+tol/2) True >>> a.lies_on_circle((tol/2, tol/2), 1-tol) ...
[ "def", "lies_on_circle", "(", "self", ",", "center", ",", "radius", ")", ":", "return", "np", ".", "all", "(", "abs", "(", "np", ".", "asarray", "(", "center", ")", "-", "self", ".", "center", ")", "<", "tol", ")", "and", "abs", "(", "radius", "-...
Tests whether the arc circle's center and radius match the given ones within <tol> tolerance. >>> a = Arc((0, 0), 1, 0, 0, False) >>> a.lies_on_circle((tol/2, tol/2), 1+tol/2) True >>> a.lies_on_circle((tol/2, tol/2), 1-tol) False
[ "Tests", "whether", "the", "arc", "circle", "s", "center", "and", "radius", "match", "the", "given", "ones", "within", "<tol", ">", "tolerance", ".", ">>>", "a", "=", "Arc", "((", "0", "0", ")", "1", "0", "0", "False", ")", ">>>", "a", ".", "lies_o...
python
train
ejeschke/ginga
ginga/util/heaptimer.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/util/heaptimer.py#L201-L207
def _remove(self, timer): """Remove timer from heap lock and presence are assumed""" assert timer.timer_heap == self del self.timers[timer] assert timer in self.heap self.heap.remove(timer) heapq.heapify(self.heap)
[ "def", "_remove", "(", "self", ",", "timer", ")", ":", "assert", "timer", ".", "timer_heap", "==", "self", "del", "self", ".", "timers", "[", "timer", "]", "assert", "timer", "in", "self", ".", "heap", "self", ".", "heap", ".", "remove", "(", "timer"...
Remove timer from heap lock and presence are assumed
[ "Remove", "timer", "from", "heap", "lock", "and", "presence", "are", "assumed" ]
python
train
datosgobar/pydatajson
pydatajson/documentation.py
https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/documentation.py#L85-L107
def field_to_markdown(field): """Genera texto en markdown a partir de los metadatos de un `field`. Args: field (dict): Diccionario con metadatos de un `field`. Returns: str: Texto que describe un `field`. """ if "title" in field: field_title = "**{}**".format(field["title"]...
[ "def", "field_to_markdown", "(", "field", ")", ":", "if", "\"title\"", "in", "field", ":", "field_title", "=", "\"**{}**\"", ".", "format", "(", "field", "[", "\"title\"", "]", ")", "else", ":", "raise", "Exception", "(", "\"Es necesario un `title` para describi...
Genera texto en markdown a partir de los metadatos de un `field`. Args: field (dict): Diccionario con metadatos de un `field`. Returns: str: Texto que describe un `field`.
[ "Genera", "texto", "en", "markdown", "a", "partir", "de", "los", "metadatos", "de", "un", "field", "." ]
python
train
SheffieldML/GPy
GPy/core/parameterization/priorizable.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/core/parameterization/priorizable.py#L49-L65
def log_prior(self): """evaluate the prior""" if self.priors.size == 0: return 0. x = self.param_array #evaluate the prior log densities log_p = reduce(lambda a, b: a + b, (p.lnpdf(x[ind]).sum() for p, ind in self.priors.items()), 0) #account for the transfor...
[ "def", "log_prior", "(", "self", ")", ":", "if", "self", ".", "priors", ".", "size", "==", "0", ":", "return", "0.", "x", "=", "self", ".", "param_array", "#evaluate the prior log densities", "log_p", "=", "reduce", "(", "lambda", "a", ",", "b", ":", "...
evaluate the prior
[ "evaluate", "the", "prior" ]
python
train
wuher/devil
devil/resource.py
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L316-L334
def _create_object(self, data, request): """ Create a python object from the given data. This will use ``self.factory`` object's ``create()`` function to create the data. If no factory is defined, this will simply return the same data that was given. """ if req...
[ "def", "_create_object", "(", "self", ",", "data", ",", "request", ")", ":", "if", "request", ".", "method", ".", "upper", "(", ")", "==", "'POST'", "and", "self", ".", "post_factory", ":", "fac_func", "=", "self", ".", "post_factory", ".", "create", "...
Create a python object from the given data. This will use ``self.factory`` object's ``create()`` function to create the data. If no factory is defined, this will simply return the same data that was given.
[ "Create", "a", "python", "object", "from", "the", "given", "data", "." ]
python
train
msiemens/PyGitUp
PyGitUp/gitup.py
https://github.com/msiemens/PyGitUp/blob/b1f78831cb6b8d29d3a7d59f7a2b54fdd0720e9c/PyGitUp/gitup.py#L628-L656
def run(version, quiet, no_fetch, push, **kwargs): # pragma: no cover """ A nicer `git pull`. """ if version: if NO_DISTRIBUTE: print(colored('Please install \'git-up\' via pip in order to ' 'get version information.', 'yellow')) else: ...
[ "def", "run", "(", "version", ",", "quiet", ",", "no_fetch", ",", "push", ",", "*", "*", "kwargs", ")", ":", "# pragma: no cover\r", "if", "version", ":", "if", "NO_DISTRIBUTE", ":", "print", "(", "colored", "(", "'Please install \\'git-up\\' via pip in order to...
A nicer `git pull`.
[ "A", "nicer", "git", "pull", "." ]
python
train
sdispater/orator
orator/orm/relations/has_one_or_many.py
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/has_one_or_many.py#L78-L113
def _match_one_or_many(self, models, results, relation, type_): """ Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The rel...
[ "def", "_match_one_or_many", "(", "self", ",", "models", ",", "results", ",", "relation", ",", "type_", ")", ":", "dictionary", "=", "self", ".", "_build_dictionary", "(", "results", ")", "for", "model", "in", "models", ":", "key", "=", "model", ".", "ge...
Match the eargerly loaded resuls to their single parents. :param models: The parents :type models: list :param results: The results collection :type results: Collection :param relation: The relation :type relation: str :param type_: The match type :typ...
[ "Match", "the", "eargerly", "loaded", "resuls", "to", "their", "single", "parents", "." ]
python
train
nimbis/cmsplugin-newsplus
cmsplugin_newsplus/admin.py
https://github.com/nimbis/cmsplugin-newsplus/blob/1787fb674faa7800845f18ce782154e290f6be27/cmsplugin_newsplus/admin.py#L49-L57
def make_unpublished(self, request, queryset): """ Marks selected news items as unpublished """ rows_updated = queryset.update(is_published=False) self.message_user(request, ungettext('%(count)d newsitem was unpublished', ...
[ "def", "make_unpublished", "(", "self", ",", "request", ",", "queryset", ")", ":", "rows_updated", "=", "queryset", ".", "update", "(", "is_published", "=", "False", ")", "self", ".", "message_user", "(", "request", ",", "ungettext", "(", "'%(count)d newsitem ...
Marks selected news items as unpublished
[ "Marks", "selected", "news", "items", "as", "unpublished" ]
python
train
victorlei/smop
smop/parse.py
https://github.com/victorlei/smop/blob/bdad96b715d1dd75ce8ab4724f76b9b1bb1f61cd/smop/parse.py#L464-L466
def p_expr_string(p): "string : STRING" p[0] = node.string(p[1], lineno=p.lineno(1), lexpos=p.lexpos(1))
[ "def", "p_expr_string", "(", "p", ")", ":", "p", "[", "0", "]", "=", "node", ".", "string", "(", "p", "[", "1", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ",", "lexpos", "=", "p", ".", "lexpos", "(", "1", ")", ")" ]
string : STRING
[ "string", ":", "STRING" ]
python
train
FNNDSC/pfmisc
pfmisc/C_snode.py
https://github.com/FNNDSC/pfmisc/blob/960b4d6135fcc50bed0a8e55db2ab1ddad9b99d8/pfmisc/C_snode.py#L381-L386
def node_branch(self, astr_node, abranch): """ Adds a branch to a node, i.e. depth addition. The given node's md_nodes is set to the abranch's mdict_branch. """ self.dict_branch[astr_node].node_dictBranch(abranch.dict_branch)
[ "def", "node_branch", "(", "self", ",", "astr_node", ",", "abranch", ")", ":", "self", ".", "dict_branch", "[", "astr_node", "]", ".", "node_dictBranch", "(", "abranch", ".", "dict_branch", ")" ]
Adds a branch to a node, i.e. depth addition. The given node's md_nodes is set to the abranch's mdict_branch.
[ "Adds", "a", "branch", "to", "a", "node", "i", ".", "e", ".", "depth", "addition", ".", "The", "given", "node", "s", "md_nodes", "is", "set", "to", "the", "abranch", "s", "mdict_branch", "." ]
python
train
the01/python-paps
paps/si/app/sensorClient.py
https://github.com/the01/python-paps/blob/2dde5a71913e4c7b22901cf05c6ecedd890919c4/paps/si/app/sensorClient.py#L244-L256
def stop(self): """ Stop the interface :rtype: None """ self.debug("()") try: self.unjoin() time.sleep(2) except: self.exception("Failed to leave audience") super(SensorClient, self).stop()
[ "def", "stop", "(", "self", ")", ":", "self", ".", "debug", "(", "\"()\"", ")", "try", ":", "self", ".", "unjoin", "(", ")", "time", ".", "sleep", "(", "2", ")", "except", ":", "self", ".", "exception", "(", "\"Failed to leave audience\"", ")", "supe...
Stop the interface :rtype: None
[ "Stop", "the", "interface" ]
python
train
lk-geimfari/mimesis
mimesis/providers/address.py
https://github.com/lk-geimfari/mimesis/blob/4b16ee7a8dba6281a904654a88dbb4b052869fc5/mimesis/providers/address.py#L205-L219
def _get_fs(self, key: str, dms: bool = False) -> Union[str, float]: """Get float number. :param key: Key (`lt` or `lg`). :param dms: DMS format. :return: Float number """ # Default range is a range of longitude. rng = (-90, 90) if key == 'lt' else (-180, 180) ...
[ "def", "_get_fs", "(", "self", ",", "key", ":", "str", ",", "dms", ":", "bool", "=", "False", ")", "->", "Union", "[", "str", ",", "float", "]", ":", "# Default range is a range of longitude.", "rng", "=", "(", "-", "90", ",", "90", ")", "if", "key",...
Get float number. :param key: Key (`lt` or `lg`). :param dms: DMS format. :return: Float number
[ "Get", "float", "number", "." ]
python
train
jaredLunde/redis_structures
redis_structures/__init__.py
https://github.com/jaredLunde/redis_structures/blob/b9cce5f5c85db5e12c292633ff8d04e3ae053294/redis_structures/__init__.py#L1706-L1715
def union(self, *others): """ Calculates union between sets @others: one or several :class:RedisSet objects or #str redis set keynames -> #set of new set members """ others = self._typesafe_others(others) return set(map( self._loads, s...
[ "def", "union", "(", "self", ",", "*", "others", ")", ":", "others", "=", "self", ".", "_typesafe_others", "(", "others", ")", "return", "set", "(", "map", "(", "self", ".", "_loads", ",", "self", ".", "_client", ".", "sunion", "(", "self", ".", "k...
Calculates union between sets @others: one or several :class:RedisSet objects or #str redis set keynames -> #set of new set members
[ "Calculates", "union", "between", "sets", "@others", ":", "one", "or", "several", ":", "class", ":", "RedisSet", "objects", "or", "#str", "redis", "set", "keynames" ]
python
train
kappius/pyheaderfile
pyheaderfile/excel.py
https://github.com/kappius/pyheaderfile/blob/8d587dadae538adcec527fd8e74ad89ed5e2006a/pyheaderfile/excel.py#L56-L65
def write_cell(self, x, y, value, style=None): """ writing style and value in the cell of x and y position """ if isinstance(style, str): style = self.xlwt.easyxf(style) if style: self._sheet.write(x, y, label=value, style=style) else: ...
[ "def", "write_cell", "(", "self", ",", "x", ",", "y", ",", "value", ",", "style", "=", "None", ")", ":", "if", "isinstance", "(", "style", ",", "str", ")", ":", "style", "=", "self", ".", "xlwt", ".", "easyxf", "(", "style", ")", "if", "style", ...
writing style and value in the cell of x and y position
[ "writing", "style", "and", "value", "in", "the", "cell", "of", "x", "and", "y", "position" ]
python
train
3DLIRIOUS/MeshLabXML
meshlabxml/transform.py
https://github.com/3DLIRIOUS/MeshLabXML/blob/177cce21e92baca500f56a932d66bd9a33257af8/meshlabxml/transform.py#L363-L413
def function(script, x_func='x', y_func='y', z_func='z'): """Geometric function using muparser lib to generate new Coordinates You can change x, y, z for every vertex according to the function specified. See help(mlx.muparser_ref) for muparser reference documentation. It's possible to use the followin...
[ "def", "function", "(", "script", ",", "x_func", "=", "'x'", ",", "y_func", "=", "'y'", ",", "z_func", "=", "'z'", ")", ":", "filter_xml", "=", "''", ".", "join", "(", "[", "' <filter name=\"Geometric Function\">\\n'", ",", "' <Param name=\"x\" '", ",", ...
Geometric function using muparser lib to generate new Coordinates You can change x, y, z for every vertex according to the function specified. See help(mlx.muparser_ref) for muparser reference documentation. It's possible to use the following per-vertex variables in the expression: Variables (per ver...
[ "Geometric", "function", "using", "muparser", "lib", "to", "generate", "new", "Coordinates" ]
python
test
poppy-project/pypot
pypot/vrep/remoteApiBindings/vrep.py
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/remoteApiBindings/vrep.py#L875-L888
def simxGetObjectSelection(clientID, operationMode): ''' Please have a look at the function description/documentation in the V-REP user manual ''' objectCount = ct.c_int() objectHandles = ct.POINTER(ct.c_int)() ret = c_GetObjectSelection(clientID, ct.byref(objectHandles), ct.byref(objectCount)...
[ "def", "simxGetObjectSelection", "(", "clientID", ",", "operationMode", ")", ":", "objectCount", "=", "ct", ".", "c_int", "(", ")", "objectHandles", "=", "ct", ".", "POINTER", "(", "ct", ".", "c_int", ")", "(", ")", "ret", "=", "c_GetObjectSelection", "(",...
Please have a look at the function description/documentation in the V-REP user manual
[ "Please", "have", "a", "look", "at", "the", "function", "description", "/", "documentation", "in", "the", "V", "-", "REP", "user", "manual" ]
python
train
JoelBender/bacpypes
py25/bacpypes/appservice.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py25/bacpypes/appservice.py#L760-L856
def confirmation(self, apdu): """This function is called when the application has provided a response and needs it to be sent to the client.""" if _debug: ServerSSM._debug("confirmation %r", apdu) # check to see we are in the correct state if self.state != AWAIT_RESPONSE: ...
[ "def", "confirmation", "(", "self", ",", "apdu", ")", ":", "if", "_debug", ":", "ServerSSM", ".", "_debug", "(", "\"confirmation %r\"", ",", "apdu", ")", "# check to see we are in the correct state", "if", "self", ".", "state", "!=", "AWAIT_RESPONSE", ":", "if",...
This function is called when the application has provided a response and needs it to be sent to the client.
[ "This", "function", "is", "called", "when", "the", "application", "has", "provided", "a", "response", "and", "needs", "it", "to", "be", "sent", "to", "the", "client", "." ]
python
train
amyth/django-instapush
instapush/models/base.py
https://github.com/amyth/django-instapush/blob/f8643a2e342fc73a16c95dff79c3daac8ce4b034/instapush/models/base.py#L63-L74
def send_message(self, message, **kwargs): """ Sends a push notification to this device via GCM """ from ..libs.gcm import gcm_send_message data = kwargs.pop("extra", {}) if message is not None: data["message"] = message return gcm_send_message(regis...
[ "def", "send_message", "(", "self", ",", "message", ",", "*", "*", "kwargs", ")", ":", "from", ".", ".", "libs", ".", "gcm", "import", "gcm_send_message", "data", "=", "kwargs", ".", "pop", "(", "\"extra\"", ",", "{", "}", ")", "if", "message", "is",...
Sends a push notification to this device via GCM
[ "Sends", "a", "push", "notification", "to", "this", "device", "via", "GCM" ]
python
test
open511/open511
open511/converter/o5xml.py
https://github.com/open511/open511/blob/3d573f59d7efa06ff1b5419ea5ff4d90a90b3cf8/open511/converter/o5xml.py#L43-L91
def json_struct_to_xml(json_obj, root, custom_namespace=None): """Converts a Open511 JSON fragment to XML. Takes a dict deserialized from JSON, returns an lxml Element. This won't provide a conforming document if you pass in a full JSON document; it's for translating little fragments, and is mostly us...
[ "def", "json_struct_to_xml", "(", "json_obj", ",", "root", ",", "custom_namespace", "=", "None", ")", ":", "if", "isinstance", "(", "root", ",", "(", "str", ",", "unicode", ")", ")", ":", "if", "root", ".", "startswith", "(", "'!'", ")", ":", "root", ...
Converts a Open511 JSON fragment to XML. Takes a dict deserialized from JSON, returns an lxml Element. This won't provide a conforming document if you pass in a full JSON document; it's for translating little fragments, and is mostly used internally.
[ "Converts", "a", "Open511", "JSON", "fragment", "to", "XML", "." ]
python
valid
csparpa/pyowm
pyowm/utils/timeformatutils.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/utils/timeformatutils.py#L50-L76
def to_date(timeobject): """ Returns the ``datetime.datetime`` object corresponding to the time value conveyed by the specified object, which can be either a UNIXtime, a ``datetime.datetime`` object or an ISO8601-formatted string in the format `YYYY-MM-DD HH:MM:SS+00``. :param timeobject: the o...
[ "def", "to_date", "(", "timeobject", ")", ":", "if", "isinstance", "(", "timeobject", ",", "int", ")", ":", "if", "timeobject", "<", "0", ":", "raise", "ValueError", "(", "\"The time value is a negative number\"", ")", "return", "datetime", ".", "utcfromtimestam...
Returns the ``datetime.datetime`` object corresponding to the time value conveyed by the specified object, which can be either a UNIXtime, a ``datetime.datetime`` object or an ISO8601-formatted string in the format `YYYY-MM-DD HH:MM:SS+00``. :param timeobject: the object conveying the time value :t...
[ "Returns", "the", "datetime", ".", "datetime", "object", "corresponding", "to", "the", "time", "value", "conveyed", "by", "the", "specified", "object", "which", "can", "be", "either", "a", "UNIXtime", "a", "datetime", ".", "datetime", "object", "or", "an", "...
python
train
glormph/msstitch
src/app/drivers/prottable/fdr.py
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/prottable/fdr.py#L32-L36
def prepare(self): """No percolator XML for protein tables""" self.target = self.fn self.targetheader = reader.get_tsv_header(self.target) self.decoyheader = reader.get_tsv_header(self.decoyfn)
[ "def", "prepare", "(", "self", ")", ":", "self", ".", "target", "=", "self", ".", "fn", "self", ".", "targetheader", "=", "reader", ".", "get_tsv_header", "(", "self", ".", "target", ")", "self", ".", "decoyheader", "=", "reader", ".", "get_tsv_header", ...
No percolator XML for protein tables
[ "No", "percolator", "XML", "for", "protein", "tables" ]
python
train
kurtbrose/pyjks
jks/jks.py
https://github.com/kurtbrose/pyjks/blob/1cbe7f060e2ad076b6462f3273f11d635771ea3d/jks/jks.py#L730-L739
def _java_is_subclass(cls, obj, class_name): """Given a deserialized JavaObject as returned by the javaobj library, determine whether it's a subclass of the given class name. """ clazz = obj.get_class() while clazz: if clazz.name == class_name: return ...
[ "def", "_java_is_subclass", "(", "cls", ",", "obj", ",", "class_name", ")", ":", "clazz", "=", "obj", ".", "get_class", "(", ")", "while", "clazz", ":", "if", "clazz", ".", "name", "==", "class_name", ":", "return", "True", "clazz", "=", "clazz", ".", ...
Given a deserialized JavaObject as returned by the javaobj library, determine whether it's a subclass of the given class name.
[ "Given", "a", "deserialized", "JavaObject", "as", "returned", "by", "the", "javaobj", "library", "determine", "whether", "it", "s", "a", "subclass", "of", "the", "given", "class", "name", "." ]
python
train
CTPUG/wafer
wafer/compare/admin.py
https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/compare/admin.py#L129-L154
def compare_view(self, request, object_id, version_id, extra_context=None): """Actually compare two versions.""" opts = self.model._meta object_id = unquote(object_id) # get_for_object's ordering means this is always the latest revision. # The reversion we want to compare to ...
[ "def", "compare_view", "(", "self", ",", "request", ",", "object_id", ",", "version_id", ",", "extra_context", "=", "None", ")", ":", "opts", "=", "self", ".", "model", ".", "_meta", "object_id", "=", "unquote", "(", "object_id", ")", "# get_for_object's ord...
Actually compare two versions.
[ "Actually", "compare", "two", "versions", "." ]
python
train
kristianfoerster/melodist
melodist/station.py
https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/station.py#L298-L338
def disaggregate_precipitation(self, method='equal', zerodiv='uniform', shift=0, master_precip=None): """ Disaggregate precipitation. Parameters ---------- method : str, optional Disaggregation method. ``equal`` Daily precipitation is dis...
[ "def", "disaggregate_precipitation", "(", "self", ",", "method", "=", "'equal'", ",", "zerodiv", "=", "'uniform'", ",", "shift", "=", "0", ",", "master_precip", "=", "None", ")", ":", "if", "method", "==", "'equal'", ":", "precip_disagg", "=", "melodist", ...
Disaggregate precipitation. Parameters ---------- method : str, optional Disaggregation method. ``equal`` Daily precipitation is distributed equally over the 24 hours of the day. (Default) ``cascade`` Hourly precipitation val...
[ "Disaggregate", "precipitation", "." ]
python
train
etscrivner/nose-perfdump
perfdump/html.py
https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/html.py#L36-L81
def write(cls, html_file): """Writes the HTML report to the given file.""" f = open(html_file, 'w') f.write('<html>') f.write('<head>') f.write('</head>') f.write('<body>') f.write('<h1>Test times</h1>') fmt_test = '<tr><td>{:.05f}</td><td>{}</td>...
[ "def", "write", "(", "cls", ",", "html_file", ")", ":", "f", "=", "open", "(", "html_file", ",", "'w'", ")", "f", ".", "write", "(", "'<html>'", ")", "f", ".", "write", "(", "'<head>'", ")", "f", ".", "write", "(", "'</head>'", ")", "f", ".", "...
Writes the HTML report to the given file.
[ "Writes", "the", "HTML", "report", "to", "the", "given", "file", "." ]
python
train
galaxyproject/pulsar
pulsar/util/__init__.py
https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/pulsar/util/__init__.py#L27-L34
def copy_to_temp(object): """ Copy file-like object to temp file and return path. """ temp_file = NamedTemporaryFile(delete=False) _copy_and_close(object, temp_file) return temp_file.name
[ "def", "copy_to_temp", "(", "object", ")", ":", "temp_file", "=", "NamedTemporaryFile", "(", "delete", "=", "False", ")", "_copy_and_close", "(", "object", ",", "temp_file", ")", "return", "temp_file", ".", "name" ]
Copy file-like object to temp file and return path.
[ "Copy", "file", "-", "like", "object", "to", "temp", "file", "and", "return", "path", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/well_known_types.py#L352-L355
def FromTimedelta(self, td): """Convertd timedelta to Duration.""" self._NormalizeDuration(td.seconds + td.days * _SECONDS_PER_DAY, td.microseconds * _NANOS_PER_MICROSECOND)
[ "def", "FromTimedelta", "(", "self", ",", "td", ")", ":", "self", ".", "_NormalizeDuration", "(", "td", ".", "seconds", "+", "td", ".", "days", "*", "_SECONDS_PER_DAY", ",", "td", ".", "microseconds", "*", "_NANOS_PER_MICROSECOND", ")" ]
Convertd timedelta to Duration.
[ "Convertd", "timedelta", "to", "Duration", "." ]
python
train
spacetelescope/drizzlepac
drizzlepac/imageObject.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/imageObject.py#L288-L317
def _findExtnames(self, extname=None, exclude=None): """ This method builds a list of all extensions which have 'EXTNAME'==extname and do not include any extensions with 'EXTNAME'==exclude, if any are specified for exclusion at all. """ #make a list of the available exten...
[ "def", "_findExtnames", "(", "self", ",", "extname", "=", "None", ",", "exclude", "=", "None", ")", ":", "#make a list of the available extension names for the object", "extensions", "=", "[", "]", "if", "extname", "is", "not", "None", ":", "if", "not", "isinsta...
This method builds a list of all extensions which have 'EXTNAME'==extname and do not include any extensions with 'EXTNAME'==exclude, if any are specified for exclusion at all.
[ "This", "method", "builds", "a", "list", "of", "all", "extensions", "which", "have", "EXTNAME", "==", "extname", "and", "do", "not", "include", "any", "extensions", "with", "EXTNAME", "==", "exclude", "if", "any", "are", "specified", "for", "exclusion", "at"...
python
train
Dentosal/python-sc2
sc2/client.py
https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/client.py#L281-L307
async def debug_create_unit(self, unit_spawn_commands: List[List[Union[UnitTypeId, int, Point2, Point3]]]): """ Usage example (will spawn 1 marine in the center of the map for player ID 1): await self._client.debug_create_unit([[UnitTypeId.MARINE, 1, self._game_info.map_center, 1]]) """ assert i...
[ "async", "def", "debug_create_unit", "(", "self", ",", "unit_spawn_commands", ":", "List", "[", "List", "[", "Union", "[", "UnitTypeId", ",", "int", ",", "Point2", ",", "Point3", "]", "]", "]", ")", ":", "assert", "isinstance", "(", "unit_spawn_commands", ...
Usage example (will spawn 1 marine in the center of the map for player ID 1): await self._client.debug_create_unit([[UnitTypeId.MARINE, 1, self._game_info.map_center, 1]])
[ "Usage", "example", "(", "will", "spawn", "1", "marine", "in", "the", "center", "of", "the", "map", "for", "player", "ID", "1", ")", ":", "await", "self", ".", "_client", ".", "debug_create_unit", "(", "[[", "UnitTypeId", ".", "MARINE", "1", "self", "....
python
train
bethgelab/foolbox
foolbox/utils.py
https://github.com/bethgelab/foolbox/blob/8ab54248c70e45d8580a7d9ee44c9c0fb5755c4a/foolbox/utils.py#L89-L117
def binarize(x, values, threshold=None, included_in='upper'): """Binarizes the values of x. Parameters ---------- values : tuple of two floats The lower and upper value to which the inputs are mapped. threshold : float The threshold; defaults to (values[0] + values[1]) / 2 if None. ...
[ "def", "binarize", "(", "x", ",", "values", ",", "threshold", "=", "None", ",", "included_in", "=", "'upper'", ")", ":", "lower", ",", "upper", "=", "values", "if", "threshold", "is", "None", ":", "threshold", "=", "(", "lower", "+", "upper", ")", "/...
Binarizes the values of x. Parameters ---------- values : tuple of two floats The lower and upper value to which the inputs are mapped. threshold : float The threshold; defaults to (values[0] + values[1]) / 2 if None. included_in : str Whether the threshold value itself belo...
[ "Binarizes", "the", "values", "of", "x", "." ]
python
valid
smarie/python-parsyfiles
parsyfiles/parsing_registries.py
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_registries.py#L29-L39
def build_parser_for_fileobject_and_desiredtype(self, obj_on_filesystem: PersistedObject, object_type: Type[T], logger: Logger = None) -> Parser: """ Returns the most appropriate parser to use to parse object obj_on_filesystem as an object of type obje...
[ "def", "build_parser_for_fileobject_and_desiredtype", "(", "self", ",", "obj_on_filesystem", ":", "PersistedObject", ",", "object_type", ":", "Type", "[", "T", "]", ",", "logger", ":", "Logger", "=", "None", ")", "->", "Parser", ":", "pass" ]
Returns the most appropriate parser to use to parse object obj_on_filesystem as an object of type object_type :param obj_on_filesystem: the filesystem object to parse :param object_type: the type of object that the parser is expected to produce :param logger: :return:
[ "Returns", "the", "most", "appropriate", "parser", "to", "use", "to", "parse", "object", "obj_on_filesystem", "as", "an", "object", "of", "type", "object_type" ]
python
train
RobotStudio/bors
bors/api/adapter/api.py
https://github.com/RobotStudio/bors/blob/38bf338fc6905d90819faa56bd832140116720f0/bors/api/adapter/api.py#L20-L32
def run(self): """Executed on startup of application""" self.api = self.context.get("cls")(self.context) self.context["inst"].append(self) # Adapters used by strategies for call, calldata in self.context.get("calls", {}).items(): def loop(): """Loop on event...
[ "def", "run", "(", "self", ")", ":", "self", ".", "api", "=", "self", ".", "context", ".", "get", "(", "\"cls\"", ")", "(", "self", ".", "context", ")", "self", ".", "context", "[", "\"inst\"", "]", ".", "append", "(", "self", ")", "# Adapters used...
Executed on startup of application
[ "Executed", "on", "startup", "of", "application" ]
python
train
dpgaspar/Flask-AppBuilder
flask_appbuilder/baseviews.py
https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/baseviews.py#L885-L930
def _get_list_widget( self, filters, actions=None, order_column="", order_direction="", page=None, page_size=None, widgets=None, **args ): """ get joined base filter and current active filter for query """ widgets = widgets or ...
[ "def", "_get_list_widget", "(", "self", ",", "filters", ",", "actions", "=", "None", ",", "order_column", "=", "\"\"", ",", "order_direction", "=", "\"\"", ",", "page", "=", "None", ",", "page_size", "=", "None", ",", "widgets", "=", "None", ",", "*", ...
get joined base filter and current active filter for query
[ "get", "joined", "base", "filter", "and", "current", "active", "filter", "for", "query" ]
python
train
timothycrosley/isort
isort/utils.py
https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/utils.py#L34-L44
def union(a: Iterable[Any], b: Iterable[Any]) -> List[Any]: """ Return a list of items that are in `a` or `b` """ u = [] # type: List[Any] for item in a: if item not in u: u.append(item) for item in b: if item not in u: u.append(item) return u
[ "def", "union", "(", "a", ":", "Iterable", "[", "Any", "]", ",", "b", ":", "Iterable", "[", "Any", "]", ")", "->", "List", "[", "Any", "]", ":", "u", "=", "[", "]", "# type: List[Any]", "for", "item", "in", "a", ":", "if", "item", "not", "in", ...
Return a list of items that are in `a` or `b`
[ "Return", "a", "list", "of", "items", "that", "are", "in", "a", "or", "b" ]
python
train
peterbrittain/asciimatics
asciimatics/widgets.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/widgets.py#L2506-L2513
def _get_pos(self): """ Get current position for scroll bar. """ if self._h >= len(self._options): return 0 else: return self._start_line / (len(self._options) - self._h)
[ "def", "_get_pos", "(", "self", ")", ":", "if", "self", ".", "_h", ">=", "len", "(", "self", ".", "_options", ")", ":", "return", "0", "else", ":", "return", "self", ".", "_start_line", "/", "(", "len", "(", "self", ".", "_options", ")", "-", "se...
Get current position for scroll bar.
[ "Get", "current", "position", "for", "scroll", "bar", "." ]
python
train
Jaymon/endpoints
endpoints/http.py
https://github.com/Jaymon/endpoints/blob/2f1c4ae2c69a168e69447d3d8395ada7becaa5fb/endpoints/http.py#L1004-L1010
def body(self): """return the raw version of the body""" body = None if self.body_input: body = self.body_input.read(int(self.get_header('content-length', -1))) return body
[ "def", "body", "(", "self", ")", ":", "body", "=", "None", "if", "self", ".", "body_input", ":", "body", "=", "self", ".", "body_input", ".", "read", "(", "int", "(", "self", ".", "get_header", "(", "'content-length'", ",", "-", "1", ")", ")", ")",...
return the raw version of the body
[ "return", "the", "raw", "version", "of", "the", "body" ]
python
train