Welcome to surly’s documentation!

Contents:

class surly.re_parse.JavascriptReverser[source]

Super-quick javascript reverser. Generates an anonymous function which can take an object as a parameter and produce a URL. Since URLs are not user generated, there is no effort to stop cross-site scripting

add_literal(char)[source]

Append a literal character to the JS expression. The function handles single and double quotes.

add_named_group(name)[source]

Add a named group to the JS expression, having it append fields[“name”]

Parameters:name (string) – the name of the capture group
value()[source]

Returns the anonymous JS function built up over the course of parsing

Return type:string
class surly.re_parse.PythonReverser[source]

Python format string reverser. Generates a python format string which will produce a URL.

add_literal(char)[source]

Append a literal character to the format string

add_named_group(name)[source]

Add a variable to the format string group to the JS expression (e.g. {name})

Parameters:name (string) – the name of the capture group
surly.re_parse.reverse(re_str, kwargs)[source]

reverse interpolates kwargs values into their respective named capture groups within re_str.

Parameters:
  • re_str – A Python string (raw strings are recommended) representing the regular expression to be reversed.
  • kwargs – A dictionary mapping capture group names to the value that should be interpolated into the capture expression.
surly.re_parse.reverse_template(re_str)[source]

Turn a regular expression into a python format string

Parameters:re_str (string) – the regular expression
surly.re_parse.reverse_template_js(re_str)[source]

Turn a regular expression into an anonymous JS function which can be used to generate URLs

Parameters:re_str (string) – the regular expression

Indices and tables

Project Versions

Table Of Contents

This Page