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
apache/airflow
airflow/contrib/hooks/pinot_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/pinot_hook.py#L66-L76
def get_records(self, sql): """ Executes the sql and returns a set of records. :param sql: the sql statement to be executed (str) or a list of sql statements to execute :type sql: str """ with self.get_conn() as cur: cur.execute(sql) r...
[ "def", "get_records", "(", "self", ",", "sql", ")", ":", "with", "self", ".", "get_conn", "(", ")", "as", "cur", ":", "cur", ".", "execute", "(", "sql", ")", "return", "cur", ".", "fetchall", "(", ")" ]
Executes the sql and returns a set of records. :param sql: the sql statement to be executed (str) or a list of sql statements to execute :type sql: str
[ "Executes", "the", "sql", "and", "returns", "a", "set", "of", "records", "." ]
python
test
mbj4668/pyang
pyang/plugins/jsonxsl.py
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/jsonxsl.py#L124-L135
def process_rpc(self, rpc): """Process input and output parts of `rpc`.""" p = "/nc:rpc/" + self.qname(rpc) tmpl = self.xsl_template(p) inp = rpc.search_one("input") if inp is not None: ct = self.xsl_calltemplate("rpc-input", tmpl) self.xsl_withparam("nsid...
[ "def", "process_rpc", "(", "self", ",", "rpc", ")", ":", "p", "=", "\"/nc:rpc/\"", "+", "self", ".", "qname", "(", "rpc", ")", "tmpl", "=", "self", ".", "xsl_template", "(", "p", ")", "inp", "=", "rpc", ".", "search_one", "(", "\"input\"", ")", "if...
Process input and output parts of `rpc`.
[ "Process", "input", "and", "output", "parts", "of", "rpc", "." ]
python
train
sdss/sdss_access
python/sdss_access/path/path.py
https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/path/path.py#L453-L485
def refine(self, filelist, regex, filterdir='out', **kwargs): ''' Returns a list of files filterd by a regular expression Parameters ---------- filelist : list A list of files to filter on. regex : str The regular expression string to filter your list ...
[ "def", "refine", "(", "self", ",", "filelist", ",", "regex", ",", "filterdir", "=", "'out'", ",", "*", "*", "kwargs", ")", ":", "assert", "filelist", ",", "'Must provide a list of filenames to refine on'", "assert", "regex", ",", "'Must provide a regular expression ...
Returns a list of files filterd by a regular expression Parameters ---------- filelist : list A list of files to filter on. regex : str The regular expression string to filter your list filterdir: {'in', 'out'} Indicates the filter to be inc...
[ "Returns", "a", "list", "of", "files", "filterd", "by", "a", "regular", "expression" ]
python
train
llllllllll/codetransformer
codetransformer/decompiler/_343.py
https://github.com/llllllllll/codetransformer/blob/c5f551e915df45adc7da7e0b1b635f0cc6a1bb27/codetransformer/decompiler/_343.py#L182-L211
def make_if_statement(instr, queue, stack, context): """ Make an ast.If block from a POP_JUMP_IF_TRUE or POP_JUMP_IF_FALSE. """ test_expr = make_expr(stack) if isinstance(instr, instrs.POP_JUMP_IF_TRUE): test_expr = ast.UnaryOp(op=ast.Not(), operand=test_expr) first_block = popwhile(op....
[ "def", "make_if_statement", "(", "instr", ",", "queue", ",", "stack", ",", "context", ")", ":", "test_expr", "=", "make_expr", "(", "stack", ")", "if", "isinstance", "(", "instr", ",", "instrs", ".", "POP_JUMP_IF_TRUE", ")", ":", "test_expr", "=", "ast", ...
Make an ast.If block from a POP_JUMP_IF_TRUE or POP_JUMP_IF_FALSE.
[ "Make", "an", "ast", ".", "If", "block", "from", "a", "POP_JUMP_IF_TRUE", "or", "POP_JUMP_IF_FALSE", "." ]
python
train
markchil/gptools
gptools/mean.py
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L446-L484
def linear(X, n, *args, **kwargs): """Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`. The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`. Parameters ---------- X : array, (`M`, `D`) The points to evaluate the model at. n :...
[ "def", "linear", "(", "X", ",", "n", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "hyper_deriv", "=", "kwargs", ".", "pop", "(", "'hyper_deriv'", ",", "None", ")", "m", "=", "scipy", ".", "asarray", "(", "args", "[", ":", "-", "1", "]",...
Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`. The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`. Parameters ---------- X : array, (`M`, `D`) The points to evaluate the model at. n : array of non-negative int, (`D`) ...
[ "Linear", "mean", "function", "of", "arbitrary", "dimension", "suitable", "for", "use", "with", ":", "py", ":", "class", ":", "MeanFunction", ".", "The", "form", "is", ":", "math", ":", "m_0", "*", "X", "[", ":", "0", "]", "+", "m_1", "*", "X", "["...
python
train
andymccurdy/redis-py
redis/client.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L2164-L2182
def xrange(self, name, min='-', max='+', count=None): """ Read stream values within an interval. name: name of the stream. start: first stream ID. defaults to '-', meaning the earliest available. finish: last stream ID. defaults to '+', meaning the ...
[ "def", "xrange", "(", "self", ",", "name", ",", "min", "=", "'-'", ",", "max", "=", "'+'", ",", "count", "=", "None", ")", ":", "pieces", "=", "[", "min", ",", "max", "]", "if", "count", "is", "not", "None", ":", "if", "not", "isinstance", "(",...
Read stream values within an interval. name: name of the stream. start: first stream ID. defaults to '-', meaning the earliest available. finish: last stream ID. defaults to '+', meaning the latest available. count: if set, only return this many items, begi...
[ "Read", "stream", "values", "within", "an", "interval", ".", "name", ":", "name", "of", "the", "stream", ".", "start", ":", "first", "stream", "ID", ".", "defaults", "to", "-", "meaning", "the", "earliest", "available", ".", "finish", ":", "last", "strea...
python
train
Cog-Creators/Red-Lavalink
lavalink/rest_api.py
https://github.com/Cog-Creators/Red-Lavalink/blob/5b3fc6eb31ee5db8bd2b633a523cf69749957111/lavalink/rest_api.py#L102-L111
def exception_message(self) -> Union[str, None]: """ On Lavalink V3, if there was an exception during a load or get tracks call this property will be populated with the error message. If there was no error this property will be ``None``. """ if self.has_error: ...
[ "def", "exception_message", "(", "self", ")", "->", "Union", "[", "str", ",", "None", "]", ":", "if", "self", ".", "has_error", ":", "exception_data", "=", "self", ".", "_raw", ".", "get", "(", "\"exception\"", ",", "{", "}", ")", "return", "exception_...
On Lavalink V3, if there was an exception during a load or get tracks call this property will be populated with the error message. If there was no error this property will be ``None``.
[ "On", "Lavalink", "V3", "if", "there", "was", "an", "exception", "during", "a", "load", "or", "get", "tracks", "call", "this", "property", "will", "be", "populated", "with", "the", "error", "message", ".", "If", "there", "was", "no", "error", "this", "pr...
python
train
jamieleshaw/lurklib
lurklib/channel.py
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/channel.py#L289-L335
def names(self, channel): """ Get a list of users in the channel. Required arguments: * channel - Channel to get list of users for. """ with self.lock: self.is_in_channel(channel) self.send('NAMES %s' % channel) names = [] ...
[ "def", "names", "(", "self", ",", "channel", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "is_in_channel", "(", "channel", ")", "self", ".", "send", "(", "'NAMES %s'", "%", "channel", ")", "names", "=", "[", "]", "while", "self", ".", "...
Get a list of users in the channel. Required arguments: * channel - Channel to get list of users for.
[ "Get", "a", "list", "of", "users", "in", "the", "channel", ".", "Required", "arguments", ":", "*", "channel", "-", "Channel", "to", "get", "list", "of", "users", "for", "." ]
python
train
GoogleCloudPlatform/cloud-debug-python
src/googleclouddebugger/gcp_hub_client.py
https://github.com/GoogleCloudPlatform/cloud-debug-python/blob/89ce3782c98b814838a3ecb5479ed3882368cbee/src/googleclouddebugger/gcp_hub_client.py#L475-L497
def _ComputeUniquifier(self, debuggee): """Computes debuggee uniquifier. The debuggee uniquifier has to be identical on all instances. Therefore the uniquifier should not include any random numbers and should only be based on inputs that are guaranteed to be the same on all instances. Args: ...
[ "def", "_ComputeUniquifier", "(", "self", ",", "debuggee", ")", ":", "uniquifier", "=", "hashlib", ".", "sha1", "(", ")", "# Compute hash of application files if we don't have source context. This", "# way we can still distinguish between different deployments.", "if", "(", "'m...
Computes debuggee uniquifier. The debuggee uniquifier has to be identical on all instances. Therefore the uniquifier should not include any random numbers and should only be based on inputs that are guaranteed to be the same on all instances. Args: debuggee: complete debuggee message without the...
[ "Computes", "debuggee", "uniquifier", "." ]
python
train
tgalal/yowsup
yowsup/axolotl/manager.py
https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/manager.py#L192-L203
def group_encrypt(self, groupid, message): """ :param groupid: :type groupid: str :param message: :type message: bytes :return: :rtype: """ logger.debug("group_encrypt(groupid=%s, message=%s)" % (groupid, message)) group_cipher = self._get_...
[ "def", "group_encrypt", "(", "self", ",", "groupid", ",", "message", ")", ":", "logger", ".", "debug", "(", "\"group_encrypt(groupid=%s, message=%s)\"", "%", "(", "groupid", ",", "message", ")", ")", "group_cipher", "=", "self", ".", "_get_group_cipher", "(", ...
:param groupid: :type groupid: str :param message: :type message: bytes :return: :rtype:
[ ":", "param", "groupid", ":", ":", "type", "groupid", ":", "str", ":", "param", "message", ":", ":", "type", "message", ":", "bytes", ":", "return", ":", ":", "rtype", ":" ]
python
train
googleapis/google-cloud-python
error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_stats_service_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/error_reporting/google/cloud/errorreporting_v1beta1/gapic/error_stats_service_client.py#L472-L542
def delete_events( self, project_name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Deletes all error events of a given project. Example: >>> from google.cloud import...
[ "def", "delete_events", "(", "self", ",", "project_name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "...
Deletes all error events of a given project. Example: >>> from google.cloud import errorreporting_v1beta1 >>> >>> client = errorreporting_v1beta1.ErrorStatsServiceClient() >>> >>> project_name = client.project_path('[PROJECT]') >>> ...
[ "Deletes", "all", "error", "events", "of", "a", "given", "project", "." ]
python
train
wummel/linkchecker
linkcheck/configuration/__init__.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/configuration/__init__.py#L123-L133
def get_system_cert_file(): """Try to find a system-wide SSL certificate file. @return: the filename to the cert file @raises: ValueError when no system cert file could be found """ if os.name == 'posix': filename = "/etc/ssl/certs/ca-certificates.crt" if os.path.isfile(filename): ...
[ "def", "get_system_cert_file", "(", ")", ":", "if", "os", ".", "name", "==", "'posix'", ":", "filename", "=", "\"/etc/ssl/certs/ca-certificates.crt\"", "if", "os", ".", "path", ".", "isfile", "(", "filename", ")", ":", "return", "filename", "msg", "=", "\"no...
Try to find a system-wide SSL certificate file. @return: the filename to the cert file @raises: ValueError when no system cert file could be found
[ "Try", "to", "find", "a", "system", "-", "wide", "SSL", "certificate", "file", "." ]
python
train
shoebot/shoebot
lib/photobot/__init__.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/photobot/__init__.py#L433-L443
def down(self): """Moves the layer down in the stacking order. """ i = self.index() if i != None: del self.canvas.layers[i] i = max(0, i-1) self.canvas.layers.insert(i, self)
[ "def", "down", "(", "self", ")", ":", "i", "=", "self", ".", "index", "(", ")", "if", "i", "!=", "None", ":", "del", "self", ".", "canvas", ".", "layers", "[", "i", "]", "i", "=", "max", "(", "0", ",", "i", "-", "1", ")", "self", ".", "ca...
Moves the layer down in the stacking order.
[ "Moves", "the", "layer", "down", "in", "the", "stacking", "order", "." ]
python
valid
jhermann/rituals
src/rituals/util/scm/git.py
https://github.com/jhermann/rituals/blob/1534f50d81e19bbbe799e2eba0acdefbce047c06/src/rituals/util/scm/git.py#L87-L90
def tag(self, label, message=None): """Tag the current workdir state.""" options = ' -m "{}" -a'.format(message) if message else '' self.run_elective('git tag{} "{}"'.format(options, label))
[ "def", "tag", "(", "self", ",", "label", ",", "message", "=", "None", ")", ":", "options", "=", "' -m \"{}\" -a'", ".", "format", "(", "message", ")", "if", "message", "else", "''", "self", ".", "run_elective", "(", "'git tag{} \"{}\"'", ".", "format", "...
Tag the current workdir state.
[ "Tag", "the", "current", "workdir", "state", "." ]
python
valid
waqasbhatti/astrobase
astrobase/lcmath.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcmath.py#L1233-L1334
def phase_bin_magseries(phases, mags, binsize=0.005, minbinelems=7): '''Bins a phased magnitude/flux time-series using the bin size provided. Parameters ---------- phases,mags : np.array The phased magnitude/flux time-series to bin in phase. Non-...
[ "def", "phase_bin_magseries", "(", "phases", ",", "mags", ",", "binsize", "=", "0.005", ",", "minbinelems", "=", "7", ")", ":", "# check if the input arrays are ok", "if", "not", "(", "phases", ".", "shape", "and", "mags", ".", "shape", "and", "len", "(", ...
Bins a phased magnitude/flux time-series using the bin size provided. Parameters ---------- phases,mags : np.array The phased magnitude/flux time-series to bin in phase. Non-finite elements will be removed from these arrays. At least 10 elements in each array are required for this ...
[ "Bins", "a", "phased", "magnitude", "/", "flux", "time", "-", "series", "using", "the", "bin", "size", "provided", "." ]
python
valid
samfoo/vt102
vt102/__init__.py
https://github.com/samfoo/vt102/blob/ff5be883bc9a880a422b09bb87b210d7c408cf2c/vt102/__init__.py#L209-L221
def _end_escape_sequence(self, char): """ Handle the end of an escape sequence. The final character in an escape sequence is the command to execute, which corresponds to the event that is dispatched here. """ num = ord(char) if num in self.sequence: s...
[ "def", "_end_escape_sequence", "(", "self", ",", "char", ")", ":", "num", "=", "ord", "(", "char", ")", "if", "num", "in", "self", ".", "sequence", ":", "self", ".", "dispatch", "(", "self", ".", "sequence", "[", "num", "]", ",", "*", "self", ".", ...
Handle the end of an escape sequence. The final character in an escape sequence is the command to execute, which corresponds to the event that is dispatched here.
[ "Handle", "the", "end", "of", "an", "escape", "sequence", ".", "The", "final", "character", "in", "an", "escape", "sequence", "is", "the", "command", "to", "execute", "which", "corresponds", "to", "the", "event", "that", "is", "dispatched", "here", "." ]
python
train
cloudbase/python-hnvclient
hnv/client.py
https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/client.py#L811-L816
def process_raw_data(cls, raw_data): """Create a new model using raw API response.""" raw_settings = raw_data.get("qosSettings", {}) qos_settings = QosSettings.from_raw_data(raw_settings) raw_data["qosSettings"] = qos_settings return super(PortSettings, cls).process_raw_data(raw_...
[ "def", "process_raw_data", "(", "cls", ",", "raw_data", ")", ":", "raw_settings", "=", "raw_data", ".", "get", "(", "\"qosSettings\"", ",", "{", "}", ")", "qos_settings", "=", "QosSettings", ".", "from_raw_data", "(", "raw_settings", ")", "raw_data", "[", "\...
Create a new model using raw API response.
[ "Create", "a", "new", "model", "using", "raw", "API", "response", "." ]
python
train
alexandrovteam/pyimzML
pyimzml/ImzMLParser.py
https://github.com/alexandrovteam/pyimzML/blob/baae0bea7279f9439113d6b2f61be528c0462b3f/pyimzml/ImzMLParser.py#L266-L283
def get_physical_coordinates(self, i): """ For a pixel index i, return the real-world coordinates in nanometers. This is equivalent to multiplying the image coordinates of the given pixel with the pixel size. :param i: the pixel index :return: a tuple of x and y coordinates. ...
[ "def", "get_physical_coordinates", "(", "self", ",", "i", ")", ":", "try", ":", "pixel_size_x", "=", "self", ".", "imzmldict", "[", "\"pixel size x\"", "]", "pixel_size_y", "=", "self", ".", "imzmldict", "[", "\"pixel size y\"", "]", "except", "KeyError", ":",...
For a pixel index i, return the real-world coordinates in nanometers. This is equivalent to multiplying the image coordinates of the given pixel with the pixel size. :param i: the pixel index :return: a tuple of x and y coordinates. :rtype: Tuple[float] :raises KeyError: if the...
[ "For", "a", "pixel", "index", "i", "return", "the", "real", "-", "world", "coordinates", "in", "nanometers", "." ]
python
train
iandees/pyosm
pyosm/parsing.py
https://github.com/iandees/pyosm/blob/532dffceae91e2bce89c530ceff627bc8210f8aa/pyosm/parsing.py#L213-L280
def iter_osm_stream(start_sqn=None, base_url='https://planet.openstreetmap.org/replication/minute', expected_interval=60, parse_timestamps=True, state_dir=None): """Start processing an OSM diff stream and yield one changeset at a time to the caller.""" # If the user specifies a state_dir, read the state fr...
[ "def", "iter_osm_stream", "(", "start_sqn", "=", "None", ",", "base_url", "=", "'https://planet.openstreetmap.org/replication/minute'", ",", "expected_interval", "=", "60", ",", "parse_timestamps", "=", "True", ",", "state_dir", "=", "None", ")", ":", "# If the user s...
Start processing an OSM diff stream and yield one changeset at a time to the caller.
[ "Start", "processing", "an", "OSM", "diff", "stream", "and", "yield", "one", "changeset", "at", "a", "time", "to", "the", "caller", "." ]
python
test
jwodder/doapi
doapi/droplet.py
https://github.com/jwodder/doapi/blob/b1306de86a01d8ae7b9c1fe2699765bb82e4f310/doapi/droplet.py#L394-L410
def rebuild(self, image): """ Rebuild the droplet with the specified image A rebuild action functions just like a new create. [APIDocs]_ :param image: an image ID, an image slug, or an `Image` object representing the image the droplet should use as a base :type ...
[ "def", "rebuild", "(", "self", ",", "image", ")", ":", "if", "isinstance", "(", "image", ",", "Image", ")", ":", "image", "=", "image", ".", "id", "return", "self", ".", "act", "(", "type", "=", "'rebuild'", ",", "image", "=", "image", ")" ]
Rebuild the droplet with the specified image A rebuild action functions just like a new create. [APIDocs]_ :param image: an image ID, an image slug, or an `Image` object representing the image the droplet should use as a base :type image: integer, string, or `Image` :re...
[ "Rebuild", "the", "droplet", "with", "the", "specified", "image" ]
python
train
JamesPHoughton/pysd
pysd/py_backend/builder.py
https://github.com/JamesPHoughton/pysd/blob/bf1b1d03954e9ba5acac9ba4f1ada7cd93352eda/pysd/py_backend/builder.py#L25-L106
def build(elements, subscript_dict, namespace, outfile_name): """ Actually constructs and writes the python representation of the model Parameters ---------- elements: list Each element is a dictionary, with the various components needed to assemble a model component in python synta...
[ "def", "build", "(", "elements", ",", "subscript_dict", ",", "namespace", ",", "outfile_name", ")", ":", "# Todo: deal with model level documentation", "# Todo: Make np, PySD.functions import conditional on usage in the file", "# Todo: Make presence of subscript_dict instantiation condit...
Actually constructs and writes the python representation of the model Parameters ---------- elements: list Each element is a dictionary, with the various components needed to assemble a model component in python syntax. This will contain multiple entries for elements that have multi...
[ "Actually", "constructs", "and", "writes", "the", "python", "representation", "of", "the", "model" ]
python
train
kontron/python-ipmi
pyipmi/interfaces/aardvark.py
https://github.com/kontron/python-ipmi/blob/ce46da47a37dd683615f32d04a10eda069aa569a/pyipmi/interfaces/aardvark.py#L131-L168
def _send_and_receive(self, target, lun, netfn, cmdid, payload): """Send and receive data using aardvark interface. target: lun: netfn: cmdid: payload: IPMI message payload as bytestring Returns the received data as bytestring """ self._inc_seque...
[ "def", "_send_and_receive", "(", "self", ",", "target", ",", "lun", ",", "netfn", ",", "cmdid", ",", "payload", ")", ":", "self", ".", "_inc_sequence_number", "(", ")", "# assemble IPMB header", "header", "=", "IpmbHeaderReq", "(", ")", "header", ".", "netfn...
Send and receive data using aardvark interface. target: lun: netfn: cmdid: payload: IPMI message payload as bytestring Returns the received data as bytestring
[ "Send", "and", "receive", "data", "using", "aardvark", "interface", "." ]
python
train
matthew-sochor/transfer
transfer/input.py
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/input.py#L57-L76
def bool_input(message): ''' Ask a user for a boolean input args: message (str): Prompt for user returns: bool_in (boolean): Input boolean ''' while True: suffix = ' (true or false): ' inp = input(message + suffix) if inp.lower() == 'true': ...
[ "def", "bool_input", "(", "message", ")", ":", "while", "True", ":", "suffix", "=", "' (true or false): '", "inp", "=", "input", "(", "message", "+", "suffix", ")", "if", "inp", ".", "lower", "(", ")", "==", "'true'", ":", "return", "True", "elif", "in...
Ask a user for a boolean input args: message (str): Prompt for user returns: bool_in (boolean): Input boolean
[ "Ask", "a", "user", "for", "a", "boolean", "input" ]
python
train
tgalal/yowsup
yowsup/config/transforms/config_dict.py
https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/transforms/config_dict.py#L8-L18
def transform(self, config): """ :param config: :type config: dict :return: :rtype: yowsup.config.config.Config """ out = {} for prop in vars(config): out[prop] = getattr(config, prop) return out
[ "def", "transform", "(", "self", ",", "config", ")", ":", "out", "=", "{", "}", "for", "prop", "in", "vars", "(", "config", ")", ":", "out", "[", "prop", "]", "=", "getattr", "(", "config", ",", "prop", ")", "return", "out" ]
:param config: :type config: dict :return: :rtype: yowsup.config.config.Config
[ ":", "param", "config", ":", ":", "type", "config", ":", "dict", ":", "return", ":", ":", "rtype", ":", "yowsup", ".", "config", ".", "config", ".", "Config" ]
python
train
hvac/hvac
hvac/api/secrets_engines/azure.py
https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/secrets_engines/azure.py#L99-L136
def create_or_update_role(self, name, azure_roles, ttl="", max_ttl="", mount_point=DEFAULT_MOUNT_POINT): """Create or update a Vault role. The provided Azure roles must exist for this call to succeed. See the Azure secrets roles docs for more information about roles. Supported methods:...
[ "def", "create_or_update_role", "(", "self", ",", "name", ",", "azure_roles", ",", "ttl", "=", "\"\"", ",", "max_ttl", "=", "\"\"", ",", "mount_point", "=", "DEFAULT_MOUNT_POINT", ")", ":", "params", "=", "{", "'azure_roles'", ":", "json", ".", "dumps", "(...
Create or update a Vault role. The provided Azure roles must exist for this call to succeed. See the Azure secrets roles docs for more information about roles. Supported methods: POST: /{mount_point}/roles/{name}. Produces: 204 (empty body) :param name: Name of the role. ...
[ "Create", "or", "update", "a", "Vault", "role", "." ]
python
train
eonpatapon/contrail-api-cli
contrail_api_cli/client.py
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/client.py#L136-L147
def post_json(self, url, data, cls=None, **kwargs): """ POST data to the api-server :param url: resource location (eg: "/type/uuid") :type url: str :param cls: JSONEncoder class :type cls: JSONEncoder """ kwargs['data'] = to_json(data, cls=cls) kw...
[ "def", "post_json", "(", "self", ",", "url", ",", "data", ",", "cls", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'data'", "]", "=", "to_json", "(", "data", ",", "cls", "=", "cls", ")", "kwargs", "[", "'headers'", "]", "=", ...
POST data to the api-server :param url: resource location (eg: "/type/uuid") :type url: str :param cls: JSONEncoder class :type cls: JSONEncoder
[ "POST", "data", "to", "the", "api", "-", "server" ]
python
train
ellmetha/django-machina
machina/apps/forum_member/views.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_member/views.py#L175-L177
def perform_permissions_check(self, user, obj, perms): """ Performs the permission check. """ return self.request.forum_permission_handler.can_subscribe_to_topic(obj, user)
[ "def", "perform_permissions_check", "(", "self", ",", "user", ",", "obj", ",", "perms", ")", ":", "return", "self", ".", "request", ".", "forum_permission_handler", ".", "can_subscribe_to_topic", "(", "obj", ",", "user", ")" ]
Performs the permission check.
[ "Performs", "the", "permission", "check", "." ]
python
train
KelSolaar/Umbra
umbra/preferences.py
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/preferences.py#L283-L297
def set_default_preferences(self): """ Defines the default settings file content. :return: Method success. :rtype: bool """ LOGGER.debug("> Initializing default settings!") for key in self.__default_settings.allKeys(): self.__settings.setValue(key, ...
[ "def", "set_default_preferences", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"> Initializing default settings!\"", ")", "for", "key", "in", "self", ".", "__default_settings", ".", "allKeys", "(", ")", ":", "self", ".", "__settings", ".", "setValue", ...
Defines the default settings file content. :return: Method success. :rtype: bool
[ "Defines", "the", "default", "settings", "file", "content", "." ]
python
train
rpcope1/HackerNewsAPI-Py
HackerNewsAPI/API.py
https://github.com/rpcope1/HackerNewsAPI-Py/blob/b231aed24ec59fc32af320bbef27d48cc4b69914/HackerNewsAPI/API.py#L28-L37
def _make_request(self, suburl): """ Helper function for making requests :param suburl: The suburl to query :return: Decoded json object """ url = "{}/{}".format(self.API_BASE_URL, suburl) response = self.session.get(url) response.raise_for_status() ...
[ "def", "_make_request", "(", "self", ",", "suburl", ")", ":", "url", "=", "\"{}/{}\"", ".", "format", "(", "self", ".", "API_BASE_URL", ",", "suburl", ")", "response", "=", "self", ".", "session", ".", "get", "(", "url", ")", "response", ".", "raise_fo...
Helper function for making requests :param suburl: The suburl to query :return: Decoded json object
[ "Helper", "function", "for", "making", "requests", ":", "param", "suburl", ":", "The", "suburl", "to", "query", ":", "return", ":", "Decoded", "json", "object" ]
python
train
cloudera/cm_api
python/src/cm_api/endpoints/types.py
https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/types.py#L216-L226
def _set_attrs(self, attrs, allow_ro=False, from_json=True): """ Sets all the attributes in the dictionary. Optionally, allows setting read-only attributes (e.g. when deserializing from JSON) and skipping JSON deserialization of values. """ for k, v in attrs.iteritems(): attr = self._check...
[ "def", "_set_attrs", "(", "self", ",", "attrs", ",", "allow_ro", "=", "False", ",", "from_json", "=", "True", ")", ":", "for", "k", ",", "v", "in", "attrs", ".", "iteritems", "(", ")", ":", "attr", "=", "self", ".", "_check_attr", "(", "k", ",", ...
Sets all the attributes in the dictionary. Optionally, allows setting read-only attributes (e.g. when deserializing from JSON) and skipping JSON deserialization of values.
[ "Sets", "all", "the", "attributes", "in", "the", "dictionary", ".", "Optionally", "allows", "setting", "read", "-", "only", "attributes", "(", "e", ".", "g", ".", "when", "deserializing", "from", "JSON", ")", "and", "skipping", "JSON", "deserialization", "of...
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v10/matrixpilot.py#L9407-L9420
def mission_request_partial_list_encode(self, target_system, target_component, start_index, end_index): ''' Request a partial list of mission items from the system/component. http://qgroundcontrol.org/mavlink/waypoint_protocol. If start and end index are t...
[ "def", "mission_request_partial_list_encode", "(", "self", ",", "target_system", ",", "target_component", ",", "start_index", ",", "end_index", ")", ":", "return", "MAVLink_mission_request_partial_list_message", "(", "target_system", ",", "target_component", ",", "start_ind...
Request a partial list of mission items from the system/component. http://qgroundcontrol.org/mavlink/waypoint_protocol. If start and end index are the same, just send one waypoint. target_system : System ID (uint8_t) target_com...
[ "Request", "a", "partial", "list", "of", "mission", "items", "from", "the", "system", "/", "component", ".", "http", ":", "//", "qgroundcontrol", ".", "org", "/", "mavlink", "/", "waypoint_protocol", ".", "If", "start", "and", "end", "index", "are", "the",...
python
train
saltstack/salt
salt/modules/firewalld.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/firewalld.py#L1027-L1044
def remove_rich_rule(zone, rule, permanent=True): ''' Add a rich rule to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_rich_rule zone 'rule' ''' cmd = "--zone={0} --remove-rich-rule='{1}'".format(zone, rule) if permanent: ...
[ "def", "remove_rich_rule", "(", "zone", ",", "rule", ",", "permanent", "=", "True", ")", ":", "cmd", "=", "\"--zone={0} --remove-rich-rule='{1}'\"", ".", "format", "(", "zone", ",", "rule", ")", "if", "permanent", ":", "cmd", "+=", "' --permanent'", "return", ...
Add a rich rule to a zone .. versionadded:: 2016.11.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_rich_rule zone 'rule'
[ "Add", "a", "rich", "rule", "to", "a", "zone" ]
python
train
openstack/quark
quark/drivers/nvp_driver.py
https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/drivers/nvp_driver.py#L740-L748
def get_lswitch_ids_for_network(self, context, network_id): """Public interface for fetching lswitch ids for a given network. NOTE(morgabra) This is here because calling private methods from outside the class feels wrong, and we need to be able to fetch lswitch ids for use in other driv...
[ "def", "get_lswitch_ids_for_network", "(", "self", ",", "context", ",", "network_id", ")", ":", "lswitches", "=", "self", ".", "_lswitches_for_network", "(", "context", ",", "network_id", ")", ".", "results", "(", ")", "return", "[", "s", "[", "'uuid'", "]",...
Public interface for fetching lswitch ids for a given network. NOTE(morgabra) This is here because calling private methods from outside the class feels wrong, and we need to be able to fetch lswitch ids for use in other drivers.
[ "Public", "interface", "for", "fetching", "lswitch", "ids", "for", "a", "given", "network", "." ]
python
valid
googlefonts/fontbakery
Lib/fontbakery/profiles/googlefonts.py
https://github.com/googlefonts/fontbakery/blob/b355aea2e619a4477769e060d24c32448aa65399/Lib/fontbakery/profiles/googlefonts.py#L3781-L3807
def com_google_fonts_check_name_family_and_style_max_length(ttFont): """Combined length of family and style must not exceed 27 characters.""" from fontbakery.utils import (get_name_entries, get_name_entry_strings) failed = False for familyname in get_name_entries(ttFont, ...
[ "def", "com_google_fonts_check_name_family_and_style_max_length", "(", "ttFont", ")", ":", "from", "fontbakery", ".", "utils", "import", "(", "get_name_entries", ",", "get_name_entry_strings", ")", "failed", "=", "False", "for", "familyname", "in", "get_name_entries", "...
Combined length of family and style must not exceed 27 characters.
[ "Combined", "length", "of", "family", "and", "style", "must", "not", "exceed", "27", "characters", "." ]
python
train
bloomreach/s4cmd
s4cmd.py
https://github.com/bloomreach/s4cmd/blob/bb51075bf43703e7cd95aa39288cf7732ec13a6d/s4cmd.py#L175-L189
def fail(message, exc_info=None, status=1, stacktrace=False): '''Utility function to handle runtime failures gracefully. Show concise information if possible, then terminate program. ''' text = message if exc_info: text += str(exc_info) error(text) if stacktrace: error(traceback.format_exc()) ...
[ "def", "fail", "(", "message", ",", "exc_info", "=", "None", ",", "status", "=", "1", ",", "stacktrace", "=", "False", ")", ":", "text", "=", "message", "if", "exc_info", ":", "text", "+=", "str", "(", "exc_info", ")", "error", "(", "text", ")", "i...
Utility function to handle runtime failures gracefully. Show concise information if possible, then terminate program.
[ "Utility", "function", "to", "handle", "runtime", "failures", "gracefully", ".", "Show", "concise", "information", "if", "possible", "then", "terminate", "program", "." ]
python
test
log2timeline/plaso
plaso/parsers/esedb_plugins/srum.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/esedb_plugins/srum.py#L479-L496
def ParseNetworkConnectivityUsage( self, parser_mediator, cache=None, database=None, table=None, **unused_kwargs): """Parses the network connectivity usage monitor table. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as stor...
[ "def", "ParseNetworkConnectivityUsage", "(", "self", ",", "parser_mediator", ",", "cache", "=", "None", ",", "database", "=", "None", ",", "table", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "# TODO: consider making ConnectStartTime + ConnectedTime an even...
Parses the network connectivity usage monitor table. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. cache (Optional[ESEDBCache]): cache, which contains information about the identifiers stored in the Sru...
[ "Parses", "the", "network", "connectivity", "usage", "monitor", "table", "." ]
python
train
klen/muffin-rest
muffin_rest/peewee.py
https://github.com/klen/muffin-rest/blob/1d85bdd3b72a89eaeab8c4086926260a960408aa/muffin_rest/peewee.py#L95-L104
def get_one(self, request, **kwargs): """Load a resource.""" resource = request.match_info.get(self.name) if not resource: return None try: return self.collection.where(self.meta.model_pk == resource).get() except Exception: raise RESTNotFound...
[ "def", "get_one", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "resource", "=", "request", ".", "match_info", ".", "get", "(", "self", ".", "name", ")", "if", "not", "resource", ":", "return", "None", "try", ":", "return", "self", ...
Load a resource.
[ "Load", "a", "resource", "." ]
python
train
klmitch/metatools
metatools.py
https://github.com/klmitch/metatools/blob/7161cf22ef2b194cfd4406e85b81e39a49104d9d/metatools.py#L134-L173
def inherit_set(base, namespace, attr_name, inherit=lambda i: True): """ Perform inheritance of sets. Returns a list of items that were inherited, for post-processing. :param base: The base class being considered; see ``iter_bases()``. :...
[ "def", "inherit_set", "(", "base", ",", "namespace", ",", "attr_name", ",", "inherit", "=", "lambda", "i", ":", "True", ")", ":", "items", "=", "[", "]", "# Get the sets to compare", "base_set", "=", "getattr", "(", "base", ",", "attr_name", ",", "set", ...
Perform inheritance of sets. Returns a list of items that were inherited, for post-processing. :param base: The base class being considered; see ``iter_bases()``. :param namespace: The dictionary of the new class being built. :param attr_name: The name of the attri...
[ "Perform", "inheritance", "of", "sets", ".", "Returns", "a", "list", "of", "items", "that", "were", "inherited", "for", "post", "-", "processing", "." ]
python
train
pandas-dev/pandas
pandas/core/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L7033-L7115
def corr(self, method='pearson', min_periods=1): """ Compute pairwise correlation of columns, excluding NA/null values. Parameters ---------- method : {'pearson', 'kendall', 'spearman'} or callable * pearson : standard correlation coefficient * kendall : ...
[ "def", "corr", "(", "self", ",", "method", "=", "'pearson'", ",", "min_periods", "=", "1", ")", ":", "numeric_df", "=", "self", ".", "_get_numeric_data", "(", ")", "cols", "=", "numeric_df", ".", "columns", "idx", "=", "cols", ".", "copy", "(", ")", ...
Compute pairwise correlation of columns, excluding NA/null values. Parameters ---------- method : {'pearson', 'kendall', 'spearman'} or callable * pearson : standard correlation coefficient * kendall : Kendall Tau correlation coefficient * spearman : Spearman...
[ "Compute", "pairwise", "correlation", "of", "columns", "excluding", "NA", "/", "null", "values", "." ]
python
train
pmorissette/bt
bt/core.py
https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L175-L181
def value(self): """ Current value of the Node """ if self.root.stale: self.root.update(self.root.now, None) return self._value
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "root", ".", "stale", ":", "self", ".", "root", ".", "update", "(", "self", ".", "root", ".", "now", ",", "None", ")", "return", "self", ".", "_value" ]
Current value of the Node
[ "Current", "value", "of", "the", "Node" ]
python
train
fermiPy/fermipy
fermipy/jobs/link.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L346-L350
def _fill_argparser(self, parser): """Fill an `argparser.ArgumentParser` with the options from this chain """ for key, val in self._options.items(): add_argument(parser, key, val)
[ "def", "_fill_argparser", "(", "self", ",", "parser", ")", ":", "for", "key", ",", "val", "in", "self", ".", "_options", ".", "items", "(", ")", ":", "add_argument", "(", "parser", ",", "key", ",", "val", ")" ]
Fill an `argparser.ArgumentParser` with the options from this chain
[ "Fill", "an", "argparser", ".", "ArgumentParser", "with", "the", "options", "from", "this", "chain" ]
python
train
blockstack/blockstack-core
blockstack/lib/config.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1168-L1173
def get_announce_filename( working_dir ): """ Get the path to the file that stores all of the announcements. """ announce_filepath = os.path.join( working_dir, get_default_virtualchain_impl().get_virtual_chain_name() ) + '.announce' return announce_filepath
[ "def", "get_announce_filename", "(", "working_dir", ")", ":", "announce_filepath", "=", "os", ".", "path", ".", "join", "(", "working_dir", ",", "get_default_virtualchain_impl", "(", ")", ".", "get_virtual_chain_name", "(", ")", ")", "+", "'.announce'", "return", ...
Get the path to the file that stores all of the announcements.
[ "Get", "the", "path", "to", "the", "file", "that", "stores", "all", "of", "the", "announcements", "." ]
python
train
gitpython-developers/GitPython
git/objects/submodule/base.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/objects/submodule/base.py#L912-L957
def set_parent_commit(self, commit, check=True): """Set this instance to use the given commit whose tree is supposed to contain the .gitmodules blob. :param commit: Commit'ish reference pointing at the root_tree, or None to always point to the most recent commit ...
[ "def", "set_parent_commit", "(", "self", ",", "commit", ",", "check", "=", "True", ")", ":", "if", "commit", "is", "None", ":", "self", ".", "_parent_commit", "=", "None", "return", "self", "# end handle None", "pcommit", "=", "self", ".", "repo", ".", "...
Set this instance to use the given commit whose tree is supposed to contain the .gitmodules blob. :param commit: Commit'ish reference pointing at the root_tree, or None to always point to the most recent commit :param check: if True, relatively expensive chec...
[ "Set", "this", "instance", "to", "use", "the", "given", "commit", "whose", "tree", "is", "supposed", "to", "contain", "the", ".", "gitmodules", "blob", "." ]
python
train
jaredLunde/vital-tools
vital/tools/encoding.py
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/encoding.py#L216-L279
def text_badness(text): u''' Look for red flags that text is encoded incorrectly: Obvious problems: - The replacement character \ufffd, indicating a decoding error - Unassigned or private-use Unicode characters Very weird things: - Adjacent letters from two different scripts - Letters ...
[ "def", "text_badness", "(", "text", ")", ":", "assert", "isinstance", "(", "text", ",", "str", ")", "errors", "=", "0", "very_weird_things", "=", "0", "weird_things", "=", "0", "prev_letter_script", "=", "None", "unicodedata_name", "=", "unicodedata", ".", "...
u''' Look for red flags that text is encoded incorrectly: Obvious problems: - The replacement character \ufffd, indicating a decoding error - Unassigned or private-use Unicode characters Very weird things: - Adjacent letters from two different scripts - Letters in scripts that are very rar...
[ "u", "Look", "for", "red", "flags", "that", "text", "is", "encoded", "incorrectly", ":" ]
python
train
iotile/coretools
iotilecore/iotile/core/hw/transport/server/standard.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/hw/transport/server/standard.py#L91-L120
async def client_event_handler(self, client_id, event_tuple, user_data): """Method called to actually send an event to a client. Users of this class should override this method to actually forward device events to their clients. It is called with the client_id passed to (or returned fr...
[ "async", "def", "client_event_handler", "(", "self", ",", "client_id", ",", "event_tuple", ",", "user_data", ")", ":", "conn_string", ",", "event_name", ",", "_event", "=", "event_tuple", "self", ".", "_logger", ".", "debug", "(", "\"Ignoring event %s from device ...
Method called to actually send an event to a client. Users of this class should override this method to actually forward device events to their clients. It is called with the client_id passed to (or returned from) :meth:`setup_client` as well as the user_data object that was included t...
[ "Method", "called", "to", "actually", "send", "an", "event", "to", "a", "client", "." ]
python
train
Datary/scrapbag
scrapbag/files.py
https://github.com/Datary/scrapbag/blob/3a4f9824ab6fe21121214ba9963690618da2c9de/scrapbag/files.py#L94-L109
def open_remote_url(urls, **kwargs): """Open the url and check that it stores a file. Args: :urls: Endpoint to take the file """ if isinstance(urls, str): urls = [urls] for url in urls: try: web_file = requests.get(url, stream=True, **kwargs) if 'html'...
[ "def", "open_remote_url", "(", "urls", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "urls", ",", "str", ")", ":", "urls", "=", "[", "urls", "]", "for", "url", "in", "urls", ":", "try", ":", "web_file", "=", "requests", ".", "get", ...
Open the url and check that it stores a file. Args: :urls: Endpoint to take the file
[ "Open", "the", "url", "and", "check", "that", "it", "stores", "a", "file", ".", "Args", ":", ":", "urls", ":", "Endpoint", "to", "take", "the", "file" ]
python
train
knipknap/exscript
Exscript/protocols/protocol.py
https://github.com/knipknap/exscript/blob/72718eee3e87b345d5a5255be9824e867e42927b/Exscript/protocols/protocol.py#L907-L930
def auto_app_authorize(self, account=None, flush=True, bailout=False): """ Like authorize(), but instead of just waiting for a user or password prompt, it automatically initiates the authorization procedure by sending a driver-specific command. In the case of devices that unders...
[ "def", "auto_app_authorize", "(", "self", ",", "account", "=", "None", ",", "flush", "=", "True", ",", "bailout", "=", "False", ")", ":", "with", "self", ".", "_get_account", "(", "account", ")", "as", "account", ":", "self", ".", "_dbg", "(", "1", "...
Like authorize(), but instead of just waiting for a user or password prompt, it automatically initiates the authorization procedure by sending a driver-specific command. In the case of devices that understand AAA, that means sending a command to the device. For example, on routers runni...
[ "Like", "authorize", "()", "but", "instead", "of", "just", "waiting", "for", "a", "user", "or", "password", "prompt", "it", "automatically", "initiates", "the", "authorization", "procedure", "by", "sending", "a", "driver", "-", "specific", "command", "." ]
python
train
michael-lazar/rtv
rtv/packages/praw/__init__.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L2347-L2359
def get_multireddit(self, redditor, multi, *args, **kwargs): """Return a Multireddit object for the author and name specified. :param redditor: The username or Redditor object of the user who owns the multireddit. :param multi: The name of the multireddit to fetch. The addi...
[ "def", "get_multireddit", "(", "self", ",", "redditor", ",", "multi", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "objects", ".", "Multireddit", "(", "self", ",", "six", ".", "text_type", "(", "redditor", ")", ",", "multi", ",", "*...
Return a Multireddit object for the author and name specified. :param redditor: The username or Redditor object of the user who owns the multireddit. :param multi: The name of the multireddit to fetch. The additional parameters are passed directly into the :class:`.Multired...
[ "Return", "a", "Multireddit", "object", "for", "the", "author", "and", "name", "specified", "." ]
python
train
Garee/pytodoist
pytodoist/api.py
https://github.com/Garee/pytodoist/blob/3359cbff485ebdbbb4ffbd58d71e21a817874dd7/pytodoist/api.py#L384-L413
def get_redirect_link(self, api_token, **kwargs): """Return the absolute URL to redirect or to open in a browser. The first time the link is used it logs in the user automatically and performs a redirect to a given page. Once used, the link keeps working as a plain redirect. :pa...
[ "def", "get_redirect_link", "(", "self", ",", "api_token", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'token'", ":", "api_token", "}", "return", "self", ".", "_get", "(", "'get_redirect_link'", ",", "params", ",", "*", "*", "kwargs", ")" ]
Return the absolute URL to redirect or to open in a browser. The first time the link is used it logs in the user automatically and performs a redirect to a given page. Once used, the link keeps working as a plain redirect. :param api_token: The user's login api_token. :type api_...
[ "Return", "the", "absolute", "URL", "to", "redirect", "or", "to", "open", "in", "a", "browser", ".", "The", "first", "time", "the", "link", "is", "used", "it", "logs", "in", "the", "user", "automatically", "and", "performs", "a", "redirect", "to", "a", ...
python
train
ff0000/scarlet
scarlet/cms/sites.py
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/sites.py#L299-L342
def index(self, request, extra_context=None): """ Displays the dashboard. Includes the main navigation that the user has permission for as well as the cms log for those sections. The log list can be filtered by those same sections and is paginated. """ da...
[ "def", "index", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "dashboard", "=", "self", ".", "get_dashboard_urls", "(", "request", ")", "dash_blocks", "=", "self", ".", "get_dashboard_blocks", "(", "request", ")", "sections", ",",...
Displays the dashboard. Includes the main navigation that the user has permission for as well as the cms log for those sections. The log list can be filtered by those same sections and is paginated.
[ "Displays", "the", "dashboard", ".", "Includes", "the", "main", "navigation", "that", "the", "user", "has", "permission", "for", "as", "well", "as", "the", "cms", "log", "for", "those", "sections", ".", "The", "log", "list", "can", "be", "filtered", "by", ...
python
train
fboender/ansible-cmdb
lib/mako/runtime.py
https://github.com/fboender/ansible-cmdb/blob/ebd960ac10684e8c9ec2b12751bba2c4c9504ab7/lib/mako/runtime.py#L502-L505
def include_file(self, uri, **kwargs): """Include a file at the given ``uri``.""" _include_file(self.context, uri, self._templateuri, **kwargs)
[ "def", "include_file", "(", "self", ",", "uri", ",", "*", "*", "kwargs", ")", ":", "_include_file", "(", "self", ".", "context", ",", "uri", ",", "self", ".", "_templateuri", ",", "*", "*", "kwargs", ")" ]
Include a file at the given ``uri``.
[ "Include", "a", "file", "at", "the", "given", "uri", "." ]
python
train
nickoala/telepot
telepot/__init__.py
https://github.com/nickoala/telepot/blob/3792fde251d0f1d5a6ca16c8ad1a71f89360c41d/telepot/__init__.py#L25-L57
def flavor(msg): """ Return flavor of message or event. A message's flavor may be one of these: - ``chat`` - ``callback_query`` - ``inline_query`` - ``chosen_inline_result`` - ``shipping_query`` - ``pre_checkout_query`` An event's flavor is determined by the single top-level k...
[ "def", "flavor", "(", "msg", ")", ":", "if", "'message_id'", "in", "msg", ":", "return", "'chat'", "elif", "'id'", "in", "msg", "and", "'chat_instance'", "in", "msg", ":", "return", "'callback_query'", "elif", "'id'", "in", "msg", "and", "'query'", "in", ...
Return flavor of message or event. A message's flavor may be one of these: - ``chat`` - ``callback_query`` - ``inline_query`` - ``chosen_inline_result`` - ``shipping_query`` - ``pre_checkout_query`` An event's flavor is determined by the single top-level key.
[ "Return", "flavor", "of", "message", "or", "event", "." ]
python
train
saltstack/salt
salt/cloud/clouds/opennebula.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/opennebula.py#L3135-L3202
def vm_disk_save(name, kwargs=None, call=None): ''' Sets the disk to be saved in the given image. .. versionadded:: 2016.3.0 name The name of the VM containing the disk to save. disk_id The ID of the disk to save. image_name The name of the new image where the disk wi...
[ "def", "vm_disk_save", "(", "name", ",", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'action'", ":", "raise", "SaltCloudSystemExit", "(", "'The vm_disk_save action must be called with -a or --action.'", ")", "if", "kwargs", "is"...
Sets the disk to be saved in the given image. .. versionadded:: 2016.3.0 name The name of the VM containing the disk to save. disk_id The ID of the disk to save. image_name The name of the new image where the disk will be saved. image_type The type for the new im...
[ "Sets", "the", "disk", "to", "be", "saved", "in", "the", "given", "image", "." ]
python
train
spencerahill/aospy
aospy/automate.py
https://github.com/spencerahill/aospy/blob/2f6e775b9b9956c54af117fdcdce2c87196afb6c/aospy/automate.py#L280-L288
def _submit_calcs_on_client(calcs, client, func): """Submit calculations via dask.bag and a distributed client""" logging.info('Connected to client: {}'.format(client)) if LooseVersion(dask.__version__) < '0.18': dask_option_setter = dask.set_options else: dask_option_setter = dask.confi...
[ "def", "_submit_calcs_on_client", "(", "calcs", ",", "client", ",", "func", ")", ":", "logging", ".", "info", "(", "'Connected to client: {}'", ".", "format", "(", "client", ")", ")", "if", "LooseVersion", "(", "dask", ".", "__version__", ")", "<", "'0.18'",...
Submit calculations via dask.bag and a distributed client
[ "Submit", "calculations", "via", "dask", ".", "bag", "and", "a", "distributed", "client" ]
python
train
atlassian-api/atlassian-python-api
atlassian/confluence.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/confluence.py#L218-L236
def get_all_draft_pages_from_space_through_cql(self, space, start=0, limit=500, status='draft'): """ Search list of draft pages by space key Use case is cleanup old drafts from Confluence :param space: Space Key :param status: Can be changed :param start: OPTIONAL: The st...
[ "def", "get_all_draft_pages_from_space_through_cql", "(", "self", ",", "space", ",", "start", "=", "0", ",", "limit", "=", "500", ",", "status", "=", "'draft'", ")", ":", "url", "=", "'rest/api/content?cql=space=spaceKey={space} and status={status}'", ".", "format", ...
Search list of draft pages by space key Use case is cleanup old drafts from Confluence :param space: Space Key :param status: Can be changed :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit of the number of ...
[ "Search", "list", "of", "draft", "pages", "by", "space", "key", "Use", "case", "is", "cleanup", "old", "drafts", "from", "Confluence", ":", "param", "space", ":", "Space", "Key", ":", "param", "status", ":", "Can", "be", "changed", ":", "param", "start",...
python
train
allenai/allennlp
allennlp/data/vocabulary.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/data/vocabulary.py#L569-L595
def extend_from_instances(self, params: Params, instances: Iterable['adi.Instance'] = ()) -> None: """ Extends an already generated vocabulary using a collection of instances. """ min_count = params.pop("min_count", None) ...
[ "def", "extend_from_instances", "(", "self", ",", "params", ":", "Params", ",", "instances", ":", "Iterable", "[", "'adi.Instance'", "]", "=", "(", ")", ")", "->", "None", ":", "min_count", "=", "params", ".", "pop", "(", "\"min_count\"", ",", "None", ")...
Extends an already generated vocabulary using a collection of instances.
[ "Extends", "an", "already", "generated", "vocabulary", "using", "a", "collection", "of", "instances", "." ]
python
train
wikimedia/ores
ores/scoring_context.py
https://github.com/wikimedia/ores/blob/75599b6ba0172c86d94f7f7e1e05a3c282333a18/ores/scoring_context.py#L95-L101
def _solve_features(self, model_name, dependency_cache=None): """ Solves the vector (`list`) of features for a given model using the `dependency_cache` and returns them. """ features = self[model_name].features return list(self.extractor.solve(features, cache=dependency_c...
[ "def", "_solve_features", "(", "self", ",", "model_name", ",", "dependency_cache", "=", "None", ")", ":", "features", "=", "self", "[", "model_name", "]", ".", "features", "return", "list", "(", "self", ".", "extractor", ".", "solve", "(", "features", ",",...
Solves the vector (`list`) of features for a given model using the `dependency_cache` and returns them.
[ "Solves", "the", "vector", "(", "list", ")", "of", "features", "for", "a", "given", "model", "using", "the", "dependency_cache", "and", "returns", "them", "." ]
python
train
bfontaine/trigrams
trigrams/__init__.py
https://github.com/bfontaine/trigrams/blob/7e3906f7aae83d9b069bd11e611074c56d4e4803/trigrams/__init__.py#L63-L99
def generate(self, **kwargs): """ Generate some text from the database. By default only 70 words are generated, but you can change this using keyword arguments. Keyword arguments: - ``wlen``: maximum length (words) - ``words``: a list of words to use to begin th...
[ "def", "generate", "(", "self", ",", "*", "*", "kwargs", ")", ":", "words", "=", "list", "(", "map", "(", "self", ".", "_sanitize", ",", "kwargs", ".", "get", "(", "'words'", ",", "[", "]", ")", ")", ")", "max_wlen", "=", "kwargs", ".", "get", ...
Generate some text from the database. By default only 70 words are generated, but you can change this using keyword arguments. Keyword arguments: - ``wlen``: maximum length (words) - ``words``: a list of words to use to begin the text with
[ "Generate", "some", "text", "from", "the", "database", ".", "By", "default", "only", "70", "words", "are", "generated", "but", "you", "can", "change", "this", "using", "keyword", "arguments", "." ]
python
train
EnergieID/smappy
smappy/smappy.py
https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L357-L386
def _actuator_on_off(self, on_off, service_location_id, actuator_id, duration=None): """ Turn actuator on or off Parameters ---------- on_off : str 'on' or 'off' service_location_id : int actuator_id : int duration : i...
[ "def", "_actuator_on_off", "(", "self", ",", "on_off", ",", "service_location_id", ",", "actuator_id", ",", "duration", "=", "None", ")", ":", "url", "=", "urljoin", "(", "URLS", "[", "'servicelocation'", "]", ",", "service_location_id", ",", "\"actuator\"", "...
Turn actuator on or off Parameters ---------- on_off : str 'on' or 'off' service_location_id : int actuator_id : int duration : int, optional 300,900,1800 or 3600 , specifying the time in seconds the actuator should be turned on. Any o...
[ "Turn", "actuator", "on", "or", "off" ]
python
train
72squared/redpipe
redpipe/keyspaces.py
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L1776-L1788
def zremrangebylex(self, name, min, max): """ Remove all elements in the sorted set between the lexicographical range specified by ``min`` and ``max``. Returns the number of elements removed. :param name: str the name of the redis key :param min: int or -inf ...
[ "def", "zremrangebylex", "(", "self", ",", "name", ",", "min", ",", "max", ")", ":", "with", "self", ".", "pipe", "as", "pipe", ":", "return", "pipe", ".", "zremrangebylex", "(", "self", ".", "redis_key", "(", "name", ")", ",", "min", ",", "max", "...
Remove all elements in the sorted set between the lexicographical range specified by ``min`` and ``max``. Returns the number of elements removed. :param name: str the name of the redis key :param min: int or -inf :param max: into or +inf :return: Future()
[ "Remove", "all", "elements", "in", "the", "sorted", "set", "between", "the", "lexicographical", "range", "specified", "by", "min", "and", "max", "." ]
python
train
nitmir/django-cas-server
cas_server/views.py
https://github.com/nitmir/django-cas-server/blob/d106181b94c444f1946269da5c20f6c904840ad3/cas_server/views.py#L1125-L1189
def get(self, request): """ method called on GET request on this view :param django.http.HttpRequest request: The current request object: :return: The rendering of ``cas_server/serviceValidate.xml`` if no errors is raised, the rendering or ``cas_server/servic...
[ "def", "get", "(", "self", ",", "request", ")", ":", "# define the class parameters", "self", ".", "request", "=", "request", "self", ".", "service", "=", "request", ".", "GET", ".", "get", "(", "'service'", ")", "self", ".", "ticket", "=", "request", "....
method called on GET request on this view :param django.http.HttpRequest request: The current request object: :return: The rendering of ``cas_server/serviceValidate.xml`` if no errors is raised, the rendering or ``cas_server/serviceValidateError.xml`` otherwise. :rty...
[ "method", "called", "on", "GET", "request", "on", "this", "view" ]
python
train
googleapis/google-cloud-python
bigquery/google/cloud/bigquery/dataset.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/dataset.py#L362-L376
def access_entries(self): """List[google.cloud.bigquery.dataset.AccessEntry]: Dataset's access entries. ``role`` augments the entity type and must be present **unless** the entity type is ``view``. Raises: TypeError: If 'value' is not a sequence ValueErr...
[ "def", "access_entries", "(", "self", ")", ":", "entries", "=", "self", ".", "_properties", ".", "get", "(", "\"access\"", ",", "[", "]", ")", "return", "[", "AccessEntry", ".", "from_api_repr", "(", "entry", ")", "for", "entry", "in", "entries", "]" ]
List[google.cloud.bigquery.dataset.AccessEntry]: Dataset's access entries. ``role`` augments the entity type and must be present **unless** the entity type is ``view``. Raises: TypeError: If 'value' is not a sequence ValueError: If any item in th...
[ "List", "[", "google", ".", "cloud", ".", "bigquery", ".", "dataset", ".", "AccessEntry", "]", ":", "Dataset", "s", "access", "entries", "." ]
python
train
genomoncology/related
src/related/fields.py
https://github.com/genomoncology/related/blob/be47c0081e60fc60afcde3a25f00ebcad5d18510/src/related/fields.py#L13-L27
def BooleanField(default=NOTHING, required=True, repr=True, cmp=True, key=None): """ Create new bool field on a model. :param default: any boolean value :param bool required: whether or not the object is invalid if not provided. :param bool repr: include this field should appear in...
[ "def", "BooleanField", "(", "default", "=", "NOTHING", ",", "required", "=", "True", ",", "repr", "=", "True", ",", "cmp", "=", "True", ",", "key", "=", "None", ")", ":", "default", "=", "_init_fields", ".", "init_default", "(", "required", ",", "defau...
Create new bool field on a model. :param default: any boolean value :param bool required: whether or not the object is invalid if not provided. :param bool repr: include this field should appear in object's repr. :param bool cmp: include this field in generated comparison. :param string key: overri...
[ "Create", "new", "bool", "field", "on", "a", "model", "." ]
python
train
obulpathi/cdn-fastly-python
fastly/__init__.py
https://github.com/obulpathi/cdn-fastly-python/blob/db2564b047e8af4bce72c3b88d6c27d3d0291425/fastly/__init__.py#L537-L540
def get_healthcheck(self, service_id, version_number, name): """Get the healthcheck for a particular service and version.""" content = self._fetch("/service/%s/version/%d/healthcheck/%s" % (service_id, version_number, name)) return FastlyHealthCheck(self, content)
[ "def", "get_healthcheck", "(", "self", ",", "service_id", ",", "version_number", ",", "name", ")", ":", "content", "=", "self", ".", "_fetch", "(", "\"/service/%s/version/%d/healthcheck/%s\"", "%", "(", "service_id", ",", "version_number", ",", "name", ")", ")",...
Get the healthcheck for a particular service and version.
[ "Get", "the", "healthcheck", "for", "a", "particular", "service", "and", "version", "." ]
python
train
mikedh/trimesh
trimesh/transformations.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/transformations.py#L1218-L1272
def quaternion_from_euler(ai, aj, ak, axes='sxyz'): """Return quaternion from Euler angles and axis sequence. ai, aj, ak : Euler's roll, pitch and yaw angles axes : One of 24 axis sequences as string or encoded tuple >>> q = quaternion_from_euler(1, 2, 3, 'ryxz') >>> np.allclose(q, [0.435953, 0.31...
[ "def", "quaternion_from_euler", "(", "ai", ",", "aj", ",", "ak", ",", "axes", "=", "'sxyz'", ")", ":", "try", ":", "firstaxis", ",", "parity", ",", "repetition", ",", "frame", "=", "_AXES2TUPLE", "[", "axes", ".", "lower", "(", ")", "]", "except", "(...
Return quaternion from Euler angles and axis sequence. ai, aj, ak : Euler's roll, pitch and yaw angles axes : One of 24 axis sequences as string or encoded tuple >>> q = quaternion_from_euler(1, 2, 3, 'ryxz') >>> np.allclose(q, [0.435953, 0.310622, -0.718287, 0.444435]) True
[ "Return", "quaternion", "from", "Euler", "angles", "and", "axis", "sequence", "." ]
python
train
webrecorder/pywb
pywb/apps/wbrequestresponse.py
https://github.com/webrecorder/pywb/blob/77f8bb647639dd66f6b92b7a9174c28810e4b1d9/pywb/apps/wbrequestresponse.py#L170-L196
def add_access_control_headers(self, env=None): """Adds Access-Control* HTTP headers to this WbResponse's HTTP headers. :param dict env: The WSGI environment dictionary :return: The same WbResponse but with the values for the Access-Control* HTTP header added :rtype: WbResponse ...
[ "def", "add_access_control_headers", "(", "self", ",", "env", "=", "None", ")", ":", "allowed_methods", "=", "'GET, POST, PUT, OPTIONS, DELETE, PATCH, HEAD, TRACE, CONNECT'", "allowed_origin", "=", "None", "if", "env", "is", "not", "None", ":", "acr_method", "=", "env...
Adds Access-Control* HTTP headers to this WbResponse's HTTP headers. :param dict env: The WSGI environment dictionary :return: The same WbResponse but with the values for the Access-Control* HTTP header added :rtype: WbResponse
[ "Adds", "Access", "-", "Control", "*", "HTTP", "headers", "to", "this", "WbResponse", "s", "HTTP", "headers", "." ]
python
train
fermiPy/fermipy
fermipy/gtanalysis.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/gtanalysis.py#L5508-L5525
def write_weight_map(self, model_name=None): """Save counts model map to a FITS file. """ if model_name is None: suffix = self.config['file_suffix'] else: suffix = '_%s%s' % (model_name, self.config['file_suffix']) self.logger.info('Generating model map...
[ "def", "write_weight_map", "(", "self", ",", "model_name", "=", "None", ")", ":", "if", "model_name", "is", "None", ":", "suffix", "=", "self", ".", "config", "[", "'file_suffix'", "]", "else", ":", "suffix", "=", "'_%s%s'", "%", "(", "model_name", ",", ...
Save counts model map to a FITS file.
[ "Save", "counts", "model", "map", "to", "a", "FITS", "file", "." ]
python
train
noahbenson/neuropythy
neuropythy/geometry/util.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/geometry/util.py#L120-L134
def point_on_line(ab, c): ''' point_on_line((a,b), c) yields True if point x is on line (a,b) and False otherwise. ''' (a,b) = ab abc = [np.asarray(u) for u in (a,b,c)] if any(len(u.shape) == 2 for u in abc): (a,b,c) = [np.reshape(u,(len(u),-1)) for u in abc] else: ...
[ "def", "point_on_line", "(", "ab", ",", "c", ")", ":", "(", "a", ",", "b", ")", "=", "ab", "abc", "=", "[", "np", ".", "asarray", "(", "u", ")", "for", "u", "in", "(", "a", ",", "b", ",", "c", ")", "]", "if", "any", "(", "len", "(", "u"...
point_on_line((a,b), c) yields True if point x is on line (a,b) and False otherwise.
[ "point_on_line", "((", "a", "b", ")", "c", ")", "yields", "True", "if", "point", "x", "is", "on", "line", "(", "a", "b", ")", "and", "False", "otherwise", "." ]
python
train
pyopenapi/pyswagger
pyswagger/utils.py
https://github.com/pyopenapi/pyswagger/blob/333c4ca08e758cd2194943d9904a3eda3fe43977/pyswagger/utils.py#L232-L242
def jp_compose(s, base=None): """ append/encode a string to json-pointer """ if s == None: return base ss = [s] if isinstance(s, six.string_types) else s ss = [s.replace('~', '~0').replace('/', '~1') for s in ss] if base: ss.insert(0, base) return '/'.join(ss)
[ "def", "jp_compose", "(", "s", ",", "base", "=", "None", ")", ":", "if", "s", "==", "None", ":", "return", "base", "ss", "=", "[", "s", "]", "if", "isinstance", "(", "s", ",", "six", ".", "string_types", ")", "else", "s", "ss", "=", "[", "s", ...
append/encode a string to json-pointer
[ "append", "/", "encode", "a", "string", "to", "json", "-", "pointer" ]
python
train
Fantomas42/django-blog-zinnia
zinnia/templatetags/zinnia.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/templatetags/zinnia.py#L65-L72
def get_categories_tree(context, template='zinnia/tags/categories_tree.html'): """ Return the categories as a tree. """ return {'template': template, 'categories': Category.objects.all().annotate( count_entries=Count('entries')), 'context_category': context.get('c...
[ "def", "get_categories_tree", "(", "context", ",", "template", "=", "'zinnia/tags/categories_tree.html'", ")", ":", "return", "{", "'template'", ":", "template", ",", "'categories'", ":", "Category", ".", "objects", ".", "all", "(", ")", ".", "annotate", "(", ...
Return the categories as a tree.
[ "Return", "the", "categories", "as", "a", "tree", "." ]
python
train
Rambatino/CHAID
CHAID/column.py
https://github.com/Rambatino/CHAID/blob/dc19e41ebdf2773168733efdf0d7579950c8d2e7/CHAID/column.py#L104-L136
def substitute_values(self, vect): """ Internal method to substitute integers into the vector, and construct metadata to convert back to the original vector. np.nan is always given -1, all other objects are given integers in order of apperence. Parameters ------...
[ "def", "substitute_values", "(", "self", ",", "vect", ")", ":", "try", ":", "unique", "=", "np", ".", "unique", "(", "vect", ")", "except", ":", "unique", "=", "set", "(", "vect", ")", "unique", "=", "[", "x", "for", "x", "in", "unique", "if", "n...
Internal method to substitute integers into the vector, and construct metadata to convert back to the original vector. np.nan is always given -1, all other objects are given integers in order of apperence. Parameters ---------- vect : np.array the vector in ...
[ "Internal", "method", "to", "substitute", "integers", "into", "the", "vector", "and", "construct", "metadata", "to", "convert", "back", "to", "the", "original", "vector", "." ]
python
train
madsbk/lrcloud
lrcloud/__main__.py
https://github.com/madsbk/lrcloud/blob/8d99be3e1abdf941642e9a1c86b7d775dc373c0b/lrcloud/__main__.py#L74-L81
def hashsum(filename): """Return a hash of the file From <http://stackoverflow.com/a/7829658>""" with open(filename, mode='rb') as f: d = hashlib.sha1() for buf in iter(partial(f.read, 2**20), b''): d.update(buf) return d.hexdigest()
[ "def", "hashsum", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "mode", "=", "'rb'", ")", "as", "f", ":", "d", "=", "hashlib", ".", "sha1", "(", ")", "for", "buf", "in", "iter", "(", "partial", "(", "f", ".", "read", ",", "2"...
Return a hash of the file From <http://stackoverflow.com/a/7829658>
[ "Return", "a", "hash", "of", "the", "file", "From", "<http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "7829658", ">" ]
python
valid
cprogrammer1994/ModernGL.ext.obj
ModernGL/ext/obj/objects.py
https://github.com/cprogrammer1994/ModernGL.ext.obj/blob/84ef626166dc9a2520512158f1746c8bac0d95d2/ModernGL/ext/obj/objects.py#L83-L174
def fromstring(data) -> 'Obj': ''' Args: data (str): The obj file content. Returns: Obj: The object. Examples: .. code-block:: python import ModernGL from ModernGL.ext import obj ...
[ "def", "fromstring", "(", "data", ")", "->", "'Obj'", ":", "vert", "=", "[", "]", "text", "=", "[", "]", "norm", "=", "[", "]", "face", "=", "[", "]", "data", "=", "RE_COMMENT", ".", "sub", "(", "'\\n'", ",", "data", ")", "for", "line", "in", ...
Args: data (str): The obj file content. Returns: Obj: The object. Examples: .. code-block:: python import ModernGL from ModernGL.ext import obj content = open('box.obj').read() ...
[ "Args", ":", "data", "(", "str", ")", ":", "The", "obj", "file", "content", "." ]
python
train
relwell/corenlp-xml-lib
corenlp_xml/document.py
https://github.com/relwell/corenlp-xml-lib/blob/9b0f8c912ba3ecedd34473f74a9f2d033a75baf9/corenlp_xml/document.py#L261-L273
def collapsed_dependencies(self): """ Accessess collapsed dependencies for this sentence :getter: Returns the dependency graph for collapsed dependencies :type: corenlp_xml.dependencies.DependencyGraph """ if self._basic_dependencies is None: deps = self._el...
[ "def", "collapsed_dependencies", "(", "self", ")", ":", "if", "self", ".", "_basic_dependencies", "is", "None", ":", "deps", "=", "self", ".", "_element", ".", "xpath", "(", "'dependencies[@type=\"collapsed-dependencies\"]'", ")", "if", "len", "(", "deps", ")", ...
Accessess collapsed dependencies for this sentence :getter: Returns the dependency graph for collapsed dependencies :type: corenlp_xml.dependencies.DependencyGraph
[ "Accessess", "collapsed", "dependencies", "for", "this", "sentence" ]
python
train
SmokinCaterpillar/pypet
pypet/trajectory.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/trajectory.py#L1306-L1420
def f_explore(self, build_dict): """Prepares the trajectory to explore the parameter space. To explore the parameter space you need to provide a dictionary with the names of the parameters to explore as keys and iterables specifying the exploration ranges as values. All iterables need...
[ "def", "f_explore", "(", "self", ",", "build_dict", ")", ":", "for", "run_idx", "in", "range", "(", "len", "(", "self", ")", ")", ":", "if", "self", ".", "f_is_completed", "(", "run_idx", ")", ":", "raise", "TypeError", "(", "'You cannot explore a trajecto...
Prepares the trajectory to explore the parameter space. To explore the parameter space you need to provide a dictionary with the names of the parameters to explore as keys and iterables specifying the exploration ranges as values. All iterables need to have the same length otherwise a ValueEr...
[ "Prepares", "the", "trajectory", "to", "explore", "the", "parameter", "space", "." ]
python
test
cloud9ers/gurumate
environment/lib/python2.7/site-packages/psutil/_pslinux.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/psutil/_pslinux.py#L197-L214
def get_system_per_cpu_times(): """Return a list of namedtuple representing the CPU times for every CPU available on the system. """ cpus = [] f = open('/proc/stat', 'r') # get rid of the first line who refers to system wide CPU stats try: f.readline() for line in f.readlines...
[ "def", "get_system_per_cpu_times", "(", ")", ":", "cpus", "=", "[", "]", "f", "=", "open", "(", "'/proc/stat'", ",", "'r'", ")", "# get rid of the first line who refers to system wide CPU stats", "try", ":", "f", ".", "readline", "(", ")", "for", "line", "in", ...
Return a list of namedtuple representing the CPU times for every CPU available on the system.
[ "Return", "a", "list", "of", "namedtuple", "representing", "the", "CPU", "times", "for", "every", "CPU", "available", "on", "the", "system", "." ]
python
test
icometrix/dicom2nifti
scripts/shrink_singleframe.py
https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/scripts/shrink_singleframe.py#L16-L72
def _shrink_file(dicom_file_in, subsample_factor): """ Anonimize a single dicomfile :param dicom_file_in: filepath for input file :param dicom_file_out: filepath for output file :param fields_to_keep: dicom tags to keep """ # Default meta_fields # Required fields according to reference ...
[ "def", "_shrink_file", "(", "dicom_file_in", ",", "subsample_factor", ")", ":", "# Default meta_fields", "# Required fields according to reference", "dicom_file_out", "=", "dicom_file_in", "# Load dicom_file_in", "dicom_in", "=", "compressed_dicom", ".", "read_file", "(", "di...
Anonimize a single dicomfile :param dicom_file_in: filepath for input file :param dicom_file_out: filepath for output file :param fields_to_keep: dicom tags to keep
[ "Anonimize", "a", "single", "dicomfile", ":", "param", "dicom_file_in", ":", "filepath", "for", "input", "file", ":", "param", "dicom_file_out", ":", "filepath", "for", "output", "file", ":", "param", "fields_to_keep", ":", "dicom", "tags", "to", "keep" ]
python
train
spyder-ide/spyder
spyder/plugins/workingdirectory/plugin.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/workingdirectory/plugin.py#L171-L178
def save_wdhistory(self): """Save history to a text file in user home directory""" text = [ to_text_string( self.pathedit.itemText(index) ) \ for index in range(self.pathedit.count()) ] try: encoding.writelines(text, self.LOG_PATH) except EnvironmentErr...
[ "def", "save_wdhistory", "(", "self", ")", ":", "text", "=", "[", "to_text_string", "(", "self", ".", "pathedit", ".", "itemText", "(", "index", ")", ")", "for", "index", "in", "range", "(", "self", ".", "pathedit", ".", "count", "(", ")", ")", "]", ...
Save history to a text file in user home directory
[ "Save", "history", "to", "a", "text", "file", "in", "user", "home", "directory" ]
python
train
numenta/htmresearch
projects/sdr_paper/pytorch_experiments/union_experiment.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/sdr_paper/pytorch_experiments/union_experiment.py#L44-L76
def create_union_mnist_dataset(): """ Create a UnionDataset composed of two versions of the MNIST datasets where each item in the dataset contains 2 distinct images superimposed """ transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081...
[ "def", "create_union_mnist_dataset", "(", ")", ":", "transform", "=", "transforms", ".", "Compose", "(", "[", "transforms", ".", "ToTensor", "(", ")", ",", "transforms", ".", "Normalize", "(", "(", "0.1307", ",", ")", ",", "(", "0.3081", ",", ")", ")", ...
Create a UnionDataset composed of two versions of the MNIST datasets where each item in the dataset contains 2 distinct images superimposed
[ "Create", "a", "UnionDataset", "composed", "of", "two", "versions", "of", "the", "MNIST", "datasets", "where", "each", "item", "in", "the", "dataset", "contains", "2", "distinct", "images", "superimposed" ]
python
train
ArchiveTeam/wpull
wpull/scraper/html.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/scraper/html.py#L656-L663
def is_html_link(cls, tag, attribute): '''Return whether the link is likely to be external object.''' if tag in cls.TAG_ATTRIBUTES \ and attribute in cls.TAG_ATTRIBUTES[tag]: attr_flags = cls.TAG_ATTRIBUTES[tag][attribute] return attr_flags & cls.ATTR_HTML ret...
[ "def", "is_html_link", "(", "cls", ",", "tag", ",", "attribute", ")", ":", "if", "tag", "in", "cls", ".", "TAG_ATTRIBUTES", "and", "attribute", "in", "cls", ".", "TAG_ATTRIBUTES", "[", "tag", "]", ":", "attr_flags", "=", "cls", ".", "TAG_ATTRIBUTES", "["...
Return whether the link is likely to be external object.
[ "Return", "whether", "the", "link", "is", "likely", "to", "be", "external", "object", "." ]
python
train
wakatime/wakatime
wakatime/arguments.py
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/arguments.py#L340-L364
def boolean_or_list(config_name, args, configs, alternative_names=[]): """Get a boolean or list of regexes from args and configs.""" # when argument flag present, set to wildcard regex for key in alternative_names + [config_name]: if hasattr(args, key) and getattr(args, key): setattr(ar...
[ "def", "boolean_or_list", "(", "config_name", ",", "args", ",", "configs", ",", "alternative_names", "=", "[", "]", ")", ":", "# when argument flag present, set to wildcard regex", "for", "key", "in", "alternative_names", "+", "[", "config_name", "]", ":", "if", "...
Get a boolean or list of regexes from args and configs.
[ "Get", "a", "boolean", "or", "list", "of", "regexes", "from", "args", "and", "configs", "." ]
python
train
mozilla/mozdownload
mozdownload/parser.py
https://github.com/mozilla/mozdownload/blob/97796a028455bb5200434562d23b66d5a5eb537b/mozdownload/parser.py#L53-L59
def filter(self, filter): """Filter entries by calling function or applying regex.""" if hasattr(filter, '__call__'): return [entry for entry in self.entries if filter(entry)] else: pattern = re.compile(filter, re.IGNORECASE) return [entry for entry in self.en...
[ "def", "filter", "(", "self", ",", "filter", ")", ":", "if", "hasattr", "(", "filter", ",", "'__call__'", ")", ":", "return", "[", "entry", "for", "entry", "in", "self", ".", "entries", "if", "filter", "(", "entry", ")", "]", "else", ":", "pattern", ...
Filter entries by calling function or applying regex.
[ "Filter", "entries", "by", "calling", "function", "or", "applying", "regex", "." ]
python
train
dsoprea/PySchedules
pyschedules/examples/read.py
https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/examples/read.py#L55-L61
def new_lineup(self, name, location, device, _type, postalCode, _id): """Callback run for each new lineup""" if self.__v_lineup: # [Lineup: Comcast West Palm Beach /Palm Beach Co., West Palm Beach, Digital, CableDigital, 33436, FL09567:X] print("[Lineup: %s, %s, %s, %s, %s, %s]"...
[ "def", "new_lineup", "(", "self", ",", "name", ",", "location", ",", "device", ",", "_type", ",", "postalCode", ",", "_id", ")", ":", "if", "self", ".", "__v_lineup", ":", "# [Lineup: Comcast West Palm Beach /Palm Beach Co., West Palm Beach, Digital, CableDigital, 33436...
Callback run for each new lineup
[ "Callback", "run", "for", "each", "new", "lineup" ]
python
train
Fantomas42/django-blog-zinnia
zinnia/spam_checker/__init__.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/spam_checker/__init__.py#L10-L25
def get_spam_checker(backend_path): """ Return the selected spam checker backend. """ try: backend_module = import_module(backend_path) backend = getattr(backend_module, 'backend') except (ImportError, AttributeError): warnings.warn('%s backend cannot be imported' % backend_p...
[ "def", "get_spam_checker", "(", "backend_path", ")", ":", "try", ":", "backend_module", "=", "import_module", "(", "backend_path", ")", "backend", "=", "getattr", "(", "backend_module", ",", "'backend'", ")", "except", "(", "ImportError", ",", "AttributeError", ...
Return the selected spam checker backend.
[ "Return", "the", "selected", "spam", "checker", "backend", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/image_utils.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/image_utils.py#L43-L62
def image_to_tf_summary_value(image, tag): """Converts a NumPy image to a tf.Summary.Value object. Args: image: 3-D NumPy array. tag: name for tf.Summary.Value for display in tensorboard. Returns: image_summary: A tf.Summary.Value object. """ curr_image = np.asarray(image, dtype=np.uint8) heigh...
[ "def", "image_to_tf_summary_value", "(", "image", ",", "tag", ")", ":", "curr_image", "=", "np", ".", "asarray", "(", "image", ",", "dtype", "=", "np", ".", "uint8", ")", "height", ",", "width", ",", "n_channels", "=", "curr_image", ".", "shape", "# If m...
Converts a NumPy image to a tf.Summary.Value object. Args: image: 3-D NumPy array. tag: name for tf.Summary.Value for display in tensorboard. Returns: image_summary: A tf.Summary.Value object.
[ "Converts", "a", "NumPy", "image", "to", "a", "tf", ".", "Summary", ".", "Value", "object", "." ]
python
train
cltk/cltk
cltk/phonology/old_english/phonology.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/phonology/old_english/phonology.py#L283-L306
def ascii_encoding(self): """ :return: str: Returns the ASCII-encoded string Thorn (Þ, þ) and Ash(Æ, æ) are substituted by the digraphs 'th' and 'ae' respectively. Wynn(Ƿ, ƿ) and Eth(Ð, ð) are replaced by 'w' and 'd'. Examples: >>> Word('ġelǣd').ascii_encod...
[ "def", "ascii_encoding", "(", "self", ")", ":", "w", "=", "self", ".", "remove_diacritics", "(", ")", "for", "k", ",", "val", "in", "zip", "(", "Normalize", ".", "keys", "(", ")", ",", "Normalize", ".", "values", "(", ")", ")", ":", "w", "=", "w"...
:return: str: Returns the ASCII-encoded string Thorn (Þ, þ) and Ash(Æ, æ) are substituted by the digraphs 'th' and 'ae' respectively. Wynn(Ƿ, ƿ) and Eth(Ð, ð) are replaced by 'w' and 'd'. Examples: >>> Word('ġelǣd').ascii_encoding() 'gelaed' >>> Wo...
[ ":", "return", ":", "str", ":", "Returns", "the", "ASCII", "-", "encoded", "string" ]
python
train
yunojuno/elasticsearch-django
elasticsearch_django/models.py
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L565-L617
def execute_search( search, search_terms="", user=None, reference="", save=True, query_type=SearchQuery.QUERY_TYPE_SEARCH, ): """ Create a new SearchQuery instance and execute a search against ES. Args: search: elasticsearch.search.Search object, that internally contains ...
[ "def", "execute_search", "(", "search", ",", "search_terms", "=", "\"\"", ",", "user", "=", "None", ",", "reference", "=", "\"\"", ",", "save", "=", "True", ",", "query_type", "=", "SearchQuery", ".", "QUERY_TYPE_SEARCH", ",", ")", ":", "start", "=", "ti...
Create a new SearchQuery instance and execute a search against ES. Args: search: elasticsearch.search.Search object, that internally contains the connection and query; this is the query that is executed. All we are doing is logging the input and parsing the output. search_te...
[ "Create", "a", "new", "SearchQuery", "instance", "and", "execute", "a", "search", "against", "ES", "." ]
python
train
JarryShaw/f2format
src/core.py
https://github.com/JarryShaw/f2format/blob/a144250268247ce0a98d734a26d53faadff7a6f8/src/core.py#L199-L225
def f2format(filename): """Wrapper works for conversion. Args: - filename -- str, file to be converted """ print('Now converting %r...' % filename) # fetch encoding encoding = os.getenv('F2FORMAT_ENCODING', LOCALE_ENCODING) lineno = dict() # line number -> file offset conten...
[ "def", "f2format", "(", "filename", ")", ":", "print", "(", "'Now converting %r...'", "%", "filename", ")", "# fetch encoding", "encoding", "=", "os", ".", "getenv", "(", "'F2FORMAT_ENCODING'", ",", "LOCALE_ENCODING", ")", "lineno", "=", "dict", "(", ")", "# l...
Wrapper works for conversion. Args: - filename -- str, file to be converted
[ "Wrapper", "works", "for", "conversion", "." ]
python
train
djgagne/hagelslag
hagelslag/evaluation/ProbabilityMetrics.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/ProbabilityMetrics.py#L194-L212
def from_str(self, in_str): """ Read the DistributedROC string and parse the contingency table values from it. Args: in_str (str): The string output from the __str__ method """ parts = in_str.split(";") for part in parts: var_name, value = part.sp...
[ "def", "from_str", "(", "self", ",", "in_str", ")", ":", "parts", "=", "in_str", ".", "split", "(", "\";\"", ")", "for", "part", "in", "parts", ":", "var_name", ",", "value", "=", "part", ".", "split", "(", "\":\"", ")", "if", "var_name", "==", "\"...
Read the DistributedROC string and parse the contingency table values from it. Args: in_str (str): The string output from the __str__ method
[ "Read", "the", "DistributedROC", "string", "and", "parse", "the", "contingency", "table", "values", "from", "it", "." ]
python
train
saltstack/salt
salt/output/highstate.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/highstate.py#L554-L595
def _format_terse(tcolor, comps, ret, colors, tabular): ''' Terse formatting of a message. ''' result = 'Clean' if ret['changes']: result = 'Changed' if ret['result'] is False: result = 'Failed' elif ret['result'] is None: result = 'Differs' if tabular is True: ...
[ "def", "_format_terse", "(", "tcolor", ",", "comps", ",", "ret", ",", "colors", ",", "tabular", ")", ":", "result", "=", "'Clean'", "if", "ret", "[", "'changes'", "]", ":", "result", "=", "'Changed'", "if", "ret", "[", "'result'", "]", "is", "False", ...
Terse formatting of a message.
[ "Terse", "formatting", "of", "a", "message", "." ]
python
train
saltstack/salt
salt/states/win_iis.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_iis.py#L733-L780
def remove_vdir(name, site, app='/'): ''' Remove an IIS virtual directory. :param str name: The virtual directory name. :param str site: The IIS site name. :param str app: The IIS application. Example of usage with only the required arguments: .. code-block:: yaml site0-foo-vdir-...
[ "def", "remove_vdir", "(", "name", ",", "site", ",", "app", "=", "'/'", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'comment'", ":", "str", "(", ")", ",", "'result'", ":", "None", "}", "current_vdirs", ...
Remove an IIS virtual directory. :param str name: The virtual directory name. :param str site: The IIS site name. :param str app: The IIS application. Example of usage with only the required arguments: .. code-block:: yaml site0-foo-vdir-remove: win_iis.remove_vdir: ...
[ "Remove", "an", "IIS", "virtual", "directory", "." ]
python
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4122-L4127
def multiplyC(self, alpha): """multiply C with a scalar and update all related internal variables (dC, D,...)""" self.C *= alpha if self.dC is not self.C: self.dC *= alpha self.D *= alpha**0.5
[ "def", "multiplyC", "(", "self", ",", "alpha", ")", ":", "self", ".", "C", "*=", "alpha", "if", "self", ".", "dC", "is", "not", "self", ".", "C", ":", "self", ".", "dC", "*=", "alpha", "self", ".", "D", "*=", "alpha", "**", "0.5" ]
multiply C with a scalar and update all related internal variables (dC, D,...)
[ "multiply", "C", "with", "a", "scalar", "and", "update", "all", "related", "internal", "variables", "(", "dC", "D", "...", ")" ]
python
train
eng-tools/sfsimodels
sfsimodels/models/soils.py
https://github.com/eng-tools/sfsimodels/blob/65a690ca440d61307f5a9b8478e4704f203a5925/sfsimodels/models/soils.py#L1125-L1158
def one_vertical_total_stress(self, z_c): """ Determine the vertical total stress at a single depth z_c. :param z_c: depth from surface """ total_stress = 0.0 depths = self.depths end = 0 for layer_int in range(1, len(depths) + 1): l_index = l...
[ "def", "one_vertical_total_stress", "(", "self", ",", "z_c", ")", ":", "total_stress", "=", "0.0", "depths", "=", "self", ".", "depths", "end", "=", "0", "for", "layer_int", "in", "range", "(", "1", ",", "len", "(", "depths", ")", "+", "1", ")", ":",...
Determine the vertical total stress at a single depth z_c. :param z_c: depth from surface
[ "Determine", "the", "vertical", "total", "stress", "at", "a", "single", "depth", "z_c", "." ]
python
train
raphaelvallat/pingouin
pingouin/external/tabulate.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/external/tabulate.py#L751-L769
def _align_header(header, alignment, width, visible_width, is_multiline=False, width_fn=None): "Pad string header to width chars given known visible_width of the header." if is_multiline: header_lines = re.split(_multiline_codes, header) padded_lines = [_align_header(h, alignme...
[ "def", "_align_header", "(", "header", ",", "alignment", ",", "width", ",", "visible_width", ",", "is_multiline", "=", "False", ",", "width_fn", "=", "None", ")", ":", "if", "is_multiline", ":", "header_lines", "=", "re", ".", "split", "(", "_multiline_codes...
Pad string header to width chars given known visible_width of the header.
[ "Pad", "string", "header", "to", "width", "chars", "given", "known", "visible_width", "of", "the", "header", "." ]
python
train
carpedm20/fbchat
fbchat/_client.py
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1407-L1444
def quickReply(self, quick_reply, payload=None, thread_id=None, thread_type=None): """ Replies to a chosen quick reply :param quick_reply: Quick reply to reply to :param payload: Optional answer to the quick reply :param thread_id: User/Group ID to send to. See :ref:`intro_threa...
[ "def", "quickReply", "(", "self", ",", "quick_reply", ",", "payload", "=", "None", ",", "thread_id", "=", "None", ",", "thread_type", "=", "None", ")", ":", "quick_reply", ".", "is_response", "=", "True", "if", "isinstance", "(", "quick_reply", ",", "Quick...
Replies to a chosen quick reply :param quick_reply: Quick reply to reply to :param payload: Optional answer to the quick reply :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type quick_reply: models.QuickReply ...
[ "Replies", "to", "a", "chosen", "quick", "reply" ]
python
train
openpaperwork/paperwork-backend
paperwork_backend/index.py
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/index.py#L495-L504
def get(self, obj_id): """ Get a document or a page using its ID Won't instantiate them if they are not yet available """ if BasicPage.PAGE_ID_SEPARATOR in obj_id: (docid, page_nb) = obj_id.split(BasicPage.PAGE_ID_SEPARATOR) page_nb = int(page_nb) ...
[ "def", "get", "(", "self", ",", "obj_id", ")", ":", "if", "BasicPage", ".", "PAGE_ID_SEPARATOR", "in", "obj_id", ":", "(", "docid", ",", "page_nb", ")", "=", "obj_id", ".", "split", "(", "BasicPage", ".", "PAGE_ID_SEPARATOR", ")", "page_nb", "=", "int", ...
Get a document or a page using its ID Won't instantiate them if they are not yet available
[ "Get", "a", "document", "or", "a", "page", "using", "its", "ID", "Won", "t", "instantiate", "them", "if", "they", "are", "not", "yet", "available" ]
python
train
althonos/pronto
pronto/ontology.py
https://github.com/althonos/pronto/blob/a768adcba19fb34f26f67cde4a03d317f932c274/pronto/ontology.py#L487-L529
def _obo_meta(self): """Generate the obo metadata header and updates metadata. When called, this method will create appropriate values for the ``auto-generated-by`` and ``date`` fields. Note: Generated following specs of the unofficial format guide: ftp://ftp.ge...
[ "def", "_obo_meta", "(", "self", ")", ":", "metatags", "=", "(", "\"format-version\"", ",", "\"data-version\"", ",", "\"date\"", ",", "\"saved-by\"", ",", "\"auto-generated-by\"", ",", "\"import\"", ",", "\"subsetdef\"", ",", "\"synonymtypedef\"", ",", "\"default-na...
Generate the obo metadata header and updates metadata. When called, this method will create appropriate values for the ``auto-generated-by`` and ``date`` fields. Note: Generated following specs of the unofficial format guide: ftp://ftp.geneontology.org/pub/go/www/GO.for...
[ "Generate", "the", "obo", "metadata", "header", "and", "updates", "metadata", "." ]
python
train
mikedh/trimesh
trimesh/path/exchange/dxf.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/path/exchange/dxf.py#L66-L481
def load_dxf(file_obj, **kwargs): """ Load a DXF file to a dictionary containing vertices and entities. Parameters ---------- file_obj: file or file- like object (has object.read method) Returns ---------- result: dict, keys are entities, vertices and metadata """ def inf...
[ "def", "load_dxf", "(", "file_obj", ",", "*", "*", "kwargs", ")", ":", "def", "info", "(", "e", ")", ":", "\"\"\"\n Pull metadata based on group code, and return as a dict.\n \"\"\"", "# which keys should we extract from the entity data", "# DXF group code : our met...
Load a DXF file to a dictionary containing vertices and entities. Parameters ---------- file_obj: file or file- like object (has object.read method) Returns ---------- result: dict, keys are entities, vertices and metadata
[ "Load", "a", "DXF", "file", "to", "a", "dictionary", "containing", "vertices", "and", "entities", "." ]
python
train
ramses-tech/nefertari
nefertari/renderers.py
https://github.com/ramses-tech/nefertari/blob/c7caffe11576c11aa111adbdbadeff70ce66b1dd/nefertari/renderers.py#L96-L102
def _get_create_update_kwargs(self, value, common_kw): """ Get kwargs common to create, update, replace. """ kw = common_kw.copy() kw['body'] = value if '_self' in value: kw['headers'] = [('Location', value['_self'])] return kw
[ "def", "_get_create_update_kwargs", "(", "self", ",", "value", ",", "common_kw", ")", ":", "kw", "=", "common_kw", ".", "copy", "(", ")", "kw", "[", "'body'", "]", "=", "value", "if", "'_self'", "in", "value", ":", "kw", "[", "'headers'", "]", "=", "...
Get kwargs common to create, update, replace.
[ "Get", "kwargs", "common", "to", "create", "update", "replace", "." ]
python
train
serkanyersen/underscore.py
src/underscore.py
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L973-L982
def functions(self): """ Return a sorted list of the function names available on the object. """ names = [] for i, k in enumerate(self.obj): if _(self.obj[k]).isCallable(): names.append(k) return self._wrap(sorted(names))
[ "def", "functions", "(", "self", ")", ":", "names", "=", "[", "]", "for", "i", ",", "k", "in", "enumerate", "(", "self", ".", "obj", ")", ":", "if", "_", "(", "self", ".", "obj", "[", "k", "]", ")", ".", "isCallable", "(", ")", ":", "names", ...
Return a sorted list of the function names available on the object.
[ "Return", "a", "sorted", "list", "of", "the", "function", "names", "available", "on", "the", "object", "." ]
python
train