38
38
from qgis .PyQt .QtCore import QCoreApplication , QSettings , QTimer , QTranslator , qVersion
39
39
from qgis .PyQt .QtGui import QIcon
40
40
from qgis .PyQt .QtWidgets import QAction , QListWidgetItem , QMessageBox
41
+ from qgis .utils import iface
41
42
42
43
from nlsgpkgloader .nls_geopackage_loader_mtk_productdata import (
43
44
MTK_ALL_PRODUCTS_TITLE ,
64
65
class NLSGeoPackageLoader :
65
66
"""QGIS Plugin Implementation."""
66
67
67
- def __init__ (self , iface ):
68
+ def __init__ (self ):
68
69
"""Constructor.
69
70
70
71
:param iface: An interface instance that will be passed to this class
@@ -469,7 +470,7 @@ def toggle_layers(self):
469
470
self .instance .addMapLayer (self .utm10_layer )
470
471
if not found_utm5_layer and self .utm5_layer :
471
472
self .instance .addMapLayer (self .utm5_layer )
472
- except :
473
+ except Exception :
473
474
self .load_layers ()
474
475
if not found_utm200_layer and self .utm200_layer :
475
476
self .instance .addMapLayer (self .utm200_layer )
@@ -489,14 +490,14 @@ def toggle_layers(self):
489
490
if self .showSeatilesAsLayer and not found_seatiles_layer :
490
491
try :
491
492
self .instance .addMapLayer (self .seatile_layer )
492
- except :
493
+ except Exception :
493
494
self .load_layers ()
494
495
self .instance .addMapLayer (self .seatile_layer )
495
496
496
497
if self .showMunicipalitiesAsLayer and not found_municipality_layer :
497
498
try :
498
499
self .instance .addMapLayer (self .municipality_layer )
499
- except :
500
+ except Exception :
500
501
self .load_layers ()
501
502
self .instance .addMapLayer (self .municipality_layer )
502
503
@@ -704,18 +705,6 @@ def download_data(self, product_types):
704
705
self .all_urls .extend (urls )
705
706
self .total_download_count += len (urls )
706
707
707
- try :
708
- percentage = self .download_count / float (self .total_download_count ) * 100.0
709
- percentage_text = "%.2f" % round (percentage , 2 )
710
- except ZeroDivisionError :
711
- QMessageBox .critical (
712
- self .iface .mainWindow (),
713
- self .tr (u"Invalid selection" ),
714
- self .tr (u"Found nothing to download!" ),
715
- )
716
- self .progress_dialog .hide ()
717
- return
718
-
719
708
self .progress_dialog .progressBar .reset ()
720
709
self .progress_dialog .progressBar .show ()
721
710
self .progress_dialog .label .setText ("Downloading data..." )
@@ -746,7 +735,8 @@ def download_nls_product_types(self):
746
735
QgsMessageLog .logMessage (id .text , "NLSgpkgloader" , 0 )
747
736
748
737
if title .text == "Maastotietokanta, kaikki kohteet" :
749
- # TODO let user choose in the options dialog if the individual layers can be selected
738
+ # TODO let user choose in the options dialog if the individual
739
+ # layers can be selected
750
740
for mtk_product_name in MTK_PRODUCT_NAMES :
751
741
products [
752
742
MTK_LAYERS_KEY_PREFIX + mtk_product_name
@@ -763,7 +753,10 @@ def download_one_file(self):
763
753
or self .download_count >= len (self .all_urls )
764
754
):
765
755
QgsMessageLog .logMessage (
766
- "download_count == total_download_count or download_count >= len(all_urls)" ,
756
+ (
757
+ "download_count == total_download_count or "
758
+ "download_count >= len(all_urls)"
759
+ ),
767
760
"NLSgpkgloader" ,
768
761
2 ,
769
762
)
@@ -919,9 +912,9 @@ def show_settings_dialog(self):
919
912
920
913
def create_download_urls (self , product_key , product_title ):
921
914
urls = []
922
- if (
923
- product_key
924
- == "https://tiedostopalvelu.maanmittauslaitos.fi/tp/feed /mtp/maastotietokanta/kaikki"
915
+ if product_key == (
916
+ "https://tiedostopalvelu.maanmittauslaitos.fi/tp/feed"
917
+ " /mtp/maastotietokanta/kaikki"
925
918
):
926
919
for utm_feature in self .utm25lr_features :
927
920
sheet_name = utm_feature ["LEHTITUNNU" ]
0 commit comments