README.md (search-result)
1:An unnecessarily convoluted app to test the boundaries of the treesitter parser

main.py (search-result)
1:from src.interface import parse_arguments, render_response
2:from src.operations import add, divide, multiply, subtract
3:
4:
5:def main():
6:    a, op, b = parse_arguments()
7:
8:    if op == "+":
9:        result = add(a, b)
10:    elif op == "-":
11:        result = subtract(a, b)
12:    elif op == "*":
13:        result = multiply(a, b)
14:    elif op == "/":
15:        result = divide(a, b)
16:    else:
17:        raise ValueError("Unsupported operation")
18:
19:    render_response(result)
20:
21:
22:if __name__ == "__main__":
23:    main()

src/__init__.py (search-result)

src/interface.py (search-result)
1:import argparse
2:import re
3:
4:
5:def parse_arguments():
6:    parser = argparse.ArgumentParser(description="Basic Calculator")
7:    parser.add_argument("operation", type=str, help="Calculation operation")
8:    args = parser.parse_args()
9:
10:    # use re to parse symbol, nubmer before, nubmer after
11:    match = re.match(r"(\d+)(\D)(\d+)", args.operation)
12:    if match is None:
13:        raise ValueError("Invalid operation")
14:    return int(match.group(1)), match.group(2), int(match.group(3))
15:
16:
17:def render_response(result):
18:    print(result)

src/operations.py (search-result)
1:import math
2:
3:
4:def add(a, b):
5:    return a + b
6:
7:
8:def subtract(a, b):
9:    return a - b
10:
11:
12:def multiply(a, b):
13:    return a * b
14:
15:
16:def divide(a, b):
17:    return a / b
18:
19:
20:def sqrt(a):
21:    return math.sqrt(a)
