[nvda-addons] Re: commit/StationPlaylist: norrumar: Possible improvements cleaning code.

  • From: Noelia <nrm1977@xxxxxxxxx>
  • To: nvda-addons@xxxxxxxxxxxxx
  • Date: Fri, 12 Dec 2014 20:16:06 +0100

Thanks. You can merge it and fix indentation.
possibleImprovements is a good idea, not mine :)
Mesar created a similar branch for appendText add-on revision.
BTW, it this add-on is useful, feel free to post it in our website.
Cheers.


El 12/12/2014 19:55, Joseph Lee escribió:
Hi,
Gotcha - I think it is better for me to commit your ideas in master
directly, as indentation is important in name change event - your commit
broke library scan announcement feature but it's a trivial fix (don't worry,
I'll take care of it). Thanks for your code cleanup suggestion - please keep
them coming in the possible improvements branch.
Cheers,
Joseph

-----Original Message-----
From: nvda-addons-bounce@xxxxxxxxxxxxx
[mailto:nvda-addons-bounce@xxxxxxxxxxxxx] On Behalf Of Noelia
Sent: Friday, December 12, 2014 9:39 AM
To: nvda-addons@xxxxxxxxxxxxx
Subject: [nvda-addons] Re: commit/StationPlaylist: norrumar: Possible
improvements cleaning code.

Hi, I'm now reviewing stationPlaylist app module.
It's a complex add-on, so it requires time.
I'm in scripts section.
I think that in line 129, after the return sentence, else can be ommitted
and then simplify the function subsequently.

In the terminate, I think globalConfig is not necessary, since it won't be
changed, just it will be checked.
Therefore, in NVDA core, when saving a configuration file, a try and except
instructions are used checking if the system is readonly, to prevent errors.
You can test all this. I don't have SPL application.
Thanks.



El 12/12/2014 18:33, commits-noreply@xxxxxxxxxxxxx escribió:
1 new commit in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/aa61db2a940b/
Changeset:   aa61db2a940b
Branch:      possibleImprovements
User:        norrumar
Date:        2014-12-12 17:32:30+00:00
Summary:     Possible improvements cleaning code.

Affected #:  1 file

diff --git a/addon/appModules/splstudio.py
b/addon/appModules/splstudio.py index 482b414..260c6b4 100644
--- a/addon/appModules/splstudio.py
+++ b/addon/appModules/splstudio.py
@@ -126,68 +126,67 @@ class AppModule(appModuleHandler.AppModule):
                # Do not let NvDA get name for None object when SPL window
is maximized.
                if not obj.name:
                        return
-               else:
-                       if obj.windowClassName == "TStatusBar" and not
obj.name.startswith("  Up time:"):
-                               # Special handling for Play Status
-                               fgWinClass =
api.getForegroundObject().windowClassName
-                               if obj.IAccessibleChildID == 1:
-                                       if fgWinClass == "TStudioForm":
-                                               # Strip off "  Play status:
" for brevity only in main playlist window.
-                                               ui.message(obj.name[15:])
-                                       elif fgWinClass ==
"TTrackInsertForm" and self.libraryScanProgress > 0:
-                                               # If library scan is in
progress, announce its progress.
-                                               self.scanCount+=1
-                                               if self.scanCount%100 == 0:
-                                                       if
self.libraryScanProgress == self.libraryScanMessage:
-
tones.beep(550, 100) if self.beepAnnounce else ui.message("Scanning")
-                                                       elif
self.libraryScanProgress == self.libraryScanNumbers:
-                                                               if
self.beepAnnounce: tones.beep(550, 100)
-
ui.message(obj.name[1:obj.name.find("]")])
-                                               if "Loading" in obj.name and
not self.libraryScanning:
-                                                       self.libraryScanning
= True
-                                               elif "match" in obj.name and
self.libraryScanning:
-                                                       tones.beep(370, 100)
if self.beepAnnounce else ui.message("Scan complete")
-                                                       self.libraryScanning
= False
-                                                       self.scanCount = 0
+               if obj.windowClassName == "TStatusBar" and not
obj.name.startswith("  Up time:"):
+                       # Special handling for Play Status
+                       fgWinClass =
api.getForegroundObject().windowClassName
+                       if obj.IAccessibleChildID == 1:
+                               if fgWinClass == "TStudioForm":
+                                       # Strip off "  Play status: " for
brevity only in main playlist window.
+                                       ui.message(obj.name[15:])
+                               elif fgWinClass == "TTrackInsertForm" and
self.libraryScanProgress > 0:
+                                       # If library scan is in progress,
announce its progress.
+                                       self.scanCount+=1
+                                       if self.scanCount%100 == 0:
+                                               if self.libraryScanProgress
== self.libraryScanMessage:
+                                                       tones.beep(550, 100)
if self.beepAnnounce else ui.message("Scanning")
+                                               elif
self.libraryScanProgress == self.libraryScanNumbers:
+                                                       if
self.beepAnnounce: tones.beep(550, 100)
+
ui.message(obj.name[1:obj.name.find("]")])
+                                       if "Loading" in obj.name and not
self.libraryScanning:
+                                               self.libraryScanning = True
+                                       elif "match" in obj.name and
self.libraryScanning:
+                                               tones.beep(370, 100) if
self.beepAnnounce else ui.message("Scan complete")
+                                               self.libraryScanning = False
+                                               self.scanCount = 0
                                else:
+                                       # Even with beeps enabled, be sure
to announce scheduled time and name of the playing cart.
+                                       if obj.name.startswith("Scheduled
for") or obj.name.startswith("Cart") and obj.IAccessibleChildID == 3:
+                                               ui.message(obj.name)
+                                       elif not (obj.name.endswith(" On")
or obj.name.endswith(" Off")):
+                                               # Announce status
information that does not contain toggle messages.
+                                               ui.message(obj.name)
                                        if self.beepAnnounce:
-                                               # Even with beeps enabled,
be sure to announce scheduled time and name of the playing cart.
-                                               if
obj.name.startswith("Scheduled for") or obj.name.startswith("Cart") and
obj.IAccessibleChildID == 3:
-                                                       ui.message(obj.name)
-                                               elif not
(obj.name.endswith(" On") or obj.name.endswith(" Off")):
-                                                       # Announce status
information that does not contain toggle messages.
-                                                       ui.message(obj.name)
-                                               else:
-                                                       # User wishes to
hear beeps instead of words. The beeps are power on and off sounds from PAC
Mate Omni.
-                                                       beep =
obj.name.split(" ")
-                                                       stat = beep[-1]
-                                                       wavDir =
os.path.dirname(__file__)
-                                                       # Play a wave file
based on on/off status.
-                                                       if stat == "Off":
-                                                               wavFile =
os.path.join(wavDir, "SPL_off.wav")
-                                                       elif stat == "On":
-                                                               wavFile =
os.path.join(wavDir, "SPL_on.wav")
-
messageSound(wavFile, obj.name)
+                                               # User wishes to hear beeps
instead of words. The beeps are power on and off sounds from PAC Mate Omni.
+                                               beep = obj.name.split(" ")
+                                               stat = beep[-1]
+                                               wavDir =
os.path.dirname(__file__)
+                                               # Play a wave file based on
on/off status.
+                                               if stat == "Off":
+                                                       wavFile =
os.path.join(wavDir, "SPL_off.wav")
+                                               elif stat == "On":
+                                                       wavFile =
os.path.join(wavDir, "SPL_on.wav")
+                                               messageSound(wavFile,
obj.name)
                                        else:
                                                ui.message(obj.name)
-                                       if self.cartExplorer or
self.micAlarm:
-                                               # Activate mic alarm or
announce when cart explorer is active.
-                                               self.doExtraAction(obj.name)
-                       # Monitor the end of track and song intro time and
announce it.
-                       elif obj.windowClassName == "TStaticText": # For
future extensions.
-                               if obj.simplePrevious != None and
obj.simplePrevious.name == "Remaining Time":
+                               if self.cartExplorer or self.micAlarm:
+                                       # Activate mic alarm or announce
when cart explorer is active.
+                                       self.doExtraAction(obj.name)
+               # Monitor the end of track and song intro time and announce
it.
+               elif obj.windowClassName == "TStaticText": # For future
extensions.
+                       if obj.simplePrevious != None:
+                               if obj.simplePrevious.name == "Remaining
Time":
                                        # End of track for SPL 5.x.
                                        if self.brailleTimer in
[self.brailleTimerEnding, self.brailleTimerBoth]: #and "00:00" < obj.name <=
self.SPLEndOfTrackTime:

braille.handler.message(obj.name)
                                        if obj.name ==
self.SPLEndOfTrackTime:
                                                tones.beep(440, 200)
-                               elif obj.simplePrevious != None and
obj.simplePrevious.name == "Remaining Song Ramp":
+                               if obj.simplePrevious.name == "Remaining
Song Ramp":
                                        # Song intro for SPL 5.x.
                                        if self.brailleTimer in
[self.brailleTimerIntro, self.brailleTimerBoth]: #and "00:00" < obj.name <=
self.SPLSongRampTime:

braille.handler.message(obj.name)
                                        if obj.name == self.SPLSongRampTime:
                                                tones.beep(512, 400)
-                       # Clean this mess with a more elegant solution.
+               # Clean this mess with a more elegant solution.
                nextHandler()

        # JL's additions
@@ -195,7 +194,7 @@ class AppModule(appModuleHandler.AppModule):
        # Perform extra action in specific situations (mic alarm, for
example).
        def doExtraAction(self, status):
                global micAlarmT
