2016-03-02 20:53:19 -05:00
|
|
|
import copy
|
2018-05-21 13:10:17 -04:00
|
|
|
import os
|
2020-12-02 18:49:36 -05:00
|
|
|
from argparse import Namespace
|
2016-03-02 20:53:19 -05:00
|
|
|
|
2022-01-30 18:48:30 -05:00
|
|
|
|
2023-09-09 20:39:45 -04:00
|
|
|
class Context:
|
2022-01-30 18:48:30 -05:00
|
|
|
"""
|
2016-03-02 20:53:19 -05:00
|
|
|
Contextual data and information for plugins.
|
2022-01-30 18:48:30 -05:00
|
|
|
"""
|
2016-03-02 20:53:19 -05:00
|
|
|
|
2020-12-02 18:49:36 -05:00
|
|
|
def __init__(self, base_directory, options=Namespace()):
|
2016-03-02 20:53:19 -05:00
|
|
|
self._base_directory = base_directory
|
|
|
|
self._defaults = {}
|
2020-12-02 18:49:36 -05:00
|
|
|
self._options = options
|
2016-03-02 20:53:19 -05:00
|
|
|
pass
|
|
|
|
|
|
|
|
def set_base_directory(self, base_directory):
|
|
|
|
self._base_directory = base_directory
|
|
|
|
|
2018-05-21 13:10:17 -04:00
|
|
|
def base_directory(self, canonical_path=True):
|
|
|
|
base_directory = self._base_directory
|
|
|
|
if canonical_path:
|
|
|
|
base_directory = os.path.realpath(base_directory)
|
|
|
|
return base_directory
|
2016-03-02 20:53:19 -05:00
|
|
|
|
|
|
|
def set_defaults(self, defaults):
|
|
|
|
self._defaults = defaults
|
|
|
|
|
|
|
|
def defaults(self):
|
|
|
|
return copy.deepcopy(self._defaults)
|
2020-12-02 18:49:36 -05:00
|
|
|
|
|
|
|
def options(self):
|
|
|
|
return copy.deepcopy(self._options)
|