pyplanet.utils

pyplanet.utils.gbxparser

exception pyplanet.utils.gbxparser.GbxException[source]

Exception with parsing the Gbx file.

class pyplanet.utils.gbxparser.GbxParser(file=None, buffer=None)[source]

Async GBX Map Information Parser.

Author: Toffe.

seek(offset)[source]

We need to override the second param to move from the current position.

Parameters:offset (int) – offset to move away.

pyplanet.utils.style

pyplanet.utils.style.STRIP_ALL = {'letters': 'wnoitsgz<>', 'part': '\\$[lh]\\[.+\\]|\\$[lh]|\\$[0-9a-f]{3}'}

Strip all custom maniaplanet styles + formatting.

pyplanet.utils.style.STRIP_CAPITALS = {'letters': 't'}

Strip capital style ($t).

pyplanet.utils.style.STRIP_COLORS = {'letters': 'g', 'part': '\\$[0-9a-f]{3}'}

Strip colors from your input (including $g, color reset).

Strip links ($h and $l).

pyplanet.utils.style.STRIP_SHADOWS = {'letters': 's'}

Strip shadow style ($s).

pyplanet.utils.style.STRIP_SIZES = {'letters': 'wnoiz'}

Strip all size and adjustments styles ($w $n $o $i $z).

pyplanet.utils.style.style_strip(text, *strip_methods, strip_styling_blocks=True, keep_reset=False, keep_color_reset=False)[source]

Strip styles from the Maniaplanet universe.

Examples:

print("--- Strip: colours ---")
print(style_strip("$i$fffMax$06fSmurf$f00.$fffes$$l$09f.$fffm$08f$a5x$n$w$o", STRIP_COLORS))
print(style_strip("$l[some link]$i$FFFMax$06fSmurf$f00.$fffesl$09f.$fffm$08fx$l", STRIP_COLORS))
print(style_strip("$l[some link]$i$fffMax$06fSmurf$f00.$fffesl$09f.$fffm$08fx", STRIP_COLORS))
print("--- Strip: links ---")
print(style_strip("$l$i$fffMax$06fSmurf$f00.$fffesl$09f.$fffm$08f$a5x$l", STRIP_LINKS))
print(style_strip("$i$fffMax$06fSmurf$f00.$fffesl$09f.$fffm$08f$a5x", STRIP_LINKS))
print(style_strip("$l[some link]$i$fffMax$06fSmurf$f00.$fffes$$l$09f.$fffm$08fx$l", STRIP_LINKS))
print(style_strip("$l[some link]$i$fffMax$06fSmurf$f00.$fffesl$09f.$fffm$08fx", STRIP_LINKS))
print("--- Strip: sizes ---")
print(style_strip("$i$n$fffMax$06fSmurf$f00.$w$o$fffe$$nsl$09f.$w$fffm$08f$a5$ox", STRIP_SIZES))
print("--- Strip: everything ---")
print(style_strip("$h$i$fffMax$06fSmurf$f00.$fffesl$09f.$fffm$08f$a5x$h", STRIP_ALL))
print(style_strip("$l[some link]$i$fffMax$06fSmur$$f$f00.$fffesl$09f.$fffm$08fx$l"))
print(style_strip("$l[some link]$i$fffMax$06fSmu$nrf$f00.$fffesl$09f.$fffm$08fx"))
# Other stuff.:
print(style_strip("$l[some link]$i$fffMax$06fSmu$nrf$f00.$fffesl$09f.$fffm$08fx", STRIP_CAPITALS, STRIP_SHADOWS))

.

Parameters:
  • text (str) – The input string text.
  • strip_methods – Methods for stripping, use one of the STRIP_* constants or leave undefined to strip everything.
  • strip_styling_blocks (bool) – Strip all styling blocks ($> and $<)
  • keep_reset (bool) – Keep full resets ($z).
  • keep_color_reset (bool) – Keep color resets ($g).
Returns:

Stripped style string.

Return type:

str

pyplanet.utils.times

pyplanet.utils.times.format_time(time, hide_hours_when_zero=True, hide_milliseconds=False)[source]

Format time from integer milliseconds to string format that could be displayed to the end-user.

Parameters:
  • time (int) – Integer time in milliseconds.
  • hide_hours_when_zero (bool) – Hide the hours when there are zero hours.
  • hide_milliseconds (bool) – Hide the milliseconds.
Returns:

String output

Return type:

str