Skip to content

Commit 8f9058f

Browse files
committed
Changes for building PyYAML for Fedora Core 27 (#556)
1 parent 215cbcf commit 8f9058f

File tree

3 files changed

+62
-18
lines changed

3 files changed

+62
-18
lines changed

data/rpm_templates/PyYAML.spec

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,22 @@ algorithm is simple enough to be a reference for YAML parser implementors.
2424
A simple extension API is also provided. The package is built using libyaml
2525
for improved speed.
2626

27-
%package -n python3-%{{name}}
27+
%package -n python2-pyyaml
28+
Obsoletes: PyYAML < %{{version}}
29+
Provides: PyYAML = %{{version}}
2830
Summary: YAML parser and emitter for Python
2931

30-
%description -n python3-%{{name}}
32+
%description -n python2-pyyaml
33+
Python-yaml is a complete YAML 1.1 parser and emitter
34+
for Python. It can parse all examples from the specification. The parsing
35+
algorithm is simple enough to be a reference for YAML parser implementors.
36+
A simple extension API is also provided. The package is built using libyaml
37+
for improved speed.
38+
39+
%package -n python3-pyyaml
40+
Summary: YAML parser and emitter for Python
41+
42+
%description -n python3-pyyaml
3143
Python-yaml is a complete YAML 1.1 parser and emitter
3244
for Python. It can parse all examples from the specification. The parsing
3345
algorithm is simple enough to be a reference for YAML parser implementors.
@@ -51,13 +63,13 @@ rm -rf %{{buildroot}}/usr/share/doc/%{{name}}/
5163
%clean
5264
rm -rf %{{buildroot}}
5365

54-
%files -n %{{name}}
66+
%files -n python2-pyyaml
5567
%license LICENSE
5668
%doc CHANGES README
5769
%{{_libdir}}/python2*/site-packages/yaml/
5870
%{{_libdir}}/python2*/site-packages/PyYAML*.egg-info
5971

60-
%files -n python3-%{{name}}
72+
%files -n python3-pyyaml
6173
%license LICENSE
6274
%doc CHANGES README
6375
%{{_libdir}}/python3*/site-packages/yaml/

l2tdevtools/review_helpers/pylint.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ class PylintHelper(cli.CLIHelper):
2020

2121
_RCFILE_NAME = '.pylintrc'
2222

23+
def _GetVersion(self):
24+
"""Retrieves the pylint version.
25+
26+
Returns:
27+
tuple[int]: pylint version as a tuple of integers or (0, 0, 0) if
28+
not available.
29+
"""
30+
version_tuple = (0, 0, 0)
31+
32+
exit_code, output, _ = self.RunCommand('pylint --version')
33+
if exit_code == 0:
34+
for line in output.split('\n'):
35+
if line.startswith('pylint '):
36+
_, _, version = line.partition(' ')
37+
# Remove a trailing comma.
38+
version, _, _ = version.partition(',')
39+
40+
version_tuple = tuple([
41+
int(digit, 10) for digit in version.split('.')])
42+
43+
return version_tuple
44+
2345
def CheckFiles(self, filenames, rcfile):
2446
"""Checks if the linting of the files is correct using pylint.
2547
@@ -30,12 +52,22 @@ def CheckFiles(self, filenames, rcfile):
3052
Returns:
3153
bool: True if the files were linted without errors.
3254
"""
55+
version_tuple = self._GetVersion()
56+
3357
print('Running linter on changed files.')
3458
failed_filenames = []
3559
for filename in filenames:
3660
print('Checking: {0:s}'.format(filename))
3761

3862
command = 'pylint --rcfile="{0:s}" {1:s}'.format(rcfile, filename)
63+
# For now disable pylint 2.1.1 and later specific checks.
64+
if version_tuple >= (2, 1, 1):
65+
additional_checks = [
66+
'assignment-from-none', 'chained-comparison',
67+
'useless-object-inheritance']
68+
command = '{0:s} --disable={1:s}'.format(
69+
command, ','.join(additional_checks))
70+
3971
exit_code = subprocess.call(command, shell=True)
4072
if exit_code != 0:
4173
failed_filenames.append(filename)
@@ -53,19 +85,7 @@ def CheckUpToDateVersion(self):
5385
Returns:
5486
bool: True if the pylint version is up to date.
5587
"""
56-
exit_code, output, _ = self.RunCommand('pylint --version')
57-
if exit_code != 0:
58-
return False
59-
60-
version_tuple = (0, 0, 0)
61-
for line in output.split('\n'):
62-
if line.startswith('pylint '):
63-
_, _, version = line.partition(' ')
64-
# Remove a trailing comma.
65-
version, _, _ = version.partition(',')
66-
67-
version_tuple = tuple([int(digit, 10) for digit in version.split('.')])
68-
88+
version_tuple = self._GetVersion()
6989
return version_tuple >= self._MINIMUM_VERSION_TUPLE
7090

7191
def GetRCFile(self, project_path):

tests/review_helpers/pylint.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,23 @@
1414
class PylintHelperTest(test_lib.BaseTestCase):
1515
"""Tests the pylint helper"""
1616

17+
# pylint: disable=protected-access
18+
1719
def testInitialize(self):
18-
"""Tests that the helper can be initialized."""
20+
"""Tests the __init__ function."""
1921
helper = pylint.PylintHelper()
2022
self.assertIsNotNone(helper)
2123

24+
def testGetVersion(self):
25+
"""Tests the _GetVersion function."""
26+
helper = pylint.PylintHelper()
27+
28+
helper._GetVersion()
29+
30+
# TODO: add tests for CheckFiles
31+
# TODO: add tests for CheckUpToDateVersion
32+
# TODO: add tests for GetRCFile
33+
2234

2335
if __name__ == '__main__':
2436
unittest.main()

0 commit comments

Comments
 (0)