Exemple #1
0
 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
 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)
Exemple #3
0
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 ''
Exemple #4
0
 def fix_path(x):
     u = os.path.abspath(x.decode('utf-8'))
     return get_long_path_name(u)