Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KOLANICH committed Oct 14, 2023
0 parents commit e04ffdd
Show file tree
Hide file tree
Showing 22 changed files with 972 additions and 0 deletions.
Empty file added .ci/aptPackagesToInstall.txt
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .github/.templateMarker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KOLANICH/python_project_boilerplate.py
8 changes: 8 additions & 0 deletions .github/dependabot.yml
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"
15 changes: 15 additions & 0 deletions .github/workflows/CI.yml
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 }}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
closure-compiler-*.jar
compiler_uberjar_deploy.jar

__pycache__
*.py[co]
/*.egg-info
*.srctrlbm
*.srctrldb
build
dist
.eggs
monkeytype.sqlite3
/.ipynb_checkpoints
51 changes: 51 additions & 0 deletions .gitlab-ci.yml
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/ClosureCompiler-0.CI-py3-none-any.whl
- pip3 install --upgrade ./dist/*.whl
- coverage run --source=ClosureCompiler -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
24 changes: 24 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Closure Compiler
Source: https://github.com/google/closure-compiler

Files: ClosureCompiler/lowLevel.py ClosureCompiler/__init__.py
Copyright:
2002 The Closure Compiler Authors
2007 Google Inc
2010 The Closure Library Authors
2011 PicNet Pty Ltd
2012 YouTube LLC
KOLANICH, 2023
License: Apache-2.0

Files: reuse/dep5
Copyright:
2013 Thomas Koch <thomas@koch.ro>
2018 Charlie Powell <charlie@evalagency.com>
KOLANICH, 2023
License: Apache-2.0

Files: .editorconfig .gitlab-ci.yml .gitignore ReadMe.md pyproject.toml Code_Of_Conduct.md MANIFEST.in tests/* .github/* ClosureCompiler/util.py ClosureCompiler/enums.py
Copyright: KOLANICH, 2023
License: Unlicense
53 changes: 53 additions & 0 deletions ClosureCompiler/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import typing
from pathlib import Path

from .enums import TypeInferMode
from .lowLevel import *
from .lowLevel import _optionsComponentTypes, _otherEssentialClasses

__all__ = ("SourcesMappingTU", "Compiler", "createCompilerOptions") + _optionsComponentTypes + _otherEssentialClasses


class ClosureCompilerErrror(RuntimeError):
__slots__ = ()


class Compiler:
__slots__ = ("compiler", "options")

def __init__(self, options: typing.Optional[CompilerOptions] = None) -> None:
if options is None:
options = createCompilerOptions()

self.options = options
self.compiler = None

@property
def _jsRoot(self):
prop = ji.reflectClass(self.compiler.__class__).getDeclaredField("jsRoot")
prop.setAccessible(True)
return prop.get(self.compiler)

def getBuiltInExterns(self):
return getBuiltInExterns(self.options.getEnvironment())

def __call__(self, sources: SourcesMappingTU, externs: typing.Optional[SourcesMappingTU] = None) -> Result:
return self.compile(sources, externs)

def compile(self, sources: SourcesMappingTU, externs: typing.Optional[SourcesMappingTU] = None) -> Result:
sources = convertSourcesMapping(sources)

builtinExterns = self.getBuiltInExterns()
if externs:
externs = convertSourcesMapping(externs)
else:
externs = []

self.compiler = ji.Compiler()
lowLevelRes = self.compiler.compile(
ji.ArrayList(externs + builtinExterns),
ji.ArrayList(sources),
self.options,
)

return Result.fromNativeResult(str(self.compiler.toSource()), lowLevelRes)
7 changes: 7 additions & 0 deletions ClosureCompiler/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from enum import IntFlag


class TypeInferMode(IntFlag):
none = 0b00
check = 0b01
infer = 0b10
Loading

0 comments on commit e04ffdd

Please sign in to comment.