summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-10-20 06:10:00 +0000
committerGerrit Code Review <review@openstack.org>2017-10-20 06:10:00 +0000
commit6a3c826e3b9e17c81c46463702e3095322abab63 (patch)
treee847f742655ca67444c882ca3d252623cbc8a2a0
parent3db298ad906dbd905c9b9ac4b6a877daa29130ee (diff)
parent897ec13869341cc859c2366aa20210e8ecab7b49 (diff)
Merge "Remove unnecessary 'if True'"
-rw-r--r--pbr/core.py95
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):
81 not work well with distributions that do use a `Distribution` subclass. 81 not work well with distributions that do use a `Distribution` subclass.
82 """ 82 """
83 83
84 if True: 84 if not value:
85 if not value: 85 return
86 return 86 if isinstance(value, string_type):
87 if isinstance(value, string_type): 87 path = os.path.abspath(value)
88 path = os.path.abspath(value) 88 else:
89 else: 89 path = os.path.abspath('setup.cfg')
90 path = os.path.abspath('setup.cfg') 90 if not os.path.exists(path):
91 if not os.path.exists(path): 91 raise errors.DistutilsFileError(
92 raise errors.DistutilsFileError( 92 'The setup.cfg file %s does not exist.' % path)
93 'The setup.cfg file %s does not exist.' % path)
94 93
95 # Converts the setup.cfg file to setup() arguments 94 # Converts the setup.cfg file to setup() arguments
96 try: 95 try:
97 attrs = util.cfg_to_args(path, dist.script_args) 96 attrs = util.cfg_to_args(path, dist.script_args)
98 except Exception: 97 except Exception:
99 e = sys.exc_info()[1] 98 e = sys.exc_info()[1]
100 # NB: This will output to the console if no explicit logging has 99 # NB: This will output to the console if no explicit logging has
101 # been setup - but thats fine, this is a fatal distutils error, so 100 # been setup - but thats fine, this is a fatal distutils error, so
102 # being pretty isn't the #1 goal.. being diagnosable is. 101 # being pretty isn't the #1 goal.. being diagnosable is.
103 logging.exception('Error parsing') 102 logging.exception('Error parsing')
104 raise errors.DistutilsSetupError( 103 raise errors.DistutilsSetupError(
105 'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e)) 104 'Error parsing %s: %s: %s' % (path, e.__class__.__name__, e))
106 105
107 # Repeat some of the Distribution initialization code with the newly 106 # Repeat some of the Distribution initialization code with the newly
108 # provided attrs 107 # provided attrs
109 if attrs: 108 if attrs:
110 # Skips 'options' and 'licence' support which are rarely used; may 109 # Skips 'options' and 'licence' support which are rarely used; may
111 # add back in later if demanded 110 # add back in later if demanded
112 for key, val in attrs.items(): 111 for key, val in attrs.items():
113 if hasattr(dist.metadata, 'set_' + key): 112 if hasattr(dist.metadata, 'set_' + key):
114 getattr(dist.metadata, 'set_' + key)(val) 113 getattr(dist.metadata, 'set_' + key)(val)
115 elif hasattr(dist.metadata, key): 114 elif hasattr(dist.metadata, key):
116 setattr(dist.metadata, key, val) 115 setattr(dist.metadata, key, val)
117 elif hasattr(dist, key): 116 elif hasattr(dist, key):
118 setattr(dist, key, val) 117 setattr(dist, key, val)
119 else: 118 else:
120 msg = 'Unknown distribution option: %s' % repr(key) 119 msg = 'Unknown distribution option: %s' % repr(key)
121 warnings.warn(msg) 120 warnings.warn(msg)
122 121
123 # Re-finalize the underlying Distribution 122 # Re-finalize the underlying Distribution
124 try: 123 try:
125 super(dist.__class__, dist).finalize_options() 124 super(dist.__class__, dist).finalize_options()
126 except TypeError: 125 except TypeError:
127 # If dist is not declared as a new-style class (with object as 126 # If dist is not declared as a new-style class (with object as
128 # a subclass) then super() will not work on it. This is the case 127 # a subclass) then super() will not work on it. This is the case
129 # for Python 2. In that case, fall back to doing this the ugly way 128 # for Python 2. In that case, fall back to doing this the ugly way
130 dist.__class__.__bases__[-1].finalize_options(dist) 129 dist.__class__.__bases__[-1].finalize_options(dist)
131 130
132 # This bit comes out of distribute/setuptools 131 # This bit comes out of distribute/setuptools
133 if isinstance(dist.metadata.version, integer_types + (float,)): 132 if isinstance(dist.metadata.version, integer_types + (float,)):
134 # Some people apparently take "version number" too literally :) 133 # Some people apparently take "version number" too literally :)
135 dist.metadata.version = str(dist.metadata.version) 134 dist.metadata.version = str(dist.metadata.version)