pyatom/pyatom — pull request #33 by pekkle01 (2012-09-13 06:01:02+00:00)
Title: Slightly refactored the code for getFrontmostApp()

Slightly refactored the code for getFrontmost App().

If the proposed API for getFrontmostApp() is acceptable, this would be my favored implementation over the initial version introduced yesterday.

Original commit message below:

Refactored the code common to getAppRefByLocalizedName() and
getFrontmostApp() into a private class method (class method because its
intended users are also class methods).

Also amended the exception message included when ValueError is raised
for getFrontmostApp().

Testing done:

>>> import atomac
>>> atomac.getFrontmostApp()

>>> time.sleep(1); atomac.getFrontmostApp()

>>> time.sleep(1); atomac.getFrontmostApp().windows()
[,
,
]
>>> time.sleep(1); atomac.getFrontmostApp().windows()
[]
>>> time.sleep(1); atomac.getFrontmostApp().windows()
[]
>>> time.sleep(1); atomac.getFrontmostApp()

>>> atomac.getAppRefByLocalizedName('Safari')

>>> atomac.getAppRefByLocalizedName('P4V')