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
4873e177
Unverified
Commit
4873e177
authored
Jun 19, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a Shell class
parent
99f62087
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
poetry/utils/shell.py
+44
-0
pyproject.toml
+1
-0
No files found.
poetry/utils/shell.py
0 → 100644
View file @
4873e177
import
os
from
shellingham
import
detect_shell
from
shellingham
import
ShellDetectionFailure
class
Shell
:
"""
Represents the current shell.
"""
_shell
=
None
def
__init__
(
self
,
name
,
path
):
# type: (str, str) -> None
self
.
_name
=
name
self
.
_path
=
path
@property
def
name
(
self
):
# type: () -> str
return
self
.
_name
@property
def
path
(
self
):
# type: () -> str
return
self
.
_path
@classmethod
def
get
(
cls
):
# type: () -> Shell
"""
Retrieve the current shell.
"""
if
cls
.
_shell
is
not
None
:
return
cls
.
_shell
try
:
name
,
path
=
detect_shell
(
os
.
getpid
())
except
(
RuntimeError
,
ShellDetectionFailure
):
raise
RuntimeError
(
"Unable to detect the current shell."
)
cls
.
_shell
=
cls
(
name
,
path
)
return
cls
.
_shell
def
__repr__
(
self
):
# type: () -> str
return
'{}("{}", "{}")'
.
format
(
self
.
__class__
.
__name__
,
self
.
_name
,
self
.
_path
)
pyproject.toml
View file @
4873e177
...
...
@@ -34,6 +34,7 @@ pyparsing = "^2.2"
cachecontrol
=
{
version
=
"^0.12.4"
,
extras
=
["filecache"]
}
pkginfo
=
"^1.4"
html5lib
=
"^1.0"
shellingham
=
"^1.1"
# The typing module is not in the stdlib in Python 2.7 and 3.4
typing
=
{
version
=
"^3.6"
,
python
=
"~2.7 || ~3.4"
}
...
...
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