2021-04-27 21:39:28 +00:00
|
|
|
from __future__ import division
|
|
|
|
|
2021-04-23 11:36:27 +00:00
|
|
|
from six import iteritems
|
|
|
|
|
|
|
|
|
2021-04-27 21:16:30 +00:00
|
|
|
def is_absolute(url):
|
|
|
|
return url.startswith('//') or '://' in url
|
|
|
|
|
|
|
|
|
2021-04-23 11:36:27 +00:00
|
|
|
def get_server_default_variables(server):
|
|
|
|
if 'variables' not in server:
|
|
|
|
return {}
|
|
|
|
|
|
|
|
defaults = {}
|
|
|
|
variables = server / 'variables'
|
|
|
|
for name, variable in iteritems(variables):
|
|
|
|
defaults[name] = variable['default']
|
|
|
|
return defaults
|
|
|
|
|
|
|
|
|
|
|
|
def get_server_url(server, **variables):
|
|
|
|
if not variables:
|
|
|
|
variables = get_server_default_variables(server)
|
|
|
|
return server['url'].format(**variables)
|