Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added feature to return macOS desktop path for StoragePath #813

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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