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
eb394670
Unverified
Commit
eb394670
authored
Apr 23, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change CLI error style
parent
f80962b5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
1 deletions
+73
-1
CHANGELOG.md
+1
-0
poetry/console/application.py
+70
-0
poetry/console/commands/new.py
+1
-1
poetry/console/styles/poetry.py
+1
-0
No files found.
CHANGELOG.md
View file @
eb394670
...
...
@@ -9,6 +9,7 @@
### Changed
-
Dependency resolution caches now use sha256 hashes.
-
Changed CLI error style.
## [0.8.3] - 2018-04-16
...
...
poetry/console/application.py
View file @
eb394670
import
os
import
re
import
sys
import
traceback
from
cleo
import
Application
as
BaseApplication
from
cleo.formatters
import
Formatter
from
cleo.inputs
import
ArgvInput
from
cleo.outputs
import
ConsoleOutput
from
cleo.outputs
import
Output
from
poetry
import
__version__
...
...
@@ -40,6 +45,8 @@ class Application(BaseApplication):
self
.
_poetry
=
None
self
.
_skip_io_configuration
=
False
self
.
_formatter
=
Formatter
(
True
)
self
.
_formatter
.
add_style
(
'error'
,
'red'
,
options
=
[
'bold'
])
@property
def
poetry
(
self
):
...
...
@@ -61,6 +68,7 @@ class Application(BaseApplication):
if
o
is
None
:
o
=
ConsoleOutput
()
o
.
set_formatter
(
self
.
_formatter
)
name
=
i
.
get_first_argument
()
if
name
in
[
'run'
,
'script'
]:
...
...
@@ -128,3 +136,65 @@ class Application(BaseApplication):
]
return
commands
def
render_exception
(
self
,
e
,
o
):
tb
=
traceback
.
extract_tb
(
sys
.
exc_info
()[
2
])
title
=
'[<error>
%
s</error>] '
%
e
.
__class__
.
__name__
l
=
len
(
title
)
width
=
self
.
_terminal
.
width
if
not
width
:
width
=
sys
.
maxsize
formatter
=
o
.
get_formatter
()
lines
=
[]
for
line
in
re
.
split
(
'
\r
?
\n
'
,
str
(
e
)):
for
splitline
in
[
line
[
x
:
x
+
(
width
-
4
)]
for
x
in
range
(
0
,
len
(
line
),
width
-
4
)]:
line_length
=
len
(
re
.
sub
(
'
\
[[^m]*m'
,
''
,
formatter
.
format
(
splitline
)))
+
4
lines
.
append
((
splitline
,
line_length
))
l
=
max
(
line_length
,
l
)
messages
=
[
''
]
empty_line
=
formatter
.
format
(
'
%
s'
%
(
' '
*
l
))
messages
.
append
(
empty_line
)
messages
.
append
(
formatter
.
format
(
'
%
s
%
s'
%
(
title
,
' '
*
max
(
0
,
l
-
len
(
title
)))))
for
line
in
lines
:
messages
.
append
(
formatter
.
format
(
'<error>
%
s
%
s</error>'
%
(
line
[
0
],
' '
*
(
l
-
line
[
1
])))
)
messages
.
append
(
empty_line
)
messages
.
append
(
''
)
o
.
writeln
(
messages
,
Output
.
OUTPUT_RAW
)
if
Output
.
VERBOSITY_VERBOSE
<=
o
.
get_verbosity
():
o
.
writeln
(
'<comment>Exception trace:</comment>'
)
for
exc_info
in
tb
:
file_
=
exc_info
[
0
]
line_number
=
exc_info
[
1
]
function
=
exc_info
[
2
]
line
=
exc_info
[
3
]
o
.
writeln
(
' <info>
%
s</info> in <fg=cyan>
%
s()</> '
'at line <info>
%
s</info>'
%
(
file_
,
function
,
line_number
))
o
.
writeln
(
'
%
s'
%
line
)
o
.
writeln
(
''
)
if
self
.
_running_command
is
not
None
:
o
.
writeln
(
'<info>
%
s</info>'
%
self
.
_running_command
.
get_synopsis
())
o
.
writeln
(
''
)
poetry/console/commands/new.py
View file @
eb394670
...
...
@@ -26,7 +26,7 @@ class NewCommand(Command):
if
list
(
path
.
glob
(
'*'
)):
# Directory is not empty. Aborting.
raise
RuntimeError
(
'Destination <fg=yellow
;bg=red
>{}</> '
'Destination <fg=yellow>{}</> '
'exists and is not empty'
.
format
(
path
)
...
...
poetry/console/styles/poetry.py
View file @
eb394670
...
...
@@ -7,6 +7,7 @@ class PoetryStyle(CleoStyle):
def
__init__
(
self
,
i
,
o
):
super
(
PoetryStyle
,
self
)
.
__init__
(
i
,
o
)
self
.
output
.
get_formatter
()
.
add_style
(
'error'
,
'red'
)
self
.
output
.
get_formatter
()
.
add_style
(
'warning'
,
'black'
,
'yellow'
)
self
.
output
.
get_formatter
()
.
add_style
(
'question'
,
'blue'
)
...
...
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