Skip to content

Instantly share code, notes, and snippets.

@mebiusbox
Last active September 15, 2024 07:34
Show Gist options
  • Save mebiusbox/eaa3f1dd74126f0ede8b9b683672fcf3 to your computer and use it in GitHub Desktop.
Save mebiusbox/eaa3f1dd74126f0ede8b9b683672fcf3 to your computer and use it in GitHub Desktop.
python
# python generated files
__pycache__/
*.py[cod]
*.so
*$py.class
# distribution / packaging
build/
dist/
wheels/
*.egg-info
# pyinstaller
*.manifest
*.spec
# package manager
#poetry.lock
#uv.lock
# ruff
.ruff_cache
# for visual studio code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
*.code-workspace
!default.code-workspace
.devcontainer/devcontainer.json
.devcontainer/docker-compose.override.yml
# Built Visual Studio Code Extensions
*.vsix
# local
.local/
*.local.*
# backup / temp / log
*.bak
*.old
*.log
*.tmp
# environments
.env
.venv
venv/
# OS generated files
.DS_Store
Thumbs.db
# project
version: 1
disable_existing_loggers: false
formatters:
default:
format: '{asctime} [{levelname:5}] {message}'
datefmt: '%Y/%m/%d %H:%M:%S'
style: '{'
filename:
format: '{asctime} [{levelname:5}] {message} ({filename}:{lineno})'
datefmt: '%Y/%m/%d %H:%M:%S'
style: '{'
withname:
format: '{asctime} {name} [{levelname:5}] {message} ({filename}:{lineno})'
datefmt: '%Y/%m/%d %H:%M:%S'
style: '{'
filters:
app_filter:
(): __main__.LoggingNameFilter
names: [main,main_log,app,app_log]
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: default
filters: [app_filter]
stream: ext://sys.stdout
# all:
# class: logging.StreamHandler
# level: DEBUG
# formatter: default
# stream: ext://sys.stdout
# file:
# class: logging.FileHandler
# level: DEBUG
# filename: "app.log"
# formatter: default
loggers:
main:
level: WARNING
handlers: [console]
propagate: false
# main_log:
# level: WARNING
# handlers: [console,file]
# propagate: false
# app:
# level: WARNING
# handlers: [console]
# propagate: false
# app_log:
# level: WARNING
# handlers: [console,file]
# propagate: false
root:
level: WARNING
handlers: [console]
#------------------------------------------------------------------------------
# PYAML version
#
#from pathlib import Path
#from typing import Any
#import logging
#import logging.config
#import yaml
#
#def read_yaml(input_file: Path) -> Any:
# with input_file.open(encoding="utf-8") as yml:
# return yaml.load(yml, Loader=yaml.SafeLoader)
#
#
#class LoggingNameFilter(logging.Filter):
# def __init__(self, names: str[]) -> None:
# self.names = names
#
# def filter(self, record: logging.LogRecord) -> bool:
# return record.name in self.names
#
#logging.config.dictConfig(read_yaml(Path(__file__).absolute().parent / ".logging.yaml"))
#log = logging.getLogger(__name__)
#log.setLevel(logging.DEBUG)
#------------------------------------------------------------------------------
# ruamel.yaml version
#
#from pathlib import Path
#from typing import Any
#import logging
#import logging.config
#import ruamel
#import ruamel.yaml
#
#yaml = ruamel.yaml.YAML()
#
#def read_yaml(input_file: Path) -> Any:
# with input_file.open(encoding="utf-8") as yml:
# return yaml.load(yml)
#
#
#class LoggingNameFilter(logging.Filter):
# def __init__(self, names: str[]) -> None:
# self.names = names
#
# def filter(self, record: logging.LogRecord) -> bool:
# return record.name in self.names
#
#logging.config.dictConfig(read_yaml(Path(__file__).absolute().parent / ".logging.yaml"))
#log = logging.getLogger(__name__)
#log.setLevel(logging.DEBUG)
# -*- coding:utf-8
"""This serves as a long usage message."""
import argparse
import sys
import logging
import logging.config
import yaml
from pathlib import Path
from typing import Any
def read_yaml(input_file: Path) -> Any:
with input_file.open(encoding="utf-8") as yml:
return yaml.load(yml, Loader=yaml.SafeLoader)
class LoggingNameFilter(logging.Filter):
def __init__(self, names: str[]) -> None:
self.names = names
def filter(self, record: logging.LogRecord) -> bool:
return record.name in self.names
logging.config.dictConfig(read_yaml(Path(__file__).absolute().parent / ".logging.yaml"))
logger = logging.getLogger(__name__)
# logger = logging.getLogger("main_log")
# logger.setLevel(logging.DEBUG)
def cmdline_args():
p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
p.add_argument("input", help="input files")
p.add_argument(
"-o", "--output", dest="output", default="./output", action="store", help="Path of the output directory"
)
p.add_argument("-b", "--bar", action="store_true", help="description")
p.add_argument("-f", "--foo", default=100, action="store", help="image resolution of y-coordinate")
p.add_argument("-v", "--verbose", action="store_true", help="increase output verbosity")
return p.parse_args()
def main(argv=None):
# args = cmdline_args()
# src = args.input
# dst = args.output
return 0
if __name__ == "__main__":
sys.exit(main())
[config]
skip_core_tasks = true
[env]
PACKAGE_NAME = "package_name"
[tasks.default]
run_task = "build"
# command = "makers"
# args = ["--list-all-steps"]
# [tasks.ps]
# category = "General"
# script_runner = "powershell"
# script_extension = "ps1"
# script = '''
# Write-Host "Hello, World!"
# '''
[tasks.publish]
description = "publish execution binary file"
command = "pyinstaller"
args = [
".\\src\\${PACKAGE_NAME}\\main.py",
"-n", "${PACKAGE_NAME}",
"--onefile",
"--noconsole"
]
[tasks.build]
description = "run"
command = "python"
args = [
".\\src\\${PACKAGE_NAME}\\main.py"
]
[tasks.clean]
cwd = "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}/"
description = "clean interemediate and final output files"
command = "pwsh"
args = [
"-C",
'Remove-Item -LiteralPath "build","dist" -Force'
]
[tasks.run]
cwd = "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}/dist/"
script = "${PACKAGE_NAME}.exe"
[tasks.echo]
script = "echo Hoge"
[tasks.hello]
cwd = "${CARGO_MAKE_CURRENT_TASK_INITIAL_MAKEFILE_DIRECTORY}/"
command = "pwsh"
args = [
"-C",
"Get-Location",
# "$PSVersionTable"
]
[tasks.dump]
command = "pwsh"
args = [
"-C",
"Get-ChildItem env:"
]
[tasks.test]
description = "usage: hoge"
category = "Generate"
command = "makers"
args = [
"${@}",
"--list-all-steps"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment