decode ( filesystem_encoding ) except UnicodeDecodeError : debug_print ( 'Skipping undecodeable file: %r ' % name ) continue if isdir ( join ( top, name )): dirs. listdir ( top ) except OSError as err : if onerror is not None : onerror ( err ) return dirs, nondirs =, for name in names : if isinstance ( name, bytes ): try : name = name. os.path.walk # always suppressed the exception then, rather than blow up for a # minor reason when (say) a thousand readable directories are still # left to visit. isdir # We may not have read permission for top, in which case we can't # get a list of the files the directory contains. monotonic () - base_time ), * args, ** kw ) def safe_walk ( top, topdown = True, onerror = None, followlinks = False, maxdepth = 128 ): ' A replacement for os.walk that does not die when it encounters undecodeable filenames in a linux filesystem' if maxdepth < 0 : return islink, join, isdir = os. monotonic () if is_debugging (): prints ( 'DEBUG: %6.1f ' % ( time. ''' import os, time, json, shutil from itertools import cycle from nstants import numeric_version, ismacos from calibre import prints, isbytestring, fsync from nstants import filesystem_encoding, is_debugging from import CLI from import Device from import BookList, Book from .json_codec import JsonCodec from polyglot.builtins import itervalues, string_or_bytes def debug_print ( * args, ** kw ): base_time = getattr ( debug_print, 'base_time', None ) if base_time is None : debug_print. It is intended to be subclassed with the relevant parts implemented for a particular device. This is not a complete stand alone driver. _license_ = 'GPL v3' _copyright_ = '2009, John Schember ' _docformat_ = 'restructuredtext en' ''' Generic USB Mass storage device driver.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |