Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configuration inside 'setup.cfg' #161

Merged
merged 4 commits into from
Jun 22, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions green/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,10 @@ def getConfig(filepath=None): # pragma: no cover
filepaths.append(env_filepath)

# Medium priority
cwd_filepath = os.path.join(os.getcwd(), ".green")
if os.path.isfile(cwd_filepath):
filepaths.append(cwd_filepath)
for cfg_file in (".green", "setup.cfg"):
cwd_filepath = os.path.join(os.getcwd(), cfg_file)
if os.path.isfile(cwd_filepath):
filepaths.append(cwd_filepath)

# High priority
if filepath and os.path.isfile(filepath):
Expand All @@ -380,7 +381,12 @@ def getConfig(filepath=None): # pragma: no cover
# parser.readfp(obj_with_readline)
read_func = getattr(parser, 'read_file', getattr(parser, 'readfp'))
for filepath in filepaths:
read_func(ConfigFile(filepath))
# Users are expected to put a [green] section
# only if they use setup.cfg
if filepath.endswith('setup.cfg'):
read_func(open(filepath))
else:
read_func(ConfigFile(filepath))

return parser

Expand Down