-
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 cced3f1
Showing
10 changed files
with
416 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,27 @@ | ||
name: Upload Python Package | ||
on: | ||
push: | ||
branches: | ||
- release | ||
permissions: | ||
contents: read | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.x" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build | ||
- name: Build package | ||
run: python -m build | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
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,131 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
.vscode | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
dist |
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 @@ | ||
Copyright (c) 2018 The Python Packaging Authority | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,2 @@ | ||
include LICENSE | ||
include README.md |
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 @@ | ||
# yappr | ||
|
||
Yet another python package updater | ||
|
||
## Installation | ||
|
||
You can install the package via pip: | ||
|
||
```bash | ||
pip install yappr | ||
``` | ||
|
||
## Usage | ||
|
||
```python | ||
from yappr import Updater | ||
|
||
u = Updater("httpx", first_update_interval=0) | ||
u.check_for_updates_loop() | ||
|
||
# 04/27/2024 02:35:14 AM - INFO - Checking for updates... | ||
# 04/27/2024 02:35:19 AM - INFO - New version found: 0.23.2 -> 0.27.0 | ||
# 04/27/2024 02:35:19 AM - INFO - Collecting new packages... | ||
# 04/27/2024 02:35:26 AM - INFO - Successfully downloaded new version. | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the terms of the MIT 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,38 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.2"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "yappr" | ||
version = "1.0.0" | ||
dependencies = [] | ||
requires-python = ">=3" | ||
authors = [ | ||
{ name = "Pradish Bijukchhe", email = "[email protected]" }, | ||
] | ||
description = "Yet another python package updater" | ||
readme = "README.md" | ||
license = { file = "LICENSE" } | ||
keywords = [] | ||
classifiers = ["Programming Language :: Python :: 3"] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/sandbox-pokhara/yappr" | ||
Issues = "https://github.com/sandbox-pokhara/yappr/issues" | ||
|
||
[tool.setuptools] | ||
include-package-data = true | ||
|
||
[tool.setuptools.package-dir] | ||
"yappr" = "yappr" | ||
|
||
[tool.isort] | ||
line_length = 79 | ||
force_single_line = true | ||
|
||
[tool.black] | ||
line-length = 79 | ||
preview = true | ||
|
||
[tool.pyright] | ||
typeCheckingMode = "strict" |
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,3 @@ | ||
from yappr.updater import Updater | ||
|
||
__all__ = ["Updater"] |
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,72 @@ | ||
import logging | ||
import sys | ||
from logging import LogRecord | ||
from logging import StreamHandler | ||
from typing import Any | ||
|
||
|
||
class ColorFormatter(logging.Formatter): | ||
grey = "\x1b[38;20m" | ||
blue = "\x1b[38;5;39m" | ||
yellow = "\x1b[33;20m" | ||
red = "\x1b[31;20m" | ||
bold_red = "\x1b[31;1m" | ||
reset = "\x1b[0m" | ||
|
||
colors = { | ||
logging.DEBUG: grey, | ||
logging.INFO: blue, | ||
logging.WARNING: yellow, | ||
logging.ERROR: red, | ||
logging.CRITICAL: bold_red, | ||
} | ||
|
||
def format(self, record: LogRecord): | ||
color = self.colors.get(record.levelno, self.grey) | ||
message = super().format(record) | ||
return color + message + self.reset | ||
|
||
|
||
# intialize logger | ||
root = logging.getLogger("yappr") | ||
root.setLevel(logging.DEBUG) | ||
|
||
|
||
# formatter | ||
fmt = "%(asctime)s - %(levelname)s - %(message)s" | ||
datefmt = "%m/%d/%Y %I:%M:%S %p" | ||
color_formatter = ColorFormatter(fmt, datefmt) | ||
|
||
# stream handler | ||
stream_handler = StreamHandler(sys.stdout) | ||
stream_handler.setFormatter(color_formatter) | ||
stream_handler.setLevel(logging.INFO) | ||
root.addHandler(stream_handler) | ||
|
||
|
||
# --------------------------------------------------------------------------- | ||
# Utility functions at module level. | ||
# Basically delegate everything to the root logger. | ||
# --------------------------------------------------------------------------- | ||
def critical(msg: Any): | ||
root.critical(msg) | ||
|
||
|
||
def error(msg: Any): | ||
root.error(msg) | ||
|
||
|
||
def exception(msg: Any): | ||
root.exception(msg) | ||
|
||
|
||
def warning(msg: Any): | ||
root.warning(msg) | ||
|
||
|
||
def info(msg: Any): | ||
root.info(msg) | ||
|
||
|
||
def debug(msg: Any): | ||
root.debug(msg) |
Empty file.
Oops, something went wrong.