Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Pytransifex api v3 + config plugin #4

Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pytransifex/config-plugins/opengis-mkdocs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TxProjectConfig(NamedTuple):
TX_TYPE = "GITHUBMARKDOWN"


def create_transifex_config(config: TxProjectConfig):
def create_tx_config(config: TxProjectConfig):
"""Parse all source documentation files and add the ones with tx_slug metadata
defined to transifex config file.
"""
Expand Down
6 changes: 4 additions & 2 deletions pytransifex/plugins_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class PluginManager:
# list of path_to_ subdir, path_to_ main.py
# list of path to subdir, path to main.py
discovered_subdir_main: list[tuple[Path, Path]] = []
# successfully imported modules
imported_modules: dict[str, Any] = {}
Expand All @@ -17,7 +17,8 @@ def discover():
Expecting directory structure:
pytransifex/
config-plugins/{plugins}
main.py
main.py:create_tx_config
main.py:TxProjectConfig
"""
plugins_dir = Path.cwd().joinpath("pytransifex", "config-plugins")
subdirs = [f for f in plugins_dir.iterdir() if f.is_dir()]
Expand Down Expand Up @@ -58,6 +59,7 @@ def load_plugin(target_plugin_dir: str):
if spec.loader:
spec.loader.exec_module(module)
PluginManager.imported_modules[name] = module

print(
f"Successfully imported and loaded {module}! Imported modules read: {PluginManager.imported_modules}"
)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_config-plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ def test2_plugin_import(self):

def test3_imported_plugin(self):
assert PluginManager.imported_modules["opengis-mkdocs"].TxProjectConfig

def test4_create_config(self):
imported = PluginManager.imported_modules["opengis-mkdocs"]
config_class = imported.TxProjectConfig
create_config = imported.create_tx_config
assert create_config.__name__ == "create_tx_config"
assert all(hasattr(config_class, k) for k in ["TX_ORGANIZATION", "TX_PROJECT", "TX_SOURCE_LANG", "TX_TYPE"])