AutoPEP8 formatting

This commit is contained in:
DarkCat09 2022-10-31 17:27:21 +04:00
parent b79efb22d4
commit 9ba4230745
11 changed files with 3 additions and 106 deletions

View file

@ -14,3 +14,6 @@ clean:
check:
chmod +x test.sh
bash test.sh
format:
python -m autopep8 -r --in-place .

View file

@ -27,7 +27,6 @@ class Client:
self,
atconn: AternosConnect,
servers: Optional[List[str]] = None) -> None:
"""Aternos API Client class, object
of which contains user's auth data
@ -56,7 +55,6 @@ class Client:
code: Optional[int] = None,
sessions_dir: str = '~',
**custom_args):
"""Log in to an Aternos account with
a username and a hashed password
@ -132,7 +130,6 @@ class Client:
code: Optional[int] = None,
sessions_dir: str = '~',
**custom_args):
"""Log in to Aternos with a username and a plain password
Args:
@ -157,7 +154,6 @@ class Client:
session: str,
servers: Optional[List[str]] = None,
**custom_args):
"""Log in to Aternos using a session cookie value
Args:
@ -181,7 +177,6 @@ class Client:
cls,
file: str = '~/.aternos',
**custom_args):
"""Log in to Aternos using
a saved ATERNOS_SESSION cookie
@ -228,7 +223,6 @@ class Client:
@staticmethod
def md5encode(passwd: str) -> str:
"""Encodes the given string with MD5
Args:
@ -243,7 +237,6 @@ class Client:
@staticmethod
def session_file(username: str, sessions_dir: str = '~') -> str:
"""Generates session file name
for authenticated user
@ -270,7 +263,6 @@ class Client:
self,
file: str = '~/.aternos',
incl_servers: bool = True) -> None:
"""Saves an ATERNOS_SESSION cookie to a file
Args:
@ -293,7 +285,6 @@ class Client:
f.write(s.servid + '\n')
def remove_session(self, file: str = '~/.aternos') -> None:
"""Removes a file which contains
ATERNOS_SESSION cookie saved
with `save_session()`
@ -311,7 +302,6 @@ class Client:
logging.warning('Unable to delete session file: %s', err)
def list_servers(self, cache: bool = True) -> List[AternosServer]:
"""Parses a list of your servers from Aternos website
Args:
@ -344,7 +334,6 @@ class Client:
return self.servers
def refresh_servers(self, ids: List[str]) -> None:
"""Replaces cached servers list creating
AternosServer objects by given IDs
@ -366,7 +355,6 @@ class Client:
self.parsed = True
def get_server(self, servid: str) -> AternosServer:
"""Creates a server object from the server ID.
Use this instead of list_servers
if you know the ID to save some time.
@ -378,7 +366,6 @@ class Client:
return AternosServer(servid, self.atconn)
def logout(self) -> None:
"""Log out from Aternos account"""
self.atconn.request_cloudflare(
@ -389,7 +376,6 @@ class Client:
self.remove_session(self.saved_session)
def change_username(self, value: str) -> None:
"""Changes a username in your Aternos account
Args:
@ -402,7 +388,6 @@ class Client:
)
def change_email(self, value: str) -> None:
"""Changes an e-mail in your Aternos account
Args:
@ -425,7 +410,6 @@ class Client:
)
def change_password(self, old: str, new: str) -> None:
"""Changes a password in your Aternos account
Args:
@ -439,7 +423,6 @@ class Client:
)
def change_password_hashed(self, old: str, new: str) -> None:
"""Changes a password in your Aternos account.
Unlike `change_password`, this function
takes hashed passwords as arguments
@ -458,7 +441,6 @@ class Client:
)
def qrcode_2fa(self) -> Dict[str, str]:
"""Requests a secret code and
a QR code for enabling 2FA"""
@ -468,7 +450,6 @@ class Client:
).json()
def save_qr(self, qrcode: str, filename: str) -> None:
"""Writes a 2FA QR code into a png-file
Args:
@ -484,7 +465,6 @@ class Client:
f.write(png)
def enable_2fa(self, code: int) -> None:
"""Enables Two-Factor Authentication
Args:
@ -499,7 +479,6 @@ class Client:
)
def disable_2fa(self, code: int) -> None:
"""Disables Two-Factor Authentication
Args:

View file

@ -124,7 +124,6 @@ class AternosConfig:
"""Class for editing server settings"""
def __init__(self, atserv: 'AternosServer') -> None:
"""Class for editing server settings
Args:
@ -135,7 +134,6 @@ class AternosConfig:
self.atserv = atserv
def get_timezone(self) -> str:
"""Parses timezone from options page
Returns:
@ -154,7 +152,6 @@ class AternosConfig:
return tztext.strip()
def set_timezone(self, value: str) -> None:
"""Sets new timezone
Args:
@ -178,7 +175,6 @@ class AternosConfig:
)
def get_java(self) -> int:
"""Parses Java version from options page
Returns:
@ -200,7 +196,6 @@ class AternosConfig:
return int(jdkver)
def set_java(self, value: int) -> None:
"""Sets new Java version
Args:
@ -217,7 +212,6 @@ class AternosConfig:
# server.properties
#
def set_server_prop(self, option: str, value: Any) -> None:
"""Sets server.properties option
Args:
@ -231,7 +225,6 @@ class AternosConfig:
)
def get_server_props(self, proptyping: bool = True) -> Dict[str, Any]:
"""Parses all server.properties from options page
Args:
@ -248,7 +241,6 @@ class AternosConfig:
return self.__get_all_props('https://aternos.org/options', proptyping)
def set_server_props(self, props: Dict[str, Any]) -> None:
"""Updates server.properties options with the given dict
Args:
@ -266,7 +258,6 @@ class AternosConfig:
self, option: Union[WorldOpts, WorldRules],
value: Any, gamerule: bool = False,
world: str = 'world') -> None:
"""Sets level.dat option for specified world
Args:
@ -290,7 +281,6 @@ class AternosConfig:
def get_world_props(
self, world: str = 'world',
proptyping: bool = True) -> Dict[str, Any]:
"""Parses level.dat from specified world's options page
Args:
@ -314,7 +304,6 @@ class AternosConfig:
self,
props: Dict[Union[WorldOpts, WorldRules], Any],
world: str = 'world') -> None:
"""Sets level.dat options from
the dictionary for the specified world

