-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move DCS to plugin structure, fixed relative config sourcing
- Loading branch information
Showing
12 changed files
with
78 additions
and
10 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
File renamed without changes.
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,14 @@ | ||
from pathlib import Path | ||
|
||
from dynaconf import Dynaconf, Validator | ||
|
||
print(f"{Path(__file__).parent}") | ||
settings = Dynaconf( | ||
settings_files=[f"{Path(__file__).parent.joinpath('settings.json')}"], | ||
) | ||
|
||
settings.validators.register( | ||
Validator("PLUGIN_NAME", required=True), | ||
Validator("PLUGIN_ICON", required=True), | ||
Validator("VERSION", required=True), | ||
) |
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
File renamed without changes.
File renamed without changes.
Binary file not shown.
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,50 @@ | ||
import logging | ||
from pathlib import Path | ||
|
||
from dynaconf import Dynaconf, Validator | ||
|
||
from joystick_diagrams.input.profile_collection import ProfileCollection | ||
from joystick_diagrams.plugins.dcs_world_plugin.dcs_world import DCSWorldParser | ||
from joystick_diagrams.plugins.plugin_interface import PluginInterface | ||
|
||
from .config import settings | ||
|
||
_logger = logging.getLogger("__name__") | ||
|
||
|
||
class ParserPlugin(PluginInterface): | ||
def __init__(self): | ||
self.path = None | ||
self.settings = settings | ||
self.settings.validators.register() | ||
|
||
def process(self) -> ProfileCollection: | ||
return self.instance.process_profiles() | ||
|
||
def set_path(self, path: Path) -> bool: | ||
self.path = path | ||
try: | ||
self.instance = DCSWorldParser(self.path) | ||
except: | ||
return False | ||
return True | ||
|
||
@property | ||
def name(self) -> str: | ||
return f"{self.settings.PLUGIN_NAME}" | ||
|
||
@property | ||
def version(self) -> str: | ||
return f"{self.settings.VERSION}" | ||
|
||
@property | ||
def icon(self) -> str: | ||
return f"{Path.joinpath(Path(__file__).parent,self.settings.PLUGIN_ICON)}" | ||
|
||
@property | ||
def get_path(self) -> bool: | ||
return self.path | ||
|
||
|
||
if __name__ == "__main__": | ||
plugin = ParserPlugin() |
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,5 @@ | ||
{ | ||
"PLUGIN_NAME": "DCS World", | ||
"PLUGIN_ICON": "./img/dcs.ico", | ||
"VERSION": "2.0.0" | ||
} |
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