pax_global_header00006660000000000000000000000064141745100070014511gustar00rootroot0000000000000052 comment=46d2f6892b1d2501afdd2783f4f023639c14d0e3 ansible-pygments-0.1.1/000077500000000000000000000000001417451000700147715ustar00rootroot00000000000000ansible-pygments-0.1.1/.coveragerc000066400000000000000000000011161417451000700171110ustar00rootroot00000000000000[html] directory = .test-results/pytest/cov/ show_contexts = true skip_covered = false [paths] source = src/ansible_pygments */src/ansible_pygments .tox/*/lib/python*/site-packages/ansible_pygments [report] skip_covered = true show_missing = true exclude_lines = \#\s*pragma: no cover ^\s*raise AssertionError\b ^\s*raise NotImplementedError\b ^\s*return NotImplemented\b ^\s*raise$ ^if __name__ == ['"]__main__['"]:$ [run] branch = true command_line = -m pytest cover_pylib = false parallel = true relative_files = true source = ansible_pygments tests ansible-pygments-0.1.1/.flake8000066400000000000000000000042651417451000700161530ustar00rootroot00000000000000[flake8] # Print the total number of errors: count = true # Don't even try to analyze these: extend-exclude = # No need to traverse egg info dir *.egg-info, # GitHub configs .github, # Cache files of MyPy .mypy_cache, # Cache files of pytest .pytest_cache, # Temp dir of pytest-testmon .tmontmp, # Occasional virtualenv dir .venv # VS Code .vscode, # Temporary build dir build, # This contains sdists and wheels of pylibsshext that we don't want to check dist, # Metadata of `pip wheel` cmd is autogenerated pip-wheel-metadata, # https://wemake-python-stylegui.de/en/latest/pages/usage/formatter.html #format = wemake # IMPORTANT: avoid using ignore option, always use extend-ignore instead # Completely and unconditionally ignore the following errors: extend-ignore = I # flake8-isort is drunk + we have isort integrated into pre-commit WPS300 # "Found local folder import" -- nothing bad about this WPS306 # "Found class without a base class: *" -- we have metaclass shims # Let's not overcomplicate the code: max-complexity = 10 # Accessibility/large fonts and PEP8 friendly: max-line-length = 79 # Allow certain violations in certain files: per-file-ignores = # There are multiple `assert`s (S101) # and subprocesses (import – S404; call – S603) in tests; # also, using fixtures looks like shadowing the outer scope (WPS442); # and finally it's impossible to have <= members in tests (WPS202): tests/**.py: S101, S404, S603, WPS202, WPS442 # The lexer test compares huge HTML snippets that have legit long lines: # E501 line too long tests/lexer_test.py: E501 # Count the number of occurrences of each error/warning code and print a report: statistics = true # flake8-eradicate # E800: eradicate-whitelist-extend = distutils:\s+libraries\s+=\s+|isort:\s+\w+ # flake8-pytest-style # PT001: pytest-fixture-no-parentheses = true # PT006: pytest-parametrize-names-type = tuple # PT007: pytest-parametrize-values-type = tuple pytest-parametrize-values-row-type = tuple # flake8-rst-docstrings rst-roles = # Built-in Sphinx roles: py:class, py:meth, # Sphinx's internal role: event, # wemake-python-styleguide show-source = true ansible-pygments-0.1.1/.github/000077500000000000000000000000001417451000700163315ustar00rootroot00000000000000ansible-pygments-0.1.1/.github/workflows/000077500000000000000000000000001417451000700203665ustar00rootroot00000000000000ansible-pygments-0.1.1/.github/workflows/ci-cd.yml000066400000000000000000000404021417451000700220700ustar00rootroot00000000000000--- name: CI/CD on: push: branches: - main pull_request: branches: - main workflow_dispatch: inputs: release-version: # github.event_name == 'workflow_dispatch' # && github.event.inputs.release-version description: >- Target PEP440-compliant version to release. Please, don't prepend `v`. required: true release-commitish: # github.event_name == 'workflow_dispatch' # && github.event.inputs.release-committish default: '' description: >- The commit to be released to PyPI and tagged in Git as `release-version`. Normally, you should keep this empty. YOLO: default: false description: >- Flag whether test results should block the release (true/false). Only use this under extraordinary circumstances to ignore the test failures and cut the release regardless. # Run once per week (Monday at 06:00 UTC) schedule: - cron: 0 6 * * 1 jobs: lint: name: >- Linters @ py${{ matrix.python-version }} @ ${{ matrix.os }} needs: - pre-setup runs-on: ${{ matrix.os }}-latest strategy: matrix: os: - Ubuntu python-version: - 3.9 env: PY_COLORS: 1 TOXENV: lint TOX_PARALLEL_NO_SPINNER: 1 steps: - name: >- Switch to using Python v${{ matrix.python-version }} by default uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: >- Calculate Python interpreter version hash value for use in the cache key id: calc_cache_key_py run: | from hashlib import sha512 from sys import version hash = sha512(version.encode()).hexdigest() print(f'::set-output name=py_hash_key::{hash}') shell: python - name: Get pip cache dir id: pip-cache run: >- echo "::set-output name=dir::$(pip cache dir)" - name: Set up pip cache uses: actions/cache@v2.1.5 with: path: ${{ steps.pip-cache.outputs.dir }} key: >- ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-${{ needs.pre-setup.outputs.cache_key_files }} restore-keys: | ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}- ${{ runner.os }}-pip- - name: Install tox run: >- python -m pip install --user tox - name: Grab the source from Git uses: actions/checkout@v2 - name: Pre-populate tox env run: >- python -m tox -p auto --parallel-live -vvvv --skip-missing-interpreters false --notest - name: Run linters run: >- python -m tox -p auto --parallel-live -vvvv --skip-missing-interpreters false pre-setup: name: Pre-set global build settings runs-on: ubuntu-latest defaults: run: shell: python outputs: dist_version: >- ${{ steps.tagged_check.outputs.release_requested == 'true' && github.event.inputs.release-version || steps.scm_version.outputs.dist_version }} is_untagged_devel: >- ${{ steps.not_tagged_check.outputs.is_untagged_devel || false }} release_requested: >- ${{ steps.tagged_check.outputs.release_requested || false }} cache_key_files: >- ${{ steps.calc_cache_key_files.outputs.files_hash_key }} git_tag: ${{ steps.git_tag.outputs.tag }} sdist_artifact_name: ${{ steps.artifact_name.outputs.sdist }} wheel_artifact_name: ${{ steps.artifact_name.outputs.wheel }} steps: - name: Switch to using Python 3.9 by default uses: actions/setup-python@v2 with: python-version: 3.9 - name: >- Mark the build as non-tagged ${{ github.event.repository.default_branch }} build id: not_tagged_check if: >- github.event_name == 'push' && github.ref == format( 'refs/heads/{0}', github.event.repository.default_branch ) run: >- print('::set-output name=is_untagged_devel::true') - name: Mark the build as tagged id: tagged_check if: github.event_name == 'workflow_dispatch' run: >- print('::set-output name=release_requested::true') - name: Check out src from Git if: >- steps.tagged_check.outputs.release_requested != 'true' uses: actions/checkout@v2 with: fetch-depth: 0 ref: ${{ github.event.inputs.release-committish }} - name: >- Calculate Python interpreter version hash value for use in the cache key if: >- steps.tagged_check.outputs.release_requested != 'true' id: calc_cache_key_py run: | from hashlib import sha512 from sys import version hash = sha512(version.encode()).hexdigest() print(f'::set-output name=py_hash_key::{hash}') - name: >- Calculate dependency files' combined hash value for use in the cache key if: >- steps.tagged_check.outputs.release_requested != 'true' id: calc_cache_key_files run: | from hashlib import sha512 hashes_combo = sha512('-'.join(( "${{ hashFiles('tox.ini')}}", "${{ hashFiles('pyproject.toml') }}", "${{ hashFiles('.pre-commit-config.yaml') }}", "${{ hashFiles('pytest.ini') }}", )).encode()).hexdigest() print(f'::set-output name=files_hash_key::{hashes_combo}') - name: Set up pip cache if: >- steps.tagged_check.outputs.release_requested != 'true' uses: actions/cache@v2.1.5 with: path: >- ${{ runner.os == 'Linux' && '~/.cache/pip' || '~/Library/Caches/pip' }} key: >- ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-${{ steps.calc_cache_key_files.outputs.files_hash_key }} restore-keys: | ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}- ${{ runner.os }}-pip- ${{ runner.os }}- - name: Drop Git tags from HEAD for non-tag-create events if: >- steps.tagged_check.outputs.release_requested != 'true' run: >- git tag --points-at HEAD | xargs git tag --delete shell: bash - name: Set up versioning prerequisites if: >- steps.tagged_check.outputs.release_requested != 'true' run: >- python -m pip install --user setuptools-scm shell: bash - name: Set the current dist version from Git if: steps.tagged_check.outputs.release_requested != 'true' id: scm_version run: | import setuptools_scm ver = setuptools_scm.get_version( ${{ steps.not_tagged_check.outputs.is_untagged_devel == 'true' && 'local_scheme="no-local-version"' || '' }} ) print('::set-output name=dist_version::{ver}'.format(ver=ver)) - name: Set the target Git tag id: git_tag run: >- print('::set-output name=tag::v${{ steps.tagged_check.outputs.release_requested == 'true' && github.event.inputs.release-version || steps.scm_version.outputs.dist_version }}') - name: Set the expected dist artifact names id: artifact_name run: | print('::set-output name=sdist::ansible-pygments-${{ steps.tagged_check.outputs.release_requested == 'true' && github.event.inputs.release-version || steps.scm_version.outputs.dist_version }}.tar.gz') print('::set-output name=wheel::ansible_pygments-${{ steps.tagged_check.outputs.release_requested == 'true' && github.event.inputs.release-version || steps.scm_version.outputs.dist_version }}-py3-none-any.whl') build: name: >- πŸ— sdist & wheel πŸ“¦ v${{ needs.pre-setup.outputs.dist_version }} needs: - pre-setup runs-on: ubuntu-latest env: PY_COLORS: 1 TOXENV: cleanup-dists,build-dists,metadata-validation TOX_PARALLEL_NO_SPINNER: 1 steps: - name: Switch to using Python 3.9 by default uses: actions/setup-python@v2 with: python-version: 3.9 - name: >- Calculate Python interpreter version hash value for use in the cache key id: calc_cache_key_py run: | from hashlib import sha512 from sys import version hash = sha512(version.encode()).hexdigest() print(f'::set-output name=py_hash_key::{hash}') shell: python - name: Get pip cache dir id: pip-cache run: >- echo "::set-output name=dir::$(pip cache dir)" - name: Set up pip cache uses: actions/cache@v2.1.5 with: path: ${{ steps.pip-cache.outputs.dir }} key: >- ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-${{ needs.pre-setup.outputs.cache_key_files }} restore-keys: | ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}- ${{ runner.os }}-pip- - name: Install tox run: >- python -m pip install --user tox - name: Grab the source from Git uses: actions/checkout@v2 with: ref: ${{ github.event.inputs.release-committish }} - name: >- Update the project version to ${{ needs.pre-setup.outputs.dist_version }}, in-tree run: >- sed -i 's#^\(version\s\+=\s\+\).*#\1"${{ needs.pre-setup.outputs.dist_version }}"#' pyproject.toml - name: Pre-populate tox env run: >- python -m tox -p auto --parallel-live -vvvv --skip-missing-interpreters false --notest - name: Build dists and verify their metadata run: >- python -m tox -p auto --parallel-live -vvvv --skip-missing-interpreters false - name: Store the Python package distributions uses: actions/upload-artifact@v2 with: name: python-package-distributions # NOTE: Exact expected file names are specified here # NOTE: as a safety measure β€” if anything weird ends # NOTE: up being in this dir or not all dists will be # NOTE: produced, this will fail the workflow. path: | dist/${{ needs.pre-setup.outputs.sdist_artifact_name }} dist/${{ needs.pre-setup.outputs.wheel_artifact_name }} retention-days: 4 tests: name: >- 🐍${{ matrix.python-version }} / ${{ matrix.tested-artifact }} @ ${{ matrix.os }} needs: - build - pre-setup # transitive, for accessing settings runs-on: ${{ matrix.os }}-latest strategy: matrix: os: - Ubuntu - macOS - Windows python-version: - 3.9 - pypy-3.7 - 3.6 - 3.8 - 3.7 - 3.10.0-alpha - 3.10.0 - pypy-3.6 tested-artifact: - wheel - sdist exclude: - os: Windows python-version: pypy-3.6 - os: macOS python-version: pypy-3.6 continue-on-error: >- ${{ ( needs.pre-setup.outputs.release_requested == 'true' && !toJSON(github.event.inputs.YOLO) ) && true || false }} env: ARTIFACT_NAME: >- ${{ matrix.tested-artifact == 'wheel' && needs.pre-setup.outputs.wheel_artifact_name || needs.pre-setup.outputs.sdist_artifact_name }} PIP_DISABLE_PIP_VERSION_CHECK: 1 PIP_NO_PYTHON_VERSION_WARNING: 1 PIP_NO_WARN_SCRIPT_LOCATION: 1 PY_COLORS: 1 TOXENV: python TOX_PARALLEL_NO_SPINNER: 1 steps: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: >- Calculate Python interpreter version hash value for use in the cache key id: calc_cache_key_py run: | from hashlib import sha512 from sys import version hash = sha512(version.encode()).hexdigest() print(f'::set-output name=py_hash_key::{hash}') shell: python - name: Get pip cache dir id: pip-cache run: >- echo "::set-output name=dir::$(pip cache dir)" - name: Set up pip cache uses: actions/cache@v2.1.5 with: path: ${{ steps.pip-cache.outputs.dir }} key: >- ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}-${{ needs.pre-setup.outputs.cache_key_files }} restore-keys: | ${{ runner.os }}-pip-${{ steps.calc_cache_key_py.outputs.py_hash_key }}- ${{ runner.os }}-pip- - name: Install tox run: >- python -m pip install --user tox - name: Grab the source from Git uses: actions/checkout@v2 with: ref: ${{ github.event.inputs.release-committish }} - name: Download all the dists uses: actions/download-artifact@v2 with: name: python-package-distributions path: dist/ - name: Pre-populate tox env run: >- python -m tox -p auto --parallel-live -vvvv --skip-missing-interpreters false --notest --installpkg 'dist/${{ env.ARTIFACT_NAME }}' - name: Run tests run: >- python -m tox -p auto --parallel-live -vvvv --skip-missing-interpreters false --skip-pkg-install - name: Send coverage data to Codecov uses: codecov/codecov-action@v1 with: file: .test-results/pytest/cov.xml flags: >- GHA, ${{ runner.os }}, ${{ matrix.python-version }}, ${{ env.ARTIFACT_NAME }} publish: name: Publish πŸπŸ“¦ to (Test)PyPI needs: - pre-setup # transitive, for accessing settings - tests if: >- fromJSON(needs.pre-setup.outputs.is_untagged_devel) || fromJSON(needs.pre-setup.outputs.release_requested) runs-on: ubuntu-latest steps: - name: Check out src from Git if: fromJSON(needs.pre-setup.outputs.release_requested) uses: actions/checkout@v2 with: fetch-depth: 0 - name: Setup git user as [bot] if: fromJSON(needs.pre-setup.outputs.release_requested) run: > git config --local user.email 'github-actions[bot]@users.noreply.github.com' git config --local user.name 'github-actions[bot]' - name: >- Tag the release in the local Git repo as ${{ needs.pre-setup.outputs.git_tag }} if: fromJSON(needs.pre-setup.outputs.release_requested) run: >- git tag '${{ needs.pre-setup.outputs.git_tag }}' ${{ github.event.inputs.release-committish }} - name: Download all the dists uses: actions/download-artifact@v2 with: name: python-package-distributions path: dist/ - name: Publish πŸπŸ“¦ ${{ needs.pre-setup.outputs.git_tag }}to TestPyPI if: >- fromJSON(needs.pre-setup.outputs.is_untagged_devel) || fromJSON(needs.pre-setup.outputs.release_requested) uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.TESTPYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ - name: Publish πŸπŸ“¦ ${{ needs.pre-setup.outputs.git_tag }} to PyPI if: fromJSON(needs.pre-setup.outputs.release_requested) uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} - name: >- Push ${{ needs.pre-setup.outputs.git_tag }} tag corresponding to the just published release back to GitHub if: fromJSON(needs.pre-setup.outputs.release_requested) run: >- git push --atomic origin '${{ needs.pre-setup.outputs.git_tag }}' ... ansible-pygments-0.1.1/.gitignore000066400000000000000000000034611417451000700167650ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover *.py,cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 db.sqlite3-journal # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # IPython profile_default/ ipython_config.py # pyenv .python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. # However, in case of collaboration, if having platform-specific dependencies or dependencies # having no cross-platform support, pipenv may install dependencies that don't work, or not # install all needed dependencies. #Pipfile.lock # PEP 582; used by e.g. github.com/David-OConnor/pyflow __pypackages__/ # Celery stuff celerybeat-schedule celerybeat.pid # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # poetry poetry.lock # Output files *.tar.gz *.in *.build *.deps # pytest + coveragepy reports /.test-results/ ansible-pygments-0.1.1/.pre-commit-config.yaml000066400000000000000000000035601417451000700212560ustar00rootroot00000000000000--- repos: - repo: https://github.com/asottile/add-trailing-comma.git rev: v2.1.0 hooks: - id: add-trailing-comma - repo: https://github.com/PyCQA/isort.git rev: 5.8.0 hooks: - id: isort args: - --honor-noqa - repo: https://github.com/Lucas-C/pre-commit-hooks.git rev: v1.1.10 hooks: - id: remove-tabs - repo: https://github.com/pre-commit/pre-commit-hooks.git rev: v4.0.1 hooks: # Side-effects: - id: end-of-file-fixer - id: requirements-txt-fixer - id: trailing-whitespace - id: mixed-line-ending # Non-modifying checks: - id: name-tests-test files: >- ^tests/[^_].*\.py$ - id: check-added-large-files - id: check-byte-order-marker - id: check-case-conflict - id: check-executables-have-shebangs - id: check-merge-conflict - id: check-json - id: check-symlinks - id: check-yaml - id: detect-private-key # Heavy checks: - id: check-ast - id: debug-statements language_version: python3 - repo: https://github.com/Lucas-C/pre-commit-hooks-markup.git rev: v1.0.1 hooks: - id: rst-linter files: >- ^README\.rst$ - repo: https://github.com/pycqa/pydocstyle.git rev: 6.1.1 hooks: - id: pydocstyle - repo: https://github.com/codespell-project/codespell rev: v2.0.0 hooks: - id: codespell - repo: https://github.com/adrienverge/yamllint.git rev: v1.24.2 hooks: - id: yamllint files: \.(yaml|yml)$ types: - file - yaml args: - --strict - repo: https://github.com/PyCQA/flake8.git rev: 3.9.2 hooks: - id: flake8 additional_dependencies: - flake8-2020>=1.6.0 - flake8-docstrings >= 1.5.0 - flake8-pytest-style>=1.0.0 # - wemake-python-styleguide language_version: python3 - repo: local hooks: - id: pylint language: system name: PyLint files: \.py$ entry: python -m pylint args: [] stages: - manual ... ansible-pygments-0.1.1/.pylintrc000066400000000000000000000452661417451000700166530ustar00rootroot00000000000000[MASTER] # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code. extension-pkg-allow-list= # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code. (This is an alternative name to extension-pkg-allow-list # for backward compatibility.) extension-pkg-whitelist= # Specify a score threshold to be exceeded before program exits with error. fail-under=10.0 # Files or directories to be skipped. They should be base names, not paths. ignore=CVS,.git # Files or directories matching the regex patterns are skipped. The regex # matches against base names, not paths. ignore-patterns= # Python code to execute, usually for sys.path manipulation such as # pygtk.require(). #init-hook= # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the # number of processors available to use. jobs=0 # Control the amount of potential inferred values when inferring a single # object. This can help the performance when dealing with large functions or # complex, nested conditions. limit-inference-results=100 # List of plugins (as comma separated values of python module names) to load, # usually to register additional checkers. load-plugins= # Pickle collected data for later comparisons. persistent=yes # When enabled, pylint would attempt to guess common misconfiguration and emit # user-friendly hints instead of false-positive error messages. suggestion-mode=yes # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no [MESSAGES CONTROL] # Only show warnings with the listed confidence levels. Leave empty to show # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. confidence= # Disable the message, report, category or checker with the given id(s). You # can either give multiple identifiers separated by comma (,) or put this # option multiple times (only on the command line, not in the configuration # file where it should appear only once). You can also use "--disable=all" to # disable everything first and then reenable specific checks. For example, if # you want to run only the similarities checker, you can use "--disable=all # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use "--disable=all --enable=classes # --disable=W". disable=print-statement, parameter-unpacking, unpacking-in-except, old-raise-syntax, backtick, long-suffix, old-ne-operator, old-octal-literal, import-star-module-level, non-ascii-bytes-literal, raw-checker-failed, bad-inline-option, locally-disabled, file-ignored, suppressed-message, useless-suppression, deprecated-pragma, use-symbolic-message-instead, apply-builtin, basestring-builtin, buffer-builtin, cmp-builtin, coerce-builtin, execfile-builtin, file-builtin, long-builtin, raw_input-builtin, reduce-builtin, standarderror-builtin, unicode-builtin, xrange-builtin, coerce-method, delslice-method, getslice-method, setslice-method, no-absolute-import, old-division, dict-iter-method, dict-view-method, next-method-called, metaclass-assignment, indexing-exception, raising-string, reload-builtin, oct-method, hex-method, nonzero-method, cmp-method, input-builtin, round-builtin, intern-builtin, unichr-builtin, map-builtin-not-iterating, zip-builtin-not-iterating, range-builtin-not-iterating, filter-builtin-not-iterating, using-cmp-argument, eq-without-hash, div-method, idiv-method, rdiv-method, exception-message-attribute, invalid-str-codec, sys-max-int, bad-python3-import, deprecated-string-function, deprecated-str-translate-call, deprecated-itertools-function, deprecated-types-field, next-method-defined, dict-items-not-iterating, dict-keys-not-iterating, dict-values-not-iterating, deprecated-operator-function, deprecated-urllib-function, xreadlines-attribute, deprecated-sys-function, exception-escape, comprehension-escape # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option # multiple time (only on the command line, not in the configuration file where # it should appear only once). See also the "--disable" option for examples. enable=c-extension-no-member [REPORTS] # Python expression which should return a score less than or equal to 10. You # have access to the variables 'error', 'warning', 'refactor', and 'convention' # which contain the number of messages in each category, as well as 'statement' # which is the total number of statements analyzed. This score is used by the # global evaluation report (RP0004). evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) # Template used to display messages. This is a python new-style format string # used to format the message information. See doc for all details. #msg-template= # Set the output format. Available formats are text, parseable, colorized, json # and msvs (visual studio). You can also give a reporter class, e.g. # mypackage.mymodule.MyReporterClass. output-format=colorized # Tells whether to display a full report or only the messages. reports=no # Activate the evaluation score. score=yes [REFACTORING] # Maximum number of nested blocks for function / method body max-nested-blocks=5 # Complete name of functions that never returns. When checking for # inconsistent-return-statements if a never returning function is called then # it will be considered as an explicit return statement and no message will be # printed. never-returning-functions=sys.exit,argparse.parse_error [BASIC] # Naming style matching correct argument names. argument-naming-style=snake_case # Regular expression matching correct argument names. Overrides argument- # naming-style. #argument-rgx= # Naming style matching correct attribute names. attr-naming-style=snake_case # Regular expression matching correct attribute names. Overrides attr-naming- # style. #attr-rgx= # Bad variable names which should always be refused, separated by a comma. bad-names=foo, bar, baz, toto, tutu, tata # Bad variable names regexes, separated by a comma. If names match any regex, # they will always be refused bad-names-rgxs= # Naming style matching correct class attribute names. class-attribute-naming-style=any # Regular expression matching correct class attribute names. Overrides class- # attribute-naming-style. #class-attribute-rgx= # Naming style matching correct class constant names. class-const-naming-style=UPPER_CASE # Regular expression matching correct class constant names. Overrides class- # const-naming-style. #class-const-rgx= # Naming style matching correct class names. class-naming-style=PascalCase # Regular expression matching correct class names. Overrides class-naming- # style. #class-rgx= # Naming style matching correct constant names. const-naming-style=UPPER_CASE # Regular expression matching correct constant names. Overrides const-naming- # style. #const-rgx= # Minimum line length for functions/classes that require docstrings, shorter # ones are exempt. docstring-min-length=-1 # Naming style matching correct function names. function-naming-style=snake_case # Regular expression matching correct function names. Overrides function- # naming-style. #function-rgx= # Good variable names which should always be accepted, separated by a comma. good-names=i, j, k, ex, Run, _ # Good variable names regexes, separated by a comma. If names match any regex, # they will always be accepted good-names-rgxs= # Include a hint for the correct naming format with invalid-name. include-naming-hint=no # Naming style matching correct inline iteration names. inlinevar-naming-style=any # Regular expression matching correct inline iteration names. Overrides # inlinevar-naming-style. #inlinevar-rgx= # Naming style matching correct method names. method-naming-style=snake_case # Regular expression matching correct method names. Overrides method-naming- # style. #method-rgx= # Naming style matching correct module names. module-naming-style=snake_case # Regular expression matching correct module names. Overrides module-naming- # style. #module-rgx= # Colon-delimited sets of names that determine each other's naming style when # the name regexes allow several styles. name-group= # Regular expression which should only match function or class names that do # not require a docstring. no-docstring-rgx=^_ # List of decorators that produce properties, such as abc.abstractproperty. Add # to this list to register other decorators that produce valid properties. # These decorators are taken in consideration only for invalid-name. property-classes=abc.abstractproperty # Naming style matching correct variable names. variable-naming-style=snake_case # Regular expression matching correct variable names. Overrides variable- # naming-style. #variable-rgx= [FORMAT] # Expected format of line ending, e.g. empty (any line ending), LF or CRLF. expected-line-ending-format= # Regexp for a line that is allowed to be longer than the limit. ignore-long-lines=^\s*(# )??$ # Number of spaces of indent required inside a hanging or continued line. indent-after-paren=4 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 # tab). indent-string=' ' # Maximum number of characters on a single line. max-line-length=100 # Maximum number of lines in a module. max-module-lines=1000 # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no # Allow the body of an if to be on the same line as the test if there is no # else. single-line-if-stmt=no [LOGGING] # The type of string formatting that logging methods do. `old` means using % # formatting, `new` is for `{}` formatting. logging-format-style=old # Logging modules to check that the string format arguments are in logging # function parameter format. logging-modules=logging [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. notes=FIXME, XXX, TODO # Regular expression of note tags to take in consideration. #notes-rgx= [SIMILARITIES] # Ignore comments when computing similarities. ignore-comments=yes # Ignore docstrings when computing similarities. ignore-docstrings=yes # Ignore imports when computing similarities. ignore-imports=no # Minimum lines number of a similarity. min-similarity-lines=4 [SPELLING] # Limits count of emitted suggestions for spelling mistakes. max-spelling-suggestions=4 # Spelling dictionary name. Available dictionaries: none. To make it work, # install the 'python-enchant' package. spelling-dict= # List of comma separated words that should be considered directives if they # appear and the beginning of a comment and should not be checked. spelling-ignore-comment-directives=fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy: # List of comma separated words that should not be checked. spelling-ignore-words= # A path to a file that contains the private dictionary; one word per line. spelling-private-dict-file= # Tells whether to store unknown words to the private dictionary (see the # --spelling-private-dict-file option) instead of raising a message. spelling-store-unknown-words=no [STRING] # This flag controls whether inconsistent-quotes generates a warning when the # character used as a quote delimiter is used inconsistently within a module. check-quote-consistency=no # This flag controls whether the implicit-str-concat should generate a warning # on implicit string concatenation in sequences defined over several lines. check-str-concat-over-line-jumps=no [TYPECHECK] # List of decorators that produce context managers, such as # contextlib.contextmanager. Add to this list to register other decorators that # produce valid context managers. contextmanager-decorators=contextlib.contextmanager # List of members which are set dynamically and missed by pylint inference # system, and so shouldn't trigger E1101 when accessed. Python regular # expressions are accepted. generated-members=pygments.formatters # Tells whether missing members accessed in mixin class should be ignored. A # mixin class is detected if its name ends with "mixin" (case insensitive). ignore-mixin-members=yes # Tells whether to warn about missing members when the owner of the attribute # is inferred to be None. ignore-none=yes # This flag controls whether pylint should warn about no-member and similar # checks whenever an opaque object is returned when inferring. The inference # can return multiple potential results while evaluating a Python object, but # some branches might not be evaluated, which results in partial inference. In # that case, it might be useful to still emit no-member and other checks for # the rest of the inferred objects. ignore-on-opaque-inference=yes # List of class names for which member attributes should not be checked (useful # for classes with dynamically set attributes). This supports the use of # qualified names. ignored-classes=optparse.Values,thread._local,_thread._local # List of module names for which member attributes should not be checked # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis). It # supports qualified module names, as well as Unix pattern matching. ignored-modules= # Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. missing-member-hint=yes # The minimum edit distance a name should have in order to be considered a # similar match for a missing member name. missing-member-hint-distance=1 # The total number of similar names that should be taken in consideration when # showing a hint for a missing member. missing-member-max-choices=1 # List of decorators that change the signature of a decorated function. signature-mutators= [VARIABLES] # List of additional names supposed to be defined in builtins. Remember that # you should avoid defining new builtins when possible. additional-builtins= # Tells whether unused global variables should be treated as a violation. allow-global-unused-variables=yes # List of names allowed to shadow builtins allowed-redefined-builtins= # List of strings which can identify a callback function by name. A callback # name must start or end with one of those strings. callbacks=cb_, _cb # A regular expression matching the name of dummy variables (i.e. expected to # not be used). dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ # Argument names that match this expression will be ignored. Default to name # with leading underscore. ignored-argument-names=_.*|^ignored_|^unused_ # Tells whether we should check for unused import in __init__ files. init-import=no # List of qualified module names which can have objects that can redefine # builtins. redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io [CLASSES] # Warn about protected attribute access inside special methods check-protected-access-in-special-methods=no # List of method names used to declare (i.e. assign) instance attributes. defining-attr-methods=__init__, __new__, setUp, __post_init__ # List of member names, which should be excluded from the protected access # warning. exclude-protected=_asdict, _fields, _replace, _source, _make # List of valid names for the first argument in a class method. valid-classmethod-first-arg=cls # List of valid names for the first argument in a metaclass class method. valid-metaclass-classmethod-first-arg=cls [DESIGN] # Maximum number of arguments for function / method. max-args=5 # Maximum number of attributes for a class (see R0902). max-attributes=7 # Maximum number of boolean expressions in an if statement (see R0916). max-bool-expr=5 # Maximum number of branch for function / method body. max-branches=12 # Maximum number of locals for function / method body. max-locals=15 # Maximum number of parents for a class (see R0901). max-parents=7 # Maximum number of public methods for a class (see R0904). max-public-methods=20 # Maximum number of return / yield for function / method body. max-returns=6 # Maximum number of statements in function / method body. max-statements=50 # Minimum number of public methods for a class (see R0903). min-public-methods=2 [IMPORTS] # List of modules that can be imported at any level, not just the top level # one. allow-any-import-level= # Allow wildcard imports from modules that define __all__. allow-wildcard-with-all=no # Analyse import fallback blocks. This can be used to support both Python 2 and # 3 compatible code, which means that the block might have code that exists # only in one or another interpreter, leading to false positives when analysed. analyse-fallback-blocks=no # Deprecated modules which should not be used, separated by a comma. deprecated-modules=optparse,tkinter.tix # Output a graph (.gv or any supported image format) of external dependencies # to the given file (report RP0402 must not be disabled). ext-import-graph= # Output a graph (.gv or any supported image format) of all (i.e. internal and # external) dependencies to the given file (report RP0402 must not be # disabled). import-graph= # Output a graph (.gv or any supported image format) of internal dependencies # to the given file (report RP0402 must not be disabled). int-import-graph= # Force import order to recognize a module as part of the standard # compatibility libraries. known-standard-library= # Force import order to recognize a module as part of a third party library. known-third-party=enchant # Couples of modules and preferred modules, separated by a comma. preferred-modules= [EXCEPTIONS] # Exceptions that will emit a warning when being caught. Defaults to # "BaseException, Exception". overgeneral-exceptions=BaseException, Exception ansible-pygments-0.1.1/.yamllint000066400000000000000000000003221417451000700166200ustar00rootroot00000000000000extends: default rules: indentation: indent-sequences: false level: error truthy: allowed-values: - 'true' - 'false' - 'on' # Allow "on" key name in GHA CI/CD workflow definitions ansible-pygments-0.1.1/LICENSE.md000066400000000000000000000027631417451000700164050ustar00rootroot00000000000000_Copyright 2019-2021 by Ansible Community._ _Parts copyrighted 2006-2017 by the Pygments team, see AUTHORS at https://github.com/pygments/pygments/blob/3e1b79c82d2df318f63f24984d875fd2a3400808/AUTHORS._ _Parts copyrighted by Norman Richards (original author of JSON lexer)._ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS β€œAS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ansible-pygments-0.1.1/README.md000066400000000000000000000032251417451000700162520ustar00rootroot00000000000000# [Pygments] lexer and style Ansible snippets [![GitHub Actions CI/CD workflow](https://github.com/ansible-community/ansible-pygments/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/ansible-community/ansible-pygments/actions/workflows/ci-cd.yml) [![Codecov badge](https://img.shields.io/codecov/c/github/ansible-community/ansible-pygments)](https://codecov.io/gh/ansible-community/ansible-pygments) This project provides a [Pygments] lexer that is able to handle [Ansible] output. It may be used anywhere Pygments is integrated. The lexer is registered globally under the name `ansible-output`. It also provides a [Pygments] style for tools needing to highlight code snippets. The code is licensed under the terms of the [BSD 2-Clause license]. ## Using the lexer in [Sphinx] Make sure this library in installed in the same env as your [Sphinx] automation via `pip install ansible-pygments sphinx`. Then, you should be able to use a lexer by its name `ansible-output` in the code blocks of your RST documents. For example: ```rst .. code-block:: ansible-output [WARNING]: Unable to find '/nosuchfile' in expected paths (use -vvvvv to see paths) ok: [localhost] => { "msg": "" } ``` ## Using the style in [Sphinx] It is possible to just set `ansible` in `conf.py` and it will "just work", provided that this project is installed alongside [Sphinx] as shown above. ```python pygments_style = 'ansible' ``` [Ansible]: https://www.ansible.com/?utm_medium=github-or-pypi&utm_source=ansible-pygments--readme [Pygments]: https://pygments.org [Sphinx]: https://www.sphinx-doc.org [BSD 2-Clause license]: https://opensource.org/licenses/BSD-2-Clause ansible-pygments-0.1.1/lint-flake8.sh000077500000000000000000000001561417451000700174500ustar00rootroot00000000000000#!/bin/bash set -e poetry run flake8 src/ --count --max-complexity=10 --max-line-length=100 --statistics "$@" ansible-pygments-0.1.1/lint-pylint.sh000077500000000000000000000000571417451000700176150ustar00rootroot00000000000000#!/bin/bash set -e poetry run pylint src/ "$@" ansible-pygments-0.1.1/pyproject.toml000066400000000000000000000034611417451000700177110ustar00rootroot00000000000000[build-system] requires = ["poetry-core>=1.0.7"] build-backend = "poetry.core.masonry.api" [tool.poetry] name = "ansible-pygments" version = "0.1.1" description = "Tools for building the Ansible Distribution" authors = ["Felix Fontein "] license = "BSD-2-Clause" readme = "README.md" repository = "https://github.com/ansible-community/ansible-pygments" packages = [ { include = "ansible_pygments", from = "src" }, { include = "tests", format = "sdist" } ] classifiers = [ "Development Status :: 6 - Mature", "Intended Audience :: Developers" ] [tool.poetry.urls] "Mailing lists" = "https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information" "Code of Conduct" = "https://docs.ansible.com/ansible/latest/community/code_of_conduct.html" "CI: GitHub" = "https://github.com/ansible-community/ansible-pygments/actions?branch:main+event:push" "CI: CodeCov" = "https://app.codecov.io/gh/ansible-community/ansible-pygments" "Bug tracker" = "https://github.com/ansible-community/ansible-pygments/issues" [tool.poetry.plugins."pygments.lexers"] Ansible-output = "ansible_pygments.lexers:AnsibleOutputLexer" ansible-output = "ansible_pygments.lexers:AnsibleOutputLexer" [tool.poetry.plugins."pygments.styles"] Ansible = "ansible_pygments.styles:AnsibleStyle" ansible = "ansible_pygments.styles:AnsibleStyle" [tool.poetry.dependencies] python = "^3.6.0" # Pygments 2.4.0 includes bugfixes for YAML and YAML+Jinja lexers pygments = ">= 2.4.0" [tool.poetry.dev-dependencies] codecov = "*" flake8 = ">= 3.8.0" pylint = "*" pytest = "*" pytest-cov = "*" [tool.isort] balanced_wrapping = true include_trailing_comma = true indent = 4 # Should be: 80 - 1 line_length = 79 # https://github.com/timothycrosley/isort#multi-line-output-modes multi_line_output = 5 use_parentheses = true ansible-pygments-0.1.1/pytest.ini000066400000000000000000000031771417451000700170320ustar00rootroot00000000000000[pytest] addopts = # `pytest-xdist` == -n auto: # --numprocesses=auto # Show 10 slowest invocations: --durations=10 # A bit of verbosity doesn't hurt: -v # Report all the things == -rxXs: -ra # Show local variables in tracebacks --showlocals # Autocollect and invoke the doctests from all modules: # https://docs.pytest.org/en/stable/doctest.html --doctest-modules --junitxml=.test-results/pytest/results.xml # Fail on non-existing markers: # * Deprecated since v6.2.0 but may be reintroduced later covering a # broader scope: # --strict # * Exists since v4.5.0 (advised to be used instead of `--strict`): --strict-markers # Fail on any config parsing warnings: # * Exists since v6.0.0rc1 --strict-config # `pytest-cov`: -p pytest_cov --no-cov-on-fail --cov=ansible_pygments --cov=src/ --cov=tests/ --cov-branch --cov-report=term-missing:skip-covered --cov-report=html:.test-results/pytest/cov/ --cov-report=xml:.test-results/pytest/cov.xml --cov-context=test --cov-config=.coveragerc doctest_optionflags = ALLOW_UNICODE ELLIPSIS # Marks tests with an empty parameterset as xfail(run=False) empty_parameter_set_mark = xfail faulthandler_timeout = 30 filterwarnings = error # https://docs.pytest.org/en/stable/usage.html#creating-junitxml-format-files junit_duration_report = call junit_family = xunit2 junit_logging = all junit_log_passing_tests = true junit_suite_name = ansible_pygments_test_suite minversion = 6.2.0 norecursedirs = build dist docs src/ansible_pygments.egg-info .cache .eggs .git .github .tox *.egg testpaths = tests/ xfail_strict = true ansible-pygments-0.1.1/src/000077500000000000000000000000001417451000700155605ustar00rootroot00000000000000ansible-pygments-0.1.1/src/ansible_pygments/000077500000000000000000000000001417451000700211235ustar00rootroot00000000000000ansible-pygments-0.1.1/src/ansible_pygments/__init__.py000066400000000000000000000001101417451000700232240ustar00rootroot00000000000000"""Pygments entities for highlighting and tokenizing Ansible things.""" ansible-pygments-0.1.1/src/ansible_pygments/lexers.py000066400000000000000000000163111417451000700230010ustar00rootroot00000000000000# Copyright 2019-2021 by Felix Fontein # # Copyright 2006-2017 by the Pygments team, see AUTHORS at # https://github.com/pygments/pygments/blob/3e1b79c8/AUTHORS # Copyright by Norman Richards (original author of JSON lexer). # # Licensed under BSD license: # # Copyright (c) 2006-2017 by the respective authors (see AUTHORS file). # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Pygments lexers for ansible console output.""" # pylint: disable=consider-using-f-string from pygments import token from pygments.lexer import DelegatingLexer, RegexLexer, bygroups, include from pygments.lexers import DiffLexer # pylint: disable=no-name-in-module class AnsibleOutputPrimaryLexer(RegexLexer): """Primary lexer for Ansible output.""" name = 'Ansible-output-primary' # The following definitions are borrowed from Pygment's JSON lexer. # It has been originally authored by Norman Richards. # integer part of a number int_part = r'-?(0|[1-9]\d*)' # fractional part of a number frac_part = r'\.\d+' # exponential part of a number exp_part = r'[eE](\+|-)?\d+' tokens = { # ######################################### # # BEGIN: states from JSON lexer ######### # ######################################### 'whitespace': [ (r'\s+', token.Text), ], # represents a simple terminal value 'simplevalue': [ (r'(true|false|null)\b', token.Keyword.Constant), ( ( '%(int_part)s(%(frac_part)s%(exp_part)s|' '%(exp_part)s|%(frac_part)s)' ) % vars(), token.Number.Float, ), (int_part, token.Number.Integer), (r'"(\\\\|\\"|[^"])*"', token.String), ], # the right hand side of an object, after the attribute name 'objectattribute': [ include('value'), (r':', token.Punctuation), # comma terminates the attribute but expects more (r',', token.Punctuation, '#pop'), # a closing bracket terminates the entire object, so pop twice (r'\}', token.Punctuation, '#pop:2'), ], # a json object - { attr, attr, ... } 'objectvalue': [ include('whitespace'), (r'"(\\\\|\\"|[^"])*"', token.Name.Tag, 'objectattribute'), (r'\}', token.Punctuation, '#pop'), ], # json array - [ value, value, ... ] 'arrayvalue': [ include('whitespace'), include('value'), (r',', token.Punctuation), (r'\]', token.Punctuation, '#pop'), ], # NOTE: This is a JSON value - either a simple value or a complex # NOTE: value (object or array): 'value': [ include('whitespace'), include('simplevalue'), (r'\{', token.Punctuation, 'objectvalue'), (r'\[', token.Punctuation, 'arrayvalue'), ], # ######################################### # # END: states from JSON lexer ########### # ######################################### 'host-postfix': [ (r'\n', token.Text, '#pop:3'), ( r'( )(=>)( )(\{)', bygroups( token.Text, token.Punctuation, token.Text, token.Punctuation, ), 'objectvalue', ), ], 'host-error': [ ( r'(?:(:)( )(UNREACHABLE|FAILED)(!))?', bygroups( token.Punctuation, token.Text, token.Keyword, token.Punctuation, ), 'host-postfix', ), (r'', token.Text, 'host-postfix'), ], 'host-name': [ ( r'(\[)([^ \]]+)(?:( )(=>)( )([^\]]+))?(\])', bygroups( token.Punctuation, token.Name.Variable, token.Text, token.Punctuation, token.Text, token.Name.Variable, token.Punctuation, ), 'host-error', ), ], 'host-result': [ (r'\n', token.Text, '#pop'), ( ( r'( +)(ok|changed|failed|skipped' r'|unreachable|rescued|ignored)(=)([0-9]+)' ), bygroups( token.Text, token.Keyword, token.Punctuation, token.Number.Integer, ), ), ], 'root': [ ( r'(PLAY|TASK|PLAY RECAP)(?:( )(\[)([^\]]+)(\]))?( )(\*+)(\n)', bygroups( token.Keyword, token.Text, token.Punctuation, token.Literal, token.Punctuation, token.Text, token.Name.Variable, token.Text, ), ), ( r'(fatal|ok|changed|skipping)(:)( )', bygroups(token.Keyword, token.Punctuation, token.Text), 'host-name', ), ( r'(\[)(WARNING)(\]:)([^\n]+)', bygroups( token.Punctuation, token.Keyword, token.Punctuation, token.Text, ), ), ( r'([^ ]+)( +)(:)', bygroups(token.Name, token.Text, token.Punctuation), 'host-result', ), ( r'(\tto retry, use: )(.*)(\n)', bygroups(token.Text, token.Literal.String, token.Text), ), (r'.*\n', token.Other), ], } class AnsibleOutputLexer(DelegatingLexer): """The Ansible output Pygments lexer.""" name = 'Ansible-output' aliases = ('ansible-output',) def __init__(self, **options): """Initialize the lexer with delegation.""" super().__init__(DiffLexer, AnsibleOutputPrimaryLexer, **options) ansible-pygments-0.1.1/src/ansible_pygments/styles.py000066400000000000000000000110361417451000700230210ustar00rootroot00000000000000"""Pygments styles for highlighting snippets in Ansible ecosystem.""" from pygments.style import Style from pygments.token import ( Comment, Error, Generic, Keyword, Literal, Name, Number, Operator, Punctuation, Whitespace, ) class AnsibleStyle(Style): # pylint: disable=too-few-public-methods """Ansible's GitHub-like highlighting.""" background_color = "#f8f8f8" # class: '.highlight' highlight_color = ( "#ffffcc; " "border: 1px solid #edff00; " "padding-top: 2px; " "border-radius: 3px; " "display: block" ) default_style = "" styles = { Error: "#a61717 bg:#e3d2d2 border:#FF0000", # class: 'err' # Error: "#a61717 bg:#e3d2d2 border:1px solid #FF0000", # class: 'err' Comment: "italic #6a737d", # class: 'c' Comment.Preproc: "noitalic #007020", # class: 'cp' Comment.PreprocFile: "italic #6a737d", # class: 'cpf' Comment.Hashbang: "italic #6a737d", # class: 'ch' Comment.Multiline: "italic #6a737d", # class: 'cm' Comment.Single: "italic #6a737d", # class: 'c1' Comment.Special: "bold italic #999999 bg:#fff0f0", # class: 'cs' Keyword: "bold #007020", # class: 'k' Keyword.Constant: "bold #007020", # class: 'kc' Keyword.Declaration: "bold #007020", # class: 'kd' Keyword.Namespace: "bold #007020", # class: 'kn' Keyword.Pseudo: "#007020", # class: 'kp' Keyword.Reserved: "bold #007020", # class: 'kr' Keyword.Type: "#902000", # class: 'kt' Operator: "bold #666666", # class: 'o' Operator.Word: "bold #007020", # class: 'ow' # FIXME: Indicator? pylint: disable=fixme Punctuation: "bold", # class: 'p' Name: "#333333", # class: 'n' Name.Attribute: "#008080", # class: 'na' Name.Builtin: "#0086b3", # class: 'nb' Name.Class: "bold #445588", # class: 'nc' Name.Constant: "#008080", # class: 'no' Name.Decorator: "bold #555555", # class: 'nd' Name.Entity: "bold #800080", # class: 'ni' Name.Exception: "bold #990000", # class: 'ne' Name.Function: "bold #990000", # class: 'nf' Name.Label: "bold #002070", # class: 'nl' Name.Namespace: "bold #555555", # class: 'nn' Name.Tag: "bold #22863a", # class: 'nt' Name.Variable: "bold #9960b5", # class: 'nv' Name.Builtin.Pseudo: "#999999", # class: 'bp' Name.Function.Magic: "#06287e", # class: 'fm' Name.Variable.Class: "#008080", # class: 'vc' Name.Variable.Global: "#008080", # class: 'vg' Name.Variable.Instance: "#008080", # class: 'vi' Name.Variable.Magic: "#bb60d5", # class: 'vm' # FIXME: Literal.Number? pylint: disable=fixme Number: "#208050", # class: 'm' Literal: "#032f62", # class: 'l' Literal.String: "#4070a0", # class: 's' Literal.Number.Bin: "#009999", # class: 'mb' Literal.Number.Float: "#009999", # class: 'mf' Literal.Number.Hex: "#009999", # class: 'mh' Literal.Number.Integer: "#009999", # class: 'mi' Literal.Number.Oct: "#009999", # class: 'mo' Literal.String.Affix: "#dd1144", # class: 'sa' Literal.String.Backtick: "#dd1144", # class: 'sb' Literal.String.Char: "#dd1144", # class: 'sc' Literal.String.Delimiter: "#dd1144", # class: 'dl' Literal.String.Doc: "italic #dd1144", # class: 'sd' Literal.String.Double: "#dd1144", # class: 's2' Literal.String.Escape: "bold #dd1144", # class: 'se' Literal.String.Heredoc: "#dd1144", # class: 'sh' Literal.String.Interpol: "italic #dd1144", # class: 'si' Literal.String.Other: "#dd1144", # class: 'sx' Literal.String.Regex: "#009926", # class: 'sr' Literal.String.Single: "#dd1144", # class: 's1' Literal.String.Symbol: "#990073", # class: 'ss' Literal.Number.Integer.Long: "#009999", # class: 'il' Generic.Deleted: "#A00000 bg:#ffdddd", # class: 'gd' Generic.Emph: "italic", # class: 'ge' Generic.Error: "#aa0000", # class: 'gr' Generic.Heading: "bold #000080", # class: 'gh' Generic.Inserted: "#00A000 bg:#ddffdd", # class: 'gi' Generic.Output: "#333333", # class: 'go' Generic.Prompt: "bold #c65d09", # class: 'gp' Generic.Strong: "bold", # class: 'gs' Generic.Subheading: "bold #800080", # class: 'gu' Generic.Traceback: "#0040D0", # class: 'gt' Whitespace: "#bbbbbb", # class: 'w' } ansible-pygments-0.1.1/test-pytest.sh000077500000000000000000000001561417451000700176370ustar00rootroot00000000000000#!/bin/sh set -e poetry run python -m pytest --cov-branch --cov=src/ --cov-report term-missing -vv tests "$@" ansible-pygments-0.1.1/tests/000077500000000000000000000000001417451000700161335ustar00rootroot00000000000000ansible-pygments-0.1.1/tests/lexer_test.py000066400000000000000000000136641417451000700206750ustar00rootroot00000000000000# Author: Felix Fontein # License: BSD-2-Clause # Copyright: Felix Fontein , 2021 """Tests for Pygments lexers.""" from pygments import highlight # pylint: disable=no-name-in-module # Ref: https://github.com/PyCQA/pylint/issues/491 from pygments.formatters import HtmlFormatter from ansible_pygments.lexers import AnsibleOutputLexer def run_test(data, lexer): """Format the data snippet as HTML using a given lexer.""" formatter = HtmlFormatter() result = highlight(data, lexer, formatter) return formatter.get_style_defs('.highlight'), result def test_ansible_output_lexer(): """Test that AnsibleOutputLexer produces expected HTML output.""" data = R""" ok: [windows] => { "account": { "account_name": "vagrant-domain", "type": "User" }, "authentication_package": "Kerberos", "user_flags": [] } TASK [paused] ************************************************************************************************************************************ Sunday 11 November 2018 20:16:48 +0100 (0:00:00.041) 0:07:59.637 ******* --- before +++ after @@ -1,5 +1,5 @@ { - "exists": false, - "paused": false, - "running": false + "exists": true, + "paused": true, + "running": true } \ No newline at end of file changed: [localhost] TASK [volumes (more volumes)] ******************************************************************************************************************** Sunday 11 November 2018 20:19:25 +0100 (0:00:00.607) 0:10:36.974 ******* --- before +++ after @@ -1,11 +1,11 @@ { "expected_binds": [ - "/tmp:/tmp:rw", - "/:/whatever:rw,z" + "/tmp:/somewhereelse:ro,Z", + "/tmp:/tmp:rw" ], "expected_volumes": { - "/tmp": {}, - "/whatever": {} + "/somewhereelse": {}, + "/tmp": {} }, "running": true } \ No newline at end of file changed: [localhost] """ _, result = run_test(data, AnsibleOutputLexer()) print(result) # pylint: disable=line-too-long assert result == R"""
ok: [windows] => {
    "account": {
        "account_name": "vagrant-domain",
        "type": "User"
    },
    "authentication_package": "Kerberos",
    "user_flags": []
}

TASK [paused] ************************************************************************************************************************************
Sunday 11 November 2018  20:16:48 +0100 (0:00:00.041)       0:07:59.637 *******
--- before
+++ after
@@ -1,5 +1,5 @@
 {
-  "exists": false,
-  "paused": false,
-  "running": false
+  "exists": true,
+  "paused": true,
+  "running": true
 }
\ No newline at end of file

changed: [localhost]

TASK [volumes (more volumes)] ********************************************************************************************************************
Sunday 11 November 2018  20:19:25 +0100 (0:00:00.607)       0:10:36.974 *******
--- before
+++ after
@@ -1,11 +1,11 @@
 {
   "expected_binds": [
-    "/tmp:/tmp:rw",
-    "/:/whatever:rw,z"
+    "/tmp:/somewhereelse:ro,Z",
+    "/tmp:/tmp:rw"
   ],
   "expected_volumes": {
-    "/tmp": {},
-    "/whatever": {}
+    "/somewhereelse": {},
+    "/tmp": {}
   },
   "running": true
 }
\ No newline at end of file

changed: [localhost]
""" ansible-pygments-0.1.1/tox.ini000066400000000000000000000036111417451000700163050ustar00rootroot00000000000000[tox] envlist = python isolated_build = true minversion = 3.23.0 [testenv] description = Run test suite commands = {envpython} -m \ pytest \ {tty:--color=yes} \ --cov-config={toxinidir}/.coveragerc \ --cov={envsitepackagesdir}/ansible_pygments \ {posargs:} deps = pytest pytest-cov # pytest-xdist isolated_build = true usedevelop = false [testenv:cleanup-dists] description = Wipe the the dist{/} folder usedevelop = false skip_install = true deps = commands = {envpython} -c \ "import shutil, sys; \ shutil.rmtree(sys.argv[1], ignore_errors=True)" \ {toxinidir}{/}dist{/} [testenv:build-dists] description = Build dists and put them into the dist{/} folder depends = cleanup-dists isolated_build = true # `usedevelop = true` overrides `skip_install` instruction, it's unwanted usedevelop = false skip_install = true deps = build >= 0.4.0, < 0.5.0 passenv = PEP517_BUILD_ARGS commands = {envpython} -m build \ --outdir '{toxinidir}{/}dist{/}' \ {posargs:{env:PEP517_BUILD_ARGS:--sdist --wheel}} \ '{toxinidir}' [testenv:metadata-validation] description = Verify that dists under the dist{/} dir have valid metadata depends = build-dists deps = twine usedevelop = false skip_install = true commands = twine check {toxinidir}{/}dist{/}* [testenv:lint] description = Run the quality checks commands = {envpython} -m \ pre_commit run \ --show-diff-on-failure \ --hook-stage manual \ {posargs:--all-files} # Print out the advice on how to install pre-commit from this env into Git: -{envpython} -c \ 'cmd = "{envpython} -m pre_commit install"; \ scr_width = len(cmd) + 10; sep = "=" * scr_width; \ cmd_str = " $ " + cmd; \ print(\ "\n" + sep + "\nTo install pre-commit hooks into the Git repo, run:\n\n" + \ cmd_str + "\n\n" + sep + "\n"\ )' deps = pre-commit >= 2.6.0 pylint >= 2.5.3 isolated_build = true