commit a missing file; revert one that hsould be commited [sorry]

This commit is contained in:
Nikos Kouremenos 2005-07-24 19:04:29 +00:00
parent 59050d4134
commit d4f0994f77
2 changed files with 20 additions and 21 deletions

View file

@ -84,7 +84,6 @@ def get_contact_instances_from_jid(account, jid):
return contacts_instances return contacts_instances
def get_first_contact_instance_from_jid(account, jid): def get_first_contact_instance_from_jid(account, jid):
print 'jIIIIIIIIIIIIIIIIIIID', jid
if jid in contacts[account]: if jid in contacts[account]:
contact = contacts[account][jid][0] contact = contacts[account][jid][0]
else: # it's fake jid else: # it's fake jid

View file

@ -116,12 +116,12 @@ class Logger:
show = nick show = nick
for f in files: for f in files:
path_to_file = os.path.join(LOGPATH, f) path_to_file = os.path.join(LOGPATH, f)
fic = open(path_to_file, 'a') fil = open(path_to_file, 'a')
fic.write('%s:%s:%s' % (tim, jid, show)) fil.write('%s:%s:%s' % (tim, jid, show))
if msg: if msg:
fic.write(':' + msg) fil.write(':' + msg)
fic.write('\n') fil.write('\n')
fic.close() fil.close()
def __get_path_to_file(self, fjid): def __get_path_to_file(self, fjid):
jid = fjid.split('/')[0] jid = fjid.split('/')[0]
@ -133,18 +133,18 @@ class Logger:
path_to_file = os.path.join(LOGPATH, fjid) path_to_file = os.path.join(LOGPATH, fjid)
return path_to_file return path_to_file
def get_nb_line(self, fjid): def get_no_of_lines(self, fjid):
'''return total number of lines in a log file '''return total number of lines in a log file
return 0 if log file does not exist''' return 0 if log file does not exist'''
path_to_file = self.__get_path_to_file(fjid) path_to_file = self.__get_path_to_file(fjid)
if not os.path.exists(path_to_file): if not os.path.exists(path_to_file):
return 0 return 0
fic = open(path_to_file, 'r') fil = open(path_to_file, 'r')
nb = 0 # number of lines no_of_lines = 0 # number of lines
while fic.readline(): while fil.readline():
nb += 1 no_of_lines += 1
fic.close() fil.close()
return nb return no_of_lines
def read(self, fjid, begin_line, end_line): def read(self, fjid, begin_line, end_line):
'''return number of lines read and the text in the lines '''return number of lines read and the text in the lines
@ -152,17 +152,17 @@ class Logger:
path_to_file = self.__get_path_to_file(fjid) path_to_file = self.__get_path_to_file(fjid)
if not os.path.exists(path_to_file): if not os.path.exists(path_to_file):
return 0, [] return 0, []
fic = open(path_to_file, 'r') fil = open(path_to_file, 'r')
nb = 0 # number of lines no_of_lines = 0 # number of lines
lines = [] lines = []
while (nb < begin_line and fic.readline()): while (no_of_lines < begin_line and fil.readline()):
nb += 1 no_of_lines += 1
while nb < end_line: while no_of_lines < end_line:
line = fic.readline() line = fil.readline()
if line: if line:
line = helpers.from_one_line(line) line = helpers.from_one_line(line)
lineSplited = line.split(':') lineSplited = line.split(':')
if len(lineSplited) > 2: if len(lineSplited) > 2:
lines.append(lineSplited) lines.append(lineSplited)
nb += 1 no_of_lines += 1
return nb, lines return no_of_lines, lines