fix pylint error for osc 88/220088/10 submit/trunk/20191221.141128
authoryan11.meng <yan11.meng@samsung.com>
Fri, 13 Dec 2019 03:20:45 +0000 (11:20 +0800)
committeryan11.meng <yan11.meng@samsung.com>
Mon, 16 Dec 2019 09:18:56 +0000 (17:18 +0800)
Change-Id: I72b6ecf579e9ab7362269d47e11d0ab6b1176b3d
Signed-off-by: yan11.meng <yan11.meng@samsung.com>
14 files changed:
debian/control
osc/__init__.py
osc/babysitter.py
osc/build.py
osc/cmdln.py
osc/commandline.py
osc/conf.py
osc/core.py
osc/oscerr.py
osc/util/ar.py
packaging/osc.spec
setup.py
tests/common.py
tests/test_setlinkrev.py

index 27868b90b8255a6e70876d3945f86ff3e037c58f..9749a249d6266bc5ffe2876d01a6c11cc74984de 100644 (file)
@@ -9,7 +9,7 @@ Homepage: http://en.opensuse.org/Build_Service/CLI
 Package: osc
 Section: devel
 Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python (>= 2.5), python-urlgrabber, python-rpm, python-m2crypto (>= 0.20)
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python (>= 2.5), python-urlgrabber, python-rpm, python-keyring, python-gobject, python-m2crypto (>= 0.20)
 Suggests: python-gnomekeyring, gnome-keyring, build (> 2010.04.24)
 Description: openSUSE (buildsystem) commander
  Commandline client for the openSUSE Build Service, which allows to access
index 7872a4e5e7951003a55126e611fd8b4e11f1c147..f5dbe69b29a887a9a3b1803e3b5529104e430a1a 100644 (file)
@@ -1,3 +1,3 @@
-__all__ = ['babysitter', 'core', 'commandline', 'oscerr', 'othermethods', 'build', 'fetch', 'meter']
+__all__ = ['babysitter', 'core', 'commandline', 'oscerr', 'build', 'fetch', 'meter']
 
 # vim: sw=4 et
index 682de94ccf1fb59ad08bc651fc2845ee3313ff16..272aabd3dc03e7d109a6b068445ae0f9af8e120b 100644 (file)
@@ -27,7 +27,7 @@ except:
 
 try:
     # import as RPMError because the class "error" is too generic
-    from rpm import error as RPMError
+    from rpm import error as RPMError #pylint: disable=no-name-in-module
 except:
     # if rpm-python isn't installed (we might be on a debian system):
     RPMError = None
index b2fe44c502f08c63e85da0474b8b2371ab352596..218d354c33d29d7528a6386781e6ac659be1f4ab 100644 (file)
@@ -319,7 +319,7 @@ def get_repo(path):
 
     return repositoryDirectory
 
-def get_prefer_pkgs(dirs, wanted_arch, type, cpio):
+def get_prefer_pkgs(dirs, wanted_arch, type, cpio=None):
     import glob
     from .util import repodata, packagequery
     paths = []
@@ -813,7 +813,7 @@ def main(apiurl, opts, argv):
                         self._rmtree(self.name)
                     def __del__(self):
                         self.cleanup()
-                    def __exit__(self):
+                    def __exit__(self, type=None, value=None, trace=None):
                         self.cleanup()
                     def __str__(self):
                         return self.name
index da49ce6134f01b77f1cfd621c0e3b32a0eecc5d8..c4070954b3a8e596bd9cfea77af82c391c1f5f01 100644 (file)
@@ -891,7 +891,7 @@ class RawCmdln(cmd.Cmd):
                 warnings.warn("argument '**%s' on '%s.%s' command "
                               "handler will never get values"
                               % (name, self.__class__.__name__,
-                                 getattr(func, "__name__", getattr(func, "func_name"))))
+                                 getattr(func_defaults, "__name__", getattr(func_defaults, "func_name"))))
             if co_flags & CO_FLAGS_ARGS:
                 name = argnames.pop(-1)
                 tail = "[%s...]" % name.upper()
