Skip to content

Commit 7d1a91e

Browse files
chore: convert Bunch to argparse.Namespace
This will simplify things in the future as `interact.py` returns either an `argparse.Namespace` or the return value of `parse_config_file()`. Now `parse_config_file()` will also return an `argparse.Namespace` object.
1 parent ee86def commit 7d1a91e

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

imapclient/config.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
# Released subject to the New BSD License
33
# Please see http://en.wikipedia.org/wiki/BSD_licenses
44

5+
import argparse
56
import configparser
67
import json
8+
import os
79
import ssl
810
import urllib.parse
911
import urllib.request
10-
from os import environ, path
1112

1213
import imapclient
1314

1415

1516
def getenv(name, default):
16-
return environ.get("imapclient_" + name, default)
17+
return os.environ.get("imapclient_" + name, default)
1718

1819

1920
def get_config_defaults():
@@ -92,9 +93,9 @@ def getfloat(name):
9293

9394
ssl_ca_file = get("ssl_ca_file")
9495
if ssl_ca_file:
95-
ssl_ca_file = path.expanduser(ssl_ca_file)
96+
ssl_ca_file = os.path.expanduser(ssl_ca_file)
9697

97-
return Bunch(
98+
return argparse.Namespace(
9899
host=get("host"),
99100
port=getint("port"),
100101
ssl=getboolean("ssl"),
@@ -200,14 +201,3 @@ def create_client_from_config(conf, login=True):
200201
except: # noqa: E722
201202
client.shutdown()
202203
raise
203-
204-
205-
class Bunch(dict):
206-
def __getattr__(self, k):
207-
try:
208-
return self[k]
209-
except KeyError:
210-
raise AttributeError
211-
212-
def __setattr__(self, k, v):
213-
self[k] = v

0 commit comments

Comments
 (0)