View file

@ -41,7 +41,6 @@ class AternosConnect:
self.token = ''
def add_args(self, **kwargs) -> None:
"""Pass arguments to CloudScarper
session object __init__
if kwargs is not empty
@ -59,7 +58,6 @@ class AternosConnect:
self.refresh_session()
def clear_args(self) -> None:
"""Clear CloudScarper object __init__ arguments
which was set using add_args method"""
@ -68,7 +66,6 @@ class AternosConnect:
self.refresh_session()
def refresh_session(self) -> None:
"""Creates a new CloudScraper
session object and copies all cookies.
Required for bypassing Cloudflare"""
@ -79,7 +76,6 @@ class AternosConnect:
del old_cookies
def parse_token(self) -> str:
"""Parses Aternos ajax token that
is needed for most requests
@ -149,7 +145,6 @@ class AternosConnect:
return self.token
def generate_sec(self) -> str:
"""Generates Aternos SEC token which
is also needed for most API requests
@ -175,7 +170,6 @@ class AternosConnect:
reqcookies: Optional[Dict[Any, Any]] = None,
sendtoken: bool = False,
retry: int = 5) -> requests.Response:
"""Sends a request to Aternos API bypass Cloudflare
Args:
@ -287,7 +281,6 @@ class AternosConnect:
@property
def atsession(self) -> str:
"""Aternos session cookie,
empty string if not logged in

View file

@ -37,7 +37,6 @@ class ServerError(AternosError):
"""Common class for server errors"""
def __init__(self, reason: str, message: str = '') -> None:
"""Common class for server errors
Args:
@ -71,7 +70,6 @@ class ServerStartError(AternosError):
}
def __init__(self, reason: str) -> None:
"""Raised when Aternos
can not start Minecraft server

View file

@ -34,7 +34,6 @@ class AternosFile:
dlable: bool, editable: bool,
ftype: FileType = FileType.file,
size: Union[int, float] = 0) -> None:
"""File class which contains info
about its path, type and size
@ -68,7 +67,6 @@ class AternosFile:
self,
name: str,
ftype: FileType = FileType.file) -> None:
"""Creates a file or a directory inside this one
Args:
@ -102,7 +100,6 @@ class AternosFile:
raise FileError('Unable to create a file')
def delete(self) -> None:
"""Deletes the file
Raises:
@ -126,7 +123,6 @@ class AternosFile:
raise FileError('Unable to delete the file')
def get_content(self) -> bytes:
"""Requests file content in bytes (downloads it)
Raises:
@ -159,7 +155,6 @@ class AternosFile:
return file.content
def set_content(self, value: bytes) -> None:
"""Modifies file content
Args:
@ -181,7 +176,6 @@ class AternosFile:
raise FileError('Unable to save the file')
def get_text(self) -> str:
"""Requests editing the file as a text
Raises:
@ -220,7 +214,6 @@ class AternosFile:
return editblock[0].text_content()
def set_text(self, value: str) -> None:
"""Modifies the file content,
but unlike `set_content` takes
a string as an argument
@ -233,7 +226,6 @@ class AternosFile:
@property
def path(self) -> str:
"""Abslute path to the file
without leading slash
including filename
@ -246,7 +238,6 @@ class AternosFile:
@property
def name(self) -> str:
"""Filename with extension
Returns:
@ -257,7 +248,6 @@ class AternosFile:
@property
def dirname(self) -> str:
"""Full path to the directory
which contains the file
without leading slash.
@ -271,7 +261,6 @@ class AternosFile:
@property
def deleteable(self) -> bool:
"""True if the file can be deleted,
otherwise False
@ -283,7 +272,6 @@ class AternosFile:
@property
def downloadable(self) -> bool:
"""True if the file can be downloaded,
otherwise False
@ -295,7 +283,6 @@ class AternosFile:
@property
def editable(self) -> bool:
"""True if the file can be
opened in Aternos editor,
otherwise False
@ -308,7 +295,6 @@ class AternosFile:
@property
def ftype(self) -> FileType:
"""File object type: file or directory
Returns:
@ -319,7 +305,6 @@ class AternosFile:
@property
def is_dir(self) -> bool:
"""Check if the file object is a directory
Returns:
@ -330,7 +315,6 @@ class AternosFile:
@property
def is_file(self) -> bool:
"""Check if the file object is not a directory
Returns:
@ -341,7 +325,6 @@ class AternosFile:
@property
def size(self) -> float:
"""File size in bytes
Returns:

View file

@ -16,7 +16,6 @@ class FileManager:
for viewing files structure"""
def __init__(self, atserv: 'AternosServer') -> None:
"""Aternos file manager class
for viewing files structure
@ -28,7 +27,6 @@ class FileManager:
self.atserv = atserv
def list_dir(self, path: str = '') -> List[AternosFile]:
"""Requests a list of files
in the specified directory
@ -83,7 +81,6 @@ class FileManager:
return files
def extract_size(self, fsize_raw: List[Any]) -> float:
"""Parses file size from the LXML tree
Args:
@ -113,7 +110,6 @@ class FileManager:
self,
num: Union[int, float],
measure: str) -> float:
"""Converts "human" file size to size in bytes
Args:
@ -133,7 +129,6 @@ class FileManager:
return measure_match.get(measure, -1) * num
def get_file(self, path: str) -> Optional[AternosFile]:
"""Returns :class:`python_aternos.atfile.AternosFile`
instance by its path
@ -158,7 +153,6 @@ class FileManager:
}.get('file', None)
def dl_file(self, path: str) -> bytes:
"""Returns the file content in bytes (downloads it)
Args:
@ -178,7 +172,6 @@ class FileManager:
return file.content
def dl_world(self, world: str = 'world') -> bytes:
"""Returns the world zip file content
by its name (downloads it)

View file

@ -9,7 +9,6 @@ arrowexp = regex.compile(r'\w[^\}]*+')
def to_ecma5_function(f: str) -> str:
"""Converts a ECMA6 function
to ECMA5 format (without arrow expressions)
@ -31,7 +30,6 @@ def to_ecma5_function(f: str) -> str:
def atob(s: str) -> str:
"""Decodes base64 string
Args:
@ -45,7 +43,6 @@ def atob(s: str) -> str:
def exec_js(f: str) -> js2py.EvalJs:
"""Executes a JavaScript function
Args:

View file

@ -32,7 +32,6 @@ class PlayersList:
self,
lst: Union[str, Lists],
atserv: 'AternosServer') -> None:
"""Class for managing operators,
whitelist and banned players lists
@ -60,7 +59,6 @@ class PlayersList:
self.parsed = False
def list_players(self, cache: bool = True) -> List[str]:
"""Parse a players list
Args:
@ -93,7 +91,6 @@ class PlayersList:
return result
def add(self, name: str) -> None:
"""Appends a player to the list by the nickname
Args:
@ -111,7 +108,6 @@ class PlayersList:
self.players.append(name)
def remove(self, name: str) -> None:
"""Removes a player from the list by the nickname
Args:

View file

@ -53,7 +53,6 @@ class AternosServer:
self, servid: str,
atconn: AternosConnect,
reqinfo: bool = True) -> None:
"""Class for controlling your Aternos Minecraft server
Args:
@ -70,7 +69,6 @@ class AternosServer:
self.fetch()
def fetch(self) -> None:
"""Send a request to Aternos API to get all server info"""
servreq = self.atserver_request(
@ -80,7 +78,6 @@ class AternosServer:
self._info = json.loads(servreq.content)
def wss(self, autoconfirm: bool = False) -> AternosWss:
"""Returns AternosWss instance for
listening server streams in real-time
@ -100,7 +97,6 @@ class AternosServer:
self,
headstart: bool = False,
accepteula: bool = True) -> None:
"""Starts a server
Args:
@ -135,7 +131,6 @@ class AternosServer:
raise ServerStartError(error)
def confirm(self) -> None:
"""Confirms server launching"""
self.atserver_request(
@ -144,7 +139,6 @@ class AternosServer:
)
def stop(self) -> None:
"""Stops the server"""
self.atserver_request(
@ -153,7 +147,6 @@ class AternosServer:
)
def cancel(self) -> None:
"""Cancels server launching"""
self.atserver_request(
@ -162,7 +155,6 @@ class AternosServer:
)
def restart(self) -> None:
"""Restarts the server"""
self.atserver_request(
@ -171,7 +163,6 @@ class AternosServer:
)
def eula(self) -> None:
"""Accepts the Mojang EULA"""
self.atserver_request(
@ -180,7 +171,6 @@ class AternosServer:
)
def files(self) -> FileManager:
"""Returns FileManager instance
for file operations
@ -191,7 +181,6 @@ class AternosServer:
return FileManager(self)
def config(self) -> AternosConfig:
"""Returns AternosConfig instance
for editing server settings
@ -202,7 +191,6 @@ class AternosServer:
return AternosConfig(self)
def players(self, lst: Lists) -> PlayersList:
"""Returns PlayersList instance
for managing operators, whitelist
and banned players lists
@ -223,7 +211,6 @@ class AternosServer:
data: Optional[Dict[Any, Any]] = None,
headers: Optional[Dict[Any, Any]] = None,
sendtoken: bool = False) -> requests.Response:
"""Sends a request to Aternos API
with server IDenitfier parameter
@ -253,7 +240,6 @@ class AternosServer:
@property
def subdomain(self) -> str:
"""Server subdomain
(the part of domain before `.aternos.me`)
@ -266,7 +252,6 @@ class AternosServer:
@subdomain.setter
def subdomain(self, value: str) -> None:
"""Set a new subdomain for your server
Args:
@ -281,7 +266,6 @@ class AternosServer:
@property
def motd(self) -> str:
"""Server message of the day
which is shown below its name
in the Minecraft servers list
@ -294,7 +278,6 @@ class AternosServer:
@motd.setter
def motd(self, value: str) -> None:
"""Set a new message of the day
Args:
@ -309,7 +292,6 @@ class AternosServer:
@property
def address(self) -> str:
"""Full server address
including domain and port
@ -321,7 +303,6 @@ class AternosServer:
@property
def domain(self) -> str:
"""Server domain (e.g. `test.aternos.me`).
In other words, address without port number
@ -333,7 +314,6 @@ class AternosServer:
@property
def port(self) -> int:
"""Server port number
Returns:
@ -344,7 +324,6 @@ class AternosServer:
@property
def edition(self) -> Edition:
"""Server software edition: Java or Bedrock
Returns:
@ -356,7 +335,6 @@ class AternosServer:
@property
def is_java(self) -> bool:
"""Check if server software is Java Edition
Returns:
@ -367,7 +345,6 @@ class AternosServer:
@property
def is_bedrock(self) -> bool:
"""Check if server software is Bedrock Edition
Returns:
@ -378,7 +355,6 @@ class AternosServer:
@property
def software(self) -> str:
"""Server software name (e.g. `Vanilla`)
Returns:
@ -389,7 +365,6 @@ class AternosServer:
@property
def version(self) -> str:
"""Server software version (1.16.5)
Returns:
@ -400,7 +375,6 @@ class AternosServer:
@property
def css_class(self) -> str:
"""CSS class for
server status block
on official web site
@ -415,7 +389,6 @@ class AternosServer:
@property
def status(self) -> str:
"""Server status string
(offline, loading, preparing)
@ -427,7 +400,6 @@ class AternosServer:
@property
def status_num(self) -> Status:
"""Server numeric status.
It is highly recommended to use
status string instead of a number
@ -440,7 +412,6 @@ class AternosServer:
@property
def players_list(self) -> List[str]:
"""List of connected players' nicknames
Returns:
@ -451,7 +422,6 @@ class AternosServer:
@property
def players_count(self) -> int:
"""How many players are connected
Returns:
@ -462,7 +432,6 @@ class AternosServer:
@property
def slots(self) -> int:
"""Server slots, how many
players **can** connect
@ -474,7 +443,6 @@ class AternosServer:
@property
def ram(self) -> int:
"""Server used RAM in MB
Returns:

View file

@ -49,7 +49,6 @@ class AternosWss:
self,
atserv: 'AternosServer',
autoconfirm: bool = False) -> None:
"""Class for managing websocket connection
Args:
@ -95,7 +94,6 @@ class AternosWss:
self,
stream: Streams,
arg: Tuple[Any, ...] = ()) -> Callable[[FunctionT], Any]:
"""Decorator that marks your function as a stream receiver.
When websocket receives message from the specified stream,
it calls all listeners created with this decorator.