index 8aba26bb8dfeacf4ea035a10e3f77e33ed2f1165..d7710b2a2e322bc771fcf03b2913d7af7fb5ecd5 100644 (file)
@@ -1152,7 +1152,7 @@ class Osc(cmdln.Cmdln):
                     raise oscerr.UserAbort()
         elif len(args) >= 3:
             # get the arguments from the commandline
-            src_project, src_package, dst_project = args[0:3]
+            src_project, src_package, dst_project = args[0:3] #pylint: disable=unbalanced-tuple-unpacking
             if len(args) == 4:
                 dst_package = args[3]
             else:
@@ -2779,6 +2779,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
             raise oscerr.WrongArgs('Too many arguments.')
 
         if len(args) == 0:
+            wd = os.curdir
             if is_project_dir(os.curdir):
                source_project = store_read_project(os.curdir)
             elif is_package_dir(os.curdir):
@@ -7538,7 +7539,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
             opts.headers = None
             opts.data = None
             opts.file = None
-            return self.do_api('list', opts, *args)
+            return self.do_api('list', opts, *args) #pylint: disable=no-value-for-parameter
 
 
 
index 3239cd81c53ec8446adbfa973aa0c92df77b5cb6..3ca6afbd2a00ad2bd16e67d7c373f5fe5dd14c37 100644 (file)
@@ -73,7 +73,7 @@ except:
     try:
         import gobject
         gobject.set_application_name('osc')
-        import gnomekeyring
+        import gnomekeyring #pylint: disable=import-error
         if os.environ['GNOME_DESKTOP_SESSION_ID']:
             # otherwise gnome keyring bindings spit out errors, when you have
             # it installed, but you are not under gnome
@@ -443,7 +443,7 @@ def get_apiurl_usr(apiurl):
 # cafile/capath locations)
 def _build_opener(url):
     from osc.core import __version__
-    global config
+
     apiurl = urljoin(*parse_apisrv_url(None, url))
     if 'last_opener' not in _build_opener.__dict__:
         _build_opener.last_opener = (None, None)
@@ -733,7 +733,7 @@ def add_section(filename, url, user, passwd):
     """
     Add a section to config file for new api url.
     """
-    global config
+
     cp = get_configParser(filename)
     try:
         cp.add_section(url)
index 052d8ead6cbdd5822031f3f9e2afe6f237e148cd..ed3249714ce507198d8d3d21881f0d109c684279 100644 (file)
@@ -644,7 +644,6 @@ class Project:
         self.pacs_missing = [ i for i in self.pacs_available if i not in self.pacs_have ]
 
     def wc_check(self):
-        global store
         dirty_files = []
         req_storefiles = Project.REQ_STOREFILES
         if conf.config['do_package_tracking']:
@@ -655,7 +654,6 @@ class Project:
         return dirty_files
 
     def wc_repair(self, apiurl=None):
-        global store
         if not os.path.exists(os.path.join(self.dir, store, '_apiurl')) or apiurl:
             if apiurl is None:
                 msg = 'cannot repair wc: the \'_apiurl\' file is missing but ' \
