Skip to content

Commit f575c2d

Browse files
committed
Initial commit
0 parents  commit f575c2d

16 files changed

+252
-0
lines changed

.ci/aptPackagesToInstall.txt

Whitespace-only changes.

.ci/pythonPackagesToInstallFromGit.txt

Whitespace-only changes.

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = tab
6+
indent_size = 4
7+
insert_final_newline = true
8+
end_of_line = lf
9+
10+
[*.{yml,yaml}]
11+
indent_style = space
12+
indent_size = 2

.github/.templateMarker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
KOLANICH/python_project_boilerplate.py

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
allow:
8+
- dependency-type: "all"

.github/workflows/CI.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
branches: [master]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: typical python workflow
13+
uses: KOLANICH-GHActions/typical-python-workflow@master
14+
with:
15+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
__pycache__
2+
*.py[co]
3+
/*.egg-info
4+
*.srctrlbm
5+
*.srctrldb
6+
build
7+
dist
8+
.eggs
9+
monkeytype.sqlite3
10+
/.ipynb_checkpoints

.gitlab-ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
image: registry.gitlab.com/kolanich-subgroups/docker-images/fixed_python:latest
2+
3+
variables:
4+
DOCKER_DRIVER: overlay2
5+
SAST_ANALYZER_IMAGE_TAG: latest
6+
SAST_DISABLE_DIND: "true"
7+
SAST_CONFIDENCE_LEVEL: 5
8+
CODECLIMATE_VERSION: latest
9+
10+
include:
11+
- template: SAST.gitlab-ci.yml
12+
- template: Code-Quality.gitlab-ci.yml
13+
- template: License-Management.gitlab-ci.yml
14+
15+
build:
16+
tags:
17+
- shared
18+
- linux
19+
stage: build
20+
variables:
21+
GIT_DEPTH: "1"
22+
PYTHONUSERBASE: ${CI_PROJECT_DIR}/python_user_packages
23+
24+
before_script:
25+
- export PATH="$PATH:$PYTHONUSERBASE/bin" # don't move into `variables`
26+
- apt-get update
27+
# todo:
28+
#- apt-get -y install
29+
#- pip3 install --upgrade
30+
#- python3 ./fix_python_modules_paths.py
31+
32+
script:
33+
- python3 -m build -nw bdist_wheel
34+
- mv ./dist/*.whl ./dist/GitHubReadMeRender-0.CI-py3-none-any.whl
35+
- pip3 install --upgrade ./dist/*.whl
36+
- coverage run --source=GitHubReadMeRender -m --branch pytest --junitxml=./rspec.xml ./tests/test.py
37+
- coverage report -m
38+
- coverage xml
39+
40+
coverage: "/^TOTAL(?:\\s+\\d+){4}\\s+(\\d+%).+/"
41+
42+
cache:
43+
paths:
44+
- $PYTHONUSERBASE
45+
46+
artifacts:
47+
paths:
48+
- dist
49+
reports:
50+
junit: ./rspec.xml
51+
cobertura: ./coverage.xml

Code_Of_Conduct.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No codes of conduct!

GitHubReadMeRender/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from pathlib import PurePath
2+
from warnings import warn
3+
4+
from LMRender import SF, DEFAULT_RENDERER
5+
from miniGHAPI.GitHubAPI import CT, Repo
6+
7+
__all__ = ("getAndRenderReadMe",)
8+
9+
10+
def getAndRenderReadMe(repoObj: Repo, targetFormat: SF = SF.gfm_ansi):
11+
readMe = repoObj.getReadMe(accept=CT.json)
12+
13+
rawSrc = readMe["$content"]
14+
fmt = SF.fromFileName(PurePath(readMe["name"]))
15+
unavail = DEFAULT_RENDERER.isSourceUnavailable(fmt)
16+
17+
def fallback():
18+
nonlocal rawSrc, fmt
19+
rawSrc = repoObj.getReadMe(accept=CT.html)["$content"]
20+
fmt = SF.html
21+
22+
if fmt is None:
23+
fallback()
24+
elif unavail:
25+
warn("Install " + " or ".join(unavail) + " to spare an API request. Requesting GitHub to render the ReadMe into HTML.")
26+
fallback()
27+
28+
return DEFAULT_RENDERER.render(rawSrc, fmt, targetFormat)

0 commit comments

Comments
 (0)