Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
overfl0 committed May 5, 2024
1 parent fb8d761 commit 4b5dd11
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
12 changes: 8 additions & 4 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import glob
import os
import subprocess
from itertools import chain
from pathlib import Path

armaclass_path = 'armaclass'
armaclass_path = Path('armaclass')
types = ('*.html', '*.c', '*.cpp', '*.pyd', '*.so')
files_to_delete = chain(*(glob.glob(os.path.join(armaclass_path, file_type)) for file_type in types))

files_to_delete = []
for file_type in types:
files_to_delete.extend(armaclass_path.glob(file_type))

for file_path in files_to_delete:
print('Deleting', file_path)
os.remove(file_path)

subprocess.run('python setup_cython.py build_ext --inplace --force', shell=True, check=True)
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
import platform
import sys
from pathlib import Path

from setuptools import setup

# read the contents of your README file
this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
this_directory = Path(__file__).parent
long_description = (this_directory / 'README.md').read_text(encoding='utf-8')

ext_modules = None
if not any(arg in sys.argv for arg in ['clean', 'check']) and \
Expand All @@ -23,7 +23,7 @@
compiler_directives['linetrace'] = True

ext_modules = cythonize(
os.path.join('armaclass', 'parser.py'),
str(this_directory / 'armaclass' / 'parser.py'),
language_level=3,
compiler_directives=compiler_directives,
)
Expand Down
8 changes: 5 additions & 3 deletions setup_cython.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
from pathlib import Path

from setuptools import setup
from Cython.Build import cythonize
from setuptools import setup

this_directory = Path(__file__).parent

setup(
ext_modules=cythonize(os.path.join('armaclass', 'parser.py'),
ext_modules=cythonize(str(this_directory / 'armaclass' / 'parser.py'),
language_level=3,
annotate=True,
),
Expand Down
6 changes: 3 additions & 3 deletions tests/testconfig.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import lzma
import os
import sys
import time
from itertools import zip_longest
Expand All @@ -9,7 +8,7 @@
current_dir = Path(__file__).parent
sys.path.insert(0, str(current_dir.parent))

import armaclass
import armaclass # noqa

CONFIG_CPP = current_dir / 'config_data' / 'config.cpp'
CONFIG_JSON = current_dir / 'config_data' / 'config.json'
Expand Down Expand Up @@ -44,7 +43,7 @@
raise


import pstats, cProfile
import pstats, cProfile # noqa

# import pyximport
# pyximport.install()
Expand Down Expand Up @@ -128,5 +127,6 @@ def compare_lists_equal(model, current, path=''):
error = f'{path}[{i}] == {item_current} instead of {item_model}'
raise ValueError(error)


# COMPARE HERE
compare_dicts_equal(model, parsed)

0 comments on commit 4b5dd11

Please sign in to comment.