-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from typing import Union | ||
|
||
from application.config import Config | ||
|
||
|
||
def config_init( | ||
sigfigs: int = Config.sigfigs_default, | ||
decimal_places: int = Config.decimal_places_default, | ||
print_always: bool = Config.print_always_default, | ||
): | ||
c = Config(sigfigs, decimal_places, print_always) | ||
print(c.to_json_str()) | ||
return c | ||
|
||
|
||
configuration = config_init() | ||
|
||
|
||
def config( | ||
sigfigs: Union[int, None] = None, | ||
decimal_places: Union[int, None] = None, | ||
print_always: Union[bool, None] = None, | ||
): | ||
if sigfigs is not None: | ||
configuration.sigfigs = sigfigs | ||
if decimal_places is not None: | ||
configuration.decimal_places = decimal_places | ||
if print_always is not None: | ||
configuration.print_always = print_always | ||
|
||
print(configuration.to_json_str()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import json | ||
|
||
|
||
class Config: | ||
"""Configuration settings for the application.""" | ||
|
||
sigfigs_default = 2 | ||
decimal_places_default = 2 | ||
print_always_default = False | ||
|
||
def __init__( | ||
self, | ||
sigfigs=sigfigs_default, | ||
decimal_places=decimal_places_default, | ||
print_always=print_always_default, | ||
): | ||
self.sigfigs = sigfigs | ||
self.decimal_places = decimal_places | ||
self.print_always = print_always | ||
|
||
def to_json_str(self): | ||
return json.dumps(self.__dict__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from api.config import config_init, config | ||
from api.res import res | ||
from api.export import export | ||
from application.cache import _ResultsCache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters