Skip to content

Commit

Permalink
Fix inconsistencies caused in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
SKaplanOfficial committed Nov 24, 2022
1 parent cd6a89b commit 653e194
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 38 deletions.
2 changes: 1 addition & 1 deletion PyXA/XABaseScriptable.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def bounds(self) -> list[XARectangle]:
.. versionadded:: 0.1.1
"""
ls = self.xa_elem.arrayByApplyingSelector_("bounds") or []
return [XARectangle(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height) for rect in ls]
return [XARectangle(value.rectValue().origin.x, value.rectValue().origin.y, value.rectValue().size.width, value.rectValue().size.height) for value in ls]

def closeable(self) -> list[bool]:
"""Gets the closeable status of each window in the list.
Expand Down
79 changes: 49 additions & 30 deletions PyXA/apps/Messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TransferStatus(Enum):
TRANSFERRING = XABase.OSType('FTsg')
FINALIZING = XABase.OSType('FTsz')
FINISHED = XABase.OSType('FTsf')
FAILED = XABase.OSType('FTSe')
FAILED = XABase.OSType('FTse')

class ConnectionStatus(Enum):
"""Options for the connection status of Messages.app to message transfer servers.
Expand Down Expand Up @@ -764,8 +764,11 @@ def transfer_status(self) -> list[XAMessagesApplication.TransferStatus]:
.. versionadded:: 0.0.4
"""
ls = self.xa_elem.arrayByApplyingSelector_("transferStatus")
return [XAMessagesApplication.TransferStatus(XABase.OSType(x.stringValue())) for x in ls]
ls = list(self.xa_elem.arrayByApplyingSelector_("transferStatus"))
try:
return [XAMessagesApplication.TransferStatus(x) for x in ls]
except ValueError:
return [XAMessagesApplication.TransferStatus(XABase.OSType(x.stringValue())) for x in ls]

def started(self) -> list[datetime]:
"""Gets the start time of each file transfer in the list.
Expand Down Expand Up @@ -920,55 +923,65 @@ class XAMessagesFileTransfer(XABase.XAObject, XAClipboardCodable):
"""
def __init__(self, properties):
super().__init__(properties)
self.id: str #: The unique identifier for the file transfer
self.name: str #: The name of the file
self.file_path: XABase.XAPath #: The local page to the file being transferred
self.direction: XAMessagesApplication.MessageDirection #: The direction that the file is being sent
self.account: XAMessagesAccount #: The account on which the file transfer is taking place
self.participant: XAMessagesParticipant #: The other participant in the file transfer
self.file_size: int #: The total size of the file transfers in bytes
self.file_progress: int #: The number of bytes that have been transferred
self.transfer_status: XAMessagesApplication.TransferStatus #: The current status of the file transfer
self.started: datetime #: The date and time that the file transfer started

@property
def id(self) -> str:
"""The unique identifier for the file transfer.
"""
return self.xa_elem.id()

@property
def name(self) -> str:
"""The name of the file.
"""
return self.xa_elem.name()

@property
def file_path(self) -> XABase.XAPath:
"""The local page to the file being transferred.
"""
return XABase.XAPath(self.xa_elem.filePath())

@property
def direction(self) -> XAMessagesApplication.MessageDirection:
"""The direction that the file is being sent.
"""
return XAMessagesApplication.MessageDirection(self.xa_elem.direction())

@property
def account(self) -> 'XAMessagesAccount':
"""The account on which the file transfer is taking place.
"""
return self._new_element(self.xa_elem.account(), XAMessagesAccount)

@property
def participant(self) -> 'XAMessagesParticipant':
"""The other participant in the file transfer.
"""
return self._new_element(self.xa_elem.participant(), XAMessagesParticipant)

@property
def file_size(self) -> int:
"""The total size of the file transfer in bytes.
"""
return self.xa_elem.fileSize()

@property
def file_progress(self) -> int:
"""The number of bytes that have been transferred.
"""
return self.xa_elem.fileProgress()

@property
def transfer_status(self) -> XAMessagesApplication.TransferStatus:
"""The current status of the file transfer.
"""
return XAMessagesApplication.TransferStatus(self.xa_elem.transferStatus())

@property
def started(self) -> datetime:
"""The date and time that the file transfer started.
"""
return self.xa_elem.started()

