After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 395548 - Refactor calls to util.py as calls from delegates in default.py
Refactor calls to util.py as calls from delegates in default.py
Status: RESOLVED FIXED
Product: orca
Classification: Applications
Component: general
2.17.x
Other All
: Normal enhancement
: 2.20.0
Assigned To: Rich Burridge
Orca Maintainers
Depends on:
Blocks: 407941 461719
 
 
Reported: 2007-01-11 20:09 UTC by Willie Walker
Modified: 2007-07-30 09:26 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Patch for "def traceit(frame, event, arg):" (4.30 KB, patch)
2007-03-05 17:09 UTC, Rich Burridge
committed Details | Review
Patch for moving "def speakTextSelectionState(obj, startOffset, endOffset):" (11.71 KB, patch)
2007-03-05 21:27 UTC, Rich Burridge
committed Details | Review
Patch for moving "def isTextSelected(obj, startOffset, endOffset):" (3.16 KB, patch)
2007-03-05 21:36 UTC, Rich Burridge
committed Details | Review
Moving two more routines over. (13.99 KB, patch)
2007-03-05 22:38 UTC, Rich Burridge
committed Details | Review
Moving saveOldAppSettings() and restoreOldAppSettings(prefsDict) (4.43 KB, patch)
2007-03-06 00:56 UTC, Rich Burridge
committed Details | Review
Moving findActiveWindow() (3.87 KB, patch)
2007-03-06 01:11 UTC, Rich Burridge
committed Details | Review
Moving isInActiveApp(obj) (2.38 KB, patch)
2007-03-06 01:23 UTC, Rich Burridge
committed Details | Review
Moving four more routines over (15.09 KB, patch)
2007-03-06 15:59 UTC, Rich Burridge
committed Details | Review
Moving phoneticSpellCurrentItem(string) (3.52 KB, patch)
2007-03-06 16:10 UTC, Rich Burridge
committed Details | Review
Moving findUnrelatedLabels(root) (6.64 KB, patch)
2007-03-06 16:21 UTC, Rich Burridge
committed Details | Review
Moving findByRole(root, role, onlyShowing=True) (16.66 KB, patch)
2007-03-06 16:42 UTC, Rich Burridge
committed Details | Review
Moving getKnownApplications() (4.92 KB, patch)
2007-03-06 17:36 UTC, Rich Burridge
committed Details | Review
Moving getAcceleratorAndShortcut(obj) (6.54 KB, patch)
2007-03-06 17:47 UTC, Rich Burridge
committed Details | Review
Moving getNodeLevel(obj) (5.51 KB, patch)
2007-03-06 17:56 UTC, Rich Burridge
committed Details | Review
Moving three more routines over. (43.44 KB, patch)
2007-03-06 18:32 UTC, Rich Burridge
committed Details | Review
Moving three more routines over. (9.13 KB, patch)
2007-03-06 18:43 UTC, Rich Burridge
committed Details | Review
Moving three more routines over. (12.47 KB, patch)
2007-03-06 19:07 UTC, Rich Burridge
committed Details | Review
Moving three more routines over. (16.42 KB, patch)
2007-03-06 19:23 UTC, Rich Burridge
committed Details | Review
Moving five more routines over. (47.87 KB, patch)
2007-03-06 20:14 UTC, Rich Burridge
committed Details | Review
Moving two more routines over. (9.30 KB, patch)
2007-03-06 20:23 UTC, Rich Burridge
committed Details | Review
Moving three more routine over. (30.34 KB, patch)
2007-03-06 21:02 UTC, Rich Burridge
committed Details | Review
Patch to remove all occurances of "import util" and the util.py file. (17.31 KB, patch)
2007-03-06 21:43 UTC, Rich Burridge
committed Details | Review
Various fixups (12.18 KB, patch)
2007-03-07 21:05 UTC, Rich Burridge
committed Details | Review
debug.out from OOo 2.2 open dialog, files table (145.96 KB, text/plain)
2007-03-09 21:48 UTC, Joanmarie Diggs (IRC: joanie)
  Details
Patch to fixup the problems in StarOffice.py (1.04 KB, patch)
2007-03-09 22:11 UTC, Rich Burridge
committed Details | Review
debug.out from OOo 2.2 Calc (117.81 KB, text/plain)
2007-03-11 23:21 UTC, Joanmarie Diggs (IRC: joanie)
  Details
