From e231d4a5104c342c8bbe3fc50cc0e81e20d448cf Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 6 Oct 2009 19:45:26 +0200 Subject: [PATCH] [entropy*] fix improper usage of == '' and == "" --- libraries/entropy/db.py | 6 +++--- libraries/entropy/output.py | 2 +- libraries/entropy/services/interfaces.py | 2 +- libraries/entropy/services/ugc/interfaces.py | 2 +- libraries/entropy/tools.py | 6 +++--- libraries/entropy/transceivers.py | 5 ++++- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/libraries/entropy/db.py b/libraries/entropy/db.py index 9cdd4f8fb..b6e7ad605 100644 --- a/libraries/entropy/db.py +++ b/libraries/entropy/db.py @@ -2644,7 +2644,7 @@ class EntropyRepository: """ def mymf(source): - if (not source) or (source == "") or \ + if (not source) or \ (not self.entropyTools.is_valid_string(source)): return 0 @@ -8672,12 +8672,12 @@ class EntropyRepository: if (not justname) and \ ((direction == "~") or (direction == "=") or \ - (direction == '' and not justname) or (direction == '' and \ + ((not direction) and (not justname)) or ((not direction) and \ not justname and strippedAtom.endswith("*"))): # any revision within the version specified # OR the specified version - if (direction == '' and not justname): + if ((not direction) and (not justname)): direction = "=" # remove gentoo revision (-r0 if none) diff --git a/libraries/entropy/output.py b/libraries/entropy/output.py index 815caf408..63ab18381 100644 --- a/libraries/entropy/output.py +++ b/libraries/entropy/output.py @@ -185,7 +185,7 @@ def xtermTitleReset(): global default_xterm_title if default_xterm_title is None: prompt_command = os.getenv('PROMPT_COMMAND') - if prompt_command == "": + if not prompt_command: default_xterm_title = "" elif prompt_command is not None: from entropy.tools import getstatusoutput diff --git a/libraries/entropy/services/interfaces.py b/libraries/entropy/services/interfaces.py index 90b75d85b..773f53175 100644 --- a/libraries/entropy/services/interfaces.py +++ b/libraries/entropy/services/interfaces.py @@ -433,7 +433,7 @@ class SocketHost: data += self.request.recv(1024) if self.__data_counter is None: - if data == '': # client wants to close + if not data: # client wants to close return True elif data == self.server.processor.HostInterface.answers['noop']: return False diff --git a/libraries/entropy/services/ugc/interfaces.py b/libraries/entropy/services/ugc/interfaces.py index 5220a838e..bb205dc61 100644 --- a/libraries/entropy/services/ugc/interfaces.py +++ b/libraries/entropy/services/ugc/interfaces.py @@ -2005,7 +2005,7 @@ class Client: data = do_receive() if self.buffer_length == None: self.buffered_data = '' - if (data == '') or (data == self.answers['cl']): + if (not data) or (data == self.answers['cl']): # nein! no support, KAPUTT! # RAUSS! if not self.quiet: diff --git a/libraries/entropy/tools.py b/libraries/entropy/tools.py index c6fd6ea53..a4d88c883 100644 --- a/libraries/entropy/tools.py +++ b/libraries/entropy/tools.py @@ -2965,7 +2965,7 @@ def extract_ftp_data(ftpuri): @rtype: """ ftpuser = ftpuri.split("ftp://")[-1].split(":")[0] - if (ftpuser == ""): + if (not ftpuser): ftpuser = "anonymous@" ftppassword = "anonymous" else: @@ -2973,12 +2973,12 @@ def extract_ftp_data(ftpuri): if len(ftppassword) > 1: ftppassword = '@'.join(ftppassword) ftppassword = ftppassword.split(":")[-1] - if (ftppassword == ""): + if (not ftppassword): ftppassword = "anonymous" else: ftppassword = ftppassword[0] ftppassword = ftppassword.split(":")[-1] - if (ftppassword == ""): + if (not ftppassword): ftppassword = "anonymous" ftpport = ftpuri.split(":")[-1] diff --git a/libraries/entropy/transceivers.py b/libraries/entropy/transceivers.py index 4355f869f..0f0e82640 100644 --- a/libraries/entropy/transceivers.py +++ b/libraries/entropy/transceivers.py @@ -258,7 +258,8 @@ class UrlFetcher: while True: try: rsx = self.__remotefile.read(self.__buffersize) - if rsx == '': break + if not rsx: + break if self.__abort_check_func != None: self.__abort_check_func() if self.__thread_stop_func != None: @@ -498,8 +499,10 @@ class MultipleUrlFetcher: t = ParallelTask(do_download, self.__download_statuses, th_id, downloader) self.__thread_pool[th_id] = t t.start() + self.show_download_files_info() self.__show_progress = True + while len(self.__url_path_list) != len(self.__download_statuses): try: time.sleep(0.5)