@@ -746,7 +744,7 @@ class Project:
         Returns an ``xml.etree.cElementTree`` object representing the
         parsed contents of the project's ``.osc/_packages`` XML file.
         """
-        global store
+
 
         packages_file = os.path.join(self.absdir, store, '_packages')
         if os.path.isfile(packages_file) and os.path.getsize(packages_file):
@@ -1038,7 +1036,6 @@ class Project:
 
     @staticmethod
     def init_project(apiurl, dir, project, package_tracking=True, getPackageList=True, progress_obj=None, wc_check=True):
-        global store
 
         if not os.path.exists(dir):
             # use makedirs (checkout_no_colon config option might be enabled)
@@ -1067,7 +1064,6 @@ class Package:
         '_size_limit', '_commit_msg')
 
     def __init__(self, workingdir, progress_obj=None, size_limit=None, wc_check=True):
-        global store
 
         self.dir = workingdir
         self.absdir = os.path.abspath(self.dir)
@@ -1754,7 +1750,6 @@ class Package:
                 return i
 
     def get_status(self, excluded=False, *exclude_states):
-        global store
         todo = self.todo
         if not todo:
             todo = self.filenamelist + self.to_be_added + \
@@ -2324,7 +2319,6 @@ rev: %s
 
     @staticmethod
     def init_package(apiurl, project, package, dir, size_limit=None, meta=False, progress_obj=None):
-        global store
 
         if not os.path.exists(dir):
             os.mkdir(dir)
@@ -2917,15 +2911,11 @@ def shorttime(t):
 
 
 def is_project_dir(d):
-    global store
-
     return os.path.exists(os.path.join(d, store, '_project')) and not \
            os.path.exists(os.path.join(d, store, '_package'))
 
 
 def is_package_dir(d):
-    global store
-
     return os.path.exists(os.path.join(d, store, '_project')) and \
            os.path.exists(os.path.join(d, store, '_package'))
 
@@ -2933,9 +2923,6 @@ def parse_disturl(disturl):
     """Parse a disturl, returns tuple (apiurl, project, source, repository,
     revision), else raises an oscerr.WrongArgs exception
     """
-
-    global DISTURL_RE
-
     m = DISTURL_RE.match(disturl)
     if not m:
         raise oscerr.WrongArgs("`%s' does not look like disturl" % disturl)
@@ -2949,8 +2936,6 @@ def parse_buildlogurl(buildlogurl):
     """Parse a build log url, returns a tuple (apiurl, project, package,
     repository, arch), else raises oscerr.WrongArgs exception"""
 
-    global BUILDLOGURL_RE
-
     m = BUILDLOGURL_RE.match(buildlogurl)
     if not m:
         raise oscerr.WrongArgs('\'%s\' does not look like url with a build log' % buildlogurl)
@@ -3052,7 +3037,6 @@ def filedir_to_pac(f, progress_obj=None):
 
 
 def read_filemeta(dir):
-    global store
 
     msg = '\'%s\' is not a valid working copy.' % dir
     filesmeta = os.path.join(dir, store, '_files')
@@ -3068,7 +3052,6 @@ def read_filemeta(dir):
     return r
 
 def store_readlist(dir, name):
-    global store
 
     r = []
     if os.path.exists(os.path.join(dir, store, name)):
@@ -3082,7 +3065,6 @@ def read_tobedeleted(dir):
     return store_readlist(dir, '_to_be_deleted')
 
 def read_sizelimit(dir):
-    global store
 
     r = None
     fname = os.path.join(dir, store, '_size_limit')
@@ -3228,7 +3210,6 @@ def http_DELETE(*args, **kwargs): return http_request('DELETE', *args, **kwargs)
 
 
 def check_store_version(dir):
-    global store
 
     versionfile = os.path.join(dir, store, '_osclib_version')
     try:
@@ -3541,8 +3522,6 @@ def meta_exists(metatype,
                 create_new=True,
                 apiurl=None):
 
-    global metatypes
-
     if not apiurl:
         apiurl = conf.config['apiurl']
     url = make_meta_url(metatype, path_args, apiurl)
@@ -3559,8 +3538,6 @@ def meta_exists(metatype,
     return data
 
 def make_meta_url(metatype, path_args=None, apiurl=None, force=False, remove_linking_repositories=False):
-    global metatypes
-
     if not apiurl:
         apiurl = conf.config['apiurl']
     if metatype not in metatypes.keys():
@@ -3589,8 +3566,6 @@ def edit_meta(metatype,
               change_is_required=False,
               apiurl=None):
 
-    global metatypes
-
     if not apiurl:
         apiurl = conf.config['apiurl']
     if not data:
@@ -4320,7 +4295,6 @@ def get_group_data(apiurl, group, *tags):
 
 def download(url, filename, progress_obj = None, mtime = None):
     import tempfile, shutil
-    global BUFSIZE
 
     o = None
     try:
@@ -4388,8 +4362,6 @@ def dgst(file):
     #if not os.path.exists(file):
         #return None
 
-    global BUFSIZE
-
     try:
         import hashlib
         md5 = hashlib
@@ -4403,7 +4375,7 @@ def dgst(file):
         if not buf: break
         s.update(buf)
     return s.hexdigest()
-    f.close()
#   f.close()
 
 
 def binary(s):
@@ -4428,8 +4400,6 @@ def get_source_file_diff(dir, filename, rev, oldfilename = None, olddir = None,
 
     import difflib
 
-    global store
-
     if not oldfilename:
         oldfilename = filename
 
@@ -5272,7 +5242,7 @@ def get_binarylist_published(apiurl, prj, repo, arch):
     return r
 
 
-def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[], arch=[], oldstate=None):
+def show_results_meta(apiurl=None, prj=None, package=None, lastbuild=None, repository=[], arch=[], oldstate=None):
     query = {}
     if package:
         query['package'] = package
@@ -5295,7 +5265,7 @@ def show_prj_results_meta(apiurl, prj):
     return f.readlines()
 
 
-def get_package_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], oldstate=None):
+def get_package_results(apiurl=None, prj=None, package=None, lastbuild=None, repository=[], arch=[], oldstate=None):
     """ return a package results as a list of dicts """
     r = []
 
@@ -5335,7 +5305,7 @@ def format_results(results, format):
     """apply selected format on each dict in results and return it as a list of strings"""
     return [format % r for r in results]
 
-def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], verbose=False, wait=False, printJoin=None):
+def get_results(apiurl=None, prj=None, package=None, lastbuild=None, repository=[], arch=[], verbose=False, wait=False, printJoin=None):
     r = []
     result_line_templ = '%(rep)-20s %(arch)-10s %(status)s'
     oldstate = None
@@ -5390,7 +5360,6 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], ve
 
 def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None, show_excluded=None):
     #print '----------------------------------------'
-    global buildstatus_symbols
 
     r = []
 
@@ -5917,8 +5886,6 @@ def rebuild(apiurl, prj, package, repo, arch, code=None):
 
 
 def store_read_project(dir):
-    global store
-
     try:
         p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
     except IOError:
@@ -5930,8 +5897,6 @@ def store_read_project(dir):
 
 
 def store_read_package(dir):
-    global store
-
     try:
         p = open(os.path.join(dir, store, '_package')).readlines()[0].strip()
     except IOError:
@@ -5942,8 +5907,6 @@ def store_read_package(dir):
     return p
 
 def store_read_apiurl(dir, defaulturl=True):
-    global store
-
     fname = os.path.join(dir, store, '_apiurl')
     try:
         url = open(fname).readlines()[0].strip()
@@ -5970,8 +5933,6 @@ def store_read_apiurl(dir, defaulturl=True):
     return apiurl
 
 def store_write_string(dir, file, string, subdir=''):
-    global store
-
     if subdir and not os.path.isdir(os.path.join(dir, store, subdir)):
         os.mkdir(os.path.join(dir, store, subdir))
     fname = os.path.join(dir, store, subdir, file)
@@ -5992,14 +5953,10 @@ def store_write_apiurl(dir, apiurl):
     store_write_string(dir, '_apiurl', apiurl + '\n')
 
 def store_unlink_file(dir, file):
-    global store
-
     try: os.unlink(os.path.join(dir, store, file))
     except: pass
 
 def store_read_file(dir, file):
-    global store
-
     try:
         content = open(os.path.join(dir, store, file)).read()
         return content
@@ -6007,8 +5964,6 @@ def store_read_file(dir, file):
         return None
 
 def store_write_initial_packages(dir, project, subelements):
-    global store
-
     fname = os.path.join(dir, store, '_packages')
     root = ET.Element('project', name=project)
     for elem in subelements:
@@ -6480,7 +6435,7 @@ def createPackageDir(pathname, prj_obj=None):
     """
     prj_dir, pac_dir = getPrjPacPaths(pathname)
     if is_project_dir(prj_dir):
-        global store
+
         if not os.path.exists(pac_dir+store):
             prj = prj_obj or Project(prj_dir, False)
             Package.init_package(prj.apiurl, prj.name, pac_dir, pac_dir)
index 372d6462e8b2359abb27c2c32ab8150f697e30eb..7d3f21ca922d96edb4d3faf6d8048e44addcb6e1 100644 (file)
@@ -147,7 +147,7 @@ class PackageFileConflict(PackageError):
         self.msg = msg
 
 class PackageInternalError(PackageError):
-    def __init__(self, prj, pac, msg):
+    def __init__(self, prj, pac=None, msg=None):
         PackageError.__init__(self, prj, pac)
         self.msg = msg
 # vim: sw=4 et
index 34337a13580f1bda570ecfd7c3bc5e36275655b4..6eeb05f93990c71bce9bbfe34e7d356ee56a3692 100644 (file)
@@ -101,7 +101,7 @@ class Ar:
 
     def __init__(self, fn = None, fh = None):
         if fn == None and fh == None:
-            raise ArError('either \'fn\' or \'fh\' must be != None')
+            raise ArError(fn,'either \'fn\' or \'fh\' must be != None')
         if fh != None:
             self.__file = fh
             self.__closefile = False
index a4225f3790b80ebe49fd5899a5fb23da67d1b59c..9f902ffcb13f3e1e4e49bc11e5c02aa0c707cbf2 100644 (file)
@@ -13,6 +13,9 @@ BuildArch:      noarch
 BuildRequires:  python-devel
 BuildRequires:  python-urlgrabber
 Requires:       python-urlgrabber
