From 27c3bea52e4418e818730592207b558e3a034dbf Mon Sep 17 00:00:00 2001 From: Andrey <50486086+DarkCat09@users.noreply.github.com> Date: Fri, 15 Oct 2021 19:31:47 +0400 Subject: [PATCH] Add files via upload --- python_aternos/atconf.py | 9 ++++++--- python_aternos/atfile.py | 9 ++++++--- python_aternos/atfm.py | 9 ++++++--- python_aternos/atplayers.py | 7 +++++-- python_aternos/atserver.py | 2 +- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/python_aternos/atconf.py b/python_aternos/atconf.py index 1d87616..398cd7b 100644 --- a/python_aternos/atconf.py +++ b/python_aternos/atconf.py @@ -1,10 +1,13 @@ import re import lxml.html -from typing import Any, Dict, List +from typing import Any, Dict, List, Optional +from typing import TYPE_CHECKING -from . import atserver from . import atconnect +if TYPE_CHECKING: + from atserver import AternosServer + OPT_PLAYERS = 'max-players' OPT_GAMEMODE = 'gamemode' OPT_DIFFICULTY = 'difficulty' @@ -72,7 +75,7 @@ FLAG_PROP_TYPE = 1 class AternosConfig: - def __init__(self, atserv:atserver.AternosServer) -> None: + def __init__(self, atserv:'AternosServer') -> None: self.atserv = atserv diff --git a/python_aternos/atfile.py b/python_aternos/atfile.py index a3cb782..859727b 100644 --- a/python_aternos/atfile.py +++ b/python_aternos/atfile.py @@ -1,16 +1,19 @@ import lxml.html from typing import Union +from typing import TYPE_CHECKING -from . import atserver from . import atconnect +if TYPE_CHECKING: + from atserver import AternosServer + FTYPE_FILE = 0 FTYPE_DIR = 1 class AternosFile: def __init__( - atserv:atserver.AternosServer, + self, atserv:'AternosServer', path:str, name:str, ftype:int=FTYPE_FILE, size:Union[int,float]=0, dlallowed:bool=False) -> None: @@ -96,5 +99,5 @@ class AternosFile: return self._size @property - def dlallowed(self): + def dlallowed(self) -> bool: return self._dlallowed diff --git a/python_aternos/atfm.py b/python_aternos/atfm.py index 5083e3e..6bd4129 100644 --- a/python_aternos/atfm.py +++ b/python_aternos/atfm.py @@ -1,13 +1,16 @@ import lxml.html from typing import Optional, Union, List +from typing import TYPE_CHECKING -from . import atserver from . import atconnect from . import atfile +if TYPE_CHECKING: + from atserver import AternosServer + class AternosFileManager: - def __init__(atserv:atserver.AternosServer) -> None: + def __init__(self, atserv:'AternosServer') -> None: self.atserv = atserv @@ -49,7 +52,7 @@ class AternosFileManager: if len(dlbutton) > 0: dlallowed = True - fullpath = f.xpath('/@data-path')[0] + fullpath = f.xpath('/@data-path') filepath = fullpath[:fullpath.rfind('/')] filename = fullpath[fullpath.rfind('/'):] files.append( diff --git a/python_aternos/atplayers.py b/python_aternos/atplayers.py index 9a7563c..c0d152b 100644 --- a/python_aternos/atplayers.py +++ b/python_aternos/atplayers.py @@ -1,12 +1,15 @@ import lxml.html from typing import List +from typing import TYPE_CHECKING -from . import atserver from . import atconnect +if TYPE_CHECKING: + from atserver import AternosServer + class AternosPlayersList: - def __init__(self, lst:str, atserv:atserver.AternosServer) -> None: + def __init__(self, lst:str, atserv:'AternosServer') -> None: self.atserv = atserv self.lst = lst diff --git a/python_aternos/atserver.py b/python_aternos/atserver.py index 07640bf..193c003 100644 --- a/python_aternos/atserver.py +++ b/python_aternos/atserver.py @@ -40,7 +40,7 @@ class AternosServer: self._info = json.loads( re.search( r'var\s*lastStatus\s*=\s*({.*})', - servtree.head.text + servtree.head.text_content() )[1] )