Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 13, 2024
1 parent c46cce8 commit 9be0e3a
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 98 deletions.
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
from os import environ, path

import sys
from os import environ, path

sys.path.insert(0, path.abspath(".."))

Expand Down
4 changes: 3 additions & 1 deletion menu_from_project/datamodel/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ class Project:
file: str
type_storage: str
valid: bool = True
cache_config: ProjectCacheConfig = field(default_factory=lambda: ProjectCacheConfig())
cache_config: ProjectCacheConfig = field(
default_factory=lambda: ProjectCacheConfig()
)
5 changes: 1 addition & 4 deletions menu_from_project/datamodel/project_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from typing import Any, List, Optional

# PyQGIS
from qgis.core import (
QgsMapLayerType,
QgsWkbTypes,
)
from qgis.core import QgsMapLayerType, QgsWkbTypes


@dataclass
Expand Down
14 changes: 5 additions & 9 deletions menu_from_project/logic/cache_manager.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# standard
from dataclasses import asdict
from datetime import datetime, timedelta
import json
import os
from pathlib import Path
import tempfile
from dataclasses import asdict
from datetime import datetime, timedelta
from pathlib import Path
from typing import List, Optional

# PyQGIS
from qgis.core import QgsMessageLog, QgsFileDownloader
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtCore import (
QEventLoop,
QUrl,
)
from qgis.core import QgsFileDownloader, QgsMessageLog
from qgis.PyQt.QtCore import QCoreApplication, QEventLoop, QUrl

# project
from menu_from_project.__about__ import __title__
Expand Down
25 changes: 10 additions & 15 deletions menu_from_project/logic/layer_load.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
# Standard library
import re
import os
import re
from typing import Dict, List, Optional, Tuple


# PyQGIS
from menu_from_project.toolbelt.preferences import PlgOptionsManager
from qgis.core import (
QgsApplication,
QgsLayerTreeGroup,
QgsMapLayer,
QgsMessageLog,
QgsProject,
QgsRasterLayer,
QgsReadWriteContext,
QgsRelation,
QgsVectorLayer,
QgsVectorTileLayer,
QgsRelation,
QgsLayerTreeGroup,
QgsMapLayer,
)
from qgis.PyQt import QtXml
from qgis.PyQt.QtCore import (
QCoreApplication,
QFileInfo,
Qt,
QUuid,
)
from qgis.utils import plugins, iface
from qgis.PyQt.QtCore import QCoreApplication, QFileInfo, Qt, QUuid
from qgis.PyQt.QtWidgets import QMenu, QWidget
from qgis.utils import iface, plugins

# project
from menu_from_project.__about__ import __title__
Expand All @@ -37,6 +29,9 @@
)
from menu_from_project.logic.xml_utils import getFirstChildByTagNameValue

# PyQGIS
from menu_from_project.toolbelt.preferences import PlgOptionsManager


class LayerLoad:

