Commit 897ec138 authored by Stephen Finucane's avatar Stephen Finucane

Remove unnecessary 'if True'

This was done in change I7418cc3ab36823d029a93f86df9c8b25aa7b0c5f to
keep the diff clean [1]. If can be removed now.

[1] https://bugs.launchpad.net/pbr/+bug/1620153/comments/1

Change-Id: Id66ca0522cc4c5601714e1e9ba9379492edc5905
parent a260dc3f
...@@ -81,55 +81,54 @@ def pbr(dist, attr, value): ...@@ -81,55 +81,54 @@ def pbr(dist, attr, value):
not work well with distributions that do use a `Distribution` subclass. not work well with distributions that do use a `Distribution` subclass.
""" """
if True: if not value:
if not value: return
return if isinstance(value, string_type):
if isinstance(value, string_type): path = os.path.abspath(value)
path = os.path.abspath(value) else:
else: path = os.path.abspath('setup.cfg')
path = os.path.abspath('setup.cfg') if not os.path.exists(path):
if not os.path.exists(path): raise errors.DistutilsFileError(
raise errors.DistutilsFileError( 'The setup.cfg file %s does not exist.' % path)
'The setup.cfg file %s does not exist.' % path)
# Converts the setup.cfg file to setup() arguments # Converts the setup.cfg file to setup() arguments
try: try:
attrs = util.cfg_to_args(path, dist.script_args) attrs = util.cfg_to_args(path, dist.script_args)
except Exception: except Exception:
e = sys.exc_info()[1] e = sys.exc_info()[1]
# NB: This will output to the console if no explicit logging has # NB: This will output to the console if no explicit logging has
# been setup - but thats fine, this is a fatal distutils error, so # been setup - but thats fine, this is a fatal distutils error, so
# being pretty isn't the #1 goal.. being diagnosable is. # being pretty isn't the #1 goal.. being diagnosable is.
logging.exception('Error parsing') logging.exception('Error parsing')
raise errors.DistutilsSetupError( raise errors.DistutilsSetupError(
'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e)) 'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e))
# Repeat some of the Distribution initialization code with the newly # Repeat some of the Distribution initialization code with the newly
# provided attrs # provided attrs
if attrs: if attrs:
# Skips 'options' and 'licence' support which are rarely used; may # Skips 'options' and 'licence' support which are rarely used; may
# add back in later if demanded # add back in later if demanded
for key, val in attrs.items(): for key, val in attrs.items():
if hasattr(dist.metadata, 'set_' + key): if hasattr(dist.metadata, 'set_' + key):
getattr(dist.metadata, 'set_' + key)(val) getattr(dist.metadata, 'set_' + key)(val)
elif hasattr(dist.metadata, key): elif hasattr(dist.metadata, key):
setattr(dist.metadata, key, val) setattr(dist.metadata, key, val)
elif hasattr(dist, key): elif hasattr(dist, key):
setattr(dist, key, val) setattr(dist, key, val)
else: else:
msg = 'Unknown distribution option: %s' % repr(key) msg = 'Unknown distribution option: %s' % repr(key)
warnings.warn(msg) warnings.warn(msg)
# Re-finalize the underlying Distribution # Re-finalize the underlying Distribution
try: try:
super(dist.__class__, dist).finalize_options() super(dist.__class__, dist).finalize_options()
except TypeError: except TypeError:
# If dist is not declared as a new-style class (with object as # If dist is not declared as a new-style class (with object as
# a subclass) then super() will not work on it. This is the case # a subclass) then super() will not work on it. This is the case
# for Python 2. In that case, fall back to doing this the ugly way # for Python 2. In that case, fall back to doing this the ugly way
dist.__class__.__bases__[-1].finalize_options(dist) dist.__class__.__bases__[-1].finalize_options(dist)
# This bit comes out of distribute/setuptools # This bit comes out of distribute/setuptools
if isinstance(dist.metadata.version, integer_types + (float,)): if isinstance(dist.metadata.version, integer_types + (float,)):
# Some people apparently take "version number" too literally :) # Some people apparently take "version number" too literally :)
dist.metadata.version = str(dist.metadata.version) dist.metadata.version = str(dist.metadata.version)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment