Skip to content

Commit

Permalink
indentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 13, 2014
1 parent a8150d1 commit 3682384
Show file tree
Hide file tree
Showing 33 changed files with 138 additions and 139 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/gdal/GdalAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@


class GdalAlgorithm(GeoAlgorithm):

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + '/../../images/gdal.png')

class GdalScriptAlgorithm(ScriptAlgorithm):

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + '/../../images/gdal.png')
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridAverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GridAverage(GdalAlgorithm):
ANGLE = 'ANGLE'
NODATA = 'NODATA'
OUTPUT = 'OUTPUT'

def commandLineName(self):
return "gdalogr:gridaverage"

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridDataMetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class GridDataMetrics(GdalAlgorithm):

def commandLineName(self):
return "gdalogr:griddatametrics"

def defineCharacteristics(self):
self.name = 'Grid (Data metrics)'
self.group = '[GDAL] Analysis'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridInvDist.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GridInvDist(GdalAlgorithm):

def commandLineName(self):
return "gdalogr:gridinvdist"

def defineCharacteristics(self):
self.name = 'Grid (Inverse distance to a power)'
self.group = '[GDAL] Analysis'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridNearest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class GridNearest(GdalAlgorithm):

def commandLineName(self):
return "gdalogr:gridnearestneighbor"

def defineCharacteristics(self):
self.name = 'Grid (Nearest neighbor)'
self.group = '[GDAL] Analysis'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/polygonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class polygonize(GdalAlgorithm):
INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
FIELD = 'FIELD'

def commandLineName(self):
return "gdalogr:polygonize"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def processAlgorithm(self, progress):
filename = self.getParameterValue(self.INTERSECT)
selectLayer = dataobjects.getObjectFromUri(filename)
index = vector.spatialindex(layer)

output = self.getOutputFromName(self.OUTPUT)
writer = output.getVectorWriter(layer.pendingFields(),
layer.dataProvider().geometryType(), layer.crs())
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ def help(self):
where the description is stored.
Returns None if there is no help file available.
The default implementation looks for an rst file in a help folder under the folder
The default implementation looks for an rst file in a help folder under the folder
where the algorithm is located.
The name of the file is the name console name of the algorithm, without the namespace part
"""
name = self.commandLineName().split(':')[1].lower()
filename = os.path.join(os.path.dirname(inspect.getfile(self.__class__)), 'help', name + '.rst')
print filename
filename = os.path.join(os.path.dirname(inspect.getfile(self.__class__)), 'help', name + '.rst')
print filename
try:
html = getHtmlFromRstFile(filename)
return True, html
except:
return False, None


def processAlgorithm(self):
"""Here goes the algorithm itself.
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/AlgorithmClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def loadClassification():
lines.close()

@staticmethod
def classificationFile():
return os.path.join(os.path.join(os.path.dirname(__file__), 'algclasssification.txt'))
def classificationFile():
return os.path.join(os.path.join(os.path.dirname(__file__), 'algclasssification.txt'))

@staticmethod
def getGroupsAndName(alg):
Expand Down
107 changes: 53 additions & 54 deletions python/plugins/processing/gui/GetScriptsAndModels.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def execute(self):
try:
dlg = GetScriptsAndModelsDialog(GetScriptsAndModelsDialog.SCRIPTS)
dlg.exec_()
if dlg.updateToolbox:
if dlg.updateToolbox:
self.toolbox.updateProvider('script')

except HTTPError:
QMessageBox.critical(iface.mainWindow(), "Connection problem", "Could not connect to scripts/models repository")

class GetModelsAction(ToolboxAction):

def __init__(self):
Expand All @@ -74,19 +74,19 @@ def execute(self):
try:
dlg = GetScriptsAndModelsDialog(GetScriptsAndModelsDialog.MODELS)
dlg.exec_()
if dlg.updateToolbox:
self.toolbox.updateProvider('model')
if dlg.updateToolbox:
self.toolbox.updateProvider('model')
except HTTPError:
QMessageBox.critical(iface.mainWindow(), "Connection problem", "Could not connect to scripts/models repository")
def readUrl(url):


def readUrl(url):
try:
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
return urllib2.urlopen(url).read()
finally:
finally:
QApplication.restoreOverrideCursor()


class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):

