simfile.tidy.behaviors

Classes

Preset

A predefined set of behaviors for use with tidy().

Whitespace

Normalize all whitespace in the file.

LineEndings

Normalize all line endings in the file.

ChangeComments

Add or remove comments from various parts of the simfile.

CreateMissingProperties

Fill in any missing properties in the simfile with a default value.

DestructivelyRemoveProperties

Remove any unknown properties (a destructive operation).

SortProperties

Sort the properties in the simfile.

Module Contents

class simfile.tidy.behaviors.Preset(*args, **kwds)

Bases: enum.Enum

A predefined set of behaviors for use with tidy().

NO_OP

Leave all optional behaviors off by default.

This is equivalent to not specifying a preset, except it allows you to leave all optional behaviors False.

SM5

Emulate the StepMania 5 editor’s output (nondestructively).

SM5_DESTRUCTIVE

Emulate the StepMania 5 editor’s output (including removing unknown properties).

RECOMMENDED

Same as SM5, but keep the preamble & add or update the library version.

behaviors() DefaultBehaviors
class simfile.tidy.behaviors.Whitespace(*args, **kwds)

Bases: enum.Enum

Normalize all whitespace in the file.

SM5

Normalize whitespace to match StepMania 5’s output:

  • Properties are separated by a newline.

  • Each chart is prefixed by a blank line.

  • Each SM chart property (before note data) is prefixed by 5 spaces.

Currently, this option removes comments inside of SM charts if their whitespace is adjusted. Combine with ChangeComments to regenerate measure comments if desired.

run(sim: simfile.types.Simfile) bool
class simfile.tidy.behaviors.LineEndings(*args, **kwds)

Bases: enum.Enum

Normalize all line endings in the file.

LF

Normalize all line endings to ‘n’.

CRLF

Normalize all line endings to ‘rn’.

HEURISTIC

Use the heuristic-determined line ending.

This typically matches the first line ending seen in the file.

run(sim: simfile.types.Simfile) bool
class simfile.tidy.behaviors.ChangeComments(*args, **kwds)

Bases: enum.Flag

Add or remove comments from various parts of the simfile.

REMOVE_PREAMBLE

Remove any preamble (comment at the start of the file).

REMOVE_CHART_PREAMBLE

Remove any chart preamble (comment before the first property signaling a chart, i.e. NOTES for SM and NOTEDATA for SSC).

REMOVE_CHART_INNER

Remove any comments inside a chart, such as (but not limited to) measure indicators.

REMOVE_OTHER

Remove any other comments that don’t match the above definitions.

REMOVE_ALL

Remove all comments.

This is equivalent to combining all of the above flags using the bitwise | operator.

ADD_LIBRARY_VERSION_PREAMBLE

Create a comment at the start of the file with the following string:

// Generated by simfile {VERSION} for Python

{VERSION} is replaced with the library’s version specifier. If such a comment already exists, it will be updated with the library’s current version.

ADD_CHART_PREAMBLE

Create a comment before each chart with the following string:

//---------------{STEPSTYPE} - {DESCRIPTION}----------------

{STEPSTYPE} is replaced with stepstype and {DESCRIPTION} is replaced with description. If such a comment already exists, it will be updated to reflect the chart’s current properties.

ADD_CHART_MEASURES

Create comments before each measure to indicate the measure number:

#NOTES:
// measure 0
0000
0000
0000
0000
,  // measure 1
(etc.)
ADD_ALL

Create all available types of supported comments.

This is equivalent to combining all of the above flags using the bitwise | operator.

run(sim: simfile.types.Simfile) bool
class simfile.tidy.behaviors.CreateMissingProperties(*args, **kwds)

Bases: enum.Enum

Fill in any missing properties in the simfile with a default value.

SM5

Create the same default properties that the StepMania 5 editor creates, if they don’t already exist.

Most properties’ default values are an empty string, but some have a specific non-empty default value, such as OFFSET and BPMS.

run(sim: simfile.types.Simfile) bool
class simfile.tidy.behaviors.DestructivelyRemoveProperties(*args, **kwds)

Bases: enum.Enum

Remove any unknown properties (a destructive operation).

SM5

Remove all properties that are unknown to the StepMania 5 editor.

run(sim: simfile.types.Simfile) bool
class simfile.tidy.behaviors.SortProperties(*args, **kwds)

Bases: enum.Enum

Sort the properties in the simfile.

SM5

Sort known properties to match the StepMania 5 editor’s output.

Unknown properties, if not removed, are sorted alphabetically after known properties.

run(sim: simfile.types.Simfile) bool