Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Create python package for linter #39

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions lint/LICENSES
3 changes: 1 addition & 2 deletions lint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ The witness linter can be used to make sure that a given witness conforms to the

The following modules are necessary to use the witness linter:

- lxml
- zlib
- lxml >= 4.6.3

### Usage

Expand Down
12 changes: 12 additions & 0 deletions lint/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of sv-witnesses repository: https://github.com/sosy-lab/sv-witnesses
#
# SPDX-FileCopyrightText: 2021 Dirk Beyer <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0

[build-system]
requires = [
'setuptools >= 42.0.0',
'wheel >= 0.32.0',
]
build-backend = 'setuptools.build_meta'
PhilippWendler marked this conversation as resolved.
Show resolved Hide resolved
29 changes: 29 additions & 0 deletions lint/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is part of sv-witnesses repository: https://github.com/sosy-lab/sv-witnesses
#
# SPDX-FileCopyrightText: 2021 Dirk Beyer <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0

[metadata]
name = sv-witness-lint
version = attr: witnesslint.__version__
author = Dirk Beyer
description = A linter for the sv-witness format
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/sosy-lab/sv-witnesses/tree/main/lint
project_urls =
Bug Tracker = https://github.com/sosy-lab/sv-witnesses/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: Apache Software License
Intended Audience :: Science/Research
Environment :: Console
license = Apache-2.0
license_file = LICENSES/Apache-2.0.txt

SvenUmbricht marked this conversation as resolved.
Show resolved Hide resolved
[options]
packages = witnesslint
python_requires = >=3.5
install_requires =
lxml >= 4.6.3
7 changes: 7 additions & 0 deletions lint/witnesslint/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is part of sv-witnesses repository: https://github.com/sosy-lab/sv-witnesses
#
# SPDX-FileCopyrightText: 2021 Dirk Beyer <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0

__version__ = "DEV"
PhilippWendler marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 3 additions & 6 deletions lint/witnesslint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
[1]: github.com/sosy-lab/sv-witnesses/blob/master/README.md
"""

__version__ = "DEV"

import argparse
import collections
import hashlib
Expand All @@ -21,8 +19,7 @@

from lxml import etree # noqa: S410 does not matter

from . import logger as logging
from . import witness
from witnesslint import witness, __version__, logger as logging

CREATIONTIME_PATTERN = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}([+-]\d{2}:\d{2})?$"

Expand Down Expand Up @@ -945,9 +942,9 @@ def _exit(exit_code=None):
sys.exit(exit_code)


def main(argv):
def main():
PhilippWendler marked this conversation as resolved.
Show resolved Hide resolved
try:
linter = create_linter(argv[1:])
linter = create_linter(sys.argv[1:])
linter.lint()
_exit()
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion lint/witnesslinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
from witnesslint import linter # noqa: E402 raises, but prevents bytecode generation

if __name__ == "__main__":
sys.exit(linter.main(sys.argv))
linter.main()
PhilippWendler marked this conversation as resolved.
Show resolved Hide resolved