def handle_url(self, url, signode):
     if url is None:
         raise ValueError
     # Split URL into path, query, and fragment
     _, _, path, query, fragment = urlsplit(url)
     urlnode = desc_http_url()
     # Create nodes for the path
     if path:
         pathnode = desc_http_path(path)
         path_segments = self.path_re.findall(path)[:-1]
         for text, arg in path_segments:
             pathnode += Text(text)
             if arg:
                 arg = arg[1:-1]     # Strip off { and }
                 pathnode += desc_http_patharg(arg, arg)
         urlnode += pathnode
     else:
         raise ValueError
     # Create nodes for the query string
     if query:
         querynode = desc_http_query(query)
         query_params = query.split('&')
         for p in query_params:
             querynode += desc_http_queryparam(p, p)
         urlnode += querynode
     # Create a node for the fragment
     if fragment:
         urlnode += desc_http_fragment(fragment, fragment)
     # Add urlnode to signode
     signode += urlnode
Esempio n. 2
0
 def node_from_path(self, path):
     """Returns a ``desc_http_path`` Node from a ``path`` string."""
     if path:
         pathnode = desc_http_path(path)
         path_segments = self.path_re.findall(path)[:-1]
         for text, arg in path_segments:
             pathnode += Text(text)
             if arg:
                 arg = arg[1:-1]     # Strip off { and }
                 pathnode += desc_http_patharg(arg, arg)
         return pathnode
     else:
         raise ValueError
Esempio n. 3
0
 def node_from_path(self, path):
     """Returns a ``desc_http_path`` Node from a ``path`` string."""
     if path:
         pathnode = desc_http_path(path)
         path_segments = self.path_re.findall(path)[:-1]
         for text, arg in path_segments:
             pathnode += Text(text)
             if arg:
                 arg = arg[1:-1]  # Strip off { and }
                 pathnode += desc_http_patharg(arg, arg)
         return pathnode
     else:
         raise ValueError