Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Louis
pypimonitor
Commits
8bc43782
Commit
8bc43782
authored
May 17, 2016
by
Louis
Browse files
Command line now accept a yaml filename as argument
parent
b367abf6
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/spalax.yaml
View file @
8bc43782
...
...
@@ -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
:
pypimonitor/__init__.py
View file @
8bc43782
...
...
@@ -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
:
...
...
pypimonitor/__main__.py
View file @
8bc43782
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
())
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment