diff --git a/sconstruct b/sconstruct index 6b8df42ebd7..aad61545dd5 100755 --- a/sconstruct +++ b/sconstruct @@ -394,6 +394,7 @@ def makePot(target, source, env): "--keyword=pgettext:1c,2", # Needed because xgettext doesn't recognise the .pyw extension. "--language=python", + "--from-code=UTF-8", ] + [os.path.relpath(str(f), str(sourceDir)) for f in source] ]) != 0: raise RuntimeError("xgettext failed") diff --git a/source/COMRegistrationFixes/__init__.py b/source/COMRegistrationFixes/__init__.py index 806c7466bb8..c5dc3f8ca08 100644 --- a/source/COMRegistrationFixes/__init__.py +++ b/source/COMRegistrationFixes/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: UTF-8 -*- #A part of NonVisual Desktop Access (NVDA) #Copyright (C) 2018 NV Access Limited #This file is covered by the GNU General Public License. diff --git a/source/JABHandler.py b/source/JABHandler.py index 77c94fd120f..7afe43f0e02 100644 --- a/source/JABHandler.py +++ b/source/JABHandler.py @@ -1,4 +1,3 @@ -# -*- coding: UTF-8 -*- # A part of NonVisual Desktop Access (NVDA) # Copyright (C) 2007-2019 NV Access Limited, Peter Vágner, Renaud Paquay, Babbage B.V. # This file is covered by the GNU General Public License. @@ -61,10 +60,10 @@ def _fixBridgeFunc(restype,name,*argtypes,**kwargs): try: bridgeDll=getattr(cdll,'windowsAccessBridge-32') legacyAccessBridge=False -except WindowsError: +except OSError: try: bridgeDll=cdll.windowsAccessBridge - except WindowsError: + except OSError: bridgeDll=None #Definitions of access bridge types, structs and prototypes @@ -344,7 +343,7 @@ def getWindowHandleFromAccContext(vmID,accContext): else: return vmIDsToWindowHandles.get(vmID) -class JABContext(object): +class JABContext: def __init__(self,hwnd=None,vmID=None,accContext=None): if hwnd and not vmID: @@ -416,7 +415,7 @@ def getAccessibleTextSelectionInfo(self): def getAccessibleTextRange(self,start,end): length=((end+1)-start) if length<=0: - return u"" + return "" # Use a string buffer, as from an unicode buffer, we can't get the raw data. buf = create_string_buffer((length +1) * 2) bridgeDll.getAccessibleTextRange(self.vmID, self.accContext, start, end, buf, length) diff --git a/source/NVDAHelper.py b/source/NVDAHelper.py index 822d1020151..375260d7678 100755 --- a/source/NVDAHelper.py +++ b/source/NVDAHelper.py @@ -81,12 +81,12 @@ def _lookupKeyboardLayoutNameWithHexString(layoutString): buf=create_unicode_buffer(1024) bufSize=c_int(2048) key=HKEY() - if windll.advapi32.RegOpenKeyExW(winreg.HKEY_LOCAL_MACHINE,u"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"+ layoutString,0,winreg.KEY_QUERY_VALUE,byref(key))==0: + if windll.advapi32.RegOpenKeyExW(winreg.HKEY_LOCAL_MACHINE,"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\"+ layoutString,0,winreg.KEY_QUERY_VALUE,byref(key))==0: try: - if windll.advapi32.RegQueryValueExW(key,u"Layout Display Name",0,None,buf,byref(bufSize))==0: + if windll.advapi32.RegQueryValueExW(key,"Layout Display Name",0,None,buf,byref(bufSize))==0: windll.shlwapi.SHLoadIndirectString(buf.value,buf,1023,None) return buf.value - if windll.advapi32.RegQueryValueExW(key,u"Layout Text",0,None,buf,byref(bufSize))==0: + if windll.advapi32.RegQueryValueExW(key,"Layout Text",0,None,buf,byref(bufSize))==0: return buf.value finally: windll.advapi32.RegCloseKey(key) @@ -147,7 +147,7 @@ def handleInputCompositionEnd(result): from NVDAObjects.inputComposition import InputComposition from NVDAObjects.IAccessible.mscandui import ModernCandidateUICandidateItem focus=api.getFocusObject() - result=result.lstrip(u'\u3000 ') + result=result.lstrip('\u3000 ') curInputComposition=None if isinstance(focus,InputComposition): curInputComposition=focus @@ -176,7 +176,7 @@ def handleInputCompositionEnd(result): speech.speechMode=oldSpeechMode if curInputComposition and not result: - result=curInputComposition.compositionString.lstrip(u'\u3000 ') + result=curInputComposition.compositionString.lstrip('\u3000 ') if result: speech.speakText(result,symbolLevel=characterProcessing.SYMLVL_ALL) @@ -386,7 +386,7 @@ def nvdaControllerInternal_inputLangChangeNotify(threadID,hkl,layoutString): inputMethodName="".join(inputMethodName.split(' - ')[1:]) #Include the language only if it changed. if languageID!=lastLanguageID: - msg=u"{language} - {layout}".format(language=inputLanguageName,layout=inputMethodName) + msg=f"{inputLanguageName} - {inputMethodName}" else: msg=inputMethodName lastLanguageID=languageID @@ -418,7 +418,7 @@ def nvdaControllerInternal_installAddonPackageFromPath(addonPath): wx.CallAfter(addonGui.handleRemoteAddonInstall, addonPath) return 0 -class RemoteLoader64(object): +class RemoteLoader64: def __init__(self): # Create a pipe so we can write to stdin of the loader process. @@ -438,7 +438,7 @@ def __init__(self): # Therefore, explicitly specify our own process token, which causes them to be inherited. token = winKernel.OpenProcessToken(winKernel.GetCurrentProcess(), winKernel.MAXIMUM_ALLOWED) try: - winKernel.CreateProcessAsUser(token, None, os.path.join(versionedLib64Path,u"nvdaHelperRemoteLoader.exe"), None, None, True, None, None, None, si, pi) + winKernel.CreateProcessAsUser(token, None, os.path.join(versionedLib64Path,"nvdaHelperRemoteLoader.exe"), None, None, True, None, None, None, si, pi) # We don't need the thread handle. winKernel.closeHandle(pi.hThread) self._process = pi.hProcess @@ -505,7 +505,7 @@ def initialize(): log.info("Remote injection disabled due to running as a Windows Store Application") return #Load nvdaHelperRemote.dll but with an altered search path so it can pick up other dlls in lib - h=windll.kernel32.LoadLibraryExW(os.path.abspath(os.path.join(versionedLibPath,u"nvdaHelperRemote.dll")),0,0x8) + h=windll.kernel32.LoadLibraryExW(os.path.abspath(os.path.join(versionedLibPath,"nvdaHelperRemote.dll")),0,0x8) if not h: log.critical("Error loading nvdaHelperRemote.dll: %s" % WinError()) return diff --git a/source/NVDAObjects/IAccessible/MSHTML.py b/source/NVDAObjects/IAccessible/MSHTML.py index 8b93c9e470e..5b7a3bf8fa2 100644 --- a/source/NVDAObjects/IAccessible/MSHTML.py +++ b/source/NVDAObjects/IAccessible/MSHTML.py @@ -39,7 +39,7 @@ class UIAMSHTMLTextInfo(UIATextInfo): _atEndOfStory=False def __init__(self,obj,position,_rangeObj=None): - super(UIAMSHTMLTextInfo,self).__init__(obj,position,_rangeObj) + super().__init__(obj,position,_rangeObj) if position==textInfos.POSITION_CARET: tempRange=self._rangeObj.clone() tempRange.ExpandToEnclosingUnit(UIAHandler.TextUnit_Character) @@ -47,7 +47,7 @@ def __init__(self,obj,position,_rangeObj=None): self._atEndOfStory=True def copy(self): - info=super(UIAMSHTMLTextInfo,self).copy() + info=super().copy() info._atEndOfStory=self._atEndOfStory return info @@ -55,7 +55,7 @@ def expand(self,unit): if unit in (textInfos.UNIT_CHARACTER,textInfos.UNIT_WORD) and self._atEndOfStory: return self._atEndOfStory=False - return super(UIAMSHTMLTextInfo,self).expand(unit) + return super().expand(unit) def move(self,unit,direction,endPoint=None): if direction==0: @@ -65,9 +65,9 @@ def move(self,unit,direction,endPoint=None): self._atEndOfStory=False if direction==0: return -1 - return super(UIAMSHTMLTextInfo,self).move(unit,direction,endPoint=endPoint) + return super().move(unit,direction,endPoint=endPoint) -class HTMLAttribCache(object): +class HTMLAttribCache: def __init__(self,HTMLNode): self.HTMLNode=HTMLNode @@ -282,7 +282,7 @@ def _expandToLine(self,textRange): oldSelRange.select() def __init__(self,obj,position,_rangeObj=None): - super(MSHTMLTextInfo,self).__init__(obj,position) + super().__init__(obj,position) if _rangeObj: self._rangeObj=_rangeObj.duplicate() return @@ -367,9 +367,9 @@ def setEndPoint(self,other,which): def _get_text(self): text=self._rangeObj.text if not text: - text=u"" + text="" if controlTypes.STATE_PROTECTED in self.obj.states: - text=u'*'*len(text) + text='*'*len(text) return text def move(self,unit,direction, endPoint=None): @@ -415,7 +415,7 @@ def _get__UIAControl(self): def makeTextInfo(self,position): if self._UIAControl: return self._UIAControl.makeTextInfo(position) - return super(MSHTML,self).makeTextInfo(position) + return super().makeTextInfo(position) HTMLNodeNameNavSkipList=['#comment','SCRIPT','HEAD','HTML','PARAM','STYLE'] HTMLNodeNameEmbedList=['OBJECT','EMBED','APPLET','FRAME','IFRAME'] @@ -441,7 +441,7 @@ def event_caret(self): if not newCaretBookmark or newCaretBookmark==getattr(self,'_oldCaretBookmark',None): return self._oldCaretBookmark=newCaretBookmark - return super(MSHTML,self).event_caret() + return super().event_caret() @classmethod def kwargsFromSuper(cls,kwargs,relation=None): @@ -517,7 +517,7 @@ def findOverlayClasses(self,clsList): clsList.append(MSHTML) if not self.HTMLNodeHasAncestorIAccessible: # The IAccessibleObject is for this node (not an ancestor), so IAccessible overlay classes are relevant. - super(MSHTML,self).findOverlayClasses(clsList) + super().findOverlayClasses(clsList) if self.IAccessibleRole == oleacc.ROLE_SYSTEM_DIALOG: ariaRoles = self.HTMLAttributes["role"].split(" ") if "dialog" in ariaRoles: @@ -531,7 +531,7 @@ def _get_treeInterceptorClass(self): if self.role in (controlTypes.ROLE_DOCUMENT, controlTypes.ROLE_APPLICATION, controlTypes.ROLE_DIALOG) and not self.isContentEditable: import virtualBuffers.MSHTML return virtualBuffers.MSHTML.MSHTML - return super(MSHTML,self).treeInterceptorClass + return super().treeInterceptorClass def _get_isCurrent(self): isCurrent = self.HTMLAttributes["aria-current"] @@ -568,7 +568,7 @@ def __init__(self,HTMLNode=None,IAccessibleObject=None,IAccessibleChildID=None,* if not IAccessibleObject: raise InvalidNVDAObject("Couldn't get IAccessible, probably dead object") - super(MSHTML,self).__init__(IAccessibleObject=IAccessibleObject,IAccessibleChildID=IAccessibleChildID,**kwargs) + super().__init__(IAccessibleObject=IAccessibleObject,IAccessibleChildID=IAccessibleChildID,**kwargs) self.HTMLNode=HTMLNode #object and embed nodes give back an incorrect IAccessible via queryService, so we must treet it as an ancestor IAccessible @@ -602,10 +602,10 @@ def _get_TextInfo(self): self._HTMLNodeSupportsTextRanges=False if self._HTMLNodeSupportsTextRanges: return MSHTMLTextInfo - return super(MSHTML,self).TextInfo + return super().TextInfo def isDuplicateIAccessibleEvent(self,obj): - if not super(MSHTML,self).isDuplicateIAccessibleEvent(obj): + if not super().isDuplicateIAccessibleEvent(obj): return False #MSHTML winEvents can't be trusted for uniqueness, so just do normal object comparison. return self==obj @@ -617,10 +617,10 @@ def _isEqual(self, other): return self.windowHandle == other.windowHandle and self.HTMLNodeUniqueNumber == other.HTMLNodeUniqueNumber except (COMError,NameError): pass - return super(MSHTML, self)._isEqual(other) + return super()._isEqual(other) def _get_presentationType(self): - presType=super(MSHTML,self).presentationType + presType=super().presentationType if presType==self.presType_content and self.HTMLAttributes['role']=="presentation": presType=self.presType_layout if presType==self.presType_content and self.role in (controlTypes.ROLE_TABLECELL,controlTypes.ROLE_TABLEROW,controlTypes.ROLE_TABLE,controlTypes.ROLE_TABLEBODY): @@ -637,7 +637,7 @@ def _get_shouldAllowIAccessibleFocusEvent(self): ariaRole=self.HTMLAttributes['aria-role'] if ariaRole=="gridcell": return True - return super(MSHTML,self).shouldAllowIAccessibleFocusEvent + return super().shouldAllowIAccessibleFocusEvent def _get_name(self): ariaLabelledBy=self.HTMLAttributes['aria-labelledBy'] @@ -673,7 +673,7 @@ def _get_name(self): if title and isinstance(title,str): return title return "" - return super(MSHTML,self).name + return super().name def _get_value(self): if self.HTMLNodeHasAncestorIAccessible: @@ -687,7 +687,7 @@ def _get_value(self): if IARole in (oleacc.ROLE_SYSTEM_PANE,oleacc.ROLE_SYSTEM_TEXT) or (IARole==oleacc.ROLE_SYSTEM_COMBOBOX and controlTypes.STATE_EDITABLE in self.states): return "" else: - return super(MSHTML,self).value + return super().value def _get_description(self): ariaDescribedBy=self.HTMLAttributes['aria-describedBy'] @@ -703,7 +703,7 @@ def _get_description(self): pass if self.HTMLNodeHasAncestorIAccessible: return "" - return super(MSHTML,self).description + return super().description def _get_basicText(self): if self.HTMLNode and not self.HTMLNodeName=="SELECT": @@ -712,10 +712,10 @@ def _get_basicText(self): except (COMError, AttributeError, NameError): pass try: - return self.HTMLNode.innerText or super(MSHTML,self).basicText + return self.HTMLNode.innerText or super().basicText except (COMError, AttributeError, NameError): pass - return super(MSHTML,self).basicText + return super().basicText def _get_role(self): if self.HTMLNode: @@ -731,10 +731,10 @@ def _get_role(self): if self.HTMLNodeHasAncestorIAccessible or nodeName in ("BODY","FRAMESET","FRAME","IFRAME","LABEL","NAV","SECTION","ARTICLE"): return nodeNamesToNVDARoles.get(nodeName,controlTypes.ROLE_SECTION) if self.IAccessibleChildID>0: - states=super(MSHTML,self).states + states=super().states if controlTypes.STATE_LINKED in states: return controlTypes.ROLE_LINK - role=super(MSHTML,self).role + role=super().role #IE uses a MSAA role of ROLE_SYSTEM_TEXT with no readonly state for unsupported or future tags with an explicit ARIA role. #If this is the case, force the role to staticText so this is not confused as a real edit field. if role==controlTypes.ROLE_EDITABLETEXT and ariaRole and ariaRole!="textbox": @@ -743,7 +743,7 @@ def _get_role(self): def _get_states(self): if not self.HTMLNodeHasAncestorIAccessible: - states=super(MSHTML,self).states + states=super().states else: states=set() ariaSort=self.HTMLAttributes['aria-sort'] @@ -817,7 +817,7 @@ def _get_parent(self): obj=MSHTML(HTMLNode=parentNode) if obj and obj.HTMLNodeName not in self.HTMLNodeNameNavSkipList: return obj - return super(MSHTML,self).parent + return super().parent def _get_previous(self): if self.HTMLNode: @@ -831,7 +831,7 @@ def _get_previous(self): if obj and obj.HTMLNodeName in self.HTMLNodeNameNavSkipList: obj=obj.previous return obj - return super(MSHTML,self).previous + return super().previous def _get_next(self): if self.HTMLNode: @@ -845,12 +845,12 @@ def _get_next(self): if obj and obj.HTMLNodeName in self.HTMLNodeNameNavSkipList: obj=obj.next return obj - return super(MSHTML,self).next + return super().next def _get_firstChild(self): if self.HTMLNode: if self.HTMLNodeName in ("FRAME","IFRAME"): - return super(MSHTML,self).firstChild + return super().firstChild try: childNode=self.HTMLNode.firstChild except COMError: @@ -863,12 +863,12 @@ def _get_firstChild(self): return obj if self.HTMLNodeHasAncestorIAccessible: return None - return super(MSHTML,self).firstChild + return super().firstChild def _get_lastChild(self): if self.HTMLNode: if self.HTMLNodeName in ("FRAME","IFRAME"): - return super(MSHTML,self).lastChild + return super().lastChild try: childNode=self.HTMLNode.lastChild except COMError: @@ -881,7 +881,7 @@ def _get_lastChild(self): return obj if self.HTMLNodeHasAncestorIAccessible: return None - return super(MSHTML,self).lastChild + return super().lastChild def _get_columnNumber(self): if not self.role==controlTypes.ROLE_TABLECELL or not self.HTMLNode: @@ -928,7 +928,7 @@ def doAction(self, index=None): return except NameError: pass - super(MSHTML,self).doAction(index=index) + super().doAction(index=index) def _get_isFocusable(self): nodeName = self.HTMLNodeName @@ -950,7 +950,7 @@ def setFocus(self): except (COMError, AttributeError, NameError): pass return - super(MSHTML,self).setFocus() + super().setFocus() def _get_table(self): if self.role not in (controlTypes.ROLE_TABLECELL,controlTypes.ROLE_TABLEROW) or not self.HTMLNode: @@ -983,7 +983,7 @@ def _get_HTMLNodeName(self): return self._HTMLNodeName def _get_devInfo(self): - info = super(MSHTML, self).devInfo + info = super().devInfo info.append("MSHTML node has ancestor IAccessible: %r" % self.HTMLNodeHasAncestorIAccessible) htmlNode = self.HTMLNode try: @@ -1019,7 +1019,7 @@ def event_valueChange(self): focus = api.getFocusObject() if controlTypes.STATE_FOCUSED not in self.states or focus.role != controlTypes.ROLE_COMBOBOX: # This combo box is not focused. - return super(V6ComboBox, self).event_valueChange() + return super().event_valueChange() # This combo box is focused. However, the value change is not fired on the real focus object. # Therefore, redirect this event to the real focus object. focus.event_valueChange() @@ -1032,19 +1032,19 @@ def _get_name(self): except (COMError,NameError): child=None if not child: - return super(Fieldset,self).name + return super().name try: nodeName=child.nodeName except (COMError,NameError): - return super(Fieldset,self).name + return super().name if nodeName: nodeName=nodeName.upper() if nodeName!="LEGEND": - return super(Fieldset,self).name + return super().name try: text=child.innerText except (COMError,NameError): - return super(Fieldset,self).name + return super().name return text class Body(MSHTML): @@ -1054,7 +1054,7 @@ def _get_parent(self): # This object isn't returned when requesting OBJID_CLIENT, nor is it returned as a child of its parent. # Therefore, eliminate it from the ancestry completely. # However it is possible that this body is a child document of a parent frame. In this case don't skip it. - parent = super(Body, self).parent + parent = super().parent if parent and not isinstance(parent,MSHTML): return parent.parent else: @@ -1065,7 +1065,7 @@ def _get_shouldAllowIAccessibleFocusEvent(self): # which might have the focused state. if controlTypes.STATE_FOCUSED in self.states: return True - parent = super(Body, self).parent + parent = super().parent if not parent: return False return parent.shouldAllowIAccessibleFocusEvent @@ -1081,7 +1081,7 @@ def _get_firstChild(self): except COMError: window = None if not window or window == self.windowHandle: - return super(Object, self).firstChild + return super().firstChild return Window(windowHandle=window) class PluginWindow(IAccessible): diff --git a/source/NVDAObjects/IAccessible/SysMonthCal32.py b/source/NVDAObjects/IAccessible/SysMonthCal32.py index b4106776cf0..e6080a3f1be 100755 --- a/source/NVDAObjects/IAccessible/SysMonthCal32.py +++ b/source/NVDAObjects/IAccessible/SysMonthCal32.py @@ -16,7 +16,7 @@ def _get_name(self): return "" def _get_value(self): - return super(SysMonthCal32,self).name + return super().name def script_valueChange(self,gesture): gesture.send() diff --git a/source/NVDAObjects/IAccessible/__init__.py b/source/NVDAObjects/IAccessible/__init__.py index d7ed8416876..47ec5990b73 100644 --- a/source/NVDAObjects/IAccessible/__init__.py +++ b/source/NVDAObjects/IAccessible/__init__.py @@ -40,7 +40,7 @@ def getNVDAObjectFromEvent(hwnd,objectID,childID): try: accHandle=IAccessibleHandler.accessibleObjectFromEvent(hwnd,objectID,childID) - except WindowsError: + except OSError: accHandle=None if not accHandle: return None @@ -160,20 +160,20 @@ def expand(self,unit): isMouseChunkUnit=True oldStart=self._startOffset oldEnd=self._endOffset - unit=super(IA2TextTextInfo,self).unit_mouseChunk + unit=super().unit_mouseChunk else: isMouseChunkUnit=False - super(IA2TextTextInfo,self).expand(unit) + super().expand(unit) if isMouseChunkUnit: text=self._getTextRange(self._startOffset,self._endOffset) if not text: return try: - self._startOffset=text.rindex(u'\ufffc',0,oldStart-self._startOffset) + self._startOffset=text.rindex('\ufffc',0,oldStart-self._startOffset) except ValueError: pass try: - self._endOffset=text.index(u'\ufffc',oldEnd-self._startOffset) + self._endOffset=text.index('\ufffc',oldEnd-self._startOffset) except ValueError: pass @@ -224,9 +224,9 @@ def _getLineCount(self): def _getTextRange(self,start,end): try: - return self.obj.IAccessibleTextObject.text(start,end) or u"" + return self.obj.IAccessibleTextObject.text(start,end) or "" except COMError: - return u"" + return "" def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True): try: @@ -260,11 +260,11 @@ def _getCharacterOffsets(self,offset): try: start,end,text = self.obj.IAccessibleTextObject.TextAtOffset(offset,IAccessibleHandler.IA2_TEXT_BOUNDARY_CHAR) except COMError: - return super(IA2TextTextInfo,self)._getCharacterOffsets(offset) + return super()._getCharacterOffsets(offset) if textUtils.isHighSurrogate(text) or textUtils.isLowSurrogate(text): # #8953: Some IA2 implementations, including Gecko and Chromium, # erroneously report one offset for surrogates. - return super(IA2TextTextInfo,self)._getCharacterOffsets(offset) + return super()._getCharacterOffsets(offset) return start, end def _getWordOffsets(self,offset): @@ -276,7 +276,7 @@ def _getWordOffsets(self,offset): try: start,end,text=self.obj.IAccessibleTextObject.TextAtOffset(offset,IAccessibleHandler.IA2_TEXT_BOUNDARY_WORD) except COMError: - return super(IA2TextTextInfo,self)._getWordOffsets(offset) + return super()._getWordOffsets(offset) if start>offset or offset>end: # HACK: Work around buggy implementations which return a range that does not include offset. return offset,offset+1 @@ -302,7 +302,7 @@ def _getSentenceOffsets(self,offset): raise NotImplementedError return start,end except COMError: - return super(IA2TextTextInfo,self)._getSentenceOffsets(offset) + return super()._getSentenceOffsets(offset) def _getParagraphOffsets(self,offset): try: @@ -316,7 +316,7 @@ def _getParagraphOffsets(self,offset): raise RuntimeError("did not expand to paragraph correctly") return start,end except (RuntimeError,COMError): - return super(IA2TextTextInfo,self)._getParagraphOffsets(offset) + return super()._getParagraphOffsets(offset) def _lineNumFromOffset(self,offset): return -1 @@ -345,7 +345,7 @@ def _iterTextWithEmbeddedObjects(self, withFields, formatConfig=None): while chunkStart < itemLen: # Find the next embedded object character. try: - chunkEnd = item.index(u"\uFFFC", chunkStart) + chunkEnd = item.index("\uFFFC", chunkStart) except ValueError: # This is the last chunk of text. yield item[chunkStart:] @@ -554,7 +554,7 @@ def findOverlayClasses(self,clsList): if not hasattr(IAccessible,"IID_ITextServices"): try: IAccessible.IID_ITextServices=ctypes.cast(ctypes.windll.msftedit.IID_ITextServices,ctypes.POINTER(GUID)).contents - except WindowsError: + except OSError: log.debugWarning("msftedit not available, couldn't retrieve IID_ITextServices") IAccessible.IID_ITextServices=None if IAccessible.IID_ITextServices: @@ -581,7 +581,7 @@ def findOverlayClasses(self,clsList): # This is the main (client) area of the window, so we can use other classes at the window level. # #3872: However, don't do this for IAccessible2 because # IA2 supersedes window level APIs and might conflict with them. - super(IAccessible,self).findOverlayClasses(clsList) + super().findOverlayClasses(clsList) #Generic client IAccessibles with no children should be classed as content and should use displayModel if clsList[0]==IAccessible and len(clsList)==3 and self.IAccessibleRole==oleacc.ROLE_SYSTEM_CLIENT and self.childCount==0: clsList.insert(0,ContentGenericClient) @@ -653,7 +653,7 @@ def __init__(self,windowHandle=None,IAccessibleObject=None,IAccessibleChildID=No self.event_windowHandle=event_windowHandle self.event_objectID=event_objectID self.event_childID=event_childID - super(IAccessible,self).__init__(windowHandle=windowHandle) + super().__init__(windowHandle=windowHandle) try: self.IAccessibleActionObject=IAccessibleObject.QueryInterface(IAccessibleHandler.IAccessibleAction) @@ -703,7 +703,7 @@ def _get_shouldAllowIAccessibleFocusEvent(self): def _get_TextInfo(self): if hasattr(self,'IAccessibleTextObject'): return IA2TextTextInfo - return super(IAccessible,self).TextInfo + return super().TextInfo def _isEqual(self,other): if self.IAccessibleChildID!=other.IAccessibleChildID: @@ -731,7 +731,7 @@ def _isEqual(self,other): return False if self.event_childID is not None and other.event_childID is not None and self.event_childID!=other.event_childID: return False - if not super(IAccessible,self)._isEqual(other): + if not super()._isEqual(other): return False selfIden=self.IAccessibleIdentity otherIden=other.IAccessibleIdentity @@ -841,7 +841,7 @@ def _get_IAccessibleRole(self): def _get_role(self): IARole=self.IAccessibleRole if IARole==oleacc.ROLE_SYSTEM_CLIENT: - superRole=super(IAccessible,self).role + superRole=super().role if superRole!=controlTypes.ROLE_WINDOW: return superRole if isinstance(IARole,str): @@ -862,7 +862,7 @@ def _get_IAccessibleStates(self): def _get_states(self): states=set() if self.event_objectID in (winUser.OBJID_CLIENT, winUser.OBJID_WINDOW) and self.event_childID == 0: - states.update(super(IAccessible, self).states) + states.update(super().states) try: IAccessibleStates=self.IAccessibleStates except COMError: @@ -873,7 +873,7 @@ def _get_states(self): # Not an IA2 object. return states IAccessible2States=self.IA2States - states=states|set(IAccessibleHandler.IAccessible2StatesToNVDAStates[x] for x in (y for y in (1<0: return None else: - return super(IAccessible,self)._get_groupName() + return super()._get_groupName() def event_selection(self): return self.event_stateChange() @@ -1509,10 +1509,10 @@ def _get_isPresentableFocusAncestor(self): # #4300: We check the object and child ids as well because there can be "clients" other than the root. if IARole == oleacc.ROLE_SYSTEM_CLIENT and self.event_objectID==winUser.OBJID_CLIENT and self.event_childID==0 and self.windowStyle & winUser.WS_SYSMENU: return True - return super(IAccessible, self).isPresentableFocusAncestor + return super().isPresentableFocusAncestor def _get_devInfo(self): - info = super(IAccessible, self).devInfo + info = super().devInfo iaObj = self.IAccessibleObject info.append("IAccessibleObject: %r" % iaObj) childID = self.IAccessibleChildID @@ -1653,7 +1653,7 @@ def _get_value(self): val=self.displayText truncate=len(val)>200 if truncate: - return u"%s\u2026"%val[:200] + return "%s\u2026"%val[:200] return val class GenericWindow(IAccessible): @@ -1682,7 +1682,7 @@ def _get_presentationType(self): def _get_parent(self): if self.parentUsesSuperOnWindowRootIAccessible: return super(IAccessible,self).parent - return super(WindowRoot,self).parent + return super().parent def _get_next(self): return super(IAccessible,self).next @@ -1695,7 +1695,7 @@ def _get_container(self): groupboxObj=IAccessibleHandler.findGroupboxObject(self) if groupboxObj: return groupboxObj - return super(WindowRoot,self).container + return super().container class ShellDocObjectView(IAccessible): @@ -1703,13 +1703,13 @@ def event_gainFocus(self): #Sometimes Shell DocObject View gets focus, when really the document inside it should #Adobe Reader 9 licence agreement if eventHandler.isPendingEvents("gainFocus") or self.childCount!=1: - return super(ShellDocObjectView,self).event_gainFocus() + return super().event_gainFocus() child=self.firstChild if not child or child.windowClassName!="Internet Explorer_Server" or child.role!=controlTypes.ROLE_PANE: - return super(ShellDocObjectView,self).event_gainFocus() + return super().event_gainFocus() child=child.firstChild if not child or child.windowClassName!="Internet Explorer_Server" or child.role!=controlTypes.ROLE_DOCUMENT: - return super(ShellDocObjectView,self).event_gainFocus() + return super().event_gainFocus() eventHandler.queueEvent("gainFocus",child) class JavaVMRoot(IAccessible): @@ -1755,17 +1755,17 @@ def _get_description(self): nextNext=self._getNextSkipWindows(next) if nextNext and nextNext.name!=next.name: return next.name - return super(Groupbox,self).description + return super().description def _get_isPresentableFocusAncestor(self): # Only fetch this the first time it is requested, # as it is a bit slow due to the description property # and the answer shouldn't change anyway. - self.isPresentableFocusAncestor = res = super(Groupbox, self).isPresentableFocusAncestor + self.isPresentableFocusAncestor = res = super().isPresentableFocusAncestor return res -CHAR_LTR_MARK = u'\u200E' -CHAR_RTL_MARK = u'\u200F' +CHAR_LTR_MARK = '\u200E' +CHAR_RTL_MARK = '\u200F' class TrayClockWClass(IAccessible): """ Based on NVDAObject but the role is changed to clock. @@ -1774,19 +1774,19 @@ class TrayClockWClass(IAccessible): def _get_role(self): # On Windows 10 Anniversary update and later the text 'clock' is included in the name so having clock in the control type is redundant. - if super(TrayClockWClass, self).value is None: + if super().value is None: return controlTypes.ROLE_BUTTON return controlTypes.ROLE_CLOCK def _get_name(self): # #4364 On some versions of Windows name contains redundant information that is available either in the role or the value, however on Windows 10 Anniversary Update and later the value is empty, so we cannot simply dismiss the name. - if super(TrayClockWClass, self).value is None: - clockName = super(TrayClockWClass, self).name + if super().value is None: + clockName = super().name return clockName.replace(CHAR_LTR_MARK,'').replace(CHAR_RTL_MARK,'') return None def _get_value(self): - clockValue = super(TrayClockWClass, self).value + clockValue = super().value if clockValue is not None: clockValue = clockValue.replace(CHAR_LTR_MARK,'').replace(CHAR_RTL_MARK,'') return clockValue @@ -1794,7 +1794,7 @@ def _get_value(self): class OutlineItem(IAccessible): def _get_value(self): - val=super(OutlineItem,self)._get_value() + val=super()._get_value() try: int(val) except (ValueError, TypeError): @@ -1813,13 +1813,13 @@ def reportFocus(self): def _get_role(self): if self.childCount==0: return controlTypes.ROLE_LINK - return super(SysLinkClient,self).role + return super().role class SysLink(IAccessible): def _get_name(self): #Workaround for #451 - explorer returns incorrect string length, thus it can contain garbage characters - name=super(SysLink,self).name + name=super().name if name: #Remove any data after the null character i=name.find('\0') @@ -1834,7 +1834,7 @@ def event_gainFocus(self): if self.childCount == 0: # However, in Windows 7, the task list gets focus even if alt+tab is pressed with no applications open. # In this case, we must report the focus so the user knows where the focus has landed. - return super(TaskList, self).event_gainFocus() + return super().event_gainFocus() class TaskListIcon(IAccessible): @@ -1846,25 +1846,25 @@ def _get_role(self): def reportFocus(self): if controlTypes.STATE_INVISIBLE in self.states: return - super(TaskListIcon,self).reportFocus() + super().reportFocus() class MenuItem(IAccessible): def _get_description(self): name=self.name - description=super(MenuItem,self)._get_description() + description=super()._get_description() if description!=name: return description else: return None def _get_name(self): - return super(MenuItem,self).name or self.displayText + return super().name or self.displayText def event_gainFocus(self): if eventHandler.isPendingEvents("gainFocus"): return - super(MenuItem, self).event_gainFocus() + super().event_gainFocus() class Taskbar(IAccessible): name = _("Taskbar") @@ -1872,7 +1872,7 @@ class Taskbar(IAccessible): class Button(IAccessible): def _get_name(self): - name=super(Button,self).name + name=super().name if not name or name.isspace(): name=self.displayText return name @@ -1899,7 +1899,7 @@ class StaticText(IAccessible): """Support for owner-drawn staticText controls where accName is empty.""" def _get_name(self): - name=super(StaticText,self).name + name=super().name if not name or name.isspace(): name=self.displayText return name diff --git a/source/NVDAObjects/IAccessible/adobeAcrobat.py b/source/NVDAObjects/IAccessible/adobeAcrobat.py index 15acf0eefaa..1984ec66ecd 100644 --- a/source/NVDAObjects/IAccessible/adobeAcrobat.py +++ b/source/NVDAObjects/IAccessible/adobeAcrobat.py @@ -87,7 +87,7 @@ def _get_role(self): except (AttributeError, LookupError, COMError): pass - role = super(AcrobatNode, self).role + role = super().role if role == controlTypes.ROLE_PANE: # Pane doesn't make sense for nodes in a document. role = controlTypes.ROLE_TEXTFRAME @@ -102,7 +102,7 @@ def scrollIntoView(self): def _isEqual(self, other): if self.windowHandle == other.windowHandle and self.accID and other.accID: return self.accID == other.accID - return super(AcrobatNode, self)._isEqual(other) + return super()._isEqual(other) def _getNodeMathMl(self, node): tag = node.GetTagName() @@ -123,8 +123,7 @@ def _getNodeMathMl(self, node): subNode = node.GetChild(childNum).QueryInterface(IPDDomElement) except COMError: continue - for sub in self._getNodeMathMl(subNode): - yield sub + yield from self._getNodeMathMl(subNode) yield "" % tag def _get_mathMl(self): @@ -169,7 +168,7 @@ def _get_shouldAllowIAccessibleFocusEvent(self): return self.IAccessibleObject.accFocus in (None, 0) except COMError: pass - return super(Document, self).shouldAllowIAccessibleFocusEvent + return super().shouldAllowIAccessibleFocusEvent class RootTextNode(RootNode): """The message text node that appears instead of the document when the document is not available. @@ -223,7 +222,7 @@ class BadFocusStates(AcrobatNode): """ def _get_states(self): - states = super(BadFocusStates, self).states + states = super().states states.difference_update({controlTypes.STATE_FOCUSABLE, controlTypes.STATE_FOCUSED}) return states diff --git a/source/NVDAObjects/IAccessible/adobeFlash.py b/source/NVDAObjects/IAccessible/adobeFlash.py index 64c0bf5ae5c..cfab95cd07d 100644 --- a/source/NVDAObjects/IAccessible/adobeFlash.py +++ b/source/NVDAObjects/IAccessible/adobeFlash.py @@ -66,7 +66,7 @@ def event_gainFocus(self): try: self.firstChild.firstChild.setFocus() except AttributeError: - super(PluginClientWithBrokenFocus, self).event_gainFocus() + super().event_gainFocus() def findExtraOverlayClasses(obj, clsList): """Determine the most appropriate class if this is a Flash object. diff --git a/source/NVDAObjects/IAccessible/chromium.py b/source/NVDAObjects/IAccessible/chromium.py index a2964aa0b6b..b4114cd6b46 100644 --- a/source/NVDAObjects/IAccessible/chromium.py +++ b/source/NVDAObjects/IAccessible/chromium.py @@ -38,7 +38,7 @@ def _get_treeInterceptorClass(self): states = self.states if controlTypes.STATE_EDITABLE not in states and controlTypes.STATE_BUSY not in states: return ChromeVBuf - return super(Document, self).treeInterceptorClass + return super().treeInterceptorClass class ComboboxListItem(IAccessible): """ diff --git a/source/NVDAObjects/IAccessible/hh.py b/source/NVDAObjects/IAccessible/hh.py index 75ed0aea7f6..302289407f7 100644 --- a/source/NVDAObjects/IAccessible/hh.py +++ b/source/NVDAObjects/IAccessible/hh.py @@ -42,4 +42,4 @@ def event_gainFocus(self): # We do this at the IAccessibleHandler level so that duplicate focus event checks will work properly. IAccessibleHandler.processFocusNVDAEvent(child) else: - super(KeywordList, self).event_gainFocus() + super().event_gainFocus() diff --git a/source/NVDAObjects/IAccessible/ia2TextMozilla.py b/source/NVDAObjects/IAccessible/ia2TextMozilla.py index c2d214f6461..f6249539897 100644 --- a/source/NVDAObjects/IAccessible/ia2TextMozilla.py +++ b/source/NVDAObjects/IAccessible/ia2TextMozilla.py @@ -31,7 +31,7 @@ def _iterTextWithEmbeddedObjects(self, withFields, formatConfig=None): def _getUnitOffsets(self,unit,offset): if unit in (textInfos.UNIT_WORD,textInfos.UNIT_LINE): unit=textInfos.UNIT_CHARACTER - return super(FakeEmbeddingTextInfo,self)._getUnitOffsets(unit,offset) + return super()._getUnitOffsets(unit,offset) def _getRawTextInfo(obj): if not hasattr(obj, "IAccessibleTextObject") and obj.role in (controlTypes.ROLE_TABLE, controlTypes.ROLE_TABLEROW): @@ -57,7 +57,7 @@ def _getEmbedded(obj, offset): class MozillaCompoundTextInfo(CompoundTextInfo): def __init__(self, obj, position): - super(MozillaCompoundTextInfo, self).__init__(obj, position) + super().__init__(obj, position) if isinstance(position, NVDAObject): try: self._start, self._startObj = self._findContentDescendant(position, textInfos.POSITION_FIRST) @@ -231,7 +231,7 @@ def _iterRecursiveText(self, ti, controlStack, formatConfig): for item in ti._iterTextWithEmbeddedObjects(controlStack is not None, formatConfig=formatConfig): if item is None: - yield u"" + yield "" elif isinstance(item, str): yield item elif isinstance(item, int): # Embedded object. @@ -246,7 +246,7 @@ def _iterRecursiveText(self, ti, controlStack, formatConfig): controlField["_startOfNode"] = True yield textInfos.FieldCommand("controlStart", controlField) if notText: - yield u" " + yield " " else: for subItem in self._iterRecursiveText(self._makeRawTextInfo(embedded, textInfos.POSITION_ALL), controlStack, formatConfig): yield subItem diff --git a/source/NVDAObjects/IAccessible/ia2Web.py b/source/NVDAObjects/IAccessible/ia2Web.py index 2ef69638e57..e1d7e3669a9 100644 --- a/source/NVDAObjects/IAccessible/ia2Web.py +++ b/source/NVDAObjects/IAccessible/ia2Web.py @@ -23,7 +23,7 @@ class Ia2Web(IAccessible): caretMovementDetectionUsesEvents = False def _get_positionInfo(self): - info=super(Ia2Web,self).positionInfo + info=super().positionInfo level=info.get('level',None) if not level: level=self.IA2Attributes.get('level',None) @@ -46,16 +46,16 @@ def _get_isPresentableFocusAncestor(self): # It is not useful to present IAccessible2 table rows in the focus ancestry as cells contain row and column information anyway. # Also presenting the rows would cause duplication of information return False - return super(Ia2Web,self).isPresentableFocusAncestor + return super().isPresentableFocusAncestor def _get_roleText(self): roleText=self.IA2Attributes.get('roledescription') if roleText: return roleText - return super(Ia2Web,self).roleText + return super().roleText def _get_states(self): - states=super(Ia2Web,self).states + states=super().states # Ensure that ARIA gridcells always get the focusable state, even if the Browser fails to provide it. # This is necessary for other code that calculates how selection of cells should be spoken. if 'gridcell' in self.IA2Attributes.get('xml-roles','').split(' '): diff --git a/source/NVDAObjects/IAccessible/mozilla.py b/source/NVDAObjects/IAccessible/mozilla.py index 55f899f75db..1560c1bd566 100755 --- a/source/NVDAObjects/IAccessible/mozilla.py +++ b/source/NVDAObjects/IAccessible/mozilla.py @@ -1,4 +1,3 @@ -# -*- coding: UTF-8 -*- #NVDAObjects/IAccessible/mozilla.py #A part of NonVisual Desktop Access (NVDA) #This file is covered by the GNU General Public License. @@ -40,7 +39,7 @@ def _getPhysicalFocus(self): def setFocus(self): oldFocus=self._getPhysicalFocus() - super(Mozilla,self).setFocus() + super().setFocus() # Although all versions of Firefox block inSetFocus or in accFocus until the physical focus has moved, # Firefox 57 and above return before they fire a focus winEvent communicating the focus change to ATs. # Therefore, If the call to setFocus did change the physical focus, @@ -65,10 +64,10 @@ def _get_parent(self): newObj=IAccessible(windowHandle=windowHandle,IAccessibleObject=res[0],IAccessibleChildID=res[1]) if newObj: return newObj - return super(Mozilla,self).parent + return super().parent def _get_states(self): - states = super(Mozilla, self).states + states = super().states if self.IAccessibleStates & oleacc.STATE_SYSTEM_MARQUEED: states.add(controlTypes.STATE_CHECKABLE) if self.IA2Attributes.get("hidden") == "true": @@ -76,7 +75,7 @@ def _get_states(self): return states def _get_presentationType(self): - presType=super(Mozilla,self).presentationType + presType=super().presentationType if presType==self.presType_content: if self.role==controlTypes.ROLE_TABLE and self.IA2Attributes.get('layout-guess')=='true': presType=self.presType_layout @@ -118,14 +117,14 @@ class Document(ia2Web.Document): def _get_treeInterceptorClass(self): ver=getGeckoVersion(self) if (not ver or ver.full.startswith('1.9')) and self.windowClassName!="MozillaContentWindowClass": - return super(Document,self).treeInterceptorClass + return super().treeInterceptorClass if controlTypes.STATE_EDITABLE not in self.states: import virtualBuffers.gecko_ia2 if ver and ver.major < 14: return virtualBuffers.gecko_ia2.Gecko_ia2Pre14 else: return virtualBuffers.gecko_ia2.Gecko_ia2 - return super(Document,self).treeInterceptorClass + return super().treeInterceptorClass class EmbeddedObject(Mozilla): @@ -135,7 +134,7 @@ def _get_shouldAllowIAccessibleFocusEvent(self): # This window doesn't have the focus, which means the embedded object's window probably already has the focus. # We don't want to override the focus event fired by the embedded object. return False - return super(EmbeddedObject, self).shouldAllowIAccessibleFocusEvent + return super().shouldAllowIAccessibleFocusEvent GeckoVersion = namedtuple("GeckoVersion", ("full", "major")) def getGeckoVersion(obj): @@ -159,7 +158,7 @@ class GeckoPluginWindowRoot(WindowRoot): parentUsesSuperOnWindowRootIAccessible = False def _get_parent(self): - parent=super(GeckoPluginWindowRoot,self).parent + parent=super().parent if parent.IAccessibleRole==oleacc.ROLE_SYSTEM_CLIENT: # Skip the window wrapping the plugin window, # which doesn't expose a Gecko accessible in Gecko >= 11. diff --git a/source/NVDAObjects/IAccessible/msOffice.py b/source/NVDAObjects/IAccessible/msOffice.py index 42423185c03..159b3fcf404 100755 --- a/source/NVDAObjects/IAccessible/msOffice.py +++ b/source/NVDAObjects/IAccessible/msOffice.py @@ -23,10 +23,10 @@ def _get_shouldAllowIAccessibleFocusEvent(self): # E.g. File recovery pane, clipboard manager pane if winUser.getGUIThreadInfo(0).hwndFocus!=self.windowHandle: return False - return super(SDM,self).shouldAllowIAccessibleFocusEvent + return super().shouldAllowIAccessibleFocusEvent def _get_name(self): - name=super(SDM,self).name + name=super().name if not name and self.role==controlTypes.ROLE_LISTITEM: name=self.displayText return name @@ -34,29 +34,29 @@ def _get_name(self): def _get_positionInfo(self): if self.role!=controlTypes.ROLE_LISTITEM: return {} - return super(SDM,self).positionInfo + return super().positionInfo def _get_parent(self): if self.IAccessibleChildID == 0 and self.role not in (controlTypes.ROLE_DIALOG, controlTypes.ROLE_PROPERTYPAGE, controlTypes.ROLE_WINDOW): # SDM child IAccessible objects have a broken accParent. # The parent should be the dialog. return getNVDAObjectFromEvent(self.windowHandle, winUser.OBJID_CLIENT, 0) - return super(SDM, self).parent + return super().parent def _get_presentationType(self): - t=super(SDM,self).presentationType + t=super().presentationType if t==self.presType_content and self.SDMChild: t=self.presType_layout return t def _get_firstChild(self): - child=super(SDM,self).firstChild + child=super().firstChild if not child: child=self.SDMChild return child def _get_lastChild(self): - child=super(SDM,self).lastChild + child=super().lastChild if not child: child=self.SDMChild return child @@ -86,13 +86,13 @@ def _get_isPresentableFocusAncestor(self): # Therefore suppress reporting of these toolbars in focus ancestry if they only have one child. if self.childCount==1: return False - return super(MsoCommandBarToolBar,self).isPresentableFocusAncestor + return super().isPresentableFocusAncestor def _get_name(self): - name=super(MsoCommandBarToolBar,self).name + name=super().name # #3407: overly verbose and programmatic toolbar label if name and name.startswith('MSO Generic Control Container'): - name=u"" + name="" return name description=None @@ -121,7 +121,7 @@ def _get_firstChild(self): description = None def _get_name(self): - name = super(BrokenMsoCommandBar, self).name + name = super().name if name == "MSO Generic Control Container": return None return name @@ -131,7 +131,7 @@ class CommandBarListItem(IAccessible): COMPILED_RE = re.compile(r'RGB\(\d+, \d+, \d+\)',re.I) def _get_rgbNameAndMatch(self): - name = super(CommandBarListItem,self).name + name = super().name if self.COMPILED_RE.match(name): matchRGB = True else: @@ -154,7 +154,7 @@ def _get_description(self): # Translators: a color, broken down into its RGB red, green, blue parts. return _("RGB red {rgb.red}, green {rgb.green}, blue {rgb.blue}").format(rgb=colors.RGB.fromString(name)) else: - return super(CommandBarListItem,self).description + return super().description class SDMSymbols(SDM): diff --git a/source/NVDAObjects/IAccessible/mscandui.py b/source/NVDAObjects/IAccessible/mscandui.py index 35627598dd6..433a2cc35c2 100755 --- a/source/NVDAObjects/IAccessible/mscandui.py +++ b/source/NVDAObjects/IAccessible/mscandui.py @@ -31,7 +31,7 @@ class BaseCandidateItem(CandidateItemBehavior,IAccessible): keyboardShortcut="" def _get_candidateNumber(self): - number=super(BaseCandidateItem,self).keyboardShortcut + number=super().keyboardShortcut try: number=int(number) except (ValueError,TypeError): @@ -39,7 +39,7 @@ def _get_candidateNumber(self): return number def _get_parent(self): - parent=super(BaseCandidateItem,self).parent + parent=super().parent # Translators: A label for a 'candidate' list which contains symbols the user can choose from when typing east-asian characters into a document. parent.name=_("Candidate") parent.description=None @@ -49,21 +49,21 @@ def _get_name(self): try: number=int(self.candidateNumber) except (TypeError,ValueError): - return super(BaseCandidateItem,self).name - candidate=super(BaseCandidateItem,self).name + return super().name + candidate=super().name return self.getFormattedCandidateName(number,candidate) def _get_description(self): - candidate=super(BaseCandidateItem,self).name + candidate=super().name return self.getFormattedCandidateDescription(candidate) def _get_basicText(self): - return super(BaseCandidateItem,self).name + return super().name class MSCandUI_candidateListItem(BaseCandidateItem): def _get_states(self): - states=super(MSCandUI_candidateListItem,self).states + states=super().states states.add(controlTypes.STATE_SELECTABLE) return states @@ -74,12 +74,12 @@ def event_stateChange(self): class MSCandUI21_candidateMenuItem(BaseCandidateItem): def _get_previous(self): - item=super(MSCandUI21_candidateMenuItem,self).previous + item=super().previous if not item or controlTypes.STATE_INVISIBLE in item.states: return return MSCandUI21_candidateMenuItem(IAccessibleObject=item.IAccessibleObject,IAccessibleChildID=item.IAccessibleChildID) def _get_next(self): - item=super(MSCandUI21_candidateMenuItem,self).next + item=super().next if not item or controlTypes.STATE_INVISIBLE in item.states: return return MSCandUI21_candidateMenuItem(IAccessibleObject=item.IAccessibleObject,IAccessibleChildID=item.IAccessibleChildID) @@ -204,7 +204,7 @@ class MSCandUIWindow(IAccessible): role=controlTypes.ROLE_LIST def _get_states(self): - states=super(MSCandUIWindow,self).states + states=super().states states.discard(controlTypes.STATE_UNAVAILABLE) return states @@ -229,13 +229,13 @@ def _get_candidateCharacters(self): def refreshCandidateList(self): textList=[] - candidateItems = super(ModernCandidateUICandidateItem,self).parent.children + candidateItems = super().parent.children for child in candidateItems: if not isinstance(child,ModernCandidateUICandidateItem) or controlTypes.STATE_SELECTABLE not in child.states: continue textList.append(child.candidateCharacters) if not len(textList)<=1: - self._visibleCandidateItemsText=(u", ".join(textList))+u", " + self._visibleCandidateItemsText=(", ".join(textList))+", " try: self._candidateNumber = textList.index(self.candidateCharacters)+1 except ValueError: diff --git a/source/NVDAObjects/IAccessible/qt.py b/source/NVDAObjects/IAccessible/qt.py index 78cd4c15658..11170068374 100644 --- a/source/NVDAObjects/IAccessible/qt.py +++ b/source/NVDAObjects/IAccessible/qt.py @@ -64,7 +64,7 @@ def _get_activeChild(self): def _get_shouldAllowIAccessibleFocusEvent(self): # QT doesn't fire focus on the active child as it should, so we will bounce the focus to it. # However, as the container does not have the focused state in QT5, we must still ensure we can get the event if we are going to bounce it - res=super(Container,self).shouldAllowIAccessibleFocusEvent + res=super().shouldAllowIAccessibleFocusEvent if not res: res=bool(self.activeChild) return res @@ -127,7 +127,7 @@ class Application(IAccessible): description = None def _get_states(self): - states = super(Application, self)._get_states() + states = super()._get_states() # The application should not have the focused state. # Otherwise, checks for the focused state will always hit the application and assume the focus is valid. states.discard(controlTypes.STATE_FOCUSED) diff --git a/source/NVDAObjects/IAccessible/sysListView32.py b/source/NVDAObjects/IAccessible/sysListView32.py index d8eda24502c..c430e475426 100644 --- a/source/NVDAObjects/IAccessible/sysListView32.py +++ b/source/NVDAObjects/IAccessible/sysListView32.py @@ -1,4 +1,3 @@ -# -*- coding: UTF-8 -*- #NVDAObjects/IAccessible/sysListView32.py #A part of NonVisual Desktop Access (NVDA) #Copyright (C) 2006-2017 NV Access Limited, Peter Vágner @@ -274,8 +273,8 @@ def script_collapseOrExpand(self,gesture): gesture.send() eventHandler.queueEvent("stateChange",self) -CHAR_LTR_MARK = u'\u200E' -CHAR_RTL_MARK = u'\u200F' +CHAR_LTR_MARK = '\u200E' +CHAR_RTL_MARK = '\u200F' class ListItemWithoutColumnSupport(IAccessible): diff --git a/source/NVDAObjects/IAccessible/sysTreeView32.py b/source/NVDAObjects/IAccessible/sysTreeView32.py index 90b60809090..9a58d8cc73f 100755 --- a/source/NVDAObjects/IAccessible/sysTreeView32.py +++ b/source/NVDAObjects/IAccessible/sysTreeView32.py @@ -55,7 +55,7 @@ class TreeView(IAccessible): def _get_firstChild(self): try: - return super(TreeView, self).firstChild + return super().firstChild except: # Broken commctrl 5 tree view. return BrokenCommctrl5Item.getFirstItem(self) @@ -77,7 +77,7 @@ def _get_treeview_level(self): return int(self.IAccessibleObject.accValue(self.IAccessibleChildID)) def _get_states(self): - states=super(TreeViewItem,self)._get_states() + states=super()._get_states() hItem=self.treeview_hItem itemStates=watchdog.cancellableSendMessage(self.windowHandle,TVM_GETITEMSTATE,hItem,TVIS_STATEIMAGEMASK) ch=(itemStates>>12)&3 @@ -94,13 +94,13 @@ def _get_value(self): def _get_parent(self): if self.IAccessibleChildID==0: - return super(TreeViewItem,self)._get_parent() + return super()._get_parent() hItem=self.treeview_hItem if not hItem: - return super(TreeViewItem,self)._get_parent() + return super()._get_parent() parentItem=watchdog.cancellableSendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_PARENT,hItem) if parentItem<=0: - return super(TreeViewItem,self)._get_parent() + return super()._get_parent() newID=watchdog.cancellableSendMessage(self.windowHandle,TVM_MAPHTREEITEMTOACCID,parentItem,0) if not newID: # Tree views from comctl < 6.0 use the hItem as the child ID. @@ -109,13 +109,13 @@ def _get_parent(self): def _get_firstChild(self): if self.IAccessibleChildID==0: - return super(TreeViewItem,self)._get_firstChild() + return super()._get_firstChild() hItem=self.treeview_hItem if not hItem: - return super(TreeViewItem,self)._get_firstChild() + return super()._get_firstChild() childItem=watchdog.cancellableSendMessage(self.windowHandle,TVM_GETNEXTITEM,TVGN_CHILD,hItem) if childItem<=0: - return super(TreeViewItem,self)._get_firstChild() + return super()._get_firstChild() newID=watchdog.cancellableSendMessage(self.windowHandle,TVM_MAPHTREEITEMTOACCID,childItem,0) if not newID: # Tree views from comctl < 6.0 use the hItem as the child ID. @@ -124,7 +124,7 @@ def _get_firstChild(self): def _get_next(self): if self.IAccessibleChildID==0: - return super(TreeViewItem,self)._get_next() + return super()._get_next() hItem=self.treeview_hItem if not hItem: return None @@ -139,7 +139,7 @@ def _get_next(self): def _get_previous(self): if self.IAccessibleChildID==0: - return super(TreeViewItem,self)._get_previous() + return super()._get_previous() hItem=self.treeview_hItem if not hItem: return None @@ -175,7 +175,7 @@ def _get_childCount(self): def _get_positionInfo(self): if self.IAccessibleChildID==0: - return super(TreeViewItem,self)._get_positionInfo() + return super()._get_positionInfo() info={} info['level']=self.treeview_level hItem=self.treeview_hItem @@ -197,7 +197,7 @@ def _get_positionInfo(self): def event_stateChange(self): announceContains = self is api.getFocusObject() and controlTypes.STATE_EXPANDED in self.states and controlTypes.STATE_EXPANDED not in getattr(self,'_speakObjectPropertiesCache',{}).get('states',frozenset()) - super(TreeViewItem,self).event_stateChange() + super().event_stateChange() if announceContains: speech.speakMessage(_("%s items")%self.childCount) @@ -213,12 +213,12 @@ def __init__(self, _uiaObj=None, **kwargs): if not _uiaObj: raise ValueError("Cannot instantiate directly without supplying _uiaObj") self._uiaObj = _uiaObj - super(BrokenCommctrl5Item, self).__init__(**kwargs) + super().__init__(**kwargs) def initOverlayClass(self): self._uiaObj = None if UIAHandler.handler: - parent=super(BrokenCommctrl5Item, self).parent + parent=super().parent if parent and parent.hasFocus: try: kwargs = {} @@ -260,7 +260,7 @@ def _get_parent(self): # If the parent is the tree view itself (root window object), just use super's parent. IAccessible isn't broken on the container itself. if not uiaParent.UIAElement.cachedNativeWindowHandle: return self._makeRelatedObj(uiaParent) - return super(BrokenCommctrl5Item, self).parent + return super().parent def _get_next(self): return self._makeRelatedObj(self._uiaObj.next) if self._uiaObj else None diff --git a/source/NVDAObjects/IAccessible/winword.py b/source/NVDAObjects/IAccessible/winword.py index 612237ecebb..43a0113fceb 100644 --- a/source/NVDAObjects/IAccessible/winword.py +++ b/source/NVDAObjects/IAccessible/winword.py @@ -50,13 +50,13 @@ def event_caret(self): if lastSelectionPos: if curSelectionPos._rangeObj.isEqual(lastSelectionPos._rangeObj): return - super(WordDocument,self).event_caret() + super().event_caret() def _get_role(self): return controlTypes.ROLE_EDITABLETEXT def _get_states(self): - states=super(WordDocument,self).states + states=super().states states.add(controlTypes.STATE_MULTILINE) return states @@ -416,12 +416,12 @@ def _get_errorText(self): inBold=field.field.get('bold',False) if not inBold and len(textList)>0: break - return u"".join(textList) + return "".join(textList) def _get_name(self): if self.WinwordVersion<13: - return super(SpellCheckErrorField,self).description - return super(SpellCheckErrorField,self).name + return super().description + return super().name description=None diff --git a/source/NVDAObjects/JAB/__init__.py b/source/NVDAObjects/JAB/__init__.py index 37d8daaa62c..777e2d1610b 100644 --- a/source/NVDAObjects/JAB/__init__.py +++ b/source/NVDAObjects/JAB/__init__.py @@ -174,7 +174,7 @@ def getEmbeddedObject(self, offset=0): # We need to count the embedded objects to determine which child to use. # This could possibly be optimised by caching. text = self._getTextRange(0, offset + 1) - childIndex = text.count(u"\uFFFC") - 1 + childIndex = text.count("\uFFFC") - 1 jabContext=self.obj.jabContext.getAccessibleChildFromContext(childIndex) if jabContext: return JAB(jabContext=jabContext) @@ -222,7 +222,7 @@ def __init__(self,relation=None,windowHandle=None,jabContext=None): windowHandle=jabContext.hwnd self.windowHandle=windowHandle self.jabContext=jabContext - super(JAB,self).__init__(windowHandle=windowHandle) + super().__init__(windowHandle=windowHandle) try: self._JABAccContextInfo except RuntimeError: @@ -234,7 +234,7 @@ def _get__JABAccContextInfo(self): def _get_TextInfo(self): if self._JABAccContextInfo.accessibleText and self.role not in [controlTypes.ROLE_BUTTON,controlTypes.ROLE_MENUITEM,controlTypes.ROLE_MENU,controlTypes.ROLE_LISTITEM]: return JABTextInfo - return super(JAB,self).TextInfo + return super().TextInfo def _isEqual(self,other): try: @@ -318,7 +318,7 @@ def _get_hasFocus(self): return False def _get_positionInfo(self): - info=super(JAB,self).positionInfo or {} + info=super().positionInfo or {} # If tree view item, try to retrieve the level via JAB if self.role==controlTypes.ROLE_TREEVIEWITEM: @@ -360,13 +360,13 @@ def _get_parent(self): if jabContext: self._parent=JAB(jabContext=jabContext) else: - self._parent=super(JAB,self).parent + self._parent=super().parent return self._parent def _get_next(self): parent=self.parent if not isinstance(parent,JAB): - return super(JAB,self).next + return super().next if self.indexInParent is None: return None newIndex=self.indexInParent+1 @@ -387,7 +387,7 @@ def _get_next(self): def _get_previous(self): parent=self.parent if not isinstance(parent,JAB): - return super(JAB,self).previous + return super().previous if self.indexInParent is None: return None newIndex=self.indexInParent-1 @@ -480,7 +480,7 @@ def reportFocus(self): parent=self.parent if self.role in [controlTypes.ROLE_LIST] and isinstance(parent,JAB) and parent.role==controlTypes.ROLE_COMBOBOX: return - super(JAB,self).reportFocus() + super().reportFocus() def _get__actions(self): actions = JABHandler.AccessibleActions() @@ -532,7 +532,7 @@ def _get_activeDescendant(self): def event_gainFocus(self): if eventHandler.isPendingEvents("gainFocus"): return - super(JAB,self).event_gainFocus() + super().event_gainFocus() if eventHandler.isPendingEvents("gainFocus"): return activeDescendant=self.activeDescendant @@ -542,7 +542,7 @@ def event_gainFocus(self): class ComboBox(JAB): def _get_states(self): - states=super(ComboBox,self).states + states=super().states if controlTypes.STATE_COLLAPSED not in states and controlTypes.STATE_EXPANDED not in states: if self.childCount==1 and self.firstChild and self.firstChild.role==controlTypes.ROLE_POPUPMENU: if controlTypes.STATE_INVISIBLE in self.firstChild.states: @@ -554,12 +554,12 @@ def _get_states(self): def _get_activeDescendant(self): if controlTypes.STATE_COLLAPSED in self.states: return None - return super(ComboBox,self).activeDescendant + return super().activeDescendant def _get_value(self): - value=super(ComboBox,self).value + value=super().value if not value and not self.activeDescendant: - descendant=super(ComboBox,self).activeDescendant + descendant=super().activeDescendant if descendant: value=descendant.name return value diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 8e095ed7b55..b5e2d3852e4 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -278,7 +278,7 @@ def _getFormatFieldAtRange(self,textRange,formatConfig,ignoreMixedValues=False): return textInfos.FieldCommand("formatChange",formatField) def __init__(self,obj,position,_rangeObj=None): - super(UIATextInfo,self).__init__(obj,position) + super().__init__(obj,position) if _rangeObj: try: self._rangeObj=_rangeObj.clone() @@ -475,8 +475,7 @@ def _getTextWithFields_text(self,textRange,formatConfig,UIAFormatUnits=None): field=self._getFormatFieldAtRange(tempRange,formatConfig,ignoreMixedValues=len(furtherUIAFormatUnits)==0) except UIAMixedAttributeError: log.debug("Mixed formatting. Trying higher resolution unit") - for subfield in self._getTextWithFields_text(tempRange,formatConfig,UIAFormatUnits=furtherUIAFormatUnits): - yield subfield + yield from self._getTextWithFields_text(tempRange,formatConfig,UIAFormatUnits=furtherUIAFormatUnits) log.debug("Done yielding higher resolution unit") continue log.debug("Yielding formatting and text") @@ -624,8 +623,7 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ # plain text before this child tempRange.MoveEndpointByRange(UIAHandler.TextPatternRangeEndpoint_End,childRange,UIAHandler.TextPatternRangeEndpoint_Start) log.debug("Plain text before child") - for field in self._getTextWithFields_text(tempRange,formatConfig): - yield field + yield from self._getTextWithFields_text(tempRange,formatConfig) elif childStartDelta<0: log.debug("textRange started part way through child. Cropping Start of child range to fit" ) childRange.MoveEndpointByRange(UIAHandler.TextPatternRangeEndpoint_Start,tempRange,UIAHandler.TextPatternRangeEndpoint_End) @@ -634,8 +632,7 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ log.debug("childRange is degenerate. Skipping") continue log.debug("Recursing into child %s"%index) - for field in self._getTextWithFieldsForUIARange(childElement,childRange,formatConfig,includeRoot=True,alwaysWalkAncestors=False,_rootElementClipped=(clippedStart,clippedEnd)): - yield field + yield from self._getTextWithFieldsForUIARange(childElement,childRange,formatConfig,includeRoot=True,alwaysWalkAncestors=False,_rootElementClipped=(clippedStart,clippedEnd)) log.debug("Done recursing into child %s"%index) tempRange.MoveEndpointByRange(UIAHandler.TextPatternRangeEndpoint_Start,childRange,UIAHandler.TextPatternRangeEndpoint_End) log.debug("children done") @@ -643,13 +640,11 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ if tempRange.CompareEndpoints(UIAHandler.TextPatternRangeEndpoint_Start,textRange,UIAHandler.TextPatternRangeEndpoint_End)<0: tempRange.MoveEndpointByRange(UIAHandler.TextPatternRangeEndpoint_End,textRange,UIAHandler.TextPatternRangeEndpoint_End) log.debug("Yielding final text") - for field in self._getTextWithFields_text(tempRange,formatConfig): - yield field + yield from self._getTextWithFields_text(tempRange,formatConfig) else: #no children log.debug("no children") log.debug("Yielding text") - for field in self._getTextWithFields_text(textRange,formatConfig): - yield field + yield from self._getTextWithFields_text(textRange,formatConfig) for field in parentFields: log.debug("Yielding controlEnd for parentElement") yield textInfos.FieldCommand("controlEnd",field) @@ -897,7 +892,7 @@ def findOverlayClasses(self,clsList): clsList.append(UIA) if self.UIAIsWindowElement: - super(UIA,self).findOverlayClasses(clsList) + super().findOverlayClasses(clsList) if self.UIATextPattern: #Since there is a UIA text pattern, there is no need to use the win32 edit support at all import NVDAObjects.window.edit @@ -952,7 +947,7 @@ def __init__(self,windowHandle=None,UIAElement=None,initialUIACachedPropertyIDs= windowHandle=UIAHandler.handler.getNearestWindowHandle(UIAElement) if not windowHandle: raise InvalidNVDAObject("no windowHandle") - super(UIA,self).__init__(windowHandle=windowHandle) + super().__init__(windowHandle=windowHandle) self.initialUIACachedPropertyIDs=initialUIACachedPropertyIDs if initialUIACachedPropertyIDs: @@ -1025,7 +1020,7 @@ def _get_UIALegacyIAccessiblePattern(self): _TextInfo=UIATextInfo def _get_TextInfo(self): if self.UIATextPattern: return self._TextInfo - textInfo=super(UIA,self).TextInfo + textInfo=super().TextInfo if textInfo is NVDAObjectTextInfo and self.UIAIsWindowElement and self.role==controlTypes.ROLE_WINDOW: import displayModel return displayModel.DisplayModelTextInfo @@ -1035,7 +1030,7 @@ def setFocus(self): self.UIAElement.setFocus() def _get_devInfo(self): - info=super(UIA,self).devInfo + info=super().devInfo info.append("UIAElement: %r"%self.UIAElement) try: ret=self.UIAElement.currentAutomationID @@ -1063,10 +1058,10 @@ def _get_devInfo(self): ret="Exception: %s"%e info.append("UIA className: %s"%ret) patternsAvailable = [] - patternAvailableConsts = dict( - (const, name) for name, const in UIAHandler.__dict__.items() + patternAvailableConsts = { + const: name for name, const in UIAHandler.__dict__.items() if name.startswith("UIA_Is") and name.endswith("PatternAvailablePropertyId") - ) + } self._prefetchUIACacheForPropertyIDs(list(patternAvailableConsts)) for const, name in patternAvailableConsts.items(): try: @@ -1095,7 +1090,7 @@ def _get_role(self): if s!=UIAHandler.handler.reservedNotSupportedValue: role=controlTypes.ROLE_TOGGLEBUTTON elif role in (controlTypes.ROLE_UNKNOWN,controlTypes.ROLE_PANE,controlTypes.ROLE_WINDOW) and self.windowHandle: - superRole=super(UIA,self).role + superRole=super().role if superRole!=controlTypes.ROLE_WINDOW: role=superRole return role @@ -1204,7 +1199,7 @@ def _get_states(self): return states def _get_presentationType(self): - presentationType=super(UIA,self).presentationType + presentationType=super().presentationType # UIA NVDAObjects can only be considered content if UI Automation considers them both a control and content. if presentationType==self.presType_content and not (self.UIAElement.cachedIsContentElement and self.UIAElement.cachedIsControlElement): presentationType=self.presType_layout @@ -1214,7 +1209,7 @@ def correctAPIForRelation(self, obj, relation=None): if obj and self.windowHandle != obj.windowHandle and not obj.UIAElement.cachedNativeWindowHandle: # The target element is not the root element for the window, so don't change API class; i.e. always use UIA. return obj - return super(UIA, self).correctAPIForRelation(obj, relation) + return super().correctAPIForRelation(obj, relation) def _get_parent(self): try: @@ -1222,7 +1217,7 @@ def _get_parent(self): except COMError: parentElement=None if not parentElement: - return super(UIA,self).parent + return super().parent if not parentElement.CachedNativeWindowHandle and not self.UIAElement.CachedNativeWindowHandle: # Neither self or parent have a window handle themselves, so their nearest window handle will be the same. # Cache this on the parent if cached on self, to avoid fetching it later. @@ -1280,7 +1275,7 @@ def _get_children(self): cachedChildren=self.UIAElement.buildUpdatedCache(childrenCacheRequest).getCachedChildren() except COMError as e: log.debugWarning("Could not fetch cached children from UIA element: %s"%e) - return super(UIA,self).children + return super().children children=[] if not cachedChildren: # GetCachedChildren returns null if there are no children. @@ -1432,7 +1427,7 @@ def _get_hasIrrelevantLocation(self): return isOffScreen or not self.location or not any(self.location) def _get_positionInfo(self): - info=super(UIA,self).positionInfo or {} + info=super().positionInfo or {} itemIndex=0 try: itemIndex=self._getUIACacheablePropertyValue(UIAHandler.UIA_PositionInSetPropertyId) @@ -1478,7 +1473,7 @@ def event_UIA_elementSelected(self): def event_valueChange(self): if issubclass(self.TextInfo, UIATextInfo): return - return super(UIA, self).event_valueChange() + return super().event_valueChange() def event_UIA_systemAlert(self): """ @@ -1524,7 +1519,7 @@ def _get__level(self): return level def _get_positionInfo(self): - info=super(TreeviewItem,self).positionInfo or {} + info=super().positionInfo or {} info['level']=self._level return info @@ -1532,7 +1527,7 @@ class MenuItem(UIA): def _get_description(self): name=self.name - description=super(MenuItem,self)._get_description() + description=super()._get_description() if description!=name: return description else: @@ -1541,7 +1536,7 @@ def _get_description(self): class UIColumnHeader(UIA): def _get_description(self): - description=super(UIColumnHeader,self).description + description=super().description try: itemStatus=self._getUIACacheablePropertyValue(UIAHandler.UIA_ItemStatusPropertyId) except COMError: @@ -1588,12 +1583,12 @@ def event_valueChange(self): if self==focusParent: speech.speakObjectProperties(self,value=True,reason=controlTypes.REASON_CHANGE) else: - super(SensitiveSlider,self).event_valueChange() + super().event_valueChange() class ControlPanelLink(UIA): def _get_description(self): - desc=super(ControlPanelLink,self).description + desc=super().description try: i=desc.find('\n') except: @@ -1635,7 +1630,7 @@ def event_stateChange(self): # #6337: This is an item in a combo box without the Value pattern or does not raise value change event. # This item has been selected, so notify the combo box that its value has changed. focus.event_valueChange() - super(ListItem, self).event_stateChange() + super().event_stateChange() class Dialog(Dialog): role=controlTypes.ROLE_DIALOG @@ -1714,7 +1709,7 @@ def event_UIA_elementSelected(self): class NetUIDropdownAnchor(UIA): def _get_name(self): - name=super(NetUIDropdownAnchor,self).name + name=super().name # In MS Office 2010, these combo boxes had no name. # However, the name can be found as the direct previous sibling label element. if not name and self.previous and self.previous.role==controlTypes.ROLE_STATICTEXT: diff --git a/source/NVDAObjects/UIA/edge.py b/source/NVDAObjects/UIA/edge.py index 0f37ae3dddc..5094b807182 100644 --- a/source/NVDAObjects/UIA/edge.py +++ b/source/NVDAObjects/UIA/edge.py @@ -107,14 +107,14 @@ def _moveToEdgeOfReplacedContent(self,back=False): def _collapsedMove(self,unit,direction,skipReplacedContent): """A simple collapsed move (i.e. both ends move together), but whether it classes replaced content as one character stop can be configured via the skipReplacedContent argument.""" if not skipReplacedContent: - return super(EdgeTextInfo,self).move(unit,direction) + return super().move(unit,direction) if direction==0: return chunk=1 if direction>0 else -1 finalRes=0 while finalRes!=direction: self._moveToEdgeOfReplacedContent(back=direction<0) - res=super(EdgeTextInfo,self).move(unit,chunk) + res=super().move(unit,chunk) if res==0: break finalRes+=res @@ -131,7 +131,7 @@ def move(self,unit,direction,endPoint=None,skipReplacedContent=True): return res def _getControlFieldForObject(self,obj,isEmbedded=False,startOfNode=False,endOfNode=False): - field=super(EdgeTextInfo,self)._getControlFieldForObject(obj,isEmbedded=isEmbedded,startOfNode=startOfNode,endOfNode=endOfNode) + field=super()._getControlFieldForObject(obj,isEmbedded=isEmbedded,startOfNode=startOfNode,endOfNode=endOfNode) field['embedded']=isEmbedded role=field.get('role') # Fields should be treated as block for certain roles. @@ -183,7 +183,7 @@ def getTextWithFields(self,formatConfig=None): # This would normally be a general rule, but MS Word currently needs fields for collapsed ranges, thus this code is not in the base. if self.isCollapsed: return [] - fields=super(EdgeTextInfo,self).getTextWithFields(formatConfig) + fields=super().getTextWithFields(formatConfig) seenText=False curStarts=[] # remove clickable state on descendants of controls with clickable state @@ -303,8 +303,7 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ log.debug("_getTextWithFieldsForUIARange (unbalanced)") if not recurseChildren: log.debug("recurseChildren is False. Falling back to super") - for field in super(EdgeTextInfo,self)._getTextWithFieldsForUIARange(rootElement,textRange,formatConfig,includeRoot=includeRoot,alwaysWalkAncestors=True,recurseChildren=False,_rootElementClipped=_rootElementClipped): - yield field + yield from super(EdgeTextInfo,self)._getTextWithFieldsForUIARange(rootElement,textRange,formatConfig,includeRoot=includeRoot,alwaysWalkAncestors=True,recurseChildren=False,_rootElementClipped=_rootElementClipped) return if log.isEnabledFor(log.DEBUG): log.debug("rootElement: %s"%rootElement.currentLocalizedControlType) @@ -333,8 +332,7 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ childElements=getChildrenWithCacheFromUIATextRange(startRange,self._controlFieldUIACacheRequest) if childElements.length==1 and UIAHandler.handler.clientObject.compareElements(rootElement,childElements.getElement(0)): log.debug("Using single embedded child as enclosingElement") - for field in super(EdgeTextInfo,self)._getTextWithFieldsForUIARange(rootElement,startRange,formatConfig,_rootElementClipped=_rootElementClipped,includeRoot=includeRoot,alwaysWalkAncestors=False,recurseChildren=False): - yield field + yield from super(EdgeTextInfo,self)._getTextWithFieldsForUIARange(rootElement,startRange,formatConfig,_rootElementClipped=_rootElementClipped,includeRoot=includeRoot,alwaysWalkAncestors=False,recurseChildren=False) return parents=[] parentElement=enclosingElement @@ -373,8 +371,7 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ log.debug("Yielding balanced fields for startRange") clippedStart=enclosingRange.CompareEndpoints(UIAHandler.TextPatternRangeEndpoint_Start,startRange,UIAHandler.TextPatternRangeEndpoint_Start)<0 clippedEnd=enclosingRange.CompareEndpoints(UIAHandler.TextPatternRangeEndpoint_End,startRange,UIAHandler.TextPatternRangeEndpoint_End)>0 - for field in super(EdgeTextInfo,self)._getTextWithFieldsForUIARange(enclosingElement,startRange,formatConfig,_rootElementClipped=(clippedStart,clippedEnd),includeRoot=includeRoot or hasAncestors,alwaysWalkAncestors=False,recurseChildren=True): - yield field + yield from super(EdgeTextInfo,self)._getTextWithFieldsForUIARange(enclosingElement,startRange,formatConfig,_rootElementClipped=(clippedStart,clippedEnd),includeRoot=includeRoot or hasAncestors,alwaysWalkAncestors=False,recurseChildren=True) tempRange=startRange.clone() log.debug("Walking parents to yield controlEnds and recurse unbalanced endRanges") for parentElement,field in parents: @@ -395,8 +392,7 @@ def _getTextWithFieldsForUIARange(self,rootElement,textRange,formatConfig,includ field['_endOfNode']=not clippedEnd if tempRange.CompareEndpoints(UIAHandler.TextPatternRangeEndpoint_End,tempRange,UIAHandler.TextPatternRangeEndpoint_Start)>0: log.debug("Recursing endRange") - for endField in self._getTextWithFieldsForUIARange(parentElement,tempRange,formatConfig,_rootElementClipped=(clippedStart,clippedEnd),includeRoot=False,alwaysWalkAncestors=True,recurseChildren=True): - yield endField + yield from self._getTextWithFieldsForUIARange(parentElement,tempRange,formatConfig,_rootElementClipped=(clippedStart,clippedEnd),includeRoot=False,alwaysWalkAncestors=True,recurseChildren=True) log.debug("Done recursing endRange") else: log.debug("No content after parent") @@ -430,7 +426,7 @@ def getNormalizedUIATextRangeFromElement(self,UIAElement): return textRange def _get_role(self): - role=super(EdgeNode,self).role + role=super().role if not isinstance(self,EdgeHTMLRoot) and role==controlTypes.ROLE_PANE and self.UIATextPattern: return controlTypes.ROLE_INTERNALFRAME ariaRole=self._getUIACacheablePropertyValue(UIAHandler.UIA_AriaRolePropertyId).lower() @@ -444,7 +440,7 @@ def _get_role(self): return role def _get_states(self): - states=super(EdgeNode,self).states + states=super().states if self.role in (controlTypes.ROLE_STATICTEXT,controlTypes.ROLE_GROUPING,controlTypes.ROLE_SECTION,controlTypes.ROLE_GRAPHIC) and self.UIAInvokePattern: states.add(controlTypes.STATE_CLICKABLE) return states @@ -456,7 +452,7 @@ def _get_description(self): return self._getUIACacheablePropertyValue(UIAHandler.UIA_FullDescriptionPropertyId) or "" except COMError: pass - return super(EdgeNode,self).description + return super().description def _get_ariaProperties(self): return splitUIAElementAttribs(self.UIAElement.currentAriaProperties) @@ -466,7 +462,7 @@ def _get_ariaProperties(self): # character and before the ';' character. # This could be one of: "false", "true", "page", "step", "location", "date", "time" # "false" is ignored by the regEx and will not produce a match - RE_ARIA_CURRENT_PROP_VALUE = re.compile("current=(?!false)(\w+);") + RE_ARIA_CURRENT_PROP_VALUE = re.compile(r"current=(?!false)(\w+);") def _get_isCurrent(self): ariaProperties=self._getUIACacheablePropertyValue(UIAHandler.UIA_AriaPropertiesPropertyId) @@ -520,7 +516,7 @@ class EdgeList(EdgeNode): # non-focusable lists are readonly lists (ensures correct NVDA presentation category) def _get_states(self): - states=super(EdgeList,self).states + states=super().states if controlTypes.STATE_FOCUSABLE not in states: states.add(controlTypes.STATE_READONLY) return states @@ -532,7 +528,7 @@ def event_gainFocus(self): if isinstance(firstChild,UIA): eventHandler.executeEvent("gainFocus",firstChild) return - return super(EdgeHTMLRootContainer,self).event_gainFocus() + return super().event_gainFocus() class EdgeHeadingQuickNavItem(UIATextRangeQuickNavItem): @@ -575,17 +571,17 @@ def _iterNodesByType(self,nodeType,direction="next",pos=None): if nodeType.startswith("heading"): return EdgeHeadingQuicknavIterator(nodeType,self,pos,direction=direction) else: - return super(EdgeHTMLTreeInterceptor,self)._iterNodesByType(nodeType,direction=direction,pos=pos) + return super()._iterNodesByType(nodeType,direction=direction,pos=pos) def shouldPassThrough(self,obj,reason=None): # Enter focus mode for selectable list items (