Script to get a photo of what's going on in Blaseball and copy it to the clipboard. (IP Webcam hook)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

import re
import os
def attempt_import_config() -> dict:
Attempt to import the config file
If missing, attempt to recover by copying
# Attempt normal import
from config import config
except ModuleNotFoundError as e:
config_error = e
return config
# If missing, copy config from to and try again
# Get text from sample config file, but remove comment at top saying to
# rename to
with open('') as sample:
text = ''.join(re.split(r'\n(config)',, re.MULTILINE)[-2:])
# Create new config file
with open('', 'w') as new_config:
print(text, file=new_config)
# Import new file
from config import config
# Delete any malformed config that may have been generated
except FileNotFoundError:
return config
# Raise *original* exception saying is missing
raise config_error
config = attempt_import_config()