forked from qt-creator/qt-creator
Squish: Replacing some usages of len()
Change-Id: Icaf029043fed149bff6e15861fdcc6d640a2ecfc Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -406,7 +406,7 @@ def replaceLine(fileSpec, oldLine, newLine):
|
|||||||
if openDocumentPlaceCursor(fileSpec, oldLine) == None:
|
if openDocumentPlaceCursor(fileSpec, oldLine) == None:
|
||||||
return False
|
return False
|
||||||
editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
|
editor = waitForObject(":Qt Creator_CppEditor::Internal::CPPEditorWidget")
|
||||||
for i in range(len(oldLine)):
|
for _ in oldLine:
|
||||||
type(editor, "<Backspace>")
|
type(editor, "<Backspace>")
|
||||||
type(editor, newLine)
|
type(editor, newLine)
|
||||||
return True
|
return True
|
||||||
|
@@ -79,7 +79,7 @@ class Tree:
|
|||||||
def countChildOccurrences(self, name):
|
def countChildOccurrences(self, name):
|
||||||
if not self.__children__:
|
if not self.__children__:
|
||||||
return 0
|
return 0
|
||||||
return len(filter(lambda x: x.getName() == name, self.__children__))
|
return map(lambda x: x.getName(), self.__children__).count(name)
|
||||||
|
|
||||||
# internal functions
|
# internal functions
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@@ -53,23 +53,25 @@ def main():
|
|||||||
if isQt4Build and platform.system() == 'Darwin':
|
if isQt4Build and platform.system() == 'Darwin':
|
||||||
# avoid QTCREATORBUG-9197
|
# avoid QTCREATORBUG-9197
|
||||||
filtered = [filenames[0]]
|
filtered = [filenames[0]]
|
||||||
for i in range(1, len(filenames)):
|
for filename in filenames[1:]:
|
||||||
if filenames[i].lower() != filtered[-1].lower():
|
if filename.lower() != filtered[-1].lower():
|
||||||
filtered.append(filenames[i])
|
filtered.append(filename)
|
||||||
filenames = filtered
|
filenames = filtered
|
||||||
for i in range(len(filenames)):
|
previous = filenames[-1]
|
||||||
|
for filename in filenames:
|
||||||
tempFiletype = filetype
|
tempFiletype = filetype
|
||||||
if filetype == "QML" and filenames[i - 1][-4:] != ".qml":
|
if filetype == "QML" and previous[-4:] != ".qml":
|
||||||
tempFiletype = "Other files"
|
tempFiletype = "Other files"
|
||||||
# following is necessary due to QTCREATORBUG-10179
|
# following is necessary due to QTCREATORBUG-10179
|
||||||
# will be fixed when Qt5's MIME type database can be used
|
# will be fixed when Qt5's MIME type database can be used
|
||||||
if ((filenames[-1] in ("main.cpp", "utility.cpp") and filenames[i - 1][-4:] != ".cpp")
|
if ((filenames[-1] in ("main.cpp", "utility.cpp") and previous[-4:] != ".cpp")
|
||||||
or (filenames[-1] == "utility.h" and filenames[i - 1][-2:].lower() != ".h")
|
or (filenames[-1] == "utility.h" and previous[-2:].lower() != ".h")
|
||||||
or (filetype == "Resources" and filenames[i - 1][-4:] != ".qrc")):
|
or (filetype == "Resources" and previous[-4:] != ".qrc")):
|
||||||
tempFiletype = "Other files"
|
tempFiletype = "Other files"
|
||||||
# end of handling QTCREATORBUG-10179
|
# end of handling QTCREATORBUG-10179
|
||||||
renameFile(templateDir, usedProFile, projectName + "." + tempFiletype,
|
renameFile(templateDir, usedProFile, projectName + "." + tempFiletype,
|
||||||
filenames[i - 1], filenames[i])
|
previous, filename)
|
||||||
|
previous = filename
|
||||||
invokeMenuItem("File", "Exit")
|
invokeMenuItem("File", "Exit")
|
||||||
|
|
||||||
def renameFile(projectDir, proFile, branch, oldname, newname):
|
def renameFile(projectDir, proFile, branch, oldname, newname):
|
||||||
|
Reference in New Issue
Block a user