Expand Down Expand Up @@ -516,7 +511,7 @@ def loadLayer(
j.setJoinLayerId(joinLayer.id())
j.setJoinLayer(joinLayer)
layer.addJoin(j)
except Exception as e:
except Exception:
self.log(
"Joined layer {} not added.".format(j.joinLayerId())
)
Expand Down
21 changes: 9 additions & 12 deletions menu_from_project/logic/project_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@
from pathlib import Path
from typing import Dict, Optional, Tuple

from qgis.core import QgsMapLayerType, QgsMessageLog, QgsWkbTypes

# PyQGIS
from qgis.PyQt import QtXml
from qgis.PyQt.QtCore import QFileInfo
from qgis.core import (
QgsMapLayerType,
QgsWkbTypes,
QgsMessageLog,
)

# project
from menu_from_project.__about__ import __title__
from menu_from_project.datamodel.project import Project
from menu_from_project.logic.xml_utils import getFirstChildByAttrValue
from menu_from_project.datamodel.project_config import (
MenuGroupConfig,
MenuLayerConfig,
MenuProjectConfig,
)
from menu_from_project.logic.qgs_manager import (
QgsDomManager,
get_project_title,
create_map_layer_dict,
get_project_title,
is_absolute,
)
from menu_from_project.datamodel.project_config import (
MenuProjectConfig,
MenuGroupConfig,
MenuLayerConfig,
)
from menu_from_project.logic.xml_utils import getFirstChildByAttrValue


def get_embedded_project_from_layer_tree(
Expand Down
8 changes: 4 additions & 4 deletions menu_from_project/logic/qgs_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

# PyQGIS
from qgis.core import (
QgsApplication,
QgsFileDownloader,
QgsReadWriteContext,
QgsMessageLog,
QgsApplication,
QgsReadWriteContext,
)
from qgis.PyQt import QtXml
from qgis.PyQt.QtCore import (
Expand All @@ -30,14 +30,14 @@
QTemporaryDir,
QUrl,
)

from qgis.utils import iface

from menu_from_project.__about__ import __title__, __title_clean__

# project
from menu_from_project.logic.cache_manager import CacheManager
from menu_from_project.logic.tools import guess_type_from_uri
from menu_from_project.logic.xml_utils import getFirstChildByTagNameValue
from menu_from_project.__about__ import __title__, __title_clean__

# ############################################################################
# ########## Globals ###############
Expand Down
59 changes: 29 additions & 30 deletions menu_from_project/menu_from_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,47 @@
# Standard library
import logging
import os
from typing import Dict, Optional, List, Tuple, Any
from typing import Any, List, Optional, Tuple

from qgis.core import QgsApplication, QgsMessageLog, QgsSettings, QgsTask
from qgis.PyQt.QtCore import (
QCoreApplication,
QDir,
QFileInfo,
QLocale,
Qt,
QTranslator,
QUrl,
)
from qgis.PyQt.QtGui import QDesktopServices, QFont, QIcon
from qgis.PyQt.QtWidgets import QAction, QMenu

# project
from menu_from_project.__about__ import DIR_PLUGIN_ROOT, __title__

# PyQGIS
from menu_from_project.datamodel.project import Project
from menu_from_project.datamodel.project_config import (
MenuGroupConfig,
MenuLayerConfig,
MenuProjectConfig,
)
from menu_from_project.logic.cache_manager import CacheManager
from menu_from_project.logic.layer_load import LayerLoad
from menu_from_project.toolbelt.preferences import (
SOURCE_MD_LAYER,
SOURCE_MD_NOTE,
SOURCE_MD_OGC,
PlgOptionsManager,
)
from qgis.core import (
QgsApplication,
QgsMessageLog,
QgsSettings,
QgsTask,
)
from qgis.PyQt.QtCore import QCoreApplication, QFileInfo, Qt, QTranslator
from qgis.PyQt.QtGui import QFont, QIcon
from qgis.PyQt.QtWidgets import QAction, QMenu
from qgis.PyQt.QtCore import QLocale, QUrl, QDir
from qgis.PyQt.QtGui import QDesktopServices

# project
from menu_from_project.__about__ import DIR_PLUGIN_ROOT, __title__, __title_clean__
from menu_from_project.logic.project_read import get_project_menu_config
from menu_from_project.logic.qgs_manager import (
QgsDomManager,
read_from_file,
read_from_http,
)
from menu_from_project.logic.tools import (
icon_per_layer_type,
from menu_from_project.logic.tools import icon_per_layer_type
from menu_from_project.toolbelt.preferences import (
SOURCE_MD_LAYER,
SOURCE_MD_NOTE,
SOURCE_MD_OGC,
PlgOptionsManager,
)
from menu_from_project.ui.menu_conf_dlg import MenuConfDialog # noqa: F4 I001
from menu_from_project.datamodel.project_config import (
MenuGroupConfig,
MenuLayerConfig,
MenuProjectConfig,
)

from menu_from_project.logic.project_read import get_project_menu_config

# ############################################################################
# ########## Globals ###############
Expand Down
2 changes: 1 addition & 1 deletion menu_from_project/toolbelt/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qgis.core import QgsSettings

# package
from menu_from_project.__about__ import __title__, __version__
from menu_from_project.__about__ import __version__
from menu_from_project.datamodel.project import Project, ProjectCacheConfig
from menu_from_project.logic.tools import guess_type_from_uri

Expand Down
27 changes: 13 additions & 14 deletions menu_from_project/ui/menu_conf_dlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,14 @@
import logging
from functools import partial

# PyQGIS
from menu_from_project.datamodel.project import Project, ProjectCacheConfig
from menu_from_project.logic.qgs_manager import QgsDomManager
from menu_from_project.toolbelt.preferences import (
SOURCE_MD_LAYER,
SOURCE_MD_NOTE,
SOURCE_MD_OGC,
PlgOptionsManager,
)
from qgis.core import QgsApplication, Qgis, QgsMessageLog
from qgis.gui import QgsProviderGuiRegistry, QgsSpinBox, QgsFileWidget
from qgis.core import Qgis, QgsApplication, QgsMessageLog
from qgis.gui import QgsFileWidget, QgsProviderGuiRegistry, QgsSpinBox
from qgis.PyQt import uic
from qgis.PyQt.QtCore import QRect, Qt
from qgis.PyQt.QtGui import QIcon, QPixmap
from qgis.PyQt.QtWidgets import (
QAction,
QCheckBox,
QComboBox,
QDialog,
QFileDialog,
Expand All @@ -33,15 +25,22 @@
QMenu,
QTableWidgetItem,
QToolButton,
QCheckBox,
)
from qgis.utils import iface

# project
from menu_from_project.__about__ import DIR_PLUGIN_ROOT, __title__, __version__

# PyQGIS
from menu_from_project.datamodel.project import Project, ProjectCacheConfig
from menu_from_project.logic.custom_datatypes import TABLE_COLUMNS_ORDER
from menu_from_project.logic.tools import (
icon_per_storage_type,
from menu_from_project.logic.qgs_manager import QgsDomManager
from menu_from_project.logic.tools import icon_per_storage_type
from menu_from_project.toolbelt.preferences import (
SOURCE_MD_LAYER,
SOURCE_MD_NOTE,
SOURCE_MD_OGC,
PlgOptionsManager,
)

# ############################################################################
Expand Down
12 changes: 6 additions & 6 deletions tests/qgis/test_project_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

# standard library

# PyQGIS
from qgis.testing import unittest
from pathlib import Path

from qgis.core import QgsMapLayerType, QgsWkbTypes

from pathlib import Path
# PyQGIS
from qgis.testing import unittest

from menu_from_project.datamodel.project import Project
from menu_from_project.datamodel.project_config import (
MenuProjectConfig,
MenuGroupConfig,
MenuLayerConfig,
MenuProjectConfig,
)
from menu_from_project.logic.project_read import get_project_menu_config
from menu_from_project.logic.qgs_manager import QgsDomManager
from menu_from_project.datamodel.project import Project


# ############################################################################
# ########## Classes #############
Expand Down

0 comments on commit 9be0e3a

Please sign in to comment.