@classmethod<EOL><INDENT>def get_cli(cls) -> click.Group:<DEDENT>

Get a :mod:`click` main function with added BEL namespace commands.


def add_cli_to_bel(main: click.Group) -> click.Group:

@main.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=click.File('<STR_LIT:w>'), default=sys.stdout)<EOL>@click.option('<STR_LIT>', '<STR_LIT>', default='<STR_LIT>', show_default=True, help='<STR_LIT>')<EOL>@click.pass_obj<EOL>def write(manager: BELManagerMixin, output: TextIO, fmt: str):<EOL><INDENT>"""<STR_LIT>"""<EOL>graph = manager.to_bel()<EOL>graph.serialize(file=output, fmt=fmt)<EOL>click.echo(graph.summary_str())<EOL><DEDENT>return main<EOL>

Add several command to main :mod:`click` function related to export to BEL.


def add_cli_upload_bel(main: click.Group) -> click.Group:

@main.command()<EOL>@host_option<EOL>@click.pass_obj<EOL>def upload(manager: BELManagerMixin, host: str):<EOL><INDENT>"""<STR_LIT>"""<EOL>graph = manager.to_bel()<EOL>pybel.to_web(graph, host=host, public=True)<EOL><DEDENT>return main<EOL>


if self.edge_model is ...:<EOL><INDENT>raise Bio2BELMissingEdgeModelError('<STR_LIT>')<EOL><DEDENT>elif isinstance(self.edge_model, list):<EOL><INDENT>return sum(self._count_model(m) for m in self.edge_model)<EOL><DEDENT>else:<EOL><INDENT>return self._count_model(self.edge_model)<EOL><DEDENT>

Count the number of BEL relations generated.


@abstractmethod<EOL><INDENT>def to_bel(self, *args, **kwargs) -> pybel.BELGraph:<DEDENT>

Convert the database to BEL.

        Example implementation outline:

        .. code-block:: python

            from bio2bel import AbstractManager
            from bio2bel.manager.bel_manager import BELManagerMixin
            from pybel import BELGraph
            from .models import Interaction

            class MyManager(AbstractManager, BELManagerMixin):
                module_name = 'mirtarbase'
                def to_bel(self):
                    rv = BELGraph(
                        name='miRTarBase',
                        version='1.0.0',
                    )

                    for interaction in self.session.query(Interaction):
                        mirna = mirna_dsl('mirtarbase', interaction.mirna.mirtarbase_id)
                        rna = rna_dsl('hgnc', interaction.target.hgnc_id)

                        rv.add_qualified_edge(
                            mirna,
                            rna,
                            DECREASES,
                            ...
                        )

                    return rv


def to_indra_statements(self, *args, **kwargs):

graph = self.to_bel(*args, **kwargs)<EOL>return to_indra_statements(graph)<EOL>

Dump as a list of INDRA statements.

        :rtype: List[indra.Statement]


@staticmethod<EOL><INDENT>def _cli_add_to_bel(main: click.Group) -> click.Group:<DEDENT>

return add_cli_to_bel(main)<EOL>


@staticmethod<EOL><INDENT>def _cli_add_upload_bel(main: click.Group) -> click.Group:<DEDENT>

return add_cli_upload_bel(main)<EOL>


main = super().get_cli()<EOL>@main.group()<EOL>def bel():<EOL><INDENT>"""<STR_LIT>"""<EOL><DEDENT>cls._cli_add_to_bel(bel)<EOL>cls._cli_add_upload_bel(bel)<EOL>return main<EOL>

Get a :mod:`click` main function with added BEL commands.


def add_cli_flask(main: click.Group) -> click.Group:

@main.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True)<EOL>@click.option('<STR_LIT>', '<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', default=os.urandom(<NUM_LIT:8>))<EOL>@click.pass_obj<EOL>def web(manager, debug, port, host, secret_key):<EOL><INDENT>"""<STR_LIT>"""<EOL>if not manager.is_populated():<EOL><INDENT>click.echo('<STR_LIT>'.format(manager.module_name))<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>app = manager.get_flask_admin_app(url='<STR_LIT:/>', secret_key=secret_key)<EOL>app.run(debug=debug, host=host, port=port)<EOL><DEDENT>return main<EOL>

Add a ``web`` comand main :mod:`click` function.


from flask_admin import Admin<EOL>from flask_admin.contrib.sqla import ModelView<EOL>admin = Admin(app, **kwargs)<EOL>for flask_admin_model in self.flask_admin_models:<EOL><INDENT>if isinstance(flask_admin_model, tuple):  <EOL><INDENT>if len(flask_admin_model) != <NUM_LIT:2>:<EOL><INDENT>raise TypeError<EOL><DEDENT>model, view = flask_admin_model<EOL>admin.add_view(view(model, self.session))<EOL><DEDENT>else:<EOL><INDENT>admin.add_view(ModelView(flask_admin_model, self.session))<EOL><DEDENT><DEDENT>return admin<EOL>

Add a Flask Admin interface to an application.

        :param flask.Flask app: A Flask application
        :param kwargs: Keyword arguments are passed through to :class:`flask_admin.Admin`
        :rtype: flask_admin.Admin


def get_flask_admin_app(self, url: Optional[str] = None, secret_key: Optional[str] = None):

from flask import Flask<EOL>app = Flask(__name__)<EOL>if secret_key:<EOL><INDENT>app.secret_key = secret_key<EOL><DEDENT>self._add_admin(app, url=(url or '<STR_LIT:/>'))<EOL>return app<EOL>

Create a Flask application.

        :param url: Optional mount point of the admin application. Defaults to ``'/'``.
        :rtype: flask.Flask


@staticmethod<EOL><INDENT>def _cli_add_flask(main: click.Group) -> click.Group:<DEDENT>

return add_cli_flask(main)<EOL>


main = super().get_cli()<EOL>cls._cli_add_flask(main)<EOL>return main<EOL>

Add  a :mod:`click` main function to use as a command line interface.


def add_cli_populate(main: click.Group) -> click.Group:

@main.command()<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.pass_obj<EOL>def populate(manager: AbstractManager, reset, force):<EOL><INDENT>"""<STR_LIT>"""<EOL>if reset:<EOL><INDENT>click.echo('<STR_LIT>')<EOL>manager.drop_all()<EOL>click.echo('<STR_LIT>')<EOL>manager.create_all()<EOL><DEDENT>if manager.is_populated() and not force:<EOL><INDENT>click.echo('<STR_LIT>')<EOL>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>manager.populate()<EOL><DEDENT>return main<EOL>

Add a ``populate`` command to main :mod:`click` function.


def add_cli_drop(main: click.Group) -> click.Group:

@main.command()<EOL>@click.confirmation_option(prompt='<STR_LIT>')<EOL>@click.pass_obj<EOL>def drop(manager):<EOL><INDENT>"""<STR_LIT>"""<EOL>manager.drop_all()<EOL><DEDENT>return main<EOL>

Add a ``drop`` command to main :mod:`click` function.


def add_cli_cache(main: click.Group) -> click.Group:

@main.group()<EOL>def cache():<EOL><INDENT>"""<STR_LIT>"""<EOL><DEDENT>@cache.command()<EOL>@click.pass_obj<EOL>def locate(manager):<EOL><INDENT>"""<STR_LIT>"""<EOL>data_dir = get_data_dir(manager.module_name)<EOL>click.echo(data_dir)<EOL><DEDENT>@cache.command()<EOL>@click.pass_obj<EOL>def ls(manager):<EOL><INDENT>"""<STR_LIT>"""<EOL>data_dir = get_data_dir(manager.module_name)<EOL>for path in os.listdir(data_dir):<EOL><INDENT>click.echo(path)<EOL><DEDENT><DEDENT>@cache.command()<EOL>@click.pass_obj<EOL>def clear(manager):<EOL><INDENT>"""<STR_LIT>"""<EOL>clear_cache(manager.module_name)<EOL><DEDENT>return main<EOL>

Add several commands to main :mod:`click` function for handling the cache.


def add_cli_summarize(main: click.Group) -> click.Group:

@main.command()<EOL>@click.pass_obj<EOL>def summarize(manager: AbstractManager):<EOL><INDENT>"""<STR_LIT>"""<EOL>if not manager.is_populated():<EOL><INDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>for name, count in sorted(manager.summarize().items()):<EOL><INDENT>click.echo(f'<STR_LIT>')<EOL><DEDENT><DEDENT>return main<EOL>

Add a ``summarize`` command to main :mod:`click` function.


@property<EOL><INDENT>@abstractmethod<EOL>def _base(self) -> DeclarativeMeta:<DEDENT>

Return the declarative base.

        It is usually sufficient to return an instance that is module-level.

        How to build an instance of :class:`sqlalchemy.ext.declarative.api.DeclarativeMeta` by using
        :func:`sqlalchemy.ext.declarative.declarative_base`:

        >>> from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base
        >>> Base: DeclarativeMeta = declarative_base()

        Then just override this abstract property like:

        >>> @property
        >>> def _base(self) -> DeclarativeMeta:
        >>>     return Base

        Note that this property could effectively also be a static method.


@abstractmethod<EOL><INDENT>def is_populated(self) -> bool:<DEDENT>

Check if the database is already populated.


@abstractmethod<EOL><INDENT>def populate(self, *args, **kwargs) -> None:<DEDENT>


@abstractmethod<EOL><INDENT>def summarize(self) -> Mapping[str, int]:<DEDENT>


return self._base.metadata<EOL>

Return the metadata object associated with this manager's declarative base.


def create_all(self, check_first: bool = True):

self._metadata.create_all(self.engine, checkfirst=check_first)<EOL>

Create the empty database (tables).

        :param bool check_first: Defaults to True, don't issue CREATEs for tables already present
         in the target database. Defers to :meth:`sqlalchemy.sql.schema.MetaData.create_all`


def drop_all(self, check_first: bool = True):

self._metadata.drop_all(self.engine, checkfirst=check_first)<EOL>self._store_drop()<EOL>

Drop all tables from the database.

        :param bool check_first: Defaults to True, only issue DROPs for tables confirmed to be
          present in the target database. Defers to :meth:`sqlalchemy.sql.schema.MetaData.drop_all`


return self.session.query(model)<EOL>

Get a query for the given model using this manager's session.

        :param model: A SQLAlchemy model class
        :return: a SQLAlchemy query


return self._get_query(model).count()<EOL>

Count the number of the given model in the database.

        :param model: A SQLAlchemy model class


return self._get_query(model).all()<EOL>

Get all instances of the given model in the database.

        :param model: A SQLAlchemy model class


@staticmethod<EOL><INDENT>def _cli_add_populate(main: click.Group) -> click.Group:<DEDENT>

return add_cli_populate(main)<EOL>


@staticmethod<EOL><INDENT>def _cli_add_drop(main: click.Group) -> click.Group:<DEDENT>

return add_cli_drop(main)<EOL>


@staticmethod<EOL><INDENT>def _cli_add_cache(main: click.Group) -> click.Group:<DEDENT>

return add_cli_cache(main)<EOL>


@staticmethod<EOL><INDENT>def _cli_add_summarize(main: click.Group) -> click.Group:<DEDENT>

return add_cli_summarize(main)<EOL>


@classmethod<EOL><INDENT>def get_cli(cls) -> click.Group:<DEDENT>

main = super().get_cli()<EOL>cls._cli_add_populate(main)<EOL>cls._cli_add_drop(main)<EOL>cls._cli_add_cache(main)<EOL>cls._cli_add_summarize(main)<EOL>return main<EOL>

Get the :mod:`click` main function to use as a command line interface.


for idx, name, manager_cls in _iterate_manage_classes(skip):<EOL><INDENT>if name in skip:<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>manager = manager_cls(connection=connection)<EOL><DEDENT>except TypeError as e:<EOL><INDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>yield idx, name, manager<EOL><DEDENT><DEDENT>


@main.command()<EOL>@connection_option<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, help='<STR_LIT>')<EOL>def populate(connection, reset, force, skip):

for idx, name, manager in _iterate_managers(connection, skip):<EOL><INDENT>click.echo(<EOL>click.style(f'<STR_LIT>', fg='<STR_LIT>', bold=True) +<EOL>click.style(f'<STR_LIT>', fg='<STR_LIT>', bold=True)<EOL>)<EOL>if reset:<EOL><INDENT>click.echo('<STR_LIT>')<EOL>manager.drop_all()<EOL>click.echo('<STR_LIT>')<EOL>manager.create_all()<EOL><DEDENT>elif manager.is_populated() and not force:<EOL><INDENT>click.echo(f'<STR_LIT>', color='<STR_LIT>')<EOL>continue<EOL><DEDENT>try:<EOL><INDENT>manager.populate()<EOL><DEDENT>except Exception:<EOL><INDENT>logger.exception('<STR_LIT>', name)<EOL>click.secho(f'<STR_LIT>', fg='<STR_LIT>', bold=True)<EOL><DEDENT><DEDENT>


for idx, name, manager in _iterate_managers(connection, skip):<EOL><INDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>', bold=True)<EOL>manager.drop_all()<EOL><DEDENT>


@cache.command()<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, help='<STR_LIT>')<EOL>def clear(skip):

for name in sorted(MODULES):<EOL><INDENT>if name in skip:<EOL><INDENT>continue<EOL><DEDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>', bold=True)<EOL>clear_cache(name)<EOL><DEDENT>


@main.command()<EOL>@connection_option<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, help='<STR_LIT>')<EOL>def summarize(connection, skip):

for idx, name, manager in _iterate_managers(connection, skip):<EOL><INDENT>click.secho(name, fg='<STR_LIT>', bold=True)<EOL>if not manager.is_populated():<EOL><INDENT>click.echo('<STR_LIT>')<EOL>continue<EOL><DEDENT>if isinstance(manager, BELNamespaceManagerMixin):<EOL><INDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>')<EOL><DEDENT>if isinstance(manager, BELManagerMixin):<EOL><INDENT>try:<EOL><INDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>')<EOL><DEDENT>except TypeError as e:<EOL><INDENT>click.secho(str(e), fg='<STR_LIT>')<EOL><DEDENT><DEDENT>for field_name, count in sorted(manager.summarize().items()):<EOL><INDENT>click.echo(<EOL>click.style('<STR_LIT>', fg='<STR_LIT>', bold=True) + f"<STR_LIT>"<EOL>)<EOL><DEDENT><DEDENT>


@main.command()<EOL>@connection_option<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=click.File('<STR_LIT:w>'), default=sys.stdout)<EOL>def sheet(connection, skip, file: TextIO):

from tabulate import tabulate<EOL>header = ['<STR_LIT>', '<STR_LIT:Name>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>rows = []<EOL>for i, (idx, name, manager) in enumerate(_iterate_managers(connection, skip), start=<NUM_LIT:1>):<EOL><INDENT>try:<EOL><INDENT>if not manager.is_populated():<EOL><INDENT>continue<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>')<EOL>continue<EOL><DEDENT>terms, relations = None, None<EOL>if isinstance(manager, BELNamespaceManagerMixin):<EOL><INDENT>terms = manager._count_model(manager.namespace_model)<EOL><DEDENT>if isinstance(manager, BELManagerMixin):<EOL><INDENT>try:<EOL><INDENT>relations = manager.count_relations()<EOL><DEDENT>except TypeError as e:<EOL><INDENT>relations = str(e)<EOL><DEDENT><DEDENT>rows.append((i, name, manager.__doc__.split('<STR_LIT:\n>')[<NUM_LIT:0>].strip().strip('<STR_LIT:.>'), terms, relations))<EOL><DEDENT>print(tabulate(<EOL>rows,<EOL>headers=header,<EOL>))<EOL>


@belns.command()<EOL>@connection_option<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=click.Path(file_okay=False, dir_okay=True), default=os.getcwd(),<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>def write(connection, skip, directory, force):

