Skip to content

Commit f91feb4

Browse files
committed
add get last no blank line func.
1 parent 7f987f0 commit f91feb4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

utility.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,17 @@ def log_lockfile(prog):
591591
fcntl.fcntl(lockfile_fd, fcntl.F_SETFD, old_flags | fcntl.FD_CLOEXEC)
592592
return lockfile
593593

594+
def last_non_blank_line(buf):
595+
596+
all_lines = buf.splitlines()
597+
all_lines.reverse()
598+
for line in all_lines:
599+
if (len(line) > 0):
600+
return line
601+
# shouldn't occur unless there's no output
602+
return ""
603+
604+
594605
if __name__ == '__main__':
595606
#configvalue = getConfig("./config.ini", "mysql", "port")
596607
#print configvalue

0 commit comments

Comments
 (0)