commit c6e8ee04cdbad7a9128f893a9ca9689c633f98b4 Author: bakachaneee <125930766+bakachaneee@users.noreply.github.com> Date: Thu Nov 9 09:20:04 2023 +0900 Add files via upload diff --git a/tjaf.py b/tjaf.py new file mode 100644 index 0000000..30dfdf5 --- /dev/null +++ b/tjaf.py @@ -0,0 +1,24 @@ +import pathlib + +class ValueWrapper(): + def __init__(self, value): + self.value = value + + def as_str(self): + return str(self.value) + + def as_file_ext(self): + path_str = self.as_str() + path = pathlib.Path(path_str) + return path.suffix.split(".",1)[1] + + def as_simple_str(self): + raw = self.as_str() + no_comment = raw.split("//",1)[0] + return no_comment.strip() + + def as_int(self): + return int(self.as_simple_str() or 0) + + def as_float(self): + return float(self.as_simple_str() or 0)