Skip to content

Commit

Permalink
Fix: Build error
Browse files Browse the repository at this point in the history
  • Loading branch information
nutti committed Aug 13, 2023
1 parent 0b7efc7 commit 2e8a79e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/fake_bpy_module/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ def make_next_level(self, spaces_to_add: str) -> 'RstLevel':

class BaseAnalyzer:
def __init__(self):
self.support_bge: bool = False
self.target: str = None # "blender" or "upbge"
self.current_file: str = None
self.current_module: str = None
self.current_base_classes: str = None
self.blender_version: str = None
self.target_version: str = None # Ex: "2.80"

def set_blender_version(self, version: str):
self.blender_version = version
def set_target_version(self, version: str):
self.target_version = version

def enable_bge_support(self):
self.support_bge = True
def set_target(self, target: str):
self.target = target

def _is_bge_supported(self) -> bool:
return self.support_bge
def _target(self) -> str:
return self.target

def _cleanup_string(self, line: str) -> str:
result = line
Expand Down Expand Up @@ -108,11 +108,11 @@ def _parse_module(self, file: IO[Any], level: int) -> str:

module_name = m.group(2)

if not self.support_bge:
if self.blender_version == "2.90":
if self.target == "blender":
if self.target_version == "2.90":
if module_name.startswith("bpy.types."):
module_name = module_name[:module_name.rfind(".")]
elif self.blender_version in [
elif self.target_version in [
"2.91", "2.92", "2.93",
"3.0", "3.1", "3.2", "3.3", "3.4", "latest"]:
if module_name == "bpy.data":
Expand Down Expand Up @@ -991,7 +991,7 @@ def _parse_static_method(
elif re.match(r"^\s{" + str(level.num_spaces()) + r"}(\s+)\.\. attribute::", line): # noqa # pylint: disable=C0301
next_level_spaces = re.match(r"^\s{" + str(level.num_spaces()) + r"}(\s+)\.\. attribute::", line).group(1) # noqa # pylint: disable=C0301
is_deprecated = re.search(r"\(Deprecated", line) is not None
if self._is_bge_supported() and is_deprecated:
if self._target() == "upbge" and is_deprecated:
self._skip_until_next_le_level(
file, level=level.make_next_level(next_level_spaces))
else:
Expand Down Expand Up @@ -1059,7 +1059,7 @@ def _analyze_by_file(self, filename: str) -> 'SectionInfo':
line = file.readline()
section = SectionInfo()
self.current_base_classes = None
if self._is_bge_supported() and \
if self._target() == "upbge" and \
re.search(r"/bge\.types\.(?!rst)", filename) is not None:
self.current_module = "bge.types"
else:
Expand All @@ -1083,7 +1083,7 @@ def _analyze_by_file(self, filename: str) -> 'SectionInfo':
section.add_info(class_info)
elif re.match(r"^\.\. function::", line):
deprecated = re.search(r"\(Deprecated", line) is not None
if self._is_bge_supported() and deprecated:
if self._target() == "upbge" and deprecated:
self._skip_until_next_le_level(file, level=RstLevel())
else:
file.seek(last_pos)
Expand All @@ -1097,7 +1097,7 @@ def _analyze_by_file(self, filename: str) -> 'SectionInfo':
section.add_info(function_info)
elif re.match(r"^\.\. (data|DATA)::", line):
deprecated = re.search(r"\(Deprecated", line) is not None
if self._is_bge_supported() and deprecated:
if self._target() == "upbge" and deprecated:
self._skip_until_next_le_level(file, level=RstLevel())
else:
file.seek(last_pos)
Expand Down
2 changes: 1 addition & 1 deletion src/fake_bpy_module/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def _analyze_by_rule(
# replace windows path separator
target_files = [f.replace("\\", "/") for f in rule.target_files()]
# analyze all .rst files
if self._config.support_bge:
if self._config.target == "upbge":
rule.analyzer().enable_bge_support()
if self._config.blender_version is not None:
rule.analyzer().set_blender_version(self._config.blender_version)
Expand Down

0 comments on commit 2e8a79e

Please sign in to comment.