File tree Expand file tree Collapse file tree 1 file changed +41
-4
lines changed Expand file tree Collapse file tree 1 file changed +41
-4
lines changed Original file line number Diff line number Diff line change 15
15
from collections import defaultdict , namedtuple
16
16
import warnings
17
17
import random
18
- # import json # unused
18
+ import json # unused
19
+ import yaml
19
20
from functools import wraps
20
21
import time
21
22
import pickle
22
23
import tempfile
24
+ import copy
23
25
from pathlib import Path
24
26
from configparser import ConfigParser
25
27
from typing import List , Dict , Tuple , Sequence
44
46
# pyximport.install()
45
47
# import .c.cfit
46
48
49
+ defaults = {
50
+ 'record_points' : "points"
51
+ }
52
+
53
+ settings = copy .copy (defaults )
54
+
55
+
56
+ def configure (reset : bool = False ):
57
+ """Configuration file parsing
58
+
59
+ Read a configuration file .corerc from one of the standard locations
60
+ in the following order of priority:
61
+
62
+ - current working directory
63
+ - user home directory
64
+ """
65
+
66
+ global defaults
67
+ global settings
68
+
69
+ if reset :
70
+ settings .update (defaults )
71
+ else :
72
+ cwd_rc = Path .cwd () / ".corerc"
73
+ if cwd_rc .is_file ():
74
+ # load yaml
75
+ # update settings
76
+ return
77
+
78
+ home_rc = Path .home () / ".corerc"
79
+ if home_rc .is_file ():
80
+ return
81
+
82
+ # print("No configuration file found. Using defaults.")
83
+
47
84
48
- def configure ():
85
+ def configure_deprecated ():
49
86
"""Read options from configuration file
50
87
"""
51
88
52
89
CWD = Path .cwd ()
53
- CWD_CONFIG = Path (f"{ CWD } /.cnnrc " )
90
+ CWD_CONFIG = Path (f"{ CWD } /.corerc " )
54
91
HOME = Path .home ()
55
- HOME_CONFIG = Path (f"{ HOME } /.cnnrc " )
92
+ HOME_CONFIG = Path (f"{ HOME } /.corerc " )
56
93
57
94
config_ = ConfigParser (default_section = "settings" )
58
95
config_template = ConfigParser (
You can’t perform that action at this time.
0 commit comments