Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit aab7ba3

Browse files
authored
Merge pull request #5 from ahsentekd/main
chore: project maintenance and quality improvements
2 parents c4ec817 + 6d249a8 commit aab7ba3

29 files changed

Lines changed: 3384 additions & 1318 deletions

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install Poetry
25+
uses: snok/install-poetry@v1
26+
with:
27+
version: 1.7.1
28+
virtualenvs-create: true
29+
virtualenvs-in-project: true
30+
31+
- name: Install dependencies
32+
run: |
33+
poetry install
34+
35+
- name: Run linting
36+
run: |
37+
make lint

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
3333
- name: Build package
3434
run: python -m build
35-
35+
3636
- name: Create Release
3737
id: create_release
3838
uses: actions/create-release@v1
@@ -43,7 +43,7 @@ jobs:
4343
release_name: Release v${{ env.VERSION }}
4444
draft: false
4545
prerelease: false
46-
46+
4747
- name: Upload Wheel
4848
uses: actions/upload-release-asset@v1
4949
env:
@@ -53,7 +53,7 @@ jobs:
5353
asset_path: ./dist/zmapsdk-${{ env.VERSION }}-py3-none-any.whl
5454
asset_name: zmapsdk-${{ env.VERSION }}-py3-none-any.whl
5555
asset_content_type: application/octet-stream
56-
56+
5757
- name: Upload Source
5858
uses: actions/upload-release-asset@v1
5959
env:
@@ -63,7 +63,7 @@ jobs:
6363
asset_path: ./dist/zmapsdk-${{ env.VERSION }}.tar.gz
6464
asset_name: zmapsdk-${{ env.VERSION }}.tar.gz
6565
asset_content_type: application/gzip
66-
66+
6767
- name: Publish to PyPI
6868
env:
6969
TWINE_USERNAME: __token__

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ Thumbs.db
4242
*.conf
4343
test_results/
4444
scan_results/
45+
46+
# docs build
47+
docs/_build/

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-toml
10+
- repo: https://github.com/psf/black
11+
rev: 24.2.0
12+
hooks:
13+
- id: black
14+
language_version: python3
15+
- repo: https://github.com/pycqa/isort
16+
rev: 5.13.2
17+
hooks:
18+
- id: isort
19+
- repo: https://github.com/asottile/pyupgrade
20+
rev: v3.15.1
21+
hooks:
22+
- id: pyupgrade
23+
args: [--py311-plus]

CODE_OF_CONDUCT.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
education, socio-economic status, nationality, personal appearance, race,
10+
religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at {{ email }}. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.PHONY: install format lint clean
2+
3+
install:
4+
poetry install
5+
pre-commit install
6+
7+
format:
8+
poetry run isort zmapsdk
9+
poetry run black zmapsdk
10+
11+
lint:
12+
poetry run isort --check-only --diff .
13+
poetry run black --check .
14+
poetry run pyupgrade --py311-plus $$(find . -name '*.py' -not -path './.venv/*')
15+
16+
clean:
17+
rm -rf build/
18+
rm -rf dist/
19+
rm -rf *.egg-info
20+
find . -type d -name __pycache__ -exec rm -rf {} +
21+
find . -type f -name "*.pyc" -delete

__init__.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
"""
2-
ZMap SDK - Python SDK for the ZMap network scanner
3-
"""
4-
5-
from .zmapsdk import ZMap, ZMapError, ZMapCommandError
6-
7-
__version__ = "0.1.0"
8-
__all__ = ["ZMap", "ZMapError", "ZMapCommandError"]
1+
"""
2+
ZMap SDK - Python SDK for the ZMap network scanner
3+
"""
4+
5+
from pathlib import Path
6+
7+
import tomli
8+
9+
from .zmapsdk import ZMap, ZMapCommandError, ZMapError
10+
11+
# read version from pyproject.toml
12+
try:
13+
_PYPROJECT_PATH = Path(__file__).parent.parent / "pyproject.toml"
14+
with open(_PYPROJECT_PATH, "rb") as f:
15+
_PYPROJECT = tomli.load(f)
16+
__version__ = _PYPROJECT["project"]["version"]
17+
except (FileNotFoundError, KeyError, tomli.TOMLDecodeError):
18+
# fallback for something went wrong
19+
__version__ = "0.0.0"
20+
21+
__all__ = ["ZMap", "ZMapError", "ZMapCommandError"]

build-package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ python -m build
1414
echo "Installing package..."
1515
python -m pip install -e .
1616

17-
echo "Build and installation complete!"
17+
echo "Build and installation complete!"

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
import tomlkit
10+
11+
12+
def _get_project_details():
13+
"""Get project meta details."""
14+
with open("../pyproject.toml") as pyproject:
15+
content = pyproject.read()
16+
17+
return tomlkit.parse(content)["tool"]["poetry"]
18+
19+
20+
pkg_meta = _get_project_details()
21+
project = str(pkg_meta["name"])
22+
version = str(pkg_meta["version"])
23+
copyright = "2025, Happy Hacking Space"
24+
author = "Happy Hacking Space"
25+
release = version
26+
27+
28+
# -- General configuration ---------------------------------------------------
29+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
30+
autoclass_content = "class"
31+
32+
extensions = [
33+
"sphinx.ext.autodoc",
34+
"sphinx.ext.viewcode",
35+
"sphinx.ext.doctest",
36+
"autoapi.extension",
37+
]
38+
39+
master_doc = "index"
40+
41+
# autoapi
42+
autoapi_dirs = ["../../zmapsdk/"]
43+
autoapi_type = "python"
44+
templates_path = ["_templates"]
45+
exclude_patterns = [".DS_Store", "_build", "Thumbs.db"]
46+
47+
48+
# -- Options for HTML output -------------------------------------------------
49+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
50+
51+
html_theme = "sphinx_rtd_theme"
52+
html_static_path = ["_static"]

0 commit comments

Comments
 (0)