Created
April 24, 2022 12:59
-
-
Save scarf005/3c5719d45956d67f9f82db89898b90e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import environ | |
from pathlib import Path | |
from typing import Tuple | |
template = """\ | |
{line} | |
{s:39} {e} | |
{s:39} ::: :::::::: {e} | |
{s:4} {filename:50.50} :+: :+: :+: {e} | |
{s:39} +:+ +:+ +:+ {e} | |
{s:3} {by:45.45} +#+ +:+ +#+ {e} | |
{s:39} +#+#+#+#+#+ +#+ {e} | |
{s:4} {created:49.49} #+# #+# {e} | |
{s:4} {updated:49.49}### ########.fr {e} | |
{s:39} {e} | |
{line} | |
""" | |
filename = Path("dda_dist.c") | |
# filename = Path("../Makefile") | |
name = "youkim" | |
mail = "[email protected]" | |
def create_header(path: Path, name: str, mail: str) -> str: | |
def get_begin_end(ext: str) -> Tuple[str, str]: | |
print(f"ext: {ext}") | |
if ext in [".c", ".h", ".cpp", ".hpp"]: | |
return "/* ", "*/" | |
else: | |
return "# ", " #" | |
begin, end = get_begin_end(path.suffix) | |
fmt_entry = { | |
"by": f"By: {name} <{mail}>", | |
"created": f"Created: 2022/04/24 20:15:35 by {name}", | |
"updated": f"Updated: 2022/04/24 20:15:36 by {name}", | |
"line": (begin).ljust(77, "*") + end.rjust(3), | |
} | |
return template.format(filename=path.name, s=begin, e=end, **fmt_entry) | |
def main(): | |
print(create_header(filename, name, mail)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment