repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
IBMStreams/pypi.streamsx
streamsx/rest_primitives.py
ApplicationConfiguration.update
def update(self, properties=None, description=None): """Update this application configuration. To create or update a property provide its key-value pair in `properties`. To delete a property provide its key with the value ``None`` in properties. Args: prope...
python
def update(self, properties=None, description=None): """Update this application configuration. To create or update a property provide its key-value pair in `properties`. To delete a property provide its key with the value ``None`` in properties. Args: prope...
[ "def", "update", "(", "self", ",", "properties", "=", "None", ",", "description", "=", "None", ")", ":", "cv", "=", "ApplicationConfiguration", ".", "_props", "(", "properties", "=", "properties", ",", "description", "=", "description", ")", "res", "=", "s...
Update this application configuration. To create or update a property provide its key-value pair in `properties`. To delete a property provide its key with the value ``None`` in properties. Args: properties (dict): Property values to be updated. If ``None`` the pro...
[ "Update", "this", "application", "configuration", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest_primitives.py#L2465-L2488
IBMStreams/pypi.streamsx
streamsx/rest_primitives.py
ApplicationConfiguration.delete
def delete(self): """Delete this application configuration. """ res = self.rest_client.session.delete(self.rest_self) _handle_http_errors(res)
python
def delete(self): """Delete this application configuration. """ res = self.rest_client.session.delete(self.rest_self) _handle_http_errors(res)
[ "def", "delete", "(", "self", ")", ":", "res", "=", "self", ".", "rest_client", ".", "session", ".", "delete", "(", "self", ".", "rest_self", ")", "_handle_http_errors", "(", "res", ")" ]
Delete this application configuration.
[ "Delete", "this", "application", "configuration", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest_primitives.py#L2490-L2494
IBMStreams/pypi.streamsx
streamsx/topology/schema.py
_normalize
def _normalize(schema, allow_none=True): """ Normalize a schema. """ if allow_none and schema is None: return schema if isinstance(schema, CommonSchema): return schema if isinstance(schema, StreamSchema): return schema if isinstance(schema, basestring): retur...
python
def _normalize(schema, allow_none=True): """ Normalize a schema. """ if allow_none and schema is None: return schema if isinstance(schema, CommonSchema): return schema if isinstance(schema, StreamSchema): return schema if isinstance(schema, basestring): retur...
[ "def", "_normalize", "(", "schema", ",", "allow_none", "=", "True", ")", ":", "if", "allow_none", "and", "schema", "is", "None", ":", "return", "schema", "if", "isinstance", "(", "schema", ",", "CommonSchema", ")", ":", "return", "schema", "if", "isinstanc...
Normalize a schema.
[ "Normalize", "a", "schema", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L103-L134
IBMStreams/pypi.streamsx
streamsx/topology/schema.py
is_common
def is_common(schema): """ Is `schema` an common schema. Args: schema: Scheme to test. Returns: bool: ``True`` if schema is a common schema, otherwise ``False``. """ if isinstance(schema, StreamSchema): return schema.schema() in _SCHEMA_COMMON if isinstance(schema,...
python
def is_common(schema): """ Is `schema` an common schema. Args: schema: Scheme to test. Returns: bool: ``True`` if schema is a common schema, otherwise ``False``. """ if isinstance(schema, StreamSchema): return schema.schema() in _SCHEMA_COMMON if isinstance(schema,...
[ "def", "is_common", "(", "schema", ")", ":", "if", "isinstance", "(", "schema", ",", "StreamSchema", ")", ":", "return", "schema", ".", "schema", "(", ")", "in", "_SCHEMA_COMMON", "if", "isinstance", "(", "schema", ",", "CommonSchema", ")", ":", "return", ...
Is `schema` an common schema. Args: schema: Scheme to test. Returns: bool: ``True`` if schema is a common schema, otherwise ``False``.
[ "Is", "schema", "an", "common", "schema", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L136-L153
IBMStreams/pypi.streamsx
streamsx/topology/schema.py
StreamSchema._set
def _set(self, schema): """Set a schema from another schema""" if isinstance(schema, CommonSchema): self._spl_type = False self._schema = schema.schema() self._style = self._default_style() else: self._spl_type = schema._spl_type self._...
python
def _set(self, schema): """Set a schema from another schema""" if isinstance(schema, CommonSchema): self._spl_type = False self._schema = schema.schema() self._style = self._default_style() else: self._spl_type = schema._spl_type self._...
[ "def", "_set", "(", "self", ",", "schema", ")", ":", "if", "isinstance", "(", "schema", ",", "CommonSchema", ")", ":", "self", ".", "_spl_type", "=", "False", "self", ".", "_schema", "=", "schema", ".", "schema", "(", ")", "self", ".", "_style", "=",...
Set a schema from another schema
[ "Set", "a", "schema", "from", "another", "schema" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L464-L473
IBMStreams/pypi.streamsx
streamsx/topology/schema.py
StreamSchema.as_tuple
def as_tuple(self, named=None): """ Create a structured schema that will pass stream tuples into callables as ``tuple`` instances. If this instance represents a common schema then it will be returned without modification. Stream tuples with common schemas are always passed accor...
python
def as_tuple(self, named=None): """ Create a structured schema that will pass stream tuples into callables as ``tuple`` instances. If this instance represents a common schema then it will be returned without modification. Stream tuples with common schemas are always passed accor...
[ "def", "as_tuple", "(", "self", ",", "named", "=", "None", ")", ":", "if", "not", "named", ":", "return", "self", ".", "_copy", "(", "tuple", ")", "if", "named", "==", "True", "or", "isinstance", "(", "named", ",", "basestring", ")", ":", "return", ...
Create a structured schema that will pass stream tuples into callables as ``tuple`` instances. If this instance represents a common schema then it will be returned without modification. Stream tuples with common schemas are always passed according to their definition. **Passing as tupl...
[ "Create", "a", "structured", "schema", "that", "will", "pass", "stream", "tuples", "into", "callables", "as", "tuple", "instances", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L537-L594
IBMStreams/pypi.streamsx
streamsx/topology/schema.py
StreamSchema.extend
def extend(self, schema): """ Extend a structured schema by another. For example extending ``tuple<rstring id, timestamp ts, float64 value>`` with ``tuple<float32 score>`` results in ``tuple<rstring id, timestamp ts, float64 value, float32 score>``. Args: schema(Str...
python
def extend(self, schema): """ Extend a structured schema by another. For example extending ``tuple<rstring id, timestamp ts, float64 value>`` with ``tuple<float32 score>`` results in ``tuple<rstring id, timestamp ts, float64 value, float32 score>``. Args: schema(Str...
[ "def", "extend", "(", "self", ",", "schema", ")", ":", "if", "self", ".", "_spl_type", ":", "raise", "TypeError", "(", "\"Not supported for declared SPL types\"", ")", "base", "=", "self", ".", "schema", "(", ")", "extends", "=", "schema", ".", "schema", "...
Extend a structured schema by another. For example extending ``tuple<rstring id, timestamp ts, float64 value>`` with ``tuple<float32 score>`` results in ``tuple<rstring id, timestamp ts, float64 value, float32 score>``. Args: schema(StreamSchema): Schema to extend this schema by. ...
[ "Extend", "a", "structured", "schema", "by", "another", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L627-L645
IBMStreams/pypi.streamsx
streamsx/topology/schema.py
StreamSchema._fnop_style
def _fnop_style(schema, op, name): """Set an operator's parameter representing the style of this schema.""" if is_common(schema): if name in op.params: del op.params[name] return if _is_pending(schema): ntp = 'pending' elif schema.style...
python
def _fnop_style(schema, op, name): """Set an operator's parameter representing the style of this schema.""" if is_common(schema): if name in op.params: del op.params[name] return if _is_pending(schema): ntp = 'pending' elif schema.style...
[ "def", "_fnop_style", "(", "schema", ",", "op", ",", "name", ")", ":", "if", "is_common", "(", "schema", ")", ":", "if", "name", "in", "op", ".", "params", ":", "del", "op", ".", "params", "[", "name", "]", "return", "if", "_is_pending", "(", "sche...
Set an operator's parameter representing the style of this schema.
[ "Set", "an", "operator", "s", "parameter", "representing", "the", "style", "of", "this", "schema", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/schema.py#L659-L675
raphaelm/django-hierarkey
hierarkey/forms.py
HierarkeyForm.save
def save(self) -> None: """ Saves all changed values to the database. """ for name, field in self.fields.items(): value = self.cleaned_data[name] if isinstance(value, UploadedFile): # Delete old file fname = self._s.get(name, as_typ...
python
def save(self) -> None: """ Saves all changed values to the database. """ for name, field in self.fields.items(): value = self.cleaned_data[name] if isinstance(value, UploadedFile): # Delete old file fname = self._s.get(name, as_typ...
[ "def", "save", "(", "self", ")", "->", "None", ":", "for", "name", ",", "field", "in", "self", ".", "fields", ".", "items", "(", ")", ":", "value", "=", "self", ".", "cleaned_data", "[", "name", "]", "if", "isinstance", "(", "value", ",", "Uploaded...
Saves all changed values to the database.
[ "Saves", "all", "changed", "values", "to", "the", "database", "." ]
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/forms.py#L30-L64
raphaelm/django-hierarkey
hierarkey/forms.py
HierarkeyForm.get_new_filename
def get_new_filename(self, name: str) -> str: """ Returns the file name to use based on the original filename of an uploaded file. By default, the file name is constructed as:: <model_name>-<attribute_name>/<primary_key>/<original_basename>.<random_nonce>.<extension> ...
python
def get_new_filename(self, name: str) -> str: """ Returns the file name to use based on the original filename of an uploaded file. By default, the file name is constructed as:: <model_name>-<attribute_name>/<primary_key>/<original_basename>.<random_nonce>.<extension> ...
[ "def", "get_new_filename", "(", "self", ",", "name", ":", "str", ")", "->", "str", ":", "nonce", "=", "get_random_string", "(", "length", "=", "8", ")", "return", "'%s-%s/%s/%s.%s.%s'", "%", "(", "self", ".", "obj", ".", "_meta", ".", "model_name", ",", ...
Returns the file name to use based on the original filename of an uploaded file. By default, the file name is constructed as:: <model_name>-<attribute_name>/<primary_key>/<original_basename>.<random_nonce>.<extension>
[ "Returns", "the", "file", "name", "to", "use", "based", "on", "the", "original", "filename", "of", "an", "uploaded", "file", ".", "By", "default", "the", "file", "name", "is", "constructed", "as", "::", "<model_name", ">", "-", "<attribute_name", ">", "/",...
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/forms.py#L66-L77
IBMStreams/pypi.streamsx
streamsx/scripts/service.py
_stop
def _stop(sas, cmd_args): """Stop the service if no jobs are running unless force is set""" if not cmd_args.force: status = sas.get_instance_status() jobs = int(status['job_count']) if jobs: return status return sas.stop_instance()
python
def _stop(sas, cmd_args): """Stop the service if no jobs are running unless force is set""" if not cmd_args.force: status = sas.get_instance_status() jobs = int(status['job_count']) if jobs: return status return sas.stop_instance()
[ "def", "_stop", "(", "sas", ",", "cmd_args", ")", ":", "if", "not", "cmd_args", ".", "force", ":", "status", "=", "sas", ".", "get_instance_status", "(", ")", "jobs", "=", "int", "(", "status", "[", "'job_count'", "]", ")", "if", "jobs", ":", "return...
Stop the service if no jobs are running unless force is set
[ "Stop", "the", "service", "if", "no", "jobs", "are", "running", "unless", "force", "is", "set" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/scripts/service.py#L14-L21
IBMStreams/pypi.streamsx
streamsx/scripts/service.py
main
def main(args=None): """ Performs an action against a Streaming Analytics service. """ streamsx._streams._version._mismatch_check('streamsx.topology.context') try: sr = run_cmd(args) sr['return_code'] = 0 except: sr = {'return_code':1, 'error': sys.exc_info()} return sr
python
def main(args=None): """ Performs an action against a Streaming Analytics service. """ streamsx._streams._version._mismatch_check('streamsx.topology.context') try: sr = run_cmd(args) sr['return_code'] = 0 except: sr = {'return_code':1, 'error': sys.exc_info()} return sr
[ "def", "main", "(", "args", "=", "None", ")", ":", "streamsx", ".", "_streams", ".", "_version", ".", "_mismatch_check", "(", "'streamsx.topology.context'", ")", "try", ":", "sr", "=", "run_cmd", "(", "args", ")", "sr", "[", "'return_code'", "]", "=", "0...
Performs an action against a Streaming Analytics service.
[ "Performs", "an", "action", "against", "a", "Streaming", "Analytics", "service", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/scripts/service.py#L39-L48
IBMStreams/pypi.streamsx
streamsx/scripts/service.py
_parse_args
def _parse_args(args): """ Argument parsing """ cmd_parser = argparse.ArgumentParser(description='Control commands for a Streaming Analytics service.') cmd_parser.add_argument('--service-name', help='Streaming Analytics service name') cmd_parser.add_argument('--full-response', action='store_true', h...
python
def _parse_args(args): """ Argument parsing """ cmd_parser = argparse.ArgumentParser(description='Control commands for a Streaming Analytics service.') cmd_parser.add_argument('--service-name', help='Streaming Analytics service name') cmd_parser.add_argument('--full-response', action='store_true', h...
[ "def", "_parse_args", "(", "args", ")", ":", "cmd_parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Control commands for a Streaming Analytics service.'", ")", "cmd_parser", ".", "add_argument", "(", "'--service-name'", ",", "help", "=", "'St...
Argument parsing
[ "Argument", "parsing" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/scripts/service.py#L50-L64
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
_source_info
def _source_info(): """ Get information from the user's code (two frames up) to leave breadcrumbs for file, line, class and function. """ ofi = inspect.getouterframes(inspect.currentframe())[2] try: calling_class = ofi[0].f_locals['self'].__class__ except KeyError: calling_cl...
python
def _source_info(): """ Get information from the user's code (two frames up) to leave breadcrumbs for file, line, class and function. """ ofi = inspect.getouterframes(inspect.currentframe())[2] try: calling_class = ofi[0].f_locals['self'].__class__ except KeyError: calling_cl...
[ "def", "_source_info", "(", ")", ":", "ofi", "=", "inspect", ".", "getouterframes", "(", "inspect", ".", "currentframe", "(", ")", ")", "[", "2", "]", "try", ":", "calling_class", "=", "ofi", "[", "0", "]", ".", "f_locals", "[", "'self'", "]", ".", ...
Get information from the user's code (two frames up) to leave breadcrumbs for file, line, class and function.
[ "Get", "information", "from", "the", "user", "s", "code", "(", "two", "frames", "up", ")", "to", "leave", "breadcrumbs", "for", "file", "line", "class", "and", "function", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L238-L249
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
SubscribeConnection.spl_json
def spl_json(self): """Internal method.""" return streamsx.spl.op.Expression.expression('com.ibm.streamsx.topology.topic::' + self.name).spl_json()
python
def spl_json(self): """Internal method.""" return streamsx.spl.op.Expression.expression('com.ibm.streamsx.topology.topic::' + self.name).spl_json()
[ "def", "spl_json", "(", "self", ")", ":", "return", "streamsx", ".", "spl", ".", "op", ".", "Expression", ".", "expression", "(", "'com.ibm.streamsx.topology.topic::'", "+", "self", ".", "name", ")", ".", "spl_json", "(", ")" ]
Internal method.
[ "Internal", "method", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L338-L340
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Topology.source
def source(self, func, name=None): """ Declare a source stream that introduces tuples into the application. Typically used to create a stream of tuple from an external source, such as a sensor or reading from an external system. Tuples are obtained from an iterator obtained fro...
python
def source(self, func, name=None): """ Declare a source stream that introduces tuples into the application. Typically used to create a stream of tuple from an external source, such as a sensor or reading from an external system. Tuples are obtained from an iterator obtained fro...
[ "def", "source", "(", "self", ",", "func", ",", "name", "=", "None", ")", ":", "_name", "=", "name", "if", "inspect", ".", "isroutine", "(", "func", ")", ":", "pass", "elif", "callable", "(", "func", ")", ":", "pass", "else", ":", "if", "_name", ...
Declare a source stream that introduces tuples into the application. Typically used to create a stream of tuple from an external source, such as a sensor or reading from an external system. Tuples are obtained from an iterator obtained from the passed iterable or callable that returns ...
[ "Declare", "a", "source", "stream", "that", "introduces", "tuples", "into", "the", "application", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L434-L495
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Topology.subscribe
def subscribe(self, topic, schema=streamsx.topology.schema.CommonSchema.Python, name=None, connect=None, buffer_capacity=None, buffer_full_policy=None): """ Subscribe to a topic published by other Streams applications. A Streams application may publish a stream to allow other Streams app...
python
def subscribe(self, topic, schema=streamsx.topology.schema.CommonSchema.Python, name=None, connect=None, buffer_capacity=None, buffer_full_policy=None): """ Subscribe to a topic published by other Streams applications. A Streams application may publish a stream to allow other Streams app...
[ "def", "subscribe", "(", "self", ",", "topic", ",", "schema", "=", "streamsx", ".", "topology", ".", "schema", ".", "CommonSchema", ".", "Python", ",", "name", "=", "None", ",", "connect", "=", "None", ",", "buffer_capacity", "=", "None", ",", "buffer_fu...
Subscribe to a topic published by other Streams applications. A Streams application may publish a stream to allow other Streams applications to subscribe to it. A subscriber matches a publisher if the topic and schema match. By default a stream is subscribed as :py:const:`~streamsx.topo...
[ "Subscribe", "to", "a", "topic", "published", "by", "other", "Streams", "applications", ".", "A", "Streams", "application", "may", "publish", "a", "stream", "to", "allow", "other", "Streams", "applications", "to", "subscribe", "to", "it", ".", "A", "subscriber...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L497-L558
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Topology.add_file_dependency
def add_file_dependency(self, path, location): """ Add a file or directory dependency into an Streams application bundle. Ensures that the file or directory at `path` on the local system will be available at runtime. The file will be copied and made available relative to the ...
python
def add_file_dependency(self, path, location): """ Add a file or directory dependency into an Streams application bundle. Ensures that the file or directory at `path` on the local system will be available at runtime. The file will be copied and made available relative to the ...
[ "def", "add_file_dependency", "(", "self", ",", "path", ",", "location", ")", ":", "if", "location", "not", "in", "{", "'etc'", ",", "'opt'", "}", ":", "raise", "ValueError", "(", "location", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "...
Add a file or directory dependency into an Streams application bundle. Ensures that the file or directory at `path` on the local system will be available at runtime. The file will be copied and made available relative to the application directory. Location determines where the file ...
[ "Add", "a", "file", "or", "directory", "dependency", "into", "an", "Streams", "application", "bundle", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L560-L607
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Topology.add_pip_package
def add_pip_package(self, requirement): """ Add a Python package dependency for this topology. If the package defined by the requirement specifier is not pre-installed on the build system then the package is installed using `pip` and becomes part of the Streams applicati...
python
def add_pip_package(self, requirement): """ Add a Python package dependency for this topology. If the package defined by the requirement specifier is not pre-installed on the build system then the package is installed using `pip` and becomes part of the Streams applicati...
[ "def", "add_pip_package", "(", "self", ",", "requirement", ")", ":", "self", ".", "_pip_packages", ".", "append", "(", "str", "(", "requirement", ")", ")", "pr", "=", "pkg_resources", ".", "Requirement", ".", "parse", "(", "requirement", ")", "self", ".", ...
Add a Python package dependency for this topology. If the package defined by the requirement specifier is not pre-installed on the build system then the package is installed using `pip` and becomes part of the Streams application bundle (`sab` file). The package is expected to b...
[ "Add", "a", "Python", "package", "dependency", "for", "this", "topology", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L609-L666
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Topology.create_submission_parameter
def create_submission_parameter(self, name, default=None, type_=None): """ Create a submission parameter. A submission parameter is a handle for a value that is not defined until topology submission time. Submission parameters enable the creation of reusable topology bundles. ...
python
def create_submission_parameter(self, name, default=None, type_=None): """ Create a submission parameter. A submission parameter is a handle for a value that is not defined until topology submission time. Submission parameters enable the creation of reusable topology bundles. ...
[ "def", "create_submission_parameter", "(", "self", ",", "name", ",", "default", "=", "None", ",", "type_", "=", "None", ")", ":", "if", "name", "in", "self", ".", "_submission_parameters", ":", "raise", "ValueError", "(", "\"Submission parameter {} already defined...
Create a submission parameter. A submission parameter is a handle for a value that is not defined until topology submission time. Submission parameters enable the creation of reusable topology bundles. A submission parameter has a `name`. The name must be unique within the to...
[ "Create", "a", "submission", "parameter", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L668-L725
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Topology._generate_requirements
def _generate_requirements(self): """Generate the info to create requirements.txt in the toookit.""" if not self._pip_packages: return reqs = '' for req in self._pip_packages: reqs += "{}\n".format(req) reqs_include = { 'contents': reqs, ...
python
def _generate_requirements(self): """Generate the info to create requirements.txt in the toookit.""" if not self._pip_packages: return reqs = '' for req in self._pip_packages: reqs += "{}\n".format(req) reqs_include = { 'contents': reqs, ...
[ "def", "_generate_requirements", "(", "self", ")", ":", "if", "not", "self", ".", "_pip_packages", ":", "return", "reqs", "=", "''", "for", "req", "in", "self", ".", "_pip_packages", ":", "reqs", "+=", "\"{}\\n\"", ".", "format", "(", "req", ")", "reqs_i...
Generate the info to create requirements.txt in the toookit.
[ "Generate", "the", "info", "to", "create", "requirements", ".", "txt", "in", "the", "toookit", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L775-L791
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Topology._add_job_control_plane
def _add_job_control_plane(self): """ Add a JobControlPlane operator to the topology, if one has not already been added. If a JobControlPlane operator has already been added, this has no effect. """ if not self._has_jcp: jcp = self.graph.addOperator(kind="spl...
python
def _add_job_control_plane(self): """ Add a JobControlPlane operator to the topology, if one has not already been added. If a JobControlPlane operator has already been added, this has no effect. """ if not self._has_jcp: jcp = self.graph.addOperator(kind="spl...
[ "def", "_add_job_control_plane", "(", "self", ")", ":", "if", "not", "self", ".", "_has_jcp", ":", "jcp", "=", "self", ".", "graph", ".", "addOperator", "(", "kind", "=", "\"spl.control::JobControlPlane\"", ",", "name", "=", "\"JobControlPlane\"", ")", "jcp", ...
Add a JobControlPlane operator to the topology, if one has not already been added. If a JobControlPlane operator has already been added, this has no effect.
[ "Add", "a", "JobControlPlane", "operator", "to", "the", "topology", "if", "one", "has", "not", "already", "been", "added", ".", "If", "a", "JobControlPlane", "operator", "has", "already", "been", "added", "this", "has", "no", "effect", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L793-L802
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.aliased_as
def aliased_as(self, name): """ Create an alias of this stream. Returns an alias of this stream with name `name`. When invocation of an SPL operator requires an :py:class:`~streamsx.spl.op.Expression` against an input port this can be used to ensure expression ma...
python
def aliased_as(self, name): """ Create an alias of this stream. Returns an alias of this stream with name `name`. When invocation of an SPL operator requires an :py:class:`~streamsx.spl.op.Expression` against an input port this can be used to ensure expression ma...
[ "def", "aliased_as", "(", "self", ",", "name", ")", ":", "stream", "=", "copy", ".", "copy", "(", "self", ")", "stream", ".", "_alias", "=", "name", "return", "stream" ]
Create an alias of this stream. Returns an alias of this stream with name `name`. When invocation of an SPL operator requires an :py:class:`~streamsx.spl.op.Expression` against an input port this can be used to ensure expression matches the input port alias regardless of the nam...
[ "Create", "an", "alias", "of", "this", "stream", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L844-L874
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.view
def view(self, buffer_time = 10.0, sample_size = 10000, name=None, description=None, start=False): """ Defines a view on a stream. A view is a continually updated sampled buffer of a streams's tuples. Views allow visibility into a stream from external clients such as Jupyter Not...
python
def view(self, buffer_time = 10.0, sample_size = 10000, name=None, description=None, start=False): """ Defines a view on a stream. A view is a continually updated sampled buffer of a streams's tuples. Views allow visibility into a stream from external clients such as Jupyter Not...
[ "def", "view", "(", "self", ",", "buffer_time", "=", "10.0", ",", "sample_size", "=", "10000", ",", "name", "=", "None", ",", "description", "=", "None", ",", "start", "=", "False", ")", ":", "if", "name", "is", "None", ":", "name", "=", "''", ".",...
Defines a view on a stream. A view is a continually updated sampled buffer of a streams's tuples. Views allow visibility into a stream from external clients such as Jupyter Notebooks, the Streams console, `Microsoft Excel <https://www.ibm.com/support/knowledgecenter/SSCRJU_4.2.0/com.ibm...
[ "Defines", "a", "view", "on", "a", "stream", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L963-L1023
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.map
def map(self, func=None, name=None, schema=None): """ Maps each tuple from this stream into 0 or 1 stream tuples. For each tuple on this stream ``result = func(tuple)`` is called. If `result` is not `None` then the result will be submitted as a tuple on the returned stream. If `...
python
def map(self, func=None, name=None, schema=None): """ Maps each tuple from this stream into 0 or 1 stream tuples. For each tuple on this stream ``result = func(tuple)`` is called. If `result` is not `None` then the result will be submitted as a tuple on the returned stream. If `...
[ "def", "map", "(", "self", ",", "func", "=", "None", ",", "name", "=", "None", ",", "schema", "=", "None", ")", ":", "if", "schema", "is", "None", ":", "schema", "=", "streamsx", ".", "topology", ".", "schema", ".", "CommonSchema", ".", "Python", "...
Maps each tuple from this stream into 0 or 1 stream tuples. For each tuple on this stream ``result = func(tuple)`` is called. If `result` is not `None` then the result will be submitted as a tuple on the returned stream. If `result` is `None` then no tuple submission will occur. ...
[ "Maps", "each", "tuple", "from", "this", "stream", "into", "0", "or", "1", "stream", "tuples", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1025-L1078
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.flat_map
def flat_map(self, func=None, name=None): """ Maps and flatterns each tuple from this stream into 0 or more tuples. For each tuple on this stream ``func(tuple)`` is called. If the result is not `None` then the the result is iterated over with each value from the iterator that i...
python
def flat_map(self, func=None, name=None): """ Maps and flatterns each tuple from this stream into 0 or more tuples. For each tuple on this stream ``func(tuple)`` is called. If the result is not `None` then the the result is iterated over with each value from the iterator that i...
[ "def", "flat_map", "(", "self", ",", "func", "=", "None", ",", "name", "=", "None", ")", ":", "if", "func", "is", "None", ":", "func", "=", "streamsx", ".", "topology", ".", "runtime", ".", "_identity", "if", "name", "is", "None", ":", "name", "=",...
Maps and flatterns each tuple from this stream into 0 or more tuples. For each tuple on this stream ``func(tuple)`` is called. If the result is not `None` then the the result is iterated over with each value from the iterator that is not `None` will be submitted to the return stream. ...
[ "Maps", "and", "flatterns", "each", "tuple", "from", "this", "stream", "into", "0", "or", "more", "tuples", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1089-L1138
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.parallel
def parallel(self, width, routing=Routing.ROUND_ROBIN, func=None, name=None): """ Split stream into channels and start a parallel region. Returns a new stream that will contain the contents of this stream with tuples distributed across its channels. The returned stream starts a...
python
def parallel(self, width, routing=Routing.ROUND_ROBIN, func=None, name=None): """ Split stream into channels and start a parallel region. Returns a new stream that will contain the contents of this stream with tuples distributed across its channels. The returned stream starts a...
[ "def", "parallel", "(", "self", ",", "width", ",", "routing", "=", "Routing", ".", "ROUND_ROBIN", ",", "func", "=", "None", ",", "name", "=", "None", ")", ":", "_name", "=", "name", "if", "_name", "is", "None", ":", "_name", "=", "self", ".", "name...
Split stream into channels and start a parallel region. Returns a new stream that will contain the contents of this stream with tuples distributed across its channels. The returned stream starts a parallel region where all downstream transforms are replicated across `width` channels. ...
[ "Split", "stream", "into", "channels", "and", "start", "a", "parallel", "region", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1190-L1333
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.end_parallel
def end_parallel(self): """ Ends a parallel region by merging the channels into a single stream. Returns: Stream: Stream for which subsequent transformations are no longer parallelized. .. seealso:: :py:meth:`set_parallel`, :py:meth:`parallel` """ outport = ...
python
def end_parallel(self): """ Ends a parallel region by merging the channels into a single stream. Returns: Stream: Stream for which subsequent transformations are no longer parallelized. .. seealso:: :py:meth:`set_parallel`, :py:meth:`parallel` """ outport = ...
[ "def", "end_parallel", "(", "self", ")", ":", "outport", "=", "self", ".", "oport", "if", "isinstance", "(", "self", ".", "oport", ".", "operator", ",", "streamsx", ".", "topology", ".", "graph", ".", "Marker", ")", ":", "if", "self", ".", "oport", "...
Ends a parallel region by merging the channels into a single stream. Returns: Stream: Stream for which subsequent transformations are no longer parallelized. .. seealso:: :py:meth:`set_parallel`, :py:meth:`parallel`
[ "Ends", "a", "parallel", "region", "by", "merging", "the", "channels", "into", "a", "single", "stream", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1335-L1354
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.set_parallel
def set_parallel(self, width, name=None): """ Set this source stream to be split into multiple channels as the start of a parallel region. Calling ``set_parallel`` on a stream created by :py:meth:`~Topology.source` results in the stream having `width` channels, each crea...
python
def set_parallel(self, width, name=None): """ Set this source stream to be split into multiple channels as the start of a parallel region. Calling ``set_parallel`` on a stream created by :py:meth:`~Topology.source` results in the stream having `width` channels, each crea...
[ "def", "set_parallel", "(", "self", ",", "width", ",", "name", "=", "None", ")", ":", "self", ".", "oport", ".", "operator", ".", "config", "[", "'parallel'", "]", "=", "True", "self", ".", "oport", ".", "operator", ".", "config", "[", "'width'", "]"...
Set this source stream to be split into multiple channels as the start of a parallel region. Calling ``set_parallel`` on a stream created by :py:meth:`~Topology.source` results in the stream having `width` channels, each created by its own instance of the callable:: ...
[ "Set", "this", "source", "stream", "to", "be", "split", "into", "multiple", "channels", "as", "the", "start", "of", "a", "parallel", "region", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1356-L1423
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.set_consistent
def set_consistent(self, consistent_config): """ Indicates that the stream is the start of a consistent region. Args: consistent_config(consistent.ConsistentRegionConfig): the configuration of the consistent region. Returns: Stream: Returns this stream. .. vers...
python
def set_consistent(self, consistent_config): """ Indicates that the stream is the start of a consistent region. Args: consistent_config(consistent.ConsistentRegionConfig): the configuration of the consistent region. Returns: Stream: Returns this stream. .. vers...
[ "def", "set_consistent", "(", "self", ",", "consistent_config", ")", ":", "# add job control plane if needed", "self", ".", "topology", ".", "_add_job_control_plane", "(", ")", "self", ".", "oport", ".", "operator", ".", "consistent", "(", "consistent_config", ")", ...
Indicates that the stream is the start of a consistent region. Args: consistent_config(consistent.ConsistentRegionConfig): the configuration of the consistent region. Returns: Stream: Returns this stream. .. versionadded:: 1.11
[ "Indicates", "that", "the", "stream", "is", "the", "start", "of", "a", "consistent", "region", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1425-L1440
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.last
def last(self, size=1): """ Declares a slding window containing most recent tuples on this stream. The number of tuples maintained in the window is defined by `size`. If `size` is an `int` then it is the count of tuples in the window. For example, with ``size=10`` the window al...
python
def last(self, size=1): """ Declares a slding window containing most recent tuples on this stream. The number of tuples maintained in the window is defined by `size`. If `size` is an `int` then it is the count of tuples in the window. For example, with ``size=10`` the window al...
[ "def", "last", "(", "self", ",", "size", "=", "1", ")", ":", "win", "=", "Window", "(", "self", ",", "'SLIDING'", ")", "if", "isinstance", "(", "size", ",", "datetime", ".", "timedelta", ")", ":", "win", ".", "_evict_time", "(", "size", ")", "elif"...
Declares a slding window containing most recent tuples on this stream. The number of tuples maintained in the window is defined by `size`. If `size` is an `int` then it is the count of tuples in the window. For example, with ``size=10`` the window always contains the last (most...
[ "Declares", "a", "slding", "window", "containing", "most", "recent", "tuples", "on", "this", "stream", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1442-L1483
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.union
def union(self, streamSet): """ Creates a stream that is a union of this stream and other streams Args: streamSet: a set of Stream objects to merge with this stream Returns: Stream: """ if(not isinstance(streamSet,set)) : raise...
python
def union(self, streamSet): """ Creates a stream that is a union of this stream and other streams Args: streamSet: a set of Stream objects to merge with this stream Returns: Stream: """ if(not isinstance(streamSet,set)) : raise...
[ "def", "union", "(", "self", ",", "streamSet", ")", ":", "if", "(", "not", "isinstance", "(", "streamSet", ",", "set", ")", ")", ":", "raise", "TypeError", "(", "\"The union operator parameter must be a set object\"", ")", "if", "(", "len", "(", "streamSet", ...
Creates a stream that is a union of this stream and other streams Args: streamSet: a set of Stream objects to merge with this stream Returns: Stream:
[ "Creates", "a", "stream", "that", "is", "a", "union", "of", "this", "stream", "and", "other", "streams", "Args", ":", "streamSet", ":", "a", "set", "of", "Stream", "objects", "to", "merge", "with", "this", "stream", "Returns", ":", "Stream", ":" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1551-L1569
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.print
def print(self, tag=None, name=None): """ Prints each tuple to stdout flushing after each tuple. If `tag` is not `None` then each tuple has "tag: " prepended to it before printing. Args: tag: A tag to prepend to each tuple. name(str): Name of the resulti...
python
def print(self, tag=None, name=None): """ Prints each tuple to stdout flushing after each tuple. If `tag` is not `None` then each tuple has "tag: " prepended to it before printing. Args: tag: A tag to prepend to each tuple. name(str): Name of the resulti...
[ "def", "print", "(", "self", ",", "tag", "=", "None", ",", "name", "=", "None", ")", ":", "_name", "=", "name", "if", "_name", "is", "None", ":", "_name", "=", "'print'", "fn", "=", "streamsx", ".", "topology", ".", "functions", ".", "print_flush", ...
Prints each tuple to stdout flushing after each tuple. If `tag` is not `None` then each tuple has "tag: " prepended to it before printing. Args: tag: A tag to prepend to each tuple. name(str): Name of the resulting stream. When `None` defaults to a gener...
[ "Prints", "each", "tuple", "to", "stdout", "flushing", "after", "each", "tuple", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1571-L1599
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.publish
def publish(self, topic, schema=None, name=None): """ Publish this stream on a topic for other Streams applications to subscribe to. A Streams application may publish a stream to allow other Streams applications to subscribe to it. A subscriber matches a publisher if the topic an...
python
def publish(self, topic, schema=None, name=None): """ Publish this stream on a topic for other Streams applications to subscribe to. A Streams application may publish a stream to allow other Streams applications to subscribe to it. A subscriber matches a publisher if the topic an...
[ "def", "publish", "(", "self", ",", "topic", ",", "schema", "=", "None", ",", "name", "=", "None", ")", ":", "sl", "=", "_SourceLocation", "(", "_source_info", "(", ")", ",", "'publish'", ")", "schema", "=", "streamsx", ".", "topology", ".", "schema", ...
Publish this stream on a topic for other Streams applications to subscribe to. A Streams application may publish a stream to allow other Streams applications to subscribe to it. A subscriber matches a publisher if the topic and schema match. By default a stream is published using its sc...
[ "Publish", "this", "stream", "on", "a", "topic", "for", "other", "Streams", "applications", "to", "subscribe", "to", ".", "A", "Streams", "application", "may", "publish", "a", "stream", "to", "allow", "other", "Streams", "applications", "to", "subscribe", "to"...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1601-L1667
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.autonomous
def autonomous(self): """ Starts an autonomous region for downstream processing. By default IBM Streams processing is executed in an autonomous region where any checkpointing of operator state is autonomous (independent) of other operators. This method may be use...
python
def autonomous(self): """ Starts an autonomous region for downstream processing. By default IBM Streams processing is executed in an autonomous region where any checkpointing of operator state is autonomous (independent) of other operators. This method may be use...
[ "def", "autonomous", "(", "self", ")", ":", "op", "=", "self", ".", "topology", ".", "graph", ".", "addOperator", "(", "\"$Autonomous$\"", ")", "op", ".", "addInputPort", "(", "outputPort", "=", "self", ".", "oport", ")", "oport", "=", "op", ".", "addO...
Starts an autonomous region for downstream processing. By default IBM Streams processing is executed in an autonomous region where any checkpointing of operator state is autonomous (independent) of other operators. This method may be used to end a consistent region by starting a...
[ "Starts", "an", "autonomous", "region", "for", "downstream", "processing", ".", "By", "default", "IBM", "Streams", "processing", "is", "executed", "in", "an", "autonomous", "region", "where", "any", "checkpointing", "of", "operator", "state", "is", "autonomous", ...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1669-L1691
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.as_string
def as_string(self, name=None): """ Declares a stream converting each tuple on this stream into a string using `str(tuple)`. The stream is typed as a :py:const:`string stream <streamsx.topology.schema.CommonSchema.String>`. If this stream is already typed as a string stream the...
python
def as_string(self, name=None): """ Declares a stream converting each tuple on this stream into a string using `str(tuple)`. The stream is typed as a :py:const:`string stream <streamsx.topology.schema.CommonSchema.String>`. If this stream is already typed as a string stream the...
[ "def", "as_string", "(", "self", ",", "name", "=", "None", ")", ":", "sas", "=", "self", ".", "_change_schema", "(", "streamsx", ".", "topology", ".", "schema", ".", "CommonSchema", ".", "String", ",", "'as_string'", ",", "name", ")", ".", "_layout", "...
Declares a stream converting each tuple on this stream into a string using `str(tuple)`. The stream is typed as a :py:const:`string stream <streamsx.topology.schema.CommonSchema.String>`. If this stream is already typed as a string stream then it will be returned (with no additional pr...
[ "Declares", "a", "stream", "converting", "each", "tuple", "on", "this", "stream", "into", "a", "string", "using", "str", "(", "tuple", ")", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1693-L1716
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream.as_json
def as_json(self, force_object=True, name=None): """ Declares a stream converting each tuple on this stream into a JSON value. The stream is typed as a :py:const:`JSON stream <streamsx.topology.schema.CommonSchema.Json>`. Each tuple must be supported by `JSONEncoder`. ...
python
def as_json(self, force_object=True, name=None): """ Declares a stream converting each tuple on this stream into a JSON value. The stream is typed as a :py:const:`JSON stream <streamsx.topology.schema.CommonSchema.Json>`. Each tuple must be supported by `JSONEncoder`. ...
[ "def", "as_json", "(", "self", ",", "force_object", "=", "True", ",", "name", "=", "None", ")", ":", "func", "=", "streamsx", ".", "topology", ".", "runtime", ".", "_json_force_object", "if", "force_object", "else", "None", "saj", "=", "self", ".", "_cha...
Declares a stream converting each tuple on this stream into a JSON value. The stream is typed as a :py:const:`JSON stream <streamsx.topology.schema.CommonSchema.Json>`. Each tuple must be supported by `JSONEncoder`. If `force_object` is `True` then each tuple that not a `dict` ...
[ "Declares", "a", "stream", "converting", "each", "tuple", "on", "this", "stream", "into", "a", "JSON", "value", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1718-L1753
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Stream._change_schema
def _change_schema(self, schema, action, name=None, func=None): """Internal method to change a schema. """ if self.oport.schema.schema() == schema.schema(): return self if func is None: func = streamsx.topology.functions.identity _name = name if ...
python
def _change_schema(self, schema, action, name=None, func=None): """Internal method to change a schema. """ if self.oport.schema.schema() == schema.schema(): return self if func is None: func = streamsx.topology.functions.identity _name = name if ...
[ "def", "_change_schema", "(", "self", ",", "schema", ",", "action", ",", "name", "=", "None", ",", "func", "=", "None", ")", ":", "if", "self", ".", "oport", ".", "schema", ".", "schema", "(", ")", "==", "schema", ".", "schema", "(", ")", ":", "r...
Internal method to change a schema.
[ "Internal", "method", "to", "change", "a", "schema", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1755-L1770
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
View._initialize_rest
def _initialize_rest(self): """Used to initialize the View object on first use. """ if self._submit_context is None: raise ValueError("View has not been created.") job = self._submit_context._job_access() self._view_object = job.get_views(name=self.name)[0]
python
def _initialize_rest(self): """Used to initialize the View object on first use. """ if self._submit_context is None: raise ValueError("View has not been created.") job = self._submit_context._job_access() self._view_object = job.get_views(name=self.name)[0]
[ "def", "_initialize_rest", "(", "self", ")", ":", "if", "self", ".", "_submit_context", "is", "None", ":", "raise", "ValueError", "(", "\"View has not been created.\"", ")", "job", "=", "self", ".", "_submit_context", ".", "_job_access", "(", ")", "self", ".",...
Used to initialize the View object on first use.
[ "Used", "to", "initialize", "the", "View", "object", "on", "first", "use", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1814-L1820
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
View.display
def display(self, duration=None, period=2): """Display a view within a Jupyter or IPython notebook. Provides an easy mechanism to visualize data on a stream using a view. Tuples are fetched from the view and displayed in a table within the notebook cell using a ``pandas.DataFra...
python
def display(self, duration=None, period=2): """Display a view within a Jupyter or IPython notebook. Provides an easy mechanism to visualize data on a stream using a view. Tuples are fetched from the view and displayed in a table within the notebook cell using a ``pandas.DataFra...
[ "def", "display", "(", "self", ",", "duration", "=", "None", ",", "period", "=", "2", ")", ":", "self", ".", "_initialize_rest", "(", ")", "return", "self", ".", "_view_object", ".", "display", "(", "duration", ",", "period", ")" ]
Display a view within a Jupyter or IPython notebook. Provides an easy mechanism to visualize data on a stream using a view. Tuples are fetched from the view and displayed in a table within the notebook cell using a ``pandas.DataFrame``. The table is continually updated with the...
[ "Display", "a", "view", "within", "a", "Jupyter", "or", "IPython", "notebook", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1860-L1891
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
PendingStream.complete
def complete(self, stream): """Complete the pending stream. Any connections made to :py:attr:`stream` are connected to `stream` once this method returns. Args: stream(Stream): Stream that completes the connection. """ assert not s...
python
def complete(self, stream): """Complete the pending stream. Any connections made to :py:attr:`stream` are connected to `stream` once this method returns. Args: stream(Stream): Stream that completes the connection. """ assert not s...
[ "def", "complete", "(", "self", ",", "stream", ")", ":", "assert", "not", "self", ".", "is_complete", "(", ")", "self", ".", "_marker", ".", "addInputPort", "(", "outputPort", "=", "stream", ".", "oport", ")", "self", ".", "stream", ".", "oport", ".", ...
Complete the pending stream. Any connections made to :py:attr:`stream` are connected to `stream` once this method returns. Args: stream(Stream): Stream that completes the connection.
[ "Complete", "the", "pending", "stream", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1933-L1952
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Window.trigger
def trigger(self, when=1): """Declare a window with this window's size and a trigger policy. When the window is triggered is defined by `when`. If `when` is an `int` then the window is triggered every `when` tuples. For example, with ``when=5`` the window will be triggered eve...
python
def trigger(self, when=1): """Declare a window with this window's size and a trigger policy. When the window is triggered is defined by `when`. If `when` is an `int` then the window is triggered every `when` tuples. For example, with ``when=5`` the window will be triggered eve...
[ "def", "trigger", "(", "self", ",", "when", "=", "1", ")", ":", "tw", "=", "Window", "(", "self", ".", "stream", ",", "self", ".", "_config", "[", "'type'", "]", ")", "tw", ".", "_config", "[", "'evictPolicy'", "]", "=", "self", ".", "_config", "...
Declare a window with this window's size and a trigger policy. When the window is triggered is defined by `when`. If `when` is an `int` then the window is triggered every `when` tuples. For example, with ``when=5`` the window will be triggered every five tuples. If `when` is ...
[ "Declare", "a", "window", "with", "this", "window", "s", "size", "and", "a", "trigger", "policy", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L1991-L2034
IBMStreams/pypi.streamsx
streamsx/topology/topology.py
Window.aggregate
def aggregate(self, function, name=None): """Aggregates the contents of the window when the window is triggered. Upon a window trigger, the supplied function is passed a list containing the contents of the window: ``function(items)``. The order of the window items in t...
python
def aggregate(self, function, name=None): """Aggregates the contents of the window when the window is triggered. Upon a window trigger, the supplied function is passed a list containing the contents of the window: ``function(items)``. The order of the window items in t...
[ "def", "aggregate", "(", "self", ",", "function", ",", "name", "=", "None", ")", ":", "schema", "=", "streamsx", ".", "topology", ".", "schema", ".", "CommonSchema", ".", "Python", "sl", "=", "_SourceLocation", "(", "_source_info", "(", ")", ",", "\"aggr...
Aggregates the contents of the window when the window is triggered. Upon a window trigger, the supplied function is passed a list containing the contents of the window: ``function(items)``. The order of the window items in the list are the order in which they were each receive...
[ "Aggregates", "the", "contents", "of", "the", "window", "when", "the", "window", "is", "triggered", ".", "Upon", "a", "window", "trigger", "the", "supplied", "function", "is", "passed", "a", "list", "containing", "the", "contents", "of", "the", "window", ":"...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/topology.py#L2036-L2087
IBMStreams/pypi.streamsx
streamsx/st.py
get_rest_api
def get_rest_api(): """ Get the root URL for the IBM Streams REST API. """ assert _has_local_install url=[] ok = _run_st(['geturl', '--api'], lines=url) if not ok: raise ChildProcessError('streamtool geturl') return url[0]
python
def get_rest_api(): """ Get the root URL for the IBM Streams REST API. """ assert _has_local_install url=[] ok = _run_st(['geturl', '--api'], lines=url) if not ok: raise ChildProcessError('streamtool geturl') return url[0]
[ "def", "get_rest_api", "(", ")", ":", "assert", "_has_local_install", "url", "=", "[", "]", "ok", "=", "_run_st", "(", "[", "'geturl'", ",", "'--api'", "]", ",", "lines", "=", "url", ")", "if", "not", "ok", ":", "raise", "ChildProcessError", "(", "'str...
Get the root URL for the IBM Streams REST API.
[ "Get", "the", "root", "URL", "for", "the", "IBM", "Streams", "REST", "API", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/st.py#L25-L35
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
_get_package_name
def _get_package_name(module): """ Gets the package name given a module object Returns: str: If the module belongs to a package, the package name. if the module does not belong to a package, None or ''. """ try: # if __package__ is defined, use it package_...
python
def _get_package_name(module): """ Gets the package name given a module object Returns: str: If the module belongs to a package, the package name. if the module does not belong to a package, None or ''. """ try: # if __package__ is defined, use it package_...
[ "def", "_get_package_name", "(", "module", ")", ":", "try", ":", "# if __package__ is defined, use it", "package_name", "=", "module", ".", "__package__", "except", "AttributeError", ":", "package_name", "=", "None", "if", "package_name", "is", "None", ":", "# if __...
Gets the package name given a module object Returns: str: If the module belongs to a package, the package name. if the module does not belong to a package, None or ''.
[ "Gets", "the", "package", "name", "given", "a", "module", "object", "Returns", ":", "str", ":", "If", "the", "module", "belongs", "to", "a", "package", "the", "package", "name", ".", "if", "the", "module", "does", "not", "belong", "to", "a", "package", ...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L211-L233
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
_get_module_name
def _get_module_name(function): """ Gets the function's module name Resolves the __main__ module to an actual module name Returns: str: the function's module name """ module_name = function.__module__ if module_name == '__main__': # get the main module object of the function ...
python
def _get_module_name(function): """ Gets the function's module name Resolves the __main__ module to an actual module name Returns: str: the function's module name """ module_name = function.__module__ if module_name == '__main__': # get the main module object of the function ...
[ "def", "_get_module_name", "(", "function", ")", ":", "module_name", "=", "function", ".", "__module__", "if", "module_name", "==", "'__main__'", ":", "# get the main module object of the function", "main_module", "=", "inspect", ".", "getmodule", "(", "function", ")"...
Gets the function's module name Resolves the __main__ module to an actual module name Returns: str: the function's module name
[ "Gets", "the", "function", "s", "module", "name", "Resolves", "the", "__main__", "module", "to", "an", "actual", "module", "name", "Returns", ":", "str", ":", "the", "function", "s", "module", "name" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L235-L250
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
_is_builtin_module
def _is_builtin_module(module): """Is builtin or part of standard library """ if (not hasattr(module, '__file__')) or module.__name__ in sys.builtin_module_names: return True if module.__name__ in _stdlib._STD_LIB_MODULES: return True amp = os.path.abspath(module.__file__) if 's...
python
def _is_builtin_module(module): """Is builtin or part of standard library """ if (not hasattr(module, '__file__')) or module.__name__ in sys.builtin_module_names: return True if module.__name__ in _stdlib._STD_LIB_MODULES: return True amp = os.path.abspath(module.__file__) if 's...
[ "def", "_is_builtin_module", "(", "module", ")", ":", "if", "(", "not", "hasattr", "(", "module", ",", "'__file__'", ")", ")", "or", "module", ".", "__name__", "in", "sys", ".", "builtin_module_names", ":", "return", "True", "if", "module", ".", "__name__"...
Is builtin or part of standard library
[ "Is", "builtin", "or", "part", "of", "standard", "library" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L252-L267
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
_DependencyResolver._find_dependent_modules
def _find_dependent_modules(self, module): """ Return the set of dependent modules for used modules, classes and routines. """ dms = set() for um in inspect.getmembers(module, inspect.ismodule): dms.add(um[1]) for uc in inspect.getmembers(module, insp...
python
def _find_dependent_modules(self, module): """ Return the set of dependent modules for used modules, classes and routines. """ dms = set() for um in inspect.getmembers(module, inspect.ismodule): dms.add(um[1]) for uc in inspect.getmembers(module, insp...
[ "def", "_find_dependent_modules", "(", "self", ",", "module", ")", ":", "dms", "=", "set", "(", ")", "for", "um", "in", "inspect", ".", "getmembers", "(", "module", ",", "inspect", ".", "ismodule", ")", ":", "dms", ".", "add", "(", "um", "[", "1", ...
Return the set of dependent modules for used modules, classes and routines.
[ "Return", "the", "set", "of", "dependent", "modules", "for", "used", "modules", "classes", "and", "routines", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L35-L49
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
_DependencyResolver.add_dependencies
def add_dependencies(self, module): """ Adds a module and its dependencies to the list of dependencies. Top-level entry point for adding a module and its dependecies. """ if module in self._processed_modules: return None if hasattr(module, "__name__"): ...
python
def add_dependencies(self, module): """ Adds a module and its dependencies to the list of dependencies. Top-level entry point for adding a module and its dependecies. """ if module in self._processed_modules: return None if hasattr(module, "__name__"): ...
[ "def", "add_dependencies", "(", "self", ",", "module", ")", ":", "if", "module", "in", "self", ".", "_processed_modules", ":", "return", "None", "if", "hasattr", "(", "module", ",", "\"__name__\"", ")", ":", "mn", "=", "module", ".", "__name__", "else", ...
Adds a module and its dependencies to the list of dependencies. Top-level entry point for adding a module and its dependecies.
[ "Adds", "a", "module", "and", "its", "dependencies", "to", "the", "list", "of", "dependencies", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L56-L87
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
_DependencyResolver._include_module
def _include_module(self, module, mn): """ See if a module should be included or excluded based upon included_packages and excluded_packages. As some packages have the following format: scipy.special.specfun scipy.linalg Where the top-level package name is just a prefi...
python
def _include_module(self, module, mn): """ See if a module should be included or excluded based upon included_packages and excluded_packages. As some packages have the following format: scipy.special.specfun scipy.linalg Where the top-level package name is just a prefi...
[ "def", "_include_module", "(", "self", ",", "module", ",", "mn", ")", ":", "if", "mn", "in", "self", ".", "topology", ".", "include_packages", ":", "_debug", ".", "debug", "(", "\"_include_module:explicit using __include_packages: module=%s\"", ",", "mn", ")", "...
See if a module should be included or excluded based upon included_packages and excluded_packages. As some packages have the following format: scipy.special.specfun scipy.linalg Where the top-level package name is just a prefix to a longer package name, we don't want t...
[ "See", "if", "a", "module", "should", "be", "included", "or", "excluded", "based", "upon", "included_packages", "and", "excluded_packages", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L103-L138
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
_DependencyResolver._add_dependency
def _add_dependency(self, module, mn): """ Adds a module to the list of dependencies without handling the modules dependences. Modules in site-packages are excluded from being added into the toolkit. This mimics dill. """ _debug.debug("_add_dependency:module=%s",...
python
def _add_dependency(self, module, mn): """ Adds a module to the list of dependencies without handling the modules dependences. Modules in site-packages are excluded from being added into the toolkit. This mimics dill. """ _debug.debug("_add_dependency:module=%s",...
[ "def", "_add_dependency", "(", "self", ",", "module", ",", "mn", ")", ":", "_debug", ".", "debug", "(", "\"_add_dependency:module=%s\"", ",", "mn", ")", "if", "_is_streamsx_module", "(", "module", ")", ":", "_debug", ".", "debug", "(", "\"_add_dependency:strea...
Adds a module to the list of dependencies without handling the modules dependences. Modules in site-packages are excluded from being added into the toolkit. This mimics dill.
[ "Adds", "a", "module", "to", "the", "list", "of", "dependencies", "without", "handling", "the", "modules", "dependences", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L140-L199
raphaelm/django-hierarkey
hierarkey/proxy.py
HierarkeyProxy.freeze
def freeze(self) -> dict: """ Returns a dictionary of all settings set for this object, including any values of its parents or hardcoded defaults. """ settings = {} for key, v in self._h.defaults.items(): settings[key] = self._unserialize(v.value, v.type) ...
python
def freeze(self) -> dict: """ Returns a dictionary of all settings set for this object, including any values of its parents or hardcoded defaults. """ settings = {} for key, v in self._h.defaults.items(): settings[key] = self._unserialize(v.value, v.type) ...
[ "def", "freeze", "(", "self", ")", "->", "dict", ":", "settings", "=", "{", "}", "for", "key", ",", "v", "in", "self", ".", "_h", ".", "defaults", ".", "items", "(", ")", ":", "settings", "[", "key", "]", "=", "self", ".", "_unserialize", "(", ...
Returns a dictionary of all settings set for this object, including any values of its parents or hardcoded defaults.
[ "Returns", "a", "dictionary", "of", "all", "settings", "set", "for", "this", "object", "including", "any", "values", "of", "its", "parents", "or", "hardcoded", "defaults", "." ]
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/proxy.py#L72-L84
raphaelm/django-hierarkey
hierarkey/proxy.py
HierarkeyProxy.get
def get(self, key: str, default=None, as_type: type = None, binary_file=False): """ Get a setting specified by key ``key``. Normally, settings are strings, but if you put non-strings into the settings object, you can request unserialization by specifying ``as_type``. If the key does not ...
python
def get(self, key: str, default=None, as_type: type = None, binary_file=False): """ Get a setting specified by key ``key``. Normally, settings are strings, but if you put non-strings into the settings object, you can request unserialization by specifying ``as_type``. If the key does not ...
[ "def", "get", "(", "self", ",", "key", ":", "str", ",", "default", "=", "None", ",", "as_type", ":", "type", "=", "None", ",", "binary_file", "=", "False", ")", ":", "if", "as_type", "is", "None", "and", "key", "in", "self", ".", "_h", ".", "defa...
Get a setting specified by key ``key``. Normally, settings are strings, but if you put non-strings into the settings object, you can request unserialization by specifying ``as_type``. If the key does not have a harcdoded default type, omitting ``as_type`` always will get you a string. I...
[ "Get", "a", "setting", "specified", "by", "key", "key", ".", "Normally", "settings", "are", "strings", "but", "if", "you", "put", "non", "-", "strings", "into", "the", "settings", "object", "you", "can", "request", "unserialization", "by", "specifying", "as_...
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/proxy.py#L144-L173
raphaelm/django-hierarkey
hierarkey/proxy.py
HierarkeyProxy.set
def set(self, key: str, value: Any) -> None: """ Stores a setting to the database of its object. The write to the database is performed immediately and the cache in the cache backend is flushed. The cache within this object will be updated correctly. """ wc = se...
python
def set(self, key: str, value: Any) -> None: """ Stores a setting to the database of its object. The write to the database is performed immediately and the cache in the cache backend is flushed. The cache within this object will be updated correctly. """ wc = se...
[ "def", "set", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Any", ")", "->", "None", ":", "wc", "=", "self", ".", "_write_cache", "(", ")", "if", "key", "in", "wc", ":", "s", "=", "wc", "[", "key", "]", "else", ":", "s", "=", "se...
Stores a setting to the database of its object. The write to the database is performed immediately and the cache in the cache backend is flushed. The cache within this object will be updated correctly.
[ "Stores", "a", "setting", "to", "the", "database", "of", "its", "object", ".", "The", "write", "to", "the", "database", "is", "performed", "immediately", "and", "the", "cache", "in", "the", "cache", "backend", "is", "flushed", ".", "The", "cache", "within"...
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/proxy.py#L191-L207
raphaelm/django-hierarkey
hierarkey/proxy.py
HierarkeyProxy.delete
def delete(self, key: str) -> None: """ Deletes a setting from this object's storage. The write to the database is performed immediately and the cache in the cache backend is flushed. The cache within this object will be updated correctly. """ if key in self._wri...
python
def delete(self, key: str) -> None: """ Deletes a setting from this object's storage. The write to the database is performed immediately and the cache in the cache backend is flushed. The cache within this object will be updated correctly. """ if key in self._wri...
[ "def", "delete", "(", "self", ",", "key", ":", "str", ")", "->", "None", ":", "if", "key", "in", "self", ".", "_write_cache", "(", ")", ":", "self", ".", "_write_cache", "(", ")", "[", "key", "]", ".", "delete", "(", ")", "del", "self", ".", "_...
Deletes a setting from this object's storage. The write to the database is performed immediately and the cache in the cache backend is flushed. The cache within this object will be updated correctly.
[ "Deletes", "a", "setting", "from", "this", "object", "s", "storage", ".", "The", "write", "to", "the", "database", "is", "performed", "immediately", "and", "the", "cache", "in", "the", "cache", "backend", "is", "flushed", ".", "The", "cache", "within", "th...
train
https://github.com/raphaelm/django-hierarkey/blob/3ca822f94fa633c9a6d5abe9c80cb1551299ae46/hierarkey/proxy.py#L217-L231
IBMStreams/pypi.streamsx
streamsx/rest.py
_get_vcap_services
def _get_vcap_services(vcap_services=None): """Retrieves the VCAP Services information from the `ConfigParams.VCAP_SERVICES` field in the config object. If `vcap_services` is not specified, it takes the information from VCAP_SERVICES environment variable. Args: vcap_services (str): Try to parse as ...
python
def _get_vcap_services(vcap_services=None): """Retrieves the VCAP Services information from the `ConfigParams.VCAP_SERVICES` field in the config object. If `vcap_services` is not specified, it takes the information from VCAP_SERVICES environment variable. Args: vcap_services (str): Try to parse as ...
[ "def", "_get_vcap_services", "(", "vcap_services", "=", "None", ")", ":", "vcap_services", "=", "vcap_services", "or", "os", ".", "environ", ".", "get", "(", "'VCAP_SERVICES'", ")", "if", "not", "vcap_services", ":", "raise", "ValueError", "(", "\"VCAP_SERVICES ...
Retrieves the VCAP Services information from the `ConfigParams.VCAP_SERVICES` field in the config object. If `vcap_services` is not specified, it takes the information from VCAP_SERVICES environment variable. Args: vcap_services (str): Try to parse as a JSON string, otherwise, try open it as a file. ...
[ "Retrieves", "the", "VCAP", "Services", "information", "from", "the", "ConfigParams", ".", "VCAP_SERVICES", "field", "in", "the", "config", "object", ".", "If", "vcap_services", "is", "not", "specified", "it", "takes", "the", "information", "from", "VCAP_SERVICES"...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L309-L342
IBMStreams/pypi.streamsx
streamsx/rest.py
_get_credentials
def _get_credentials(vcap_services, service_name=None): """Retrieves the credentials of the VCAP Service of the specified `service_name`. If `service_name` is not specified, it takes the information from STREAMING_ANALYTICS_SERVICE_NAME environment variable. Args: vcap_services (dict): A dict ...
python
def _get_credentials(vcap_services, service_name=None): """Retrieves the credentials of the VCAP Service of the specified `service_name`. If `service_name` is not specified, it takes the information from STREAMING_ANALYTICS_SERVICE_NAME environment variable. Args: vcap_services (dict): A dict ...
[ "def", "_get_credentials", "(", "vcap_services", ",", "service_name", "=", "None", ")", ":", "service_name", "=", "service_name", "or", "os", ".", "environ", ".", "get", "(", "'STREAMING_ANALYTICS_SERVICE_NAME'", ",", "None", ")", "# Get the service corresponding to t...
Retrieves the credentials of the VCAP Service of the specified `service_name`. If `service_name` is not specified, it takes the information from STREAMING_ANALYTICS_SERVICE_NAME environment variable. Args: vcap_services (dict): A dict representation of the VCAP Services information. servic...
[ "Retrieves", "the", "credentials", "of", "the", "VCAP", "Service", "of", "the", "specified", "service_name", ".", "If", "service_name", "is", "not", "specified", "it", "takes", "the", "information", "from", "STREAMING_ANALYTICS_SERVICE_NAME", "environment", "variable"...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L345-L372
IBMStreams/pypi.streamsx
streamsx/rest.py
_get_rest_api_url_from_creds
def _get_rest_api_url_from_creds(session, credentials): """Retrieves the Streams REST API URL from the provided credentials. Args: session (:py:class:`requests.Session`): A Requests session object for making REST calls credentials (dict): A dict representation of the credentials. Returns: ...
python
def _get_rest_api_url_from_creds(session, credentials): """Retrieves the Streams REST API URL from the provided credentials. Args: session (:py:class:`requests.Session`): A Requests session object for making REST calls credentials (dict): A dict representation of the credentials. Returns: ...
[ "def", "_get_rest_api_url_from_creds", "(", "session", ",", "credentials", ")", ":", "resources_url", "=", "credentials", "[", "'rest_url'", "]", "+", "credentials", "[", "'resources_path'", "]", "try", ":", "response_raw", "=", "session", ".", "get", "(", "reso...
Retrieves the Streams REST API URL from the provided credentials. Args: session (:py:class:`requests.Session`): A Requests session object for making REST calls credentials (dict): A dict representation of the credentials. Returns: str: The remote Streams REST API URL.
[ "Retrieves", "the", "Streams", "REST", "API", "URL", "from", "the", "provided", "credentials", ".", "Args", ":", "session", "(", ":", "py", ":", "class", ":", "requests", ".", "Session", ")", ":", "A", "Requests", "session", "object", "for", "making", "R...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L375-L394
IBMStreams/pypi.streamsx
streamsx/rest.py
_get_iam_rest_api_url_from_creds
def _get_iam_rest_api_url_from_creds(rest_client, credentials): """Retrieves the Streams REST API URL from the provided credentials using iam authentication. Args: rest_client (:py:class:`rest_primitives._IAMStreamsRestClient`): A client for making REST calls using IAM authentication credential...
python
def _get_iam_rest_api_url_from_creds(rest_client, credentials): """Retrieves the Streams REST API URL from the provided credentials using iam authentication. Args: rest_client (:py:class:`rest_primitives._IAMStreamsRestClient`): A client for making REST calls using IAM authentication credential...
[ "def", "_get_iam_rest_api_url_from_creds", "(", "rest_client", ",", "credentials", ")", ":", "res", "=", "rest_client", ".", "make_request", "(", "credentials", "[", "_IAMConstants", ".", "V2_REST_URL", "]", ")", "base", "=", "res", "[", "'streams_self'", "]", "...
Retrieves the Streams REST API URL from the provided credentials using iam authentication. Args: rest_client (:py:class:`rest_primitives._IAMStreamsRestClient`): A client for making REST calls using IAM authentication credentials (dict): A dict representation of the credentials. Returns: ...
[ "Retrieves", "the", "Streams", "REST", "API", "URL", "from", "the", "provided", "credentials", "using", "iam", "authentication", ".", "Args", ":", "rest_client", "(", ":", "py", ":", "class", ":", "rest_primitives", ".", "_IAMStreamsRestClient", ")", ":", "A",...
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L396-L407
IBMStreams/pypi.streamsx
streamsx/rest.py
StreamsConnection.resource_url
def resource_url(self): """str: Root URL for IBM Streams REST API""" self._resource_url = self._resource_url or st.get_rest_api() return self._resource_url
python
def resource_url(self): """str: Root URL for IBM Streams REST API""" self._resource_url = self._resource_url or st.get_rest_api() return self._resource_url
[ "def", "resource_url", "(", "self", ")", ":", "self", ".", "_resource_url", "=", "self", ".", "_resource_url", "or", "st", ".", "get_rest_api", "(", ")", "return", "self", ".", "_resource_url" ]
str: Root URL for IBM Streams REST API
[ "str", ":", "Root", "URL", "for", "IBM", "Streams", "REST", "API" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L139-L142
IBMStreams/pypi.streamsx
streamsx/rest.py
StreamsConnection._get_element_by_id
def _get_element_by_id(self, resource_name, eclass, id): """Get a single element matching an id""" elements = self._get_elements(resource_name, eclass, id=id) if not elements: raise ValueError("No resource matching: {0}".format(id)) if len(elements) == 1: return e...
python
def _get_element_by_id(self, resource_name, eclass, id): """Get a single element matching an id""" elements = self._get_elements(resource_name, eclass, id=id) if not elements: raise ValueError("No resource matching: {0}".format(id)) if len(elements) == 1: return e...
[ "def", "_get_element_by_id", "(", "self", ",", "resource_name", ",", "eclass", ",", "id", ")", ":", "elements", "=", "self", ".", "_get_elements", "(", "resource_name", ",", "eclass", ",", "id", "=", "id", ")", "if", "not", "elements", ":", "raise", "Val...
Get a single element matching an id
[ "Get", "a", "single", "element", "matching", "an", "id" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L154-L161
IBMStreams/pypi.streamsx
streamsx/rest.py
StreamsConnection.get_domains
def get_domains(self): """Retrieves available domains. Returns: :py:obj:`list` of :py:class:`~.rest_primitives.Domain`: List of available domains """ # Domains are fixed and actually only one per REST api. if self._domains is None: self._domains = self._g...
python
def get_domains(self): """Retrieves available domains. Returns: :py:obj:`list` of :py:class:`~.rest_primitives.Domain`: List of available domains """ # Domains are fixed and actually only one per REST api. if self._domains is None: self._domains = self._g...
[ "def", "get_domains", "(", "self", ")", ":", "# Domains are fixed and actually only one per REST api.", "if", "self", ".", "_domains", "is", "None", ":", "self", ".", "_domains", "=", "self", ".", "_get_elements", "(", "'domains'", ",", "Domain", ")", "return", ...
Retrieves available domains. Returns: :py:obj:`list` of :py:class:`~.rest_primitives.Domain`: List of available domains
[ "Retrieves", "available", "domains", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L163-L172
IBMStreams/pypi.streamsx
streamsx/rest.py
StreamsConnection.get_resources
def get_resources(self): """Retrieves a list of all known Streams high-level REST resources. Returns: :py:obj:`list` of :py:class:`~.rest_primitives.RestResource`: List of all Streams high-level REST resources. """ json_resources = self.rest_client.make_request(self.resource...
python
def get_resources(self): """Retrieves a list of all known Streams high-level REST resources. Returns: :py:obj:`list` of :py:class:`~.rest_primitives.RestResource`: List of all Streams high-level REST resources. """ json_resources = self.rest_client.make_request(self.resource...
[ "def", "get_resources", "(", "self", ")", ":", "json_resources", "=", "self", ".", "rest_client", ".", "make_request", "(", "self", ".", "resource_url", ")", "[", "'resources'", "]", "return", "[", "RestResource", "(", "resource", ",", "self", ".", "rest_cli...
Retrieves a list of all known Streams high-level REST resources. Returns: :py:obj:`list` of :py:class:`~.rest_primitives.RestResource`: List of all Streams high-level REST resources.
[ "Retrieves", "a", "list", "of", "all", "known", "Streams", "high", "-", "level", "REST", "resources", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L218-L225
IBMStreams/pypi.streamsx
streamsx/rest.py
StreamingAnalyticsConnection.of_definition
def of_definition(service_def): """Create a connection to a Streaming Analytics service. The single service is defined by `service_def` which can be one of * The `service credentials` copied from the `Service credentials` page of the service console (not the Streams console). Credentials ...
python
def of_definition(service_def): """Create a connection to a Streaming Analytics service. The single service is defined by `service_def` which can be one of * The `service credentials` copied from the `Service credentials` page of the service console (not the Streams console). Credentials ...
[ "def", "of_definition", "(", "service_def", ")", ":", "vcap_services", "=", "streamsx", ".", "topology", ".", "context", ".", "_vcap_from_service_definition", "(", "service_def", ")", "service_name", "=", "streamsx", ".", "topology", ".", "context", ".", "_name_fr...
Create a connection to a Streaming Analytics service. The single service is defined by `service_def` which can be one of * The `service credentials` copied from the `Service credentials` page of the service console (not the Streams console). Credentials are provided in JSON format. They contain ...
[ "Create", "a", "connection", "to", "a", "Streaming", "Analytics", "service", "." ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L271-L287
IBMStreams/pypi.streamsx
streamsx/rest.py
StreamingAnalyticsConnection.resource_url
def resource_url(self): """str: Root URL for IBM Streams REST API""" if self._iam: self._resource_url = self._resource_url or _get_iam_rest_api_url_from_creds(self.rest_client, self.credentials) else: self._resource_url = self._resource_url or _get_rest_api_url_from_creds...
python
def resource_url(self): """str: Root URL for IBM Streams REST API""" if self._iam: self._resource_url = self._resource_url or _get_iam_rest_api_url_from_creds(self.rest_client, self.credentials) else: self._resource_url = self._resource_url or _get_rest_api_url_from_creds...
[ "def", "resource_url", "(", "self", ")", ":", "if", "self", ".", "_iam", ":", "self", ".", "_resource_url", "=", "self", ".", "_resource_url", "or", "_get_iam_rest_api_url_from_creds", "(", "self", ".", "rest_client", ",", "self", ".", "credentials", ")", "e...
str: Root URL for IBM Streams REST API
[ "str", ":", "Root", "URL", "for", "IBM", "Streams", "REST", "API" ]
train
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest.py#L290-L296
orcasgit/django-tastypie-oauth
tastypie_oauth/authentication.py
OAuth20Authentication.is_authenticated
def is_authenticated(self, request, **kwargs): """ Verify 2-legged oauth request. Parameters accepted as values in the "Authorization" header, as a GET request parameter, or in a POST body. """ log.info("OAuth20Authentication") try: key = request.GET.g...
python
def is_authenticated(self, request, **kwargs): """ Verify 2-legged oauth request. Parameters accepted as values in the "Authorization" header, as a GET request parameter, or in a POST body. """ log.info("OAuth20Authentication") try: key = request.GET.g...
[ "def", "is_authenticated", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "log", ".", "info", "(", "\"OAuth20Authentication\"", ")", "try", ":", "key", "=", "request", ".", "GET", ".", "get", "(", "'oauth_consumer_key'", ")", "if", "not"...
Verify 2-legged oauth request. Parameters accepted as values in the "Authorization" header, as a GET request parameter, or in a POST body.
[ "Verify", "2", "-", "legged", "oauth", "request", ".", "Parameters", "accepted", "as", "values", "in", "the", "Authorization", "header", "as", "a", "GET", "request", "parameter", "or", "in", "a", "POST", "body", "." ]
train
https://github.com/orcasgit/django-tastypie-oauth/blob/01c40de7b86ae3c6cc9e9463ec9bcecbb22b897e/tastypie_oauth/authentication.py#L39-L80
orcasgit/django-tastypie-oauth
tastypie_oauth/authentication.py
OAuth2ScopedAuthentication.check_scope
def check_scope(self, token, request): http_method = request.method if not hasattr(self, http_method): raise OAuthError("HTTP method is not recognized") required_scopes = getattr(self, http_method) # a None scope means always allowed if required_scopes is None: ...
python
def check_scope(self, token, request): http_method = request.method if not hasattr(self, http_method): raise OAuthError("HTTP method is not recognized") required_scopes = getattr(self, http_method) # a None scope means always allowed if required_scopes is None: ...
[ "def", "check_scope", "(", "self", ",", "token", ",", "request", ")", ":", "http_method", "=", "request", ".", "method", "if", "not", "hasattr", "(", "self", ",", "http_method", ")", ":", "raise", "OAuthError", "(", "\"HTTP method is not recognized\"", ")", ...
The required scope is either a string or an iterable. If string, check if it is allowed for our access token otherwise, iterate through the required_scopes to see which scopes are allowed
[ "The", "required", "scope", "is", "either", "a", "string", "or", "an", "iterable", ".", "If", "string", "check", "if", "it", "is", "allowed", "for", "our", "access", "token", "otherwise", "iterate", "through", "the", "required_scopes", "to", "see", "which", ...
train
https://github.com/orcasgit/django-tastypie-oauth/blob/01c40de7b86ae3c6cc9e9463ec9bcecbb22b897e/tastypie_oauth/authentication.py#L140-L166
feluxe/sty
sty/primitive.py
_is_args_eightbit
def _is_args_eightbit(*args) -> bool: """ Check if input matches type: renderer.eightbit. """ if not args: return False elif args[0] is 0: return True elif isinstance(args[0], int): return True else: return False
python
def _is_args_eightbit(*args) -> bool: """ Check if input matches type: renderer.eightbit. """ if not args: return False elif args[0] is 0: return True elif isinstance(args[0], int): return True else: return False
[ "def", "_is_args_eightbit", "(", "*", "args", ")", "->", "bool", ":", "if", "not", "args", ":", "return", "False", "elif", "args", "[", "0", "]", "is", "0", ":", "return", "True", "elif", "isinstance", "(", "args", "[", "0", "]", ",", "int", ")", ...
Check if input matches type: renderer.eightbit.
[ "Check", "if", "input", "matches", "type", ":", "renderer", ".", "eightbit", "." ]
train
https://github.com/feluxe/sty/blob/60af9c1c59556a6f285d3d0ba4b8e125f8adc107/sty/primitive.py#L17-L30
feluxe/sty
sty/primitive.py
Base.as_dict
def as_dict(self) -> Dict[str, str]: """ Export color register as dict. """ items: Dict[str, str] = {} for k, v in self.items(): if type(v) is str: items.update({k: v}) return items
python
def as_dict(self) -> Dict[str, str]: """ Export color register as dict. """ items: Dict[str, str] = {} for k, v in self.items(): if type(v) is str: items.update({k: v}) return items
[ "def", "as_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "items", ":", "Dict", "[", "str", ",", "str", "]", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "items", "(", ")", ":", "if", "type", "(", "v", ...
Export color register as dict.
[ "Export", "color", "register", "as", "dict", "." ]
train
https://github.com/feluxe/sty/blob/60af9c1c59556a6f285d3d0ba4b8e125f8adc107/sty/primitive.py#L170-L181
feluxe/sty
sty/primitive.py
Base.as_namedtuple
def as_namedtuple(self): """ Export color register as namedtuple. """ d = self.as_dict() return namedtuple('ColorRegister', d.keys())(*d.values())
python
def as_namedtuple(self): """ Export color register as namedtuple. """ d = self.as_dict() return namedtuple('ColorRegister', d.keys())(*d.values())
[ "def", "as_namedtuple", "(", "self", ")", ":", "d", "=", "self", ".", "as_dict", "(", ")", "return", "namedtuple", "(", "'ColorRegister'", ",", "d", ".", "keys", "(", ")", ")", "(", "*", "d", ".", "values", "(", ")", ")" ]
Export color register as namedtuple.
[ "Export", "color", "register", "as", "namedtuple", "." ]
train
https://github.com/feluxe/sty/blob/60af9c1c59556a6f285d3d0ba4b8e125f8adc107/sty/primitive.py#L183-L188
tomduck/pandoc-fignos
pandoc_fignos.py
_extract_attrs
def _extract_attrs(x, n): """Extracts attributes for an image. n is the index where the attributes begin. Extracted elements are deleted from the element list x. Attrs are returned in pandoc format. """ try: return extract_attrs(x, n) except (ValueError, IndexError): if PAND...
python
def _extract_attrs(x, n): """Extracts attributes for an image. n is the index where the attributes begin. Extracted elements are deleted from the element list x. Attrs are returned in pandoc format. """ try: return extract_attrs(x, n) except (ValueError, IndexError): if PAND...
[ "def", "_extract_attrs", "(", "x", ",", "n", ")", ":", "try", ":", "return", "extract_attrs", "(", "x", ",", "n", ")", "except", "(", "ValueError", ",", "IndexError", ")", ":", "if", "PANDOCVERSION", "<", "'1.16'", ":", "# Look for attributes attached to the...
Extracts attributes for an image. n is the index where the attributes begin. Extracted elements are deleted from the element list x. Attrs are returned in pandoc format.
[ "Extracts", "attributes", "for", "an", "image", ".", "n", "is", "the", "index", "where", "the", "attributes", "begin", ".", "Extracted", "elements", "are", "deleted", "from", "the", "element", "list", "x", ".", "Attrs", "are", "returned", "in", "pandoc", "...
train
https://github.com/tomduck/pandoc-fignos/blob/44776d885b8101d9d6aeb6845b17ad1625e88e6f/pandoc_fignos.py#L93-L117
tomduck/pandoc-fignos
pandoc_fignos.py
_process_figure
def _process_figure(value, fmt): """Processes the figure. Returns a dict containing figure properties.""" # pylint: disable=global-statement global Nreferences # Global references counter global has_unnumbered_figures # Flags unnumbered figures were found global cursec ...
python
def _process_figure(value, fmt): """Processes the figure. Returns a dict containing figure properties.""" # pylint: disable=global-statement global Nreferences # Global references counter global has_unnumbered_figures # Flags unnumbered figures were found global cursec ...
[ "def", "_process_figure", "(", "value", ",", "fmt", ")", ":", "# pylint: disable=global-statement", "global", "Nreferences", "# Global references counter", "global", "has_unnumbered_figures", "# Flags unnumbered figures were found", "global", "cursec", "# Current section", "# Par...
Processes the figure. Returns a dict containing figure properties.
[ "Processes", "the", "figure", ".", "Returns", "a", "dict", "containing", "figure", "properties", "." ]
train
https://github.com/tomduck/pandoc-fignos/blob/44776d885b8101d9d6aeb6845b17ad1625e88e6f/pandoc_fignos.py#L121-L201
tomduck/pandoc-fignos
pandoc_fignos.py
process_figures
def process_figures(key, value, fmt, meta): # pylint: disable=unused-argument """Processes the figures.""" global has_unnumbered_figures # pylint: disable=global-statement # Process figures wrapped in Para elements if key == 'Para' and len(value) == 1 and \ value[0]['t'] == 'Image' and value[0]...
python
def process_figures(key, value, fmt, meta): # pylint: disable=unused-argument """Processes the figures.""" global has_unnumbered_figures # pylint: disable=global-statement # Process figures wrapped in Para elements if key == 'Para' and len(value) == 1 and \ value[0]['t'] == 'Image' and value[0]...
[ "def", "process_figures", "(", "key", ",", "value", ",", "fmt", ",", "meta", ")", ":", "# pylint: disable=unused-argument", "global", "has_unnumbered_figures", "# pylint: disable=global-statement", "# Process figures wrapped in Para elements", "if", "key", "==", "'Para'", "...
Processes the figures.
[ "Processes", "the", "figures", "." ]
train
https://github.com/tomduck/pandoc-fignos/blob/44776d885b8101d9d6aeb6845b17ad1625e88e6f/pandoc_fignos.py#L204-L266
tomduck/pandoc-fignos
pandoc_fignos.py
main
def main(): """Filters the document AST.""" # pylint: disable=global-statement global PANDOCVERSION global Image # Get the output format and document fmt = args.fmt doc = json.loads(STDIN.read()) # Initialize pandocxnos # pylint: disable=too-many-function-args PANDOCVERSION = ...
python
def main(): """Filters the document AST.""" # pylint: disable=global-statement global PANDOCVERSION global Image # Get the output format and document fmt = args.fmt doc = json.loads(STDIN.read()) # Initialize pandocxnos # pylint: disable=too-many-function-args PANDOCVERSION = ...
[ "def", "main", "(", ")", ":", "# pylint: disable=global-statement", "global", "PANDOCVERSION", "global", "Image", "# Get the output format and document", "fmt", "=", "args", ".", "fmt", "doc", "=", "json", ".", "loads", "(", "STDIN", ".", "read", "(", ")", ")", ...
Filters the document AST.
[ "Filters", "the", "document", "AST", "." ]
train
https://github.com/tomduck/pandoc-fignos/blob/44776d885b8101d9d6aeb6845b17ad1625e88e6f/pandoc_fignos.py#L390-L468
samluescher/django-media-tree
media_tree/admin/filenode_admin.py
FileNodeAdmin.i18n_javascript
def i18n_javascript(self, request): """ Displays the i18n JavaScript that the Django admin requires. This takes into account the USE_I18N setting. If it's set to False, the generated JavaScript will be leaner and faster. """ if settings.USE_I18N: from django....
python
def i18n_javascript(self, request): """ Displays the i18n JavaScript that the Django admin requires. This takes into account the USE_I18N setting. If it's set to False, the generated JavaScript will be leaner and faster. """ if settings.USE_I18N: from django....
[ "def", "i18n_javascript", "(", "self", ",", "request", ")", ":", "if", "settings", ".", "USE_I18N", ":", "from", "django", ".", "views", ".", "i18n", "import", "javascript_catalog", "else", ":", "from", "django", ".", "views", ".", "i18n", "import", "null_...
Displays the i18n JavaScript that the Django admin requires. This takes into account the USE_I18N setting. If it's set to False, the generated JavaScript will be leaner and faster.
[ "Displays", "the", "i18n", "JavaScript", "that", "the", "Django", "admin", "requires", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/filenode_admin.py#L364-L375
samluescher/django-media-tree
media_tree/templatetags/media_tree_tags.py
file_links
def file_links(items, opts=None): """ Turns a (optionally nested) list of FileNode objects into a list of strings, linking to the associated files. """ result = [] kwargs = get_kwargs_for_file_link(opts) for item in items: if isinstance(item, FileNode): result.append(get_file_link(item, **kwargs)) else: ...
python
def file_links(items, opts=None): """ Turns a (optionally nested) list of FileNode objects into a list of strings, linking to the associated files. """ result = [] kwargs = get_kwargs_for_file_link(opts) for item in items: if isinstance(item, FileNode): result.append(get_file_link(item, **kwargs)) else: ...
[ "def", "file_links", "(", "items", ",", "opts", "=", "None", ")", ":", "result", "=", "[", "]", "kwargs", "=", "get_kwargs_for_file_link", "(", "opts", ")", "for", "item", "in", "items", ":", "if", "isinstance", "(", "item", ",", "FileNode", ")", ":", ...
Turns a (optionally nested) list of FileNode objects into a list of strings, linking to the associated files.
[ "Turns", "a", "(", "optionally", "nested", ")", "list", "of", "FileNode", "objects", "into", "a", "list", "of", "strings", "linking", "to", "the", "associated", "files", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/templatetags/media_tree_tags.py#L21-L33
samluescher/django-media-tree
media_tree/admin/change_list.py
MediaTreeChangeList.get_results
def get_results(self, request): """ Temporarily decreases the `level` attribute of all search results in order to prevent indendation when displaying them. """ super(MediaTreeChangeList, self).get_results(request) try: reduce_levels = abs(int(get_request_attr(...
python
def get_results(self, request): """ Temporarily decreases the `level` attribute of all search results in order to prevent indendation when displaying them. """ super(MediaTreeChangeList, self).get_results(request) try: reduce_levels = abs(int(get_request_attr(...
[ "def", "get_results", "(", "self", ",", "request", ")", ":", "super", "(", "MediaTreeChangeList", ",", "self", ")", ".", "get_results", "(", "request", ")", "try", ":", "reduce_levels", "=", "abs", "(", "int", "(", "get_request_attr", "(", "request", ",", ...
Temporarily decreases the `level` attribute of all search results in order to prevent indendation when displaying them.
[ "Temporarily", "decreases", "the", "level", "attribute", "of", "all", "search", "results", "in", "order", "to", "prevent", "indendation", "when", "displaying", "them", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/change_list.py#L57-L77
samluescher/django-media-tree
media_tree/south_migrations/0004_reset_has_metadata.py
Migration.forwards
def forwards(self, orm): "Write your forwards methods here." for node in orm.FileNode.objects.all(): node.save()
python
def forwards(self, orm): "Write your forwards methods here." for node in orm.FileNode.objects.all(): node.save()
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "for", "node", "in", "orm", ".", "FileNode", ".", "objects", ".", "all", "(", ")", ":", "node", ".", "save", "(", ")" ]
Write your forwards methods here.
[ "Write", "your", "forwards", "methods", "here", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/south_migrations/0004_reset_has_metadata.py#L9-L12
samluescher/django-media-tree
media_tree/media_backends/__init__.py
get_media_backend
def get_media_backend(fail_silently=True, handles_media_types=None, handles_file_extensions=None, supports_thumbnails=None): """ Returns the MediaBackend subclass that is configured for use with media_tree. """ backends = app_settings.MEDIA_TREE_MEDIA_BACKENDS if no...
python
def get_media_backend(fail_silently=True, handles_media_types=None, handles_file_extensions=None, supports_thumbnails=None): """ Returns the MediaBackend subclass that is configured for use with media_tree. """ backends = app_settings.MEDIA_TREE_MEDIA_BACKENDS if no...
[ "def", "get_media_backend", "(", "fail_silently", "=", "True", ",", "handles_media_types", "=", "None", ",", "handles_file_extensions", "=", "None", ",", "supports_thumbnails", "=", "None", ")", ":", "backends", "=", "app_settings", ".", "MEDIA_TREE_MEDIA_BACKENDS", ...
Returns the MediaBackend subclass that is configured for use with media_tree.
[ "Returns", "the", "MediaBackend", "subclass", "that", "is", "configured", "for", "use", "with", "media_tree", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/media_backends/__init__.py#L11-L36
samluescher/django-media-tree
media_tree/templatetags/media_tree_thumbnail.py
thumbnail_size
def thumbnail_size(parser, token): """Returns a pre-configured thumbnail size, or assigns it to a context variable. Basic tag syntax:: {% thumbnail_size [size_name] [as var_name] %} The ``size`` parameter can be any of the size names configured using the setting ``MEDIA_TREE_THUMB...
python
def thumbnail_size(parser, token): """Returns a pre-configured thumbnail size, or assigns it to a context variable. Basic tag syntax:: {% thumbnail_size [size_name] [as var_name] %} The ``size`` parameter can be any of the size names configured using the setting ``MEDIA_TREE_THUMB...
[ "def", "thumbnail_size", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "tag", "=", "args", ".", "pop", "(", "0", ")", "if", "len", "(", "args", ")", ">=", "2", "and", "args", "[", "-", "2", "]", "...
Returns a pre-configured thumbnail size, or assigns it to a context variable. Basic tag syntax:: {% thumbnail_size [size_name] [as var_name] %} The ``size`` parameter can be any of the size names configured using the setting ``MEDIA_TREE_THUMBNAIL_SIZES``. If omitted, the default size...
[ "Returns", "a", "pre", "-", "configured", "thumbnail", "size", "or", "assigns", "it", "to", "a", "context", "variable", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/templatetags/media_tree_thumbnail.py#L63-L105
analyzere/analyzere-python
analyzere/requestor.py
request
def request(method, path, params=None, data=None, auto_retry=True): """ method - HTTP method. e.g. get, put, post, etc. path - Path to resource. e.g. /loss_sets/1234 params - Parameter to pass in the query string data - Dictionary of parameters to pass in the request body """ body = None ...
python
def request(method, path, params=None, data=None, auto_retry=True): """ method - HTTP method. e.g. get, put, post, etc. path - Path to resource. e.g. /loss_sets/1234 params - Parameter to pass in the query string data - Dictionary of parameters to pass in the request body """ body = None ...
[ "def", "request", "(", "method", ",", "path", ",", "params", "=", "None", ",", "data", "=", "None", ",", "auto_retry", "=", "True", ")", ":", "body", "=", "None", "if", "data", "is", "not", "None", ":", "body", "=", "json", ".", "dumps", "(", "da...
method - HTTP method. e.g. get, put, post, etc. path - Path to resource. e.g. /loss_sets/1234 params - Parameter to pass in the query string data - Dictionary of parameters to pass in the request body
[ "method", "-", "HTTP", "method", ".", "e", ".", "g", ".", "get", "put", "post", "etc", ".", "path", "-", "Path", "to", "resource", ".", "e", ".", "g", ".", "/", "loss_sets", "/", "1234", "params", "-", "Parameter", "to", "pass", "in", "the", "que...
train
https://github.com/analyzere/analyzere-python/blob/0593d5b7b69c4df6d6dbc80387cc6ff5dc5f4e8f/analyzere/requestor.py#L36-L61
analyzere/analyzere-python
analyzere/utils.py
file_length
def file_length(file_obj): """ Returns the length in bytes of a given file object. Necessary because os.fstat only works on real files and not file-like objects. This works on more types of streams, primarily StringIO. """ file_obj.seek(0, 2) length = file_obj.tell() file_obj.seek(0) ...
python
def file_length(file_obj): """ Returns the length in bytes of a given file object. Necessary because os.fstat only works on real files and not file-like objects. This works on more types of streams, primarily StringIO. """ file_obj.seek(0, 2) length = file_obj.tell() file_obj.seek(0) ...
[ "def", "file_length", "(", "file_obj", ")", ":", "file_obj", ".", "seek", "(", "0", ",", "2", ")", "length", "=", "file_obj", ".", "tell", "(", ")", "file_obj", ".", "seek", "(", "0", ")", "return", "length" ]
Returns the length in bytes of a given file object. Necessary because os.fstat only works on real files and not file-like objects. This works on more types of streams, primarily StringIO.
[ "Returns", "the", "length", "in", "bytes", "of", "a", "given", "file", "object", ".", "Necessary", "because", "os", ".", "fstat", "only", "works", "on", "real", "files", "and", "not", "file", "-", "like", "objects", ".", "This", "works", "on", "more", ...
train
https://github.com/analyzere/analyzere-python/blob/0593d5b7b69c4df6d6dbc80387cc6ff5dc5f4e8f/analyzere/utils.py#L55-L64
analyzere/analyzere-python
analyzere/utils.py
read_in_chunks
def read_in_chunks(file_obj, chunk_size): """Generator to read a file piece by piece.""" offset = 0 while True: data = file_obj.read(chunk_size) if not data: break yield data, offset offset += len(data)
python
def read_in_chunks(file_obj, chunk_size): """Generator to read a file piece by piece.""" offset = 0 while True: data = file_obj.read(chunk_size) if not data: break yield data, offset offset += len(data)
[ "def", "read_in_chunks", "(", "file_obj", ",", "chunk_size", ")", ":", "offset", "=", "0", "while", "True", ":", "data", "=", "file_obj", ".", "read", "(", "chunk_size", ")", "if", "not", "data", ":", "break", "yield", "data", ",", "offset", "offset", ...
Generator to read a file piece by piece.
[ "Generator", "to", "read", "a", "file", "piece", "by", "piece", "." ]
train
https://github.com/analyzere/analyzere-python/blob/0593d5b7b69c4df6d6dbc80387cc6ff5dc5f4e8f/analyzere/utils.py#L67-L75
analyzere/analyzere-python
analyzere/utils.py
parse_href
def parse_href(href): """Parses an Analyze Re href into collection name and ID""" url = urlparse(href) path = url.path.split('/') collection_name = path[1] id_ = path[2] return collection_name, id_
python
def parse_href(href): """Parses an Analyze Re href into collection name and ID""" url = urlparse(href) path = url.path.split('/') collection_name = path[1] id_ = path[2] return collection_name, id_
[ "def", "parse_href", "(", "href", ")", ":", "url", "=", "urlparse", "(", "href", ")", "path", "=", "url", ".", "path", ".", "split", "(", "'/'", ")", "collection_name", "=", "path", "[", "1", "]", "id_", "=", "path", "[", "2", "]", "return", "col...
Parses an Analyze Re href into collection name and ID
[ "Parses", "an", "Analyze", "Re", "href", "into", "collection", "name", "and", "ID" ]
train
https://github.com/analyzere/analyzere-python/blob/0593d5b7b69c4df6d6dbc80387cc6ff5dc5f4e8f/analyzere/utils.py#L78-L84
analyzere/analyzere-python
analyzere/utils.py
vectorize
def vectorize(values): """ Takes a value or list of values and returns a single result, joined by "," if necessary. """ if isinstance(values, list): return ','.join(str(v) for v in values) return values
python
def vectorize(values): """ Takes a value or list of values and returns a single result, joined by "," if necessary. """ if isinstance(values, list): return ','.join(str(v) for v in values) return values
[ "def", "vectorize", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "list", ")", ":", "return", "','", ".", "join", "(", "str", "(", "v", ")", "for", "v", "in", "values", ")", "return", "values" ]
Takes a value or list of values and returns a single result, joined by "," if necessary.
[ "Takes", "a", "value", "or", "list", "of", "values", "and", "returns", "a", "single", "result", "joined", "by", "if", "necessary", "." ]
train
https://github.com/analyzere/analyzere-python/blob/0593d5b7b69c4df6d6dbc80387cc6ff5dc5f4e8f/analyzere/utils.py#L87-L94
analyzere/analyzere-python
analyzere/utils.py
vectorize_range
def vectorize_range(values): """ This function is for url encoding. Takes a value or a tuple or list of tuples and returns a single result, tuples are joined by "," if necessary, elements in tuple are joined by '_' """ if isinstance(values, tuple): return '_'.join(str(i) for i in values)...
python
def vectorize_range(values): """ This function is for url encoding. Takes a value or a tuple or list of tuples and returns a single result, tuples are joined by "," if necessary, elements in tuple are joined by '_' """ if isinstance(values, tuple): return '_'.join(str(i) for i in values)...
[ "def", "vectorize_range", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "tuple", ")", ":", "return", "'_'", ".", "join", "(", "str", "(", "i", ")", "for", "i", "in", "values", ")", "if", "isinstance", "(", "values", ",", "list", ...
This function is for url encoding. Takes a value or a tuple or list of tuples and returns a single result, tuples are joined by "," if necessary, elements in tuple are joined by '_'
[ "This", "function", "is", "for", "url", "encoding", ".", "Takes", "a", "value", "or", "a", "tuple", "or", "list", "of", "tuples", "and", "returns", "a", "single", "result", "tuples", "are", "joined", "by", "if", "necessary", "elements", "in", "tuple", "a...
train
https://github.com/analyzere/analyzere-python/blob/0593d5b7b69c4df6d6dbc80387cc6ff5dc5f4e8f/analyzere/utils.py#L97-L109
samluescher/django-media-tree
media_tree/forms.py
FileNodeChoiceField.label_from_instance
def label_from_instance(self, obj): """ Creates labels which represent the tree level of each node when generating option labels. """ return u'%s %s %i' % (self.level_indicator * (getattr(obj, 'depth') - 1), smart_unicode(obj), obj.depth)
python
def label_from_instance(self, obj): """ Creates labels which represent the tree level of each node when generating option labels. """ return u'%s %s %i' % (self.level_indicator * (getattr(obj, 'depth') - 1), smart_unicode(obj), obj.depth)
[ "def", "label_from_instance", "(", "self", ",", "obj", ")", ":", "return", "u'%s %s %i'", "%", "(", "self", ".", "level_indicator", "*", "(", "getattr", "(", "obj", ",", "'depth'", ")", "-", "1", ")", ",", "smart_unicode", "(", "obj", ")", ",", "obj", ...
Creates labels which represent the tree level of each node when generating option labels.
[ "Creates", "labels", "which", "represent", "the", "tree", "level", "of", "each", "node", "when", "generating", "option", "labels", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/forms.py#L58-L63
analyzere/analyzere-python
analyzere/base_resources.py
DataResource.upload_data
def upload_data(self, file_or_str, chunk_size=analyzere.upload_chunk_size, poll_interval=analyzere.upload_poll_interval, upload_callback=lambda x: None, commit_callback=lambda x: None): """ Accepts a file-like object or string and uploads it. F...
python
def upload_data(self, file_or_str, chunk_size=analyzere.upload_chunk_size, poll_interval=analyzere.upload_poll_interval, upload_callback=lambda x: None, commit_callback=lambda x: None): """ Accepts a file-like object or string and uploads it. F...
[ "def", "upload_data", "(", "self", ",", "file_or_str", ",", "chunk_size", "=", "analyzere", ".", "upload_chunk_size", ",", "poll_interval", "=", "analyzere", ".", "upload_poll_interval", ",", "upload_callback", "=", "lambda", "x", ":", "None", ",", "commit_callbac...
Accepts a file-like object or string and uploads it. Files are automatically uploaded in chunks. The default chunk size is 16MiB and can be overwritten by specifying the number of bytes in the ``chunk_size`` variable. Accepts an optional poll_interval for temporarily overriding the ...
[ "Accepts", "a", "file", "-", "like", "object", "or", "string", "and", "uploads", "it", ".", "Files", "are", "automatically", "uploaded", "in", "chunks", ".", "The", "default", "chunk", "size", "is", "16MiB", "and", "can", "be", "overwritten", "by", "specif...
train
https://github.com/analyzere/analyzere-python/blob/0593d5b7b69c4df6d6dbc80387cc6ff5dc5f4e8f/analyzere/base_resources.py#L309-L366
samluescher/django-media-tree
media_tree/admin/actions/maintenance_actions.py
delete_orphaned_files
def delete_orphaned_files(modeladmin, request, queryset=None): """ Deletes orphaned files, i.e. media files existing in storage that are not in the database. """ execute = request.POST.get('execute') storage = get_media_storage() broken_node_links = [] orphaned_files_choices = [] ...
python
def delete_orphaned_files(modeladmin, request, queryset=None): """ Deletes orphaned files, i.e. media files existing in storage that are not in the database. """ execute = request.POST.get('execute') storage = get_media_storage() broken_node_links = [] orphaned_files_choices = [] ...
[ "def", "delete_orphaned_files", "(", "modeladmin", ",", "request", ",", "queryset", "=", "None", ")", ":", "execute", "=", "request", ".", "POST", ".", "get", "(", "'execute'", ")", "storage", "=", "get_media_storage", "(", ")", "broken_node_links", "=", "["...
Deletes orphaned files, i.e. media files existing in storage that are not in the database.
[ "Deletes", "orphaned", "files", "i", ".", "e", ".", "media", "files", "existing", "in", "storage", "that", "are", "not", "in", "the", "database", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/actions/maintenance_actions.py#L17-L69
samluescher/django-media-tree
media_tree/admin/actions/maintenance_actions.py
rebuild_tree
def rebuild_tree(modeladmin, request, queryset=None): """ Rebuilds whole tree in database using `parent` link. """ tree = FileNode.tree.rebuild() messages.success(request, message=_('The node tree was rebuilt.')) return HttpResponseRedirect('')
python
def rebuild_tree(modeladmin, request, queryset=None): """ Rebuilds whole tree in database using `parent` link. """ tree = FileNode.tree.rebuild() messages.success(request, message=_('The node tree was rebuilt.')) return HttpResponseRedirect('')
[ "def", "rebuild_tree", "(", "modeladmin", ",", "request", ",", "queryset", "=", "None", ")", ":", "tree", "=", "FileNode", ".", "tree", ".", "rebuild", "(", ")", "messages", ".", "success", "(", "request", ",", "message", "=", "_", "(", "'The node tree w...
Rebuilds whole tree in database using `parent` link.
[ "Rebuilds", "whole", "tree", "in", "database", "using", "parent", "link", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/actions/maintenance_actions.py#L74-L80
samluescher/django-media-tree
media_tree/admin/actions/maintenance_actions.py
clear_cache
def clear_cache(modeladmin, request, queryset=None): """ Clears media cache files such as thumbnails. """ execute = request.POST.get('execute') files_in_storage = [] storage = get_media_storage() cache_files_choices = [] for storage_name in get_cache_files(): link = mar...
python
def clear_cache(modeladmin, request, queryset=None): """ Clears media cache files such as thumbnails. """ execute = request.POST.get('execute') files_in_storage = [] storage = get_media_storage() cache_files_choices = [] for storage_name in get_cache_files(): link = mar...
[ "def", "clear_cache", "(", "modeladmin", ",", "request", ",", "queryset", "=", "None", ")", ":", "execute", "=", "request", ".", "POST", ".", "get", "(", "'execute'", ")", "files_in_storage", "=", "[", "]", "storage", "=", "get_media_storage", "(", ")", ...
Clears media cache files such as thumbnails.
[ "Clears", "media", "cache", "files", "such", "as", "thumbnails", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/actions/maintenance_actions.py#L85-L132
samluescher/django-media-tree
media_tree/fields.py
DimensionField.south_field_triple
def south_field_triple(self): "Returns a suitable description of this field for South." from south.modelsinspector import introspector field_class = "django.db.models.fields.CharField" args, kwargs = introspector(self) return (field_class, args, kwargs)
python
def south_field_triple(self): "Returns a suitable description of this field for South." from south.modelsinspector import introspector field_class = "django.db.models.fields.CharField" args, kwargs = introspector(self) return (field_class, args, kwargs)
[ "def", "south_field_triple", "(", "self", ")", ":", "from", "south", ".", "modelsinspector", "import", "introspector", "field_class", "=", "\"django.db.models.fields.CharField\"", "args", ",", "kwargs", "=", "introspector", "(", "self", ")", "return", "(", "field_cl...
Returns a suitable description of this field for South.
[ "Returns", "a", "suitable", "description", "of", "this", "field", "for", "South", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/fields.py#L98-L103
samluescher/django-media-tree
media_tree/utils/__init__.py
autodiscover_media_extensions
def autodiscover_media_extensions(): """ Auto-discover INSTALLED_APPS media_extensions.py modules and fail silently when not present. This forces an import on them to register any media extension bits they may want. Rip of django.contrib.admin.autodiscover() """ import copy from django....
python
def autodiscover_media_extensions(): """ Auto-discover INSTALLED_APPS media_extensions.py modules and fail silently when not present. This forces an import on them to register any media extension bits they may want. Rip of django.contrib.admin.autodiscover() """ import copy from django....
[ "def", "autodiscover_media_extensions", "(", ")", ":", "import", "copy", "from", "django", ".", "conf", "import", "settings", "from", "django", ".", "utils", ".", "module_loading", "import", "module_has_submodule", "for", "app", "in", "settings", ".", "INSTALLED_A...
Auto-discover INSTALLED_APPS media_extensions.py modules and fail silently when not present. This forces an import on them to register any media extension bits they may want. Rip of django.contrib.admin.autodiscover()
[ "Auto", "-", "discover", "INSTALLED_APPS", "media_extensions", ".", "py", "modules", "and", "fail", "silently", "when", "not", "present", ".", "This", "forces", "an", "import", "on", "them", "to", "register", "any", "media", "extension", "bits", "they", "may",...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/__init__.py#L37-L55
samluescher/django-media-tree
media_tree/utils/__init__.py
multi_splitext
def multi_splitext(basename): """ Similar to os.path.slittext(), but with special handling for files with multiple extensions, such as "archive.tar.gz": Returns a list containg three elements, the first being the name without any extensions (taking into account hidden files/leading periods), the sec...
python
def multi_splitext(basename): """ Similar to os.path.slittext(), but with special handling for files with multiple extensions, such as "archive.tar.gz": Returns a list containg three elements, the first being the name without any extensions (taking into account hidden files/leading periods), the sec...
[ "def", "multi_splitext", "(", "basename", ")", ":", "groups", "=", "list", "(", "RE_SPLITEXT", ".", "match", "(", "basename", ")", ".", "groups", "(", ")", ")", "if", "not", "groups", "[", "2", "]", ":", "groups", "[", "2", "]", "=", "groups", "[",...
Similar to os.path.slittext(), but with special handling for files with multiple extensions, such as "archive.tar.gz": Returns a list containg three elements, the first being the name without any extensions (taking into account hidden files/leading periods), the second being the "full" extension, the third ...
[ "Similar", "to", "os", ".", "path", ".", "slittext", "()", "but", "with", "special", "handling", "for", "files", "with", "multiple", "extensions", "such", "as", "archive", ".", "tar", ".", "gz", ":", "Returns", "a", "list", "containg", "three", "elements",...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/__init__.py#L58-L87
samluescher/django-media-tree
media_tree/utils/__init__.py
join_formatted
def join_formatted(text, new_text, glue_format_if_true = u'%s%s', glue_format_if_false = u'%s%s', condition=None, format = u'%s', escape=False): """ Joins two strings, optionally escaping the second, and using one of two string formats for glueing them together, depending on whether a condition is True ...
python
def join_formatted(text, new_text, glue_format_if_true = u'%s%s', glue_format_if_false = u'%s%s', condition=None, format = u'%s', escape=False): """ Joins two strings, optionally escaping the second, and using one of two string formats for glueing them together, depending on whether a condition is True ...
[ "def", "join_formatted", "(", "text", ",", "new_text", ",", "glue_format_if_true", "=", "u'%s%s'", ",", "glue_format_if_false", "=", "u'%s%s'", ",", "condition", "=", "None", ",", "format", "=", "u'%s'", ",", "escape", "=", "False", ")", ":", "if", "conditio...
Joins two strings, optionally escaping the second, and using one of two string formats for glueing them together, depending on whether a condition is True or False. This function is a shorthand for complicated code blocks when you want to format some strings and link them together. A typical use case m...
[ "Joins", "two", "strings", "optionally", "escaping", "the", "second", "and", "using", "one", "of", "two", "string", "formats", "for", "glueing", "them", "together", "depending", "on", "whether", "a", "condition", "is", "True", "or", "False", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/__init__.py#L90-L109
samluescher/django-media-tree
media_tree/utils/__init__.py
widthratio
def widthratio(value, max_value, max_width): """ Does the same like Django's `widthratio` template tag (scales max_width to factor value/max_value) """ ratio = float(value) / float(max_value) return int(round(ratio * max_width))
python
def widthratio(value, max_value, max_width): """ Does the same like Django's `widthratio` template tag (scales max_width to factor value/max_value) """ ratio = float(value) / float(max_value) return int(round(ratio * max_width))
[ "def", "widthratio", "(", "value", ",", "max_value", ",", "max_width", ")", ":", "ratio", "=", "float", "(", "value", ")", "/", "float", "(", "max_value", ")", "return", "int", "(", "round", "(", "ratio", "*", "max_width", ")", ")" ]
Does the same like Django's `widthratio` template tag (scales max_width to factor value/max_value)
[ "Does", "the", "same", "like", "Django", "s", "widthratio", "template", "tag", "(", "scales", "max_width", "to", "factor", "value", "/", "max_value", ")" ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/__init__.py#L113-L118
psss/fmf
fmf/base.py
Tree._initialize
def _initialize(self, path): """ Find metadata tree root, detect format version """ # Find the tree root root = os.path.abspath(path) try: while ".fmf" not in next(os.walk(root))[1]: if root == "/": raise utils.RootError( ...
python
def _initialize(self, path): """ Find metadata tree root, detect format version """ # Find the tree root root = os.path.abspath(path) try: while ".fmf" not in next(os.walk(root))[1]: if root == "/": raise utils.RootError( ...
[ "def", "_initialize", "(", "self", ",", "path", ")", ":", "# Find the tree root", "root", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "try", ":", "while", "\".fmf\"", "not", "in", "next", "(", "os", ".", "walk", "(", "root", ")", ")", ...
Find metadata tree root, detect format version
[ "Find", "metadata", "tree", "root", "detect", "format", "version" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L85-L109
psss/fmf
fmf/base.py
Tree.merge
def merge(self, parent=None): """ Merge parent data """ # Check parent, append source files if parent is None: parent = self.parent if parent is None: return self.sources = parent.sources + self.sources # Merge child data with parent data d...
python
def merge(self, parent=None): """ Merge parent data """ # Check parent, append source files if parent is None: parent = self.parent if parent is None: return self.sources = parent.sources + self.sources # Merge child data with parent data d...
[ "def", "merge", "(", "self", ",", "parent", "=", "None", ")", ":", "# Check parent, append source files", "if", "parent", "is", "None", ":", "parent", "=", "self", ".", "parent", "if", "parent", "is", "None", ":", "return", "self", ".", "sources", "=", "...
Merge parent data
[ "Merge", "parent", "data" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L111-L138
psss/fmf
fmf/base.py
Tree.inherit
def inherit(self): """ Apply inheritance """ # Preserve original data and merge parent # (original data needed for custom inheritance extensions) self.original_data = self.data self.merge() log.debug("Data for '{0}' inherited.".format(self)) log.data(pretty(self.d...
python
def inherit(self): """ Apply inheritance """ # Preserve original data and merge parent # (original data needed for custom inheritance extensions) self.original_data = self.data self.merge() log.debug("Data for '{0}' inherited.".format(self)) log.data(pretty(self.d...
[ "def", "inherit", "(", "self", ")", ":", "# Preserve original data and merge parent", "# (original data needed for custom inheritance extensions)", "self", ".", "original_data", "=", "self", ".", "data", "self", ".", "merge", "(", ")", "log", ".", "debug", "(", "\"Dat...
Apply inheritance
[ "Apply", "inheritance" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L140-L150
psss/fmf
fmf/base.py
Tree.update
def update(self, data): """ Update metadata, handle virtual hierarchy """ # Nothing to do if no data if data is None: return for key, value in sorted(data.items()): # Handle child attributes if key.startswith('/'): name = key.lstrip('/'...
python
def update(self, data): """ Update metadata, handle virtual hierarchy """ # Nothing to do if no data if data is None: return for key, value in sorted(data.items()): # Handle child attributes if key.startswith('/'): name = key.lstrip('/'...
[ "def", "update", "(", "self", ",", "data", ")", ":", "# Nothing to do if no data", "if", "data", "is", "None", ":", "return", "for", "key", ",", "value", "in", "sorted", "(", "data", ".", "items", "(", ")", ")", ":", "# Handle child attributes", "if", "k...
Update metadata, handle virtual hierarchy
[ "Update", "metadata", "handle", "virtual", "hierarchy" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L152-L173