How to use the furl.furl function in furl

To help you get started, we’ve selected a few furl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CenterForOpenScience / SHARE / share / harvesters / com_researchregistry.py View on Github external
def fetch_page(self, page, start_date, end_date):
        url = furl(self.config.base_url)
        url.args['page'] = page
        url.args['rows_per_page'] = 1000
        url.args['format'] = 'raw'
        url.args['filters'] = json.dumps({
            'match': 'and',
            'rules': [
                # date filters are strictly less/greater than, not equal to
                {'field': self.DATE_FIELD, 'operator': 'is after', 'value': start_date.subtract(days=1).to_date_string()},
                {'field': self.DATE_FIELD, 'operator': 'is before', 'value': end_date.add(days=1).to_date_string()},
            ]
        })
        response = self.requests.get(url.url, headers=self.HEADERS)
        if response.status_code // 100 != 2:
            raise ValueError('Malformed response ({}) from {}. Got {}'.format(response, url.url, response.content))
        return response.json()
github dblackrun / pbpstats / tests / test_pbp_event_consistency.py View on Github external
responses.add(responses.GET, pbp_url, json=game_pbp_response, status=200)
        responses.add(responses.GET, game_summary_url, json=game_summary_response, status=200)

        with open('tests/data/stats_game_pbp_response.json') as f:
            game_pbp_response = json.loads(f.read())
        pbp_base_url = 'https://stats.nba.com/stats/playbyplayv2'
        pbp_query_params = {
            'EndPeriod': 10,
            'EndRange': 55800,
            'GameId': '0021600270',
            'RangeType': 2,
            'StartPeriod': 0,
            'StartRange': 0,
        }
        pbp_url = furl(pbp_base_url).add(pbp_query_params).url
        responses.add(responses.GET, pbp_url, json=game_pbp_response, status=200)

        data_game_data = DataGameData(game_id, response_data_directory=None)
        data_game_data.get_pbp_events()

        stats_game_data = StatsGameData(game_id, response_data_directory=None)
        pbp_response = stats_game_data.get_pbp_response()
        events_list = stats_game_data.get_array_of_dicts_from_response(pbp_response, 0, dedupe=True)
        stats_game_data.set_period_events(events_list)

        for period in data_game_data.Periods:
            for event in period.Events:
                evt_num = event.number
                for stats_period in stats_game_data.Periods:
                    for stats_event in stats_period.Events:
                        if evt_num == stats_event.number:
github ramonsaraiva / pubg-python / tests / test_samples.py View on Github external
def test_match_filter_created_at_start(mock, samples_response):
    created_at = '2019-09-14T00:00:00Z'
    match_id = '3095f3be-a327-491c-be17-6e4823821b2e'
    url = furl(BASE_URL).join(ENDPOINT_PATH).add(
        {'filter[createdAt-start]': created_at}).url
    mock.get(url, json=samples_response)
    sample = api.samples().filter(created_at_start=created_at).get()
    match = sample.matches[0]
    assert isinstance(sample, Sample)
    assert isinstance(match, Match)
    assert match.id == match_id
github CenterForOpenScience / waterbutler / tests / providers / googlecloud / test_utils.py View on Github external
def test_build_and_sign_delete_url(self, mock_time, expires, mock_provider, file_2_obj_name):
        signed_url = mock_provider._build_and_sign_url('DELETE', file_2_obj_name, **{})
        url = furl.furl(signed_url)

        assert '{}://{}'.format(url.scheme, url.host) == mock_provider.BASE_URL
        assert url.path == '/{}/{}'.format(mock_provider.bucket, quote(file_2_obj_name, safe=''))
        assert int(url.args.get('Expires')) == expires
        assert url.args.get('GoogleAccessId') == mock_provider.creds.service_account_email
        assert url.args.get('Signature') == unquote(
            'euS%2FNjjQDP%2FYJtFa99WnEjlyi0MDZjruI9bnsqvrvl1ngSDDdpm99SNltETfJCpy7eE6hU6WKntXJj6Zfo'
            'qb0w%2B1J3Fn3h1VSZJGwMuHrLGcxLWfZ17Iix2DnqK%2BT%2BBxCgMSgckxPxupXwGhlftupn4hbRQe2ZUYpQ'
github allegroai / trains-agent / trains_agent / helper / repo.py View on Github external
"""
            return (
                None
                if user_ and user_.lower() in ["hg", "git"] and not password
                else user_
            )

        match = cls.SSH_URL_GIT_SYNTAX.match(url)
        if match:
            user, host, path = match.groups()
            return (
                furl()
                .set(scheme="https", username=get_username(user), host=host, path=path)
                .url
            )
        parsed_url = furl(url)
        if parsed_url.scheme == "ssh":
            return parsed_url.set(
                scheme="https",
                username=get_username(
                    parsed_url.username, password=parsed_url.password
                ),
            ).url
        return url
github theotherp / nzbhydra / nzbhydra / api.py View on Github external
def get_nzb_link_and_guid(searchResultId, external, downloader=None):
    externalUrl = config.settings.main.externalUrl
    if externalUrl and not (external and config.settings.main.useLocalUrlForApiAccess):
        f = furl(externalUrl)
    else:
        f = furl(get_root_url())
    f.path.add("getnzb")
    args = {"searchresultid": searchResultId}

    if external:
        apikey = config.settings.main.apikey
        if apikey is not None:
            args["apikey"] = apikey
    if downloader:
        args["downloader"] = downloader
    f.set(args=args)
    return f.url
github theotherp / nzbhydra / nzbhydra / searchmodules / nzbclub.py View on Github external
def build_base_url(self):
        f = furl(self.host)
        f.path.add("nzbrss.aspx")
        url = f.add({"ig": "2", "rpp": self.max_results, "st": 5, "ns": 1, "sn": 1})  # I need to find out wtf these values are

        return url
github CenterForOpenScience / osf.io / website / identifiers / clients / ezid.py View on Github external
def _build_url(self, *segments, **query):
        url = furl.furl(self.base_url)
        url.path.segments.extend(segments)
        url.args.update(query)
        return url.url
github theotherp / nzbhydra / nzbhydra / webaccess.py View on Github external
def getCleanProxyUrl(url):
    f = furl(url)
    return "%s://%s:%d" % (f.scheme, f.host, f.port)
github CenterForOpenScience / osf.io / website / identifiers / clients / crossref.py View on Github external
def _build_url(self, **query):
        url = furl.furl(self.base_url)
        url.args.update(query)
        return url.url

furl

URL manipulation made simple.

Unlicense
Latest version published 3 years ago

Package Health Score

76 / 100
Full package analysis

Popular furl functions