From 6ef0471234f84ee770c0c027db01d1a42afc5db0 Mon Sep 17 00:00:00 2001 From: Miroslav Suchý Date: May 27 2020 12:59:56 +0000 Subject: fix import-outside-toplevel pylint warning I am going to not touch test.py as if there is failure in import it just fail that one test. --- diff --git a/rpmfluff/rpmbuild.py b/rpmfluff/rpmbuild.py index f5684d6..5d25604 100644 --- a/rpmfluff/rpmbuild.py +++ b/rpmfluff/rpmbuild.py @@ -13,8 +13,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +import codecs import os import os.path +import random import re import shutil import subprocess @@ -298,7 +300,6 @@ class SimpleRpmBuild(RpmBuild): self.section_postun += postunLine def gather_spec_file(self, tmpDir): - import codecs if self.specbasename and self.specbasename != '': specFileName = os.path.join(tmpDir, "%s.spec" % self.specbasename) else: @@ -686,7 +687,6 @@ class SimpleRpmBuild(RpmBuild): def add_simple_payload_file_random(self, size=100): """Trivial hook for adding a simple file to payload, random (ASCII printable chars) content of specified size (default is 100 bytes), name based on the packages ENVRA and count of the source files (to be unique)""" - import random random.seed() content = '' for _ in range(size): @@ -765,7 +765,6 @@ class SimpleRpmBuild(RpmBuild): # (which would lead to duplicates in the merged log). # So we rot13 the desired message, and echo that through a shell # rot13 (using tr), getting the desired output to stderr - import codecs rot13Message = codecs.getencoder('rot-13')(message)[0] self.section_build += "echo '%s' | tr 'a-zA-Z' 'n-za-mN-ZA-N' 1>&2\n" % rot13Message diff --git a/rpmfluff/sourcefile.py b/rpmfluff/sourcefile.py index ab6811c..dd4d59a 100644 --- a/rpmfluff/sourcefile.py +++ b/rpmfluff/sourcefile.py @@ -13,6 +13,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +import codecs import os.path class SourceFile: @@ -22,7 +23,6 @@ class SourceFile: self.encoding = encoding def _get_dst_file(self, sourcesDir): - import codecs dstFileName = os.path.join(sourcesDir, self.sourceName) if isinstance(self.content, bytes): dstFile = open(dstFileName, "wb")