Move 'readlines' to helpers
This commit is contained in:
parent
e183a4714d
commit
8f7ece20eb
|
@ -11,8 +11,8 @@ from pathlib import Path
|
|||
import re
|
||||
|
||||
import rpm
|
||||
from rpmlint import pkg as Pkg
|
||||
from rpmlint.checks.AbstractCheck import AbstractCheck
|
||||
from rpmlint.helpers import readlines
|
||||
|
||||
|
||||
chkconfig_content_regex = re.compile(r'^\s*#\s*chkconfig:\s*([-0-9]+)\s+[-0-9]+\s+[-0-9]+')
|
||||
|
@ -108,7 +108,7 @@ class InitScriptCheck(AbstractCheck):
|
|||
# check common error in file content
|
||||
content = None
|
||||
try:
|
||||
content = list(Pkg.readlines(pkgfile.path))
|
||||
content = list(readlines(pkgfile.path))
|
||||
except Exception as e:
|
||||
self.output.add_info('W', pkg, 'read-error', e)
|
||||
continue
|
||||
|
|
|
@ -14,6 +14,7 @@ from urllib.parse import urlparse
|
|||
import rpm
|
||||
from rpmlint import pkg as Pkg
|
||||
from rpmlint.checks.AbstractCheck import AbstractCheck
|
||||
from rpmlint.helpers import readlines
|
||||
|
||||
# Don't check for hardcoded library paths in biarch packages
|
||||
DEFAULT_BIARCH_PACKAGES = '^(gcc|glibc)'
|
||||
|
@ -148,7 +149,7 @@ class SpecCheck(AbstractCheck):
|
|||
def check_spec(self, pkg):
|
||||
self._spec_file = pkg.name
|
||||
spec_only = isinstance(pkg, Pkg.FakePkg)
|
||||
spec_lines = Pkg.readlines(self._spec_file)
|
||||
spec_lines = readlines(self._spec_file)
|
||||
patches = {}
|
||||
applied_patches = []
|
||||
applied_patches_ifarch = []
|
||||
|
|
|
@ -42,3 +42,9 @@ def byte_to_string(item):
|
|||
|
||||
# everything else shall be decoded and fails replaced
|
||||
return item.decode(encoding='UTF-8', errors='replace')
|
||||
|
||||
|
||||
def readlines(path):
|
||||
with open(path, 'rb') as fobj:
|
||||
for line in fobj:
|
||||
yield byte_to_string(line)
|
||||
|
|
|
@ -19,7 +19,6 @@ try:
|
|||
except ImportError:
|
||||
_magic = None
|
||||
import rpm
|
||||
|
||||
from rpmlint.helpers import byte_to_string, print_warning
|
||||
from rpmlint.pkgfile import PkgFile
|
||||
|
||||
|
@ -132,12 +131,6 @@ def has_forbidden_controlchars(val):
|
|||
return False
|
||||
|
||||
|
||||
def readlines(path):
|
||||
with open(path, 'rb') as fobj:
|
||||
for line in fobj:
|
||||
yield byte_to_string(line)
|
||||
|
||||
|
||||
# from yum 3.2.27, rpmUtils.miscutils, with rpmlint modifications
|
||||
def compareEVR(evr1, evr2):
|
||||
(e1, v1, r1) = evr1
|
||||
|
|
Loading…
Reference in New Issue