Skip to content

Commit cafde9e

Browse files
committed
feat: start on compiling to one file
1 parent 76e1a6f commit cafde9e

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
# nextcord-ol
22

3-
## :warning:**Should not be used - just a joke**:warning:
3+
## :warning:**Should not be used - just a joke**:warning
44

55
Make nextcord one line
66

77
~~for NCv4~~
88

99
<https://github.com/nextcord/nextcord> for the sane version
10+
11+
### How to run
12+
13+
```bash
14+
git clone https://github.com/nextcord/nextcord-ol
15+
poetry install # or pip install -e .
16+
git submodule update
17+
poetry run python oneliner.py # or python oneliner.py
18+
```

oneliner.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,37 @@
22
from pathlib import Path
33
from libcst import parse_module
44

5-
from transformers import StatementTransformer
5+
# from transformers import StatementTransformer
6+
# from transformers import ImportTransformer
67

78

89
target = "nextcord_submodule/nextcord"
910
write = "nextcord_test"
1011

1112

1213
def parse_file(path: Path) -> None:
13-
print(path)
1414
cst = parse_module(path.read_text())
15-
cst = cst.visit(StatementTransformer())
15+
# cst = cst.visit(StatementTransformer())
1616

17-
path = Path(str(path).replace(target, write))
18-
makedirs(Path(*path.parts[:-1]), exist_ok=True)
19-
with open(path, "w") as f:
20-
f.write(cst.code)
17+
path.write_text(cst.code)
2118

2219

2320
def parse_directory(directory: Path) -> None:
21+
output = ""
22+
2423
for file in directory.glob("**/*.py"):
25-
parse_file(file)
24+
output += file.read_text() + "\n"
25+
26+
path = Path("nextcord_test/onelined.py")
27+
28+
path.write_text(output)
29+
30+
parse_file(path)
2631

2732

2833
def main() -> None:
34+
makedirs(write, exist_ok=True)
35+
2936
parse_directory(Path(target))
3037

3138

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ libcst = "^0.4.1"
1717
[build-system]
1818
requires = ["poetry-core>=1.0.0"]
1919
build-backend = "poetry.core.masonry.api"
20+
21+
[tool.pyright]
22+
typeChectypeCheckingMode = "off" # cant bear 1K errors while working on this

transformers/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .statement import StatementTransformer
2+
from .imports import ImportTransformer
23

34

4-
__all__ = ("StatementTransformer",)
5+
__all__ = ("StatementTransformer", "ImportTransformer")

transformers/imports.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from libcst import CST

0 commit comments

Comments
 (0)