Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_post_parse_plus(self):
v = self.v
v.operator = '+'
v.post_parse()
self.assertEqual(v.join_str, ',')
self.assertEqual(v.safe, variable.URIVariable.reserved)
self.assertEqual(v.start, '')
def parse(self):
"""Parse the variable.
This finds the:
- operator,
- set of safe characters,
- variables, and
- defaults.
"""
var_list = self.original
if self.original[0] in URIVariable.operators:
self.operator = self.original[0]
var_list = self.original[1:]
if self.operator in URIVariable.operators[:2]:
self.safe = URIVariable.reserved
var_list = var_list.split(',')
for var in var_list:
default_val = None
name = var
if '=' in var:
name, default_val = tuple(var.split('=', 1))
explode = False
if name.endswith('*'):
explode = True
name = name[:-1]
prefix = None
def __init__(self, uri):
#: The original URI to be parsed.
self.uri = uri
#: A list of the variables in the URI. They are stored as
#: :class:`URIVariable`\ s
self.variables = [
URIVariable(m.groups()[0]) for m in template_re.finditer(self.uri)
]
#: A set of variable names in the URI.
self.variable_names = OrderedSet()
for variable in self.variables:
for name in variable.variable_names:
self.variable_names.add(name)