Skip to content

Commit

Permalink
Add 'dump' sub-action for sibyl config
Browse files Browse the repository at this point in the history
  • Loading branch information
commial committed Mar 15, 2017
1 parent bb8ea15 commit 8913942
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
28 changes: 16 additions & 12 deletions sibyl/actions/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ class ActionConfig(Action):

_name_ = "config"
_desc_ = "Configuration management"
_args_ = [(("-V", "--value"), {"help": "Return the value of a specific option"}),
_args_ = [
(("-V", "--value"), {"help": "Return the value of a specific option"}),
(("-d", "--dump"), {"help": "Dump the current configuration",
"action": "store_true"}),
]

def run(self):
if not self.args.value:
self.show()
exit(0)

if self.args.value.endswith("_keys") and hasattr(config,
self.args.value[:-5]):
val = getattr(config, self.args.value[:-5]).keys()
elif hasattr(config, self.args.value):
val = getattr(config, self.args.value)
if self.args.dump:
print "\n".join(config.dump())
elif self.args.value:
if self.args.value.endswith("_keys") and hasattr(config,
self.args.value[:-5]):
val = getattr(config, self.args.value[:-5]).keys()
elif hasattr(config, self.args.value):
val = getattr(config, self.args.value)
else:
val = "ERROR"
print val
else:
val = "ERROR"
print val
self.show()

def show(self):
# Configuration files
Expand Down
16 changes: 16 additions & 0 deletions sibyl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ def parse_files(self, files):
for name in cparser.options("tests"):
self.config["tests"][name] = cparser.get("tests", name)

def dump(self):
"""Dump the current configuration as a config file"""
out = []

# Find
out.append("[find]")
out.append("jit_engine = %s" % ",".join(self.config["jit_engine"]))

# Tests
out.append("")
out.append("[tests]")
for name, path in self.config["tests"].iteritems():
out.append("%s = %s" % (name, path))

return out

@property
def jit_engine(self):
"""Name of engine to use for jit"""
Expand Down

0 comments on commit 8913942

Please sign in to comment.