Fix flake8 compliants in tools python programs.
Change-Id: I59feb2824fce16d23d56833fd51e4814a0e641cf
This commit is contained in:
parent
18bd6b8a0d
commit
02f8d000ff
@ -14,9 +14,9 @@ import argparse
|
||||
import collections
|
||||
import iso8601
|
||||
import logging
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
@ -3,14 +3,12 @@
|
||||
import argparse
|
||||
import distutils.spawn
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import pip.index
|
||||
import pip.req
|
||||
from pip.vcs import git, mercurial, subversion, bazaar
|
||||
import pkg_resources
|
||||
|
||||
|
||||
@ -201,19 +199,16 @@ def join_one_requirement(req_list):
|
||||
"""
|
||||
if len(req_list) == 1:
|
||||
return req_list[0]
|
||||
req_strict = None
|
||||
lower_bound_str = None
|
||||
lower_bound_version = None
|
||||
lower_bound_req = None
|
||||
upper_bound_str = None
|
||||
upper_bound_version = None
|
||||
upper_bound_req = None
|
||||
conflicts = []
|
||||
for req in req_list:
|
||||
for spec in req.req.specs:
|
||||
if spec[0] == "==":
|
||||
return req
|
||||
spec_str = "%s%s" % spec
|
||||
spec_str = "%s%s" % spec
|
||||
if spec[0] == "!=":
|
||||
conflicts.append(spec_str)
|
||||
continue
|
||||
@ -225,15 +220,13 @@ def join_one_requirement(req_list):
|
||||
(strict_check and version == lower_bound_version)):
|
||||
lower_bound_version = version
|
||||
lower_bound_str = spec_str
|
||||
lower_bound_req = req
|
||||
else:
|
||||
if (not upper_bound_version or (version < upper_bound_version) or
|
||||
(strict_check and version == upper_bound_version)):
|
||||
upper_bound_version = version
|
||||
upper_bound_str = spec_str
|
||||
upper_bound_req = req
|
||||
req_key = req_list[0].req.key
|
||||
if lower_bound_version and upper_bound_version:
|
||||
bad_bounds = False
|
||||
if lower_bound_version > upper_bound_version:
|
||||
upper_bound_str = None
|
||||
if lower_bound_version == upper_bound_version:
|
||||
@ -244,7 +237,6 @@ def join_one_requirement(req_list):
|
||||
else:
|
||||
upper_bound_str = None
|
||||
req_specs = []
|
||||
req_key = req_list[0].req.key
|
||||
if lower_bound_str:
|
||||
req_specs.append(lower_bound_str)
|
||||
if upper_bound_str:
|
||||
@ -304,7 +296,7 @@ def join_requirements(options):
|
||||
conflicts.append(parsed)
|
||||
if exact_version:
|
||||
for req in req_list:
|
||||
if not exact_version in req.req:
|
||||
if exact_version not in req.req:
|
||||
incompatible_requirement(joined_req, req)
|
||||
else:
|
||||
for req in req_list:
|
||||
|
@ -16,7 +16,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from distutils.version import (StrictVersion, LooseVersion)
|
||||
from distutils.version import LooseVersion
|
||||
from distutils.version import StrictVersion
|
||||
|
||||
import collections
|
||||
import distutils
|
||||
|
11
tools/py2rpm
11
tools/py2rpm
@ -4,9 +4,9 @@ import argparse
|
||||
import distutils.spawn
|
||||
import email.parser
|
||||
import logging
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@ -58,6 +58,7 @@ mv -f INSTALLED_FILES{.tmp,}""",
|
||||
"""rm -rf $RPM_BUILD_ROOT""",
|
||||
}
|
||||
|
||||
|
||||
class InstallationError(Exception):
|
||||
pass
|
||||
|
||||
@ -70,7 +71,7 @@ def python_key_to_rpm(python_name):
|
||||
python_name = python_name.lower()
|
||||
try:
|
||||
return package_map[python_name]
|
||||
except:
|
||||
except KeyError:
|
||||
pass
|
||||
python_name = python_name.replace("_", "-").replace(".", "-")
|
||||
if python_name.startswith("python-"):
|
||||
@ -329,7 +330,7 @@ def requires_and_conflicts(req_list):
|
||||
for line in req_list:
|
||||
try:
|
||||
req = pkg_resources.Requirement.parse(line)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
rpm_name = python_key_to_rpm(req.key)
|
||||
if not req.specs:
|
||||
@ -407,7 +408,7 @@ def build_rpm(options, filename):
|
||||
# flake8 v2 that we don't go ahead and build a v2.0 version.
|
||||
#
|
||||
# Note(harlowja): Not sure why rpm seems to not understand these are the same...
|
||||
cleaned_version = trim_zeroes(version.replace('-','_'))
|
||||
cleaned_version = trim_zeroes(version.replace('-', '_'))
|
||||
with open(spec_name, "w") as spec_file:
|
||||
print >> spec_file, "%define pkg_name", pkg_name
|
||||
print >> spec_file, "%define rpm_name", rpm_name
|
||||
@ -440,7 +441,7 @@ def build_rpm(options, filename):
|
||||
max_name_len = max(len(tag[0]) for tag in tags)
|
||||
for tag in tags:
|
||||
print >> spec_file, "%s:" % tag[0], " " * (
|
||||
max_name_len - len(tag[0]) + 1), one_line(tag[1], max_len=-1)
|
||||
max_name_len - len(tag[0]) + 1), one_line(tag[1], max_len=-1)
|
||||
if rpm_requires:
|
||||
print >> spec_file, rpm_requires
|
||||
if rpm_conflicts:
|
||||
|
@ -23,9 +23,7 @@ from optparse import OptionParser
|
||||
|
||||
import collections
|
||||
import json
|
||||
import os
|
||||
import pkg_resources
|
||||
import sys
|
||||
|
||||
from yum import YumBase
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user