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

Style script fix platform dependent path separator #1889

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tools/style_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create_namespace_structure(extension: str, path: str, root_namespace: str =

if os.path.isfile(path):
namespace_structure[root_namespace] = {
os.path.splitext(path)[0]: path.replace('\\', '/')
os.path.splitext(path)[0]: path
}
return namespace_structure

Expand All @@ -25,7 +25,7 @@ def create_namespace_structure(extension: str, path: str, root_namespace: str =
if relative_path == ".":
relative_path = root_namespace
namespace_structure[relative_path] = {
os.path.splitext(f)[0]: os.path.join(dirpath, f).replace('\\', '/')
os.path.splitext(f)[0]: os.path.join(dirpath, f)
for f in files
}

Expand All @@ -48,7 +48,7 @@ def replace_property(in_file: str, value: str) -> bool:

# Generates a QSS variable for a given file
def generate_qss_variable(filepath: str, indent: str, root_folder: str) -> str:
value = os.path.relpath(filepath, root_folder).replace("/", "_").replace(".qss", "")
value = os.path.relpath(filepath, root_folder).replace(os.sep, "_").replace(".qss", "")
if not replace_property(filepath, value):
return ""

Expand All @@ -67,7 +67,7 @@ def add_namespaces(folder: List[str], files: Dict[str, str], level: int) -> None
code_lines.append(variable_func(filepath, f'{indent}\t', root_folder))
else:
subnamespace = {k: v for k, v in namespace_structure.items() if
k.startswith('/'.join(folder[:level + 1]) + '/')}
k.startswith(os.sep.join(folder[:level + 1]) + os.sep)}
if subnamespace:
for subpath, subfiles in subnamespace.items():
subpath_parts = subpath.split(os.sep)
Expand Down Expand Up @@ -137,7 +137,7 @@ def parse_json_file(filepath: str, root_folder: str) -> Dict[str, str]:
for item in items:
key, value = item.split(':', 1)
key = key.strip().strip('"')
formatted_key = os.path.relpath(filepath, root_folder).replace("/", "_").replace(".json", "") + "_" + key
formatted_key = os.path.relpath(filepath, root_folder).replace(os.sep, "_").replace(".json", "") + "_" + key
json_content[key] = formatted_key

return json_content
Expand Down
Loading