コード例 #1
0
ファイル: win_file_dialogs.py プロジェクト: zwpaper/calibre
 def fix_path(x):
     u = os.path.abspath(x.decode('utf-8'))
     with suppress(Exception):
         try:
             return get_long_path_name(u)
         except FileNotFoundError:
             base, fn = os.path.split(u)
             return os.path.join(get_long_path_name(base), fn)
     return u
コード例 #2
0
 def setUp(self):
     with tempfile.NamedTemporaryFile(delete=False) as tf:
         tf.write(b'external')
         self.temp_file = os.path.abspath(tf.name)
     if iswindows:
         from calibre_extensions.winutil import get_long_path_name
         self.temp_file = get_long_path_name(self.temp_file)
コード例 #3
0
ファイル: dnd.py プロジェクト: zwpaper/calibre
def path_from_qurl(qurl, allow_remote=False):
    lf = qurl.toLocalFile()
    if lf:
        if iswindows:
            from calibre_extensions.winutil import get_long_path_name
            lf = get_long_path_name(lf)
            lf = make_long_path_useable(lf)
        return lf
    if not allow_remote:
        return ''
    if qurl.scheme() in remote_protocols:
        path = qurl.path()
        if path and '.' in path:
            return path.rpartition('.')[-1]
    return ''
コード例 #4
0
ファイル: win_file_dialogs.py プロジェクト: pfnsnp/calibre
 def fix_path(x):
     u = os.path.abspath(x.decode('utf-8'))
     return get_long_path_name(u)