formatter Package

formatter Package

class formatter.Formatter

Bases: object

format_directory(directory)
format_file(name)
format_path(path, recursive=False)
classmethod format_string(string)
class formatter.Token(offsets, tok_type, token, begin, end, line)

Bases: object

begin

The begin coordinates.

Settings this to a tuple will set the first to the row and the latter to the col.

This returns a SmartList with the row and the column.

begin_col

The begin column.

begin_row

The begin row.

col

The column.

Setting this to a tuple will set the first to the begin and the latter to the end.

This returns a SmartList with the begin and end column.

end

The end.

Settings this to a tuple will set the first to the row and the latter to the col.

This returns a SmartList with the row and column.

end_col

The end column.

end_row

The end row.

line

The line.

Setting the line automatically updates the column as well.

Returns a str() object with the line.

preprocess()

formatter.types.TokenType.preprocess()

row

The row.

Setting this to a tuple will set the first to the begin and the latter to the end.

This returns a SmartList with the begin and end row.

type
class formatter.Tokens(readline)

Bases: object

format()

Format the string, expects the extra whitespace to be removed already

classmethod from_fh(fh)
classmethod from_readline(readline)
generate_tokens(readline)
strip()

Strip all whitespace so we can begin formatting

to_str()

Convert the tokens back to a string

class formatter.TokenOffsets(parent, default_type=None)

Bases: dict

get(key, recurse=False)
get_key(key)
class formatter.TokenOffset(parent, type_, token, pre=0, post=0, children=None, end=None)

Bases: object

copy(type_=None, token=None)
end

Set the end token in case of children.

Should either be a token or a tuple with TokenType and token which will be a string.

parent

The parent. TokenOffsets

surround

Surround the token with this amount of space. Setting will set the pre and post when given a tuple or int().

type

The type. TokenType

class formatter.DefaultTokenOffset(parent=None)

Bases: formatter.offsets.TokenOffset

pprint(stream=<open file '<stderr>', mode 'w' at 0x7f8e290af270>)

formatter Module

class formatter.formatter.Formatter[source]

Bases: object

format_directory(directory)[source]
format_file(name)[source]
format_path(path, recursive=False)[source]
classmethod format_string(string)[source]

main Module

formatter.main.main(*argv)[source]

offsets Module

class formatter.offsets.DefaultTokenOffset(parent=None)[source]

Bases: formatter.offsets.TokenOffset

pprint(stream=<open file '<stderr>', mode 'w' at 0x7f8e290af270>)[source]
class formatter.offsets.TokenOffset(parent, type_, token, pre=0, post=0, children=None, end=None)[source]

Bases: object

copy(type_=None, token=None)[source]
end

Set the end token in case of children.

Should either be a token or a tuple with TokenType and token which will be a string.

parent

The parent. TokenOffsets

surround

Surround the token with this amount of space. Setting will set the pre and post when given a tuple or int().

type

The type. TokenType

class formatter.offsets.TokenOffsets(parent, default_type=None)[source]

Bases: dict

get(key, recurse=False)[source]
get_key(key)[source]
formatter.offsets.get_token_offsets()[source]

tokens Module

class formatter.tokens.SmartList(*items, **kwargs)[source]

Bases: list

copy()[source]
set(value)[source]
class formatter.tokens.Token(offsets, tok_type, token, begin, end, line)[source]

Bases: object

begin

The begin coordinates.

Settings this to a tuple will set the first to the row and the latter to the col.

This returns a SmartList with the row and the column.

begin_col

The begin column.

begin_row

The begin row.

col

The column.

Setting this to a tuple will set the first to the begin and the latter to the end.

This returns a SmartList with the begin and end column.

end

The end.

Settings this to a tuple will set the first to the row and the latter to the col.

This returns a SmartList with the row and column.

end_col

The end column.

end_row

The end row.

line

The line.

Setting the line automatically updates the column as well.

Returns a str() object with the line.

preprocess()[source]

formatter.types.TokenType.preprocess()

row

The row.

Setting this to a tuple will set the first to the begin and the latter to the end.

This returns a SmartList with the begin and end row.

type[source]
class formatter.tokens.Tokens(readline)[source]

Bases: object

format()[source]

Format the string, expects the extra whitespace to be removed already

classmethod from_fh(fh)[source]
classmethod from_readline(readline)[source]
generate_tokens(readline)[source]
strip()[source]

Strip all whitespace so we can begin formatting

to_str()[source]

Convert the tokens back to a string

types Module

class formatter.types.DefaultTokenType[source]

Bases: formatter.types.TokenType

class formatter.types.StringTokenType(id_, name)[source]

Bases: formatter.types.TokenType

name = 'STRING'
preprocess(token)[source]

Preprocess the token

This automatically replaces strings with ” to ‘ if possible

class formatter.types.TokenType(id_, name)[source]

Bases: object

get_keys()[source]
preprocess(token)[source]

Preprocess the token, this can do pretty much anything including changing the column

class formatter.types.TokenTypes[source]

Bases: dict

register(token_type)[source]
formatter.types.get_token_types()[source]

Table Of Contents

Related Topics

This Page