join: join paths parts together to represent a path.

        @return: URI instance of joined path
        @rtype: URI
968037
def join(self, *args):
        
        sep = self.sep
        if sep != '/':
            args = [x.replace(sep, '/') for x in args]
        args = (
            [self.parse_result.path.rstrip('/')] +
            [x.strip('/') for x in args[:-1]] +
            [args[-1]]
            )
        parts = self.parse_result.as_list()
        parts[2] = '/'.join(args)

        result = self.__class__(
            uri_from_parts(parts),
            sep=sep,
            **self._extras()
            )

        result.parse_result.query = self.query.copy()

        return result
128885
def path_from_uri(self, uri):
        
        (scheme, netloc, path, params, query, frag) = urlparse(uri)
        if (netloc == ''):
            return(uri)
        path = '/'.join([netloc, path])
        path = re.sub('[^\w\-\.]', '_', path)
        path = re.sub('__+', '_', path)
        path = re.sub('[_\.]+$', '', path)
        path = re.sub('^[_\.]+', '', path)
        return(path)
506869
def join_path(*path_to_join, **kwargs):
    
    if "get_root" in kwargs:
        get_root = kwargs["get_root"]
    else:
        # default value
        get_root = False
    sdp = dataset_path(get_root=get_root)
    pth = os.path.join(sdp, *path_to_join)
    logger.debug("sample_data_path" + str(sdp))
    logger.debug("path " + str(pth))
    return pth
718467
def uri_path(self):
        
        value = []
        for option in self.options:
            if option.number == defines.OptionRegistry.URI_PATH.number:
                value.append(str(option.value) + '/')
        value = "".join(value)
        value = value[:-1]
        return value
747744
def join_url_parts(*args):
    
    # check for edge case
    if len(args) == 1:
        return args[0]

    return_val = clean_url_segment(args[0])

    for i in range(1, len(args)):
        arg = args[i]

        if i == len(args) - 1:
            # no need to remove a trailing slash if this is the last segment
            return_val += '/' + arg
        else:
            # remove a trailing slash so it won't be duplicated
            return_val += '/' + clean_url_segment(arg)

    return return_val
304758
def join(path1, path2):
    '''
    
    '''
    if path1.endswith('/') and path2.startswith('/'):
        return ''.join([path1, path2[1:]])
    elif path1.endswith('/') or path2.startswith('/'):
        return ''.join([path1, path2])
    else:
        return ''.join([path1, '/', path2])
1289339
def join_paths(fnames:FilePathList, path:PathOrStr='.')->Collection[Path]:
    ""
    path = Path(path)
    return [join_path(o,path) for o in fnames]
432184
def join(*paths):
	
	"""
	paths_with_drives = map(os.path.splitdrive, paths)
	drives, paths = zip(*paths_with_drives)
	# the drive we care about is the last one in the list
	drive = next(filter(None, reversed(drives)), '')
	return os.path.join(drive, os.path.join(*paths))
562451
def url(self):
        
        path = None
        nodes = self.parents()
        while not nodes.empty():
            path = urljoin(path, nodes.get().path())
        return path
1202273
def pathparts(self):
        
        try:
            parts = self.parent.pathparts()
            parts.append(self.name)
            return parts
        except AttributeError:
            return []
648097
def join(uri)
      if !uri.respond_to?(:to_str)
        raise TypeError, "Can't convert #{uri.class} into String."
      end
      if !uri.kind_of?(URI)
        # Otherwise, convert to a String, then parse.
        uri = URI.parse(uri.to_str)
      end
      if uri.to_s.empty?
        return self.dup
      end

      joined_scheme = nil
      joined_user = nil
      joined_password = nil
      joined_host = nil
      joined_port = nil
      joined_path = nil
      joined_query = nil
      joined_fragment = nil

      # Section 5.2.2 of RFC 3986
      if uri.scheme != nil
        joined_scheme = uri.scheme
        joined_user = uri.user
        joined_password = uri.password
        joined_host = uri.host
        joined_port = uri.port
        joined_path = URI.normalize_path(uri.path)
        joined_query = uri.query
      else
        if uri.authority != nil
          joined_user = uri.user
          joined_password = uri.password
          joined_host = uri.host
          joined_port = uri.port
          joined_path = URI.normalize_path(uri.path)
          joined_query = uri.query
        else
          if uri.path == nil || uri.path.empty?
            joined_path = self.path
            if uri.query != nil
              joined_query = uri.query
            else
              joined_query = self.query
            end
          else
            if uri.path[0..0] == SLASH
              joined_path = URI.normalize_path(uri.path)
            else
              base_path = self.path.dup
              base_path = EMPTY_STR if base_path == nil
              base_path = URI.normalize_path(base_path)

              # Section 5.2.3 of RFC 3986
              #
              # Removes the right-most path segment from the base path.
              if base_path =~ /\//
                base_path.sub!(/\/[^\/]+$/, SLASH)
              else
                base_path = EMPTY_STR
              end

              # If the base path is empty and an authority segment has been
              # defined, use a base path of SLASH
              if base_path.empty? && self.authority != nil
                base_path = SLASH
              end

              joined_path = URI.normalize_path(base_path + uri.path)
            end
            joined_query = uri.query
          end
          joined_user = self.user
          joined_password = self.password
          joined_host = self.host
          joined_port = self.port
        end
        joined_scheme = self.scheme
      end
      joined_fragment = uri.fragment

      return self.class.new(
        :scheme => joined_scheme,
        :user => joined_user,
        :password => joined_password,
        :host => joined_host,
        :port => joined_port,
        :path => joined_path,
        :query => joined_query,
        :fragment => joined_fragment
      )
    end
141942
def _JoinKeyPath(self, path_segments):
    
    # This is an optimized way to combine the path segments into a single path
    # and combine multiple successive path separators to one.

    # Split all the path segments based on the path (segment) separator.
    path_segments = [
        segment.split(definitions.KEY_PATH_SEPARATOR)
        for segment in path_segments]

    # Flatten the sublists into one list.
    path_segments = [
        element for sublist in path_segments for element in sublist]

    # Remove empty path segments.
    path_segments = filter(None, path_segments)

    return definitions.KEY_PATH_SEPARATOR.join(path_segments)
980359
def path(self):
        
        if self.parent is None:
            return self.title
        return join(self.parent.path, self.title)
599540
def join_path(a, *p):
    """"""
    path = a
    for b in p:
        if len(b) == 0:
            continue
        if b.startswith('/'):
            path += b[1:]
        elif path == '' or path.endswith('/'):
            path += b
        else:
            path += '/' + b
    # END for each path token to add
    return path
1026803
def join(*args, **kwargs):
    """"""
    import os.path
    if _is_list(args[0]):
        return os.path.join(*args[0])
    return os.path.join(*args, **kwargs)
41347
def include_path(self):
        
        parts = [self.include_dir(root=self.url_root)]
        parts.append("index")
        return "/".join(parts)
1030530
def join_paths(path1: Optional[str], path2: Optional[str]) -> Optional[str]:
    
    if path1 is not None and path2 is not None:
        return os.path.join(path1, path2)