whg 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- whg-1.0.0/PKG-INFO +24 -0
- whg-1.0.0/README.md +16 -0
- whg-1.0.0/pyproject.toml +17 -0
- whg-1.0.0/setup.cfg +4 -0
- whg-1.0.0/src/whg/__init__.py +29 -0
- whg-1.0.0/src/whg.egg-info/PKG-INFO +24 -0
- whg-1.0.0/src/whg.egg-info/SOURCES.txt +7 -0
- whg-1.0.0/src/whg.egg-info/dependency_links.txt +1 -0
- whg-1.0.0/src/whg.egg-info/top_level.txt +1 -0
whg-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: whg
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python helper for code formatting and syntax checking
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# WHG
|
|
10
|
+
|
|
11
|
+
Python helper library for Termux and Python projects.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
import whg
|
|
16
|
+
|
|
17
|
+
ok, message = whg.check_file("main.py")
|
|
18
|
+
print(ok, message)
|
|
19
|
+
|
|
20
|
+
fixed = whg.fix_code(" print('Hello')")
|
|
21
|
+
print(fixed)
|
|
22
|
+
|
|
23
|
+
WHG checks Python syntax and normalizes basic indentation.
|
|
24
|
+
It does not automatically repair every syntax or logic error.
|
whg-1.0.0/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# WHG
|
|
2
|
+
|
|
3
|
+
Python helper library for Termux and Python projects.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
import whg
|
|
8
|
+
|
|
9
|
+
ok, message = whg.check_file("main.py")
|
|
10
|
+
print(ok, message)
|
|
11
|
+
|
|
12
|
+
fixed = whg.fix_code(" print('Hello')")
|
|
13
|
+
print(fixed)
|
|
14
|
+
|
|
15
|
+
WHG checks Python syntax and normalizes basic indentation.
|
|
16
|
+
It does not automatically repair every syntax or logic error.
|
whg-1.0.0/pyproject.toml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "whg"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Python helper for code formatting and syntax checking"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
|
|
13
|
+
[tool.setuptools]
|
|
14
|
+
package-dir = {"" = "src"}
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
where = ["src"]
|
whg-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
import textwrap
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
__version__ = "1.0.0"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def fix_code(code):
|
|
9
|
+
"""Chuẩn hóa thụt lề cơ bản cho một khối code."""
|
|
10
|
+
return textwrap.dedent(code).expandtabs(4)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def check_code(code):
|
|
14
|
+
"""Trả về (True, thông báo) hoặc (False, lỗi cú pháp)."""
|
|
15
|
+
try:
|
|
16
|
+
ast.parse(code)
|
|
17
|
+
return True, "Không phát hiện lỗi cú pháp."
|
|
18
|
+
except SyntaxError as e:
|
|
19
|
+
return False, f"Dòng {e.lineno}: {e.msg}"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def check_file(filename):
|
|
23
|
+
"""Kiểm tra cú pháp file Python, không sửa file gốc."""
|
|
24
|
+
path = Path(filename)
|
|
25
|
+
try:
|
|
26
|
+
code = path.read_text(encoding="utf-8")
|
|
27
|
+
except OSError as e:
|
|
28
|
+
return False, str(e)
|
|
29
|
+
return check_code(code)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: whg
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python helper for code formatting and syntax checking
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# WHG
|
|
10
|
+
|
|
11
|
+
Python helper library for Termux and Python projects.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
import whg
|
|
16
|
+
|
|
17
|
+
ok, message = whg.check_file("main.py")
|
|
18
|
+
print(ok, message)
|
|
19
|
+
|
|
20
|
+
fixed = whg.fix_code(" print('Hello')")
|
|
21
|
+
print(fixed)
|
|
22
|
+
|
|
23
|
+
WHG checks Python syntax and normalizes basic indentation.
|
|
24
|
+
It does not automatically repair every syntax or logic error.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
whg
|