lsfiles


Namelsfiles JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://pypi.org/project/lsfiles/
SummaryPath object VC index
upload_time2023-02-04 17:38:20
maintainerjshwi
docs_urlNone
authorjshwi
requires_python>=3.8,<4.0
licenseMIT
keywords git index lsfiles oop vc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            lsfiles
=======
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
    :target: https://opensource.org/licenses/MIT
    :alt: License
.. image:: https://img.shields.io/pypi/v/lsfiles
    :target: https://pypi.org/project/lsfiles/
    :alt: PyPI
.. image:: https://github.com/jshwi/lsfiles/actions/workflows/build.yaml/badge.svg
    :target: https://github.com/jshwi/lsfiles/actions/workflows/build.yaml
    :alt: Build
.. image:: https://github.com/jshwi/lsfiles/actions/workflows/codeql-analysis.yml/badge.svg
    :target: https://github.com/jshwi/lsfiles/actions/workflows/codeql-analysis.yml
    :alt: CodeQL
.. image:: https://results.pre-commit.ci/badge/github/jshwi/lsfiles/master.svg
   :target: https://results.pre-commit.ci/latest/github/jshwi/lsfiles/master
   :alt: pre-commit.ci status
.. image:: https://codecov.io/gh/jshwi/lsfiles/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/jshwi/lsfiles
    :alt: codecov.io
.. image:: https://readthedocs.org/projects/lsfiles/badge/?version=latest
    :target: https://lsfiles.readthedocs.io/en/latest/?badge=latest
    :alt: readthedocs.org
.. image:: https://img.shields.io/badge/python-3.8-blue.svg
    :target: https://www.python.org/downloads/release/python-380
    :alt: python3.8
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: Black
.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
    :target: https://pycqa.github.io/isort/
    :alt: isort
.. image:: https://img.shields.io/badge/%20formatter-docformatter-fedcba.svg
    :target: https://github.com/PyCQA/docformatter
    :alt: docformatter
.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen
    :target: https://github.com/PyCQA/pylint
    :alt: pylint
.. image:: https://img.shields.io/badge/security-bandit-yellow.svg
    :target: https://github.com/PyCQA/bandit
    :alt: Security Status
.. image:: https://snyk.io/test/github/jshwi/pyaud/badge.svg
    :target: https://snyk.io/test/github/jshwi/pyaud/badge.svg
    :alt: Known Vulnerabilities
.. image:: https://snyk.io/advisor/python/lsfiles/badge.svg
    :target: https://snyk.io/advisor/python/lsfiles
    :alt: lsfiles

Path object VC index
--------------------

Index versioned .py files

Install
-------

``pip install lsfiles``

Development
-----------

``poetry install``

Usage
-----


The ``LSFiles`` instance is a list-like object instantiated with an empty index

.. code-block:: python

    >>> from lsfiles import LSFiles
    >>> from pathlib import Path
    >>>
    >>> files = LSFiles()
    >>> files
    <LSFiles []>


The ``LSFiles`` index calls ``git ls-files`` and only versioned files are indexed

.. code-block:: python

    >>> files.populate()
    >>> for path in sorted([p.relative_to(Path.cwd()) for p in files]):
    ...     print(path)
    docs/conf.py
    lsfiles/__init__.py
    lsfiles/_indexing.py
    lsfiles/_objects.py
    lsfiles/_version.py
    tests/__init__.py
    tests/_environ.py
    tests/_test.py
    tests/conftest.py
    whitelist.py

The ``LSFiles`` instance is an index of unique file paths

It's implementation of ``extend`` prevents duplicates

.. code-block:: python

    >>> p1 = Path.cwd() / "f1"
    >>> p2 = Path.cwd() / "f1"
    >>>
    >>> files = LSFiles()
    >>> files.extend([p1, p2])
    >>> sorted([p.relative_to(Path.cwd()) for p in files.reduce()])
    [PosixPath('f1')]

Reduce minimizes index to directories and individual files relative to the current working dir

The list value is returned, leaving the instance unaltered

.. code-block:: python

    >>> p1 = Path.cwd() / "f1"
    >>>
    >>> d = Path.cwd() / "dir"
    >>> p2 = d / "f2"
    >>> p3 = d / "f3"
    >>>
    >>> files = LSFiles()
    >>> files.extend([p1, p2, p3])
    >>> sorted(p.relative_to(Path.cwd()) for p in files.reduce())
    [PosixPath('dir'), PosixPath('f1')]

Exclusions can be added on instantiation

Exclusions are evaluated by their basename, and does not have to be an absolute path

.. code-block:: python

    >>> p1 = Path.cwd() / "docs" / "conf.py"
    >>> p2 = Path.cwd() / "lsfiles" / "__init__.py"
    >>>
    >>> files = LSFiles(p1.name)
    >>> files.populate()
    >>>
    >>> ps = [str(p) for p in files]
    >>>
    >>> assert not str(p1) in ps
    >>> assert str(p2) in ps

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/lsfiles/",
    "name": "lsfiles",
    "maintainer": "jshwi",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "stephen@jshwisolutions.com",
    "keywords": "git,index,lsfiles,oop,vc",
    "author": "jshwi",
    "author_email": "stephen@jshwisolutions.com",
    "download_url": "https://files.pythonhosted.org/packages/58/14/a68bcd678b1db2dff6e1d3bf6c2b9d6e1327b07faf4d0db0b5fa03ad968a/lsfiles-0.3.0.tar.gz",
    "platform": null,
    "description": "lsfiles\n=======\n.. image:: https://img.shields.io/badge/License-MIT-yellow.svg\n    :target: https://opensource.org/licenses/MIT\n    :alt: License\n.. image:: https://img.shields.io/pypi/v/lsfiles\n    :target: https://pypi.org/project/lsfiles/\n    :alt: PyPI\n.. image:: https://github.com/jshwi/lsfiles/actions/workflows/build.yaml/badge.svg\n    :target: https://github.com/jshwi/lsfiles/actions/workflows/build.yaml\n    :alt: Build\n.. image:: https://github.com/jshwi/lsfiles/actions/workflows/codeql-analysis.yml/badge.svg\n    :target: https://github.com/jshwi/lsfiles/actions/workflows/codeql-analysis.yml\n    :alt: CodeQL\n.. image:: https://results.pre-commit.ci/badge/github/jshwi/lsfiles/master.svg\n   :target: https://results.pre-commit.ci/latest/github/jshwi/lsfiles/master\n   :alt: pre-commit.ci status\n.. image:: https://codecov.io/gh/jshwi/lsfiles/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jshwi/lsfiles\n    :alt: codecov.io\n.. image:: https://readthedocs.org/projects/lsfiles/badge/?version=latest\n    :target: https://lsfiles.readthedocs.io/en/latest/?badge=latest\n    :alt: readthedocs.org\n.. image:: https://img.shields.io/badge/python-3.8-blue.svg\n    :target: https://www.python.org/downloads/release/python-380\n    :alt: python3.8\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Black\n.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336\n    :target: https://pycqa.github.io/isort/\n    :alt: isort\n.. image:: https://img.shields.io/badge/%20formatter-docformatter-fedcba.svg\n    :target: https://github.com/PyCQA/docformatter\n    :alt: docformatter\n.. image:: https://img.shields.io/badge/linting-pylint-yellowgreen\n    :target: https://github.com/PyCQA/pylint\n    :alt: pylint\n.. image:: https://img.shields.io/badge/security-bandit-yellow.svg\n    :target: https://github.com/PyCQA/bandit\n    :alt: Security Status\n.. image:: https://snyk.io/test/github/jshwi/pyaud/badge.svg\n    :target: https://snyk.io/test/github/jshwi/pyaud/badge.svg\n    :alt: Known Vulnerabilities\n.. image:: https://snyk.io/advisor/python/lsfiles/badge.svg\n    :target: https://snyk.io/advisor/python/lsfiles\n    :alt: lsfiles\n\nPath object VC index\n--------------------\n\nIndex versioned .py files\n\nInstall\n-------\n\n``pip install lsfiles``\n\nDevelopment\n-----------\n\n``poetry install``\n\nUsage\n-----\n\n\nThe ``LSFiles`` instance is a list-like object instantiated with an empty index\n\n.. code-block:: python\n\n    >>> from lsfiles import LSFiles\n    >>> from pathlib import Path\n    >>>\n    >>> files = LSFiles()\n    >>> files\n    <LSFiles []>\n\n\nThe ``LSFiles`` index calls ``git ls-files`` and only versioned files are indexed\n\n.. code-block:: python\n\n    >>> files.populate()\n    >>> for path in sorted([p.relative_to(Path.cwd()) for p in files]):\n    ...     print(path)\n    docs/conf.py\n    lsfiles/__init__.py\n    lsfiles/_indexing.py\n    lsfiles/_objects.py\n    lsfiles/_version.py\n    tests/__init__.py\n    tests/_environ.py\n    tests/_test.py\n    tests/conftest.py\n    whitelist.py\n\nThe ``LSFiles`` instance is an index of unique file paths\n\nIt's implementation of ``extend`` prevents duplicates\n\n.. code-block:: python\n\n    >>> p1 = Path.cwd() / \"f1\"\n    >>> p2 = Path.cwd() / \"f1\"\n    >>>\n    >>> files = LSFiles()\n    >>> files.extend([p1, p2])\n    >>> sorted([p.relative_to(Path.cwd()) for p in files.reduce()])\n    [PosixPath('f1')]\n\nReduce minimizes index to directories and individual files relative to the current working dir\n\nThe list value is returned, leaving the instance unaltered\n\n.. code-block:: python\n\n    >>> p1 = Path.cwd() / \"f1\"\n    >>>\n    >>> d = Path.cwd() / \"dir\"\n    >>> p2 = d / \"f2\"\n    >>> p3 = d / \"f3\"\n    >>>\n    >>> files = LSFiles()\n    >>> files.extend([p1, p2, p3])\n    >>> sorted(p.relative_to(Path.cwd()) for p in files.reduce())\n    [PosixPath('dir'), PosixPath('f1')]\n\nExclusions can be added on instantiation\n\nExclusions are evaluated by their basename, and does not have to be an absolute path\n\n.. code-block:: python\n\n    >>> p1 = Path.cwd() / \"docs\" / \"conf.py\"\n    >>> p2 = Path.cwd() / \"lsfiles\" / \"__init__.py\"\n    >>>\n    >>> files = LSFiles(p1.name)\n    >>> files.populate()\n    >>>\n    >>> ps = [str(p) for p in files]\n    >>>\n    >>> assert not str(p1) in ps\n    >>> assert str(p2) in ps\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Path object VC index",
    "version": "0.3.0",
    "split_keywords": [
        "git",
        "index",
        "lsfiles",
        "oop",
        "vc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad62ad52c0a726ca4bf7ee98759a65575c45d094342760d5376b77cbd3c62ee1",
                "md5": "9e78de4eae45f8df5c98294a4fc21ae0",
                "sha256": "2eaf64daa1016f50956e1253f3e62ceebe601a69b0b3308d0b4dbc4bdc56d65d"
            },
            "downloads": -1,
            "filename": "lsfiles-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e78de4eae45f8df5c98294a4fc21ae0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 5536,
            "upload_time": "2023-02-04T17:38:18",
            "upload_time_iso_8601": "2023-02-04T17:38:18.290952Z",
            "url": "https://files.pythonhosted.org/packages/ad/62/ad52c0a726ca4bf7ee98759a65575c45d094342760d5376b77cbd3c62ee1/lsfiles-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5814a68bcd678b1db2dff6e1d3bf6c2b9d6e1327b07faf4d0db0b5fa03ad968a",
                "md5": "e858d87163e3b464232e7a4b6dd10fe6",
                "sha256": "2bbb8d0023b244224db61f4a0b0782066a45d1713e83150da293955fac686dda"
            },
            "downloads": -1,
            "filename": "lsfiles-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e858d87163e3b464232e7a4b6dd10fe6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 5944,
            "upload_time": "2023-02-04T17:38:20",
            "upload_time_iso_8601": "2023-02-04T17:38:20.392500Z",
            "url": "https://files.pythonhosted.org/packages/58/14/a68bcd678b1db2dff6e1d3bf6c2b9d6e1327b07faf4d0db0b5fa03ad968a/lsfiles-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-04 17:38:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "lsfiles"
}
        
Elapsed time: 0.03537s