Skip to content

Commit 3c957b5

Browse files
author
Clark Perkins
committed
Fixed logic error in config object
1 parent 716ae06 commit 3c957b5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

stackdio/cli/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
4-
53
import os
64

75
import click

stackdio/client/config.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,26 @@ class StackdioConfig(object):
4646
str(False): False,
4747
}
4848

49-
def __init__(self, config_file=CFG_FILE, section='main'):
49+
def __init__(self, config_file=CFG_FILE, section='stackdio'):
5050
super(StackdioConfig, self).__init__()
5151

5252
self.section = section
5353

5454
self._cfg_file = config_file
5555

56-
self.usable_config = os.path.isfile(config_file)
57-
5856
self._config = ConfigParser()
5957

60-
if not self.usable_config:
61-
self._config.add_section(section)
62-
else:
58+
self.usable_file = os.path.isfile(self._cfg_file)
59+
60+
if self.usable_file:
6361
self._config.read(config_file)
6462

63+
self.usable_section = self._config.has_section(self.section)
64+
self.usable_config = self.usable_file and self.usable_section
65+
66+
if not self.usable_section:
67+
self._config.add_section(section)
68+
6569
def save(self):
6670
with open(self._cfg_file, 'w') as f:
6771
self._config.write(f)

0 commit comments

Comments
 (0)