def get_clipboard_representation(self) -> list[AppKit.NSURL]:
Expand Down Expand Up @@ -1165,57 +1178,58 @@ class XAMessagesParticipant(XABase.XAObject, XAClipboardCodable):
"""
def __init__(self, properties):
super().__init__(properties)
self.id: str #: The unique identifier for the participant
self.account: XAMessagesAccount #: The account for the participant
self.name: str #: The name of the participant as it appears in the participant list
self.handle: str #: The participant's handle
self.first_name: str #: The first name of the participant, taken from their contact card (if available)
self.last_name: str #: The last name of the participant, taken from their contact card (if available)
self.full_name: str #: The full name of the participant, taken from their contact card (if available)

@property
def id(self) -> str:
"""The unique identifier for the participant.
.. versionadded:: 0.0.1
"""
return self.xa_elem.id()

@property
def account(self) -> 'XAMessagesAccount':
"""The account for the participant.
.. versionadded:: 0.0.1
"""
return self._new_element(self.xa_elem.account(), XAMessagesAccount)

@property
def name(self) -> str:
return self.xa_elem.name()
"""The name of the participant as it appears in the participant list
.. versionadded:: 0.0.1
"""
return self.xa_elem.name() or ""

@property
def handle(self) -> str:
return self.xa_elem.handle()
"""The participant's handle.
.. versionadded:: 0.0.1
"""
return self.xa_elem.handle() or ""

@property
def first_name(self) -> str:
return self.xa_elem.firstName()
"""The first name of the participant, taken from their contact card (if available).
.. versionadded:: 0.0.1
"""
return self.xa_elem.firstName() or ""

@property
def last_name(self) -> str:
return self.xa_elem.lastName()
"""The last name of the participant, taken from their contact card (if available).
.. versionadded:: 0.0.1
"""
return self.xa_elem.lastName() or ""

@property
def full_name(self) -> str:
return self.xa_elem.fullName()
"""The full name of the participant, taken from their contact card (if available).
.. versionadded:: 0.0.1
"""
Expand Down Expand Up @@ -1377,22 +1391,23 @@ class XAMessagesAccount(XABase.XAObject, XAClipboardCodable):
"""
def __init__(self, properties):
super().__init__(properties)
self.id: str #: The unique identifier for the account
self.object_description: str #: The name of the account as defined in the Account Preferences description field
self.enabled: bool #: Whether the account is currently enabled
self.connection_status: XAMessagesApplication.ConnectionStatus #: The connection status for the account
self.service_type: XAMessagesApplication.ServiceType #: The type of service for the account

@property
def id(self) -> str:
"""The unique identifier for the account.
"""
return self.xa_elem.id()

@property
def object_description(self) -> str:
"""The name of the account as defined in the Account Preferences description field.
"""
return self.xa_elem.objectDescription()

@property
def enabled(self) -> bool:
"""Whether the account is currently enabled.
"""
return self.xa_elem.enabled()

@enabled.setter
Expand All @@ -1401,10 +1416,14 @@ def enabled(self, enabled: bool):

@property
def connection_status(self) -> XAMessagesApplication.ConnectionStatus:
"""The connection status for the account.
"""
return XAMessagesApplication.ConnectionStatus(self.xa_elem.connectionStatus())

@property
def service_type(self) -> XAMessagesApplication.ServiceType:
"""The type of service for the account.
"""
return XAMessagesApplication.ServiceType(self.xa_elem.serviceType())

def chats(self, filter: Union[dict, None] = None) -> XAMessagesChatList:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = mac-pyxa
version = 0.1.1
version = 0.1.1.1
author = Stephen Kaplan
author_email = stephen.kaplan@maine.edu
description = A package for accomplish AppleScript automation tasks using Python syntax.
Expand Down
9 changes: 3 additions & 6 deletions tests/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,16 @@ def test_finder_lists(self):
self.assertIsInstance(clipping_windows[0].xa_elem, ScriptingBridge.SBObject)

def test_finder_selection(self):
self.app.selection = self.app.files()[0]
self.app.selection = self.app.insertion_location.files()[0]
self.assertEqual(len(self.app.selection), 1)

pre_selection = self.app.selection

self.app.selection = self.app.files()[0:10]
self.app.selection = self.app.insertion_location.files()[0:3]

self.assertNotEqual(len(self.app.selection), 1)
print(pre_selection)
print(self.app.selection)
self.assertEqual(pre_selection == self.app.selection, False)

file = self.app.files()[0]
file = self.app.insertion_location.files()[0]
file.reveal()
self.assertEqual(len(self.app.selection), 1)
self.assertIn(file.url, self.app.selection.url())
Expand Down
1 change: 1 addition & 0 deletions tests/test_textedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_textedit_make_documents(self):

def test_textedit_window_methods(self):
self.app.front_window.miniaturized = True
time.sleep(1)
self.assertEqual(self.app.front_window.miniaturized, True)

time.sleep(0.5)
Expand Down

0 comments on commit 653e194

Please sign in to comment.