generated from KOLANICH/python_project_boilerplate.py
-
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 f575c2d
Showing
16 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
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,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
insert_final_newline = true | ||
end_of_line = lf | ||
|
||
[*.{yml,yaml}] | ||
indent_style = space | ||
indent_size = 2 |
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 @@ | ||
KOLANICH/python_project_boilerplate.py |
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,8 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
allow: | ||
- dependency-type: "all" |
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: CI | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: typical python workflow | ||
uses: KOLANICH-GHActions/typical-python-workflow@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_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,10 @@ | ||
__pycache__ | ||
*.py[co] | ||
/*.egg-info | ||
*.srctrlbm | ||
*.srctrldb | ||
build | ||
dist | ||
.eggs | ||
monkeytype.sqlite3 | ||
/.ipynb_checkpoints |
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,51 @@ | ||
image: registry.gitlab.com/kolanich-subgroups/docker-images/fixed_python:latest | ||
|
||
variables: | ||
DOCKER_DRIVER: overlay2 | ||
SAST_ANALYZER_IMAGE_TAG: latest | ||
SAST_DISABLE_DIND: "true" | ||
SAST_CONFIDENCE_LEVEL: 5 | ||
CODECLIMATE_VERSION: latest | ||
|
||
include: | ||
- template: SAST.gitlab-ci.yml | ||
- template: Code-Quality.gitlab-ci.yml | ||
- template: License-Management.gitlab-ci.yml | ||
|
||
build: | ||
tags: | ||
- shared | ||
- linux | ||
stage: build | ||
variables: | ||
GIT_DEPTH: "1" | ||
PYTHONUSERBASE: ${CI_PROJECT_DIR}/python_user_packages | ||
|
||
before_script: | ||
- export PATH="$PATH:$PYTHONUSERBASE/bin" # don't move into `variables` | ||
- apt-get update | ||
# todo: | ||
#- apt-get -y install | ||
#- pip3 install --upgrade | ||
#- python3 ./fix_python_modules_paths.py | ||
|
||
script: | ||
- python3 -m build -nw bdist_wheel | ||
- mv ./dist/*.whl ./dist/GitHubReadMeRender-0.CI-py3-none-any.whl | ||
- pip3 install --upgrade ./dist/*.whl | ||
- coverage run --source=GitHubReadMeRender -m --branch pytest --junitxml=./rspec.xml ./tests/test.py | ||
- coverage report -m | ||
- coverage xml | ||
|
||
coverage: "/^TOTAL(?:\\s+\\d+){4}\\s+(\\d+%).+/" | ||
|
||
cache: | ||
paths: | ||
- $PYTHONUSERBASE | ||
|
||
artifacts: | ||
paths: | ||
- dist | ||
reports: | ||
junit: ./rspec.xml | ||
cobertura: ./coverage.xml |
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 @@ | ||
No codes of conduct! |
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,28 @@ | ||
from pathlib import PurePath | ||
from warnings import warn | ||
|
||
from LMRender import SF, DEFAULT_RENDERER | ||
from miniGHAPI.GitHubAPI import CT, Repo | ||
|
||
__all__ = ("getAndRenderReadMe",) | ||
|
||
|
||
def getAndRenderReadMe(repoObj: Repo, targetFormat: SF = SF.gfm_ansi): | ||
readMe = repoObj.getReadMe(accept=CT.json) | ||
|
||
rawSrc = readMe["$content"] | ||
fmt = SF.fromFileName(PurePath(readMe["name"])) | ||
unavail = DEFAULT_RENDERER.isSourceUnavailable(fmt) | ||
|
||
def fallback(): | ||
nonlocal rawSrc, fmt | ||
rawSrc = repoObj.getReadMe(accept=CT.html)["$content"] | ||
fmt = SF.html | ||
|
||
if fmt is None: | ||
fallback() | ||
elif unavail: | ||
warn("Install " + " or ".join(unavail) + " to spare an API request. Requesting GitHub to render the ReadMe into HTML.") | ||
fallback() | ||
|
||
return DEFAULT_RENDERER.render(rawSrc, fmt, targetFormat) |
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,24 @@ | ||
import argparse | ||
|
||
from miniGHAPI.GitHubAPI import GHAPI | ||
|
||
from . import getAndRenderReadMe | ||
|
||
p = argparse.ArgumentParser(description="Renders readme of a GitHub repo in console") | ||
p.add_argument("--format") | ||
p.add_argument("repo") | ||
|
||
|
||
def main(): | ||
args = p.parse_args() | ||
owner, repo = args.repo.strip().split("/") | ||
|
||
gha = GHAPI("") | ||
r = gha.repo(owner, repo) | ||
|
||
rendered = getAndRenderReadMe(r) | ||
print(rendered) | ||
|
||
|
||
if __name__ == "__main__": | ||
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include UNLICENSE | ||
include *.md | ||
include tests | ||
include .editorconfig |
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,8 @@ | ||
GitHubReadMeRender.py [![Unlicensed work](https://raw.githubusercontent.com/unlicense/unlicense.org/master/static/favicon.png)](https://unlicense.org/) | ||
===================== | ||
~~[wheel (GHA via `nightly.link`)](https://nightly.link/KOLANICH-libs/GitHubReadMeRender.py/workflows/CI/master/GitHubReadMeRender-0.CI-py3-none-any.whl)~~ | ||
~~[![GitHub Actions](https://github.com/KOLANICH-libs/GitHubReadMeRender.py/workflows/CI/badge.svg)](https://github.com/KOLANICH-libs/GitHubReadMeRender.py/actions/)~~ | ||
[![Libraries.io Status](https://img.shields.io/librariesio/github/KOLANICH-libs/GitHubReadMeRender.py.svg)](https://libraries.io/github/KOLANICH-libs/GitHubReadMeRender.py) | ||
[![Code style: antiflash](https://img.shields.io/badge/code%20style-antiflash-FFF.svg)](https://codeberg.org/KOLANICH-tools/antiflash.py) | ||
|
||
This lib allows you to retrieve a ReadMe of a GitHub repo in the form of text that can be shown in console. |
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,24 @@ | ||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
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 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. | ||
|
||
For more information, please refer to <https://unlicense.org/> |
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,42 @@ | ||
[build-system] | ||
requires = ["setuptools>=61.2.0", "setuptools_scm[toml]>=3.4.3"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "GitHubReadMeRender" | ||
readme = "ReadMe.md" | ||
description = "This lib allows you to retrieve a ReadMe of a GitHub repo in the form of text that can be shown in console." | ||
authors = [{name = "KOLANICH"}] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Environment :: Other Environment", | ||
"Intended Audience :: Developers", | ||
"License :: Public Domain", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
] | ||
keywords = ["GitHubReadMeRender"] | ||
license = {text = "Unlicense"} | ||
requires-python = ">=3.4" | ||
dynamic = ["version"] | ||
requirements = [ | ||
"miniGHAPI", # @ git+https://codeberg.org/KOLANICH-libs/miniGHAPI.py | ||
"LMRender", # @ git+https://codeberg.org/KOLANICH-libs/LMRender.py | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://codeberg.org/KOLANICH-libs/GitHubReadMeRender.py" | ||
|
||
[project.scripts] | ||
GitHubReadMeRender = "GitHubReadMeRender.__main__:main" | ||
|
||
[tool.setuptools] | ||
zip-safe = true | ||
|
||
[tool.setuptools.packages.find] | ||
include = ["GitHubReadMeRender", "GitHubReadMeRender.*"] | ||
|
||
[tool.setuptools_scm] |
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,24 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
from pathlib import Path | ||
import unittest | ||
import itertools, re | ||
|
||
sys.path.insert(0, str(Path(__file__).parent.parent)) | ||
|
||
from collections import OrderedDict | ||
|
||
dict = OrderedDict | ||
|
||
import GitHubReadMeRender | ||
from GitHubReadMeRender import * | ||
|
||
|
||
class Tests(unittest.TestCase): | ||
|
||
def testSimple(self): | ||
raise NotImplementedError | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |