File tree 5 files changed +31
-10
lines changed
5 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 1
1
# nextcord-ol
2
2
3
- ## :warning : ** Should not be used - just a joke** :warning :
3
+ ## :warning : ** Should not be used - just a joke** : warning
4
4
5
5
Make nextcord one line
6
6
7
7
~~ for NCv4~~
8
8
9
9
< 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
+ ```
Original file line number Diff line number Diff line change 2
2
from pathlib import Path
3
3
from libcst import parse_module
4
4
5
- from transformers import StatementTransformer
5
+ # from transformers import StatementTransformer
6
+ # from transformers import ImportTransformer
6
7
7
8
8
9
target = "nextcord_submodule/nextcord"
9
10
write = "nextcord_test"
10
11
11
12
12
13
def parse_file (path : Path ) -> None :
13
- print (path )
14
14
cst = parse_module (path .read_text ())
15
- cst = cst .visit (StatementTransformer ())
15
+ # cst = cst.visit(StatementTransformer())
16
16
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 )
21
18
22
19
23
20
def parse_directory (directory : Path ) -> None :
21
+ output = ""
22
+
24
23
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 )
26
31
27
32
28
33
def main () -> None :
34
+ makedirs (write , exist_ok = True )
35
+
29
36
parse_directory (Path (target ))
30
37
31
38
Original file line number Diff line number Diff line change @@ -17,3 +17,6 @@ libcst = "^0.4.1"
17
17
[build-system ]
18
18
requires = [" poetry-core>=1.0.0" ]
19
19
build-backend = " poetry.core.masonry.api"
20
+
21
+ [tool .pyright ]
22
+ typeChectypeCheckingMode = " off" # cant bear 1K errors while working on this
Original file line number Diff line number Diff line change 1
1
from .statement import StatementTransformer
2
+ from .imports import ImportTransformer
2
3
3
4
4
- __all__ = ("StatementTransformer" ,)
5
+ __all__ = ("StatementTransformer" , "ImportTransformer" )
Original file line number Diff line number Diff line change
1
+ from libcst import CST
You can’t perform that action at this time.
0 commit comments