1
- import configparser as ConfigParser
2
1
import hashlib
3
2
import logging
4
3
import os
5
4
import shlex
6
5
import sys
7
6
import typing
8
7
import warnings
8
+ from configparser import (
9
+ ConfigParser ,
10
+ InterpolationError ,
11
+ NoOptionError ,
12
+ NoSectionError ,
13
+ RawConfigParser ,
14
+ )
9
15
from functools import wraps
10
16
from io import StringIO
11
17
@@ -195,9 +201,9 @@ def fetch_val_for_key(self, key, delete_key=False):
195
201
try :
196
202
try :
197
203
return self ._theano_cfg .get (section , option )
198
- except ConfigParser . InterpolationError :
204
+ except InterpolationError :
199
205
return self ._theano_raw_cfg .get (section , option )
200
- except (ConfigParser . NoOptionError , ConfigParser . NoSectionError ):
206
+ except (NoOptionError , NoSectionError ):
201
207
raise KeyError (key )
202
208
203
209
def change_flags (self , * args , ** kwargs ) -> _ChangeFlagsDecorator :
@@ -494,7 +500,7 @@ def _create_default_config():
494
500
THEANO_FLAGS_DICT = parse_config_string (THEANO_FLAGS , issue_warnings = True )
495
501
496
502
config_files = config_files_from_theanorc ()
497
- theano_cfg = ConfigParser . ConfigParser (
503
+ theano_cfg = ConfigParser (
498
504
{
499
505
"USER" : os .getenv ("USER" , os .path .split (os .path .expanduser ("~" ))[- 1 ]),
500
506
"LSCRATCH" : os .getenv ("LSCRATCH" , "" ),
@@ -508,7 +514,7 @@ def _create_default_config():
508
514
# Having a raw version of the config around as well enables us to pass
509
515
# through config values that contain format strings.
510
516
# The time required to parse the config twice is negligible.
511
- theano_raw_cfg = ConfigParser . RawConfigParser ()
517
+ theano_raw_cfg = RawConfigParser ()
512
518
theano_raw_cfg .read (config_files )
513
519
514
520
# Instances of TheanoConfigParser can have independent current values!
0 commit comments