re-run through ruff formatter

This commit is contained in:
Onyx and Iris 2025-01-20 13:32:36 +00:00
parent 0b67bcd832
commit 3555d5fe6c
4 changed files with 42 additions and 36 deletions

View File

@ -2,30 +2,30 @@ import streamlabsio
def on_youtube_event(event, data):
print(f"{event}: {data.attrs()}")
print(f'{event}: {data.attrs()}')
def on_twitch_event(event, data):
if event == "follow":
print(f"Received follow from {data.name}")
elif event == "bits":
print(f"{data.name} donated {data.amount} bits! With message: {data.message}")
elif event == "donation":
if event == 'follow':
print(f'Received follow from {data.name}')
elif event == 'bits':
print(f'{data.name} donated {data.amount} bits! With message: {data.message}')
elif event == 'donation':
print(
f"{data.name} donated {data.formatted_amount}! With message: {data.message}"
f'{data.name} donated {data.formatted_amount}! With message: {data.message}'
)
def main():
# read token from config.toml
with streamlabsio.connect() as client:
client.obs.on("streamlabs", on_twitch_event)
client.obs.on("twitch_account", on_twitch_event)
client.obs.on("youtube_account", on_youtube_event)
client.obs.on('streamlabs', on_twitch_event)
client.obs.on('twitch_account', on_twitch_event)
client.obs.on('youtube_account', on_youtube_event)
# run for 30 seconds then disconnect client from server
client.sio.sleep(30)
if __name__ == "__main__":
if __name__ == '__main__':
main()

View File

@ -4,47 +4,53 @@ import streamlabsio
config.dictConfig(
{
"version": 1,
"formatters": {
"standard": {
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
'version': 1,
'disable_existing_loggers': False,
'loggers': {
'streamlabsio.client': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
}
},
"handlers": {
"stream": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "standard",
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'simple',
'stream': 'ext://sys.stdout',
}
},
"loggers": {"streamlabsio.client": {"handlers": ["stream"], "level": "DEBUG"}},
'formatters': {
'simple': {'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'}
},
}
)
def on_youtube_event(event, data):
print(f"{event}: {data.attrs()}")
print(f'{event}: {data.attrs()}')
def on_twitch_event(event, data):
if event == "follow":
print(f"Received follow from {data.name}")
elif event == "bits":
print(f"{data.name} donated {data.amount} bits! With message: {data.message}")
elif event == "donation":
if event == 'follow':
print(f'Received follow from {data.name}')
elif event == 'bits':
print(f'{data.name} donated {data.amount} bits! With message: {data.message}')
elif event == 'donation':
print(
f"{data.name} donated {data.formatted_amount}! With message: {data.message}"
f'{data.name} donated {data.formatted_amount}! With message: {data.message}'
)
def main():
with streamlabsio.connect() as client:
client.obs.on("streamlabs", on_twitch_event)
client.obs.on("twitch_account", on_twitch_event)
client.obs.on("youtube_account", on_youtube_event)
client.obs.on('streamlabs', on_twitch_event)
client.obs.on('twitch_account', on_twitch_event)
client.obs.on('youtube_account', on_youtube_event)
client.sio.sleep(30)
if __name__ == "__main__":
if __name__ == '__main__':
main()

View File

@ -4,5 +4,5 @@ from pathlib import Path
def ex_debug():
scriptpath = Path.cwd() / "examples" / "debug" / "."
scriptpath = Path.cwd() / 'examples' / 'debug' / '.'
subprocess.run([sys.executable, str(scriptpath)])

View File

@ -3,7 +3,7 @@ from dataclasses import dataclass
def to_snake_case(s):
return re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()
return re.sub(r'(?<!^)(?=[A-Z])', '_', s).lower()
def as_dataclass(identifier, data):
@ -12,10 +12,10 @@ def as_dataclass(identifier, data):
return dataclass(
type(
f"{identifier.capitalize()}Dataclass",
f'{identifier.capitalize()}Dataclass',
(),
{
"attrs": attrs,
'attrs': attrs,
**{to_snake_case(k): v for k, v in data.items()},
},
)