Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from .plugins.pluginlist import load_plugin_list_if_exists | ||
|
||
|
||
__version__ = "0.23" | ||
__released__ = True |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
from typing import Dict, List, Optional, Tuple | ||
|
||
|
||
def load_plugin_list_if_exists(path: str) -> Optional[List[str]]: | ||
if not os.path.exists(path): | ||
return None | ||
|
||
return load_plugin_list(path) | ||
|
||
|
||
def load_plugin_list(path: str) -> List[str]: | ||
with open(path, "r") as f: | ||
data = f.read() | ||
return parse_plugins_list(data) | ||
|
||
|
||
def parse_plugins_list(data: str) -> List[str]: | ||
plugins: List[str] = [] | ||
definitions: Dict[str, Tuple[int, str]] = {} | ||
|
||
for line, entry in enumerate(data.splitlines()): | ||
plugin = entry.strip() | ||
|
||
if "#" in plugin: | ||
comment_start = plugin.find("#") | ||
plugin = plugin[:comment_start].strip() | ||
if not plugin: | ||
continue | ||
|
||
if plugin in definitions: | ||
first_line, first_entry = definitions[plugin] | ||
raise ValueError( | ||
f"plugin '{plugin}' is listed more than once: " | ||
f"at line {first_line} ('{first_entry}') and at {line} ('{entry}')" | ||
) | ||
definitions[plugin] = line, entry | ||
|
||
plugins.append(plugin) | ||
|
||
return plugins |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from ..pluginlist import parse_plugins_list | ||
|
||
|
||
def test_empty_plugins_str_is_parsed_to_empty_list(): | ||
assert parse_plugins_list("") == [] | ||
|
||
|
||
def test_comment_str_is_parsed_to_empty_list(): | ||
assert parse_plugins_list("# comment") == [] | ||
|
||
|
||
def test_line_containing_plugin_name_is_parsed(): | ||
assert parse_plugins_list("plugin") == ["plugin"] | ||
|
||
|
||
def test_comment_is_removed_from_line_containing_plugin_name(): | ||
assert parse_plugins_list("plugin # comment") == ["plugin"] | ||
|
||
|
||
def test_multiple_lines_containing_plugin_names_are_parsed(): | ||
assert parse_plugins_list("plugin1\nplugin2") == ["plugin1", "plugin2"] | ||
|
||
|
||
def test_empty_lines_are_skipped_by_parser(): | ||
assert parse_plugins_list("plugin1\n\nplugin2") == ["plugin1", "plugin2"] | ||
|
||
|
||
def test_comments_are_filtered_from_plugin_list(): | ||
assert parse_plugins_list("plugin1\n# comment\nplugin2") == ["plugin1", "plugin2"] | ||
|
||
|
||
def test_whitespace_is_stripped_from_line_start_and_end_by_parser(): | ||
assert parse_plugins_list("plugin1\n plugin2") == ["plugin1", "plugin2"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# List of enabled plugins | ||
# To enable plugin, simply enter its module name here: | ||
# | ||
# plugin_module | ||
# | ||
# To enable multiple plugins, list their names in separate lines: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# File purposefully left empty | ||
# Feel free to add plugins here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# This file is autogenerated by pip-compile | ||
# To update, run: | ||
# | ||
# pip-compile --output-file=requirements-plugins.txt requirements-plugins.in | ||
# |