[FOSSGIS-Talk] QGIS Python-Konsole "Indentation Error", Python-Editor kein "Indentation Error"

Chr. Enderle enderlec at staff.uni-marburg.de
Di Sep 27 08:28:30 CEST 2022


Hallo nochmal,

komisch, heute läuft das Skript auch in der Version wie im Beispiel 
meiner ersten mail in der Konsole ohne Fehlermeldung. Dann ist es 
vielleicht auch ein Speicherproblem? Gestern wollte es trotz geleerter 
Konsole und QGIS-Neustart nicht laufen. Egal. Jedenfalls habt ihr mich 
auf einen neuen Lösungsweg gebracht!

Viele Grüße,

Christiane

Am 26.09.2022 um 17:17 schrieb Thomas B:
> Hallo Christiane,
> kannst du mal testen, ob das hier durchläuft?
>
> https://gist.githubusercontent.com/thbaumann/2321f1f655ba44dea09b4ccddc39aa1f/raw/e875a1e9146cab4fb9978b67ed7ab98c318d5fcf/test_temp.py 
>
>
> VG
> Thomas
>
> Am Mo., 26. Sept. 2022 um 13:43 Uhr schrieb Chr. Enderle via 
> FOSSGIS-Talk-Liste <fossgis-talk-liste at fossgis.de>:
>
>
>
>
>     ---------- Forwarded message ----------
>     From: "Chr. Enderle" <enderlec at staff.uni-marburg.de>
>     To: fossgis-talk-liste at fossgis.de
>     Cc:
>     Bcc:
>     Date: Mon, 26 Sep 2022 13:43:26 +0200
>     Subject: QGIS Python-Konsole "Indentation Error", Python-Editor
>     kein "Indentation Error"
>     Hallo Liste,
>
>     mir ist aufgefallen, dass die Python-Konsole in QGIS (3.22) bei
>     Leerzeilen im Code "IndentationError" meldet, während der
>     Python-Editor
>     dasselbe Script ohne Fehlermeldung verarbeitet.
>
>     Es handelt sich um einzelne Leerzeilen gefolgt von einem
>     Kommentar, die
>     ich z.B. im Verlauf einer for-Schleife wegen der Übersichtlichkeit
>     eingefügt habe. Einen Beispiel-Ausschnitt aus dem Script siehe unten.
>     In dem Beispiel haben die Leerzeilen keine Einrückung. Ich füge das
>     gesamte Script per copy & paste in die Konsole bzw. den Editor
>     ein. In
>     der Konsole führt es zur genannten Fehlermeldung. Wenn das Script
>     dagegen aus dem Editor heraus gestartet wird, läuft es fehlerfrei.
>
>     Gibt es dafür eine Erklärung?
>
>     Wo im Code Einrückungen nötig sind, sind sie alle mit Tabulator(en)
>     gesetzt, keine Leerzeichen.
>
>     -------------------------------------------------------------------------------------------
>
>     # Iterating over the input layer :
>     for m in municip.getFeatures():
>          inh_center = m['EWZ']
>
>     # central municipalites with 0 inhabitants must be excluded; the
>     value
>     of "center_pos" will be set to -1.
>          if inh_center == 0:
>              center_pos = -1
>              dict = {m.fieldNameIndex('center_pos'):center_pos}
>              municip.dataProvider().changeAttributeValues({m.id
>     <http://m.id>(): dict})
>
>     # Extract by location:
>          else:
>              key = m['AGS']
>              municip.selectByExpression('\"AGS\" = ' + str(key),
>     QgsVectorLayer.SetSelection)
>              result =
>     processing.run("qgis:extractbylocation",{'INPUT':QgsProcessingFeatureSourceDefinition(municip.id
>     <http://municip.id>(),False),'PREDICATE':4,'INTERSECT':QgsProcessingFeatureSourceDefinition(municip.id
>     <http://municip.id>(),True),'OUTPUT':'memory:'})
>              extracted = result['OUTPUT']
>              count_all = extracted.featureCount()
>              countsmall = 0
>
>     ----------------------------------------------------------------------------------------
>
>     Viele Grüße,
>
>     Christiane
>
>
>     -- 
>     Christiane Enderle, MSc
>     Philipps-Universität Marburg
>     Fachbereich Geographie
>     Deutschhausstr. 10
>     35037 Marburg
>     Tel. +49 (0)6421-2822179
>     Fax +49 (0)6421-2828950
>
>
>
>
>     ---------- Forwarded message ----------
>     From: "Chr. Enderle via FOSSGIS-Talk-Liste"
>     <fossgis-talk-liste at fossgis.de>
>     To: fossgis-talk-liste at fossgis.de
>     Cc:
>     Bcc:
>     Date: Mon, 26 Sep 2022 13:43:26 +0200
>     Subject: [FOSSGIS-Talk] QGIS Python-Konsole "Indentation Error",
>     Python-Editor kein "Indentation Error"
>     -- 
>     ....................................................................
>     FOSSGIS Veranstaltungen
>     https://www.fossgis.de/news/fossgis-events/
>
>     FOSSGIS e.V, der Verein zur Förderung von Freier Software aus dem
>     GIS-Bereich und Freier Geodaten!
>     https://www.fossgis.de/ https://twitter.com/FOSSGIS_Verein
>
>     ____________________________________________________________________
>     FOSSGIS-Talk-Liste mailing list
>     FOSSGIS-Talk-Liste at fossgis.de
>     https://lists.fossgis.de/mailman/listinfo/fossgis-talk-liste
>
-- 
Christiane Enderle, MSc
Philipps-Universität Marburg
Fachbereich Geographie
Deutschhausstr. 10
35037 Marburg
Tel. +49 (0)6421-2822179
Fax +49 (0)6421-2828950


Mehr Informationen über die Mailingliste FOSSGIS-Talk-Liste