mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
Everywhere: Format all python files with black
This commit is contained in:
parent
9e8336c04f
commit
2f9957c618
Notes:
github-actions[bot]
2025-05-22 14:22:50 +00:00
Author: https://github.com/trflynn89
Commit: 2f9957c618
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4841
Reviewed-by: https://github.com/gmta ✅
18 changed files with 338 additions and 350 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Generates a clang module map for a given directory
|
||||
Generates a clang module map for a given directory
|
||||
"""
|
||||
|
||||
import argparse
|
||||
|
@ -11,26 +11,24 @@ import sys
|
|||
|
||||
def write_file_if_not_same(file_path, content):
|
||||
try:
|
||||
with open(file_path, 'r') as f:
|
||||
with open(file_path, "r") as f:
|
||||
if f.read() == content:
|
||||
return
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
with open(file_path, 'w') as f:
|
||||
with open(file_path, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
epilog=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('directory', help='source directory to generate module map for')
|
||||
parser.add_argument('--module-name', help='top-level module name')
|
||||
parser.add_argument('--module-map', required=True, help='output module map file')
|
||||
parser.add_argument('--vfs-map', required=True, help='output VFS map file')
|
||||
parser.add_argument('--exclude-files', nargs='*', required=False, help='files to exclude in the module map')
|
||||
parser.add_argument('--generated-files', nargs='*', help='extra files to include in the module map')
|
||||
parser = argparse.ArgumentParser(epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("directory", help="source directory to generate module map for")
|
||||
parser.add_argument("--module-name", help="top-level module name")
|
||||
parser.add_argument("--module-map", required=True, help="output module map file")
|
||||
parser.add_argument("--vfs-map", required=True, help="output VFS map file")
|
||||
parser.add_argument("--exclude-files", nargs="*", required=False, help="files to exclude in the module map")
|
||||
parser.add_argument("--generated-files", nargs="*", help="extra files to include in the module map")
|
||||
args = parser.parse_args()
|
||||
|
||||
root = pathlib.Path(args.directory)
|
||||
|
@ -41,14 +39,14 @@ def main():
|
|||
pathlib.Path(args.vfs_map).parent.mkdir(parents=True, exist_ok=True)
|
||||
exclude_files = set(args.exclude_files) if args.exclude_files else set()
|
||||
|
||||
header_files = [f for f in root.rglob('**/*.h') if f.is_file() and f.name not in exclude_files]
|
||||
header_files = [f for f in root.rglob("**/*.h") if f.is_file() and f.name not in exclude_files]
|
||||
module_name = args.module_name if args.module_name else root.name
|
||||
|
||||
module_map = f"module {module_name} {{\n"
|
||||
for header_file in header_files:
|
||||
module_map += f" header \"{header_file.relative_to(root)}\"\n"
|
||||
module_map += f' header "{header_file.relative_to(root)}"\n'
|
||||
for generated_file in args.generated_files:
|
||||
module_map += f" header \"{generated_file}\"\n"
|
||||
module_map += f' header "{generated_file}"\n'
|
||||
module_map += " requires cplusplus\n"
|
||||
module_map += " export *\n"
|
||||
module_map += "}\n"
|
||||
|
@ -60,14 +58,14 @@ def main():
|
|||
{
|
||||
"name": f"{root}/module.modulemap",
|
||||
"type": "file",
|
||||
"external-contents": f"{args.module_map}"
|
||||
"external-contents": f"{args.module_map}",
|
||||
}
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
write_file_if_not_same(args.module_map, module_map)
|
||||
write_file_if_not_same(args.vfs_map, yaml.dump(vfs_map))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue