summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvainpocentek@gmail.com>2018-10-11 18:51:55 +0200
committerGitHub <noreply@github.com>2018-10-11 18:51:55 +0200
commit156a21e1a2c9dcb6a14d95655ef24d5520e1dcc1 (patch)
treee40c2e50b41ac2b0952fca3223d8ee262608e205
parent5ff2608f3eef773f06d3b1c70c2317a96f53a4b4 (diff)
parentd29a48981b521bf31d6f0304b88f39a63185328a (diff)
downloadgitlab-156a21e1a2c9dcb6a14d95655ef24d5520e1dcc1.tar.gz
Merge pull request #608 from python-gitlab/ci-output-option
docs(cli): add PyYAML requirement notice
-rw-r--r--README.rst7
-rw-r--r--docs/cli.rst5
-rw-r--r--gitlab/v4/cli.py22
3 files changed, 28 insertions, 6 deletions
diff --git a/README.rst b/README.rst
index ff71fcb..e8f2d76 100644
--- a/README.rst
+++ b/README.rst
@@ -54,6 +54,13 @@ Documentation
The full documentation for CLI and API is available on `readthedocs
<http://python-gitlab.readthedocs.org/en/stable/>`_.
+Build the docs
+--------------
+You can build the documentation using ``sphinx``::
+
+ pip install sphinx
+ python setup.py build_sphinx
+
Contributing
============
diff --git a/docs/cli.rst b/docs/cli.rst
index 220f079..2051d03 100644
--- a/docs/cli.rst
+++ b/docs/cli.rst
@@ -157,6 +157,11 @@ These options must be defined before the mandatory arguments.
``--output``, ``-o``
Output format. Defaults to a custom format. Can also be ``yaml`` or ``json``.
+ **Notice:**
+
+ The `PyYAML package <https://pypi.org/project/PyYAML/>`_ is required to use the yaml output option.
+ You need to install it separately using ``pip install PyYAML``
+
``--fields``, ``-f``
Comma-separated list of fields to display (``yaml`` and ``json`` output
formats only). If not used, all the object fields are displayed.
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index a876f9e..242874d 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -302,14 +302,24 @@ class JSONPrinter(object):
class YAMLPrinter(object):
def display(self, d, **kwargs):
- import yaml # noqa
- print(yaml.safe_dump(d, default_flow_style=False))
+ try:
+ import yaml # noqa
+ print(yaml.safe_dump(d, default_flow_style=False))
+ except ImportError:
+ exit("PyYaml is not installed.\n"
+ "Install it with `pip install PyYaml` "
+ "to use the yaml output feature")
def display_list(self, data, fields, **kwargs):
- import yaml # noqa
- print(yaml.safe_dump(
- [get_dict(obj, fields) for obj in data],
- default_flow_style=False))
+ try:
+ import yaml # noqa
+ print(yaml.safe_dump(
+ [get_dict(obj, fields) for obj in data],
+ default_flow_style=False))
+ except ImportError:
+ exit("PyYaml is not installed.\n"
+ "Install it with `pip install PyYaml` "
+ "to use the yaml output feature")
class LegacyPrinter(object):