Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for python versions older than 3.10 #5

Merged
merged 1 commit into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gdlevelconverter/conversion/conversionoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from dataclasses import dataclass
from typing import Optional
from typing import Optional, List

from .gjgameobjectconversiongroups.gjgameobjectconversiongroup \
import GJGameObjectConversionGroup
Expand All @@ -14,5 +14,5 @@ class ConversionOptions:
"""
Options during full level conversion
"""
groups: list[GJGameObjectConversionGroup]
groups: List[GJGameObjectConversionGroup]
maximum_id: Optional[int] = None
8 changes: 4 additions & 4 deletions gdlevelconverter/conversion/conversionreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from dataclasses import dataclass
from typing import Generic, TypeVar
from typing import Generic, TypeVar, List, Dict

from .gjgameobjectconversiongroups.gjgameobjectconversiongroup import GJGameObjectConversionGroup

Expand All @@ -17,7 +17,7 @@ class ConversionReport(Generic[TYPE]):
"""
Options during full level conversion
"""
converted_triggers: list[TYPE]
group_conversions: dict[GJGameObjectConversionGroup, list[TYPE]]
removed_objects: list[TYPE]
converted_triggers: List[TYPE]
group_conversions: Dict[GJGameObjectConversionGroup, List[TYPE]]
removed_objects: List[TYPE]
preconversion_object_count: int
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from dataclasses import dataclass
from typing import List


@dataclass(frozen=True)
Expand All @@ -20,7 +21,7 @@ class GJGameObjectConversionGroup:
Defines a conversion group
"""
name: str
conversions: list[GJGameObjectConversion]
conversions: List[GJGameObjectConversion]
show_hitbox_warning: bool = False
show_visual_warning: bool = False

Expand Down
4 changes: 2 additions & 2 deletions gdlevelconverter/conversion/levelsettingscolorconversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from dataclasses import dataclass

from typing import List

@dataclass(frozen=True)
class LevelSettingsColorConversion():
Expand All @@ -14,7 +14,7 @@ class LevelSettingsColorConversion():
header_key: str


LevelSettingsColorConversions: list[LevelSettingsColorConversion] = [
LevelSettingsColorConversions: List[LevelSettingsColorConversion] = [
LevelSettingsColorConversion(1, "color_1"),
LevelSettingsColorConversion(2, "color_2"),
LevelSettingsColorConversion(3, "color_3"),
Expand Down
3 changes: 2 additions & 1 deletion gdlevelconverter/conversion/triggerobjectcolorconversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

from dataclasses import dataclass
from typing import List


@dataclass(frozen=True)
Expand All @@ -14,7 +15,7 @@ class TriggerObjectColorConversion():
result_id: int


TriggerObjectColorConversions: list[TriggerObjectColorConversion] = [
TriggerObjectColorConversions: List[TriggerObjectColorConversion] = [
TriggerObjectColorConversion(1, 221),
TriggerObjectColorConversion(2, 717),
TriggerObjectColorConversion(3, 718),
Expand Down
4 changes: 2 additions & 2 deletions gdlevelconverter/gjobjects/gjclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass
import urllib.request
import urllib.parse

from typing import Dict

@dataclass
class GJClient:
Expand All @@ -20,7 +20,7 @@ class GJClient:
udid: str = "S-hi-people"
user_name: str = "21Reupload"

def make_req(self, url: str, data: dict[str, str]):
def make_req(self, url: str, data: Dict[str, str]):
"""
Makes a post request a url with data
"""
Expand Down
12 changes: 6 additions & 6 deletions gdlevelconverter/gjobjects/gjdictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from abc import abstractmethod
from dataclasses import dataclass
from typing import Callable
from typing import Callable, List, Tuple


@dataclass
Expand Down Expand Up @@ -34,14 +34,14 @@ class ObjectDefinition:
"""


def class_from_string(string: str, splitter: str, definitions: list[ObjectDefinition], cls: object):
def class_from_string(string: str, splitter: str, definitions: List[ObjectDefinition], cls: object):
"""
parses the special robtop style array
- expects string like 1,53,2,65,3,14.3
- returns dict like {'1': '53', '2': '65', '3': '14.3'}
"""

