Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
7c57995a
Unverified
Commit
7c57995a
authored
Jul 30, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix single value display in the config command
Fixes #349
parent
9dac5bf0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
11 deletions
+42
-11
poetry/console/commands/config.py
+27
-11
tests/console/commands/test_config.py
+15
-0
No files found.
poetry/console/commands/config.py
View file @
7c57995a
...
@@ -118,6 +118,17 @@ To remove a repository (repo is a short alias for repositories):
...
@@ -118,6 +118,17 @@ To remove a repository (repo is a short alias for repositories):
value
=
repo
value
=
repo
self
.
line
(
str
(
value
))
self
.
line
(
str
(
value
))
else
:
values
=
self
.
unique_config_values
if
setting_key
not
in
values
:
raise
ValueError
(
"There is no {} setting."
.
format
(
setting_key
))
values
=
self
.
_get_setting
(
self
.
_config
.
content
,
setting_key
,
default
=
values
[
setting_key
][
-
1
]
)
for
value
in
values
:
self
.
line
(
value
[
1
])
return
0
return
0
...
@@ -240,17 +251,22 @@ To remove a repository (repo is a short alias for repositories):
...
@@ -240,17 +251,22 @@ To remove a repository (repo is a short alias for repositories):
self
.
_list_setting
(
repositories
,
k
=
"repositories."
)
self
.
_list_setting
(
repositories
,
k
=
"repositories."
)
def
_list_setting
(
self
,
contents
,
setting
=
None
,
k
=
None
,
default
=
None
):
def
_list_setting
(
self
,
contents
,
setting
=
None
,
k
=
None
,
default
=
None
):
values
=
self
.
_get_setting
(
contents
,
setting
,
k
,
default
)
for
value
in
values
:
self
.
line
(
"<comment>{}</comment> = <info>{}</info>"
.
format
(
value
[
0
],
value
[
1
])
)
def
_get_setting
(
self
,
contents
,
setting
=
None
,
k
=
None
,
default
=
None
):
orig_k
=
k
orig_k
=
k
if
setting
and
setting
.
split
(
"."
)[
0
]
not
in
contents
:
if
setting
and
setting
.
split
(
"."
)[
0
]
not
in
contents
:
value
=
json
.
dumps
(
default
)
value
=
json
.
dumps
(
default
)
self
.
line
(
return
[((
k
or
""
)
+
setting
,
value
)]
"<comment>{}</comment> = <info>{}</info>"
.
format
(
(
k
or
""
)
+
setting
,
value
)
)
else
:
else
:
values
=
[]
for
key
,
value
in
contents
.
items
():
for
key
,
value
in
contents
.
items
():
if
k
is
None
and
key
not
in
[
"config"
,
"repositories"
,
"settings"
]:
if
k
is
None
and
key
not
in
[
"config"
,
"repositories"
,
"settings"
]:
continue
continue
...
@@ -266,7 +282,9 @@ To remove a repository (repo is a short alias for repositories):
...
@@ -266,7 +282,9 @@ To remove a repository (repo is a short alias for repositories):
if
setting
and
len
(
setting
)
>
1
:
if
setting
and
len
(
setting
)
>
1
:
setting
=
"."
.
join
(
setting
.
split
(
"."
)[
1
:])
setting
=
"."
.
join
(
setting
.
split
(
"."
)[
1
:])
self
.
_list_setting
(
value
,
k
=
k
,
setting
=
setting
,
default
=
default
)
values
+=
self
.
_get_setting
(
value
,
k
=
k
,
setting
=
setting
,
default
=
default
)
k
=
orig_k
k
=
orig_k
continue
continue
...
@@ -281,11 +299,9 @@ To remove a repository (repo is a short alias for repositories):
...
@@ -281,11 +299,9 @@ To remove a repository (repo is a short alias for repositories):
value
=
json
.
dumps
(
value
)
value
=
json
.
dumps
(
value
)
self
.
line
(
values
.
append
(((
k
or
""
)
+
key
,
value
))
"<comment>{}</comment> = <info>{}</info>"
.
format
(
(
k
or
""
)
+
key
,
value
return
values
)
)
def
_get_formatted_value
(
self
,
value
):
def
_get_formatted_value
(
self
,
value
):
if
isinstance
(
value
,
list
):
if
isinstance
(
value
,
list
):
...
...
tests/console/commands/test_config.py
View file @
7c57995a
...
@@ -64,3 +64,18 @@ repositories = {}
...
@@ -64,3 +64,18 @@ repositories = {}
"""
"""
assert
tester
.
get_display
(
True
)
==
expected
assert
tester
.
get_display
(
True
)
==
expected
def
test_display_single_setting
(
app
,
config
):
command
=
app
.
find
(
"config"
)
command
.
_config
=
Config
(
config
.
file
)
tester
=
CommandTester
(
command
)
tester
.
execute
(
[(
"command"
,
command
.
get_name
()),
(
"key"
,
"settings.virtualenvs.create"
)]
)
expected
=
"""true
"""
assert
tester
.
get_display
(
True
)
==
expected
Write
Preview
Markdown
is supported
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