-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8bddcbf
Showing
14 changed files
with
521 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This file is part of aptscan | ||
# https://github.com/scorphus/aptscan | ||
|
||
# Licensed under the BSD-3-Clause license: | ||
# https://opensource.org/licenses/BSD-3-Clause | ||
# Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
|
||
# EditorConfig is awesome! Check https://EditorConfig.org. It helps developers | ||
# define and maintain consistent coding styles between different editors/IDEs. | ||
|
||
# top-most EditorConfig file (no other file in a parent directory will be used) | ||
root = true | ||
|
||
# For all file types | ||
[*] | ||
end_of_line = lf # Unix-style newlines | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
# Default charset | ||
charset = utf-8 | ||
|
||
# Default indent style and size | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This file is part of aptscan | ||
# https://github.com/scorphus/aptscan | ||
|
||
# Licensed under the BSD-3-Clause license: | ||
# https://opensource.org/licenses/BSD-3-Clause | ||
# Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
|
||
name: Python | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
id: deps_cache | ||
with: | ||
path: | | ||
${{ env.pythonLocation}}/lib/*/site-packages/* | ||
${{ env.pythonLocation}}/bin/* | ||
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-${{ matrix.python-version }}- | ||
${{ runner.os }}-pip- | ||
${{ runner.os }}- | ||
- name: Install package and dependencies | ||
run: make setup-ci | ||
- name: Run tests | ||
run: make test | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
if: matrix.python-version == '3.12' | ||
- name: Run linters and check formatting | ||
if: matrix.python-version == '3.12' | ||
run: make lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This file is part of aptscan | ||
# https://github.com/scorphus/aptscan | ||
|
||
# Licensed under the BSD-3-Clause license: | ||
# https://opensource.org/licenses/BSD-3-Clause | ||
# Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.3.0 | ||
hooks: | ||
- id: check-executables-have-shebangs | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-symlinks | ||
- id: check-vcs-permalinks | ||
- id: check-yaml | ||
args: ['--unsafe'] | ||
- id: end-of-file-fixer | ||
types: [non-executable, file, text] | ||
exclude_types: [markdown] | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
types: [non-executable, file, text] | ||
exclude_types: [markdown] | ||
- repo: meta | ||
hooks: | ||
- id: check-useless-excludes | ||
- repo: local | ||
hooks: | ||
- id: isort | ||
name: isort | ||
language: system | ||
entry: isort | ||
types: [python] | ||
require_serial: true | ||
- id: pylint | ||
name: pylint | ||
files: ^tracytracker/ | ||
language: system | ||
entry: pylint | ||
types: [python] | ||
require_serial: true | ||
- id: pylint-tests | ||
name: pylint-tests | ||
files: ^tests/ | ||
language: system | ||
entry: pylint --rc-file tests/pylintrc | ||
types: [python] | ||
require_serial: true | ||
- id: black | ||
name: black | ||
language: system | ||
entry: black | ||
types: [python] | ||
require_serial: true | ||
- id: test | ||
name: test | ||
language: system | ||
entry: make test | ||
types: [python] | ||
pass_filenames: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
All rights reserved. | ||
|
||
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. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
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 HOLDER 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# This file is part of aptscan | ||
# https://github.com/scorphus/aptscan | ||
|
||
# Licensed under the BSD-3-Clause license: | ||
# https://opensource.org/licenses/BSD-3-Clause | ||
# Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
|
||
# list all available targets | ||
list: | ||
@sh -c "$(MAKE) -p no_targets__ | awk -F':' '/^[a-zA-Z0-9][^\$$#\/\\t=]*:([^=]|$$)/ {split(\$$1,A,/ /);for(i in A)print A[i]}' | grep -v '__\$$' | grep -v 'make\[1\]' | grep -v 'Makefile' | sort" | ||
.PHONY: list | ||
# required for list | ||
no_targets__: | ||
|
||
# install dependencies and pre-commit hooks | ||
setup: | ||
@PIP_REQUIRE_VIRTUALENV=true pip install -U -e .\[tests\] | ||
@pre-commit install -f --hook-type pre-commit | ||
@pre-commit install -f --hook-type pre-push | ||
.PHONY: setup | ||
|
||
# install dependencies | ||
setup-ci: | ||
@pip install -U -e .\[tests\] | ||
.PHONY: setup-ci | ||
|
||
# run isort, black and flake8 for style guide enforcement | ||
isort: | ||
@isort . | ||
.PHONY: isort | ||
|
||
black: | ||
@black . | ||
.PHONY: black | ||
|
||
pylint: | ||
@pylint aptscan | ||
@pylint --rc-file tests/pylintrc tests | ||
.PHONY: pylint | ||
|
||
lint: isort black pylint | ||
.PHONY: lint | ||
|
||
# run tests with coverage | ||
test: | ||
@pytest --cov=aptscan tests | ||
.PHONY: test | ||
|
||
# report coverage in html format | ||
coverage: test | ||
@coverage html | ||
.PHONY: coverage | ||
|
||
# clean python object, test and coverage files | ||
pyclean: | ||
@find . -type d -iname '__pycache__' -exec rm -rf \{\} + -print | ||
@find . -type d -iname '.benchmarks' -exec rm -rf \{\} + -print | ||
@find . -type d -iname '.mypy_cache' -exec rm -rf \{\} + -print | ||
@find . -type d -iname '.pytest_cache' -exec rm -rf \{\} + -print | ||
@find . -type d -iname '*.egg-info' -exec rm -rf \{\} + -print | ||
@find . -type f -iname '.coverage' -exec rm -rf \{\} + -print | ||
@find . -type f -name "*.pyc" -delete -print | ||
.PHONY: pyclean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# AptScan - Apartment Floor Plan Scanner [![Build Status][build-badge]][action-link] [![Coverage Status][codecov-badge]][codecov-link] [![Maintainability][codeclimate-badge]][codeclimate-link] [![Code Quality][codacy-badge]][codacy-link] | ||
|
||
AptScan swiftly scans floor plans, automating chair type counting for each room | ||
in the floor plan. It provides the user with the number of chairs in each room | ||
and the total number of chairs in the floor plan. | ||
|
||
## Installation | ||
|
||
To install, follow these steps: | ||
|
||
1. Create a Python virtual environment using your preferred choice ([pyenv][] | ||
is recommended) | ||
2. With the recently created virtual environment activated, install the package | ||
with the following command: | ||
|
||
```shell | ||
make setup | ||
``` | ||
|
||
> _Note: aptscan requires Python 3.10 or newer._ | ||
|
||
## Running tests | ||
|
||
1. Run tests with: | ||
```shell | ||
make test | ||
``` | ||
2. And check code coverage with: | ||
```shell | ||
make coverage | ||
open htmlcov/index.html | ||
``` | ||
|
||
## Extra | ||
|
||
1. To see all available make targets: | ||
```shell | ||
make list | ||
``` | ||
|
||
## License | ||
|
||
Code in this repository is distributed under the terms of the BSD 3-Clause | ||
License (BSD-3-Clause). | ||
|
||
See [LICENSE][] for details. | ||
|
||
[build-badge]: https://github.com/scorphus/aptscan/workflows/Python/badge.svg | ||
[action-link]: https://github.com/scorphus/aptscan/actions?query=workflow%3APython | ||
[codecov-badge]: https://codecov.io/gh/scorphus/aptscan/branch/main/graph/badge.svg | ||
[codecov-link]: https://codecov.io/gh/scorphus/aptscan | ||
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/a0a0a0a0a0a0a0a0a0a0/maintainability | ||
[codeclimate-link]: https://codeclimate.com/github/scorphus/aptscan/maintainability | ||
[codacy-badge]: https://app.codacy.com/project/badge/Grade/a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0 | ||
[codacy-link]: https://app.codacy.com/gh/scorphus/aptscan/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade | ||
[pyenv]: https://github.com/pyenv/pyenv | ||
[LICENSE]: LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of aptscan | ||
# https://github.com/scorphus/aptscan | ||
|
||
# Licensed under the BSD-3-Clause license: | ||
# https://opensource.org/licenses/BSD-3-Clause | ||
# Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
|
||
"""aptscan - Apartment Floor Plan Scanner | ||
AptScan swiftly scans floor plans, automating chair type counting for each room | ||
in the floor plan. It provides the user with the number of chairs in each room | ||
and the total number of chairs in the floor plan. | ||
""" | ||
|
||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of aptscan | ||
# https://github.com/scorphus/aptscan | ||
|
||
# Licensed under the BSD-3-Clause license: | ||
# https://opensource.org/licenses/BSD-3-Clause | ||
# Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
|
||
"""main contains the `aptscan` entry point along with main action""" | ||
|
||
import argparse | ||
import sys | ||
from typing import NamedTuple, Tuple | ||
|
||
from aptscan import __doc__, __version__ | ||
|
||
|
||
class AptScanArgs(NamedTuple): | ||
"""AptScanArgs contains the arguments passed to the program""" | ||
|
||
version: bool | ||
|
||
|
||
def aptscan() -> None: # pragma: no cover | ||
"""Entry point for command line tool ``aptscan``. | ||
:Usage: | ||
.. code-block:: text | ||
$ aptscan --help # to display help | ||
$ aptscan rooms.txt # to scan rooms.txt | ||
""" | ||
parser, parsed_args = parse_args() | ||
if parsed_args.version: | ||
sys.stderr.write(f"aptscan {__version__}\n") | ||
else: | ||
parser.print_usage() | ||
|
||
|
||
def parse_args() -> Tuple[argparse.ArgumentParser, AptScanArgs]: # pragma: no cover | ||
"""Parse arguments passed to the program""" | ||
parser = argparse.ArgumentParser( | ||
prog="aptscan", | ||
description=__doc__, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
parser.add_argument("-V", "--version", action="store_true", help="display program version") | ||
return parser, parser.parse_args() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file is part of aptscan | ||
# https://github.com/scorphus/aptscan | ||
|
||
# Licensed under the BSD-3-Clause license: | ||
# https://opensource.org/licenses/BSD-3-Clause | ||
# Copyright (c) 2024, Pablo S. Blum de Aguiar <scorphus@gmail.com> | ||
|
||
[tool.black] | ||
exclude = ''' | ||
( | ||
/( | ||
\.eggs | ||
| \.git | ||
| \.tox | ||
| dist | ||
)/ | ||
) | ||
''' | ||
line-length = 99 |
Oops, something went wrong.