diff --git a/.gitignore b/.gitignore
index 372c13e..4395561 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
__pycache__/
-
+.venv
diff --git a/README.md b/README.md
index 86efa03..7f10ee6 100644
--- a/README.md
+++ b/README.md
@@ -181,6 +181,7 @@ def try_build(building:BuildingId) -> Integer:
all functions pass by value and all variables in the function are only in their own scope. Note that it is the same variable for every call of the function, so if you do not set the varible it will have the value for the last call. If you need a variable from ouside the funtion you can use global to access it. otherwize it will create a new function scoped veriable.
+
```
def build_around_tc(building:BuildingId, radius:Integer) -> Integer:
global tc_location
@@ -189,6 +190,7 @@ def build_around_tc(building:BuildingId, radius:Integer) -> Integer:
chat_to_all("E: tc_location not set, cannot build_around_tc")
return -1
```
+
aoe2script Commands now look like functions, as you have seen above. but they are not the same!
if you use an aoe2script command it will work like it does in the original langauge. I have just added things for conveineince bellow.
diff --git a/pyproject.toml b/pyproject.toml
index fdf9caa..c17b605 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,13 +4,16 @@ version = "0.0.1"
description = "compile python code to aoe2script"
readme = "README.md"
requires-python = ">=3.6"
-dependencies = []
+dependencies = [
+ "aenum>=3.1.10",
+ "colorama>=0.4.6",
+ "sortedcontainers>=2.4.0",
+]
[dependency-groups]
dev = [
- "colorama>=0.4.6",
+ "bs4<1",
"pytest>=7.0.1",
- "aenum>=3.1.10",
]
[tool.pytest.ini_options]
diff --git a/src/Compiler.py b/src/Compiler.py
index a01e74b..4e4fefb 100644
--- a/src/Compiler.py
+++ b/src/Compiler.py
@@ -1,16 +1,19 @@
import ast
+from copy import copy, deepcopy
import inspect
from itertools import chain
+
from aenum import EnumType, Enum
+
+from custom_ast_nodes import Command, DefRule, Variable, aoeOp, EnumNode, Constructor, JumpType, FuncModule
+from Memory import Memory, FUNC_RET_REG, ARRAY_RETURN_REG, FUNC_DEPTH_COUNT, FUNC_RETURN_LENGTH, ARRAY_RETURN_PTR, FUNC_RETURN_ARRAY, ARRAY_OFFSET
+from MyLogging import logger
from scraper import *
from scraper import AOE2FUNC, Integer, Constant, Array, Register
from scraper import aoe2scriptFunctions as aoe2scriptFunctions
-from custom_ast_nodes import Command, DefRule, Variable, aoeOp, EnumNode, Constructor, JumpType, FuncModule
-from Memory import Memory, FUNC_RET_REG, ARRAY_RETURN_REG, FUNC_DEPTH_COUNT, FUNC_RETURN_LENGTH, ARRAY_RETURN_PTR, FUNC_RETURN_ARRAY, ARRAY_OFFSET
-from copy import copy, deepcopy
from utils import ast_to_aoe, evaluate_expression, get_enum_classes, reverse_compare_op, get_aoe2_var_types, get_list_from_return, TEMP_SUPBSTRING
from utils_display import print_bordered
-from MyLogging import logger
+
reserved_function_names = [
'range',
diff --git a/src/Main.py b/src/Main.py
index 2b89bf6..8cea18d 100644
--- a/src/Main.py
+++ b/src/Main.py
@@ -1,20 +1,23 @@
+import argparse
+import ast
+from collections import namedtuple
+import cProfile
+from math import ceil, floor
+from pathlib import Path
+from pprint import pprint
+import re
+import sys
+from time import time
+
+from colorama import Fore, Back, Style
+
from Asserter import Asserter
-from Printer import Printer
from Compiler import Compiler
-import sys
-from pprint import pprint
-from pathlib import Path
from Parser import Parser
-from colorama import Fore, Back, Style
-import re
-from math import ceil, floor
-import ast
-from collections import namedtuple
+from Printer import Printer
from scraper import *
from utils_display import print_bright, print_bordered, print_stats
-import argparse
-from time import time
-import cProfile
+
def main(file_name, arguments):
first_time = time()
diff --git a/src/Memory.py b/src/Memory.py
index d8f851c..89ea43a 100644
--- a/src/Memory.py
+++ b/src/Memory.py
@@ -1,12 +1,15 @@
+import ast
+import inspect
+from pprint import pprint
+
+from sortedcontainers import SortedDict
+
+from MyLogging import logger
from scraper import (AOE2OBJ, Point, State, Integer, Boolean,
AOE2VarType, aoe2scriptEnums, Array, Constant, Timer, Register)
-from sortedcontainers import SortedDict
from utils import normalize_var_type
from utils_display import print_bright, print_dim
-from pprint import pprint
-import ast
-import inspect
-from MyLogging import logger
+
#! find out where the return pts for functions is and is the 15900 still hardcoded
diff --git a/src/Parser.py b/src/Parser.py
index cf05407..b84d9f9 100644
--- a/src/Parser.py
+++ b/src/Parser.py
@@ -1,4 +1,5 @@
import ast
+
from scraper import Constant
class Aoe2Tree:
diff --git a/src/Printer.py b/src/Printer.py
index 86145e5..e91435d 100644
--- a/src/Printer.py
+++ b/src/Printer.py
@@ -1,15 +1,18 @@
import ast
-from Compiler import Command, Variable, aoeOp
-from scraper import *
-from scraper import mathOp, compareOp, Strenum, typeOp
-from utils_display import read_file_as_string
-from colorama import Fore, Back, Style
+from pprint import pprint
import re
+from time import time
+
from aenum import EnumType
+from colorama import Fore, Back, Style
+
+from Compiler import Command, Variable, aoeOp
from MyLogging import logger
+from scraper import *
+from scraper import mathOp, compareOp, Strenum, typeOp
from utils import get_enum_classes
-from time import time
-from pprint import pprint
+from utils_display import read_file_as_string
+
class DefRulePrintVisitor(ast.NodeVisitor):
def __init__(self, final_list, const_tree = [], NO_FILE=False, TEST=True):
@@ -27,7 +30,7 @@ def __init__(self, final_list, const_tree = [], NO_FILE=False, TEST=True):
name = node.targets[0].id
value = node.value.args[0].value
self.def_const_list.add(name + " " + str(value))
- except IndexErrors:
+ except IndexError:
raise Exception(f"defined Constant has no parameter, line {node.lineno}")
def visit_if(self, node):
diff --git a/src/custom_ast_nodes.py b/src/custom_ast_nodes.py
index 45db715..85e9f84 100644
--- a/src/custom_ast_nodes.py
+++ b/src/custom_ast_nodes.py
@@ -1,11 +1,12 @@
import ast
-from utils import get_enum_classes, get_function_list_typeOp
-from scraper import aoe2scriptFunctions as aoe2scriptFunctions
-from scraper import typeOp
-from Memory import FUNC_RET_REG
from enum import Enum
-from scraper import AOE2FUNC
+
+from Memory import FUNC_RET_REG
from MyLogging import logger
+from scraper import aoe2scriptFunctions as aoe2scriptFunctions
+from scraper import AOE2FUNC, typeOp
+from utils import get_enum_classes, get_function_list_typeOp
+
class JumpType(Enum):
last_rule_in_node = 0
diff --git a/src/utils.py b/src/utils.py
index 714850f..962be46 100644
--- a/src/utils.py
+++ b/src/utils.py
@@ -1,11 +1,13 @@
-from scraper import *
import ast
-import operator
-import inspect
import enum
+import inspect
+import operator
+
+from MyLogging import logger
+from scraper import *
import scraper.aoe2scriptEnums
from scraper.aoe2scriptFunctions import function_list, AOE2VarType
-from MyLogging import logger
+
TEMP_SUPBSTRING = "-temp"
diff --git a/src/utils_display.py b/src/utils_display.py
index fe3c90d..dd5c46a 100644
--- a/src/utils_display.py
+++ b/src/utils_display.py
@@ -1,6 +1,8 @@
-from colorama import Fore, Back, Style
from math import ceil, floor
+from colorama import Fore, Back, Style
+
+
def print_completion_bar(percentage, bar_length=50):
"""
Prints a static completion bar with the given percentage filled.