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
4c6d2250
Unverified
Commit
4c6d2250
authored
Oct 04, 2019
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Align the debug resolve command with add and init
parent
aa2cc9b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
56 deletions
+17
-56
poetry/console/commands/debug/resolve.py
+17
-56
No files found.
poetry/console/commands/debug/resolve.py
View file @
4c6d2250
...
@@ -5,10 +5,10 @@ from typing import List
...
@@ -5,10 +5,10 @@ from typing import List
from
cleo
import
argument
from
cleo
import
argument
from
cleo
import
option
from
cleo
import
option
from
..
command
import
Command
from
..
init
import
Init
Command
class
DebugResolveCommand
(
Command
):
class
DebugResolveCommand
(
Init
Command
):
name
=
"resolve"
name
=
"resolve"
description
=
"Debugs dependency resolution."
description
=
"Debugs dependency resolution."
...
@@ -43,12 +43,25 @@ class DebugResolveCommand(Command):
...
@@ -43,12 +43,25 @@ class DebugResolveCommand(Command):
if
not
packages
:
if
not
packages
:
package
=
self
.
poetry
.
package
package
=
self
.
poetry
.
package
else
:
else
:
# Using current pool for determine_requirements()
self
.
_pool
=
self
.
poetry
.
pool
package
=
ProjectPackage
(
package
=
ProjectPackage
(
self
.
poetry
.
package
.
name
,
self
.
poetry
.
package
.
version
self
.
poetry
.
package
.
name
,
self
.
poetry
.
package
.
version
)
)
requirements
=
self
.
_format_requirements
(
packages
)
for
name
,
constraint
in
requirements
.
items
():
# Silencing output
is_quiet
=
self
.
io
.
output
.
is_quiet
()
if
not
is_quiet
:
self
.
io
.
output
.
set_quiet
(
True
)
requirements
=
self
.
_determine_requirements
(
packages
)
if
not
is_quiet
:
self
.
io
.
output
.
set_quiet
(
False
)
for
constraint
in
requirements
:
name
=
constraint
.
pop
(
"name"
)
dep
=
package
.
add_dependency
(
name
,
constraint
)
dep
=
package
.
add_dependency
(
name
,
constraint
)
extras
=
[]
extras
=
[]
for
extra
in
self
.
option
(
"extras"
):
for
extra
in
self
.
option
(
"extras"
):
...
@@ -116,55 +129,3 @@ class DebugResolveCommand(Command):
...
@@ -116,55 +129,3 @@ class DebugResolveCommand(Command):
table
.
set_rows
(
rows
)
table
.
set_rows
(
rows
)
table
.
render
(
self
.
io
)
table
.
render
(
self
.
io
)
def
_determine_requirements
(
self
,
requires
):
# type: (List[str]) -> List[str]
from
poetry.semver
import
parse_constraint
if
not
requires
:
return
[]
requires
=
self
.
_parse_name_version_pairs
(
requires
)
for
requirement
in
requires
:
if
"version"
in
requirement
:
parse_constraint
(
requirement
[
"version"
])
return
requires
def
_parse_name_version_pairs
(
self
,
pairs
):
# type: (list) -> list
result
=
[]
for
i
in
range
(
len
(
pairs
)):
if
pairs
[
i
]
.
startswith
(
"git+https://"
):
url
=
pairs
[
i
]
.
lstrip
(
"git+"
)
rev
=
None
if
"@"
in
url
:
url
,
rev
=
url
.
split
(
"@"
)
pair
=
{
"name"
:
url
.
split
(
"/"
)[
-
1
]
.
rstrip
(
".git"
),
"git"
:
url
}
if
rev
:
pair
[
"rev"
]
=
rev
result
.
append
(
pair
)
continue
pair
=
re
.
sub
(
"^([^=: ]+)[=: ](.*)$"
,
"
\\
1
\\
2"
,
pairs
[
i
]
.
strip
())
pair
=
pair
.
strip
()
if
" "
in
pair
:
name
,
version
=
pair
.
split
(
" "
,
2
)
result
.
append
({
"name"
:
name
,
"version"
:
version
})
else
:
result
.
append
({
"name"
:
pair
,
"version"
:
"*"
})
return
result
def
_format_requirements
(
self
,
requirements
):
# type: (List[str]) -> dict
requires
=
{}
requirements
=
self
.
_determine_requirements
(
requirements
)
for
requirement
in
requirements
:
name
=
requirement
.
pop
(
"name"
)
requires
[
name
]
=
requirement
return
requires
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