-               if self.cartExplorer:   
+               if self.cartExplorer:
                        if status == "Cart Edit On":
                                # Translators: Presented when cart edit mode
is toggled on while cart explorer is on.
                                ui.message(_("Cart explorer is active")) @@
-229,7 +228,6 @@
class AppModule(appModuleHandler.AppModule):

        # Save configuration when terminating.
        def terminate(self):
-               global SPLConfig
                if SPLConfig is not None: SPLConfig.write()

        # Script sections (for ease of maintenance):

Repository URL: https://bitbucket.org/nvdaaddonteam/stationplaylist/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


---
El software de antivirus Avast ha analizado este correo electrónico en busca
de virus.
http://www.avast.com

----------------------------------------------------------------

NVDA add-ons Central: A list for discussing NVDA add-ons

To post a message, send an email to nvda-addons@xxxxxxxxxxxxx.

To unsubscribe, send an email with the subject line of "unsubscribe"
(without quotes) to nvda-addons-request@xxxxxxxxxxxxx.

If you have questions for list moderators, please send a message to
nvda-addons-moderators@xxxxxxxxxxxxx.

Community addons can be found here: http://addons.nvda-project.org

----------------------------------------------------------------

NVDA add-ons Central: A list for discussing NVDA add-ons

To post a message, send an email to nvda-addons@xxxxxxxxxxxxx.

To unsubscribe, send an email with the subject line of "unsubscribe" (without 
quotes) to nvda-addons-request@xxxxxxxxxxxxx.

If you have questions for list moderators, please send a message to 
nvda-addons-moderators@xxxxxxxxxxxxx.

Community addons can be found here: http://addons.nvda-project.org


---
El software de antivirus Avast ha analizado este correo electrónico en busca de 
virus.
http://www.avast.com

----------------------------------------------------------------

NVDA add-ons Central: A list for discussing NVDA add-ons

To post a message, send an email to nvda-addons@xxxxxxxxxxxxx.

To unsubscribe, send an email with the subject line of "unsubscribe" (without 
quotes) to nvda-addons-request@xxxxxxxxxxxxx.

If you have questions for list moderators, please send a message to 
nvda-addons-moderators@xxxxxxxxxxxxx.

Community addons can be found here: http://addons.nvda-project.org

Other related posts: