From: Nicolas Boisselier Date: Tue, 11 Aug 2015 23:27:39 +0000 (+0100) Subject: nb.py X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=71c5d8557e9ee482ab81340038ec42d838eedeca;p=nb.git nb.py --- diff --git a/lib/python/nb.py b/lib/python/nb.py index 2c75f804..285ba0d6 100644 --- a/lib/python/nb.py +++ b/lib/python/nb.py @@ -1,12 +1,19 @@ import sys -class NB: - debug = false +def debug(msg): + print >> sys.stderr, msg - def __init__(self):#, name, salary): - self.name = name - self.salary = salary - - def debug(msg): - if NB.debug: - print sys.stderr, msg +def file_head_tail(fname): + with open(fname, 'rb') as fh: + first = next(fh) + offs = -100 + while True: + fh.seek(offs, 2) + lines = fh.readlines() + if len(lines)>1: + last = lines[-1] + break + offs *= 2 + return [first,last] + print first + print last diff --git a/lib/python/nb.pyc b/lib/python/nb.pyc index 24a3d7e3..8f360f29 100644 Binary files a/lib/python/nb.pyc and b/lib/python/nb.pyc differ