configpaths: Add get_plugin_dirs() method
This helps with mypy because otherwise get() has multiple return types This reduces our usage of cast()
This commit is contained in:
parent
5db0178a15
commit
ad5f59ba49
|
@ -24,7 +24,6 @@ from typing import List
|
|||
from typing import Generator
|
||||
from typing import Optional # pylint: disable=unused-import
|
||||
from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -37,14 +36,16 @@ from gajim.common.const import PathType, PathLocation
|
|||
from gajim.common.types import PathTuple
|
||||
|
||||
|
||||
def get(key: str) -> Union[str, List[str]]:
|
||||
if key == 'PLUGINS_DIRS':
|
||||
def get(key: str) -> str:
|
||||
return _paths[key]
|
||||
|
||||
|
||||
def get_plugin_dirs() -> List[str]:
|
||||
if gajim.IS_FLATPAK:
|
||||
return ['/app/plugins',
|
||||
_paths['PLUGINS_BASE']]
|
||||
return [_paths['PLUGINS_BASE'],
|
||||
_paths['PLUGINS_USER']]
|
||||
return _paths[key]
|
||||
|
||||
|
||||
def get_paths(type_: PathType) -> Generator[str, None, None]:
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import cast
|
||||
|
||||
import sys
|
||||
import os
|
||||
import traceback
|
||||
|
@ -42,7 +40,7 @@ if __name__ == '__main__':
|
|||
glade_file = os.path.join('data', 'gui', 'exception_dialog.ui')
|
||||
else:
|
||||
from gajim.common import configpaths
|
||||
gui_path = cast(str, configpaths.get('GUI'))
|
||||
gui_path = configpaths.get('GUI')
|
||||
glade_file = os.path.join(gui_path, 'exception_dialog.ui')
|
||||
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class PluginManager(metaclass=Singleton):
|
|||
Registered names with instances of encryption Plugins.
|
||||
'''
|
||||
|
||||
for path in reversed(configpaths.get('PLUGINS_DIRS')):
|
||||
for path in reversed(configpaths.get_plugin_dirs()):
|
||||
pc = PluginManager.scan_dir_for_plugins(path)
|
||||
self.add_plugins(pc)
|
||||
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import cast
|
||||
|
||||
import os
|
||||
import locale
|
||||
import gettext
|
||||
|
@ -23,7 +21,7 @@ import gettext
|
|||
from gajim.common import configpaths
|
||||
|
||||
APP = 'gajim_plugins'
|
||||
plugin_user_dir = cast(str, configpaths.get('PLUGINS_USER'))
|
||||
plugin_user_dir = configpaths.get('PLUGINS_USER')
|
||||
plugins_locale_dir = os.path.join(plugin_user_dir, 'locale')
|
||||
|
||||
if os.name != 'nt':
|
||||
|
|
Loading…
Reference in New Issue