Commit 8bc43782 authored by Louis's avatar Louis
Browse files

Command line now accept a yaml filename as argument

parent b367abf6
......@@ -13,7 +13,24 @@ columns:
- coverage
- depends
packages:
PdfAutoNup:
argdispatch:
cahier:
chval:
devoir:
dummypdf:
evariste:
fullcoverage:
jouets:
lessormore:
mklog:
papersize:
patacrep:
docs:
type: readthedocs
ci:
type: travis
slug: patacrep/patacrep
pdfautonup:
docs:
type: readthedocs
ci:
......@@ -22,13 +39,13 @@ packages:
TODO
depends:
TODO
patacrep:
docs:
type: readthedocs
ci:
type: travis
slug: patacrep/patacrep
pdfimpose:
pypimonitor:
scal:
squelette:
sphinxcontrib-packages:
docs:
type: readthedocs
slug: packages
sphinxcontrib-proof:
srsync:
......@@ -50,11 +50,19 @@ def iter_user_packages(user):
str(error),
))
class Renderer:
def __init__(self, config):
# Processing config
self.config = config
if "columns" not in self.config:
self.config['columns'] = list(set(itertools.chain(*[
package.keys()
for package
in self.config['packages'].values()
])))
# Processing packages
self.packages = {}
for name in sorted(config['packages']):
try:
......
import argparse
import sys
import logging
import pypimonitor
LOGGER = logging.getLogger(pypimonitor.__name__)
def commandline_parser():
"""Return a command line parser."""
......@@ -41,6 +45,13 @@ def commandline_parser():
default=[],
)
parser.add_argument(
'yaml',
help='Configuration file.',
nargs="?",
default=None,
)
return parser
def _flatten(list_of_lists):
......@@ -50,8 +61,14 @@ def _flatten(list_of_lists):
if __name__ == "__main__":
arguments = commandline_parser().parse_args()
print(pypimonitor.Renderer.from_args(
packages=_flatten(arguments.package),
columns=_flatten(arguments.column),
users=_flatten(arguments.user),
).render())
if ((arguments.yaml is not None) and (arguments.column or arguments.package or arguments.user)):
LOGGER.error("Configuration file and --column, --package and --user arguments are incompatible.")
sys.exit(1)
if arguments.yaml is None:
print(pypimonitor.Renderer.from_args(
packages=_flatten(arguments.package),
columns=_flatten(arguments.column),
users=_flatten(arguments.user),
).render())
else:
print(pypimonitor.Renderer.from_yaml(arguments.yaml).render())
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment