certbot_nginx.nginxparser

Very low-level nginx config parser based on pyparsing.

class certbot_nginx.nginxparser.RawNginxParser(source)[source]

Bases: object

A class that parses nginx configuration with pyparsing.

parse()[source]

Returns the parsed tree.

as_list()[source]

Returns the parsed tree as a list.

class certbot_nginx.nginxparser.RawNginxDumper(blocks)[source]

Bases: object

A class that dumps nginx configuration from the provided tree.

certbot_nginx.nginxparser.loads(source)[source]

Parses from a string.

Parameters:source (str) – The string to parse
Returns:The parsed tree
Return type:list
certbot_nginx.nginxparser.load(_file)[source]

Parses from a file.

Parameters:_file (file) – The file to parse
Returns:The parsed tree
Return type:list
certbot_nginx.nginxparser.dumps(blocks)[source]

Dump to a string.

Parameters:
  • block (UnspacedList) – The parsed tree
  • indentation (int) – The number of spaces to indent
Return type:

str

certbot_nginx.nginxparser.dump(blocks, _file)[source]

Dump to a file.

Parameters:
  • block (UnspacedList) – The parsed tree
  • _file (file) – The file to dump to
  • indentation (int) – The number of spaces to indent
Return type:

NoneType

class certbot_nginx.nginxparser.UnspacedList(list_source)[source]

Bases: list

Wrap a list [of lists], making any whitespace entries magically invisible

_coerce(inbound)[source]

Coerce some inbound object to be appropriately usable in this object

Parameters:inbound – string or None or list or UnspacedList
Returns:(coerced UnspacedList or string or None, spaced equivalent)
Return type:tuple
insert(i, x)[source]

L.insert(index, object) – insert object before index

append(x)[source]

L.append(object) – append object to end

extend(x)[source]

L.extend(iterable) – extend list by appending elements from the iterable

pop([index]) → item -- remove and return item at index (default last).[source]

Raises IndexError if list is empty or index is out of range.

remove(_)[source]

L.remove(value) – remove first occurrence of value. Raises ValueError if the value is not present.

reverse()[source]

L.reverse() – reverse IN PLACE

sort(_cmp=None, _key=None, _Rev=None)[source]

L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; cmp(x, y) -> -1, 0, 1

is_dirty()[source]

Recurse through the parse tree to figure out if any sublists are dirty

_spaced_position(idx)[source]

Convert from indexes in the unspaced list to positions in the spaced one