spotifywebapipython.sautils

def GetUnixTimestampMSFromUtcNow(days: int = 0, hours: int = 0, minutes: int = 0, seconds: int = 0) -> int:

Returns a Unix millisecond timestamp value from the current utc datetime for the difference specified by input arguments.

def static_init(cls):

Define the decorator used to call an initializer for a class with all static methods. This allows static variables to be initialized one time for the class.

def export(fn):

Define the decorator used to modify a module's "__all__" variable. This avoids us having to manually modify a module's "__all__" variable when adding new classes.

class Event:

C# like event processing in Python3.

View Sample Code

# Define the class that will be raising events:
class MyFileWatcher:
    def __init__(self):
        self.fileChanged = Event()      # define event

    def watchFiles(self):
        source_path = "foo"
        self.fileChanged(source_path)   # fire event

def log_file_change(source_path):       # event handler 1
    print "%r changed." % (source_path,)

def log_file_change2(source_path):      # event handler 2
    print "%r changed!" % (source_path,)

# Define the code that will be handling raised events.
watcher              = MyFileWatcher()
watcher.fileChanged += log_file_change2
watcher.fileChanged += log_file_change
watcher.fileChanged -= log_file_change2
watcher.watchFiles()

Event(*args)

Initializes a new instance of the class.

handlers
def fire(self, *args, **kargs):

Calls (i.e. "fires") all method handlers defined for this event.

def getHandlerCount(self):

Returns the number of method handlers defined for this event.

def handle(self, handler):

Adds a method handler for this event.

def unhandle(self, handler):

Removes the specified method handler for this event.

Arguments:
  • handler (object): The method handler to remove.

This method will not throw an exception.

def unhandle_all(self):

Removes all method handlers (if any) for this event.

This method will not throw an exception.