up
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from setuptools.command.setopt import config_file, edit_config, option_base
|
||||
|
||||
from distutils.errors import DistutilsOptionError
|
||||
|
||||
from setuptools.command.setopt import edit_config, option_base, config_file
|
||||
|
||||
|
||||
def shquote(arg):
|
||||
"""Quote an argument for later parsing by shlex.split()"""
|
||||
@@ -30,14 +30,15 @@ class alias(option_base):
|
||||
self.args = None
|
||||
self.remove = None
|
||||
|
||||
def finalize_options(self) -> 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"
|
||||
"Must specify exactly one argument (the alias name) when "
|
||||
"using --remove"
|
||||
)
|
||||
|
||||
def run(self) -> None:
|
||||
def run(self):
|
||||
aliases = self.distribution.get_option_dict('aliases')
|
||||
|
||||
if not self.args:
|
||||
@@ -48,14 +49,14 @@ class alias(option_base):
|
||||
return
|
||||
|
||||
elif len(self.args) == 1:
|
||||
(alias,) = self.args
|
||||
alias, = self.args
|
||||
if self.remove:
|
||||
command = None
|
||||
elif alias in aliases:
|
||||
print("setup.py alias", format_alias(alias, aliases))
|
||||
return
|
||||
else:
|
||||
print(f"No alias definition found for {alias!r}")
|
||||
print("No alias definition found for %r" % alias)
|
||||
return
|
||||
else:
|
||||
alias = self.args[0]
|
||||
@@ -73,5 +74,5 @@ def format_alias(name, aliases):
|
||||
elif source == config_file('local'):
|
||||
source = ''
|
||||
else:
|
||||
source = f'--filename={source!r}'
|
||||
source = '--filename=%r' % source
|
||||
return source + name + ' ' + command
|
||||
|
||||
Reference in New Issue
Block a user