Add backend and frontend

This commit is contained in:
Gk0Wk
2024-04-07 15:04:00 +08:00
parent 49fdd9cc43
commit 84a7cb1b7e
233 changed files with 29927 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
class FormatList:
_list = []
offset: int = 0
def __init__(self, input_list: list, offset: int = 0):
self._list = input_list.copy()
self.offset = offset
def __str__(self):
s = str("")
if len(self._list) <= 0:
return s
if len(self._list) == 1:
return self._list[0]
if len(self._list) == 2:
return " and ".join(self._list)
if len(self._list) > 2:
return ", ".join(self._list[:-1]) + " and " + self._list[-1]
def Format(self):
s = str("")
if len(self._list) <= 0:
return s
if len(self._list) == 1:
return TransToFrontFormat(0 + self.offset)
if len(self._list) == 2:
return " and ".join(
[
TransToFrontFormat(i + self.offset)
for i in range(len(self._list))
]
)
if len(self._list) > 2:
return (
", ".join(
[
TransToFrontFormat(i + self.offset)
for i in range(len(self._list) - 1)
]
)
+ " and "
+ TransToFrontFormat(len(self._list) - 1 + self.offset)
)
def TransToFrontFormat(index: int):
return "!<" + str(index) + ">!"