mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Clean up some problems discovered with pylint and pychecker
Much of this is formatting to make pylint happy but it also fixes some real bugs.
This commit is contained in:
@@ -15,10 +15,6 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
import ldap
|
||||
import ldif
|
||||
import re
|
||||
import cStringIO
|
||||
import copy
|
||||
|
||||
import ipapython.ipautil
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
# the reference counting and SharedSocketClient provides an constructor
|
||||
# and close() method that call incref() and decref() correctly.
|
||||
|
||||
import socket
|
||||
import errno
|
||||
from httplib import UnimplementedFileMode
|
||||
|
||||
class SharedSocket:
|
||||
def __init__(self, sock):
|
||||
self.sock = sock
|
||||
@@ -91,13 +95,13 @@ class SSLFile(SharedSocketClient):
|
||||
break
|
||||
L.append(s)
|
||||
avail += len(s)
|
||||
all = "".join(L)
|
||||
alldata = "".join(L)
|
||||
if size is None:
|
||||
self._buf = ''
|
||||
return all
|
||||
return alldata
|
||||
else:
|
||||
self._buf = all[size:]
|
||||
return all[:size]
|
||||
self._buf = alldata[size:]
|
||||
return alldata[:size]
|
||||
|
||||
def readline(self):
|
||||
L = [self._buf]
|
||||
@@ -114,25 +118,25 @@ class SSLFile(SharedSocketClient):
|
||||
# loop exited because there is no more data
|
||||
return "".join(L)
|
||||
else:
|
||||
all = "".join(L)
|
||||
alldata = "".join(L)
|
||||
# XXX could do enough bookkeeping not to do a 2nd search
|
||||
i = all.find("\n") + 1
|
||||
line = all[:i]
|
||||
self._buf = all[i:]
|
||||
i = alldata.find("\n") + 1
|
||||
line = alldata[:i]
|
||||
self._buf = alldata[i:]
|
||||
return line
|
||||
|
||||
def readlines(self, sizehint=0):
|
||||
total = 0
|
||||
list = []
|
||||
inlist = []
|
||||
while True:
|
||||
line = self.readline()
|
||||
if not line:
|
||||
break
|
||||
list.append(line)
|
||||
inlist.append(line)
|
||||
total += len(line)
|
||||
if sizehint and total >= sizehint:
|
||||
break
|
||||
return list
|
||||
return inlist
|
||||
|
||||
def fileno(self):
|
||||
return self._sock.fileno()
|
||||
|
||||
@@ -57,7 +57,7 @@ def get_domain_name():
|
||||
try:
|
||||
config.init_config()
|
||||
domain_name = config.config.get_domain()
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
return domain_name
|
||||
@@ -362,13 +362,13 @@ class GeneralizedTimeZone(datetime.tzinfo):
|
||||
if self.houroffset < 0:
|
||||
self.minoffset *= -1
|
||||
|
||||
def utcoffset(self, dt):
|
||||
def utcoffset(self):
|
||||
return datetime.timedelta(hours=self.houroffset, minutes=self.minoffset)
|
||||
|
||||
def dst(self, dt):
|
||||
def dst(self):
|
||||
return datetime.timedelta(0)
|
||||
|
||||
def tzname(self, dt):
|
||||
def tzname(self):
|
||||
return self.name
|
||||
|
||||
|
||||
@@ -748,7 +748,7 @@ class AttributeValueCompleter:
|
||||
return self.default_value.get(self.lhs, None)
|
||||
elif default_value_type is FunctionType:
|
||||
return self.default_value(self.lhs)
|
||||
elif default_value_type is StringsType:
|
||||
elif default_value_type is StringType:
|
||||
return self.default_value
|
||||
else:
|
||||
return None
|
||||
@@ -759,7 +759,7 @@ class AttributeValueCompleter:
|
||||
else:
|
||||
self.completions = self.lhs_names
|
||||
|
||||
def complete(self, text, state):
|
||||
def complete(self, state):
|
||||
self.line_buffer= readline.get_line_buffer()
|
||||
self.parse_input()
|
||||
if not self.lhs_complete:
|
||||
@@ -905,7 +905,7 @@ class ItemCompleter:
|
||||
else:
|
||||
self.completions = self.items
|
||||
|
||||
def complete(self, text, state):
|
||||
def complete(self, state):
|
||||
self.line_buffer= readline.get_line_buffer()
|
||||
if state == 0:
|
||||
beg = readline.get_begidx()
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
import httplib
|
||||
import getpass
|
||||
import socket
|
||||
import errno
|
||||
|
||||
from nss.error import NSPRError
|
||||
import nss.io as io
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import errno
|
||||
import shutil
|
||||
import logging
|
||||
import ConfigParser
|
||||
@@ -110,13 +109,13 @@ class FileStore:
|
||||
logging.debug(" -> Not backing up - '%s' doesn't exist", path)
|
||||
return
|
||||
|
||||
(reldir, file) = os.path.split(path)
|
||||
(reldir, backupfile) = os.path.split(path)
|
||||
|
||||
filename = ""
|
||||
for i in range(8):
|
||||
h = "%02x" % self.random.randint(0,255)
|
||||
filename += h
|
||||
filename += "-"+file
|
||||
filename += "-"+backupfile
|
||||
|
||||
backup_path = os.path.join(self._path, filename)
|
||||
if os.path.exists(backup_path):
|
||||
|
||||
Reference in New Issue
Block a user