+Requires:       python-keyring
+Requires:       python-gobject
+Requires:       python-rpm
 
 %if 0%{?suse_version} || "0%{?tizen_version}" != "0"
 BuildRequires:  python-m2crypto
index f608e63ac1e53b2c1a5a80c4b3fa625286dbc07d..220b03c3ad2bc0c41447c778c6eff7f04ab1625e 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ from osc import commandline
 from osc import babysitter
 # optional support for py2exe
 try:
-    import py2exe
+    import py2exe   #pylint: disable=import-error
     HAVE_PY2EXE = True
 except:
     HAVE_PY2EXE = False
index f0fee8b506a79180c75cd3d87020f094e2333f89..7ed9bc8b1c1b9be8ab067165ed4f7c2732cd0b9c 100644 (file)
@@ -17,8 +17,8 @@ try:
     from urlparse import urlparse, parse_qs
 except ImportError:
     from io import StringIO
-    from urllib.request import HTTPHandler, addinfourl, build_opener
-    from urllib.parse import urlparse, parse_qs
+    from urllib.request import HTTPHandler, addinfourl, build_opener #pylint: disable=no-name-in-module,import-error
+    from urllib.parse import urlparse, parse_qs #pylint: disable=no-name-in-module,import-error
 
 def urlcompare(url, *args):
     """compare all components of url except query string - it is converted to
@@ -135,7 +135,7 @@ def DELETE(fullurl, **kwargs):
     return urldecorator('DELETE', fullurl, **kwargs)
 
 def addExpectedRequest(method, url, **kwargs):
-    global EXPECTED_REQUESTS
+
     EXPECTED_REQUESTS.append((method, url, kwargs))
 
 class OscTestCase(unittest.TestCase):
index 6d097122d49cc7fa06c2f3337af03e8a00b7d8b1..da699e0e35560701919e2cd4aa7c2e167be1462b 100644 (file)
@@ -78,7 +78,7 @@ class TestSetLinkRev(OscTestCase):
     @GET('http://localhost/source/osctest/simple/_link', file='md5_rev_link')
     @PUT('http://localhost/source/osctest/simple/_link',
          exp='<link package="srcpkg" project="srcprj" />', text='dummytext')
-    def test_deleterev(self):
+    def test_deleterev1(self):
         """delete rev and vrev attribute from link xml"""
         osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None)