Beispiel #1
0
 def _visit(self, fname, api):
     """Visit a file."""
     basename, ext = os.path.splitext(fname)
     extension = '.' + api.options['extension']
     if ext == '.py':
         messages = self._visit_python(fname, api)
     elif ext == extension:
         base2, ext2 = os.path.splitext(basename)
         if islocale(ext2):
             return []
         messages = self._visit_template(fname, api)
     else:
         return []
     relname = fname[len(api.docroot):]
     if api.opts.verbose:
         self.write('%s:\n' % relname)
         self._show_messages(messages)
     return messages
Beispiel #2
0
def parse_draco_uri(uri, docroot):
    """Decompose an URI into Draco specific components.

    The return value is the 8-tuple: (protocol, host, path,
        filename, locale, session, pathinfo, args)
    """
    protocol, host, path, args = urimod.parse_uri(uri)
    directory, filename, pathinfo = urimod.resolve_path_uri(path, docroot) 
    parts = pathinfo.split('/')
    if parts and islocale(parts[0]):
        locale = parts[0]
        parts = parts[1:]
    else:
        locale = ''
    if parts and issessionid(parts[0]):
        session = parts[0]
        parts = parts[1:]
    else:
        session = ''
    pathinfo = '/'.join(parts)
    return (protocol, host, directory, filename, locale, session,
            pathinfo, args)
Beispiel #3
0
 def test_islocale(self):
     for name,parsed in self.data:
         assert util.islocale(name)