Skip to content

Commit fcdfc4e

Browse files
committed
Initial commit
0 parents  commit fcdfc4e

File tree

15 files changed

+355
-0
lines changed

15 files changed

+355
-0
lines changed

.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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
/*.egg-info
5+
/build
6+
/dist
7+
/.eggs
8+
*.sqlite3
9+
/.mypy_cache
10+
*.py,cover
11+
/.coverage
12+
/rspec.xml
13+
/monkeytype.sqlite3
14+
/*.srctrldb
15+
/*.srctrlbm
16+
/*.srctrlprj

.gitlab-ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#image: pypy:latest
2+
image: registry.gitlab.com/kolanich-subgroups/docker-images/fixed_python:latest
3+
stages:
4+
- dependencies
5+
- build
6+
- trigger
7+
- test
8+
9+
variables:
10+
DOCKER_DRIVER: overlay2
11+
SAST_ANALYZER_IMAGE_TAG: latest
12+
SAST_DISABLE_DIND: "true"
13+
14+
include:
15+
- template: SAST.gitlab-ci.yml
16+
#- template: DAST.gitlab-ci.yml
17+
#- template: License-Management.gitlab-ci.yml
18+
#- template: Container-Scanning.gitlab-ci.yml
19+
#- template: Dependency-Scanning.gitlab-ci.yml
20+
- template: Code-Quality.gitlab-ci.yml
21+
22+
23+
build:
24+
tags:
25+
- shared
26+
- linux
27+
stage: build
28+
variables:
29+
GIT_DEPTH: "1"
30+
PYTHONUSERBASE: ${CI_PROJECT_DIR}/python_user_packages
31+
32+
before_script:
33+
- export PYTHON_MODULES_DIR=${PYTHONUSERBASE}/lib/python3.8
34+
- export EXECUTABLE_DEPENDENCIES_DIR=${PYTHONUSERBASE}/bin
35+
- export PATH="$PATH:$EXECUTABLE_DEPENDENCIES_DIR" # don't move into `variables` any of them, it is unordered
36+
- apt-get update
37+
- apt-get install -y python3-apt python3-psutil
38+
- python3 ./fix_python_modules_paths.py
39+
- pip install --user --upgrade --pre git+https://gitlab.com/File2Package.py/File2Package.py.git git+https://github.com/amoffat/sh.git git+https://github.com/KOLANICH/python-debparse.git@fixes
40+
- mkdir ./wheels
41+
42+
script:
43+
- python3 ./setup.py bdist_wheel
44+
- mv ./dist/*.whl ./wheels/File2Package.backend.dpkg-0.CI_python-py3-none-any.whl
45+
- pip3 install --upgrade --pre --user ./wheels/File2Package.backend.dpkg-0.CI_python-py3-none-any.whl
46+
- coverage run --source=File2Package.backend.dpkg --branch -m pytest --junitxml=./rspec.xml ./tests/tests.py
47+
- coverage report -m
48+
- coverage xml
49+
50+
coverage: /^TOTAL\\s+.+?(\\d{1,3}%)$/
51+
52+
cache:
53+
paths:
54+
- $PYTHONUSERBASE
55+
56+
artifacts:
57+
paths:
58+
- wheels
59+
reports:
60+
junit: ./rspec.xml
61+
cobertura: ./coverage.xml
62+
63+
update_prebuilder_dependencies_image:
64+
only:
65+
- master
66+
stage: trigger
67+
allow_failure: true
68+
trigger:
69+
project: KOLANICH-subgroups/docker-images/prebuilder_dependencies
70+
strategy: depend

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!

File2Package/backend/dpkg.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import json
2+
import typing
3+
from pathlib import Path
4+
5+
import sh
6+
from AnyVer import AnyVer
7+
from fuckapt import *
8+
from PackageRef import VersionedPackageRef
9+
10+
11+
def init(interfaces):
12+
class DPKGFile2PackagePopulator(interfaces.IFile2PackagePopulator):
13+
__slots__ = ("infoFilesLoc", "defaultArch")
14+
15+
def __init__(self, infoFilesLoc: Path = infoFilesLoc, defaultArch: str = defaultArch):
16+
self.infoFilesLoc = infoFilesLoc
17+
self.defaultArch = defaultArch
18+
19+
def packagesMappingYielder(self, pkgs):
20+
index = {pkg["Package"].text: AnyVer(pkg["Version"].text) for pkg in readStatusFile() if "Version" in pkg}
21+
22+
for p in pkgs:
23+
nameArch = p.stem.split(":")
24+
if len(nameArch) != 1:
25+
name, arch = nameArch
26+
else:
27+
name = nameArch[0]
28+
arch = self.defaultArch
29+
30+
if name in index:
31+
ref = interfaces.VersionedPackageRef(name, arch, version=index[name])
32+
else:
33+
ref = interfaces.BasePackageRef(name, arch)
34+
35+
yield interfaces.FilesPackageMapping(ref, self.__class__.filesYielder(p))
36+
37+
def __call__(self):
38+
pkgs = tuple(self.infoFilesLoc.glob("*.list"))
39+
return len(pkgs), self.packagesMappingYielder(pkgs)
40+
41+
@staticmethod
42+
def filesYielder(p: Path):
43+
with p.open("rt", encoding="utf-8") as f:
44+
for l in f:
45+
yield Path(l.strip())
46+
47+
return DPKGFile2PackagePopulator

File2Package/backend/py.typed

Whitespace-only changes.

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include UNLICENSE
2+
include *.md
3+
include tests
4+
include .editorconfig

0 commit comments

Comments
 (0)