diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2017-10-10 10:23:32 +0100 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2017-10-12 13:44:59 +0100 |
commit | 897ec13869341cc859c2366aa20210e8ecab7b49 (patch) | |
tree | 77d8652c2a5563967a87926b31256a221ad84dde | |
parent | a260dc3f294568529562fe548ff73cac5d57df1a (diff) | |
download | pbr-897ec13869341cc859c2366aa20210e8ecab7b49.tar.gz |
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
-rw-r--r-- | pbr/core.py | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/pbr/core.py b/pbr/core.py index 3649e36..a93253b 100644 --- a/pbr/core.py +++ b/pbr/core.py @@ -81,55 +81,54 @@ def pbr(dist, attr, value): not work well with distributions that do use a `Distribution` subclass. """ - if True: - if not value: - return - if isinstance(value, string_type): - path = os.path.abspath(value) - else: - path = os.path.abspath('setup.cfg') - if not os.path.exists(path): - raise errors.DistutilsFileError( - 'The setup.cfg file %s does not exist.' % path) + if not value: + return + if isinstance(value, string_type): + path = os.path.abspath(value) + else: + path = os.path.abspath('setup.cfg') + if not os.path.exists(path): + raise errors.DistutilsFileError( + 'The setup.cfg file %s does not exist.' % path) - # Converts the setup.cfg file to setup() arguments - try: - attrs = util.cfg_to_args(path, dist.script_args) - except Exception: - e = sys.exc_info()[1] - # NB: This will output to the console if no explicit logging has - # been setup - but thats fine, this is a fatal distutils error, so - # being pretty isn't the #1 goal.. being diagnosable is. - logging.exception('Error parsing') - raise errors.DistutilsSetupError( - 'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e)) + # Converts the setup.cfg file to setup() arguments + try: + attrs = util.cfg_to_args(path, dist.script_args) + except Exception: + e = sys.exc_info()[1] + # NB: This will output to the console if no explicit logging has + # been setup - but thats fine, this is a fatal distutils error, so + # being pretty isn't the #1 goal.. being diagnosable is. + logging.exception('Error parsing') + raise errors.DistutilsSetupError( + 'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e)) - # Repeat some of the Distribution initialization code with the newly - # provided attrs - if attrs: - # Skips 'options' and 'licence' support which are rarely used; may - # add back in later if demanded - for key, val in attrs.items(): - if hasattr(dist.metadata, 'set_' + key): - getattr(dist.metadata, 'set_' + key)(val) - elif hasattr(dist.metadata, key): - setattr(dist.metadata, key, val) - elif hasattr(dist, key): - setattr(dist, key, val) - else: - msg = 'Unknown distribution option: %s' % repr(key) - warnings.warn(msg) + # Repeat some of the Distribution initialization code with the newly + # provided attrs + if attrs: + # Skips 'options' and 'licence' support which are rarely used; may + # add back in later if demanded + for key, val in attrs.items(): + if hasattr(dist.metadata, 'set_' + key): + getattr(dist.metadata, 'set_' + key)(val) + elif hasattr(dist.metadata, key): + setattr(dist.metadata, key, val) + elif hasattr(dist, key): + setattr(dist, key, val) + else: + msg = 'Unknown distribution option: %s' % repr(key) + warnings.warn(msg) - # Re-finalize the underlying Distribution - try: - super(dist.__class__, dist).finalize_options() - except TypeError: - # 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 - # for Python 2. In that case, fall back to doing this the ugly way - dist.__class__.__bases__[-1].finalize_options(dist) + # Re-finalize the underlying Distribution + try: + super(dist.__class__, dist).finalize_options() + except TypeError: + # 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 + # for Python 2. In that case, fall back to doing this the ugly way + dist.__class__.__bases__[-1].finalize_options(dist) - # This bit comes out of distribute/setuptools - if isinstance(dist.metadata.version, integer_types + (float,)): - # Some people apparently take "version number" too literally :) - dist.metadata.version = str(dist.metadata.version) + # This bit comes out of distribute/setuptools + if isinstance(dist.metadata.version, integer_types + (float,)): + # Some people apparently take "version number" too literally :) + dist.metadata.version = str(dist.metadata.version) |