Skip to main content

A spec-compliant gitignore parser for Python

Project description

igittigitt

Version v1.0.0 as of 2020-08-13 see Changelog

travis_build license jupyter pypi

codecov better_code Maintainability Maintainability Code Coverage snyk

A spec-compliant gitignore parser for Python

forked from https://github.com/mherrmann/gitignore_parser we might join later ….

Suppose /home/michael/project/.gitignore contains the following:

# /home/michael/project/.gitignore
__pycache__/
*.py[cod]

Then:

>>> import igittigitt
>>> parser = igittigitt.IgnoreParser()
>>> parser.parse_rule_file(pathlib.Path('/home/michael/project/.gitignore'))
>>> parser.match(pathlib.Path('/home/michael/project/main.py'))
False
>>> parser.match(pathlib.Path('/home/michael/project/main.pyc'))
True
>>> parser.match(pathlib.Path('/home/michael/project/dir/main.pyc'))
True
>>> parser.match(pathlib.Path('/home/michael/project/__pycache__'))
True

Motivation

I couldn’t find a good library for doing the above on PyPI. There are several other libraries, but they don’t seem to support all features, be it the square brackets in *.py[cod] or top-level paths /….

forked from https://github.com/mherrmann/gitignore_parser because I need to move on faster … we might join the projects again after stabilisation

igittigitt

  • meaning (german):

    often perceived as an exaggeration exclamation of rejection, rejection full of disgust, disgust (mostly used by young children)

  • synonyms:

    ugh, brr, ugh devil, yuck

  • origin

    probably covering for: o God, ogottogott


automated tests, Travis Matrix, Documentation, Badges, etc. are managed with PizzaCutter (cookiecutter on steroids)

Python version required: 3.6.0 or newer

tested on linux “bionic” with python 3.6, 3.7, 3.8, 3.8-dev, pypy3 - architectures: amd64, ppc64le, s390x, arm64

100% code coverage, flake8 style checking ,tested under Linux, macOS, Windows, automatic daily builds and monitoring



Try it Online

You might try it right away in Jupyter Notebook by using the “launch binder” badge, or click here

Usage

  • Ignore Parser

class IgnoreParser(object):
    def __init__(self):
        """
        init the igittigitt parser.
        """
>>> # init as normal Instance
>>> parser = igittigitt.IgnoreParser()
>>> print(parser)
<...IgnoreParser object at ...>

>>> # init with context manager
>>> with igittigitt.IgnoreParser() as parser:
...     print(parser)
<...IgnoreParser object at ...>

Usage from Commandline

Usage: igittigitt [OPTIONS] COMMAND [ARGS]...

  A spec-compliant gitignore parser for Python

Options:
  --version                     Show the version and exit.
  --traceback / --no-traceback  return traceback information on cli
  -h, --help                    Show this message and exit.

Commands:
  info  get program informations

Installation and Upgrade

  • Before You start, its highly recommended to update pip and setup tools:

python -m pip --upgrade pip
python -m pip --upgrade setuptools
  • to install the latest release from PyPi via pip (recommended):

python -m pip install --upgrade igittigitt
  • to install the latest version from github via pip:

python -m pip install --upgrade git+https://github.com/bitranox/igittigitt.git
  • include it into Your requirements.txt:

# Insert following line in Your requirements.txt:
# for the latest Release on pypi:
igittigitt

# for the latest development version :
igittigitt @ git+https://github.com/bitranox/igittigitt.git

# to install and upgrade all modules mentioned in requirements.txt:
python -m pip install --upgrade -r /<path>/requirements.txt
  • to install the latest development version from source code:

# cd ~
$ git clone https://github.com/bitranox/igittigitt.git
$ cd igittigitt
python setup.py install
  • via makefile: makefiles are a very convenient way to install. Here we can do much more, like installing virtual environments, clean caches and so on.

# from Your shell's homedirectory:
$ git clone https://github.com/bitranox/igittigitt.git
$ cd igittigitt

# to run the tests:
$ make test

# to install the package
$ make install

# to clean the package
$ make clean

# uninstall the package
$ make uninstall

Requirements

following modules will be automatically installed :

## Project Requirements
click
cli_exit_tools @ git+https://github.com/bitranox/cli_exit_tools.git

Acknowledgements

  • special thanks to “uncle bob” Robert C. Martin, especially for his books on “clean code” and “clean architecture”

Contribute

I would love for you to fork and send me pull request for this project. - please Contribute

License

This software is licensed under the MIT license

Changelog

  • new MAJOR version for incompatible API changes,

  • new MINOR version for added functionality in a backwards compatible manner

  • new PATCH version for backwards compatible bug fixes

TODO:
  • code coverage

  • test context manager

  • add nested .gitignore files

  • __ALL__= …

  • documentation

  • asserts for __ALL__ parameters

v1.0.0

2020-08-13: change the API interface
  • put parser in a class to keep rules there

  • change tests to pytest

  • start type annotations

  • implement black codestyle

v0.0.1

2020-08-12: initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

igittigitt-1.0.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

igittigitt-1.0.0-py3.8.egg (14.8 kB view details)

Uploaded Egg

igittigitt-1.0.0-py3.7.egg (14.7 kB view details)

Uploaded Egg

igittigitt-1.0.0-py3.6.egg (14.7 kB view details)

Uploaded Egg

igittigitt-1.0.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file igittigitt-1.0.0.tar.gz.

File metadata

  • Download URL: igittigitt-1.0.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10

File hashes

Hashes for igittigitt-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b1dfe8b531be240209fd27dc5ac6eaee21323a72c33e8ed33b3d41c6ec54d3ff
MD5 5a5f352548fbbdff33da71841c01719f
BLAKE2b-256 acd1d9c4fd4f10a8bc046fb168364ab19a3d2f4b35bb8f0fe72040df3d36ca50

See more details on using hashes here.

File details

Details for the file igittigitt-1.0.0-py3.8.egg.

File metadata

  • Download URL: igittigitt-1.0.0-py3.8.egg
  • Upload date:
  • Size: 14.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.1

File hashes

Hashes for igittigitt-1.0.0-py3.8.egg
Algorithm Hash digest
SHA256 0356ed94ef7ec8ff6ab6dbd2cf170f77fb6b8d117f4e8187f0940b3159de65be
MD5 4c1c3b982873b4e9799c4fe94513f44b
BLAKE2b-256 301e3db9462e4452acf8e2831d292d460af0980052e8e6507c0830ec09aacc74

See more details on using hashes here.

File details

Details for the file igittigitt-1.0.0-py3.7.egg.

File metadata

  • Download URL: igittigitt-1.0.0-py3.7.egg
  • Upload date:
  • Size: 14.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.6

File hashes

Hashes for igittigitt-1.0.0-py3.7.egg
Algorithm Hash digest
SHA256 61f8745ed641e7b6b729b6422fae911b6c520b1ab3138f0f44e2f6287c716bc5
MD5 9cf65bcbbb4da645efba546bd8453a66
BLAKE2b-256 40cc742fbe5bfda288a1b34606e28e1bdf1c9922808d3cdff1a758f565695d92

See more details on using hashes here.

File details

Details for the file igittigitt-1.0.0-py3.6.egg.

File metadata

  • Download URL: igittigitt-1.0.0-py3.6.egg
  • Upload date:
  • Size: 14.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10

File hashes

Hashes for igittigitt-1.0.0-py3.6.egg
Algorithm Hash digest
SHA256 1f9ab893a09bbfa2e6cb72bda06569e67126011009c42adbb9c258ada4fd3a45
MD5 48d45484932fef84b9ed0a029373cbff
BLAKE2b-256 d63a99bfcc7a535d9eca5f80b181d1a4dd3f173db0c42d13f07bfa9ca57e4738

See more details on using hashes here.

File details

Details for the file igittigitt-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: igittigitt-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.10

File hashes

Hashes for igittigitt-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 31f283b2e13bb623bb71dafaac57ef99517084e69e0066b37acdc62943168410
MD5 903341769846ed6924df07a2af51f309
BLAKE2b-256 59291d2391eac1ea00fb9cfa241b6f0a58e673d2d0b3eb068bd232c2172317d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page