Next / Previous / Contents / Shipman's homepage

6.16. PathInfo.__dasher(): Format a permission bit

Formats a permission bit using the “ls -l” convention. The bit argument is true if the permission is granted, false otherwise. The flag argument is returned if the permission is true, otherwise the method returns "-".

pathinfo.py
# - - -   P a t h I n f o . _ _ d a s h e r   - - -

    def __dasher ( self, bit, flag ):
        """Format a permission bit as in ls -l.

          [ (bit is a Boolean value) and (flag is a string) ->
              if bit is true ->
                return flag
              else -> return "-" ]
        """
        if  bit:  return flag
        else:     return "-"