generated from hakancelikdev/python-package
-
-
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
1 parent
64abe71
commit 3fc9a96
Showing
28 changed files
with
460 additions
and
117 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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ on: | |
branches: | ||
- stable | ||
jobs: | ||
deploy: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
|
@@ -16,8 +16,10 @@ jobs: | |
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -I .[docs] | ||
python -m pip install .[docs] | ||
- name: Build Docs | ||
run: | | ||
git fetch --all | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Hakan Celik" | ||
git fetch --all | ||
mkdocs gh-deploy -m "Update Docs" --remote-branch gh-pages |
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,15 @@ | ||
name: pre-commit | ||
on: [push, pull_request] | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- name: Install dependencies for pre-commit | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install tox | ||
- name: pre-commit | ||
run: | | ||
tox -e pre-commit |
This file was deleted.
Oops, something went wrong.
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,46 @@ | ||
name: publish-package-on-pypi | ||
on: | ||
push: | ||
tags: | ||
- "**" | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/[email protected] | ||
with: | ||
python-version: "3.8" | ||
architecture: "x64" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade build | ||
- run: python -m build | ||
- name: Publish package to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
verbose: true | ||
|
||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: actions/[email protected] | ||
with: | ||
python-version: "3.8" | ||
architecture: "x64" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade build | ||
- run: python -m build | ||
- name: Publish a Python distribution to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} | ||
verbose: true |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
name: Test | ||
name: test | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
run: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ["3.8", "3.9", "3.10"] | ||
os: [ubuntu-latest, macos-latest] | ||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
|
@@ -16,19 +16,10 @@ jobs: | |
python-version: ${{ matrix.python-version }} | ||
architecture: x64 | ||
|
||
- name: Install Dependencies | ||
- name: Install Dependencies for Python${{ matrix.python-version }} | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -I .[tests] | ||
- name: Test with pytest | ||
run: | | ||
python -m pytest tests -v | ||
- name: Generate coverage report | ||
python -m pip install tox | ||
- name: Test with pytest for Python${{ matrix.python-version }} | ||
run: | | ||
pytest --cov=./ --cov-report=xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN }} | ||
tox -e ${{ matrix.python-version }} |
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
This file was deleted.
Oops, something went wrong.
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
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,39 @@ | ||
install: | ||
pip install -e .[tests] | ||
|
||
lint: | ||
git add . | ||
pre-commit run --all-files | ||
|
||
test: | ||
pytest tests -x -v --disable-warnings | ||
|
||
clean: | ||
rm -rf `find . -name __pycache__` | ||
rm -f `find . -type f -name '*.py[co]' ` | ||
rm -f `find . -type f -name '*~' ` | ||
rm -f `find . -type f -name '.*~' ` | ||
rm -rf .cache | ||
rm -rf .pytest_cache | ||
rm -rf .mypy_cache | ||
rm -rf htmlcov | ||
rm -rf *.egg-info | ||
rm -f .coverage | ||
rm -f .coverage.* | ||
rm -rf .tox | ||
rm -rf build | ||
|
||
push: | ||
git push origin head | ||
|
||
amend: | ||
git add . | ||
git commit --amend --no-edit | ||
git push origin head -f | ||
|
||
stable: | ||
git checkout main | ||
git branch -D stable | ||
git checkout -b stable | ||
git push origin head -f | ||
git checkout main |
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 |
---|---|---|
@@ -1 +1,54 @@ | ||
# {{project-name}} | ||
# Define If | ||
|
||
**If the condition is true, define the method.** | ||
|
||
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/hakancelikdev/defineif/main.svg)](https://results.pre-commit.ci/latest/github/hakancelikdev/defineif/main) | ||
[![test](https://github.com/hakancelikdev/defineif/actions/workflows/tests.yml/badge.svg)](https://github.com/hakancelikdev/defineif/actions/workflows/tests.yml) | ||
[![build-docs](https://github.com/hakancelikdev/defineif/actions/workflows/docs.yml/badge.svg)](https://github.com/hakancelikdev/defineif/actions/workflows/docs.yml) | ||
[![publish-package-on-pypi](https://github.com/hakancelikdev/defineif/actions/workflows/pypi.yml/badge.svg)](https://github.com/hakancelikdev/defineif/actions/workflows/pypi.yml) | ||
|
||
[![Pypi](https://img.shields.io/pypi/v/defineif)](https://pypi.org/project/defineif/) | ||
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/defineif) | ||
[![Downloads](https://static.pepy.tech/personalized-badge/defineif?period=total&units=international_system&left_color=grey&right_color=red&left_text=downloads)](https://pepy.tech/project/defineif) | ||
[![License](https://img.shields.io/github/license/hakancelikdev/defineif.svg)](https://github.com/hakancelikdev/defineif/blob/main/LICENSE) | ||
|
||
[![Forks](https://img.shields.io/github/forks/hakancelikdev/defineif)](https://github.com/hakancelikdev/defineif/fork) | ||
[![Issues](https://img.shields.io/github/issues/hakancelikdev/defineif)](https://github.com/hakancelikdev/defineif/issues) | ||
[![Stars](https://img.shields.io/github/stars/hakancelikdev/defineif)](https://github.com/hakancelikdev/defineif/stargazers) | ||
|
||
[![Codecov](https://codecov.io/gh/hakancelikdev/defineif/branch/main/graph/badge.svg)](https://codecov.io/gh/hakancelikdev/defineif) | ||
[![Contributors](https://img.shields.io/github/contributors/hakancelikdev/defineif)](https://github.com/hakancelikdev/defineif/graphs/contributors) | ||
[![Last Commit](https://img.shields.io/github/last-commit/hakancelikdev/defineif.svg)](https://github.com/hakancelikdev/defineif/commits/main) | ||
|
||
For more information see: https://defineif.hakancelik.dev/ | ||
|
||
## How to install ? | ||
|
||
``` | ||
pip install defineif | ||
``` | ||
|
||
## How to use it ? | ||
|
||
```python | ||
import os | ||
|
||
from defineif import DefineIf | ||
|
||
|
||
class Klass(DefineIf): | ||
|
||
@staticmethod | ||
@DefineIf(os.name == 'nt') | ||
def get_platform(): | ||
return 'Windows' | ||
|
||
@staticmethod | ||
@DefineIf(os.name == 'posix') | ||
def get_platform(): | ||
return 'Linux' | ||
|
||
platform = Klass.get_platform() | ||
|
||
print(platform) | ||
``` |
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,38 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and | ||
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] - YYYY-MM-DD | ||
|
||
## [0.1.0] - 2022-11-24 | ||
|
||
### Added | ||
|
||
- DefineIf class implemented, we can now use it via inheritance and decorators. For | ||
example: | ||
|
||
```python | ||
import os | ||
|
||
from defineif import DefineIf | ||
|
||
|
||
class Klass(DefineIf): | ||
|
||
@staticmethod | ||
@DefineIf(os.name == 'nt') | ||
def get_platform(): | ||
return 'Windows' | ||
|
||
@staticmethod | ||
@DefineIf(os.name == 'posix') | ||
def get_platform(): | ||
return 'Linux' | ||
|
||
platform = Klass.get_platform() | ||
|
||
print(platform) | ||
``` |
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 |
---|---|---|
@@ -1 +1 @@ | ||
{{project-name}}.hakancelik.dev | ||
defineif.hakancelik.dev |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## Authors | ||
|
||
- Hakan Çelik (@hakancelikdev) <[email protected]> | ||
- Hakan Çelik (@hakancelikdev) <[email protected]> | ||
|
||
## Contributors | ||
|
||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.