Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd29a489

Browse files
committed
docs(cli): add PyYAML requirement notice
Fixes#606
1 parent6585c96 commitd29a489

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

‎docs/cli.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ These options must be defined before the mandatory arguments.
157157
``--output``, ``-o``
158158
Output format. Defaults to a custom format. Can also be ``yaml`` or ``json``.
159159

160+
**Notice:**
161+
162+
The `PyYAML package<https://pypi.org/project/PyYAML/>`_ is required to use the yaml output option.
163+
You need to install it separately using ``pip install PyYAML``
164+
160165
``--fields``, ``-f``
161166
Comma-separated list of fields to display (``yaml`` and ``json`` output
162167
formats only). If not used, all the object fields are displayed.

‎gitlab/v4/cli.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,24 @@ def display_list(self, data, fields, **kwargs):
302302

303303
classYAMLPrinter(object):
304304
defdisplay(self,d,**kwargs):
305-
importyaml# noqa
306-
print(yaml.safe_dump(d,default_flow_style=False))
305+
try:
306+
importyaml# noqa
307+
print(yaml.safe_dump(d,default_flow_style=False))
308+
exceptImportError:
309+
exit("PyYaml is not installed.\n"
310+
"Install it with `pip install PyYaml` "
311+
"to use the yaml output feature")
307312

308313
defdisplay_list(self,data,fields,**kwargs):
309-
importyaml# noqa
310-
print(yaml.safe_dump(
311-
[get_dict(obj,fields)forobjindata],
312-
default_flow_style=False))
314+
try:
315+
importyaml# noqa
316+
print(yaml.safe_dump(
317+
[get_dict(obj,fields)forobjindata],
318+
default_flow_style=False))
319+
exceptImportError:
320+
exit("PyYaml is not installed.\n"
321+
"Install it with `pip install PyYaml` "
322+
"to use the yaml output feature")
313323

314324

315325
classLegacyPrinter(object):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp