return Popen(self.get_args(), stdin=PIPE, stdout=PIPE, stderr=PIPE)<EOL>

Returns :class:`subprocess.Popen` instance with args from
        :meth:`get_args` result and piped stdin, stdout and stderr.


return [self.executable] + self.params<EOL>

Returns the list of :class:`subprocess.Popen` arguments.


paths = [self.path]<EOL>if os.path.basename(self.path_without_suffix) != '<STR_LIT:index>':<EOL><INDENT>path = os.path.join(self.path_without_suffix, '<STR_LIT:index>')<EOL>paths.append(path + '<STR_LIT>'.join(self.suffix))<EOL><DEDENT>return paths<EOL>

The list of logical paths which are used to search for an asset.
        This property makes sense only if the attributes was created with
        logical path.

        It is assumed that the logical path can be a directory containing a
        file named ``index`` with the same suffix.

        Example::

            >>> attrs = AssetAttributes(environment, 'js/app.js')
            >>> attrs.search_paths
            ['js/app.js', 'js/app/index.js']

            >>> attrs = AssetAttributes(environment, 'js/app/index.js')
            >>> attrs.search_paths
            ['js/models/index.js']


if self.suffix:<EOL><INDENT>return self.path[:-len('<STR_LIT>'.join(self.suffix))]<EOL><DEDENT>return self.path<EOL>

The relative path to asset without suffix.
        Example::

            >>> attrs = AssetAttributes(environment, 'js/app.js')
            >>> attrs.path_without_suffix
            'js/app'


format_extension = self.format_extension or self.compiler_format_extension<EOL>if format_extension is None:<EOL><INDENT>return self.path<EOL><DEDENT>return self.path_without_suffix + format_extension<EOL>

The logical path to asset.
        Example::

            >>> attrs = AssetAttributes(environment, 'js/models.js.coffee')
            >>> attrs.logical_path
            'js/models.js'


return re.findall(r'<STR_LIT>', os.path.basename(self.path))<EOL>

The list of asset extensions.
        Example::

            >>> attrs = AssetAttributes(environment, 'js/models.js.coffee')
            >>> attrs.extensions
            ['.js', '.coffee']

            >>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
            >>> attrs.format_extension
            ['.min', '.js', '.coffee']


for extension in reversed(self.extensions):<EOL><INDENT>compiler = self.environment.compilers.get(extension)<EOL>if not compiler and self.environment.mimetypes.get(extension):<EOL><INDENT>return extension<EOL><DEDENT><DEDENT>

The format extension of asset.
        Example::

            >>> attrs = AssetAttributes(environment, 'js/models.js.coffee')
            >>> attrs.format_extension
            '.js'

            >>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
            >>> attrs.format_extension
            '.js'


return self.extensions[len(self.unknown_extensions):]<EOL>

The list of asset extensions starting from the first known extension.
        Example::

            >>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
            >>> attrs.suffix
            ['.js', '.coffee']


unknown_extensions = []<EOL>for extension in self.extensions:<EOL><INDENT>compiler = self.environment.compilers.get(extension)<EOL>if compiler or self.environment.mimetypes.get(extension):<EOL><INDENT>return unknown_extensions<EOL><DEDENT>unknown_extensions.append(extension)<EOL><DEDENT>return unknown_extensions<EOL>

The list of unknown extensions, which are actually parts of asset
        filename. Example::

            >>> attrs = AssetAttributes(environment, 'js/lib-2.0.min.js')
            >>> attrs.suffix
            ['.0', '.min']


try:<EOL><INDENT>index = self.extensions.index(self.format_extension)<EOL><DEDENT>except ValueError:<EOL><INDENT>index = <NUM_LIT:0><EOL><DEDENT>extensions = self.extensions[index:]<EOL>return [e for e in extensions if self.environment.compilers.get(e)]<EOL>

The list of compiler extensions.
        Example::

            >>> attrs = AssetAttributes(environment, 'js/lib/external.min.js.coffee')
            >>> attrs.compiler_extensions
            ['.coffee']


return [self.environment.compilers.get(e) for e in self.compiler_extensions]<EOL>

The list of compilers used to build asset.


return self.environment.preprocessors.get(self.mimetype)<EOL>

The list of preprocessors used to build asset.


return self.environment.postprocessors.get(self.mimetype)<EOL>

The list of postprocessors used to build asset.


return self.preprocessors + list(reversed(self.compilers)) + self.postprocessors<EOL>

The list of all processors (preprocessors, compilers,
        postprocessors) used to build asset.


return self.environment.compressors.get(self.mimetype)<EOL>

The compressors used to compress the asset.


return (self.environment.mimetypes.get(self.format_extension) or<EOL>self.compiler_mimetype or '<STR_LIT>')<EOL>


for compiler in reversed(self.compilers):<EOL><INDENT>if compiler.result_mimetype:<EOL><INDENT>return compiler.result_mimetype<EOL><DEDENT><DEDENT>return None<EOL>

Implicit MIME type of the asset by its compilers.


for extension, mimetype in self.environment.mimetypes.items():<EOL><INDENT>if mimetype == self.compiler_mimetype:<EOL><INDENT>return extension<EOL><DEDENT><DEDENT>return None<EOL>

Implicit format extension on the asset by its compilers.


if finder not in self:<EOL><INDENT>self.append(finder)<EOL><DEDENT>

Append passed ``finder`` to the list of finders.


if finder in self:<EOL><INDENT>self.remove(finder)<EOL><DEDENT>

Remove passed ``finder`` from the list of finders. If ``finder``
        does not found in the registry, nothing happens.


self.register('<STR_LIT>', '<STR_LIT>')<EOL>self.register('<STR_LIT>', '<STR_LIT>')<EOL>

Register MIME types for ``.js`` and ``.css`` extensions.


def register(self, extension, mimetype):

self[extension] = mimetype<EOL>

Register passed ``mimetype`` MIME type with ``extension`` extension.


if extension in self:<EOL><INDENT>del self[extension]<EOL><DEDENT>

Remove registered MIME type for passed ``extension`` extension. If
        MIME type for this extension does not found in the registry, nothing
        happens.


def register(self, extension, compiler):

self[extension] = compiler<EOL>

Register passed `compiler` with passed `extension`.


Remove registered compiler for passed `extension`. If compiler for
        this extension does not found in the registry, nothing happens.


def register(self, mimetype, processor):

if mimetype not in self or processor not in self[mimetype]:<EOL><INDENT>self.setdefault(mimetype, []).append(processor)<EOL><DEDENT>

Register passed `processor` for passed `mimetype`.


def unregister(self, mimetype, processor):

if mimetype in self and processor in self[mimetype]:<EOL><INDENT>self[mimetype].remove(processor)<EOL><DEDENT>

Remove passed `processor` for passed `mimetype`. If processor for
        this MIME type does not found in the registry, nothing happens.


return super(Processors, self).get(mimetype, [])<EOL>

Return a list of processors, registered for passed `mimetype`. If
        no processors are registered for this MIME type, empty list is
        returned.


self.register('<STR_LIT>', DirectivesProcessor.as_handler())<EOL>self.register('<STR_LIT>', DirectivesProcessor.as_handler())<EOL>

Register :class:`~gears.processors.DirectivesProcessor` as
        a preprocessor for `text/css` and `application/javascript` MIME types.


def register(self, mimetype, compressor):

self[mimetype] = compressor<EOL>

Register passed `compressor` for passed `mimetype`.


if mimetype in self:<EOL><INDENT>del self[mimetype]<EOL><DEDENT>

Remove registered compressors for passed `mimetype`. If compressor
        for this MIME type does not found in the registry, nothing happens.


if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>suffixes = Suffixes()<EOL>for extension, mimetype in self.mimetypes.items():<EOL><INDENT>suffixes.register(extension, root=True, mimetype=mimetype)<EOL><DEDENT>for extension, compiler in self.compilers.items():<EOL><INDENT>suffixes.register(extension, to=compiler.result_mimetype)<EOL><DEDENT>self._suffixes = suffixes<EOL><DEDENT>return self._suffixes<EOL>

The registry for supported suffixes of assets. It is built from
        MIME types and compilers registries, and is cached at the first call.
        See :class:`~gears.environment.Suffixes` for more information.


if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>paths = []<EOL>for finder in self.finders:<EOL><INDENT>if hasattr(finder, '<STR_LIT>'):<EOL><INDENT>paths.extend(finder.paths)<EOL><DEDENT><DEDENT>self._paths = paths<EOL><DEDENT>return self._paths<EOL>

The list of search paths. It is built from registered finders, which
        has ``paths`` property. Can be useful for compilers to resolve internal
        dependencies.


self.mimetypes.register_defaults()<EOL>self.preprocessors.register_defaults()<EOL>self.postprocessors.register_defaults()<EOL>

Register default compilers, preprocessors and MIME types.


for entry_point in iter_entry_points('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if entry_point.module_name not in exclude:<EOL><INDENT>register = entry_point.load()<EOL>register(self)<EOL><DEDENT><DEDENT>

Allow Gears plugins to inject themselves to the environment. For
        example, if your plugin's package contains such ``entry_points``
        definition in ``setup.py``, ``gears_plugin.register`` function will be
        called with current environment during ``register_entry_points`` call::

            entry_points = {
                'gears': [
                    'register = gears_plugin:register',
                ],
            }

        Here is an example of such function::

            def register(environment):
                assets_dir = os.path.join(os.path.dirname(__file__), 'assets')
                assets_dir = os.path.absolute_path(assets_dir)
                environment.register(FileSystemFinder([assets_dir]))

        If you want to disable this behavior for some plugins, list their
        packages using ``exclude`` argument::

            environment.register_entry_points(exclude=['plugin'])


if isinstance(item, AssetAttributes):<EOL><INDENT>for path in item.search_paths:<EOL><INDENT>try:<EOL><INDENT>return self.find(path, logical)<EOL><DEDENT>except FileNotFound:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>raise FileNotFound(item.path)<EOL><DEDENT>if logical:<EOL><INDENT>asset_attributes = AssetAttributes(self, item)<EOL>suffixes = self.suffixes.find(asset_attributes.mimetype)<EOL>if not suffixes:<EOL><INDENT>return self.find(item)<EOL><DEDENT>path = asset_attributes.path_without_suffix<EOL>for suffix in suffixes:<EOL><INDENT>try:<EOL><INDENT>return self.find(path + suffix)<EOL><DEDENT>except FileNotFound:<EOL><INDENT>continue<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for finder in self.finders:<EOL><INDENT>try:<EOL><INDENT>absolute_path = finder.find(item)<EOL><DEDENT>except FileNotFound:<EOL><INDENT>continue<EOL><DEDENT>return AssetAttributes(self, item), absolute_path<EOL><DEDENT><DEDENT>raise FileNotFound(item)<EOL>

Find files using :attr:`finders` registry. The ``item`` parameter
        can be an instance of :class:`~gears.asset_attributes.AssetAttributes`
        class, a path to the asset or a logical path to the asset. If ``item``
        is a logical path, `logical` parameter must be set to ``True``.

        Returns a tuple with :class:`~gears.asset_attributes.AssetAttributes`
        instance for found file path as first item, and absolute path to this
        file as second item.

        If nothing is found, :class:`gears.exceptions.FileNotFound` exception
        is rased.


basename_pattern = os.path.basename(path)<EOL>if path.endswith('<STR_LIT>'):<EOL><INDENT>paths = [path]<EOL><DEDENT>else:<EOL><INDENT>paths = AssetAttributes(self, path).search_paths<EOL><DEDENT>paths = map(lambda p: p if p.endswith('<STR_LIT:*>') else p + '<STR_LIT:*>', paths)<EOL>results = unique(self._list_paths(paths), lambda x: x[<NUM_LIT:0>])<EOL>for logical_path, absolute_path in results:<EOL><INDENT>asset_attributes = AssetAttributes(self, logical_path)<EOL>if mimetype is not None and asset_attributes.mimetype != mimetype:<EOL><INDENT>continue<EOL><DEDENT>basename = os.path.basename(asset_attributes.path_without_suffix)<EOL>if not fnmatch(basename, basename_pattern) and basename != '<STR_LIT:index>':<EOL><INDENT>continue<EOL><DEDENT>yield asset_attributes, absolute_path<EOL><DEDENT>

Yield two-tuples for all files found in the directory given by
        ``path`` parameter. Result can be filtered by the second parameter,
        ``mimetype``, that must be a MIME type of assets compiled source code.
        Each tuple has :class:`~gears.asset_attributes.AssetAttributes`
        instance for found file path as first item, and absolute path to this
        file as second item.

        Usage example::

            # Yield all files from 'js/templates' directory.
            environment.list('js/templates/*')

            # Yield only files that are in 'js/templates' directory and have
            # 'application/javascript' MIME type of compiled source code.
            environment.list('js/templates/*', mimetype='application/javascript')


for asset_attributes, absolute_path in self.list('<STR_LIT>'):<EOL><INDENT>logical_path = os.path.normpath(asset_attributes.logical_path)<EOL>check_asset = build_asset(self, logical_path, check=True)<EOL>if check_asset.is_public:<EOL><INDENT>asset = build_asset(self, logical_path)<EOL>source = bytes(asset)<EOL>self.save_file(logical_path, source, asset.gzippable)<EOL>if self.fingerprinting:<EOL><INDENT>self.save_file(asset.hexdigest_path, source, asset.gzippable)<EOL>self.manifest.files[logical_path] = asset.hexdigest_path<EOL><DEDENT><DEDENT><DEDENT>self.manifest.dump()<EOL>

Save handled public assets to :attr:`root` directory.


return functor.map(func)<EOL>

Applies a function to the data 'inside' a functor.

    Uses functools.singledispatch so you can write your own functors
    for use with the library.


@singledispatch<EOL>def setitem(self, key, value):<EOL>

try:<EOL><INDENT>self._lens_setitem<EOL><DEDENT>except AttributeError:<EOL><INDENT>selfcopy = copy.copy(self)<EOL>selfcopy[key] = value<EOL>return selfcopy<EOL><DEDENT>else:<EOL><INDENT>return self._lens_setitem(key, value)<EOL><DEDENT>

Takes an object, a key, and a value and produces a new object
    that is a copy of the original but with ``value`` as the new value of
    ``key``.

    The following equality should hold for your definition:

    .. code-block:: python

        setitem(obj, key, obj[key]) == obj

    This function is used by many lenses (particularly GetitemLens) to
    set items on states even when those states do not ordinarily support
    ``setitem``. This function is designed to have a similar signature
    as python's built-in ``setitem`` except that it returns a new object
    that has the item set rather than mutating the object in place.

    It's what enables the ``lens[some_key]`` functionality.

    The corresponding method call for this hook is
    ``obj._lens_setitem(key, value)``.

    The default implementation makes a copy of the object using
    ``copy.copy`` and then mutates the new object by setting the item
    on it in the conventional way.


@singledispatch<EOL>def setattr(self, name, value):<EOL>

try:<EOL><INDENT>self._lens_setattr<EOL><DEDENT>except AttributeError:<EOL><INDENT>selfcopy = copy.copy(self)<EOL>builtin_setattr(selfcopy, name, value)<EOL>return selfcopy<EOL><DEDENT>else:<EOL><INDENT>return self._lens_setattr(name, value)<EOL><DEDENT>

Takes an object, a string, and a value and produces a new object
    that is a copy of the original but with the attribute called ``name``
    set to ``value``.

    The following equality should hold for your definition:

    .. code-block:: python

        setattr(obj, 'attr', obj.attr) == obj

    This function is used by many lenses (particularly GetattrLens) to set
    attributes on states even when those states do not ordinarily support
    ``setattr``. This function is designed to have a similar signature
    as python's built-in ``setattr`` except that it returns a new object
    that has the attribute set rather than mutating the object in place.

    It's what enables the ``lens.some_attribute`` functionality.

    The corresponding method call for this hook is
    ``obj._lens_setattr(name, value)``.

    The default implementation makes a copy of the object using
    ``copy.copy`` and then mutates the new object by calling python's
    built in ``setattr`` on it.


try:<EOL><INDENT>self._lens_contains_add<EOL><DEDENT>except AttributeError:<EOL><INDENT>message = '<STR_LIT>'<EOL>raise NotImplementedError(message.format(type(self)))<EOL><DEDENT>else:<EOL><INDENT>return self._lens_contains_add(item)<EOL><DEDENT>

Takes a collection and an item and returns a new collection
    of the same type that contains the item. The notion of "contains"
    is defined by the object itself; The following must be ``True``:

    .. code-block:: python

        item in contains_add(obj, item)

    This function is used by some lenses (particularly ContainsLens)
    to add new items to containers when necessary.

    The corresponding method call for this hook is
    ``obj._lens_contains_add(item)``.

    There is no default implementation.


try:<EOL><INDENT>self._lens_contains_remove<EOL><DEDENT>except AttributeError:<EOL><INDENT>message = '<STR_LIT>'<EOL>raise NotImplementedError(message.format(type(self)))<EOL><DEDENT>else:<EOL><INDENT>return self._lens_contains_remove(item)<EOL><DEDENT>

Takes a collection and an item and returns a new collection
    of the same type with that item removed. The notion of "contains"
    is defined by the object itself; the following must be ``True``:

    .. code-block:: python

        item not in contains_remove(obj, item)

    This function is used by some lenses (particularly ContainsLens)
    to remove items from containers when necessary.

    The corresponding method call for this hook is
    ``obj._lens_contains_remove(item)``.

    There is no default implementation.


try:<EOL><INDENT>self._lens_to_iter<EOL><DEDENT>except AttributeError:<EOL><INDENT>return iter(self)<EOL><DEDENT>else:<EOL><INDENT>return self._lens_to_iter()<EOL><DEDENT>

Takes an object and produces an iterable. It is intended as the
    inverse of the ``from_iter`` function.

    The reason this hook exists is to customise how dictionaries are
    iterated. In order to properly reconstruct a dictionary from an
    iterable you need access to both the keys and the values. So this
    function iterates over dictionaries by thier items instead.

    The corresponding method call for this hook is
    ``obj._lens_to_iter()``.

    The default implementation is to call python's built in ``iter``
    function.


try:<EOL><INDENT>self._lens_from_iter<EOL><DEDENT>except AttributeError:<EOL><INDENT>message = '<STR_LIT>'<EOL>raise NotImplementedError(message.format(type(self)))<EOL><DEDENT>else:<EOL><INDENT>return self._lens_from_iter(iterable)<EOL><DEDENT>

Takes an object and an iterable and produces a new object that is
    a copy of the original with data from ``iterable`` reincorporated. It
    is intended as the inverse of the ``to_iter`` function. Any state in
    ``self`` that is not modelled by the iterable should remain unchanged.

    The following equality should hold for your definition:

    .. code-block:: python

        from_iter(self, to_iter(self)) == self

    This function is used by EachLens to synthesise states from iterables,
    allowing it to focus every element of an iterable state.

    The corresponding method call for this hook is
    ``obj._lens_from_iter(iterable)``.

    There is no default implementation.


return Just(fn(self.item))<EOL>

Apply a function to the value inside the Maybe.


return self.item<EOL>

Unwraps the value, returning it is there is one, else
        returning the guard.


return Nothing()<EOL>


return guard<EOL>


return ui.BoundLens(state, optics.TrivialIso())<EOL>

Returns a simple BoundLens object bound to `state`.


def call(self, method_name, *args, **kwargs):<EOL>

caller = operator.methodcaller(method_name, *args, **kwargs)<EOL>return self.modify(caller)<EOL>

Call a method on the focus. The method must return a new
        value for the focus.

            >>> from lenses import lens
            >>> lens[2].call('upper')(['alpha', 'beta', 'gamma'])
            ['alpha', 'beta', 'GAMMA']

        As a shortcut, you can include the name of the method you want
        to call immediately after `call_`:

            >>> lens[2].call_upper()(['alpha', 'beta', 'gamma'])
            ['alpha', 'beta', 'GAMMA']


def call_mut(self, method_name, *args, **kwargs):<EOL>

shallow = False<EOL>if '<STR_LIT>' in kwargs:<EOL><INDENT>shallow = kwargs['<STR_LIT>']<EOL>del kwargs['<STR_LIT>']<EOL><DEDENT>def func(a):<EOL><INDENT>a = copy.copy(a) if shallow else copy.deepcopy(a)<EOL>getattr(a, method_name)(*args, **kwargs)<EOL>return cast(B, a)<EOL><DEDENT>return self.modify(func)<EOL>

Call a method on the focus that will mutate it in place.
        Works by making a deep copy of the focus before calling the
        mutating method on it. The return value of that method is ignored.
        You can pass a keyword argument shallow=True to only make a
        shallow copy.

            >>> from lenses import lens
            >>> lens[0].call_mut('sort')([[3, 1, 2], [5, 4]])
            [[1, 2, 3], [5, 4]]

        As a shortcut, you can include the name of the method you want
        to call immediately after `call_mut_`:

            >>> lens[0].call_mut_sort()([[3, 1, 2], [5, 4]])
            [[1, 2, 3], [5, 4]]


def func(a):<EOL><INDENT>return a & other<EOL><DEDENT>return self.modify(func)<EOL>

Uses the bitwise and operator on the focus. A convenience
        method since lenses use __and__ for doing composition.

            >>> from lenses import lens
            >>> lens.Each().bitwise_and(5)([1, 2, 3, 4])
            [1, 0, 1, 4]


return self._compose_optic(optics.ContainsLens(item))<EOL>

A lens that focuses a boolean that tells you whether the
        state contains some item.

            >>> from lenses import lens
            >>> lens.Contains(1)
            UnboundLens(ContainsLens(1))
            >>> lens.Contains(1).get()([2, 3])
            False
            >>> lens.Contains(1).get()([1, 2, 3])
            True
            >>> lens.Contains(1).set(False)([1, 2, 3])
            [2, 3]
            >>> lens.Contains(1).set(True)([2, 3])
            [2, 3, 1]

        The behaviour of this lens depends on the implementation of
        ``lenses.hooks.contains_add`` and ``lenses.hooks.contains_remove``.


def Decode(self, encoding='<STR_LIT:utf-8>', errors='<STR_LIT:strict>'):<EOL>

return self._compose_optic(optics.DecodeIso(encoding, errors))<EOL>

An isomorphism that decodes and encodes its focus on the
        fly. Lets you focus a byte string as a unicode string. The
        arguments have the same meanings as `bytes.decode`. Analogous to
        `bytes.decode`.

            >>> from lenses import lens
            >>> lens.Decode(encoding='utf8')
            UnboundLens(DecodeIso('utf8', 'strict'))
            >>> lens.Decode().get()(b'hello')  # doctest: +SKIP
            'hello'
            >>> lens.Decode().set('world')(b'hello')  # doctest: +SKIP
            b'world'


return self._compose_optic(optics.EachTraversal())<EOL>

A traversal that iterates over its state, focusing everything
        it iterates over. It uses `lenses.hooks.fromiter` to reform
        the state afterwards so it should work with any iterable that
        function supports. Analogous to `iter`.

            >>> from lenses import lens
            >>> data = [1, 2, 3]
            >>> lens.Each()
            UnboundLens(EachTraversal())
            >>> lens.Each().collect()(data)
            [1, 2, 3]
            >>> (lens.Each() + 1)(data)
            [2, 3, 4]

        For technical reasons, this lens iterates over dictionaries by
        their items and not just their keys.

            >>> data = {'one': 1}
            >>> lens.Each().collect()(data)
            [('one', 1)]
            >>> (lens.Each()[1] + 1)(data)
            {'one': 2}


def Error(self, exception, message=None):<EOL>

return self._compose_optic(optics.ErrorIso(exception, message))<EOL>

An optic that raises an exception whenever it tries to focus
        something. If `message is None` then the exception will be
        raised unmodified. If `message is not None` then when the lens
        is asked to focus something it will run `message.format(state)`
        and the exception will be called with the resulting formatted
        message as it's only argument. Useful for debugging.

            >>> from lenses import lens
            >>> lens.Error(Exception())
            UnboundLens(ErrorIso(Exception()))
            >>> lens.Error(Exception, '{}')
            UnboundLens(ErrorIso(<...Exception...>, '{}'))
            >>> lens.Error(Exception).get()(True)
            Traceback (most recent call last):
              File "<stdin>", line 1, in ?
            Exception
            >>> lens.Error(Exception('An error occurred')).set(False)(True)
            Traceback (most recent call last):
              File "<stdin>", line 1, in ?
            Exception: An error occurred
            >>> lens.Error(ValueError, 'applied to {}').get()(True)
            Traceback (most recent call last):
              File "<stdin>", line 1, in ?
            ValueError: applied to True


return self._compose_optic(optics.Getter(getter))<EOL>

An optic that wraps a getter function. A getter function is
        one that takes a state and returns a value derived from that
        state. The function is called on the focus before it is returned.

            >>> from lenses import lens
            >>> lens.F(abs)
            UnboundLens(Getter(<built-in function abs>))
            >>> lens.F(abs).get()(-1)
            1
            >>> lens.Each().F(abs).collect()([-1, 2, -3])
            [1, 2, 3]

        This optic cannot be used to set or modify values.


return self._compose_optic(optics.FilteringPrism(predicate))<EOL>

A prism that only focuses a value if the predicate returns
        `True` when called with that value as an argument. Best used
        when composed after a traversal. It only prevents the traversal
        from visiting foci, it does not filter out values the way that
        python's regular `filter` function does.

            >>> from lenses import lens
            >>> lens.Filter(all)
            UnboundLens(FilteringPrism(<built-in function all>))
            >>> data = [[1, 2], [0], ['a'], ['', 'b']]
            >>> lens.Each().Filter(all).collect()(data)
            [[1, 2], ['a']]
            >>> lens.Each().Filter(all).set(2)(data)
            [2, [0], 2, ['', 'b']]

        The filtering is done to foci before the lens' manipulation is
        applied. This means that the resulting foci can still violate
        the predicate if the manipulating function doesn't respect it:

            >>> lens.Each().Filter(bool).set(None)(['', 2, ''])
            ['', None, '']


return self._compose_optic(optics.Fold(func))<EOL>

A fold that takes a function that returns an iterable and
        focuses all the values in that iterable.

            >>> from lenses import lens
            >>> def ends(state):
            ...     yield state[0]
            ...     yield state[-1]
            >>> lens.Fold(ends).collect()([1, 2, 3])
            [1, 3]


true_lenses = [l._optic for l in lenses]<EOL>return self._compose_optic(optics.ForkedSetter(*true_lenses))<EOL>

A setter representing the parallel composition of several
        sub-lenses.

            >>> from lenses import lens
            >>> lens.Fork(lens[0], lens[2])
            UnboundLens(ForkedSetter(GetitemLens(0), GetitemLens(2)))
            >>> lens.Fork(lens[0][1], lens[2]).set(1)([[0, 0], 0, 0])
            [[0, 1], 0, 1]


return self._compose_optic(optics.GetitemOrElseLens(key, default))<EOL>

A lens that focuses an item inside a container by calling
        its `get` method, allowing you to specify a default value for
        missing keys.  Analogous to `dict.get`.

            >>> from lenses import lens
            >>> lens.Get('foo')
            UnboundLens(GetitemOrElseLens('foo', default=None))
            >>> lens.Get('baz').get()({'foo': 'bar'})
            >>> lens.Get('baz', []).get()({'foo': 'bar'})
            []
            >>> from collections import OrderedDict
            >>> lens.Get('baz').set('qux')(OrderedDict({'foo': 'bar'}))
            OrderedDict([('foo', 'bar'), ('baz', 'qux')])


return self._compose_optic(optics.GetattrLens(name))<EOL>

A lens that focuses an attribute of an object. Analogous to
        `getattr`.

            >>> from lenses import lens
            >>> from collections import namedtuple
            >>> Pair = namedtuple('Pair', 'left right')
            >>> lens.GetAttr('left')
            UnboundLens(GetattrLens('left'))
            >>> lens.GetAttr('left').get()(Pair(1, 2))
            1
            >>> lens.GetAttr('right').set(3)(Pair(1, 2))
            Pair(left=1, right=3)


return self._compose_optic(optics.GetitemLens(key))<EOL>

A lens that focuses an item inside a container. Analogous to
        `operator.itemgetter`.

            >>> from lenses import lens
            >>> lens[0]
            UnboundLens(GetitemLens(0))
            >>> lens.GetItem(0)
            UnboundLens(GetitemLens(0))
            >>> lens[0].get()([1, 2, 3])
            1
            >>> lens['hello'].get()({'hello': 'world'})
            'world'
            >>> lens[0].set(4)([1, 2, 3])
            [4, 2, 3]
            >>> lens['hello'].set('universe')({'hello': 'world'})
            {'hello': 'universe'}


return self._compose_optic(optics.Lens(getter, setter))<EOL>

An optic that wraps a pair of getter and setter functions. A
        getter function is one that takes a state and returns a value
        derived from that state. A setter function takes an old state
        and a new value and uses them to construct a new state.

            >>> from lenses import lens
            >>> def getter(state):
            ...     'Get the average of a list'
            ...     return sum(state) // len(state)
            ...
            >>> def setter(old_state, value):
            ...     'Set the average of a list by changing the final value'
            ...     target_sum = value * len(old_state)
            ...     prefix = old_state[:-1]
            ...     return prefix + [target_sum - sum(prefix)]
            ...
            >>> average_lens = lens.Lens(getter, setter)
            >>> average_lens
            UnboundLens(Lens(<function getter...>, <function setter...>))
            >>> average_lens.get()([1, 2, 4, 5])
            3
            >>> average_lens.set(4)([1, 2, 3])
            [1, 2, 9]
            >>> (average_lens - 1)([1, 2, 3])
            [1, 2, 0]


return self._compose_optic(optics.GetZoomAttrTraversal(name))<EOL>

A traversal that focuses an attribute of an object, though if
        that attribute happens to be a lens it will zoom the lens. This
        is used internally to make lenses that are attributes of objects
        transparent. If you already know whether you are focusing a lens
        or a non-lens you should be explicit and use a ZoomAttrTraversal
        or a GetAttrLens respectively.

            >>> from lenses import lens
            >>> from collections import namedtuple
            >>> Triple = namedtuple('Triple', 'left mid right')
            >>> state = Triple(1, 2, lens.mid)
            >>> lens.left
            UnboundLens(GetZoomAttrTraversal('left'))
            >>> lens.left.get()(state)
            1
            >>> lens.left.set(3)(state)
            Triple(left=3, mid=2, right=UnboundLens(GetZoomAttrTraversal('mid')))
            >>> lens.right.get()(state)
            2
            >>> lens.right.set(4)(state)
            Triple(left=1, mid=4, right=UnboundLens(GetZoomAttrTraversal('mid')))


return self._compose_optic(optics.InstancePrism(type_))<EOL>

A prism that focuses a value only when that value is an
        instance of `type_`.

            >>> from lenses import lens
            >>> lens.Instance(int)
            UnboundLens(InstancePrism(...))
            >>> lens.Instance(int).collect()(1)
            [1]
            >>> lens.Instance(float).collect()(1)
            []
            >>> lens.Instance(int).set(2)(1)
            2
            >>> lens.Instance(float).set(2)(1)
            1


def Iso(self, forwards, backwards):<EOL>

return self._compose_optic(optics.Isomorphism(forwards, backwards))<EOL>

A lens based on an isomorphism. An isomorphism can be
        formed by two functions that mirror each other; they can convert
        forwards and backwards between a state and a focus without losing
        information. The difference between this and a regular Lens is
        that here the backwards functions don't need to know anything
        about the original state in order to produce a new state.

        These equalities should hold for the functions you supply (given
        a reasonable definition for __eq__)::

            backwards(forwards(state)) == state
            forwards(backwards(focus)) == focus

        These kinds of conversion functions are very common across
        the python ecosystem. For example, NumPy has `np.array` and
        `np.ndarray.tolist` for converting between python lists and its
        own arrays. Isomorphism makes it easy to store data in one form,
        but interact with it in a more convenient form.

            >>> from lenses import lens
            >>> lens.Iso(chr, ord)
            UnboundLens(Isomorphism(<... chr>, <... ord>))
            >>> lens.Iso(chr, ord).get()(65)
            'A'
            >>> lens.Iso(chr, ord).set('B')(65)
            66

        Due to their symmetry, isomorphisms can be flipped, thereby
        swapping thier forwards and backwards functions:

            >>> flipped = lens.Iso(chr, ord).flip()
            >>> flipped
            UnboundLens(Isomorphism(<... ord>, <... chr>))
            >>> flipped.get()('A')
            65


return self._compose_optic(optics.ItemLens(key))<EOL>

A lens that focuses a single item (key-value pair) in a
        dictionary by its key. Set an item to `None` to remove it from
        the dictionary.

            >>> from lenses import lens
            >>> from collections import OrderedDict
            >>> data = OrderedDict([(1, 10), (2, 20)])
            >>> lens.Item(1)
            UnboundLens(ItemLens(1))
            >>> lens.Item(1).get()(data)
            (1, 10)
            >>> lens.Item(3).get()(data) is None
            True
            >>> lens.Item(1).set((1, 11))(data)
            OrderedDict([(1, 11), (2, 20)])
            >>> lens.Item(1).set(None)(data)
            OrderedDict([(2, 20)])


return self._compose_optic(optics.ItemByValueLens(value))<EOL>

A lens that focuses a single item (key-value pair) in a
        dictionary by its value. Set an item to `None` to remove it
        from the dictionary. This lens assumes that there will only be
        a single key with that particular value. If you violate that
        assumption then you're on your own.

            >>> from lenses import lens
            >>> from collections import OrderedDict
            >>> data = OrderedDict([(1, 10), (2, 20)])
            >>> lens.ItemByValue(10)
            UnboundLens(ItemByValueLens(10))
            >>> lens.ItemByValue(10).get()(data)
            (1, 10)
            >>> lens.ItemByValue(30).get()(data) is None
            True
            >>> lens.ItemByValue(10).set((3, 10))(data)
            OrderedDict([(2, 20), (3, 10)])
            >>> lens.ItemByValue(10).set(None)(data)
            OrderedDict([(2, 20)])


return self._compose_optic(optics.ItemsTraversal())<EOL>

A traversal focusing key-value tuples that are the items of
        a dictionary. Analogous to `dict.items`.

            >>> from lenses import lens
            >>> from collections import OrderedDict
            >>> data = OrderedDict([(1, 10), (2, 20)])
            >>> lens.Items()
            UnboundLens(ItemsTraversal())
            >>> lens.Items().collect()(data)
            [(1, 10), (2, 20)]
            >>> lens.Items()[1].modify(lambda n: n + 1)(data)
            OrderedDict([(1, 11), (2, 21)])


return self._compose_optic(optics.IterableFold())<EOL>

A fold that can get values from any iterable object in python
        by iterating over it. Like any fold, you cannot set values.

            >>> from lenses import lens
            >>> lens.Iter()
            UnboundLens(IterableFold())
            >>> data = {2, 1, 3}
            >>> lens.Iter().collect()(data) == list(data)
            True
            >>> def numbers():
            ...     yield 1
            ...     yield 2
            ...     yield 3
            ...
            >>> lens.Iter().collect()(numbers())
            [1, 2, 3]
            >>> lens.Iter().collect()([])
            []

        If you want to be able to set values as you iterate then look
        into the EachTraversal.


return self._compose_optic(optics.JsonIso())<EOL>

An isomorphism that focuses a string containing json data as
        its parsed equivalent. Analogous to `json.loads`.

            >>> from lenses import lens
            >>> data = '[{"points": [4, 7]}]'
            >>> lens.Json()
            UnboundLens(JsonIso())
            >>> lens.Json()[0]['points'][1].get()(data)
            7
            >>> lens.Json()[0]['points'][0].set(8)(data)
            '[{"points": [8, 7]}]'


return self._compose_optic(optics.JustPrism())<EOL>

A prism that focuses the value inside a `lenses.maybe.Just`
        object.

            >>> from lenses import lens
            >>> from lenses.maybe import Just, Nothing
            >>> lens.Just()
            UnboundLens(JustPrism())
            >>> lens.Just().collect()(Just(1))
            [1]
            >>> lens.Just().collect()(Nothing())
            []
            >>> lens.Just().set(2)(Just(1))
            Just(2)
            >>> lens.Just().set(2)(Nothing())
            Nothing()


return self._compose_optic(<EOL>optics.ItemsTraversal() & optics.GetitemLens(<NUM_LIT:0>)<EOL>)<EOL>

A traversal focusing the keys of a dictionary. Analogous to
        `dict.keys`.

            >>> from lenses import lens
            >>> from collections import OrderedDict
            >>> data = OrderedDict([(1, 10), (2, 20)])
            >>> lens.Keys()
            UnboundLens(ItemsTraversal() & GetitemLens(0))
            >>> lens.Keys().collect()(data)
            [1, 2]
            >>> lens.Keys().modify(lambda n: n + 1)(data)
            OrderedDict([(2, 10), (3, 20)])


return self._compose_optic(optics.NormalisingIso(setter))<EOL>

An isomorphism that applies a function as it sets a new
        focus without regard to the old state. It will get foci without
        transformation. This lens allows you to pre-process values before
        you set them, but still get values as they exist in the state.
        Useful for type conversions or normalising data.

        For best results, your normalisation function should be
        idempotent.  That is, applying the function twice should have
        no effect::

            setter(setter(value)) == setter(value)

        Equivalent to `Isomorphism((lambda s: s), setter)`.

            >>> from lenses import lens
            >>> def real_only(num):
            ...     return num.real
            ...
            >>> lens.Norm(real_only)
            UnboundLens(NormalisingIso(<function real_only at ...>))
            >>> lens[0].Norm(real_only).get()([1.0, 2.0, 3.0])
            1.0
            >>> lens[0].Norm(real_only).set(4+7j)([1.0, 2.0, 3.0])
            [4.0, 2.0, 3.0]

        Types with constructors that do conversion are often good targets
        for this lens:

            >>> lens[0].Norm(int).set(4.0)([1, 2, 3])
            [4, 2, 3]
            >>> lens[1].Norm(int).set('5')([1, 2, 3])
            [1, 5, 3]


def Prism(self, unpack, pack, ignore_none=False, ignore_errors=None):<EOL>

if not (ignore_none or ignore_errors):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if ignore_errors is True:<EOL><INDENT>ignore_errors = (Exception,)<EOL><DEDENT>@functools.wraps(unpack)<EOL>def new_unpack(state):<EOL><INDENT>try:<EOL><INDENT>result = unpack(state)<EOL><DEDENT>except Exception as e:<EOL><INDENT>if ignore_errors and isinstance(e, ignore_errors):<EOL><INDENT>return mNothing()<EOL><DEDENT>else:<EOL><INDENT>raise e<EOL><DEDENT><DEDENT>if ignore_none:<EOL><INDENT>return mNothing() if result is None else mJust(result)<EOL><DEDENT>return mJust(result)<EOL><DEDENT>return self._compose_optic(optics.Prism(new_unpack, pack))<EOL>

A prism is an optic made from a pair of functions that pack and
        unpack a state where the unpacking process can potentially fail.

        `pack` is a function that takes a focus and returns that focus
        wrapped up in a new state. `unpack` is a function that takes
        a state and unpacks it to get a focus. The unpack function may
        choose to fail to unpack a focus, either by returning None or
        raising an exception (or both).

        All prisms are also traversals that have exactly zero or one foci.

        You must pass one or both of the ``ignore_none=True`` or
        ``ignore_errors=True`` keyword arguments. If you pass the former
        then the prism will fail to focus anything when your unpacking
        function returns ``None``. If you pass the latter then it will
        fail to focus when your unpacking function raises an error.

            >>> from lenses import lens
            >>> lens.Prism(int, str)
            Traceback (most recent call last):
              File "<stdin>", line 1 in ?
            ValueError: Must specify what to ignore
            >>> lens.Prism(int, str, ignore_errors=True)
            UnboundLens(Prism(..., ...))
            >>> lens.Prism(int, str, ignore_errors=True).collect()('42')
            [42]
            >>> lens.Prism(int, str, ignore_errors=True).collect()('fourty two')
            []

        If you set ``ignore_errors`` to ``True`` then it will catch any
        and all exceptions. A better alternative is to set it to a tuple of
        exception types to ignore (such as you would pass to ``isinstance``).

            >>> errors = (ValueError,)
            >>> lens.Prism(int, str, ignore_errors=errors)
            UnboundLens(Prism(..., ...))
            >>> lens.Prism(int, str, ignore_errors=errors).collect()('42')
            [42]
            >>> lens.Prism(int, str, ignore_errors=errors).collect()('fourty two')
            []
            >>> lens.Prism(int, str, ignore_errors=errors).collect()([1, 2, 3])
            Traceback (most recent call last):
              File "<stdin>", line 1 in ?
            TypeError: int() argument must be ...


return self._compose_optic(optics.RecurTraversal(cls))<EOL>

A traversal that recurses through an object focusing everything it
        can find of a particular type. This traversal will probe arbitrarily
        deep into the contents of the state looking for sub-objects. It
        uses some naughty tricks to do this including looking at an object's
        `__dict__` attribute.

        It is somewhat analogous to haskell's uniplate optic.

            >>> from lenses import lens
            >>> lens.Recur(int)
            UnboundLens(RecurTraversal(<... 'int'>))
            >>> data = [[1, 2, 100.0], [3, 'hello', [{}, 4], 5]]
            >>> lens.Recur(int).collect()(data)
            [1, 2, 3, 4, 5]
            >>> (lens.Recur(int) + 1)(data)
            [[2, 3, 100.0], [4, 'hello', [{}, 5], 6]]

        It also works on custom classes:

            >>> class Container(object):
            ...     def __init__(self, contents):
            ...         self.contents = contents
            ...     def __repr__(self):
            ...         return 'Container({!r})'.format(self.contents)
            >>> data = [Container(1), 2, Container(Container(3)), [4, 5]]
            >>> (lens.Recur(int) + 1)(data)
            [Container(2), 3, Container(Container(4)), [5, 6]]
            >>> lens.Recur(Container).collect()(data)
            [Container(1), Container(Container(3))]

        Be careful with this; it can focus things you might not expect.


def Traversal(self, folder, builder):<EOL>

return self._compose_optic(optics.Traversal(folder, builder))<EOL>

An optic that wraps folder and builder functions.

        The folder function is a function that takes a single argument -
        the state - and returns an iterable containing all the foci that
        exist in that state. Generators are a good option for writing
        folder functions.

        A builder function takes the old state and an list of values
        and constructs a new state with the old state's values swapped
        out. The number of values passed to builder for any given state
        should always be the same as the number of values that the folder
        function would have returned for that same state.

            >>> from lenses import lens
            >>> def ends_folder(state):
            ...     'Yields the first and last elements of a list'
            ...     yield state[0]
            ...     yield state[-1]
            >>> def ends_builder(state, values):
            ...     'Sets the first and last elements of a list'
            ...     result = list(state)
            ...     result[0] = values[0]
            ...     result[-1] = values[1]
            ...     return result
            >>> both_ends = lens.Traversal(ends_folder, ends_builder)
            >>> both_ends
            UnboundLens(Traversal(...ends_folder..., ...ends_builder...))
            >>> both_ends.collect()([1, 2, 3, 4])
            [1, 4]
            >>> both_ends.set(5)([1, 2, 3, 4])
            [5, 2, 3, 5]


true_lenses = [l._optic for l in lenses]<EOL>return self._compose_optic(optics.TupleLens(*true_lenses))<EOL>

A lens that combines the focuses of other lenses into a
        single tuple. The sublenses must be optics of kind Lens; this
        means no Traversals.

            >>> from lenses import lens
            >>> lens.Tuple()
            UnboundLens(TupleLens())
            >>> tl = lens.Tuple(lens[0], lens[2])
            >>> tl
            UnboundLens(TupleLens(GetitemLens(0), GetitemLens(2)))
            >>> tl.get()([1, 2, 3, 4])
            (1, 3)
            >>> tl.set((5, 6))([1, 2, 3, 4])
            [5, 2, 6, 4]

        This lens is particularly useful when immediately followed by
        an EachLens, allowing you to traverse data even when it comes
        from disparate locations within the state.

            >>> state = ([1, 2, 3], 4, [5, 6])
            >>> tl.Each().Each().collect()(state)
            [1, 2, 3, 5, 6]
            >>> (tl.Each().Each() + 10)(state)
            ([11, 12, 13], 4, [15, 16])


return self._compose_optic(<EOL>optics.ItemsTraversal() & optics.GetitemLens(<NUM_LIT:1>)<EOL>)<EOL>

A traversal focusing the values of a dictionary. Analogous to
        `dict.values`.

            >>> from lenses import lens
            >>> from collections import OrderedDict
            >>> data = OrderedDict([(1, 10), (2, 20)])
            >>> lens.Values()
            UnboundLens(ItemsTraversal() & GetitemLens(1))
            >>> lens.Values().collect()(data)
            [10, 20]
            >>> lens.Values().modify(lambda n: n + 1)(data)
            OrderedDict([(1, 11), (2, 21)])


return self._compose_optic(optics.ZoomTraversal())<EOL>

Follows its state as if it were a `BoundLens` object.

            >>> from lenses import lens, bind
            >>> data = [bind([1, 2])[1], 4]
            >>> lens.Zoom()
            UnboundLens(ZoomTraversal())
            >>> lens[0].Zoom().get()(data)
            2
            >>> lens[0].Zoom().set(3)(data)
            [[1, 3], 4]


return self._compose_optic(optics.ZoomAttrTraversal(name))<EOL>

A lens that looks up an attribute on its target and follows
        it as if were a `BoundLens` object. Ignores the state, if any,
        of the lens that is being looked up.

            >>> from lenses import lens
            >>> class ClassWithLens(object):
            ...     def __init__(self, items):
            ...         self._private_items = items
            ...     def __repr__(self):
            ...         return 'ClassWithLens({!r})'.format(self._private_items)
            ...     first = lens._private_items[0]
            ...
            >>> data = (ClassWithLens([1, 2, 3]), 4)
            >>> lens.ZoomAttr('first')
            UnboundLens(ZoomAttrTraversal('first'))
            >>> lens[0].ZoomAttr('first').get()(data)
            1
            >>> lens[0].ZoomAttr('first').set(5)(data)
            (ClassWithLens([5, 2, 3]), 4)


def getter(state):<EOL><INDENT>return self._optic.to_list_of(state)[<NUM_LIT:0>]<EOL><DEDENT>return getter<EOL>

Get the first value focused by the lens.

            >>> from lenses import lens
            >>> getter = lens.get()
            >>> getter([1, 2, 3])
            [1, 2, 3]
            >>> zero_item_getter = lens[0].get()
            >>> zero_item_getter([1, 2, 3])
            1


def getter(state):<EOL><INDENT>return self._optic.to_list_of(state)<EOL><DEDENT>return getter<EOL>

Get multiple values focused by the lens. Returns them as
        a list.

            >>> from lenses import lens
            >>> collect_each_first = lens.Each()[0].collect()
            >>> collect_each_first([(1, 2), (3, 4), (5, 6)])
            [1, 3, 5]


def getter(state):<EOL><INDENT>return self._optic.view(state)<EOL><DEDENT>return getter<EOL>

Get the values focused by the lens, merging them together by
        treating them as a monoid. See `lenses.typeclass.mappend`.

            >>> from lenses import lens
            >>> get_each_monoidally = lens.Each().get_monoid()
            >>> get_each_monoidally([[], [1], [2, 3]])
            [1, 2, 3]


def setter(state):<EOL><INDENT>return self._optic.set(state, newvalue)<EOL><DEDENT>return setter<EOL>

Set the focus to `newvalue`.

            >>> from lenses import lens
            >>> set_item_one_to_four = lens[1].set(4)
            >>> set_item_one_to_four([1, 2, 3])
            [1, 4, 3]


def setter_many(state):<EOL><INDENT>return self._optic.iterate(state, new_values)<EOL><DEDENT>return setter_many<EOL>

Set many foci to values taken by iterating over `new_values`.

            >>> from lenses import lens
            >>> lens.Each().set_many(range(4, 7))([0, 1, 2])
            [4, 5, 6]


def modifier(state):<EOL><INDENT>return self._optic.over(state, func)<EOL><DEDENT>return modifier<EOL>

Apply a function to the focus.

            >>> from lenses import lens
            >>> convert_item_one_to_string = lens[1].modify(str)
            >>> convert_item_one_to_string([1, 2, 3])
            [1, '2', 3]
            >>> add_ten_to_item_one = lens[1].modify(lambda n: n + 10)
            >>> add_ten_to_item_one([1, 2, 3])
            [1, 12, 3]


return self._optic.re().view(focus)<EOL>


return UnboundLens(self._optic.re())<EOL>

Flips the direction of the lens. The lens must be unbound
        and all the underlying operations must be isomorphisms.

            >>> from lenses import lens
            >>> json_encoder = lens.Decode().Json().flip()
            >>> json_encode = json_encoder.get()
            >>> json_encode(['hello', 'world'])  # doctest: +SKIP
            b'["hello", "world"]'


if not isinstance(other, UnboundLens):<EOL><INDENT>message = '<STR_LIT>'<EOL>raise TypeError(message.format(type(other)))<EOL><DEDENT>return self._compose_optic(other._optic)<EOL>

Refine the current focus of this lens by composing it with
        another lens object. The other lens must be unbound.

            >>> from lenses import lens
            >>> first = lens[0]
            >>> second = lens[1]
            >>> second_first = second & first
            >>> get_second_then_first = second_first.get()
            >>> get_second_then_first([[0, 1], [2, 3]])
            2


return self._optic.kind().__name__<EOL>


return self._optic.to_list_of(self._state)[<NUM_LIT:0>]<EOL>

Get the first value focused by the lens.

            >>> from lenses import bind
            >>> bind([1, 2, 3]).get()
            [1, 2, 3]
            >>> bind([1, 2, 3])[0].get()
            1


return self._optic.to_list_of(self._state)<EOL>

Get multiple values focused by the lens. Returns them as
        a list.

            >>> from lenses import bind
            >>> bind([(1, 2), (3, 4), (5, 6)]).Each()[0].collect()
            [1, 3, 5]


return self._optic.view(self._state)<EOL>

Get the values focused by the lens, merging them together by
        treating them as a monoid. See `lenses.typeclass.mappend`.

            >>> from lenses import bind
            >>> bind([[], [1], [2, 3]]).Each().get_monoid()
            [1, 2, 3]


return self._optic.set(self._state, newvalue)<EOL>

Set the focus to `newvalue`.

            >>> from lenses import bind
            >>> bind([1, 2, 3])[1].set(4)
            [1, 4, 3]


return self._optic.iterate(self._state, new_values)<EOL>

Set many foci to values taken by iterating over `new_values`.

            >>> from lenses import bind
            >>> bind([0, 1, 2]).Each().set_many(range(4, 7))
            [4, 5, 6]


return self._optic.over(self._state, func)<EOL>

Apply a function to the focus.

            >>> from lenses import bind
            >>> bind([1, 2, 3])[1].modify(str)
            [1, '2', 3]
            >>> bind([1, 2, 3])[1].modify(lambda n: n + 10)
            [1, 12, 3]


Refine the current focus of this lens by composing it with
        another lens object. The other lens must be unbound.

            >>> from lenses import lens, bind
            >>> first = lens[0]
            >>> second = bind([[0, 1], [2, 3]])[1]
            >>> (second & first).get()
            2


functor = typeclass.fmap(args[<NUM_LIT:0>], func)<EOL>for arg in args[<NUM_LIT:1>:]:<EOL><INDENT>functor = typeclass.apply(arg, functor)<EOL><DEDENT>return functor<EOL>

Applies `func` to the data inside the `args` functors
    incrementally. `func` must be a curried function that takes
    `len(args)` arguments.

        >>> func = lambda a: lambda b: a + b
        >>> multiap(func, [1, 10], [100])
        [101, 110]


args = []<EOL>def arg_collector(arg):<EOL><INDENT>args.append(arg)<EOL>if len(args) == n:<EOL><INDENT>return tuple(args)<EOL><DEDENT>else:<EOL><INDENT>return arg_collector<EOL><DEDENT><DEDENT>return arg_collector<EOL>

Returns a function that can be called `n` times with a single
    argument before returning all the args that have been passed to it
    in a tuple. Useful as a substitute for functions that can't easily be
    curried.

        >>> collect_args(3)(1)(2)(3)
        (1, 2, 3)


message = '<STR_LIT>'<EOL>raise NotImplementedError(message.format(type(self)))<EOL>

Intended to be overridden by subclasses. Raises
        NotImplementedError.


return self.func(Functorisor(pure, f), state)<EOL>

Runs the lens over the `state` applying `f` to all the foci
        collecting the results together using the applicative functor
        functions defined in `lenses.typeclass`. `f` must return an
        applicative functor. For the case when no focus exists you must
        also provide a `pure` which should take a focus and return the
        pure form of the functor returned by `f`.


if not self._is_kind(Fold):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>pure = lambda a: Const(Nothing())<EOL>func = lambda a: Const(Just(a))<EOL>return self.apply(func, pure, state).unwrap()<EOL>

Previews a potentially non-existant focus within
        `state`. Returns `Just(focus)` if it exists, Nothing otherwise.

        Requires kind Fold.


if not self._is_kind(Fold):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>guard = object()<EOL>result = self.preview(state).maybe(guard)<EOL>if result is guard:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return cast(B, result)<EOL>

Returns the focus within `state`. If multiple items are
        focused then it will attempt to join them together as a monoid.
        See `lenses.typeclass.mappend`.

        Requires kind Fold. This method will raise TypeError if the
        optic has no way to get any foci.

        For technical reasons, this method requires there to be at least
        one foci at the end of the view. It will raise ValueError when
        there is none.


if not self._is_kind(Fold):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>pure = lambda a: Const([])<EOL>func = lambda a: Const([a])<EOL>return self.apply(func, pure, state).unwrap()<EOL>

Returns a list of all the foci within `state`.

        Requires kind Fold. This method will raise TypeError if the
        optic has no way to get any foci.


if not self._is_kind(Setter):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>pure = lambda a: Identity(a)<EOL>func = lambda a: Identity(fn(a))<EOL>return self.apply(func, pure, state).unwrap()<EOL>

Applies a function `fn` to all the foci within `state`.

        Requires kind Setter. This method will raise TypeError when the
        optic has no way to set foci.


if not self._is_kind(Setter):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>pure = lambda a: Identity(a)<EOL>func = lambda a: Identity(value)<EOL>return self.apply(func, pure, state).unwrap()<EOL>

Sets all the foci within `state` to `value`.

        Requires kind Setter. This method will raise TypeError when the
        optic has no way to set foci.


def iterate(self, state, iterable):<EOL>

if not self._is_kind(Setter):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>i = iter(iterable)<EOL>pure = lambda a: Identity(a)<EOL>func = lambda a: Identity(next(i))<EOL>return self.apply(func, pure, state).unwrap()<EOL>

Sets all the foci within `state` to values taken from `iterable`.

        Requires kind Setter. This method will raise TypeError when the
        optic has no way to set foci.


return ComposedLens([self]).compose(other)<EOL>

Composes another lens with this one. The result is a lens
        that feeds the foci of `self` into the state of `other`.


optics = [<EOL>Equality,<EOL>Isomorphism,<EOL>Prism,<EOL>Review,<EOL>Lens,<EOL>Traversal,<EOL>Getter,<EOL>Setter,<EOL>Fold,<EOL>]<EOL>for optic in optics:<EOL><INDENT>if self._is_kind(optic):<EOL><INDENT>return optic<EOL><DEDENT><DEDENT>

Returns a class representing the 'kind' of optic.


return not self.unpack(state).is_nothing()<EOL>

Returns `True` when the state would be successfully focused
        by this prism, otherwise `False`.

            >>> from lenses.maybe import Nothing, Just
            >>> def pack(focus):
            ...     return focus
            >>> def unpack(state):
            ...     if state > 0:
            ...         return Just(state)
            ...     return Nothing()
            >>> positive = Prism(unpack, pack)
            >>> positive.has(-1)
            False
            >>> positive.has(1)
            True


state = GameState()<EOL>print(state)<EOL>while state.running:<EOL><INDENT>input = get_single_char()<EOL>state, should_advance = state.handle_input(input)<EOL>if should_advance:<EOL><INDENT>state = state.advance_robots()<EOL>state = state.check_game_end()<EOL><DEDENT>print(state)<EOL><DEDENT>print(state.message)<EOL>

The main function. Instantiates a GameState object and then
    enters a REPL-like main loop, waiting for input, updating the state
    based on the input, then outputting the new state.


return cls((randint(<NUM_LIT:0>, MAXX), randint(<NUM_LIT:0>, MAXY)))<EOL>

produces a random vector inside the play area.


return all([<NUM_LIT:0> <= self[<NUM_LIT:0>] <= MAXX, <NUM_LIT:0> <= self[<NUM_LIT:1>] <= MAXY])<EOL>

checks if the vector is inside the play area.


return self + Vector(<EOL>(<EOL>(self[<NUM_LIT:0>] < other[<NUM_LIT:0>]) - (self[<NUM_LIT:0>] > other[<NUM_LIT:0>]),<EOL>(self[<NUM_LIT:1>] < other[<NUM_LIT:1>]) - (self[<NUM_LIT:1>] > other[<NUM_LIT:1>]),<EOL>)<EOL>)<EOL>

returns the vector moved one step in the direction of the
        other, potentially diagonally.


dirs = {<EOL>'<STR_LIT:h>': (-<NUM_LIT:1>, <NUM_LIT:0>),<EOL>'<STR_LIT>': (<NUM_LIT:0>, <NUM_LIT:1>),<EOL>'<STR_LIT:k>': (<NUM_LIT:0>, -<NUM_LIT:1>),<EOL>'<STR_LIT:l>': (<NUM_LIT:1>, <NUM_LIT:0>),<EOL>'<STR_LIT:y>': (-<NUM_LIT:1>, -<NUM_LIT:1>),<EOL>'<STR_LIT:u>': (<NUM_LIT:1>, -<NUM_LIT:1>),<EOL>'<STR_LIT:n>': (<NUM_LIT:1>, <NUM_LIT:1>),<EOL>'<STR_LIT:b>': (-<NUM_LIT:1>, <NUM_LIT:1>),<EOL>}<EOL>if input in dirs:<EOL><INDENT>new_self = (lens.player + dirs[input])(self)<EOL>if not new_self.player.inside():<EOL><INDENT>return self, False<EOL><DEDENT>return new_self, True<EOL><DEDENT>elif input == '<STR_LIT:.>':<EOL><INDENT>return self, True<EOL><DEDENT>elif input == '<STR_LIT:q>':<EOL><INDENT>return self.end_game(), False<EOL><DEDENT>elif input == '<STR_LIT:t>':<EOL><INDENT>self = lens.player.set(Vector.random())(self)<EOL>return self, True<EOL><DEDENT>else:<EOL><INDENT>return self, False<EOL><DEDENT>

Takes a single character string as input and alters the game
        state according to that input. Mostly, this means moving the
        player around. Returns a new game state and boolean indicating
        whether the input had an effect on the state.


<EOL>self = lens.robots.Each().call_step_towards(self.player)(self)<EOL>self = lens.crashes.call_union(duplicates(self.robots))(self)<EOL>self = lens.robots.modify(lambda r: list(set(r) - self.crashes))(self)<EOL>return self<EOL>

Produces a new game state in which the robots have advanced
        towards the player by one step. Handles the robots crashing into
        one another too.


if self.player in self.crashes.union(self.robots):<EOL><INDENT>return self.end_game('<STR_LIT>')<EOL><DEDENT>elif not self.robots:<EOL><INDENT>return self.end_game('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>return self<EOL><DEDENT>

Checks for the game's win/lose conditions and 'alters' the
        game state to reflect the condition found. If the game has not
        been won or lost then it just returns the game state
        unaltered.


return lens.running.set(False)(lens.message.set(message)(self))<EOL>

Returns a completed game state object, setting an optional
        message to display after the game is over.


print(board, end='<STR_LIT>')<EOL>x, y = input('<STR_LIT>')<EOL>print()<EOL>return int(x) - <NUM_LIT:1>, ord(y) - ord('<STR_LIT:a>')<EOL>

Shows the board to the player on the console and asks them to
    make a move.


return random.choice(range(<NUM_LIT:3>)), random.choice(range(<NUM_LIT:3>))<EOL>


ai = {'<STR_LIT:X>': player_move, '<STR_LIT:O>': random_move}<EOL>board = Board()<EOL>while not board.winner:<EOL><INDENT>x, y = ai[board.player](board)<EOL>board = board.make_move(x, y)<EOL><DEDENT>print(board, end='<STR_LIT>')<EOL>print(board.winner)<EOL>

Play a game of naughts and crosses against the computer.


return self is not Outcome.ongoing<EOL>


if self.board[y][x] == '<STR_LIT:U+0020>':<EOL><INDENT>return lens.board[y][x].set(self.player)(self)<EOL><DEDENT>return self<EOL>

Return a board with a cell filled in by the current player. If
        the cell is already occupied then return the board unchanged.


return '<STR_LIT:X>' if self._count('<STR_LIT:X>') <= self._count('<STR_LIT:O>') else '<STR_LIT:O>'<EOL>


for potential_win in self._potential_wins():<EOL><INDENT>if potential_win == tuple('<STR_LIT>'):<EOL><INDENT>return Outcome.win_for_crosses<EOL><DEDENT>elif potential_win == tuple('<STR_LIT>'):<EOL><INDENT>return Outcome.win_for_naughts<EOL><DEDENT><DEDENT>if self._count('<STR_LIT:U+0020>') == <NUM_LIT:0>:<EOL><INDENT>return Outcome.draw<EOL><DEDENT>return Outcome.ongoing<EOL>


return sum(cell == character for cell in self._all_cells())<EOL>

Counts the number of cells in the board that contain a
        particular character.


yield from self.board<EOL>yield from zip(*self.board)<EOL>yield self.board[<NUM_LIT:0>][<NUM_LIT:0>], self.board[<NUM_LIT:1>][<NUM_LIT:1>], self.board[<NUM_LIT:2>][<NUM_LIT:2>]<EOL>yield self.board[<NUM_LIT:0>][<NUM_LIT:2>], self.board[<NUM_LIT:1>][<NUM_LIT:1>], self.board[<NUM_LIT:2>][<NUM_LIT:0>]<EOL>

Generates all the combinations of board positions that need
        to be checked for a win.


def __init__(self, ptype='<STR_LIT>', legislature=None):

assert(ptype in ['<STR_LIT>', '<STR_LIT>'])<EOL>assert(legislature in ['<STR_LIT>', '<STR_LIT>', None])<EOL>self.legislature = legislature<EOL>self.ptype = ptype<EOL>self.ptype_plural = ptype + '<STR_LIT:s>'<EOL>self.base_url = '<STR_LIT>' % (legislature or '<STR_LIT>', self.ptype_plural)<EOL>

type: depute or senateur
legislature: 2007-2012 or None


if month is None and self.legislature == '<STR_LIT>':<EOL><INDENT>raise AssertionError('<STR_LIT>')<EOL><DEDENT>if month is None:<EOL><INDENT>month = '<STR_LIT:data>'<EOL><DEDENT>url = '<STR_LIT>' % (self.base_url, month, self.format)<EOL>data = requests.get(url).json()<EOL>return [depute[self.ptype] for depute in data[self.ptype_plural]]<EOL>


Constructor.

        Args:
          channel: A grpc.Channel.


context.set_code(grpc.StatusCode.UNIMPLEMENTED)<EOL>context.set_details('<STR_LIT>')<EOL>raise NotImplementedError('<STR_LIT>')<EOL>


return dict(self)<EOL>

Return a shallow mutable copy of this object.  Keep in mind that
        the standard library's :func:`copy` function is a no-op for this class
        like for any other python immutable type (eg: :class:`tuple`).


level = logger.getEffectiveLevel()<EOL>current = logger<EOL>while current:<EOL><INDENT>if any(handler.level <= level for handler in current.handlers):<EOL><INDENT>return True<EOL><DEDENT>if not current.propagate:<EOL><INDENT>break<EOL><DEDENT>current = current.parent<EOL><DEDENT>return False<EOL>

Check if there is a handler in the logging chain that will handle the
    given logger's :meth:`effective level <~logging.Logger.getEffectiveLevel>`.


loc = object.__getattribute__(self, '<STR_LIT>')<EOL>if not hasattr(loc, '<STR_LIT>'):<EOL><INDENT>return loc(*self.__args, **self.__kwargs)<EOL><DEDENT>try:  <EOL><INDENT>return getattr(loc, self.__name__)<EOL><DEDENT>except AttributeError:  <EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(self))<EOL><DEDENT>

Get current object.
        This is useful if you want the real
        object behind the proxy at a time for performance reasons or because
        you want to pass the object into a different context.


name = servicer.__name__<EOL>if name in self._servicers:<EOL><INDENT>raise exceptions.ConfigException(<EOL>'<STR_LIT>'.format(name))<EOL><DEDENT>add_func = self._get_servicer_add_func(servicer)<EOL>self._servicers[name] = (add_func, servicer)<EOL>

register serviser

        :param servicer: servicer


def _register_extension(self, name, ext):

ext.init_app(self)<EOL>if name in self._extensions:<EOL><INDENT>raise exceptions.ConfigException(<EOL>'<STR_LIT>'.format(name))<EOL><DEDENT>self._extensions[name] = ext<EOL>

register extension

        :param name: extension name
        :param ext: extension object


walk = [(dirpath.replace(package + os.sep, '<STR_LIT>', <NUM_LIT:1>), filenames)<EOL>for dirpath, dirnames, filenames in os.walk(package)]<EOL>filepaths = []<EOL>for base, filenames in walk:<EOL><INDENT>filepaths.extend([os.path.join(base, filename)<EOL>for filename in filenames])<EOL><DEDENT>return filepaths<EOL>

Return all files under the root package, that are not in a
package themselves.


def fill_with(self, opts=None, *other_opts, **opts_as_kwargs):

if not opts: opts = {}<EOL>list_of_opts = [merge(opts, opts_as_kwargs)] + list(other_opts)<EOL>for options in list_of_opts:<EOL><INDENT>for (field, value) in iteritems(options):<EOL><INDENT>getattr(self._element, field).set(value)<EOL><DEDENT><DEDENT>return self<EOL>

fills fields of self with values passed in dicts in one of the following ways:
as one dict via **kwargs in case the order of fields does not matter:
    fill_with(some_field="value", some_other_field="other value")
as many dicts via *args if the order for some fields does matter:
    fill_with({"field1_should_be_set_first"="value"},
              {"field_dependent_on_field1"="other value", "other_field": "some other value"})


<EOL>base_url = selene.config.app_host if selene.config.app_host else selene.config.base_url<EOL>driver().get(base_url + absolute_or_relative_url)<EOL>

Loads a web page in the current browser session.
:param absolgenerateute_or_relative_url:
    an absolute url to web page in case of config.base_url is not specified,
    otherwise - relative url correspondingly

:Usage:
    open_url('http://mydomain.com/subpage1')
    open_url('http://mydomain.com/subpage2')
    # OR
    config.base_url = 'http://mydomain.com'
    open_url('/subpage1')
    open_url('/subpage2')


result = {}<EOL>for dictionary in dict_args:<EOL><INDENT>result.update(dictionary)<EOL><DEDENT>return result<EOL>

Given any number of dicts, shallow copy and merge into a new dict,
precedence goes to key value pairs in latter dicts.


return self.filtered_by(condition)<EOL>


warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>return self.filtered_by(condition)<EOL>


warnings.warn("<STR_LIT>", DeprecationWarning)<EOL>return self.element_by(condition)<EOL>


def snap_to_cube(q_start, q_stop, chunk_depth=<NUM_LIT:16>, q_index=<NUM_LIT:1>):

lo = <NUM_LIT:0><EOL>hi = <NUM_LIT:0><EOL>q_start -= q_index<EOL>q_stop -= q_index<EOL>if q_start % chunk_depth == <NUM_LIT:0>:<EOL><INDENT>lo = q_start<EOL><DEDENT>else:<EOL><INDENT>lo = q_start - (q_start % chunk_depth)<EOL><DEDENT>if q_stop % chunk_depth == <NUM_LIT:0>:<EOL><INDENT>hi = q_stop<EOL><DEDENT>else:<EOL><INDENT>hi = q_stop + (chunk_depth - q_stop % chunk_depth)<EOL><DEDENT>return [lo + q_index, hi + q_index + <NUM_LIT:1>]<EOL>

For any q in {x, y, z, t}
Takes in a q-range and returns a 1D bound that starts at a cube
boundary and ends at another cube boundary and includes the volume
inside the bounds. For instance, snap_to_cube(2, 3) = (1, 17)

Arguments:
    q_start (int): The lower bound of the q bounding box of volume
    q_stop (int): The upper bound of the q bounding box of volume
    chunk_depth (int : CHUNK_DEPTH) The size of the chunk in this
        volume (use ``get_info()``)
    q_index (int : 1): The starting index of the volume (in q)

Returns:
    2-tuple: (lo, hi) bounding box for the volume


def block_compute(x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_start, z_stop,<EOL>origin=(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:1>),<EOL>block_size=(<NUM_LIT>, <NUM_LIT>, <NUM_LIT:16>)):

<EOL>x_bounds = range(origin[<NUM_LIT:0>], x_stop + block_size[<NUM_LIT:0>], block_size[<NUM_LIT:0>])<EOL>x_bounds = [x for x in x_bounds if (x > x_start and x < x_stop)]<EOL>if len(x_bounds) is <NUM_LIT:0>:<EOL><INDENT>x_slices = [(x_start, x_stop)]<EOL><DEDENT>else:<EOL><INDENT>x_slices = []<EOL>for start_x in x_bounds[:-<NUM_LIT:1>]:<EOL><INDENT>x_slices.append((start_x, start_x + block_size[<NUM_LIT:0>]))<EOL><DEDENT>x_slices.append((x_start, x_bounds[<NUM_LIT:0>]))<EOL>x_slices.append((x_bounds[-<NUM_LIT:1>], x_stop))<EOL><DEDENT>y_bounds = range(origin[<NUM_LIT:1>], x_stop + block_size[<NUM_LIT:1>], block_size[<NUM_LIT:1>])<EOL>y_bounds = [y for y in y_bounds if (y > y_start and y < y_stop)]<EOL>if len(y_bounds) is <NUM_LIT:0>:<EOL><INDENT>y_slices = [(y_start, y_stop)]<EOL><DEDENT>else:<EOL><INDENT>y_slices = []<EOL>for start_y in y_bounds[:-<NUM_LIT:1>]:<EOL><INDENT>y_slices.append((start_y, start_y + block_size[<NUM_LIT:1>]))<EOL><DEDENT>y_slices.append((y_start, y_bounds[<NUM_LIT:0>]))<EOL>y_slices.append((y_bounds[-<NUM_LIT:1>], y_stop))<EOL><DEDENT>z_bounds = range(origin[<NUM_LIT:2>], z_stop + block_size[<NUM_LIT:2>], block_size[<NUM_LIT:2>])<EOL>z_bounds = [z for z in z_bounds if (z > z_start and z < z_stop)]<EOL>if len(z_bounds) is <NUM_LIT:0>:<EOL><INDENT>z_slices = [(z_start, z_stop)]<EOL><DEDENT>else:<EOL><INDENT>z_slices = []<EOL>for start_z in z_bounds[:-<NUM_LIT:1>]:<EOL><INDENT>z_slices.append((start_z, start_z + block_size[<NUM_LIT:2>]))<EOL><DEDENT>z_slices.append((z_start, z_bounds[<NUM_LIT:0>]))<EOL>z_slices.append((z_bounds[-<NUM_LIT:1>], z_stop))<EOL><DEDENT>chunks = []<EOL>for x in x_slices:<EOL><INDENT>for y in y_slices:<EOL><INDENT>for z in z_slices:<EOL><INDENT>chunks.append((x, y, z))<EOL><DEDENT><DEDENT><DEDENT>return chunks<EOL>

Get bounding box coordinates (in 3D) of small cutouts to request in
order to reconstitute a larger cutout.

Arguments:
    x_start (int): The lower bound of dimension x
    x_stop (int): The upper bound of dimension x
    y_start (int): The lower bound of dimension y
    y_stop (int): The upper bound of dimension y
    z_start (int): The lower bound of dimension z
    z_stop (int): The upper bound of dimension z

Returns:
    [((x_start, x_stop), (y_start, y_stop), (z_start, z_stop)), ... ]


def export_dae(filename, cutout, level=<NUM_LIT:0>):

if "<STR_LIT>" not in filename:<EOL><INDENT>filename = filename + "<STR_LIT>"<EOL><DEDENT>vs, fs = mcubes.marching_cubes(cutout, level)<EOL>mcubes.export_mesh(vs, fs, filename, "<STR_LIT>")<EOL>

Converts a dense annotation to a DAE, using Marching Cubes (PyMCubes).

Arguments:
    filename (str): The filename to write out to
    cutout (numpy.ndarray): The dense annotation
    level (int): The level at which to run mcubes

Returns:
    boolean success


def export_obj(filename, cutout, level=<NUM_LIT:0>):

if "<STR_LIT>" not in filename:<EOL><INDENT>filename = filename + "<STR_LIT>"<EOL><DEDENT>vs, fs = mcubes.marching_cubes(cutout, level)<EOL>mcubes.export_obj(vs, fs, filename)<EOL>

Converts a dense annotation to a obj, using Marching Cubes (PyMCubes).

Arguments:
    filename (str): The filename to write out to
    cutout (numpy.ndarray): The dense annotation
    level (int): The level at which to run mcubes

Returns:
    boolean success


def export_ply(filename, cutout, level=<NUM_LIT:0>):

if "<STR_LIT>" not in filename:<EOL><INDENT>filename = filename + "<STR_LIT>"<EOL><DEDENT>vs, fs = mcubes.marching_cubes(cutout, level)<EOL>with open(filename, '<STR_LIT:w>') as fh:<EOL><INDENT>lines = [<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>" + str(len(vs)),<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>" + str(len(fs)),<EOL>"<STR_LIT>",<EOL>"<STR_LIT>"<EOL>]<EOL>fh.writelines(lines)<EOL>for v in vs:<EOL><INDENT>fh.write("<STR_LIT>".format(v[<NUM_LIT:0>], v[<NUM_LIT:1>], v[<NUM_LIT:2>]))<EOL><DEDENT>for f in fs:<EOL><INDENT>fh.write("<STR_LIT>".format(f[<NUM_LIT:0>], f[<NUM_LIT:1>], f[<NUM_LIT:2>]))<EOL><DEDENT><DEDENT>

Converts a dense annotation to a .PLY, using Marching Cubes (PyMCubes).

Arguments:
    filename (str): The filename to write out to
    cutout (numpy.ndarray): The dense annotation
    level (int): The level at which to run mcubes

Returns:
    boolean success


self._user_token = user_token<EOL>

Initializes for remote_utils.

Arguments:
    user_token (str): Authentication token for user.


try:<EOL><INDENT>req = requests.get(url, headers={<EOL>'<STR_LIT>': '<STR_LIT>'.format(self._user_token)<EOL>}, verify=False)<EOL>if req.status_code is <NUM_LIT>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>return req<EOL><DEDENT><DEDENT>except requests.exceptions.ConnectionError as e:<EOL><INDENT>if str(e) == '<STR_LIT>':<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>raise e<EOL><DEDENT><DEDENT>

Get a response object for a given url.

Arguments:
    url (str): The url make a get to
    token (str): The authentication token

Returns:
    obj: The response object


def post_url(self, url, token='<STR_LIT>', json=None, data=None, headers=None):

if (token == '<STR_LIT>'):<EOL><INDENT>token = self._user_token<EOL><DEDENT>if headers:<EOL><INDENT>headers.update({'<STR_LIT>': '<STR_LIT>'.format(token)})<EOL><DEDENT>else:<EOL><INDENT>headers = {'<STR_LIT>': '<STR_LIT>'.format(token)}<EOL><DEDENT>if json:<EOL><INDENT>return requests.post(url,<EOL>headers=headers,<EOL>json=json,<EOL>verify=False)<EOL><DEDENT>if data:<EOL><INDENT>return requests.post(url,<EOL>headers=headers,<EOL>data=data,<EOL>verify=False)<EOL><DEDENT>return requests.post(url,<EOL>headers=headers,<EOL>verify=False)<EOL>

Returns a post resquest object taking in a url, user token, and
possible json information.

Arguments:
    url (str): The url to make post to
    token (str): The authentication token
    json (dict): json info to send

Returns:
    obj: Post request object


def delete_url(self, url, token='<STR_LIT>'):

if (token == '<STR_LIT>'):<EOL><INDENT>token = self._user_token<EOL><DEDENT>return requests.delete(url,<EOL>headers={<EOL>'<STR_LIT>': '<STR_LIT>'.format(token)},<EOL>verify=False,)<EOL>

Returns a delete resquest object taking in a url and user token.

Arguments:
    url (str): The url to make post to
    token (str): The authentication token

Returns:
    obj: Delete request object


def ping(self, url, endpoint='<STR_LIT>'):

r = self.get_url(url + "<STR_LIT:/>" + endpoint)<EOL>return r.status_code<EOL>

Ping the server to make sure that you can access the base URL.

Arguments:
    None
Returns:
    `boolean` Successful access of server (or status code)


self.channels = {}<EOL>self.dataset = []<EOL>self.project = []<EOL>self.metadata = '<STR_LIT>'<EOL>if site_host is not None:<EOL><INDENT>self.oo = nd(site_host)<EOL><DEDENT>else:<EOL><INDENT>self.oo = nd()<EOL><DEDENT>rd = requests.get('<STR_LIT>'.format(SCHEMA_BASE))<EOL>if (rd.status_code < <NUM_LIT>):<EOL><INDENT>self.DATASET_SCHEMA = load(eval(str(rd.text)))<EOL><DEDENT>else:<EOL><INDENT>raise OSError("<STR_LIT>")<EOL><DEDENT>rc = requests.get('<STR_LIT>'.format(SCHEMA_BASE))<EOL>if (rc.status_code < <NUM_LIT>):<EOL><INDENT>self.CHANNEL_SCHEMA = load(eval(str(rc.text)))<EOL><DEDENT>else:<EOL><INDENT>raise OSError("<STR_LIT>")<EOL><DEDENT>rp = requests.get('<STR_LIT>'.format(SCHEMA_BASE))<EOL>if (rp.status_code < <NUM_LIT>):<EOL><INDENT>self.PROJECT_SCHEMA = load(eval(str(rp.text)))<EOL><DEDENT>else:<EOL><INDENT>raise Value("<STR_LIT>")<EOL><DEDENT>

Arguments:
    site_host(str): The site host to post the data to, by default
        http://openconnectome.me.

Returns:
    None


def add_channel(self, channel_name, datatype, channel_type,<EOL>data_url, file_format, file_type, exceptions=None,<EOL>resolution=None, windowrange=None, readonly=None):

self.channels[channel_name] = [<EOL>channel_name.strip().replace("<STR_LIT:U+0020>", "<STR_LIT>"), datatype,<EOL>channel_type.lower(), data_url,<EOL>file_format, file_type, exceptions, resolution,<EOL>windowrange, readonly<EOL>]<EOL>

Arguments:
    channel_name (str): Channel Name is the specific name of a
        specific series of data. Standard naming convention is to do
        ImageTypeIterationNumber or NameSubProjectName.
    datatype (str): The data type is the storage method of data in
        the channel. It can be uint8, uint16, uint32, uint64, or
        float32.
    channel_type (str): The channel type is the kind of data being
        stored in the channel. It can be image, annotation, or
        timeseries.
    data_url (str): This url points to the root directory of the
        files. Dropbox (or any data requiring authentication to
        download such as private s3) is not an acceptable HTTP
        Server. See additional instructions in documentation online
        to format s3 properly so it is http accessible.
    file_format (str): File format refers to the overarching kind
        of data, as in slices (normal image data) or catmaid
        (tile-based).
    file_type (str): File type refers to the specific type of file
        that the data is stored in, as in, tiff, png, or tif.
    exceptions (int): Exceptions is an option to enable the
        possibility for annotations to contradict each other (assign
        different values to the same point). 1 corresponds to True,
        0 corresponds to False.
    resolution (int): Resolution is the starting resolution of the
        data being uploaded to the channel.
    windowrange (int, int): Window range is the maximum and minimum
        pixel values for a particular image. This is used so that the
        image can be displayed in a readable way for viewing through
        RESTful calls
    readonly (int): This option allows the user to control if,
        after the initial data commit, the channel is read-only.
        Generally this is suggested with data that will be publicly
        viewable.

Returns:
    None


def add_project(self, project_name, token_name=None, public=None):

self.project = (project_name.strip().replace("<STR_LIT:U+0020>", "<STR_LIT>"),<EOL>token_name.strip().replace("<STR_LIT:U+0020>", "<STR_LIT>"), public)<EOL>

Arguments:
    project_name (str): Project name is the specific project within
        a dataset's name. If there is only one project associated
        with a dataset then standard convention is to name the
        project the same as its associated dataset.
    token_name (str): The token name is the default token. If you
        do not wish to specify one, a default one will be created for
        you with the same name as the project name. However, if the
        project is private you must specify a token.
    public (int): This option allows users to specify if they want
        the project/channels to be publicly viewable/search-able.
        (1, 0) = (TRUE, FALSE)

Returns:
    None


def add_dataset(self, dataset_name, imagesize, voxelres, offset=None,<EOL>timerange=None, scalinglevels=None, scaling=None):

self.dataset = (dataset_name.strip().replace("<STR_LIT:U+0020>", "<STR_LIT>"), imagesize,<EOL>voxelres, offset, timerange, scalinglevels, scaling)<EOL>

Add a new dataset to the ingest.

Arguments:
    dataset_name (str): Dataset Name is the overarching name of the
        research effort. Standard naming convention is to do
        LabNamePublicationYear or LeadResearcherCurrentYear.
    imagesize (int, int, int): Image size is the pixel count
        dimensions of the data. For example is the data is stored
        as a series of 100 slices each 2100x2000 pixel TIFF images,
        the X,Y,Z dimensions are (2100, 2000, 100).
    voxelres (float, float, float): Voxel Resolution is the number
        of voxels per unit pixel. We store X,Y,Z voxel resolution
        separately.
    offset (int, int, int): If your data is not well aligned and
        there is "excess" image data you do not wish to examine, but
        are present in your images, offset is how you specify where
        your actual image starts. Offset is provided a pixel
        coordinate offset from origin which specifies the "actual"
        origin of the image. The offset is for X,Y,Z dimensions.
    timerange (int, int): Time Range is a parameter to support
        storage of Time Series data, so the value of the tuple is a
        0 to X range of how many images over time were taken. It
        takes 2 inputs timeStepStart and timeStepStop.
    scalinglevels (int): Scaling levels is the number of levels the
        data is scalable to (how many zoom levels are present in the
        data). The highest resolution of the data is at scaling level
        0, and for each level up the data is down sampled by 2x2
        (per slice). To learn more about the sampling service used,
        visit the the propagation service page.
    scaling (int): Scaling is the scaling method of the data being
        stored. 0 corresponds to a Z-slice orientation (as in a
        collection of tiff images in which each tiff is a slice on
        the z plane) where data will be scaled only on the xy plane,
        not the z plane. 1 corresponds to an isotropic orientation
        (in which each tiff is a slice on the y plane) where data
        is scaled along all axis.

Returns:
    None


self.metadata = metadata<EOL>

Arguments:
    metadata(str): Any metadata as appropriate from the LIMS schema

Returns:
    None


def nd_json(self, dataset, project, channel_list, metadata):

nd_dict = {}<EOL>nd_dict['<STR_LIT>'] = self.dataset_dict(*dataset)<EOL>nd_dict['<STR_LIT>'] = self.project_dict(*project)<EOL>nd_dict['<STR_LIT>'] = metadata<EOL>nd_dict['<STR_LIT>'] = {}<EOL>for channel_name, value in channel_list.items():<EOL><INDENT>nd_dict['<STR_LIT>'][channel_name] = self.channel_dict(*value)<EOL><DEDENT>return json.dumps(nd_dict, sort_keys=True, indent=<NUM_LIT:4>)<EOL>


def nd_json_list(self, dataset, project, channel_list, metadata):

nd_dict = {}<EOL>nd_dict['<STR_LIT>'] = self.dataset_dict(*dataset)<EOL>nd_dict['<STR_LIT>'] = self.project_dict(*project)<EOL>nd_dict['<STR_LIT>'] = metadata<EOL>nd_dict['<STR_LIT>'] = {}<EOL>for channel_name, value in channel_list.items():<EOL><INDENT>nd_dict['<STR_LIT>'].append(self.channel_dict(*value))<EOL><DEDENT>return json.dumps(nd_dict, sort_keys=True, indent=<NUM_LIT:4>)<EOL>


def dataset_dict(<EOL>self, dataset_name, imagesize, voxelres,<EOL>offset, timerange, scalinglevels, scaling):

dataset_dict = {}<EOL>dataset_dict['<STR_LIT>'] = dataset_name<EOL>dataset_dict['<STR_LIT>'] = imagesize<EOL>dataset_dict['<STR_LIT>'] = voxelres<EOL>if offset is not None:<EOL><INDENT>dataset_dict['<STR_LIT>'] = offset<EOL><DEDENT>if timerange is not None:<EOL><INDENT>dataset_dict['<STR_LIT>'] = timerange<EOL><DEDENT>if scalinglevels is not None:<EOL><INDENT>dataset_dict['<STR_LIT>'] = scalinglevels<EOL><DEDENT>if scaling is not None:<EOL><INDENT>dataset_dict['<STR_LIT>'] = scaling<EOL><DEDENT>return dataset_dict<EOL>


def channel_dict(self, channel_name, datatype, channel_type, data_url,<EOL>file_format, file_type, exceptions, resolution,<EOL>windowrange, readonly):

channel_dict = {}<EOL>channel_dict['<STR_LIT>'] = channel_name<EOL>channel_dict['<STR_LIT>'] = datatype<EOL>channel_dict['<STR_LIT>'] = channel_type<EOL>if exceptions is not None:<EOL><INDENT>channel_dict['<STR_LIT>'] = exceptions<EOL><DEDENT>if resolution is not None:<EOL><INDENT>channel_dict['<STR_LIT>'] = resolution<EOL><DEDENT>if windowrange is not None:<EOL><INDENT>channel_dict['<STR_LIT>'] = windowrange<EOL><DEDENT>if readonly is not None:<EOL><INDENT>channel_dict['<STR_LIT>'] = readonly<EOL><DEDENT>channel_dict['<STR_LIT>'] = data_url<EOL>channel_dict['<STR_LIT>'] = file_format<EOL>channel_dict['<STR_LIT>'] = file_type<EOL>return channel_dict<EOL>


def project_dict(self, project_name, token_name, public):

project_dict = {}<EOL>project_dict['<STR_LIT>'] = project_name<EOL>if token_name is not None:<EOL><INDENT>if token_name == '<STR_LIT>':<EOL><INDENT>project_dict['<STR_LIT>'] = project_name<EOL><DEDENT>else:<EOL><INDENT>project_dict['<STR_LIT>'] = token_name<EOL><DEDENT><DEDENT>else:<EOL><INDENT>project_dict['<STR_LIT>'] = project_name<EOL><DEDENT>if public is not None:<EOL><INDENT>project_dict['<STR_LIT>'] = public<EOL><DEDENT>return project_dict<EOL>


def identify_imagesize(self, image_type, image_path='<STR_LIT>'):

dims = ()<EOL>try:<EOL><INDENT>if (image_type.lower() == '<STR_LIT>'):<EOL><INDENT>dims = np.shape(ndpng.load('<STR_LIT>'.format(<EOL>image_path, image_type<EOL>)))<EOL><DEDENT>elif (image_type.lower() == '<STR_LIT>' or image_type.lower() == '<STR_LIT>'):<EOL><INDENT>dims = np.shape(ndtiff.load('<STR_LIT>'.format(<EOL>image_path, image_type<EOL>)))<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>except:<EOL><INDENT>raise OSError('<STR_LIT>'.format(<EOL>image_path,<EOL>image_type<EOL>))<EOL><DEDENT>return dims[::-<NUM_LIT:1>]<EOL>

Identify the image size using the data location and other parameters


def verify_path(self, data, verifytype):

<EOL>try:<EOL><INDENT>token_name = data["<STR_LIT>"]["<STR_LIT>"]<EOL><DEDENT>except:<EOL><INDENT>token_name = data["<STR_LIT>"]["<STR_LIT>"]<EOL><DEDENT>channel_names = list(data["<STR_LIT>"].copy().keys())<EOL>imgsz = data['<STR_LIT>']['<STR_LIT>']<EOL>for i in range(<NUM_LIT:0>, len(channel_names)):<EOL><INDENT>channel_type = data["<STR_LIT>"][<EOL>channel_names[i]]["<STR_LIT>"]<EOL>path = data["<STR_LIT>"][channel_names[i]]["<STR_LIT>"]<EOL>aws_pattern = re.compile("<STR_LIT>")<EOL>file_type = data["<STR_LIT>"][channel_names[i]]["<STR_LIT>"]<EOL>if "<STR_LIT>" in data["<STR_LIT>"]:<EOL><INDENT>offset = data["<STR_LIT>"]["<STR_LIT>"][<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>offset = <NUM_LIT:0><EOL><DEDENT>if (aws_pattern.match(path)):<EOL><INDENT>verifytype = VERIFY_BY_SLICE<EOL><DEDENT>if (channel_type == "<STR_LIT>"):<EOL><INDENT>timerange = data["<STR_LIT>"]["<STR_LIT>"]<EOL>try:<EOL><INDENT>assert(timerange[<NUM_LIT:0>] != timerange[<NUM_LIT:1>])<EOL><DEDENT>except AssertionError:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>for j in range(timerange[<NUM_LIT:0>], timerange[<NUM_LIT:1>] + <NUM_LIT:1>):<EOL><INDENT>if (verifytype == VERIFY_BY_FOLDER):<EOL><INDENT>work_path = "<STR_LIT>".format(<EOL>path, token_name, channel_names[i], ("<STR_LIT>" % j))<EOL><DEDENT>elif (verifytype == VERIFY_BY_SLICE):<EOL><INDENT>work_path = "<STR_LIT>".format(<EOL>path, token_name, channel_names[i], ("<STR_LIT>" % j),<EOL>("<STR_LIT>" % offset), file_type)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>if (verifytype == VERIFY_BY_FOLDER):<EOL><INDENT>resp = requests.head(work_path)<EOL>assert(resp.status_code == <NUM_LIT:200>)<EOL><DEDENT>elif (verifytype == VERIFY_BY_SLICE):<EOL><INDENT>resp = requests.get(<EOL>work_path, stream=True, verify=False)<EOL>with open('<STR_LIT>'.format(file_type),<EOL>'<STR_LIT:wb>') as out_file:<EOL><INDENT>shutil.copyfileobj(resp.raw, out_file)<EOL><DEDENT>out_file.close()<EOL>assert(resp.status_code == <NUM_LIT:200>)<EOL>resp.close()<EOL><DEDENT><DEDENT>except AssertionError:<EOL><INDENT>raise OSError('<STR_LIT>'.format(resp.status_code,<EOL>work_path))<EOL><DEDENT>try:<EOL><INDENT>if (verifytype == VERIFY_BY_SLICE):<EOL><INDENT>assert(list(self.identify_imagesize(file_type)) ==<EOL>imgsz[<NUM_LIT:0>:<NUM_LIT:2>])<EOL><DEDENT><DEDENT>except:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if (verifytype == VERIFY_BY_FOLDER):<EOL><INDENT>work_path = "<STR_LIT>".format(<EOL>path, token_name, channel_names[i])<EOL><DEDENT>elif (verifytype == VERIFY_BY_SLICE):<EOL><INDENT>work_path = "<STR_LIT>".format(<EOL>path, token_name, channel_names[i],<EOL>("<STR_LIT>" % offset), file_type)<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>if (verifytype == VERIFY_BY_FOLDER):<EOL><INDENT>resp = requests.head(work_path)<EOL><DEDENT>elif (verifytype == VERIFY_BY_SLICE):<EOL><INDENT>resp = requests.get(work_path, stream=True, verify=False)<EOL>with open('<STR_LIT>'.format(file_type),<EOL>'<STR_LIT:wb>') as out_file:<EOL><INDENT>shutil.copyfileobj(resp.raw, out_file)<EOL><DEDENT>out_file.close()<EOL>resp.close()<EOL><DEDENT>if (resp.status_code >= <NUM_LIT>):<EOL><INDENT>raise OSError('<STR_LIT>'.format(resp.status_code,<EOL>work_path))<EOL><DEDENT>try:<EOL><INDENT>if (verifytype == VERIFY_BY_SLICE):<EOL><INDENT>assert(list(self.identify_imagesize(file_type)) ==<EOL>imgsz[<NUM_LIT:0>:<NUM_LIT:2>])<EOL><DEDENT><DEDENT>except:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>


URLPath = self.oo.url("<STR_LIT>")<EOL>try:<EOL><INDENT>response = requests.post(URLPath, data=json.dumps(data),<EOL>verify=False)<EOL>assert(response.status_code == <NUM_LIT:200>)<EOL>print("<STR_LIT>".format(response.content))<EOL><DEDENT>except:<EOL><INDENT>raise OSError("Error in posting JSON file {}\ (response.status_code))


def post_data(self, file_name=None, legacy=False,<EOL>verifytype=VERIFY_BY_SLICE):

if (file_name is None):<EOL><INDENT>complete_example = (<EOL>self.dataset, self.project, self.channels, self.metadata)<EOL>data = json.loads(self.nd_json(*complete_example))<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>with open(file_name) as data_file:<EOL><INDENT>data = json.load(data_file)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>raise OSError("<STR_LIT>")<EOL><DEDENT><DEDENT>self.put_data(data)<EOL>

Arguments:
    file_name (str): The file name of the json file to post (optional).
        If this is left unspecified it is assumed the data is in the
        AutoIngest object.
    dev (bool): If pushing to a microns dev branch server set this
        to True, if not leave False.
    verifytype (enum): Set http verification type, by checking the
        first slice is accessible or by checking channel folder.
        NOTE: If verification occurs by folder there is NO image size
        or type verification. Enum: [Folder, Slice]

Returns:
    None


complete_example = (<EOL>self.dataset, self.project, self.channels, self.metadata)<EOL>data = json.loads(self.nd_json(*complete_example))<EOL>self.verify_path(data, VERIFY_BY_SLICE)<EOL>f = open(file_name, '<STR_LIT:w>')<EOL>f.write(str(data))<EOL>f.close()<EOL>

Arguments:
    file_name(str : '/tmp/ND.json'): The file name to store the json to

Returns:
    None


self.data = data(user_token,<EOL>hostname,<EOL>protocol,<EOL>meta_root,<EOL>meta_protocol, **kwargs)<EOL>self.resources = resources(user_token,<EOL>hostname,<EOL>protocol,<EOL>meta_root,<EOL>meta_protocol, **kwargs)<EOL>super(neurodata, self).__init__(user_token,<EOL>hostname,<EOL>protocol,<EOL>meta_root,<EOL>meta_protocol, **kwargs)<EOL>

Initializer for the neurodata remote class.

Arguments:
    hostname (str: "openconnecto.me"): The hostname to connect to
    protocol (str: "http"): The protocol (http or https) to use
    meta_root (str: "http://lims.neurodata.io/"): The metadata server
    meta_protocol (str: "http"): The protocol to use for the md server
    check_tokens (boolean: False): Whether functions that take `token`
        as an argument should check for the existance of that token and
        fail immediately if it is not found. This is a good idea for
        functions that take more time to complete, and might not fail
        until the very end otherwise.
    chunk_threshold (int: 1e9 / 4): The maximum size of a numpy array
        that will be uploaded in one HTTP request. If you find that
        your data requests are commonly timing out, try reducing this.
        Default is 1e9 / 4, or a 0.25GiB.
    suffix (str: "ocp"): The URL suffix to specify ndstore/microns. If
        you aren't sure what to do with this, don't specify one.


def get_block_size(self, token, resolution=None):

return self.data.get_block_size(token, resolution)<EOL>

Gets the block-size for a given token at a given resolution.

Arguments:
    token (str): The token to inspect
    resolution (int : None): The resolution at which to inspect data.
        If none is specified, uses the minimum available.

Returns:
    int[3]: The xyz blocksize.


def get_image_offset(self, token, resolution=<NUM_LIT:0>):

return self.data.get_image_offset(token, resolution)<EOL>

Gets the image offset for a given token at a given resolution. For
instance, the `kasthuri11` dataset starts at (0, 0, 1), so its 1850th
slice is slice 1850, not 1849. When downloading a full dataset, the
result of this function should be your x/y/z starts.

Arguments:
    token (str): The token to inspect
    resolution (int : 0): The resolution at which to gather the offset

Returns:
    int[3]: The origin of the dataset, as a list


def get_xy_slice(self, token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_index,<EOL>resolution=<NUM_LIT:0>):

return self.data.get_xy_slice(token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_index,<EOL>resolution)<EOL>

Return a binary-encoded, decompressed 2d image. You should
specify a 'token' and 'channel' pair.  For image data, users
should use the channel 'image.'

Arguments:
    token (str): Token to identify data to download
    channel (str): Channel
    resolution (int): Resolution level
    Q_start (int):` The lower bound of dimension 'Q'
    Q_stop (int): The upper bound of dimension 'Q'
    z_index (int): The z-slice to image

Returns:
    str: binary image data


def get_image(self, token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_index,<EOL>resolution=<NUM_LIT:0>):

return self.data.get_image(token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_index, resolution)<EOL>

Alias for the `get_xy_slice` function for backwards compatibility.


def get_volume(self, token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_start, z_stop,<EOL>resolution=<NUM_LIT:1>,<EOL>block_size=DEFAULT_BLOCK_SIZE,<EOL>neariso=False):

return self.data.get_volume(token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_start, z_stop,<EOL>resolution, block_size, neariso)<EOL>

Get a RAMONVolume volumetric cutout from the neurodata server.

Arguments:
    token (str): Token to identify data to download
    channel (str): Channel
    resolution (int): Resolution level
    Q_start (int): The lower bound of dimension 'Q'
    Q_stop (int): The upper bound of dimension 'Q'
    block_size (int[3]): Block size of this dataset
    neariso (bool : False): Passes the 'neariso' param to the cutout.
        If you don't know what this means, ignore it!

Returns:
    ndio.ramon.RAMONVolume: Downloaded data.


def get_cutout(self, token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_start, z_stop,<EOL>t_start=<NUM_LIT:0>, t_stop=<NUM_LIT:1>,<EOL>resolution=<NUM_LIT:1>,<EOL>block_size=DEFAULT_BLOCK_SIZE,<EOL>neariso=False):

return self.data.get_cutout(token, channel,<EOL>x_start, x_stop,<EOL>y_start, y_stop,<EOL>z_start, z_stop,<EOL>t_start, t_stop,<EOL>resolution,<EOL>block_size,<EOL>neariso)<EOL>

Get volumetric cutout data from the neurodata server.

Arguments:
    token (str): Token to identify data to download
    channel (str): Channel
    resolution (int): Resolution level
    Q_start (int): The lower bound of dimension 'Q'
    Q_stop (int): The upper bound of dimension 'Q'
    block_size (int[3]): Block size of this dataset. If not provided,
        ndio uses the metadata of this tokenchannel to set. If you find
        that your downloads are timing out or otherwise failing, it may
        be wise to start off by making this smaller.
    neariso (bool : False): Passes the 'neariso' param to the cutout.
        If you don't know what this means, ignore it!

Returns:
    numpy.ndarray: Downloaded data.


def post_cutout(self, token, channel,<EOL>x_start,<EOL>y_start,<EOL>z_start,<EOL>data,<EOL>resolution=<NUM_LIT:0>):

return self.data.post_cutout(token, channel,<EOL>x_start,<EOL>y_start,<EOL>z_start,<EOL>data,<EOL>resolution)<EOL>

Post a cutout to the server.

Arguments:
    token (str)
    channel (str)
    x_start (int)
    y_start (int)
    z_start (int)
    data (numpy.ndarray): A numpy array of data. Pass in (x, y, z)
    resolution (int : 0): Resolution at which to insert the data

Returns:
    bool: True on success

Raises:
    RemoteDataUploadError: if there's an issue during upload.