Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .copier/answers_pypackage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
#
# You can use `pdm run copier update --defaults` to update the template
# files using the answers stored in this file.
# (see https://copier.readthedocs.io/en/stable/updating/ for details)

_commit: v0.2.1
_src_path: https://github.com/feeph/pypackage-template
author_email: 55798703+feeph@users.noreply.github.com
author_name: Feeph Aifeimei
default_branch: master
is_typed: true
issuetracker_url: https://github.com/feeph/libi2c-python/issues
max_line_length: 250
package_description: abstraction layer for the I²C bus (incl. simulation for testing)
package_name: i2c
package_namespace: feeph
python_constraint: '>=3.10,<3.13'
repository_name: libi2c-python
repository_url: https://github.com/feeph/libi2c-python
13 changes: 13 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# define code ownership for this repository
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
#
# It's possible to add groups as well but they need to be added to the
# repository and assigned a permission level first. Otherwise they will
# be underlined with red squiggly lines when looking at the file in the
# WebGUI and it won't work.
# (GitHub -> Repository -> Settings -> Collaborators)
#

# define default ownership
* @feeph
2 changes: 1 addition & 1 deletion .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# enable dependabot's scanning but do not allow creation of pull requests
# (please use 'scripts/update_dependencies' to update the dependencies)
#
#
# - dependabot does not understand PEP-621 repositories (pyproject.toml)
# - dependabot expects the filename to end in '<...>requirements.txt' and
# ignores requirements-dev.txt ('dev-requirements.txt' would work but
Expand Down
37 changes: 34 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
# documentation can be found at https://pre-commit.com/
#
# perform once after cloning the repository:
# pipx install pre-commit
# pre-commit install --hook-type pre-commit
# pre-commit install --hook-type commit-msg
# scripts/prepare_repository
#
# if you want to trigger pre-commit manually:
# pre-commit run
# pre-commit run --all-files
#
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-merge-conflict
args: [--assume-in-merge]
- id: check-json
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -40,3 +43,31 @@ repos:
rev: 7.0.0
hooks:
- id: flake8
# -----------------------------------------------------------------------
# !! post-commit can't prevent the commit from happening !!
#
# At this point we can only complain that the commit wasn't signed
# properly and provide a warning that something isn't right and remind
# the user to go back and fix this specific commit.
#
# (We rely on the 'pre-push' stage to prevent pushing of unsigned commits.)
- repo: local
hooks:
- id: commit-signed
name: Verify commit is signed
stages:
- post-commit
always_run: true
language: system
entry: git
args: [ "verify-commit", "HEAD" ]
# -----------------------------------------------------------------------
- repo: local
hooks:
- id: signed-commits
name: Verify signature
language: script
entry: scripts/verify_commits-are-signed
args: [ "$PRE_COMMIT_FROM_REF", "$PRE_COMMIT_TO_REF" ]
stages:
- pre-push
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# libi2c-python

[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-purple.json)](https://github.com/copier-org/copier)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![pdm-managed](https://img.shields.io/endpoint?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fpdm-project%2F.github%2Fbadge.json)](https://pdm-project.org)
[![tox](https://img.shields.io/badge/tox-ab79d2)](https://tox.wiki/)

abstraction layer for the I²C bus (incl. simulation for testing)

## Purpose

## Usage

## Bugs & Features

Please submit bugs and request features on the [issue tracker](https://github.com/feeph/libi2c-python/issues).

Contributions are always welcome.

## How to contribute

Please refer to the [Contribution guide](docs/CONTRIBUTING.md).
57 changes: 57 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Contributing

## quickstart

### one-time setup

__system-wide__

- __install pipx__
- __install build dependencies__ for pyenv
https://github.com/pyenv/pyenv/wiki#suggested-build-environment

__user-specific__

```SHELL
# install dev tools
pipx install pdm pre-commit tox
pipx inject pdm pdm-autoexport
pipx inject tox virtualenv-pyenv

# OS-independent Python versions
curl https://pyenv.run | bash
pyenv install 3.10
pyenv install 3.11
pyenv install 3.12
```

### repository setup

```SHELL
# install pre-commit hooks
for hook_type in pre-commit commit-msg post-commit pre-push ; do
pre-commit install --allow-missing-config --hook-type $hook_type
done

# install package dependencies
pdm install
```

### perform unit tests:

```SHELL
pdm run pytest
```

### perform compatibility tests:

```SHELL
tox
```

### use the demo script

```SHELL
pdm run examples/demonstrator.py
pdm run examples/demonstrator.py -v -i 2
```
4 changes: 1 addition & 3 deletions feeph/i2c/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
```
"""

import logging


def convert_uint_to_bytearry(value: int, byte_count: int) -> bytearray:
"""
Expand All @@ -34,7 +32,7 @@ def convert_uint_to_bytearry(value: int, byte_count: int) -> bytearray:
```
"""
min_value = 0
max_value = pow(256, byte_count) - 1
max_value = pow(256, byte_count) - 1
if min_value <= value <= max_value:
buf = bytearray(byte_count)
for idx in range(byte_count):
Expand Down
Loading