Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
news
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sartika Aritonang
news
Commits
80ae48a3
Commit
80ae48a3
authored
May 29, 2020
by
Sartika Aritonang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
fa8b6d66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
alias.py
stbi/Lib/site-packages/setuptools/command/alias.py
+80
-0
No files found.
stbi/Lib/site-packages/setuptools/command/alias.py
0 → 100644
View file @
80ae48a3
from
distutils.errors
import
DistutilsOptionError
from
setuptools.extern.six.moves
import
map
from
setuptools.command.setopt
import
edit_config
,
option_base
,
config_file
def
shquote
(
arg
):
"""Quote an argument for later parsing by shlex.split()"""
for
c
in
'"'
,
"'"
,
"
\\
"
,
"#"
:
if
c
in
arg
:
return
repr
(
arg
)
if
arg
.
split
()
!=
[
arg
]:
return
repr
(
arg
)
return
arg
class
alias
(
option_base
):
"""Define a shortcut that invokes one or more commands"""
description
=
"define a shortcut to invoke one or more commands"
command_consumes_arguments
=
True
user_options
=
[
(
'remove'
,
'r'
,
'remove (unset) the alias'
),
]
+
option_base
.
user_options
boolean_options
=
option_base
.
boolean_options
+
[
'remove'
]
def
initialize_options
(
self
):
option_base
.
initialize_options
(
self
)
self
.
args
=
None
self
.
remove
=
None
def
finalize_options
(
self
):
option_base
.
finalize_options
(
self
)
if
self
.
remove
and
len
(
self
.
args
)
!=
1
:
raise
DistutilsOptionError
(
"Must specify exactly one argument (the alias name) when "
"using --remove"
)
def
run
(
self
):
aliases
=
self
.
distribution
.
get_option_dict
(
'aliases'
)
if
not
self
.
args
:
print
(
"Command Aliases"
)
print
(
"---------------"
)
for
alias
in
aliases
:
print
(
"setup.py alias"
,
format_alias
(
alias
,
aliases
))
return
elif
len
(
self
.
args
)
==
1
:
alias
,
=
self
.
args
if
self
.
remove
:
command
=
None
elif
alias
in
aliases
:
print
(
"setup.py alias"
,
format_alias
(
alias
,
aliases
))
return
else
:
print
(
"No alias definition found for
%
r"
%
alias
)
return
else
:
alias
=
self
.
args
[
0
]
command
=
' '
.
join
(
map
(
shquote
,
self
.
args
[
1
:]))
edit_config
(
self
.
filename
,
{
'aliases'
:
{
alias
:
command
}},
self
.
dry_run
)
def
format_alias
(
name
,
aliases
):
source
,
command
=
aliases
[
name
]
if
source
==
config_file
(
'global'
):
source
=
'--global-config '
elif
source
==
config_file
(
'user'
):
source
=
'--user-config '
elif
source
==
config_file
(
'local'
):
source
=
''
else
:
source
=
'--filename=
%
r'
%
source
return
source
+
name
+
' '
+
command
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