(self, native_dirpath, native_name)
return trunk + (b'.' if ext or not trunk else b'') + ext
Convert native name to short name or (not normalised or even legal) dos-style name.
Convert native name to short name or (not normalised or even legal) dos-style name.
Convert native name to short name or ( not normalised or even legal ) dos - style name .
def _get_dos_display_name(self, native_dirpath, native_name):
        """Convert native name to short name or (not normalised or even legal) dos-style name."""
        native_path = os.path.join(native_dirpath, native_name)
        # get the short name if it exists, keep long name otherwise
        native_path = get_short_pathname(native_path) or native_path
        native_name = os.path.basename(native_path)
        # see if we have a legal dos name that matches
        try:
            ascii_name = native_name.encode('ascii')
        except UnicodeEncodeError:
            pass
        else:
            if dos_is_legal_name(ascii_name):
                return dos_normalise_name(ascii_name)
        # convert to codepage
        cp_name = self._codepage.unicode_to_bytes(native_name, errors='replace')
        # clip overlong & mark as shortened
        trunk, ext = dos_splitext(cp_name)
        if len(trunk) > 8:
            trunk = trunk[:7] + b'+'
        if len(ext) > 3:
            ext = ext[:2] + b'+'
        return trunk + (b'.' if ext or not trunk else b'') + ext
def _get_dos_display_name ( self , native_dirpath , native_name ) : native_path = os . path . join ( native_dirpath , native_name ) # get the short name if it exists, keep long name otherwise native_path = get_short_pathname ( native_path ) or native_path native_name = os . path . basename ( native_path ) # see if we have a legal dos name that matches try : ascii_name = native_name . encode ( 'ascii' ) except UnicodeEncodeError : pass else : if dos_is_legal_name ( ascii_name ) : return dos_normalise_name ( ascii_name ) # convert to codepage cp_name = self . _codepage . unicode_to_bytes ( native_name , errors = 'replace' ) # clip overlong & mark as shortened trunk , ext = dos_splitext ( cp_name ) if len ( trunk ) > 8 : trunk = trunk [ : 7 ] + b'+' if len ( ext ) > 3 : ext = ext [ : 2 ] + b'+' return trunk + ( b'.' if ext or not trunk else b'' ) + ext