1
# -*- encoding: utf-8 -*-
3
# Copyright 2009-2011 Canonical Ltd.
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
"""Platform specific bindings."""
22
from ubuntu_sso.xdg_base_directory import xdg_home
3
24
# very hackish way to avoid "import *" to satisfy pyflakes
4
25
# and to avoid import ubuntuone.platform.X as source (it wont work)
13
34
from ubuntuone.platform import credentials
15
target = sys.modules[__name__]
17
setattr(target, k, getattr(source, k))
35
from ubuntuone.platform import tools
38
def expand_user(path):
39
"""Fix Python expanduser for weird chars in windows."""
40
# Receives bytes, returns unicode
41
assert isinstance(path, str)
44
except UnicodeDecodeError:
45
raise AssertionError('The path %r must be encoded in utf-8' % path)
47
if not path.startswith(tilde) or \
48
(len(path) > 1 and path[1:2] != os.path.sep):
50
result = path.replace('~', xdg_home, 1)
52
assert isinstance(result, str)
54
result.decode('utf-8')
55
except UnicodeDecodeError:
56
raise AssertionError('The path %r must be encoded in utf-8' % result)
60
platform = source.platform
61
access = source.access
62
allow_writes = source.allow_writes
63
can_write = source.can_write
64
get_path_list = source.get_path_list
65
is_link = source.is_link
66
is_root = source.is_root
67
listdir = source.listdir
68
make_dir = source.make_dir
69
make_link = source.make_link
70
move_to_trash = source.move_to_trash
71
native_rename = source.native_rename
72
normpath = source.normpath
73
open_file = source.open_file
74
path_exists = source.path_exists
75
read_link = source.read_link
76
recursive_move = source.recursive_move
77
remove_dir = source.remove_dir
78
remove_file = source.remove_file
79
remove_link = source.remove_link
80
remove_tree = source.remove_tree
81
rename = source.rename
82
set_application_name = source.set_application_name
83
set_dir_readonly = source.set_dir_readonly
84
set_dir_readwrite = source.set_dir_readwrite
85
set_file_readonly = source.set_file_readonly
86
set_file_readwrite = source.set_file_readwrite
87
set_no_rights = source.set_no_rights
88
stat_path = source.stat_path
92
setup_filesystem_logging = source.setup_filesystem_logging
93
get_filesystem_logger = source.get_filesystem_logger
95
# From File System Notifications
96
FilesystemMonitor = source.FilesystemMonitor
97
_GeneralINotifyProcessor = source._GeneralINotifyProcessor
100
ExternalInterface = source.ExternalInterface
101
is_already_running = source.is_already_running