Rename variables for readability

This commit is contained in:
Susko3 2024-10-29 20:37:34 +00:00 committed by Sam Lantinga
parent bdf16628fb
commit 415abf2ea2
1 changed files with 14 additions and 14 deletions

View File

@ -4,7 +4,7 @@ import uuid
REPOSITORY_ROOT = pathlib.Path(__file__).parent.parent.parent REPOSITORY_ROOT = pathlib.Path(__file__).parent.parent.parent
def generate(x, y): def generate(category, example_name):
guid = str(uuid.uuid4()).upper() guid = str(uuid.uuid4()).upper()
text = f""" text = f"""
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
@ -15,31 +15,31 @@ def generate(x, y):
<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" />
<ItemGroup> <ItemGroup>
<None Include="$(SolutionDir)\\..\\examples\\{x}\\{y}\\README.txt" /> <None Include="$(SolutionDir)\\..\\examples\\{category}\\{example_name}\\README.txt" />
<ClCompile Include="$(SolutionDir)\\..\\examples\\{x}\\{y}\\*.c" /> <ClCompile Include="$(SolutionDir)\\..\\examples\\{category}\\{example_name}\\*.c" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" />
</Project> </Project>
""".strip() """.strip()
file_name = REPOSITORY_ROOT / "VisualC" / "examples" / x / y / f"{y}.vcxproj" project_file = REPOSITORY_ROOT / "VisualC" / "examples" / category / example_name / f"{example_name}.vcxproj"
if file_name.exists(): if project_file.exists():
print("Skipping:", file_name) print("Skipping:", project_file)
return return
print("Generating file:", file_name) print("Generating file:", project_file)
os.makedirs(file_name.parent, exist_ok=True) os.makedirs(project_file.parent, exist_ok=True)
with open(file_name, "w", encoding="utf-8") as f: with open(project_file, "w", encoding="utf-8") as f:
f.write(text) f.write(text)
def main(): def main():
path = REPOSITORY_ROOT / "examples" path = REPOSITORY_ROOT / "examples"
for x in path.iterdir(): for category in path.iterdir():
if x.is_dir(): if category.is_dir():
for y in x.iterdir(): for example in category.iterdir():
generate(x.name, y.name) generate(category.name, example.name)
if __name__ == "__main__": if __name__ == "__main__":