split_first_step: list[str] = string.split(splitter)
split_first_step: List[str] = string.split(splitter)

for index, _value in enumerate(split_first_step):
# if odd then we on index
Expand Down Expand Up @@ -83,7 +83,7 @@ def from_list(splitter: str):
Used as value in object definition
Creates a function that converts a list into string using splitter
"""
def into_str(obj: list[any]):
def into_str(obj: List[any]):
# gd ends lists with splitter from what i can tell
return splitter.join([str(x) for x in obj]) + splitter

Expand All @@ -104,7 +104,7 @@ def _splitter(self) -> str:

@property
@abstractmethod
def _definitions(self) -> list[ObjectDefinition]:
def _definitions(self) -> List[ObjectDefinition]:
"""
Defintions for use when converting to/from dictionary
"""
Expand All @@ -127,7 +127,7 @@ def __init__(self, string: str = None):
def __info_for_key(self, key: str):
return next((x for x in self._definitions if x.key == key), None)

def __map_tuple_key_to_index(self, obj: tuple[str, any]):
def __map_tuple_key_to_index(self, obj: Tuple[str, any]):
(key, value) = obj

key_info = self.__info_for_key(key)
Expand Down
1 change: 1 addition & 0 deletions gdlevelconverter/gjobjects/gjgamelevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .gjclient import GJClient
from .gjlevelstring import GJLevelString
from . import gjdictionary
from typing import Dict


class GJGameLevel(gjdictionary.GJDictionary):
Expand Down
4 changes: 2 additions & 2 deletions gdlevelconverter/gjobjects/gjgameobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
GJGameObject class definition
"""

from typing import Optional
from typing import Optional, List

from ..conversion import GJGameObjectConversionGroup
from ..conversion import TriggerObjectColorConversions
Expand Down Expand Up @@ -67,7 +67,7 @@ def to_legacy_color(self) -> bool:

def remap_to_legacy_id_by_groups(
self,
groups: list[GJGameObjectConversionGroup]
groups: List[GJGameObjectConversionGroup]
) -> Optional[GJGameObjectConversionGroup]:
"""
Remaps the object's id based on the ids defined in groups
Expand Down
4 changes: 2 additions & 2 deletions gdlevelconverter/gjobjects/gjlevelsettingsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Definition for GJLevelSettingsObject
"""

from typing import Optional
from typing import Optional, List, Dict

from ..conversion import LevelSettingsColorConversions
from .gjcolorobject import GJColorObject
Expand Down Expand Up @@ -50,7 +50,7 @@ class GJLevelSettingsObject(gjdictionary.GJDictionary):
color_4: Optional[GJColorObject]
color_3dl: Optional[GJColorObject]

color_list: Optional[list[GJColorObject]]
color_list: Optional[List[GJColorObject]]

def to_legacy_format(self) -> bool:
"""
Expand Down
3 changes: 2 additions & 1 deletion gdlevelconverter/gjobjects/gjlevelstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ..conversion.conversionreport import ConversionReport
from .gjgameobject import GJGameObject
from .gjlevelsettingsobject import GJLevelSettingsObject
from typing import List


class GJLevelString:
Expand All @@ -18,7 +19,7 @@ class GJLevelString:
OBJECT_SEPARATOR: str = ";"

header: GJLevelSettingsObject
objects: list[GJGameObject]
objects: List[GJGameObject]

def __init__(self, level):
object_strings = level.split(self.OBJECT_SEPARATOR)
Expand Down
3 changes: 2 additions & 1 deletion tests/testgjdictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest

from gdlevelconverter.gjobjects import gjdictionary
from typing import List


class GJTestObject(gjdictionary.GJDictionary):
Expand All @@ -27,7 +28,7 @@ class GJTestObject(gjdictionary.GJDictionary):

title: str

names: list[str]
names: List[str]


class TestGJDictionary(unittest.TestCase):
Expand Down