Skip to content

Instantly share code, notes, and snippets.

View cluelessperson's full-sized avatar

Clueless cluelessperson

View GitHub Profile
@staticmethod
def _get_cli_config():
for i, arg in enumerate(sys.argv):
if "--" in arg and len(sys.argv)-1 > i:
key = arg[2:]
value = sys.argv[i+1]
yield (key, value)
class Config(object):
def __init__(self, parent_logger:logging.Logger=logger):
self.log = parent_logger.getChild(self.__class__.__name__)
self.config = {}
print("here")
def __getattr__(self, attr):
try:
return self.config[attr]
except IndexError:
import logging, pathlib, json, sys, subprocess, os
from .logging import root_logger as logger
class Config(object):
def __init__(self, parent_logger:logging.Logger=logger):
self.log = parent_logger.getChild(self.__class__.__name__)
self.config = {"log_level": "INFO"}
def __getattr__(self, attr):
import sys, subprocess, os, pathlib, json
import fbf
def _get_cli_config_file():
if ".json" in sys.argv[-1]:
return sys.argv[-1]
def _get_cli_config():
import logging, pathlib, json, sys, subprocess, os
from .. import version
from .logging import root_logger as logger
class Config(object):
def __init__(self, parent_logger=logger):
self.log = parent_logger.getChild(self.__class__.__name__)
self.config = {"log_level": "INFO"}
from .util.logging import root_logger as logger
from .util.config import FileConfig, GCloudFileConfig, EnvironmentalVariableConfig, CliConfig, ConfigCombiner
config = ConfigCombiner(
[
FileConfig,
GCloudFileConfig,
EnvironmentalVariableConfig,
CliConfig
],
import logging, pathlib, json, sys, subprocess, os
from .. import version
from .logging import root_logger as logger
class Config(object):
def __init__(self):
self.config = {"log_level": "INFO"}
def __getattr__(self, attr):
def coerce_number(s, zero_if_fail=False):
s = s.strip()
try:
return int(s)
except ValueError:
try:
return float(s)
except ValueError:
if zero_if_fail:
return 0
"board": [
{
"lvl1": 1 if 0 <= i <= 7 else 0,
"lvl2": 1 if 8 <= i <= 15 else 0,
"lvl3": 1 if 16 <= i <= 23 else 0,
"lvl4": 1 if 24 <= i <= 31 else 0
}
for i in range(32)
]
default_state = {
"turn": 1,
"player_count": 1,
"players": [
{
"score": 0,
"depth": 0,
"turned_back": False,
"haul": {
"stacks": 0,