Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 27f4422

Browse files
committed
feat: added command module for the base command
1 parent 8492b8b commit 27f4422

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from typing import Any
2+
from abc import abstractmethod, ABC
3+
from urllib.parse import quote
4+
5+
6+
class CmdBase(ABC):
7+
"""Base class for all the CAS (Computer Algebra System) API Commands."""
8+
9+
def __init__(self, operation: str, base_url: str):
10+
self.operation = operation
11+
self.base_url = base_url
12+
13+
@abstractmethod
14+
def command(self, expr: str) -> Any:
15+
"""
16+
Command for sending request to Newton CAS API with a given expression string and returns the result from
17+
the API response.
18+
"""
19+
pass
20+
21+
@staticmethod
22+
def url_encode(inp_str: str) -> str:
23+
"""Encode the input string to a URL-safe format."""
24+
return quote(inp_str)

0 commit comments

Comments
 (0)