Skip to content

Commit

Permalink
Changes for building PyYAML for Fedora Core 27 (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jan 17, 2019
1 parent 215cbcf commit 8f9058f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 18 deletions.
20 changes: 16 additions & 4 deletions data/rpm_templates/PyYAML.spec
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,22 @@ algorithm is simple enough to be a reference for YAML parser implementors.
A simple extension API is also provided. The package is built using libyaml
for improved speed.

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

%description -n python3-%{{name}}
%description -n python2-pyyaml
Python-yaml is a complete YAML 1.1 parser and emitter
for Python. It can parse all examples from the specification. The parsing
algorithm is simple enough to be a reference for YAML parser implementors.
A simple extension API is also provided. The package is built using libyaml
for improved speed.

%package -n python3-pyyaml
Summary: YAML parser and emitter for Python

%description -n python3-pyyaml
Python-yaml is a complete YAML 1.1 parser and emitter
for Python. It can parse all examples from the specification. The parsing
algorithm is simple enough to be a reference for YAML parser implementors.
Expand All @@ -51,13 +63,13 @@ rm -rf %{{buildroot}}/usr/share/doc/%{{name}}/
%clean
rm -rf %{{buildroot}}

%files -n %{{name}}
%files -n python2-pyyaml
%license LICENSE
%doc CHANGES README
%{{_libdir}}/python2*/site-packages/yaml/
%{{_libdir}}/python2*/site-packages/PyYAML*.egg-info

%files -n python3-%{{name}}
%files -n python3-pyyaml
%license LICENSE
%doc CHANGES README
%{{_libdir}}/python3*/site-packages/yaml/
Expand Down
46 changes: 33 additions & 13 deletions l2tdevtools/review_helpers/pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ class PylintHelper(cli.CLIHelper):

_RCFILE_NAME = '.pylintrc'

def _GetVersion(self):
"""Retrieves the pylint version.
Returns:
tuple[int]: pylint version as a tuple of integers or (0, 0, 0) if
not available.
"""
version_tuple = (0, 0, 0)

exit_code, output, _ = self.RunCommand('pylint --version')
if exit_code == 0:
for line in output.split('\n'):
if line.startswith('pylint '):
_, _, version = line.partition(' ')
# Remove a trailing comma.
version, _, _ = version.partition(',')

version_tuple = tuple([
int(digit, 10) for digit in version.split('.')])

return version_tuple

def CheckFiles(self, filenames, rcfile):
"""Checks if the linting of the files is correct using pylint.
Expand All @@ -30,12 +52,22 @@ def CheckFiles(self, filenames, rcfile):
Returns:
bool: True if the files were linted without errors.
"""
version_tuple = self._GetVersion()

print('Running linter on changed files.')
failed_filenames = []
for filename in filenames:
print('Checking: {0:s}'.format(filename))

command = 'pylint --rcfile="{0:s}" {1:s}'.format(rcfile, filename)
# For now disable pylint 2.1.1 and later specific checks.
if version_tuple >= (2, 1, 1):
additional_checks = [
'assignment-from-none', 'chained-comparison',
'useless-object-inheritance']
command = '{0:s} --disable={1:s}'.format(
command, ','.join(additional_checks))

exit_code = subprocess.call(command, shell=True)
if exit_code != 0:
failed_filenames.append(filename)
Expand All @@ -53,19 +85,7 @@ def CheckUpToDateVersion(self):
Returns:
bool: True if the pylint version is up to date.
"""
exit_code, output, _ = self.RunCommand('pylint --version')
if exit_code != 0:
return False

version_tuple = (0, 0, 0)
for line in output.split('\n'):
if line.startswith('pylint '):
_, _, version = line.partition(' ')
# Remove a trailing comma.
version, _, _ = version.partition(',')

version_tuple = tuple([int(digit, 10) for digit in version.split('.')])

version_tuple = self._GetVersion()
return version_tuple >= self._MINIMUM_VERSION_TUPLE

def GetRCFile(self, project_path):
Expand Down
14 changes: 13 additions & 1 deletion tests/review_helpers/pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,23 @@
class PylintHelperTest(test_lib.BaseTestCase):
"""Tests the pylint helper"""

# pylint: disable=protected-access

def testInitialize(self):
"""Tests that the helper can be initialized."""
"""Tests the __init__ function."""
helper = pylint.PylintHelper()
self.assertIsNotNone(helper)

def testGetVersion(self):
"""Tests the _GetVersion function."""
helper = pylint.PylintHelper()

helper._GetVersion()

# TODO: add tests for CheckFiles
# TODO: add tests for CheckUpToDateVersion
# TODO: add tests for GetRCFile


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

0 comments on commit 8f9058f

Please sign in to comment.