Utilities

These utilities are provided to make working with certain types of data a bit easier.

DepotFile

class sc2reader.utils.DepotFile(bytes)
Parameters:bytes – The raw bytes representing the depot file

The DepotFile object parses bytes for a dependency into their components and assembles them into a URL so that the dependency can be fetched.

url

Returns url of the depot file.

Color

class sc2reader.utils.Color(name=None, r=0, g=0, b=0, a=255)

Stores a color name and rgba representation of a color. Individual color components can be retrieved with the dot operator:

color = Color(r=255, g=0, b=0, a=75)
tuple(color.r,color.g, color.b, color.a) == color.rgba

You can also create a color by name.

color = Color(‘Red’)

Only standard Starcraft colors are supported. ValueErrors will be thrown on invalid names or hex values.

hex

The hexadecimal representation of the color

rgba

Returns a tuple containing the color’s (r,g,b,a)

Length

class sc2reader.utils.Length

Extends the builtin timedelta class. See python docs for more info on what capabilities this gives you.

hours

The number of hours in represented.

mins

The number of minutes in excess of the hours.

secs

The number of seconds in excess of the minutes.

PersonDict

AttributeDict

get_files

sc2reader.utils.get_files(path, exclude=[], depth=-1, followlinks=False, extension=None, **extras)

Retrieves files from the given path with configurable behavior.

Parameters:
  • path – Path to search for files
  • depth – Limits the depth of the search. -1 = Unlimited
  • followLinks – Enables the search to follow links.
  • exclude – Excludes subdirectories with names in this list.
  • extension – Restricts results to files matching the given extension.”