Expand All @@ -95,55 +95,55 @@ class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):
"<p>Algorithms are divided in 3 groups:</p>"
"<ul><li><b>Installed:</b> Algorihms already in your system, with the latest version available</li>"
"<li><b>Upgradable:</b> Algorihms already in your system, but with a newer version available in the server</li>"
"<li><b>Not installed:</b> Algorithms not installed in your system</li></ul>")
"<li><b>Not installed:</b> Algorithms not installed in your system</li></ul>")
MODELS = 0
SCRIPTS = 1

def __init__(self, resourceType):
QDialog.__init__(self, iface.mainWindow())
self.resourceType = resourceType
self.resourceType = resourceType
if self.resourceType == self.MODELS:
self.folder = ModelerUtils.modelsFolder()
self.folder = ModelerUtils.modelsFolder()
self.urlBase = "https://raw.githubusercontent.com/qgis/QGIS-Processing/master/models/"
self.icon = QtGui.QIcon(os.path.dirname(__file__) + '/../images/model.png')
else:
self.folder = ScriptUtils.scriptsFolder()
self.folder = ScriptUtils.scriptsFolder()
self.urlBase = "https://raw.githubusercontent.com/qgis/QGIS-Processing/master/scripts/"
self.icon = QtGui.QIcon(os.path.dirname(__file__) + '/../images/script.png')
self.lastSelectedItem = None
self.icon = QtGui.QIcon(os.path.dirname(__file__) + '/../images/script.png')
self.lastSelectedItem = None
self.setupUi(self)
self.populateTree()
self.updateToolbox = False
self.populateTree()
self.updateToolbox = False
self.buttonBox.accepted.connect(self.okPressed)
self.buttonBox.rejected.connect(self.cancelPressed)
self.tree.currentItemChanged .connect(self.currentItemChanged)
def populateTree(self):
self.uptodateItem = QTreeWidgetItem()

def populateTree(self):
self.uptodateItem = QTreeWidgetItem()
self.uptodateItem.setText(0, "Installed")
self.toupdateItem = QTreeWidgetItem()
self.toupdateItem.setText(0, "Upgradable")
self.notinstalledItem = QTreeWidgetItem()
self.notinstalledItem.setText(0, "Not installed")
self.notinstalledItem.setText(0, "Not installed")
self.toupdateItem.setIcon(0, self.icon)
self.uptodateItem.setIcon(0, self.icon)
self.notinstalledItem.setIcon(0, self.icon)
self.notinstalledItem.setIcon(0, self.icon)
resources = readUrl(self.urlBase + "list.txt").splitlines()
resources = [r.split(",") for r in resources]
for filename, version, name in resources:
treeBranch = self.getTreeBranchForState(filename, float(version))
item = TreeItem(filename, name, self.icon)
treeBranch = self.getTreeBranchForState(filename, float(version))
item = TreeItem(filename, name, self.icon)
treeBranch.addChild(item)
if treeBranch != self.notinstalledItem:
item.setCheckState(0, Qt.Checked)

self.tree.addTopLevelItem(self.toupdateItem)
self.tree.addTopLevelItem(self.notinstalledItem)
self.tree.addTopLevelItem(self.notinstalledItem)
self.tree.addTopLevelItem(self.uptodateItem)

self.webView.setHtml(self.HELP_TEXT)
def currentItemChanged(self, item, prev):

def currentItemChanged(self, item, prev):
if isinstance(item, TreeItem):
try:
url = self.urlBase + item.filename.replace(" ","%20") + ".help"
Expand All @@ -152,33 +152,33 @@ def currentItemChanged(self, item, prev):
html = "<h2>%s</h2>" % item.name
html+="<p><b>Description:</b> " + getDescription(ALG_DESC, descriptions)+"</p>"
html+="<p><b>Created by:</b> " + getDescription(ALG_CREATOR, descriptions)+"</p>"
html+="<p><b>Version:</b> " + getDescription(ALG_VERSION, descriptions)+"</p>"
html+="<p><b>Version:</b> " + getDescription(ALG_VERSION, descriptions)+"</p>"
except HTTPError, e:
html = "<h2>No detailed description available for this script</h2>"
self.webView.setHtml(html)
else:
self.webView.setHtml(self.HELP_TEXT)
def getTreeBranchForState(self, filename, version):

