(self)
return mount_dict
Assign default drive letters.
Assign default drive letters.
Assign default drive letters .
def _get_default_drives(self):
        """Assign default drive letters."""
        mount_dict = {}
        if WIN32:
            # get all drives in use by windows
            # if started from CMD.EXE, get the 'current working dir' for each drive
            # if not in CMD.EXE, there's only one cwd
            save_current = getcwdu()
            for letter in iterchar(UPPERCASE):
                try:
                    os.chdir(letter + b':')
                    cwd = get_short_pathname(getcwdu()) or getcwdu()
                except EnvironmentError:
                    # doesn't exist or can't access, do not mount this drive
                    pass
                else:
                    path, cwd = os.path.splitdrive(cwd)
                    if path:
                        # cwd must not start with \\
                        if cwd[:1] == u'\\':
                            path += u'\\'
                            cwd = cwd[1:]
                        if cwd:
                            mount_dict[letter] = u':'.join((path, cwd))
                        else:
                            mount_dict[letter] = path
                    else:
                        logging.warning('Not mounting `%s`: no drive letter.', cwd)
            os.chdir(save_current)
        else:
            # non-Windows systems simply have 'Z:' set to their their cwd by default
            mount_dict[b'Z'] = getcwdu()
        return mount_dict
def _get_default_drives ( self ) : mount_dict = { } if WIN32 : # get all drives in use by windows # if started from CMD.EXE, get the 'current working dir' for each drive # if not in CMD.EXE, there's only one cwd save_current = getcwdu ( ) for letter in iterchar ( UPPERCASE ) : try : os . chdir ( letter + b':' ) cwd = get_short_pathname ( getcwdu ( ) ) or getcwdu ( ) except EnvironmentError : # doesn't exist or can't access, do not mount this drive pass else : path , cwd = os . path . splitdrive ( cwd ) if path : # cwd must not start with \\ if cwd [ : 1 ] == u'\\' : path += u'\\' cwd = cwd [ 1 : ] if cwd : mount_dict [ letter ] = u':' . join ( ( path , cwd ) ) else : mount_dict [ letter ] = path else : logging . warning ( 'Not mounting `%s`: no drive letter.' , cwd ) os . chdir ( save_current ) else : # non-Windows systems simply have 'Z:' set to their their cwd by default mount_dict [ b'Z' ] = getcwdu ( ) return mount_dict