Did I find the right examples for you? yes no

All Samples(37)  |  Call(24)  |  Derive(0)  |  Import(13)
Join multiple paths into a single url

>>> urlpathjoin('http://storage.scrapinghub.com:8002/', 'jobs', '1/2/3')
'http://storage.scrapinghub.com:8002/jobs/1/2/3'
>>> urlpathjoin('http://storage.scrapinghub.com:8002', 'jobs', '1/2/3', None)
'http://storage.scrapinghub.com:8002/jobs/1/2/3'
>>> urlpathjoin(_, 'state')
'http://storage.scrapinghub.com:8002/jobs/1/2/3/state'
>>> urlpathjoin(_, None)
'http://storage.scrapinghub.com:8002/jobs/1/2/3/state'(more...)

        def urlpathjoin(*parts):
    """Join multiple paths into a single url

    >>> urlpathjoin('http://storage.scrapinghub.com:8002/', 'jobs', '1/2/3')
    'http://storage.scrapinghub.com:8002/jobs/1/2/3'
    >>> urlpathjoin('http://storage.scrapinghub.com:8002', 'jobs', '1/2/3', None)
    'http://storage.scrapinghub.com:8002/jobs/1/2/3'
    >>> urlpathjoin(_, 'state')
    'http://storage.scrapinghub.com:8002/jobs/1/2/3/state'
    >>> urlpathjoin(_, None)
    'http://storage.scrapinghub.com:8002/jobs/1/2/3/state'
    >>> urlpathjoin(78)
    '78'
    >>> urlpathjoin('78')
    '78'
    >>> urlpathjoin('s', 78)
    's/78'
    >>> urlpathjoin('s', 78, 'foo')
    's/78/foo'
    >>> urlpathjoin('s/78/foo')
    's/78/foo'
    >>> urlpathjoin((111, 'jobs'), 33)
    '111/jobs/33'
    >>> urlpathjoin('http://localhost:8003/', ('jobs', '1111111'), '2/1')
    'http://localhost:8003/jobs/1111111/2/1'

    """
    url = None
    for p in parts:
        if p is None:
            continue
        elif isinstance(p, tuple):
            p = urlpathjoin(*p)
        elif isinstance(p, unicode):
            p = p.encode('utf8')
        elif not isinstance(p, str):
            p = str(p)

        url = p if url is None else '{0}/{1}'.format(url.rstrip('/'), p)

    return url
        


src/h/u/hubstorage-0.13.1/hubstorage/resourcetype.py   hubstorage(Download)
import logging, time, json, socket
from collections import MutableMapping
import requests.exceptions as rexc
from .utils import urlpathjoin, xauth
from .serialization import jlencode, jldecode
    def __init__(self, client, key, auth=None):
        self.client = client
        self.key = urlpathjoin(self.resource_type, key, self.key_suffix)
        self.auth = xauth(auth) or client.auth
        self.url = urlpathjoin(client.endpoint, self.key)
 
    def _iter_lines(self, _path, **kwargs):
        kwargs['url'] = urlpathjoin(self.url, _path)
                    raise
                lastexc = exc
                url = urlpathjoin(self.url, _path)
                msg = "Retrying read of %s in %ds: attempt=%d/%d error=%s"
                args = url, self.RETRY_INTERVAL, attempt, self.MAX_RETRIES, exc

src/p/y/python-hubstorage-HEAD/hubstorage/resourcetype.py   python-hubstorage(Download)
import logging, time, json, socket
from collections import MutableMapping
import requests.exceptions as rexc
from .utils import urlpathjoin, xauth
from .serialization import jlencode, jldecode
    def __init__(self, client, key, auth=None):
        self.client = client
        self.key = urlpathjoin(self.resource_type, key, self.key_suffix)
        self.auth = xauth(auth) or client.auth
        self.url = urlpathjoin(client.endpoint, self.key)
 
    def _iter_lines(self, _path, **kwargs):
        kwargs['url'] = urlpathjoin(self.url, _path)
                    raise
                lastexc = exc
                url = urlpathjoin(self.url, _path)
                msg = "Retrying read of %s in %ds: attempt=%d/%d error=%s"
                args = url, self.RETRY_INTERVAL, attempt, self.MAX_RETRIES, exc

src/h/u/hubstorage-0.13.1/hubstorage/frontier.py   hubstorage(Download)
import json
 
from .resourcetype import ResourceType
from .utils import urlpathjoin
 
        if not writer:
            writer = self.client.batchuploader.create_writer(
                url=urlpathjoin(self.url, frontier, 's', slot),
                auth=self.auth,
                size=self.batch_size,

src/p/y/python-hubstorage-HEAD/hubstorage/frontier.py   python-hubstorage(Download)
import json
 
from .resourcetype import ResourceType
from .utils import urlpathjoin
 
        if not writer:
            writer = self.client.batchuploader.create_writer(
                url=urlpathjoin(self.url, frontier, 's', slot),
                auth=self.auth,
                size=self.batch_size,

src/h/u/hubstorage-0.13.1/hubstorage/collectionsrt.py   hubstorage(Download)
from requests.exceptions import HTTPError
from .resourcetype import DownloadableResource
from .utils import urlpathjoin
 
 
    def create_writer(self, coltype, colname, **writer_kwargs):
        kwargs = dict(writer_kwargs)
        kwargs.setdefault('content_encoding', 'gzip')
        kwargs.setdefault('auth', self.auth)
        url = urlpathjoin(self.url, coltype, colname)

src/p/y/python-hubstorage-HEAD/hubstorage/collectionsrt.py   python-hubstorage(Download)
from requests.exceptions import HTTPError
from .resourcetype import DownloadableResource
from .utils import urlpathjoin
 
 
    def create_writer(self, coltype, colname, **writer_kwargs):
        kwargs = dict(writer_kwargs)
        kwargs.setdefault('content_encoding', 'gzip')
        kwargs.setdefault('auth', self.auth)
        url = urlpathjoin(self.url, coltype, colname)

src/h/u/hubstorage-0.13.1/hubstorage/client.py   hubstorage(Download)
import pkgutil
from requests import session
from .utils import xauth, urlpathjoin
from .project import Project
from .job import Job
    def server_timestamp(self):
        tsurl = urlpathjoin(self.endpoint, 'system/ts')
        return self.session.get(tsurl).json()
 
    def close(self, timeout=None):

src/p/y/python-hubstorage-HEAD/hubstorage/client.py   python-hubstorage(Download)
import pkgutil
from requests import session, adapters
from .utils import xauth, urlpathjoin
from .project import Project
from .job import Job
    def server_timestamp(self):
        tsurl = urlpathjoin(self.endpoint, 'system/ts')
        return self.session.get(tsurl).json()
 
    def close(self, timeout=None):

src/h/u/hubstorage-0.13.1/hubstorage/project.py   hubstorage(Download)
from .frontier import Frontier
from .resourcetype import ResourceType, MappingResourceType
from .utils import urlpathjoin, xauth
 
 
class Project(object):
 
    def __init__(self, client, projectid, auth=None):
        self.client = client
        self.projectid = urlpathjoin(projectid)
    def get_job(self, _key, *args, **kwargs):
        key = urlpathjoin(_key)
        parts = key.split('/')
        if len(parts) == 2:
            key = (self.projectid, key)

src/p/y/python-hubstorage-HEAD/hubstorage/project.py   python-hubstorage(Download)
from .frontier import Frontier
from .resourcetype import ResourceType, MappingResourceType
from .utils import urlpathjoin, xauth
 
 
class Project(object):
 
    def __init__(self, client, projectid, auth=None):
        self.client = client
        self.projectid = urlpathjoin(projectid)
    def get_job(self, _key, *args, **kwargs):
        key = urlpathjoin(_key)
        parts = key.split('/')
        if len(parts) == 2:
            key = (self.projectid, key)

  1 | 2  Next