Draft: Avoid dictionary.keys() where possible (#10160)
This commit is contained in:
@@ -71,7 +71,7 @@ def move(objectslist, vector, copy=False):
|
||||
doc = App.ActiveDocument
|
||||
for obj in objectslist:
|
||||
if obj.isDerivedFrom("App::DocumentObjectGroup") \
|
||||
and obj.Name not in newgroups.keys():
|
||||
and obj.Name not in newgroups:
|
||||
newgroups[obj.Name] = doc.addObject(obj.TypeId,
|
||||
utils.get_real_name(obj.Name))
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ def rotate(objectslist, angle, center=App.Vector(0, 0, 0),
|
||||
doc = App.ActiveDocument
|
||||
for obj in objectslist:
|
||||
if obj.isDerivedFrom("App::DocumentObjectGroup") \
|
||||
and obj.Name not in newgroups.keys():
|
||||
and obj.Name not in newgroups:
|
||||
newgroups[obj.Name] = doc.addObject(obj.TypeId,
|
||||
utils.get_real_name(obj.Name))
|
||||
|
||||
|
||||
@@ -183,12 +183,12 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
|
||||
# empty annotation styles list
|
||||
pass
|
||||
else:
|
||||
if vobj.AnnotationStyle in self.renamed.keys():
|
||||
if vobj.AnnotationStyle in self.renamed:
|
||||
# the style has been renamed
|
||||
# temporarily add the new style and switch to it
|
||||
vobj.AnnotationStyle = vobj.AnnotationStyle + [self.renamed[vobj.AnnotationStyle]]
|
||||
vobj.AnnotationStyle = self.renamed[vobj.AnnotationStyle]
|
||||
if vobj.AnnotationStyle in styles.keys():
|
||||
if vobj.AnnotationStyle in styles:
|
||||
if vobj.AnnotationStyle in changedstyles:
|
||||
# the style has changed
|
||||
for attr, value in styles[vobj.AnnotationStyle].items():
|
||||
@@ -202,7 +202,7 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
|
||||
else:
|
||||
# the style has been removed
|
||||
vobj.AnnotationStyle = ""
|
||||
vobj.AnnotationStyle = [""] + list(styles.keys())
|
||||
vobj.AnnotationStyle = [""] + list(styles)
|
||||
|
||||
def on_style_changed(self, index):
|
||||
"""Execute as a callback when the styles combobox changes."""
|
||||
|
||||
@@ -750,7 +750,7 @@ class Edit(gui_base_original.Modifier):
|
||||
"""
|
||||
if (hasattr(obj, 'obj_gui_tools') or
|
||||
(hasattr(obj, 'Proxy') and hasattr(obj.Proxy, 'obj_gui_tools')) or
|
||||
(utils.get_type(obj) in self.gui_tools_repository.keys()) ):
|
||||
(utils.get_type(obj) in self.gui_tools_repository) ):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -106,12 +106,13 @@ class Draft_SetStyle_TaskPanel:
|
||||
presets = [self.form.comboPresets.itemText(0)]
|
||||
self.form.comboPresets.clear()
|
||||
pdict = self.load()
|
||||
presets.extend(pdict.keys())
|
||||
pdict_keys = list(pdict)
|
||||
presets.extend(pdict_keys)
|
||||
self.form.comboPresets.addItems(presets)
|
||||
current = self.getValues()
|
||||
for name,preset in pdict.items():
|
||||
for name, preset in pdict.items():
|
||||
if all(item in current.items() for item in preset.items()): #if preset == current:
|
||||
self.form.comboPresets.setCurrentIndex(1+(list(pdict.keys()).index(name)))
|
||||
self.form.comboPresets.setCurrentIndex(1 + (pdict_keys.index(name)))
|
||||
break
|
||||
|
||||
def getPrefColor(self,group,prop,default):
|
||||
@@ -273,7 +274,7 @@ class Draft_SetStyle_TaskPanel:
|
||||
|
||||
if index > 0:
|
||||
pdict = self.load()
|
||||
if self.form.comboPresets.itemText(index) in pdict.keys():
|
||||
if self.form.comboPresets.itemText(index) in pdict:
|
||||
preset = pdict[self.form.comboPresets.itemText(index)]
|
||||
self.setValues(preset)
|
||||
|
||||
@@ -287,7 +288,7 @@ class Draft_SetStyle_TaskPanel:
|
||||
name = reply[0]
|
||||
pdict = self.load()
|
||||
if pdict:
|
||||
if name in pdict.keys():
|
||||
if name in pdict:
|
||||
reply = QtGui.QMessageBox.question(None,
|
||||
translate("Draft","Warning"),
|
||||
translate("Draft","Name exists. Overwrite?"),
|
||||
|
||||
@@ -106,7 +106,7 @@ class ViewProviderDraft(object):
|
||||
"Draft",
|
||||
QT_TRANSLATE_NOOP("App::Property",
|
||||
"Defines an SVG pattern."))
|
||||
patterns = list(utils.svg_patterns().keys())
|
||||
patterns = list(utils.svg_patterns())
|
||||
patterns.sort()
|
||||
vobj.Pattern = ["None"] + patterns
|
||||
|
||||
@@ -283,7 +283,7 @@ class ViewProviderDraft(object):
|
||||
path = vobj.TextureImage
|
||||
if not path:
|
||||
if hasattr(vobj, "Pattern"):
|
||||
if str(vobj.Pattern) in list(utils.svg_patterns().keys()):
|
||||
if str(vobj.Pattern) in utils.svg_patterns():
|
||||
path = utils.svg_patterns()[vobj.Pattern][1]
|
||||
else:
|
||||
path = "None"
|
||||
|
||||
Reference in New Issue
Block a user