Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g.extension: fix getting addon directories names without Py/C source code #4900

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions scripts/g.extension/g.extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,25 +1449,36 @@ def install_extension_xml(edict):
def get_multi_addon_addons_which_install_only_html_man_page():
"""Get multi-addon addons which install only manual html page

:return list addons: list of multi-addon addons which install
only manual html page
:return list addon_dirs: list of addon directories which does
not contains any Python, C source code
files
tmszi marked this conversation as resolved.
Show resolved Hide resolved
"""
all_addon_dirs = []
addon_dirs = []
escape_dot = "\\."
addon_paths = re.findall(
rf".*{options['extension']}*.",
rf".*{options['extension'].replace('.', escape_dot)}.*",
get_addons_paths(gg_addons_base_dir=options["prefix"]),
)
addon_dir_paths = {os.path.dirname(i) for i in addon_paths}
for addon_dir in addon_dir_paths:
addon_src_files = list(
re.finditer(rf"{addon_dir}/(.*py)|(.*c)\n", "\n".join(addon_paths)),
re.finditer(
rf"{addon_dir.replace('.', escape_dot)}/(.*.py)|(.*.c)\n",
"\n".join(addon_paths),
),
)
if not addon_src_files:
all_addon_dirs.append(os.path.basename(addon_dir))
if addon_dir not in {os.path.dirname(i.group(0)) for i in addon_src_files}:
addon_dirs.append(os.path.basename(addon_dir))
else:
for addon_src_file in addon_src_files:
addon_paths.pop(addon_paths.index(addon_src_file.group(0)))
return all_addon_dirs
addon_paths.pop(
addon_paths.index(addon_src_file.group(0).replace("\n", ""))
)
gs.debug(
f"Addon dicrectories names <{', '.join(addon_dirs)}> which "
" does not contains any Python, C source code files."
)
tmszi marked this conversation as resolved.
Show resolved Hide resolved
return addon_dirs


def filter_multi_addon_addons(mlist):
Expand All @@ -1491,6 +1502,7 @@ def filter_multi_addon_addons(mlist):
# to check if metadata is available if there is no executable module.
for addon in get_multi_addon_addons_which_install_only_html_man_page():
if addon in mlist:
gs.debug(f"Addon name <{addon}> which install only HTML man page.")
tmszi marked this conversation as resolved.
Show resolved Hide resolved
mlist.pop(mlist.index(addon))
return mlist

Expand Down
Loading