Skip to content

Commit

Permalink
Fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Wallvon committed Aug 7, 2022
1 parent 60f4ca6 commit da0d33c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 31 deletions.
2 changes: 0 additions & 2 deletions .env.example

This file was deleted.

4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "mofh"
copyright = "2022, Robert S."
copyright = "MMXXII, Robert S"
author = "Robert S."
release = "1.0.0"
release = "1.0.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx==5.1.1
mofh==1.0.0
mofh==1.0.1
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
aiohttp[speedups]==3.8.1
asyncio==3.4.3
uvloop==0.16.0
requests==2.28.1
requests==2.28.1
defusedxml==0.7.1
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
name = mofh
description = API wrapper for https://myownfreehost.net
version = 1.0.0
version = 1.0.1
author = Robert S.
author_email = admin@robert-s.dev
url = https://github.com/Wallvon/mofh
Expand Down Expand Up @@ -38,6 +38,7 @@ install_requires =
asyncio>=3.4.3
uvloop>=0.16.0
requests>=2.28.1
defusedxml>=0.7.1
python_requires = >=3.8
package_dir =
=src
Expand Down
4 changes: 3 additions & 1 deletion src/mofh/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .main import Client, AsyncClient
from .main import *

__version__ = "1.0.1"
37 changes: 14 additions & 23 deletions src/mofh/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import ast
import asyncio
import xml.etree.ElementTree
from defusedxml import ElementTree
from typing import Optional, Any, Union
from xml.etree.ElementTree import Element

import uvloop
from aiohttp import ClientSession, BasicAuth, TCPConnector
Expand All @@ -12,7 +11,7 @@
from .errors import APIError


class Client(object):
class Client:
"""
MyOwnFreeHost API client.
Expand Down Expand Up @@ -55,17 +54,14 @@ def _ensure_session(self) -> Session:
return self._session

@staticmethod
def _parse_xml(response: str) -> Element:
def _parse_xml(response: str) -> Any:
"""
Parses the XML response and returns a dictionary.
:param response: XML response.
"""
# Parse the response and get the root element.
tree = xml.etree.ElementTree.ElementTree(
xml.etree.ElementTree.fromstring(response)
)
root = tree.getroot()
root = ElementTree.fromstring(response)

return root

Expand Down Expand Up @@ -116,10 +112,9 @@ def create(
if status == "1":
# Return the vPanel username.
return root[0][0][1].text
else:
# Raise exception with error.
error = root[0][3].text
raise APIError(error, 0)
# Raise exception with error.
error = root[0][3].text
raise APIError(error, 0)

def suspend(self, username: str, reason: str) -> Optional[int]:
"""
Expand Down Expand Up @@ -337,9 +332,9 @@ def close(self) -> None:
self._session.close()


class AsyncClient(object):
class AsyncClient:
"""
MyOwnFreeHost Async API client.
MyOwnFreeHost async API client.
:param username: MyOwnFreeHost API username
:param password: MyOwnFreeHost API password
Expand Down Expand Up @@ -385,17 +380,14 @@ async def _ensure_session(self) -> Any:
return self._session

@staticmethod
def _parse_xml(response: str) -> Element:
def _parse_xml(response: str) -> Any:
"""
Parses the XML response and returns a dictionary.
:param response: XML response.
"""
# Parse the response and get the root element.
tree = xml.etree.ElementTree.ElementTree(
xml.etree.ElementTree.fromstring(response)
)
root = tree.getroot()
root = ElementTree.fromstring(response)

return root

Expand Down Expand Up @@ -446,10 +438,9 @@ async def create(
if status == "1":
# Return the vPanel username.
return root[0][0][1].text
else:
# Raise exception with error.
error = root[0][3].text
raise APIError(error, 0)
# Raise exception with error.
error = root[0][3].text
raise APIError(error, 0)

async def suspend(self, username: str, reason: str) -> Optional[int]:
"""
Expand Down

0 comments on commit da0d33c

Please sign in to comment.