os.makedirs(directory, exist_ok=True)<EOL>from .manager.namespace_manager import BELNamespaceManagerMixin<EOL>for idx, name, manager in _iterate_managers(connection, skip):<EOL><INDENT>if not (isinstance(manager, AbstractManager) and isinstance(manager, BELNamespaceManagerMixin)):<EOL><INDENT>continue<EOL><DEDENT>click.secho(name, fg='<STR_LIT>', bold=True)<EOL>if force:<EOL><INDENT>try:<EOL><INDENT>click.echo(f'<STR_LIT>')<EOL>manager.drop_all()<EOL>click.echo('<STR_LIT>')<EOL>clear_cache(name)<EOL>click.echo('<STR_LIT>')<EOL>manager.populate()<EOL><DEDENT>except Exception:<EOL><INDENT>click.secho(f'<STR_LIT>', fg='<STR_LIT>')<EOL>continue<EOL><DEDENT><DEDENT>try:<EOL><INDENT>r = manager.write_directory(directory)<EOL><DEDENT>except TypeError as e:<EOL><INDENT>click.secho(f'<STR_LIT>'.rstrip(), fg='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if not r:<EOL><INDENT>click.echo('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>

Write a BEL namespace names/identifiers to terminology store.


@bel.command()  <EOL>@connection_option<EOL>@click.option('<STR_LIT>', '<STR_LIT>', multiple=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=click.Path(file_okay=False, dir_okay=True), default=os.getcwd(),<EOL>help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>def write(connection, skip, directory, force):

os.makedirs(directory, exist_ok=True)<EOL>from .manager.bel_manager import BELManagerMixin<EOL>import pybel<EOL>for idx, name, manager in _iterate_managers(connection, skip):<EOL><INDENT>if not isinstance(manager, BELManagerMixin):<EOL><INDENT>continue<EOL><DEDENT>click.secho(name, fg='<STR_LIT>', bold=True)<EOL>path = os.path.join(directory, f'<STR_LIT>')<EOL>if os.path.exists(path) and not force:<EOL><INDENT>click.echo('<STR_LIT>')<EOL>continue<EOL><DEDENT>if not manager.is_populated():<EOL><INDENT>click.echo('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>graph = manager.to_bel()<EOL>pybel.to_pickle(graph, path)<EOL>pybel.to_json_path(graph, os.path.join(directory, f'<STR_LIT>'))<EOL><DEDENT><DEDENT>


@main.command()<EOL>@connection_option<EOL>@click.option('<STR_LIT>', default='<STR_LIT>')<EOL>@click.option('<STR_LIT>', type=int, default=<NUM_LIT>)<EOL>def web(connection, host, port):

from bio2bel.web.application import create_application<EOL>app = create_application(connection=connection)<EOL>app.run(host=host, port=port)<EOL>


session = _make_session(connection=connection)<EOL>for action in Action.ls(session=session):<EOL><INDENT>click.echo(f'<STR_LIT>')<EOL><DEDENT>


return config.connection<EOL>


self.group = group<EOL>

Initialize the importer with the group name.

        :param str group: a string representing the package resources entry_points group that will be used


Call this method to install the new importer to :code:`sys.meta_path`. Should probably only be done once.


def find_module(self, fullname, path=None):

if not fullname.startswith(self._group_with_dot):<EOL><INDENT>return<EOL><DEDENT>end_name = fullname[len(self._group_with_dot):]<EOL>for entry_point in iter_entry_points(group=self.group, name=None):<EOL><INDENT>if entry_point.name == end_name:<EOL><INDENT>return self<EOL><DEDENT><DEDENT>

Find a module if its name starts with :code:`self.group` and is registered.


if fullname in sys.modules:<EOL><INDENT>return sys.modules[fullname]<EOL><DEDENT>end_name = fullname[len(self._group_with_dot):]<EOL>for entry_point in iter_entry_points(group=self.group, name=end_name):<EOL><INDENT>mod = entry_point.load()<EOL>sys.modules[fullname] = mod<EOL>return mod<EOL><DEDENT>

Load a module if its name starts with :code:`self.group` and is registered.


def make_obo_getter(data_url: str,<EOL>data_path: str,<EOL>*,<EOL>preparsed_path: Optional[str] = None,<EOL>) -> Callable[[Optional[str], bool, bool], MultiDiGraph]:

download_function = make_downloader(data_url, data_path)<EOL>def get_obo(url: Optional[str] = None, cache: bool = True, force_download: bool = False) -> MultiDiGraph:<EOL><INDENT>"""<STR_LIT>"""<EOL>if preparsed_path is not None and os.path.exists(preparsed_path):<EOL><INDENT>return read_gpickle(preparsed_path)<EOL><DEDENT>if url is None and cache:<EOL><INDENT>url = download_function(force_download=force_download)<EOL><DEDENT>result = obonet.read_obo(url)<EOL>if preparsed_path is not None:<EOL><INDENT>write_gpickle(result, preparsed_path)<EOL><DEDENT>return result<EOL><DEDENT>return get_obo<EOL>

Build a function that handles downloading OBO data and parsing it into a NetworkX object.

    :param data_url: The URL of the data
    :param data_path: The path where the data should get stored
    :param preparsed_path: The optional path to cache a pre-parsed json version


@main.command()<EOL>@click.argument('<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=click.File('<STR_LIT:w>'))<EOL>@click.option('<STR_LIT>', '<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', is_flag=True)<EOL>def belns(keyword: str, file: TextIO, encoding: Optional[str], use_names: bool):

directory = get_data_dir(keyword)<EOL>obo_url = f'<STR_LIT>'<EOL>obo_path = os.path.join(directory, f'<STR_LIT>')<EOL>obo_cache_path = os.path.join(directory, f'<STR_LIT>')<EOL>obo_getter = make_obo_getter(obo_url, obo_path, preparsed_path=obo_cache_path)<EOL>graph = obo_getter()<EOL>convert_obo_graph_to_belns(<EOL>graph,<EOL>file=file,<EOL>encoding=encoding,<EOL>use_names=use_names,<EOL>)<EOL>


@main.command()<EOL>@click.argument('<STR_LIT>')<EOL>@click.option('<STR_LIT>', '<STR_LIT>', type=click.File('<STR_LIT:w>'))<EOL>def belanno(keyword: str, file: TextIO):

directory = get_data_dir(keyword)<EOL>obo_url = f'<STR_LIT>'<EOL>obo_path = os.path.join(directory, f'<STR_LIT>')<EOL>obo_cache_path = os.path.join(directory, f'<STR_LIT>')<EOL>obo_getter = make_obo_getter(obo_url, obo_path, preparsed_path=obo_cache_path)<EOL>graph = obo_getter()<EOL>convert_obo_graph_to_belanno(<EOL>graph,<EOL>file=file,<EOL>)<EOL>


def make_temporary_cache_class_mixin(manager_cls: Type[AbstractManager]) -> Type[<EOL>AbstractTemporaryCacheClassMixin]:

class TemporaryCacheClassMixin(AbstractTemporaryCacheClassMixin):<EOL><INDENT>Manager = manager_cls<EOL><DEDENT>return TemporaryCacheClassMixin<EOL>

Build a testing class that has a Bio2BEL manager instance ready to go.


super().setUp()<EOL>self.fd, self.path = tempfile.mkstemp()<EOL>self.connection = '<STR_LIT>' + self.path<EOL>log.info('<STR_LIT>', self.connection)<EOL>

Create a temporary file to use as a persistent database throughout tests in this class.


os.close(self.fd)<EOL>os.remove(self.path)<EOL>

Close the connection to the database and removes the files created for it.


super().setUpClass()<EOL>cls.fd, cls.path = tempfile.mkstemp()<EOL>cls.connection = '<STR_LIT>' + cls.path<EOL>log.info('<STR_LIT>', cls.connection)<EOL>

Create a temporary file to use as a persistent database throughout tests in this class.

        Subclasses of :class:`TemporaryCacheClsMixin` can extend :func:`TemporaryCacheClsMixin.setUpClass` to populate
        the database.


os.close(cls.fd)<EOL>os.remove(cls.path)<EOL>


super().setUp()<EOL>def mock_connection() -> str:<EOL><INDENT>"""<STR_LIT>"""<EOL>return self.connection<EOL><DEDENT>self.mock_global_connection = mock.patch('<STR_LIT>', mock_connection)<EOL>self.mock_module_connection = mock.patch('<STR_LIT>', mock_connection)<EOL>

Set up the test with a mock connection string.

        Add two class-level variables: ``mock_global_connection`` and ``mock_module_connection`` that can be
        used as context managers to mock the bio2bel connection getter functions.


if self.Manager is ...:<EOL><INDENT>raise Bio2BELTestMissingManagerError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if not issubclass(self.Manager, AbstractManager):<EOL><INDENT>raise Bio2BELManagerTypeError('<STR_LIT>')<EOL><DEDENT>super().setUp()<EOL>self.manager = self.Manager(connection=self.connection)<EOL>self.populate()<EOL>

Set up the class with the given manager and allows an optional populate hook to be overridden.


self.manager.session.close()<EOL>super().tearDown()<EOL>

Close the connection in the manager and deletes the temporary database.


Populate the database.

        This stub should be overridden.


if cls.Manager is ...:<EOL><INDENT>raise Bio2BELTestMissingManagerError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>if not issubclass(cls.Manager, AbstractManager):<EOL><INDENT>raise Bio2BELManagerTypeError('<STR_LIT>')<EOL><DEDENT>super().setUpClass()<EOL>cls.manager = cls.Manager(connection=cls.connection)<EOL>cls.populate()<EOL>


cls.manager.session.close()<EOL>super().tearDownClass()<EOL>


def get_data_dir(module_name: str) -> str:

module_name = module_name.lower()<EOL>data_dir = os.path.join(BIO2BEL_DIR, module_name)<EOL>os.makedirs(data_dir, exist_ok=True)<EOL>return data_dir<EOL>

Ensure the appropriate Bio2BEL data directory exists for the given module, then returns the file path.

    :param module_name: The name of the module. Ex: 'chembl'
    :return: The module's data directory


def get_module_config_cls(module_name: str) -> Type[_AbstractModuleConfig]:

class ModuleConfig(_AbstractModuleConfig):<EOL><INDENT>NAME = f'<STR_LIT>'<EOL>FILES = DEFAULT_CONFIG_PATHS + [<EOL>os.path.join(DEFAULT_CONFIG_DIRECTORY, module_name, '<STR_LIT>')<EOL>]<EOL><DEDENT>return ModuleConfig<EOL>


def get_connection(module_name: str, connection: Optional[str] = None) -> str:

<EOL>if connection is not None:<EOL><INDENT>return connection<EOL><DEDENT>module_name = module_name.lower()<EOL>module_config_cls = get_module_config_cls(module_name)<EOL>module_config = module_config_cls.load()<EOL>return module_config.connection or config.connection<EOL>

Return the SQLAlchemy connection string if it is set.

    Order of operations:

    1. Return the connection if given as a parameter
    2. Check the environment for BIO2BEL_{module_name}_CONNECTION
    3. Look in the bio2bel config file for module-specific connection. Create if doesn't exist. Check the
       module-specific section for ``connection``
    4. Look in the bio2bel module folder for a config file. Don't create if doesn't exist. Check the default section
       for ``connection``
    5. Check the environment for BIO2BEL_CONNECTION
    6. Check the bio2bel config file for default
    7. Fall back to standard default cache connection

    :param module_name: The name of the module to get the configuration for
    :param connection: get the SQLAlchemy connection string
    :return: The SQLAlchemy connection string based on the configuration


return VERSION<EOL>


modules = {}<EOL>for entry_point in iter_entry_points(group='<STR_LIT>', name=None):<EOL><INDENT>entry = entry_point.name<EOL>try:<EOL><INDENT>modules[entry] = entry_point.load()<EOL><DEDENT>except VersionConflict as exc:<EOL><INDENT>log.warning('<STR_LIT>', entry, exc)<EOL>continue<EOL><DEDENT>except UnknownExtra as exc:<EOL><INDENT>log.warning('<STR_LIT>', entry, exc)<EOL>continue<EOL><DEDENT>except ImportError as exc:<EOL><INDENT>log.exception('<STR_LIT>', entry, exc)<EOL>continue<EOL><DEDENT><DEDENT>return modules<EOL>


def clear_cache(module_name: str, keep_database: bool = True) -> None:

data_dir = get_data_dir(module_name)<EOL>if not os.path.exists(data_dir):<EOL><INDENT>return<EOL><DEDENT>for name in os.listdir(data_dir):<EOL><INDENT>if name in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>continue<EOL><DEDENT>if name == '<STR_LIT>' and keep_database:<EOL><INDENT>continue<EOL><DEDENT>path = os.path.join(data_dir, name)<EOL>if os.path.isdir(path):<EOL><INDENT>shutil.rmtree(path)<EOL><DEDENT>else:<EOL><INDENT>os.remove(path)<EOL><DEDENT>os.rmdir(data_dir)<EOL><DEDENT>


def _store_helper(model: Action, session: Optional[Session] = None) -> None:

if session is None:<EOL><INDENT>session = _make_session()<EOL><DEDENT>session.add(model)<EOL>session.commit()<EOL>session.close()<EOL>


def _make_session(connection: Optional[str] = None) -> Session:

if connection is None:<EOL><INDENT>connection = get_global_connection()<EOL><DEDENT>engine = create_engine(connection)<EOL>create_all(engine)<EOL>session_cls = sessionmaker(bind=engine)<EOL>session = session_cls()<EOL>return session<EOL>


Base.metadata.create_all(bind=engine, checkfirst=checkfirst)<EOL>


@staticmethod<EOL><INDENT>def make_populate(resource: str) -> '<STR_LIT>':<DEDENT>

return Action(resource=resource.lower(), action='<STR_LIT>')<EOL>

Make a ``populate`` instance of :class:`Action`.


@staticmethod<EOL><INDENT>def make_populate_failed(resource: str) -> '<STR_LIT>':<DEDENT>

Make a ``populate_failed`` instance of :class:`Action`.


@staticmethod<EOL><INDENT>def make_drop(resource: str) -> '<STR_LIT>':<DEDENT>

Make a ``drop`` instance of :class:`Action`.


@classmethod<EOL><INDENT>def store_populate(cls, resource: str, session: Optional[Session] = None) -> '<STR_LIT>':<DEDENT>

action = cls.make_populate(resource)<EOL>_store_helper(action, session=session)<EOL>return action<EOL>

Store a "populate" event.

        :param resource: The normalized name of the resource to store

        Example:

        >>> from bio2bel.models import Action
        >>> Action.store_populate('hgnc')


@classmethod<EOL><INDENT>def store_populate_failed(cls, resource: str, session: Optional[Session] = None) -> '<STR_LIT>':<DEDENT>

action = cls.make_populate_failed(resource)<EOL>_store_helper(action, session=session)<EOL>return action<EOL>

Store a "populate failed" event.

        :param resource: The normalized name of the resource to store

        Example:

        >>> from bio2bel.models import Action
        >>> Action.store_populate_failed('hgnc')


@classmethod<EOL><INDENT>def store_drop(cls, resource: str, session: Optional[Session] = None) -> '<STR_LIT>':<DEDENT>

action = cls.make_drop(resource)<EOL>_store_helper(action, session=session)<EOL>return action<EOL>

Store a "drop" event.

        :param resource: The normalized name of the resource to store

        Example:

        >>> from bio2bel.models import Action
        >>> Action.store_drop('hgnc')


@classmethod<EOL><INDENT>def ls(cls, session: Optional[Session] = None) -> List['<STR_LIT>']:<DEDENT>

if session is None:<EOL><INDENT>session = _make_session()<EOL><DEDENT>actions = session.query(cls).order_by(cls.created.desc()).all()<EOL>session.close()<EOL>return actions<EOL>


@classmethod<EOL><INDENT>def count(cls, session: Optional[Session] = None) -> int:<DEDENT>

if session is None:<EOL><INDENT>session = _make_session()<EOL><DEDENT>count = session.query(cls).count()<EOL>session.close()<EOL>return count<EOL>


return render_template('<STR_LIT>', entries=sorted(add_admins))<EOL>


def create_application(connection: Optional[str] = None) -> Flask:

app = Flask(__name__)<EOL>flask_bootstrap.Bootstrap(app)<EOL>Admin(app)<EOL>connection = connection or DEFAULT_CACHE_CONNECTION<EOL>engine, session = build_engine_session(connection)<EOL>for name, add_admin in add_admins.items():<EOL><INDENT>url = '<STR_LIT>'.format(name)<EOL>add_admin(app, session, url=url, endpoint=name, name=name)<EOL>log.debug('<STR_LIT>', name, add_admin, url)<EOL><DEDENT>app.register_blueprint(ui)<EOL>return app<EOL>


with codecs.open(os.path.join(HERE, *parts), '<STR_LIT:rb>', '<STR_LIT:utf-8>') as f:<EOL><INDENT>return f.read()<EOL><DEDENT>

Build an absolute path from *parts* and return the contents of the resulting file. Assume UTF-8 encoding.


meta_match = re.search(<EOL>r'<STR_LIT>'.format(meta=meta),<EOL>META_FILE, re.M<EOL>)<EOL>if meta_match:<EOL><INDENT>return meta_match.group(<NUM_LIT:1>)<EOL><DEDENT>raise RuntimeError('<STR_LIT>'.format(meta=meta))<EOL>


with codecs.open(os.path.join(HERE, '<STR_LIT>'), encoding='<STR_LIT:utf-8>') as f:<EOL><INDENT>long_description = f.read()<EOL><DEDENT>return long_description<EOL>

Get the long_description from the README.rst file. Assume UTF-8 encoding.


args = list(args)<EOL>lngth = args.__len__()<EOL>if(lngth==<NUM_LIT:0>):<EOL><INDENT>diff_funcs_arr = kwargs['<STR_LIT>']<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL><DEDENT>elif(lngth==<NUM_LIT:1>):<EOL><INDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>diff_funcs_arr = args[<NUM_LIT:0>]<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>diff_funcs_arr = kwargs['<STR_LIT>']<EOL>diff_args_arr = args[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>diff_funcs_arr = args[<NUM_LIT:0>]<EOL>diff_args_arr = args[<NUM_LIT:1>]<EOL><DEDENT>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = diff_args_arr[i]<EOL>ele = func(index,value,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapfivo          f,i,v,o四元决定                     fivo-4-tuple-engine
#map_func         diff_func(index,value,*diff_args)


lngth = ol.__len__()<EOL>diff_funcs_arr = kwargs['<STR_LIT>']<EOL>common_args_arr = init(lngth,map_func_args)<EOL>rslt = mapfivo(ol,map_funcs=diff_funcs_arr,map_func_args_array=common_args_arr)<EOL>return(rslt)<EOL>

#mapfiv           共享相同的o                         share common other_args
#map_func         diff_func(index,value,*common_args)


diff_funcs_arr = kwargs['<STR_LIT>']<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = diff_args_arr[i]<EOL>ele = func(index,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapfio           v不作为map_func参数                 NOT take value as a param for map_func
#map_func         diff_func(index,*diff_args)


diff_funcs_arr = kwargs['<STR_LIT>']<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = diff_args_arr[i]<EOL>ele = func(value,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapfvo           i不作为map_func参数                 NOT take index as a param for map_func
#map_func         diff_func(value,*diff_args)


lngth = ol.__len__()<EOL>common_funcs_arr = init(lngth,map_func)<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL>rslt = mapfivo(ol,map_funcs=common_funcs_arr,map_func_args_array=diff_args_arr)<EOL>return(rslt)<EOL>

#mapivo           共享相同的f                         share common map_func
#map_func         common_func(index,value,*diff_args)


def get_self(obj):<EOL><INDENT>return(obj)<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>index_map_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>index_map_func_args = []<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>value_map_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>value_map_func_args = []<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>index_map_func = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>index_map_func = get_self<EOL><DEDENT>length = ol.__len__()<EOL>il = list(range(<NUM_LIT:0>,length))<EOL>nil = list(map(lambda ele:index_map_func(ele,*index_map_func_args),il))<EOL>nvl = []<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>ele = ol[i]<EOL>v = value_map_func(nil[i],ele,*value_map_func_args)<EOL>nvl.append(v)<EOL><DEDENT>return(nvl)<EOL>

from elist.elist import *
ol = ['a','b','c','d']
def index_map_func(index,prefix,suffix):
    s = prefix +str(index+97)+ suffix
    return(s)

def value_map_func(mapped_index,ele,prefix,suffix):
    s = prefix+mapped_index+': ' + str(ele) + suffix
    return(s)

####
rslt = array_dualmap2(ol,index_map_func=index_map_func,index_map_func_args=[': ',' is '],value_map_func=value_map_func,value_map_func_args=['ord',' yes?'])
pobj(rslt)


def get_self(obj,*args):<EOL><INDENT>return(obj)<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>value_map_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>value_map_func_args = []<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>index_map_func = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>index_map_func = get_self<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>index_map_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>index_map_func_args = []<EOL><DEDENT>length = ol.__len__()<EOL>il = list(range(<NUM_LIT:0>,length))<EOL>nil = list(map(lambda ele:index_map_func(ele,*index_map_func_args),il))<EOL>refls = list(refls)<EOL>refls = prepend(refls,nil)<EOL>nvl = array_map2(*refls,map_func = value_map_func,map_func_args=value_map_func_args)<EOL>return(nvl)<EOL>

from elist.elist import *
ol = [1,2,3,4]
refl1 = ['+','+','+','+']
refl2 = [7,7,7,7]
refl3 = ['=','=','=','=']
def index_map_func(index):
    s ="<"+str(index)+">"
    return(s)

def value_map_func(mapped_index,ele,ref_ele1,ref_ele2,ref_ele3,prefix,suffix):
    s = prefix+mapped_index+': ' + str(ele) + str(ref_ele1) + str(ref_ele2) + str(ref_ele3) + suffix
    return(s)

####
rslt = array_dualmap2(ol,refl1,refl2,refl3,index_map_func=index_map_func,value_map_func=value_map_func,value_map_func_args=['Q','?'])
pobj(rslt)


diff_funcs_arr = kwargs['<STR_LIT>']<EOL>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = map_func_args<EOL>ele = func(index,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapfi            共享相同的o,v不作为map_func参数
#                 share common other_args,NOT take value as a param for map_func
#map_func         diff_func(index,*common_args)


args = list(args)<EOL>lngth = args.__len__()<EOL>if(lngth == <NUM_LIT:0>):<EOL><INDENT>diff_funcs_arr = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>diff_funcs_arr = args[<NUM_LIT:0>]<EOL><DEDENT>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = map_func_args<EOL>ele = func(value,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapfv            共享相同的o,i不作为map_func参数
#                 share common other_args,NOT take value as a param for map_func
#map_func         diff_func(value,*common_args)


diff_args_arr = kwargs['<STR_LIT>']<EOL>diff_funcs_arr = kwargs['<STR_LIT>']<EOL>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = diff_args_arr[i]<EOL>ele = func(value,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapfo            i不作为map_func参数,v不作为map_func参数
#                 NOT take value as a param for map_func,NOT take index as a param for map_func
#map_func         diff_func(*diff_args)


lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = map_func<EOL>args = map_func_args<EOL>ele = func(index,value,*args)<EOL>rslt.append(ele)    <EOL><DEDENT>return(rslt)<EOL>

#mapiv            共享相同的o,共享相同的f              share common map_func,share common other_args
#map_func         common_func(index,value,*common_args)


args = list(args)<EOL>if(args.__len__() > <NUM_LIT:0>):<EOL><INDENT>map_func_args = args<EOL><DEDENT>else:<EOL><INDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>map_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>map_func_args = []<EOL><DEDENT><DEDENT>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>ele = map_func(i,ol[i],*map_func_args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = ['a','b','c','d']
#1
def map_func(index,value,*others):
    return(value * index + others[0] +others[-1])
mapiv(ol,map_func,'tailA-','tailB')
#2
mapiv2(ol,lambda index,value,other:(value*index+other),['-'])
mapiv2(ol,lambda index,value,other:(value*index+other),'-')
mapiv2(ol,lambda index,value:(value*index))


lngth = ol.__len__()<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = map_func<EOL>args = diff_args_arr[i]<EOL>ele = func(index,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapvo    共享相同的f,i不作为map_func参数
#         share common map_func,NOT take index as a param for map_func
#         common_func(value,*priv_args)


lngth = ol.__len__()<EOL>args = list(args)<EOL>if(args.__len__()==<NUM_LIT:0>):<EOL><INDENT>diff_args_arr = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>diff_args_arr = args[<NUM_LIT:0>]<EOL><DEDENT>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = map_func<EOL>args = diff_args_arr[i]<EOL>ele = func(value,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>


map_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>map_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>map_func_args = []<EOL><DEDENT>length = referls.__len__()<EOL>rslt = []<EOL>anum = list(referls)[<NUM_LIT:0>].__len__()<EOL>for j in range(<NUM_LIT:0>,anum):<EOL><INDENT>args = []<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>refl = referls[i]<EOL>args.append(refl[j])<EOL><DEDENT>args.extend(map_func_args)<EOL>v = map_func(*args)<EOL>rslt.append(v)<EOL><DEDENT>return(rslt)<EOL>

obseleted just for compatible
from elist.elist import *
ol = [1,2,3,4]
refl1 = ['+','+','+','+']
refl2 = [7,7,7,7]
refl3 = ['=','=','=','=']
def map_func(ele,ref_ele1,ref_ele2,ref_ele3,prefix,suffix):
    s = prefix+': ' + str(ele) + str(ref_ele1) + str(ref_ele2) + str(ref_ele3) + suffix
    return(s)

####
rslt = array_map2(ol,refl1,refl2,refl3,map_func=map_func,map_func_args=['Q','?'])
pobj(rslt)


diff_funcs_arr = kwargs['<STR_LIT>']<EOL>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = map_func_args<EOL>ele = func(*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapf     i不作为map_func参数,v不作为map_func参数,共享相同的o
#         NOT take value as a param for map_func
#         NOT take index as a param for map_func
#         share common other_args
#         diff_func(*common_args)


lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = map_func<EOL>args = map_func_args<EOL>ele = func(index,*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapi     v不作为map_func参数,共享相同的f,共享相同的o
#         NOT take value as a param for map_func
#         share common other_args
#         share common map_func
#         common_func(index,*common_args)


rslt = list(map(lambda ele:map_func(ele,*map_func_args),ol))<EOL>return(rslt)<EOL>

#mapv     i不作为map_func参数,共享相同的f,共享相同的o
#         NOT take index as a param for map_func
#         share common other_args
#         share common map_func
#         common_func(value,*common_args)


rslt = list(map(lambda ele:map_func(ele,*args),ol))<EOL>return(rslt)<EOL>

obseleted,just for compatible
from elist.elist import *
ol = [1,2,3,4]
def map_func(ele,mul,plus):
    return(ele*mul+plus)

array_map(ol,map_func,2,100)


params = list(params)<EOL>if(params.__len__()==<NUM_LIT:0>):<EOL><INDENT>diff_args_arr = kwargs['<STR_LIT>']<EOL><DEDENT>elif(isinstance(params[<NUM_LIT:0>],list)):<EOL><INDENT>diff_args_arr = params[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>diff_args_arr = params<EOL><DEDENT>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = map_func<EOL>args = diff_args_arr[i]<EOL>ele = func(*args)<EOL>rslt.append(ele)<EOL><DEDENT>return(rslt)<EOL>

#mapo     i不作为map_func参数,v不作为map_func参数,共享相同的f
#         NOT take index as a param for map_func
#         NOT take value as a param for map_func
#         share common map_func
#         common_func(*priv_args)


args = list(args)<EOL>lngth = args.__len__()<EOL>if(lngth==<NUM_LIT:0>):<EOL><INDENT>diff_funcs_arr = kwargs['<STR_LIT>']<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL><DEDENT>elif(lngth==<NUM_LIT:1>):<EOL><INDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>diff_funcs_arr = args[<NUM_LIT:0>]<EOL>diff_args_arr = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>diff_funcs_arr = kwargs['<STR_LIT>']<EOL>diff_args_arr = args[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>diff_funcs_arr = args[<NUM_LIT:0>]<EOL>diff_args_arr = args[<NUM_LIT:1>]<EOL><DEDENT>lngth = ol.__len__()<EOL>rslt = []<EOL>for i in range(<NUM_LIT:0>,lngth):<EOL><INDENT>index = i<EOL>value = ol[i]<EOL>func = diff_funcs_arr[i]<EOL>args = diff_args_arr[i]<EOL>cond = func(index,value,*args)<EOL>if(cond):<EOL><INDENT>rslt.append((index,value))<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(rslt)<EOL>

#findfivo          f,i,v,o四元决定                     fivo-4-tuple-engine
#cond_func         diff_func(index,value,*diff_args)


lngth = ol.__len__()<EOL>diff_funcs_arr = kwargs['<STR_LIT>']<EOL>common_args_arr = init(lngth,map_func_args)<EOL>rslt = findfivo(ol,cond_funcs=diff_funcs_arr,cond_func_args_array=common_args_arr)<EOL>return(rslt)<EOL>

#findfiv           共享相同的o                         share common other_args
#cond_func         diff_func(index,value,*common_args)


rslt = []<EOL>for i in range(ol.__len__()):<EOL><INDENT>cond = cond_func(ol[i],*cond_func_args)<EOL>if(cond):<EOL><INDENT>rslt.append((i,ol[i]))<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(rslt)<EOL>

#mapv     i不作为map_func参数,共享相同的f,共享相同的o
#         NOT take index as a param for map_func
#         share common other_args
#         share common cond_func
#         common_func(value,*common_args)


cond_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>cond_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>cond_func_args = []<EOL><DEDENT>founded = find_all(ol,cond_func,*cond_func_args)<EOL>rslt = array_map(founded,lambda ele:ele['<STR_LIT:value>'])<EOL>return(rslt)<EOL>

from elist.elist import *
from elist.jprint import pobj
def test_func(ele,x):
    cond = (ele > x)
    return(cond)

ol = [1,2,3,4,5,6,7]
rslt = cond_select_all(ol,cond_func = test_func,cond_func_args = [3])
pobj(rslt)


cond_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>cond_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>cond_func_args = []<EOL><DEDENT>founded = find_all2(ol,cond_func,*cond_func_args)<EOL>rslt = array_map(founded,lambda ele:ele['<STR_LIT:value>'])<EOL>return(rslt)<EOL>

from elist.elist import *
from xdict.jprint import pobj
def test_func(ele,index,x):
    cond1 = (ele > x)
    cond2 = (index %2 == 0)
    cond =(cond1 & cond2)
    return(cond)

ol = [1,2,3,4,5,6,7]
rslt = cond_select_all2(ol,cond_func = test_func,cond_func_args = [3])
pobj(rslt)


cond_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>cond_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>cond_func_args = []<EOL><DEDENT>founded = find_all(ol,cond_func,*cond_func_args)<EOL>rslt = array_map(founded,lambda ele:ele['<STR_LIT:index>'])<EOL>return(rslt)<EOL>

from elist.elist import *
from elist.jprint import pobj
def test_func(ele,x):
    cond = (ele > x)
    return(cond)

ol = [1,2,3,4,5,6,7]
rslt = cond_select_indexes_all(ol,cond_func = test_func, cond_func_args = [3])
pobj(rslt)


cond_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>cond_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>cond_func_args = []<EOL><DEDENT>founded = find_all2(ol,cond_func,*cond_func_args)<EOL>rslt = array_map(founded,lambda ele:ele['<STR_LIT:index>'])<EOL>return(rslt)<EOL>

from elist.elist import *
from xdict.jprint import pobj
def test_func(ele,index,x):
    cond1 = (ele > x)
    cond2 = (index %2 == 0)
    cond =(cond1 & cond2)
    return(cond)

ol = [1,2,3,4,5,6,7]
rslt = cond_select_indexes_all2(ol,cond_func = test_func,cond_func_args = [3])
pobj(rslt)


rslt =copy.deepcopy(ol)<EOL>rslt = itemgetter(*seqs)(ol)<EOL>if(seqs.__len__()==<NUM_LIT:0>):<EOL><INDENT>rslt = []<EOL><DEDENT>elif(seqs.__len__()==<NUM_LIT:1>):<EOL><INDENT>rslt = [rslt]<EOL><DEDENT>else:<EOL><INDENT>rslt = list(rslt)<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = ['a','b','c','d']
select_seqs(ol,[1,2])


seqs = list(seqs)<EOL>return(select_seqs(ol,seqs))<EOL>

from elist.elist import *
ol = ['a','b','c','d']
select_some(ol,1,2)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>new.append(ele)<EOL>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.append(ele)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,2,3,4]
ele = 5
id(ol)
append(ol,ele,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
ele = 5
id(ol)
new = append(ol,ele)
new
id(new)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>return(extend(ol,list(eles),mode=mode))<EOL>

from elist.elist import *
ol = [1,2,3,4]
id(ol)
append_some(ol,5,6,7,8,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
id(ol)
new = append_some(ol,5,6,7,8)
new
id(new)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = [ele]<EOL>cpol = copy.deepcopy(ol)<EOL>new.extend(cpol)<EOL>return(new)<EOL><DEDENT>else:<EOL><INDENT>length = ol.__len__()<EOL>ol.append(None)<EOL>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>ol[i+<NUM_LIT:1>] = ol[i]<EOL><DEDENT>ol[<NUM_LIT:0>] = ele<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,2,3,4]
ele = 5
id(ol)
prepend(ol,ele,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
ele = 5
id(ol)
new = prepend(ol,ele)
new
id(new)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>return(prextend(ol,list(eles),mode=mode))<EOL>

from elist.elist import *
ol = [1,2,3,4]
id(ol)
prepend_some(ol,5,6,7,8,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
id(ol)
new = prepend_some(ol,5,6,7,8)
new
id(new)
#####unshift is the same as prepend_some
>>> unshift(ol,9,10,11,12)
[9, 10, 11, 12, 1, 2, 3, 4]


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>cpnl = copy.deepcopy(nl)<EOL>new.extend(cpnl)<EOL>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.extend(nl)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
extend(ol,nl,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
new = extend(ol,nl)
new
id(new)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>eles = list(eles)<EOL>return(extend(ol,eles,mode=mode))<EOL>

from elist.elist import *
ol=[1,2,3,4]
id(ol)
new = push(ol,5,6,7)
new
id(new)
####
ol=[1,2,3,4]
id(ol)
rslt = push(ol,5,6,7,mode="original")
rslt
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(nl)<EOL>cpol = copy.deepcopy(ol)<EOL>new.extend(cpol)<EOL>return(new)<EOL><DEDENT>else:<EOL><INDENT>length = ol.__len__()<EOL>nl_len = nl.__len__()<EOL>for i in range(<NUM_LIT:0>,nl_len):<EOL><INDENT>ol.append(None)<EOL><DEDENT>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>ol[i+nl_len] = ol[i]<EOL><DEDENT>for i in range(<NUM_LIT:0>,nl_len):<EOL><INDENT>ol[i] = nl[i]<EOL><DEDENT>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
id(nl)
prextend(ol,nl,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
nl = [5,6,7,8]
id(ol)
id(nl)
new = prextend(ol,nl)
new
id(new)


new = []<EOL>length = arrays.__len__()<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>array = copy.deepcopy(arrays[i])<EOL>new.extend(array)<EOL><DEDENT>return(new)<EOL>

from elist.elist import *
l1 = [1,2,3]
l2 = ["a","b","c"]
l3 = [100,200]
id(l1)
id(l2)
id(l3)
arrays = [l1,l2,l3]
new = concat(arrays)
new
id(new)


return(concat(*tuple(arrays)))<EOL>

from elist.elist import *
l1 = [1,2,3]
l2 = ["a","b","c"]
l3 = [100,200]
id(l1)
id(l2)
id(l3)
arrays = [l1,l2,l3]
new = concat_seqs(arrays)
new
id(new)


from elist.elist import *
ol=[1,2,3,4]
car(ol)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>cpol = copy.deepcopy(ol)<EOL>return(cpol[<NUM_LIT:1>:])<EOL><DEDENT>else:<EOL><INDENT>ol.pop(<NUM_LIT:0>)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol=[1,2,3,4]
id(ol)
new = cdr(ol)
new
id(new)
####
ol=[1,2,3,4]
id(ol)
rslt = cdr(ol,mode="original")
rslt
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>return(prepend(l,head_ele,mode=mode))<EOL>

from elist.elist import *
ol=[1,2,3,4]
id(ol)
new = cons(5,ol)
new
id(new)
####
ol=[1,2,3,4]
id(ol)
rslt = cons(5,ol,mode="original")
rslt
id(rslt)


if(index<<NUM_LIT:0>):<EOL><INDENT>rl = length+index<EOL>if(rl<<NUM_LIT:0>):<EOL><INDENT>index = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>index = rl<EOL><DEDENT><DEDENT>elif(index>=length):<EOL><INDENT>index = length<EOL><DEDENT>else:<EOL><INDENT>index = index<EOL><DEDENT>return(index)<EOL>

uniform_index(0,3)
uniform_index(-1,3)
uniform_index(-4,3)
uniform_index(-3,3)
uniform_index(5,3)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>si = uniform_index(start_index,length)<EOL>new = copy.deepcopy(cpol[<NUM_LIT:0>:si])<EOL>new.append(ele)<EOL>new.extend(cpol[si:])<EOL>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.insert(start_index,ele)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,2,3,4]
ele = 5
id(ol)
insert(ol,2,ele,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
ele = 5
id(ol)
new = insert(ol,2,ele)
new
id(new)


start_index = kwargs['<STR_LIT:index>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>si = uniform_index(start_index,length)<EOL>new = copy.deepcopy(cpol[<NUM_LIT:0>:si])<EOL>new.extend(list(eles))<EOL>new.extend(cpol[si:])<EOL>return(new)<EOL><DEDENT>else:<EOL><INDENT>si = uniform_index(start_index,length)<EOL>new = cpol[<NUM_LIT:0>:si]<EOL>new.extend(list(eles))<EOL>new.extend(cpol[si:])<EOL>ol.clear()<EOL>for i in range(<NUM_LIT:0>,new.__len__()):<EOL><INDENT>ol.append(new[i])<EOL><DEDENT>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,2,3,4]
id(ol)
insert_some(ol,5,6,7,8,index=2,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
id(ol)
new = insert_some(ol,5,6,7,8,index=2)
new
id(new)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>eles = copy.deepcopy(eles)<EOL>locs = copy.deepcopy(locs)<EOL>new = []<EOL>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,locs.__len__()):<EOL><INDENT>if(locs[i]>=length):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>locs[i] = uniform_index(locs[i],length)<EOL><DEDENT><DEDENT>tmp = sorted_refer_to(eles,locs)<EOL>eles = tmp['<STR_LIT:list>']<EOL>locs = tmp['<STR_LIT>']<EOL>label = eles.__len__()<EOL>si = <NUM_LIT:0><EOL>ei = <NUM_LIT:0><EOL>for i in range(<NUM_LIT:0>,locs.__len__()):<EOL><INDENT>if(locs[i]>=length):<EOL><INDENT>label = i<EOL>break<EOL><DEDENT>else:<EOL><INDENT>ei = locs[i]<EOL>new.extend(cpol[si:ei])<EOL>new.append(eles[i])<EOL>si = ei<EOL><DEDENT><DEDENT>for i in range(label,locs.__len__()):<EOL><INDENT>new.append(eles[i])<EOL><DEDENT>new.extend(cpol[ei:])<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,2,3,4,5]
eles = [7,77,777]
locs = [0,2,4]
id(ol)
new = insert_many(ol,eles,locs)
ol
new
id(new)
####
ol = [1,2,3,4,5]
eles = [7,77,777]
locs = [0,2,4]
id(ol)
rslt = insert_many(ol,eles,locs,mode="original")
ol
rslt
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>loc = kwargs['<STR_LIT:index>']<EOL>secs = list(secs)<EOL>secs = [concat(*secs)]<EOL>locs = [loc]<EOL>return(insert_sections_many(ol,secs,locs,mode=mode))<EOL>

ol = initRange(0,20,1)
ol
loc = 6
rslt = insert_sections_some(ol,['a','a','a'],['c','c','c','c'],index=loc)
rslt
####


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>secs = [sec]<EOL>locs = [loc]<EOL>return(insert_sections_many(ol,secs,locs,mode=mode))<EOL>

ol = initRange(0,20,1)
ol
loc = 6
sec = ['a','b','c','d']
rslt = insert_section(ol,sec,loc)
rslt
####


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>secs = copy.deepcopy(secs)<EOL>locs = copy.deepcopy(locs)<EOL>brked = broken_seqs(ol,locs)<EOL>seclen = secs.__len__()<EOL>brklen = brked.__len__()<EOL>if(locs[<NUM_LIT:0>]==<NUM_LIT:0>):<EOL><INDENT>new = secs[<NUM_LIT:0>]<EOL>length = seclen -<NUM_LIT:1><EOL>if(length < brklen):<EOL><INDENT>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>new.extend(brked[i])<EOL>new.extend(secs[i+<NUM_LIT:1>])<EOL><DEDENT>for i in range(length,brklen):<EOL><INDENT>new.extend(brked[i])<EOL><DEDENT><DEDENT>elif(length == brklen):<EOL><INDENT>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>new.extend(brked[i])<EOL>new.extend(secs[i+<NUM_LIT:1>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for i in range(<NUM_LIT:0>,brklen):<EOL><INDENT>new.extend(brked[i])<EOL>new.extend(secs[i+<NUM_LIT:1>])<EOL><DEDENT>for i in range(brklen,length):<EOL><INDENT>new.extend(secs[i])<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>new = brked[<NUM_LIT:0>]<EOL>length = brklen -<NUM_LIT:1><EOL>if(length < seclen):<EOL><INDENT>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>new.extend(secs[i])<EOL>new.extend(brked[i+<NUM_LIT:1>])<EOL><DEDENT>for i in range(length,seclen):<EOL><INDENT>new.extend(secs[i])<EOL><DEDENT><DEDENT>elif(length == seclen):<EOL><INDENT>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>new.extend(secs[i])<EOL>new.extend(brked[i+<NUM_LIT:1>])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for i in range(<NUM_LIT:0>,seclen):<EOL><INDENT>new.extend(secs[i])<EOL>new.extend(brked[i+<NUM_LIT:1>])<EOL><DEDENT>for i in range(seclen,length):<EOL><INDENT>new.extend(brked[i])<EOL><DEDENT><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>


def cond_func(ele,ol):<EOL><INDENT>index = ol.index(ele)<EOL>return(index)<EOL><DEDENT>indexes = array_map(sub,cond_func,ol)<EOL>nsub = sorted_refer_to(sub,indexes)['<STR_LIT:list>']<EOL>return(nsub)<EOL>

sub = ['query', 'params', 'fragment', 'path']
ol = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment']
reorder_sub(ol,sub)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>new.sort()<EOL>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.sort()<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,3,4,2]
id(ol)
new = sort(ol)
ol
new
id(ol)
id(new)
####
ol = [1,3,4,2]
id(ol)
rslt = sort(ol,mode="original")
ol
rslt
id(ol)
id(rslt)


if("<STR_LIT>" in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>tl =[]<EOL>length = l.__len__()<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>ele = (l[i],referer[i])<EOL>tl.append(ele)<EOL><DEDENT>tl = sorted(tl,key=itemgetter(<NUM_LIT:1>),reverse=reverse)<EOL>sorted_l =[]<EOL>sorted_r = []<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>sorted_l.append(tl[i][<NUM_LIT:0>])<EOL>sorted_r.append(tl[i][<NUM_LIT:1>])<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(sorted_l)<EOL><DEDENT>elif(mode == "<STR_LIT>"):<EOL><INDENT>return(referer)<EOL><DEDENT>else:<EOL><INDENT>return({"<STR_LIT:list>":sorted_l,"<STR_LIT>":sorted_r})<EOL><DEDENT>

from elist.elist import *
l = ["a","b","c"]
referer = [7,8,6]
sorted_refer_to(l,referer)
{'list': ['c', 'a', 'b'], 'referer': [6, 7, 8]}
l
referer
>>>


if('<STR_LIT>' in kwargs):<EOL><INDENT>reverse = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>reverse = False<EOL><DEDENT>length = referer.__len__()<EOL>indexes = list(range(<NUM_LIT:0>,length))<EOL>rslt = sorted_refer_to(indexes,referer,reverse=reverse)<EOL>referer = rslt['<STR_LIT>']<EOL>indexes = rslt['<STR_LIT:list>']<EOL>rslt = []<EOL>lists = copy.deepcopy(list(lists))<EOL>for i in range(<NUM_LIT:0>,lists.__len__()):<EOL><INDENT>l = lists[i]<EOL>nl = []<EOL>for j in range(<NUM_LIT:0>,length):<EOL><INDENT>loc = indexes[j]<EOL>nl.append(l[loc])<EOL><DEDENT>rslt.append(nl)<EOL><DEDENT>return(tuple(rslt))<EOL>

from elist.elist import *
referer = [4,2,3,1]
l1 = ['a','b','c','d']
l2 = [100,200,300,400]
l3 = ['A','B','A','B']
nl1,nl2,nl3 = batsorted(referer,l1,l2,l3)
nl1
nl2
nl3
nl1,nl2,nl3 = batsorted(referer,l1,l2,l3,reverse=True)
nl1
nl2
nl3
####the batsorted will not modify the original lists
l1
l2
l3


def default_eq_func(value1,value2):<EOL><INDENT>cond = (value1 == value2)<EOL>return(cond)<EOL><DEDENT>def default_gt_func(value1,value2):<EOL><INDENT>cond = (value1 > value2)<EOL>return(cond)<EOL><DEDENT>def default_lt_func(value1,value2):<EOL><INDENT>cond = (value1 < value2)<EOL>return(cond)<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>eq_func = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>eq_func = default_eq_func<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>gt_func = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>gt_func = default_gt_func<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>lt_func = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>lt_func = default_lt_func<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>reverse = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>reverse = False<EOL><DEDENT>keys = kwargs['<STR_LIT>']<EOL>def cmp_dict(d1,d2):<EOL><INDENT>'''<STR_LIT:U+0020>'''<EOL>length = keys.__len__()<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>key = keys[i]<EOL>cond = eq_func(d1[key],d2[key])<EOL>if(cond):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>cond = gt_func(d1[key],d2[key])<EOL>if(cond):<EOL><INDENT>return(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>return(-<NUM_LIT:1>)<EOL><DEDENT><DEDENT><DEDENT>return(<NUM_LIT:0>)<EOL><DEDENT>ndl = dictList<EOL>ndl = sorted(ndl,key=functools.cmp_to_key(cmp_dict),reverse=reverse)<EOL>return(ndl)<EOL>

students = [
    {'name':'john','class':'A', 'year':15},
    {'name':'jane','class':'B', 'year':12},
    {'name':'dave','class':'B', 'year':10}
]

rslt = sortDictList(students,cond_keys=['name','class','year'])
pobj(rslt)
rslt = sortDictList(students,cond_keys=['name','year','class'])
pobj(rslt)
rslt = sortDictList(students,cond_keys=['class','name','year'])
pobj(rslt)
rslt = sortDictList(students,cond_keys=['class','year','name'])
pobj(rslt)
rslt = sortDictList(students,cond_keys=['year','name','class'])
pobj(rslt)
rslt = sortDictList(students,cond_keys=['year','name','class'])
pobj(rslt)


from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_first(ol,'a')
####index_first, array_index, indexOf  are the same
array_index(ol,'a')
indexOf(ol,'a')


length = ol.__len__()<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return(i)<EOL><DEDENT><DEDENT>return(None)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_firstnot(ol,'a')
####index_firstnot, array_indexnot, indexOfnot  are the same
array_indexnot(ol,'a')
indexOfnot(ol,'a')


length = ol.__len__()<EOL>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>return(i)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(None)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_last(ol,'a')
####lastIndexOf is the same as index_last
lastIndexOf(ol,'a')


length = ol.__len__()<EOL>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>return(i)<EOL><DEDENT><DEDENT>return(None)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_lastnot(ol,'a')
####lastIndexOfnot is the same as index_lastnot
lastIndexOfnot(ol,'a')


length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq == which):<EOL><INDENT>return(i)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(None)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_which(ol,'a',0)
index_which(ol,'a',1)
index_which(ol,'a',2)
index_which(ol,'a',3) == None


length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq == which):<EOL><INDENT>return(i)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>return(None)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_whichnot(ol,'a',0)
index_whichnot(ol,'a',1)
index_whichnot(ol,'a',2)


length = ol.__len__()<EOL>indexes =[]<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>indexes.append(i)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(indexes)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_all(ol,'a')


length = ol.__len__()<EOL>indexes =[]<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>indexes.append(i)<EOL><DEDENT><DEDENT>return(indexes)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_allnot(ol,'a')


seqs = list(seqs)<EOL>length = ol.__len__()<EOL>indexes =[]<EOL>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>indexes.append(i)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(indexes)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_some(ol,'a',0,2)
indexes_some(ol,'a',0,1)
indexes_some(ol,'a',1,2)
indexes_some(ol,'a',3,4)


seqs = list(seqs)<EOL>length = ol.__len__()<EOL>indexes =[]<EOL>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(value == ol[i]):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>indexes.append(i)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>return(indexes)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_somenot(ol,'a',0,2)
indexes_somenot(ol,'a',0,1)
indexes_somenot(ol,'a',1,2)
indexes_somenot(ol,'a',3,4)


from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_seqs(ol,'a',{0,2})
indexes_seqs(ol,'a',{0,1})
indexes_seqs(ol,'a',{1,2})
indexes_seqs(ol,'a',{3,4})


from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_seqsnot(ol,'a',{0,2})
indexes_seqsnot(ol,'a',{0,1})
indexes_seqsnot(ol,'a',{1,2})
indexes_seqsnot(ol,'a',{3,4})


length = ol.__len__()<EOL>begin = None<EOL>slice = []<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(ol[i]==value):<EOL><INDENT>begin = i<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(begin == None):<EOL><INDENT>return(None)<EOL><DEDENT>else:<EOL><INDENT>slice.append(begin)<EOL>for i in range(begin+<NUM_LIT:1>,length):<EOL><INDENT>if(ol[i]==value):<EOL><INDENT>slice.append(i)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>return(slice)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
first_continuous_indexes_slice(ol,"a")


length = ol.__len__()<EOL>begin = None<EOL>slice = []<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(not(ol[i]==value)):<EOL><INDENT>begin = i<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(begin == None):<EOL><INDENT>return(None)<EOL><DEDENT>else:<EOL><INDENT>slice.append(begin)<EOL>for i in range(begin+<NUM_LIT:1>,length):<EOL><INDENT>if(not(ol[i]==value)):<EOL><INDENT>slice.append(i)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>return(slice)<EOL>

from elist.elist import *
ol = ["a",0,1,"a","a",2,3,"a",4,"a","a","a",5]
first_continuous_indexesnot_slice(ol,"a")


length = ol.__len__()<EOL>end = None<EOL>slice = []<EOL>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(ol[i]==value):<EOL><INDENT>end = i<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(end == None):<EOL><INDENT>return(None)<EOL><DEDENT>else:<EOL><INDENT>slice.append(end)<EOL>for i in range(end-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(ol[i]==value):<EOL><INDENT>slice.append(i)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>slice.reverse()<EOL>return(slice)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
last_continuous_indexes_slice(ol,"a")


length = ol.__len__()<EOL>end = None<EOL>slice = []<EOL>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(not(ol[i]==value)):<EOL><INDENT>end = i<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(end == None):<EOL><INDENT>return(None)<EOL><DEDENT>else:<EOL><INDENT>slice.append(end)<EOL>for i in range(end-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(not(ol[i]==value)):<EOL><INDENT>slice.append(i)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>slice.reverse()<EOL>return(slice)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
last_continuous_indexesnot_slice(ol,"a")


length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = (ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq == which):<EOL><INDENT>return(slice)<EOL><DEDENT>else:<EOL><INDENT>cursor = cursor + <NUM_LIT:1><EOL>begin = None<EOL>slice = []<EOL><DEDENT><DEDENT>else:<EOL><INDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT><DEDENT>if(slice):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>if(seq == which):<EOL><INDENT>return(slice)<EOL><DEDENT>else:<EOL><INDENT>return([])<EOL><DEDENT>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
which_continuous_indexes_slice(ol,"a",0)
which_continuous_indexes_slice(ol,"a",1)
which_continuous_indexes_slice(ol,"a",2)
which_continuous_indexes_slice(ol,"a",3)
which_continuous_indexes_slice(ol,"b",0)


length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = not(ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq == which):<EOL><INDENT>return(slice)<EOL><DEDENT>else:<EOL><INDENT>cursor = cursor + <NUM_LIT:1><EOL>begin = None<EOL>slice = []<EOL><DEDENT><DEDENT>else:<EOL><INDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT><DEDENT>if(slice):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>if(seq == which):<EOL><INDENT>return(slice)<EOL><DEDENT>else:<EOL><INDENT>return([])<EOL><DEDENT>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
which_continuous_indexesnot_slice(ol,"a",0)
which_continuous_indexesnot_slice(ol,"a",1)
which_continuous_indexesnot_slice(ol,"a",2)
which_continuous_indexesnot_slice(ol,"a",3)
which_continuous_indexesnot_slice(ol,"b",0)


seqs = list(seqs)<EOL>rslt = []<EOL>length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = (ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>begin = None<EOL>slice = []<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>if(slice):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
some_continuous_indexes_slices(ol,"a",0,2)


seqs = list(seqs)<EOL>rslt = []<EOL>length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = not(ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>begin = None<EOL>slice = []<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>if(slice):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
some_continuous_indexesnot_slices(ol,"a",0,2)


rslt = []<EOL>length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = (ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>begin = None<EOL>slice = []<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>if(slice):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
seqs_continuous_indexes_slices(ol,"a",{0,2})


rslt = []<EOL>length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = not(ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>begin = None<EOL>slice = []<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>if(slice):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
seqs_continuous_indexesnot_slices(ol,"a",{0,2})


rslt = []<EOL>length = ol.__len__()<EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = (ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>rslt.append(slice)<EOL>begin = None<EOL>slice = []<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>if(slice):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
all_continuous_indexes_slices(ol,"a")


rslt = []<EOL>length = ol.__len__()<EOL>cursor = <NUM_LIT:0><EOL>begin = None<EOL>slice = []<EOL>while(cursor < length):<EOL><INDENT>cond1 = not(ol[cursor] == value)<EOL>cond2 = (begin == None)<EOL>if(cond1 & cond2):<EOL><INDENT>begin = cursor<EOL>slice.append(cursor)<EOL><DEDENT>elif(cond1 & (not(cond2))):<EOL><INDENT>slice.append(cursor)<EOL><DEDENT>elif((not(cond1)) & (not(cond2))):<EOL><INDENT>rslt.append(slice)<EOL>begin = None<EOL>slice = []<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>cursor = cursor + <NUM_LIT:1><EOL><DEDENT>if(slice):<EOL><INDENT>rslt.append(slice)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
all_continuous_indexesnot_slices(ol,"a")


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>length = ol.__len__()<EOL>rslt = pop(ol,<NUM_LIT:0>,mode=mode)<EOL>return(rslt)<EOL>

from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4]
id(ol)
rslt = shift(ol)
pobj(rslt)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4]
id(ol)
rslt = shift(ol,mode="original")
rslt
ol
id(ol)


index = uniform_index(index,ol.__len__())<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>popped = new.pop(index)<EOL>return({'<STR_LIT>':popped,'<STR_LIT:list>':new})<EOL><DEDENT>else:<EOL><INDENT>popped = ol.pop(index)<EOL>return(popped)<EOL><DEDENT>

from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4]
id(ol)
rslt = pop(ol,2)
pobj(rslt)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4]
id(ol)
rslt = pop(ol,2,mode="original")
rslt
ol
id(ol)


cond_func = kwargs['<STR_LIT>']<EOL>cond_func_args = kwargs['<STR_LIT>']<EOL>index = uniform_index(index,ol.__len__())<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>value = ol[index]<EOL>cond = cond_func(index,value,*cond_func_args)<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>if(cond):<EOL><INDENT>popped = new.pop(index)<EOL><DEDENT>else:<EOL><INDENT>popped = new<EOL><DEDENT>return({'<STR_LIT>':popped,'<STR_LIT:list>':new})<EOL><DEDENT>else:<EOL><INDENT>if(cond):<EOL><INDENT>popped = ol.pop(index)<EOL><DEDENT>else:<EOL><INDENT>popped = ol<EOL><DEDENT>return(popped)<EOL><DEDENT>

from elist.jprint import pobj
from elist.elist import *
ol = [{'data':0;'type':'number'},{'data':'x';'type':'str'},{'data':'y';'type':'str'},4]
#cond_func_args is a array
def cond_func(index,value,cond_func_args):


length = ol.__len__()<EOL>start_index = uniform_index(start_index,length)<EOL>end_index = uniform_index(end_index,length)<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>cpol = copy.deepcopy(ol)<EOL>new = []<EOL>popped = []<EOL>for i in range(<NUM_LIT:0>,start_index):<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT>for i in range(start_index,end_index):<EOL><INDENT>popped.append(cpol[i])<EOL><DEDENT>for i in range(end_index,length):<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT>return({'<STR_LIT>':popped,'<STR_LIT:list>':new})<EOL><DEDENT>else:<EOL><INDENT>tmp = []<EOL>popped = []<EOL>for i in range(<NUM_LIT:0>,start_index):<EOL><INDENT>tmp.append(ol[i])<EOL><DEDENT>for i in range(start_index,end_index):<EOL><INDENT>popped.append(ol[i])<EOL><DEDENT>for i in range(end_index,length):<EOL><INDENT>tmp.append(ol[i])<EOL><DEDENT>ol.clear()<EOL>for i in range(<NUM_LIT:0>,tmp.__len__()):<EOL><INDENT>ol.append(tmp[i])<EOL><DEDENT>return(popped)<EOL><DEDENT>

from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_range(ol,2,4)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_range(ol,2,4,mode="original")
rslt
ol
id(ol)


length = ol.__len__()<EOL>indexes = list(map(lambda index:uniform_index(index,length),list(indexes)))<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>cpol = copy.deepcopy(ol)<EOL>new = []<EOL>popped = []<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(i in indexes):<EOL><INDENT>popped.append(cpol[i])<EOL><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>return({'<STR_LIT>':popped,'<STR_LIT:list>':new})<EOL><DEDENT>else:<EOL><INDENT>tmp = []<EOL>popped = []<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(i in indexes):<EOL><INDENT>popped.append(ol[i])<EOL><DEDENT>else:<EOL><INDENT>tmp.append(ol[i])<EOL><DEDENT><DEDENT>ol.clear()<EOL>for i in range(<NUM_LIT:0>,tmp.__len__()):<EOL><INDENT>ol.append(tmp[i])<EOL><DEDENT>return(popped)<EOL><DEDENT>

from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_some(ol,0,2,5)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_some(ol,0,2,5,mode="original")
rslt
ol
id(ol)


from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_indexes(ol,{0,-3,5})
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_indexes(ol,{0,-3,5},mode="original")
rslt
ol
id(ol)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>new.remove(value)<EOL>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.remove(value)<EOL>return(ol)<EOL><DEDENT>

from elist.jprint import pobj
from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_first(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_first(ol,'a',mode="original")
ol
rslt
id(ol)
id(rslt)
####array_remove is the same as remove_first


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>length = ol.__len__()<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(new[i] == value):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>new.pop(i)<EOL>return(new)<EOL><DEDENT><DEDENT>return(new)<EOL><DEDENT>else:<EOL><INDENT>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(ol[i] == value):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>ol.pop(i)<EOL>return(ol)<EOL><DEDENT><DEDENT>return(ol)<EOL><DEDENT>

from elist.jprint import pobj
from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_firstnot(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_firstnot(ol,'a',mode="original")
ol
rslt
id(ol)
id(rslt)
####array_removenot is the same as remove_firstnot


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>new = copy.deepcopy(ol)<EOL>new.reverse()<EOL>new.remove(value)<EOL>new.reverse()<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_last(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_last(ol,'a',mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>length = ol.__len__()<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(new[i] == value):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>new.pop(i)<EOL>return(new)<EOL><DEDENT><DEDENT>return(new)<EOL><DEDENT>else:<EOL><INDENT>for i in range(length-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>if(ol[i] == value):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>ol.pop(i)<EOL>return(ol)<EOL><DEDENT><DEDENT>return(ol)<EOL><DEDENT>

from elist.jprint import pobj
from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_lastnot(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_lastnot(ol,'a',mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>new = copy.deepcopy(ol)<EOL>length = ol.__len__()<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>l = new <EOL><DEDENT>else:<EOL><INDENT>l = ol<EOL><DEDENT>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(ol[i]==value):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq == which):<EOL><INDENT>l.pop(i)<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(l)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_which(ol,'a',1)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_which(ol,'a',1,mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>new = copy.deepcopy(ol)<EOL>length = ol.__len__()<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>l = new <EOL><DEDENT>else:<EOL><INDENT>l = ol<EOL><DEDENT>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(not(ol[i]==value)):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq == which):<EOL><INDENT>l.pop(i)<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return(l)<EOL>

from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_whichnot(ol,'a',1)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_whichnot(ol,'a',1,mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>seqs = list(seqs)<EOL>new = []<EOL>length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cpol = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(cpol[i]==value):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_some(ol,'a',1,3)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_some(ol,'a',1,3,mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>seqs = list(seqs)<EOL>new = []<EOL>length = ol.__len__()<EOL>seq = -<NUM_LIT:1><EOL>cpol = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(not(cpol[i]==value)):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_somenot(ol,'a',1,3)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_somenot(ol,'a',1,3,mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>seqs = list(seqs)<EOL>new = []<EOL>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(cpol[i]==value):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_seqs(ol,'a',{1,3})
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_seqs(ol,'a',{1,3},mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>seqs = list(seqs)<EOL>new = []<EOL>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>seq = -<NUM_LIT:1><EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(not(cpol[i]==value)):<EOL><INDENT>seq = seq + <NUM_LIT:1><EOL>if(seq in seqs):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_seqsnot(ol,'a',{1,3})
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_seqsnot(ol,'a',{1,3},mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>new = []<EOL>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(cpol[i]==value):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_all(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_all(ol,'a',mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>new = []<EOL>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>if(cpol[i]==value):<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_allnot(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_allnot(ol,'a',mode="original")
ol
rslt
id(ol)
id(rslt)


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>values = copy.deepcopy(values)<EOL>seqs = copy.deepcopy(seqs)<EOL>cursors = [-<NUM_LIT:1>] * values.__len__()<EOL>new = []<EOL>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>label = True<EOL>for j in range(<NUM_LIT:0>,cursors.__len__()):<EOL><INDENT>which = seqs[j]<EOL>value = values[j]<EOL>if(cpol[i] == value):<EOL><INDENT>cursors[j] = cursors[j] + <NUM_LIT:1><EOL>if(cursors[j] == which):<EOL><INDENT>label = False<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(label):<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>values = copy.deepcopy(values)<EOL>seqs = copy.deepcopy(seqs)<EOL>cursors = [-<NUM_LIT:1>] * values.__len__()<EOL>new = []<EOL>length = ol.__len__()<EOL>cpol = copy.deepcopy(ol)<EOL>for i in range(<NUM_LIT:0>,length):<EOL><INDENT>label = True<EOL>for j in range(<NUM_LIT:0>,cursors.__len__()):<EOL><INDENT>which = seqs[j]<EOL>value = values[j]<EOL>if(not(cpol[i] == value)):<EOL><INDENT>cursors[j] = cursors[j] + <NUM_LIT:1><EOL>if(cursors[j] == which):<EOL><INDENT>label = False<EOL>break<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(label):<EOL><INDENT>new.append(cpol[i])<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9]
id(ol)
new = remove_manynot(ol,['a','b'],[1,2])
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9]
id(ol)
rslt = remove_manynot(ol,['a','b'],[1,2],mode="original")
ol
rslt
id(ol)
id(rslt)


cond_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>cond_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>cond_func_args = []<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>new = copy.deepcopy(ol)<EOL>selected = find_all(new,cond_func,*cond_func_args)<EOL>selected_indexes = array_map(selected,lambda ele:ele['<STR_LIT:index>'])<EOL>new = pop_indexes(new,selected_indexes)['<STR_LIT:list>']<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
def afterCH(ele,ch):
    cond = (ord(str(ele)) > ord(ch))
    return(cond)

new = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B'])
ol
new
id(ol)
id(new)
####
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
rslt = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B'],mode='original')
ol
rslt
id(ol)
id(rslt)


cond_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>cond_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>cond_func_args = []<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>new = copy.deepcopy(ol)<EOL>selected = find_all(new,cond_func,*cond_func_args)<EOL>selected_indexes = array_map(selected,lambda ele:ele['<STR_LIT:index>'])<EOL>selected_indexes = pop_indexes(selected_indexes,seqs)['<STR_LIT>']<EOL>new = pop_indexes(new,selected_indexes)['<STR_LIT:list>']<EOL>if(mode == "<STR_LIT>"):<EOL><INDENT>return(new)<EOL><DEDENT>else:<EOL><INDENT>ol.clear()<EOL>ol.extend(new)<EOL>return(ol)<EOL><DEDENT>

from elist.elist import *
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
def afterCH(ele,ch):
    cond = (ord(str(ele)) > ord(ch))
    return(cond)

new = cond_remove_seqs(ol,[0,2],cond_func=afterCH,cond_func_args=['B'])
ol
new
id(ol)
id(new)
####
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
rslt = cond_remove_seqs(ol,[0,2],cond_func=afterCH,cond_func_args=['B'],mode='original')
ol
rslt
id(ol)
id(rslt)


cond_func = kwargs['<STR_LIT>']<EOL>if('<STR_LIT>' in kwargs):<EOL><INDENT>cond_func_args = kwargs['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>cond_func_args = []<EOL><DEDENT>if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>seqs = list(some)<EOL>rslt = cond_remove_seqs(ol,seqs,cond_func=cond_func,cond_func_args=cond_func_args)<EOL>return(rslt)<EOL>

from elist.elist import *
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)

def afterCH(ele,ch):
    cond = (ord(str(ele)) > ord(ch))
    return(cond)

new = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B'])
ol
new
id(ol)
id(new)
####
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
rslt = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B'],mode='original')
ol
rslt
id(ol)
id(rslt)


rslt = []<EOL>for i in range(<NUM_LIT:0>,len):<EOL><INDENT>rslt.append(copy.deepcopy(default_element))<EOL><DEDENT>return(rslt)<EOL>

from elist.elist import *
init(5)
init(5,"x")


return(list(range(start,end,step)))<EOL>


return(list(map(lambda ele:int(ele),l)))<EOL>

from elist.elist import *
l = ["1","3","4","5"]
intlize(l)


return(list(map(lambda ele:str(ele),l)))<EOL>

from elist.elist import *
l = [1,3,4,5]
strlize(l)


if(func):<EOL><INDENT>l = list(obj)<EOL>rslt = list(map(lambda ele:func(ele,*args),l))<EOL>return(rslt)<EOL><DEDENT>else:<EOL><INDENT>return(list(obj))<EOL><DEDENT>

from elist.elist import *
array_from("abcd",None)
#####
def map_func(ele,x,y):
    return(int(ele)+x+y)

array_from("1234",map_func,1000,100)

def map_func(ele):
    return(int(ele)*2)

array_from("1234",map_func)

array_from("1234",None)


return(list(eles))<EOL>

from elist.elist import *
array_of(1,2,4,5,6)


return(copy.deepcopy(ol))<EOL>

from elist.elist import *
ol = [1,2,3,4]
id(ol)
new = deepcopy(ol)
new
id(new)


def copy_within(ol,target, start=None, end=None):

length = ol.__len__()<EOL>if(start==None):<EOL><INDENT>start = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>if(end==None):<EOL><INDENT>end = length<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>target = uniform_index(target,length)<EOL>start = uniform_index(start,length)<EOL>end = uniform_index(end,length)<EOL>cplen = end - start<EOL>cpend = target+cplen<EOL>if(target+cplen > length):<EOL><INDENT>cpend = length<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>shift = start - target<EOL>if(shift>=<NUM_LIT:0>):<EOL><INDENT>for i in range(target,cpend):<EOL><INDENT>ol[i] = ol[i+shift]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for i in range(cpend-<NUM_LIT:1>,target-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>ol[i] = ol[i+shift]<EOL><DEDENT><DEDENT>return(ol)<EOL>

from elist.elist import *
ol = [1, 2, 3, 4, 5]
id(ol)
rslt = copyWithin(ol,0,3,4)
rslt
id(rslt)
####
ol = [1, 2, 3, 4, 5]
id(ol)
rslt = copyWithin(ol,0,3)
rslt
id(rslt)
####
ol = [1, 2, 3, 4, 5]
id(ol)
rslt = copyWithin(ol,-2)
rslt
id(rslt)
####copyWithin is the same as copy_within


if('<STR_LIT>' in kwargs):<EOL><INDENT>mode = kwargs["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>mode = "<STR_LIT>"<EOL><DEDENT>if(mode == "<STR_LIT>"):<EOL><INDENT>new = copy.deepcopy(ol)<EOL>new.reverse()<EOL>return(new) <EOL><DEDENT>else:<EOL><INDENT>ol.reverse()<EOL>return(ol)<EOL><DEDENT>'<STR_LIT>',<EOL>'<STR_LIT>'<EOL>

from elist.elist import *
ol = [1,2,3,4]
id(ol)
new = reverse(ol)
ol
new
id(ol)
id(new)
####
ol = [1,2,3,4]
id(ol)
rslt = reverse(ol,mode="original")
ol
rslt
id(ol)
id(rslt)