You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/lib/ansible_test/_internal/classification/common.py

30 lines
822 B
Python

"""Common classification code used by multiple languages."""
from __future__ import annotations
import os
from ..data import (
data_context,
)
def resolve_csharp_ps_util(import_name, path):
"""
:type import_name: str
:type path: str
"""
if data_context().content.is_ansible or not import_name.startswith('.'):
# We don't support relative paths for builtin utils, there's no point.
return import_name
packages = import_name.split('.')
module_packages = path.split(os.path.sep)
for package in packages:
if not module_packages or package:
break
del module_packages[-1]
return 'ansible_collections.%s%s' % (data_context().content.prefix,
'.'.join(module_packages + [p for p in packages if p]))