Patch to StarOffice.py script. (588 bytes, patch)
2007-03-12 00:06 UTC, Rich Burridge
committed Details | Review
Patch to fixup problems in self_voicing.py reported by hermann. (1.26 KB, patch)
2007-03-13 16:18 UTC, Rich Burridge
committed Details | Review
acroread debug.out (57.92 KB, text/plain)
2007-03-16 13:13 UTC, Joanmarie Diggs (IRC: joanie)
  Details
patch to solve the immediate problem (1.00 KB, patch)
2007-03-16 14:31 UTC, Joanmarie Diggs (IRC: joanie)
none Details | Review

Description Willie Walker 2007-01-11 20:09:42 UTC
util.py contains a number of methods that are used by default.py.  We sometimes run into occasions where we'd like to extend/override the behavior of these methods in subscripts.  

A possible way to support the extend/override desire is to provide "one line" delegate methods in default.py:Script that call their associated methods in util.py.  Alternatively, we may just consider sucking some util.py methods into the default.py:Script class, removing them from util.py altogether.
Comment 1 Rich Burridge 2007-03-02 20:49:30 UTC
Will and I just talked about this. The new plan (once the Orca code is
branched on Monday), is to move all the methods in util.py directly over
to default.py, fixup where they are being called and (eventually) remove
util.py.

I plan to do this one method at a time (to reduce the possibility of
change conflicts) and to apply numerous patches to this bug report, so 
you can easily see exactly what I've changed.

Routines are:

def isSameObject(obj1, obj2):

def appendString(text, newText, delimiter=" "):

def __hasLabelForRelation(label):

def __isLabeling(label, object):

def getUnicodeCurrencySymbols():

def getDisplayedLabel(object):

def __getDisplayedTextInComboBox(combo):

def getDisplayedText(obj):

def getRealActiveDescendant(obj):

def findFocusedObject(root):

def getClickCount(lastInputEvent, inputEvent):

def isDesiredFocusedItem(obj, rolesList):

def speakMisspeltWord(allTokens, badWord):

def textLines(obj):

def _addRepeatSegment(segment, line, respectPunctuation=True):

def adjustForRepeats(line):

def adjustForPronunciation(line):

def getLinkIndex(obj, characterIndex):

def isWordDelimiter(character):

def getFrame(obj):

def getTopLevel(obj):

def getTopLevelName(obj):

def getTextLineAtCaret(obj):

def getNodeLevel(obj):

def getAcceleratorAndShortcut(obj):

def getKnownApplications():

def getObjects(root, onlyShowing=True):

def findByRole(root, role, onlyShowing=True):

def findUnrelatedLabels(root):

def phoneticSpellCurrentItem(string):

def printAncestry(child):

def printHierarchy(root, ooi, indent="", onlyShowing=True, omitManaged=True):

def printApps():

def printActiveApp():

def isInActiveApp(obj):

def findActiveWindow():

def saveOldAppSettings():

def restoreOldAppSettings(prefsDict):

def drawOutline(x, y, width, height, erasePrevious=True):

def outlineAccessible(accessible, erasePrevious=True):

def isTextSelected(obj, startOffset, endOffset):

def speakTextSelectionState(obj, startOffset, endOffset):

def traceit(frame, event, arg):


More next week.
Comment 2 Rich Burridge 2007-03-05 17:09:52 UTC
Created attachment 83978 [details] [review]
Patch for  "def traceit(frame, event, arg):"

Moved:

          def traceit(frame, event, arg):

(in this case into debug.py).
Comment 3 Rich Burridge 2007-03-05 21:27:35 UTC
Created attachment 84012 [details] [review]
Patch for moving "def speakTextSelectionState(obj, startOffset, endOffset):"
Comment 4 Rich Burridge 2007-03-05 21:36:36 UTC
Created attachment 84014 [details] [review]
Patch for moving "def isTextSelected(obj, startOffset, endOffset):"
Comment 5 Rich Burridge 2007-03-05 22:38:23 UTC
Created attachment 84018 [details] [review]
Moving two more routines over.

  def drawOutline(x, y, width, height, erasePrevious=True):
  def outlineAccessible(accessible, erasePrevious=True):
Comment 6 Rich Burridge 2007-03-06 00:56:41 UTC
Created attachment 84025 [details] [review]
Moving saveOldAppSettings() and restoreOldAppSettings(prefsDict)
Comment 7 Rich Burridge 2007-03-06 01:11:36 UTC
Created attachment 84027 [details] [review]
Moving findActiveWindow()
Comment 8 Rich Burridge 2007-03-06 01:23:14 UTC
Created attachment 84030 [details] [review]
Moving isInActiveApp(obj)
Comment 9 Rich Burridge 2007-03-06 15:59:27 UTC
Created attachment 84079 [details] [review]
Moving four more routines over

  def printAncestry(child):
  def printHierarchy(root, ooi, indent="", onlyShowing=True, omitManaged=True):
  def printApps():
  def printActiveApp():
Comment 10 Rich Burridge 2007-03-06 16:10:54 UTC
Created attachment 84080 [details] [review]
Moving phoneticSpellCurrentItem(string)
Comment 11 Rich Burridge 2007-03-06 16:21:40 UTC
Created attachment 84081 [details] [review]
Moving findUnrelatedLabels(root)
Comment 12 Rich Burridge 2007-03-06 16:42:23 UTC
Created attachment 84083 [details] [review]
Moving findByRole(root, role, onlyShowing=True)
Comment 13 Rich Burridge 2007-03-06 17:36:39 UTC
Created attachment 84090 [details] [review]
Moving getKnownApplications()
Comment 14 Rich Burridge 2007-03-06 17:47:08 UTC
Created attachment 84095 [details] [review]
Moving getAcceleratorAndShortcut(obj)
Comment 15 Rich Burridge 2007-03-06 17:56:28 UTC
Created attachment 84097 [details] [review]
Moving getNodeLevel(obj)
Comment 16 Rich Burridge 2007-03-06 18:32:53 UTC
Created attachment 84106 [details] [review]
Moving three more routines over.

  def __getDisplayedTextInComboBox(combo):
  def getDisplayedText(obj):
  def getTextLineAtCaret(obj):
Comment 17 Rich Burridge 2007-03-06 18:43:33 UTC
Created attachment 84107 [details] [review]
Moving three more routines over.

  def getFrame(obj):
  def getTopLevel(obj):
  def getTopLevelName(obj):
Comment 18 Rich Burridge 2007-03-06 19:07:37 UTC
Created attachment 84111 [details] [review]
Moving three more routines over.

  def adjustForPronunciation(line):
  def getLinkIndex(obj, characterIndex):
  def isWordDelimiter(character):
Comment 19 Rich Burridge 2007-03-06 19:23:03 UTC
Created attachment 84112 [details] [review]
Moving three more routines over.

  def textLines(obj):
  def _addRepeatSegment(segment, line, respectPunctuation=True):
  def adjustForRepeats(line):
Comment 20 Rich Burridge 2007-03-06 20:14:17 UTC
Created attachment 84116 [details] [review]
Moving five more routines over.

  def __hasLabelForRelation(label):
  def __isLabeling(label, object):
  def getDisplayedLabel(object):
  def isDesiredFocusedItem(obj, rolesList):
  def speakMisspeltWord(allTokens, badWord):
Comment 21 Rich Burridge 2007-03-06 20:23:43 UTC
Created attachment 84117 [details] [review]
Moving two more routines over.

  def findFocusedObject(root):
  def getClickCount(lastInputEvent, inputEvent):
Comment 22 Rich Burridge 2007-03-06 21:02:20 UTC
Created attachment 84119 [details] [review]
Moving three more routine over.

  def isSameObject(obj1, obj2):
  def appendString(text, newText, delimiter=" "):
  def getUnicodeCurrencySymbols():
Comment 23 Rich Burridge 2007-03-06 21:43:08 UTC
Created attachment 84123 [details] [review]
Patch to remove all occurances of "import util" and the util.py file.

Plus a few cleanups.

I think the refactoring is now complete.

The slightly worrying part is that there are now a lot of
occurances of orca_state.activeScript.<whatever> in files
like orca.py, flat_review.py and where_am_I.py. This suggests
that we possibly need a bit more refactoring.

I've been testing this on Ubuntu Edgy. I'm getting a few
COMM_FAILURES, but it still seems to braille/speak okay.

I'm looking for others to checkout this version, take it for
a spin and provide feedback.

I'll put this bug report into the "[pending]" state, but I 
suspect there will still need to be a few final touchups. 
It was a large set of changes.
Comment 24 Rich Burridge 2007-03-07 20:19:05 UTC
Mike and Joanie gave me a heads-up on a few tracebacks from running
latest Orca. I'll work on a patch after lunch and check it in.
Comment 25 Rich Burridge 2007-03-07 21:05:59 UTC
Created attachment 84196 [details] [review]
Various fixups

All changes were adjustments from "self.<whatever>" to
"self._script.<whatever>" in various files because I
didn't initially notice that those were changes inside
subclasses of BrailleGenerator and SpeechGenerator 
rather than Script.

Mike, Joanie, could you give it another try please?
Comment 26 Joanmarie Diggs (IRC: joanie) 2007-03-07 21:18:48 UTC
Seems to solve the problem Rich.  Thanks!!!
Comment 27 Mike Pedersen 2007-03-07 21:43:18 UTC
Thanks Rich, this seems much better.  I'm still testing other apps now though to see if I can find anything else for you.  
Comment 28 Joanmarie Diggs (IRC: joanie) 2007-03-09 21:48:53 UTC
Created attachment 84325 [details]
debug.out from OOo 2.2 open dialog, files table

I may have found another issue.  Take a look at the attached beginning with line 1498.

  • File "/usr/lib/python2.5/site-packages/orca/scripts/StarOffice.py", line 176 in isSpreadSheetCell
    if self.isDesiredFocusedItem(obj, rolesList):
NameError: global name 'self' is not defined

Comment 29 Rich Burridge 2007-03-09 22:11:11 UTC
Created attachment 84329 [details] [review]
Patch to fixup the problems in StarOffice.py

Thanks Joanie. I've just committed the attached patch which should
fix that problem (and a similar one in the locateInputLine() routine).
Comment 30 Joanmarie Diggs (IRC: joanie) 2007-03-09 22:16:48 UTC
Yup, much better.  Thanks!! Just discovered something interesting as a result of this which may prove useful -- or not. :-)  Regardless, as soon as I track down the relevant bug, I'll share the info. :-)
Comment 31 Joanmarie Diggs (IRC: joanie) 2007-03-11 23:21:37 UTC
Created attachment 84405 [details]
debug.out from OOo 2.2 Calc

Rich, this is from navigating within a Calc document.  Thanks!!!
Comment 32 Rich Burridge 2007-03-12 00:06:36 UTC
Created attachment 84407 [details] [review]
Patch to StarOffice.py script.

Thanks Joanie. I've just had a nap so I'm a little more 
awake then I was on Friday. Hopefully this is the correct fix.
Comment 33 Joanmarie Diggs (IRC: joanie) 2007-03-12 00:22:53 UTC
> Hopefully this is the correct fix. 

Seems to be.  Thanks much!!
Comment 34 Rich Burridge 2007-03-13 16:18:26 UTC
Created attachment 84511 [details] [review]
Patch to fixup problems in self_voicing.py reported by hermann.
Comment 35 Joanmarie Diggs (IRC: joanie) 2007-03-16 13:13:45 UTC
Created attachment 84712 [details]
acroread debug.out

[...]
  • File "/usr/lib/python2.5/site-packages/orca/scripts/acroread.py", line 158 in getTableAndDimensions
    if self.isDesiredFocusedItem(obj, rolesList):  NameError: global name 'self' is not defined

Comment 36 Willie Walker 2007-03-16 13:29:09 UTC
Looks like there are several global methods that need to be moved into the acroread.Script class.
Comment 37 Joanmarie Diggs (IRC: joanie) 2007-03-16 13:35:43 UTC
Was wondering about that myself, actually....
Comment 38 Joanmarie Diggs (IRC: joanie) 2007-03-16 14:31:53 UTC
Created attachment 84717 [details] [review]
patch to solve the immediate problem

This patch makes the errors go away so that Orca provides access to PDFs in acroread.  Will, what about checking this in and then having a conversation about what needs to be moved where?
Comment 39 Rich Burridge 2007-03-16 15:13:52 UTC
Yeah, that patch should work. Joanie, could you commit it please
(I need to go into the office for a meeting) and announce it on the
orca-list. Thanks!

Comment 40 Joanmarie Diggs (IRC: joanie) 2007-03-16 15:19:08 UTC
Hi Rich.  Will and I discussed this via IM and he called my patch "ugly". <grins at Will>

As you (and he) pointed out, we need to move the global methods into the acroread.Script class.  I'm nearly finished with the moving.  After I do some testing, I'm going to open a new bug for the acroread refactoring, post a patch, and -- assuming *it's* not ugly <grins> --  check that in instead.  Then I'll announce it on the list. 
Comment 41 Joanmarie Diggs (IRC: joanie) 2007-03-16 15:52:06 UTC
Just opened bug #419006 for the acroread.py refactoring and posted a patch.
Comment 42 Rich Burridge 2007-03-27 15:40:37 UTC
Closing as FIXED. If any problems are found, please reopen.