def getTreeBranchForState(self, filename, version):
if not os.path.exists(os.path.join(self.folder, filename)):
return self.notinstalledItem
else:
helpFile = os.path.join(self.folder, filename + ".help")
try:
with open(helpFile) as f:
with open(helpFile) as f:
helpContent = json.load(f)
currentVersion = float(helpContent[Help2Html.ALG_VERSION])
except:
currentVersion = 1
if version > currentVersion:
currentVersion = 1
if version > currentVersion:
return self.toupdateItem
else:
return self.uptodateItem


def cancelPressed(self):
self.close()
self.close()

def okPressed(self):
toDownload = []
for i in xrange(self.toupdateItem.childCount()):
Expand All @@ -188,19 +188,19 @@ def okPressed(self):
for i in xrange(self.notinstalledItem.childCount()):
item = self.notinstalledItem.child(i)
if item.checkState(0) == Qt.Checked:
toDownload.append(item.filename)
if toDownload:
toDownload.append(item.filename)

if toDownload:
self.progressBar.setMaximum(len(toDownload))
for i, filename in enumerate(toDownload):
QCoreApplication.processEvents()
url = self.urlBase + filename.replace(" ","%20")
code = readUrl(url)
code = readUrl(url)
path = os.path.join(self.folder, filename)
with open(path, "w") as f:
f.write(code)
f.write(code)
self.progressBar.setValue(i + 1)

toDelete = []
for i in xrange(self.uptodateItem.childCount()):
item = self.uptodateItem.child(i)
Expand All @@ -209,24 +209,23 @@ def okPressed(self):
for filename in toDelete:
path = os.path.join(self.folder, filename)
os.remove(path)

self.updateToolbox = len(toDownload) + len(toDelete)> 0
self.close()
self.close()


class TreeItem(QTreeWidgetItem):

def __init__(self, filename, name, icon):
QTreeWidgetItem.__init__(self)
self.name = name
self.filename = filename
self.setText(0, name)
self.setIcon(0, icon)
self.name = name
self.filename = filename
self.setText(0, name)
self.setIcon(0, icon)
self.setCheckState(0, Qt.Unchecked)







2 changes: 1 addition & 1 deletion python/plugins/processing/gui/Help2Html.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def getHtmlFromHelpFile(alg, helpFile):
if not os.path.exists(helpFile):
return None
try:
with open(helpFile) as f:
with open(helpFile) as f:
descriptions = json.load(f)
except:
return None
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/gui/HelpEditionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def __init__(self, alg):
helpfile = alg.descriptionFile + '.help'
if os.path.exists(helpfile):
try:
with open(helpfile) as f:
with open(helpfile) as f:
self.descriptions = json.load(f)
except Exception, e:
print e
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, "Cannot open gelp file: " + helpfile)
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, "Cannot open gelp file: " + helpfile)

self.currentName = self.ALG_DESC
if self.ALG_DESC in self.descriptions:
self.text.setText(self.descriptions[self.ALG_DESC])
Expand All @@ -76,7 +76,7 @@ def accept(self):
if self.alg.descriptionFile is not None:
try:
with open(self.alg.descriptionFile + '.help', 'w') as f:
json.dump(self.descriptions, f)
json.dump(self.descriptions, f)
except Exception, e:
QMessageBox.warning(self, 'Error saving help file',
'Help file could not be saved.\n'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/ScriptEditorDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def saveScript(self, saveAs):
# the first time, we do it here
if self.help:
with open(self.filename + '.help', 'w') as f:
json.dump(self.help, f)
json.dump(self.help, f)
self.help = None
self.setHasChanged(False)
else:
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/UnthreadedAlgorithmExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def runalgIterating(alg, paramToIter, progress):
for out in alg.outputs:
outputs[out.name] = out.value

# now run all the algorithms
# now run all the algorithms
for i,f in enumerate(filelist):
alg.setParameterValue(paramToIter, f)
for out in alg.outputs:
Expand All @@ -100,7 +100,7 @@ def runalgIterating(alg, paramToIter, progress):
+ str(len(filelist)) + '...')
progress.setPercentage(i * 100 / len(filelist))
if UnthreadedAlgorithmExecutor.runalg(alg, SilentProgress()):
handleAlgorithmResults(alg, SilentProgress(), False)
handleAlgorithmResults(alg, SilentProgress(), False)
else:
return False

Expand Down
Loading

0 comments on commit 3682384

Please sign in to comment.