Logo Search packages:      
Sourcecode: zim version File versions  Download package

def zim::notebook::Notebook::cleanup_pathname (   name  ) 

Returns a safe version of name, used internally by functions like
resolve_path() to parse user input.
It raises a PageNameError when the name is not valid

Definition at line 635 of file notebook.py.

00635                                 :
            '''Returns a safe version of name, used internally by functions like
            resolve_path() to parse user input.
            It raises a PageNameError when the name is not valid
            '''
            # Reserved characters are:
            # The ':' is reserrved as seperator
            # The '?' is reserved to encode url style options
            # The '#' is reserved as anchor separator
            # The '/' and '\' are reserved to distinquise file links & urls
            # First character of each part MUST be alphanumeric
            #           (including utf8 letters / numbers)

            # Zim version < 0.42 restricted all special charachters but
            # white listed ".", "-", "_", "(", ")", ":" and "%".

            # For file system we should reserve (win32 & posix)
            # "\", "/", ":", "*", "?", '"', "<", ">", "|"

            orig = name
            name = name.replace('_', ' ')
                  # Avoid duplicates with and without '_' (e.g. in index)
                  # Note that leading "_" is stripped, due to strip() below

            for char in ("?", "#", "/", "\\", "*", '"', "<", ">", "|"):
                  if char in name:
                        raise PageNameError, orig

            parts = map(unicode.strip, filter(
                  lambda n: len(n)>0, unicode(name).split(':') ) )

            for part in parts:
                  if _first_char_re.match(part):
                        raise PageNameError, orig

            name = ':'.join(parts)

            if not name:
                  raise PageNameError, orig

            return name

      @staticmethod
      def cleanup_pathname_zim028(name):


Generated by  Doxygen 1.6.0   Back to index