Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shirayu committed Apr 21, 2021
0 parents commit 4e2fb5b
Show file tree
Hide file tree
Showing 91 changed files with 7,102 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .circleci/check_head.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
import codecs
import collections
import sys
import typing


def main():
line2fnames: typing.DefaultDict[str, typing.List[str]] = collections.defaultdict(list)
for fname in sys.argv:
with codecs.open(fname, 'r', 'utf-8') as inf:
line = inf.readline()[:-1]
line2fnames[line].append(fname)
common_line = ''
common_num = 0
for line, fnames in line2fnames.items():
if len(fnames) > common_num:
common_num = len(fnames)
common_line = line
if len(line2fnames) != 1:
print(f'Common ({common_num}): {common_line}')
print('Others:')
for line, fnames in line2fnames.items():
if line != common_line:
print(f'\t{line}: \t{fnames}')
sys.exit(1)


if __name__ == '__main__':
main()
71 changes: 71 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
version: 2.1

jobs:
lint_with_node:
docker:
- image: circleci/node:12.20.0
working_directory: ~/app_lintwithnode
steps:
- checkout
- restore_cache:
keys:
- cache-{{ .Environment.CACHE_VERSION }}-lint_with_node

- run:
name: npm module install
command: |
make setup_node_module
- save_cache:
key: cache-{{ .Environment.CACHE_VERSION }}-lint_with_node
paths:
- ./node_modules

- run:
name: markdownlint
command: |
make lint_markdown
build:
docker:
- image: circleci/python:3.7.9
working_directory: ~
steps:
- checkout

- restore_cache:
key: deps-{{ checksum "poetry.lock" }}\
-{{ .Environment.CACHE_VERSION }}
- run:
name: Install dependencies
command: |
make -j $(nproc) dev_setup
- run:
name: setup-cc
command: |
poetry run make setup-cc
- save_cache:
key: deps-{{ checksum "poetry.lock" }}\
-{{ .Environment.CACHE_VERSION }}
paths:
- ~/.cache/pypoetry/virtualenvs
- ~/.local/bin-cc
- run:
name: Lint
command: |
poetry run make -j $(nproc) lint
- run:
name: Test Python codes
command: |
poetry run make -j $(nproc) test-cc
- store_artifacts:
path: htmlcov

workflows:
version: 2
build:
jobs:
- lint_with_node
- build
43 changes: 43 additions & 0 deletions .circleci/show_method_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
import ast
import typing


def get_method_names(tree_object):
result: typing.Dict[int, typing.Tuple[str, int]] = {}
searched_line_no = 0
for node in ast.iter_child_nodes(tree_object):
if isinstance(node, ast.FunctionDef):
result[node.lineno] = (node.name, node.lineno)

for child in ast.iter_child_nodes(node):
get_method_names(child)

if hasattr(node, 'lineno'):
if node.lineno > searched_line_no:
searched_line_no = node.lineno
else:
t = result.get(node.lineno)
if t is not None:
result[node.lineno] = (t[0], searched_line_no)

return result


if __name__ == '__main__':
import codecs
import os
import sys
with codecs.open(sys.argv[1], 'r', 'utf-8') as f:
try:
source = f.read()
except UnicodeDecodeError:
raise Exception(sys.argv[1])

tree = ast.parse(source, os.path.basename(sys.argv[1]))
import re
pattern = re.compile(r'split|divide|文分割')

for line_no, v in get_method_names(tree).items():
if len(pattern.findall(v[0])) > 0:
raise Exception(f'method name violation {v[0]} at file-name = {sys.argv[1]}')
10 changes: 10 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

[run]
omit =
*/site-packages/*
*/distutils/*
tests/*

[report]
exclude_lines =
if __name__ == .__main__.:
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
versioning-strategy: lockfile-only
154 changes: 154 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
python_env
out
# 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/
cover/

# 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
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .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/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# static files generated from Django application using `collectstatic`
media
static

.idea/
.DS_Store
resource/
runs/
work_scripts/
models/
data
OLD
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
known_third_party=
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"MD007": {
"indent": 4
},
"line-length": false,
"no-inline-html": false
}
Loading

0 comments on commit 4e2fb5b

Please sign in to comment.