pyscreeps-arena 0.4a2__tar.gz → 0.4a3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/PKG-INFO +1 -1
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/compiler.py +84 -11
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena.egg-info/PKG-INFO +1 -1
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/setup.py +1 -1
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/__init__.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/build.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/core/__init__.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/core/basic.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/core/config.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/core/const.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/core/core.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/core/main.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/core/utils.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/localization.py +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena/project.7z +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena.egg-info/SOURCES.txt +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena.egg-info/dependency_links.txt +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena.egg-info/entry_points.txt +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena.egg-info/requires.txt +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena.egg-info/top_level.txt +0 -0
- {pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/setup.cfg +0 -0
|
@@ -164,15 +164,11 @@ class GameFlag{{
|
|
|
164
164
|
constructor(){{
|
|
165
165
|
}}
|
|
166
166
|
}};
|
|
167
|
-
import {{
|
|
167
|
+
import {{ ScoreCollector as GameScoreCollector, AreaEffect as GameAreaEffect, EFFECT_DAMAGE, EFFECT_FREEZE }} from 'arena/season_{config.season}/collect_and_control/{"advanced" if config.level in ["advance", "advanced"] else "basic"}';
|
|
168
168
|
|
|
169
|
-
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const RESOURCE_SCORE_X = "undefined";
|
|
173
|
-
const RESOURCE_SCORE_Y = "undefined";
|
|
174
|
-
const RESOURCE_SCORE_Z = "undefined";
|
|
175
|
-
'''}
|
|
169
|
+
{f"import {{ RESOURCE_SCORE_X, RESOURCE_SCORE_Y, RESOURCE_SCORE_Z }} from 'arena/season_{config.season}/collect_and_control/advanced';" if config.level in ["advance", "advanced"] else 'const RESOURCE_SCORE_X = "undefined"; const RESOURCE_SCORE_Y = "undefined"; const RESOURCE_SCORE_Z = "undefined";'}
|
|
170
|
+
|
|
171
|
+
{"const RESOURCE_SCORE = 'undefined';" if config.level in ["advance", "advanced"] else f"import {{ RESOURCE_SCORE }} from 'arena/season_{config.season}/collect_and_control/basic';"}
|
|
176
172
|
""",
|
|
177
173
|
const.ARENA_GRAY: lambda: f"""
|
|
178
174
|
class GameBodyPart{{
|
|
@@ -326,7 +322,7 @@ class Compiler_Utils(Compiler_Const):
|
|
|
326
322
|
return '\n'.join(result) # 将处理后的所有代码行连接成一个字符串,并返回最终结果 | join all processed lines into a string and return
|
|
327
323
|
|
|
328
324
|
def find_chain_import(self, fpath: str, search_dirs: list[str], project_path: str = None, records: dict[str, None] = None) -> list[str]:
|
|
329
|
-
"""
|
|
325
|
+
r"""
|
|
330
326
|
查找文件中的所有import语句,并返回所有import的文件路径 | find all import statements in a file and return the paths of all imported files
|
|
331
327
|
PY_IMPORT_PAT: re.compile(r'\s+from\s+(.+)(?=\s+import)\s+import\s+\*')
|
|
332
328
|
:param fpath: str 目标文件路径 | target file path
|
|
@@ -384,6 +380,81 @@ class Compiler_Utils(Compiler_Const):
|
|
|
384
380
|
|
|
385
381
|
return imps
|
|
386
382
|
|
|
383
|
+
def find_chain_import2(self, fpath: str, search_dirs: list[str], project_path: str = None, records: dict[str, None] = None) -> list[str]:
|
|
384
|
+
r"""
|
|
385
|
+
查找文件中的所有import语句,并返回所有import的文件路径 | find all import statements in a file and return the paths of all imported files
|
|
386
|
+
PY_IMPORT_PAT: re.compile(r'\s+from\s+(.+)(?=\s+import)\s+import\s+\*')
|
|
387
|
+
:param fpath: str 目标文件路径 | target file path
|
|
388
|
+
:param search_dirs: list[str] 搜索目录 | search directories
|
|
389
|
+
:param project_path=None: str python项目中的概念,指根文件所在的目录。如果不指定,默认使用第一次调用时给定的fpath,并且稍后的递归会全部使用此路径 |
|
|
390
|
+
concept in python-project, refers to the directory where the root file is located. If not specified, the fpath given at the first call is used by default, and all subsequent recursions will use this path
|
|
391
|
+
:param records=None: dict[str, None] 记录已经查找过的文件路径,避免重复查找 | record the file paths that have been searched to avoid duplicate searches
|
|
392
|
+
"""
|
|
393
|
+
if records is None:
|
|
394
|
+
records = {}
|
|
395
|
+
if not os.path.exists(fpath):
|
|
396
|
+
core.error('Compiler.find_chain_import', core.lformat(LOC_FILE_NOT_EXISTS, [fpath]), head='\n', ln=config.language)
|
|
397
|
+
imps = []
|
|
398
|
+
content = self.auto_read(fpath)
|
|
399
|
+
project_path = project_path or os.path.dirname(fpath)
|
|
400
|
+
|
|
401
|
+
# 添加根目录和 src 目录到 search_dirs
|
|
402
|
+
root_dir = os.path.dirname(project_path) # 根目录
|
|
403
|
+
src_dir = os.path.join(root_dir, 'src') # src 目录
|
|
404
|
+
if root_dir not in search_dirs:
|
|
405
|
+
search_dirs = [root_dir] + search_dirs
|
|
406
|
+
if src_dir not in search_dirs:
|
|
407
|
+
search_dirs = [src_dir] + search_dirs
|
|
408
|
+
|
|
409
|
+
for no, line in enumerate(content.split('\n')):
|
|
410
|
+
m = self.PY_IMPORT_PAT.match(line)
|
|
411
|
+
if m:
|
|
412
|
+
target = m.group(1)
|
|
413
|
+
target_path = project_path
|
|
414
|
+
|
|
415
|
+
## 向前定位 | locate forward
|
|
416
|
+
if target.startswith('.'):
|
|
417
|
+
target_path = os.path.dirname(fpath) # 因为使用了相对路径,所以需要先定位到当前文件所在的目录 |
|
|
418
|
+
# because relative path is used, need to locate the directory where the current file is located first
|
|
419
|
+
count = 0
|
|
420
|
+
for c in target:
|
|
421
|
+
if c == '.':
|
|
422
|
+
count += 1
|
|
423
|
+
else:
|
|
424
|
+
break
|
|
425
|
+
if count > 1:
|
|
426
|
+
for _ in range(count - 1):
|
|
427
|
+
target_path = os.path.dirname(target_path)
|
|
428
|
+
|
|
429
|
+
## 向后定位 | locate backward
|
|
430
|
+
while (_idx := target.find('.')) != -1:
|
|
431
|
+
first_name = target[:_idx]
|
|
432
|
+
target_path = os.path.join(target_path, first_name)
|
|
433
|
+
target = target[_idx + 1:]
|
|
434
|
+
|
|
435
|
+
## 检查是否存在 | check if exists
|
|
436
|
+
this_path = os.path.join(target_path, target)
|
|
437
|
+
if os.path.isdir(this_path):
|
|
438
|
+
this_path = os.path.join(this_path, '__init__.py')
|
|
439
|
+
else:
|
|
440
|
+
this_path += '.py'
|
|
441
|
+
|
|
442
|
+
if not os.path.exists(this_path):
|
|
443
|
+
# 如果当前路径不存在,尝试在 search_dirs 中查找
|
|
444
|
+
for search_dir in search_dirs:
|
|
445
|
+
search_path = os.path.join(search_dir, target.replace('.', os.sep)) + ('.py' if not os.path.isdir(this_path) else os.sep + '__init__.py')
|
|
446
|
+
if os.path.exists(search_path):
|
|
447
|
+
this_path = search_path
|
|
448
|
+
break
|
|
449
|
+
else:
|
|
450
|
+
core.error('Compiler.find_chain_import', core.lformat(LOC_CHAIN_FILE_NOT_EXISTS, [fpath, no + 1, this_path]), head='\n', ln=config.language)
|
|
451
|
+
if this_path not in records:
|
|
452
|
+
records[this_path] = None
|
|
453
|
+
tmp = self.find_chain_import(this_path, search_dirs, project_path, records) + [this_path]
|
|
454
|
+
imps.extend(tmp)
|
|
455
|
+
|
|
456
|
+
return imps
|
|
457
|
+
|
|
387
458
|
@staticmethod
|
|
388
459
|
def relist_pyimports_to_jsimports(base_dir:str, pyimps:list[str]) -> list[str]:
|
|
389
460
|
"""
|
|
@@ -402,7 +473,7 @@ class Compiler_Utils(Compiler_Const):
|
|
|
402
473
|
# ---------- 自定义函数 ---------- #
|
|
403
474
|
@staticmethod
|
|
404
475
|
def stage_recursive_replace(content:str) -> str:
|
|
405
|
-
"""
|
|
476
|
+
r"""
|
|
406
477
|
替换'@recursive'为'@recursive(<fname>)', 其中<fname>为被装饰器标记的函数名 |
|
|
407
478
|
Replace '@recursive' with '@recursive(<fname>)', where <fname> is the name of the decorated function.
|
|
408
479
|
|
|
@@ -414,7 +485,9 @@ class Compiler_Utils(Compiler_Const):
|
|
|
414
485
|
|
|
415
486
|
class CompilerBase(Compiler_Utils):
|
|
416
487
|
|
|
417
|
-
def __init__(self
|
|
488
|
+
def __init__(self):
|
|
489
|
+
src_dir = "src"
|
|
490
|
+
build_dir = "build"
|
|
418
491
|
# check
|
|
419
492
|
if not os.path.exists(src_dir):
|
|
420
493
|
core.error('Compiler.__init__', core.lformat(LOC_FILE_NOT_EXISTS, ['src', src_dir]), head='\n', ln=config.language)
|
|
@@ -7,7 +7,7 @@ with open(r"T:\New_PC\Import_Project\uploads\pyscreeps-arena_upload\pyscreeps-ar
|
|
|
7
7
|
long_description = f.read()
|
|
8
8
|
setup(
|
|
9
9
|
name='pyscreeps-arena',
|
|
10
|
-
version='0.
|
|
10
|
+
version='0.4a3',
|
|
11
11
|
description='Python api|interface to play game: Screeps: Arena.',
|
|
12
12
|
long_description=long_description,
|
|
13
13
|
long_description_content_type='text/markdown',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyscreeps-arena-0.4a2 → pyscreeps-arena-0.4a3}/pyscreeps_arena.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|