Conversation
|
Is there an npm-like tool for python? |
There are some alternatives. |
IsaacG
left a comment
There was a problem hiding this comment.
Are we going the Python-route for tooling? Should I assume Python and use Python to make exercise generators?
| @@ -0,0 +1,104 @@ | |||
| import argparse | |||
There was a problem hiding this comment.
| import argparse | |
| #!/usr/bin/env python | |
| import argparse |
| ) | ||
| buffer = [] | ||
| counter = 1 | ||
| for line in diff: |
There was a problem hiding this comment.
Rather than building your own output, do you just want difflib.ndiff()?
There was a problem hiding this comment.
I tested it a bit, but it did not really do what I hoped to see. Maybe my config was off?
|
|
||
|
|
||
| def dir_path(path): | ||
| if os.path.isdir(path): |
There was a problem hiding this comment.
pathlib is the modern library for path operations.
| safeguard_sqlite_info = [] | ||
| for line in original.splitlines(): | ||
| if re.match(r'^[ ]*.|(--)', line): | ||
| safeguard_sqlite_info.append("/*TEMP" + line + "TEMP*/") |
There was a problem hiding this comment.
Does this break on trailing comments? Does this mean any line starting with a space is assumed to be a comment?
There was a problem hiding this comment.
I should escape the dot.
Trailing comments stay trailing with the normal parser, but single-line comments would be added after the last SQL statement, that did not look right for me, so I changed it.
|
|
||
|
|
||
| def parse_dir(args): | ||
| for subdir, dirs, files in os.walk(args.path): |
There was a problem hiding this comment.
pathlib.walk() or pathlib.rglob("*") might be easier to use.
pathlib also supports a pathlib.rename() and read_text() etc
I would suggest |
As a relative python newbie, what's the process for installing needed libraries?
|
|
For every |
|
I'll hold off on any further python library objections. Perhaps all that's required, once we see how much python tooling this track gets, is a documented list in CONTRIBUTING.md which libraries need installing. |
We could have a requirements file, that can be fed into pip. This is how many projects ensure that the libs are where they are needed. It is a pretty smooth process in my experience. I understand, that the dependencies are easy to handle if we use bash only, but I have to admit, that it takes me a lot longer to configure the tooling if I write it in bash. Github actions seem quite capable of running Python script in a dependable manner as well. For tooling that is probably used by students, I want to keep the requirements low. For the maintenance side, I am open to using the things that bring this track online and ready in the best way. |
Typically |
|
Ping :) |
This file is supposed to end up as a github action at some point to keep our code consistent.
For now let's discuss the changes it makes:
Details here: https://sqlparse.readthedocs.io/en/latest/api/#formatting-of-sql-statements