Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rendergraph: Port perl script to Python and add pre-commit hook #18

Conversation

Holzhaus
Copy link

No description provided.

@Holzhaus Holzhaus changed the title rendergrah: Port perl script to Python and add pre-commit hook rendergraph: Port perl script to Python and add pre-commit hook Dec 17, 2024
Copy link

@acolombier acolombier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this! The python version is definitely more beefy but also should support wider system setup, as well as provide logging a command usage.

Comment on lines +72 to +91
if in_shader_block == 2:
if re.match(r"^\*\*", line):
ok = True
else:
if not comment_added and not re.match(r"^#", line):
yield "//// GENERATED - EDITS WILL BE OVERWRITTEN"
comment_added = True
if line:
if buffered_blank_line:
yield ""
buffered_blank_line = False
yield line
else:
buffered_blank_line = True
elif in_shader_block == 1:
if line.rstrip() == "Contents:":
in_shader_block = 2
else:
if line.rstrip() == "Shader 1: GLSL 120 [Standard]":
in_shader_block = 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very naive suggestion here, to help flattening the nested logic

Suggested change
if in_shader_block == 2:
if re.match(r"^\*\*", line):
ok = True
else:
if not comment_added and not re.match(r"^#", line):
yield "//// GENERATED - EDITS WILL BE OVERWRITTEN"
comment_added = True
if line:
if buffered_blank_line:
yield ""
buffered_blank_line = False
yield line
else:
buffered_blank_line = True
elif in_shader_block == 1:
if line.rstrip() == "Contents:":
in_shader_block = 2
else:
if line.rstrip() == "Shader 1: GLSL 120 [Standard]":
in_shader_block = 1
if in_shader_block == 2:
if re.match(r"^\*\*", line):
ok = True
else:
if not comment_added and not re.match(r"^#", line):
yield "//// GENERATED - EDITS WILL BE OVERWRITTEN"
comment_added = True
if line:
if buffered_blank_line:
yield ""
buffered_blank_line = False
yield line
else:
buffered_blank_line = True
elif in_shader_block == 1 and line.rstrip() == "Contents:":
in_shader_block = 2
elif line.rstrip() == "Shader 1: GLSL 120 [Standard]":
in_shader_block = 1

Comment on lines +40 to +44
additional_paths=[
"/usr/lib/qt6/bin",
"/lib/qt6/bin",
"/usr/local/lib/qt6/bin",
],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use $PATH as well?

Suggested change
additional_paths=[
"/usr/lib/qt6/bin",
"/lib/qt6/bin",
"/usr/local/lib/qt6/bin",
],
additional_paths=[
"/usr/lib/qt6/bin",
"/lib/qt6/bin",
"/usr/local/lib/qt6/bin",
] + [os.getenv("PATH", "").split(":")],

Copy link
Author

@Holzhaus Holzhaus Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call shutil.which up to two times in the funtion, the first time without setting the path argument which implicitly defaults to $PATH. So yeah, that is already supported.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good to know. Thanks for the lesson!

@m0dB m0dB merged commit b80d02b into m0dB:rg-use-opengl-node-and-add-shaders Dec 22, 2024
1 check passed
@m0dB
Copy link
Owner

m0dB commented Dec 22, 2024

Thanks @Holzhaus !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants