flake8 automap
This commit is contained in:
parent
9b7ab9ab15
commit
133e785568
@ -4,9 +4,9 @@ __email__ = "info@3liz.org"
|
|||||||
|
|
||||||
|
|
||||||
from qgis.core import QgsApplication
|
from qgis.core import QgsApplication
|
||||||
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl
|
from qgis.PyQt.QtCore import Qt, QUrl
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
from qgis.PyQt.QtGui import QDesktopServices, QIcon
|
||||||
from qgis.PyQt.QtWidgets import QAction, QMessageBox
|
from qgis.PyQt.QtWidgets import QAction
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
import qgis
|
import qgis
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
|
|||||||
'''
|
'''
|
||||||
import os
|
import os
|
||||||
from qgis.PyQt.QtCore import QSettings
|
from qgis.PyQt.QtCore import QSettings
|
||||||
|
from .about_form import AboutDialog
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
# plugin_path,
|
# plugin_path,
|
||||||
resources_path,
|
resources_path,
|
||||||
@ -35,7 +36,6 @@ pyperclip()
|
|||||||
|
|
||||||
from .canvas_editor import AutoMap_Editor
|
from .canvas_editor import AutoMap_Editor
|
||||||
from .style_invoke import AutoMap_Style
|
from .style_invoke import AutoMap_Style
|
||||||
from .about_form import AboutDialog
|
|
||||||
|
|
||||||
|
|
||||||
class PgAutoMap:
|
class PgAutoMap:
|
||||||
@ -88,39 +88,6 @@ class PgAutoMap:
|
|||||||
if os.environ['USERNAME'] == 'tlaveille' or os.environ['USERNAME'] == 'lpoulin' or os.environ['USERNAME'] == 'rclement':
|
if os.environ['USERNAME'] == 'tlaveille' or os.environ['USERNAME'] == 'lpoulin' or os.environ['USERNAME'] == 'rclement':
|
||||||
iface.addDockWidget(Qt.DockWidgetArea(0x1), self.style_dock)
|
iface.addDockWidget(Qt.DockWidgetArea(0x1), self.style_dock)
|
||||||
|
|
||||||
'''
|
|
||||||
if not self.locator_filter:
|
|
||||||
self.locator_filter = LocatorFilter(iface)
|
|
||||||
iface.registerLocatorFilter(self.locator_filter)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def check_invalid_connection_names():
|
|
||||||
""" Check for invalid connection names in the QgsSettings. """
|
|
||||||
valid, invalid = validate_connections_names()
|
|
||||||
n_invalid = len(invalid)
|
|
||||||
|
|
||||||
if n_invalid == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
invalid_text = ', '.join(invalid)
|
|
||||||
msg = QMessageBox()
|
|
||||||
msg.setIcon(QMessageBox.Warning)
|
|
||||||
msg.setWindowTitle(tr('PgMetadata: Database connection(s) not available'))
|
|
||||||
msg.setText(tr(
|
|
||||||
f'{n_invalid} connection(s) listed in PgMetadata’s settings are invalid or '
|
|
||||||
f'no longer available: {invalid_text}'))
|
|
||||||
msg.setInformativeText(tr(
|
|
||||||
'Do you want to remove these connection(s) from the PgMetadata settings? '
|
|
||||||
'(You can also do this later with the “Set Connections” tool.)'))
|
|
||||||
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
|
||||||
clicked = msg.exec()
|
|
||||||
|
|
||||||
if clicked == QMessageBox.Yes:
|
|
||||||
iface.messageBar().pushSuccess('PgMetadata', tr(f'{n_invalid} invalid connection(s) removed.'))
|
|
||||||
store_connections(valid)
|
|
||||||
if clicked == QMessageBox.No:
|
|
||||||
iface.messageBar().pushInfo('PgMetadata', tr(f'Keeping {n_invalid} invalid connections.'))
|
|
||||||
'''
|
|
||||||
def open_about_dialog(self):
|
def open_about_dialog(self):
|
||||||
"""
|
"""
|
||||||
About dialog
|
About dialog
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import os.path
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from qgis.PyQt import uic
|
from qgis.PyQt import uic
|
||||||
from qgis.PyQt.QtGui import QPixmap
|
# from qgis.PyQt.QtGui import QPixmap
|
||||||
from qgis.PyQt.QtWidgets import QDialog
|
from qgis.PyQt.QtWidgets import QDialog
|
||||||
|
|
||||||
from .tools.resources import devlog
|
from .tools.resources import devlog
|
||||||
|
|||||||
@ -1,79 +1,41 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
from enum import Enum
|
|
||||||
from functools import partial
|
|
||||||
from pathlib import Path
|
|
||||||
from xml.dom.minidom import parseString
|
|
||||||
from qgis.gui import *
|
|
||||||
import qgis
|
|
||||||
from importlib import import_module
|
|
||||||
from qgis.core import (
|
from qgis.core import (
|
||||||
NULL,
|
|
||||||
QgsApplication,
|
|
||||||
QgsScaleBarSettings,
|
QgsScaleBarSettings,
|
||||||
QgsDataSourceUri,
|
|
||||||
QgsProject,
|
QgsProject,
|
||||||
QgsProviderConnectionException,
|
|
||||||
QgsProviderRegistry,
|
|
||||||
QgsRasterLayer,
|
QgsRasterLayer,
|
||||||
QgsSettings,
|
QgsSettings,
|
||||||
QgsVectorLayer,
|
QgsVectorLayer,
|
||||||
QgsGeometry,
|
|
||||||
QgsPrintLayout,
|
QgsPrintLayout,
|
||||||
QgsReadWriteContext,
|
QgsReadWriteContext,
|
||||||
QgsLayoutItemMap,
|
QgsLayoutItemMap,
|
||||||
QgsLayoutItemPage,
|
QgsLayoutItemPage,
|
||||||
QgsLayoutSize,
|
|
||||||
QgsUnitTypes,
|
QgsUnitTypes,
|
||||||
QgsLayoutPoint,
|
|
||||||
QgsLayoutItemLabel,
|
QgsLayoutItemLabel,
|
||||||
QgsLayoutItemPicture,
|
QgsLayoutItemPicture,
|
||||||
QgsLayoutItemLegend,
|
QgsLayoutItemLegend,
|
||||||
QgsLegendStyle,
|
QgsLegendStyle,
|
||||||
QgsLayoutItemScaleBar,
|
QgsLayoutItemScaleBar,
|
||||||
QgsLayerTreeGroup,
|
QgsLayerTreeGroup,
|
||||||
QgsCoordinateReferenceSystem,
|
|
||||||
QgsCoordinateTransform,
|
|
||||||
QgsLayerTree,
|
|
||||||
QgsLayoutTableColumn,
|
|
||||||
QgsRectangle,
|
QgsRectangle,
|
||||||
QgsLayoutItemMapOverviewStack,
|
|
||||||
)
|
)
|
||||||
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt
|
from qgis.PyQt.QtCore import Qt
|
||||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie
|
from qgis.PyQt.QtGui import QColor, QFont
|
||||||
from qgis.PyQt.QtPrintSupport import QPrinter
|
|
||||||
# from qgis.PyQt.QtWebKitWidgets import QWebPage
|
|
||||||
from qgis.PyQt.QtWidgets import (
|
from qgis.PyQt.QtWidgets import (
|
||||||
QDialog,
|
QDialog,
|
||||||
QAction,
|
|
||||||
QMessageBox,
|
QMessageBox,
|
||||||
QPushButton,
|
QPushButton,
|
||||||
QDockWidget,
|
|
||||||
QFileDialog,
|
QFileDialog,
|
||||||
QInputDialog,
|
|
||||||
QMenu,
|
|
||||||
QToolButton,
|
|
||||||
QTableWidget,
|
|
||||||
QTableWidgetItem,
|
|
||||||
QVBoxLayout,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from qgis.PyQt.QtCore import QSettings
|
from qgis.PyQt.QtCore import QSettings
|
||||||
from qgis.PyQt import QtGui, QtWidgets
|
from qgis.PyQt import QtGui
|
||||||
|
|
||||||
|
|
||||||
from qgis.PyQt.QtXml import QDomDocument
|
from qgis.PyQt.QtXml import QDomDocument
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
import glob
|
import glob
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
load_ui,
|
load_ui,
|
||||||
resources_path,
|
resources_path,
|
||||||
# send_issues,
|
|
||||||
)
|
)
|
||||||
from .issues import CenRa_Issues
|
|
||||||
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
EDITOR_CLASS = load_ui('CenRa_AutoMap_base.ui')
|
EDITOR_CLASS = load_ui('CenRa_AutoMap_base.ui')
|
||||||
@ -210,11 +172,11 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
self.mComboBox_4.clear()
|
self.mComboBox_4.clear()
|
||||||
logo_library = []
|
logo_library = []
|
||||||
custome_bibliotech = glob.glob(self.s.value("automap/logoteck", 1, type=str) + '*.*')
|
custome_bibliotech = glob.glob(self.s.value("automap/logoteck", 1, type=str) + '*.*')
|
||||||
for l, logo_x in enumerate(custome_bibliotech):
|
for number, logo_x in enumerate(custome_bibliotech):
|
||||||
logo_library.append(' ' + os.path.basename(logo_x))
|
logo_library.append(' ' + os.path.basename(logo_x))
|
||||||
|
|
||||||
bibliotech = glob.glob(resources_path("logo_library", "*.png"))
|
bibliotech = glob.glob(resources_path("logo_library", "*.png"))
|
||||||
for l, logo_x in enumerate(bibliotech):
|
for number, logo_x in enumerate(bibliotech):
|
||||||
logo_library.append(os.path.basename(logo_x))
|
logo_library.append(os.path.basename(logo_x))
|
||||||
self.mComboBox_4.addItems(sorted(logo_library))
|
self.mComboBox_4.addItems(sorted(logo_library))
|
||||||
|
|
||||||
@ -452,13 +414,13 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
layout_name = self.comboBox_7.currentText()
|
layout_name = self.comboBox_7.currentText()
|
||||||
else:
|
else:
|
||||||
layout_name = self.lineEdit_2.text()
|
layout_name = self.lineEdit_2.text()
|
||||||
layouts_list = self.manager.printLayouts()
|
# layouts_list = self.manager.printLayouts()
|
||||||
|
|
||||||
for filename in glob.glob(resources_path("mises_en_pages", "*.qpt")):
|
for filename in glob.glob(resources_path("mises_en_pages", "*.qpt")):
|
||||||
with open(os.path.join(os.getcwd(), filename), 'r') as f:
|
with open(os.path.join(os.getcwd(), filename), 'r') as f:
|
||||||
self.layout = QgsPrintLayout(project)
|
self.layout = QgsPrintLayout(project)
|
||||||
self.layout.initializeDefaults()
|
self.layout.initializeDefaults()
|
||||||
myAtlas = self.layout.atlas()
|
# myAtlas = self.layout.atlas()
|
||||||
template_content = f.read()
|
template_content = f.read()
|
||||||
doc = QDomDocument()
|
doc = QDomDocument()
|
||||||
doc.setContent(template_content)
|
doc.setContent(template_content)
|
||||||
@ -466,7 +428,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cutLayout = layout_name.index("¶")
|
cutLayout = layout_name.index("¶")
|
||||||
except:
|
except ValueError:
|
||||||
cutLayout = 0
|
cutLayout = 0
|
||||||
|
|
||||||
if cutLayout >= 1:
|
if cutLayout >= 1:
|
||||||
@ -782,7 +744,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
# if self.radioButton_12.isChecked() != 1:
|
# if self.radioButton_12.isChecked() != 1:
|
||||||
if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
|
if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
|
||||||
project.layoutManager().removeLayout(existing_layout)
|
project.layoutManager().removeLayout(existing_layout)
|
||||||
result = project.layoutManager().addLayout(self.layout)
|
# result = project.layoutManager().addLayout(self.layout)
|
||||||
elif self.QMBquestion != QMessageBox.StandardButton(0x00010000):
|
elif self.QMBquestion != QMessageBox.StandardButton(0x00010000):
|
||||||
LayoutCOUNT = 0
|
LayoutCOUNT = 0
|
||||||
arrayManager = []
|
arrayManager = []
|
||||||
@ -817,7 +779,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
|||||||
else:
|
else:
|
||||||
TryMessage = False
|
TryMessage = False
|
||||||
del self.QMBquestion
|
del self.QMBquestion
|
||||||
except:
|
except ValueError:
|
||||||
TryMessage = True
|
TryMessage = True
|
||||||
|
|
||||||
if TryMessage is True:
|
if TryMessage is True:
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from qgis.utils import iface
|
|||||||
import qgis
|
import qgis
|
||||||
|
|
||||||
# include <QSettings>
|
# include <QSettings>
|
||||||
|
from .about_form import AboutDialog
|
||||||
import os
|
import os
|
||||||
from .tools.resources import (
|
from .tools.resources import (
|
||||||
pyperclip,
|
pyperclip,
|
||||||
@ -21,7 +21,6 @@ from .tools.resources import (
|
|||||||
pyperclip()
|
pyperclip()
|
||||||
|
|
||||||
from .flux_editor import Flux_Editor
|
from .flux_editor import Flux_Editor
|
||||||
from .about_form import AboutDialog
|
|
||||||
|
|
||||||
|
|
||||||
class PgFlux:
|
class PgFlux:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user