Skip to content

Commit

Permalink
Merge pull request #813 from temitayoadefemi/plyer-experiment
Browse files Browse the repository at this point in the history
Added feature to return macOS desktop path for StoragePath
  • Loading branch information
akshayaurora authored Jan 8, 2025
2 parents a54a29b + 98ed208 commit 5c874e2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plyer/facades/storagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
>>> from plyer import storagepath
>>> storagepath.get_application_dir()
'''



class StoragePath:
'''
StoragePath facade.
Expand Down Expand Up @@ -101,12 +103,17 @@ def get_application_dir(self):
Get the path of the directory holding application files.
'''
return self._get_application_dir()

def get_desktop_dir(self):
'''
Get the path of the directory holding application files.
'''
return self._get_desktop_dir()

# private

def _get_home_dir(self):
raise NotImplementedError()

def _get_external_storage_dir(self):
raise NotImplementedError()

Expand All @@ -133,3 +140,6 @@ def _get_pictures_dir(self):

def _get_application_dir(self):
raise NotImplementedError()

def _get_desktop_dir(self):
raise NotImplementedError()
1 change: 1 addition & 0 deletions plyer/platforms/ios/storagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ def _get_application_dir(self):
UTF8String()



def instance():
return iOSStoragePath()
10 changes: 10 additions & 0 deletions plyer/platforms/macosx/storagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
NSMoviesDirectory = 17
NSMusicDirectory = 18
NSPicturesDirectory = 19
NSDesktopDirectory = 12



class OSXStoragePath(StoragePath):
Expand Down Expand Up @@ -57,6 +59,14 @@ def _get_application_dir(self):
NSApplicationDirectory, 1
).firstObject().absoluteString.UTF8String()

def _get_desktop_dir(self):
return self.defaultManager.URLsForDirectory_inDomains_(
NSDesktopDirectory, 1).firstObject().absoluteString.\
UTF8String()





def instance():
return OSXStoragePath()
1 change: 1 addition & 0 deletions plyer/tests/test_storagepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_storagepath_macosx(self):
self.assertIn(path_format, storagepath.get_music_dir())
self.assertIn(path_format, storagepath.get_pictures_dir())
self.assertIn(path_format, storagepath.get_application_dir())
self.assertIn(path_format, storagepath.get_desktop_dir())

@PlatformTest('win')
def test_storagepath_windows(self):
Expand Down

0 comments on commit 5c874e2

Please sign in to comment.