]> git.nbdom.net Git - nb.git/commitdiff
nb.py
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 11 Aug 2015 23:27:39 +0000 (00:27 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 11 Aug 2015 23:27:39 +0000 (00:27 +0100)
lib/python/nb.py
lib/python/nb.pyc

index 2c75f804761424c2ba8a11970ab05bf56be51bcc..285ba0d6ff30755f58c8f30978e2c6fc3718e3d4 100644 (file)
@@ -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
index 24a3d7e39399208ffe90bab5543b008192da5153..8f360f29f883bef2c54e6109906841698d82a50c 100644 (file)
Binary files a/lib/python/nb.pyc and b/lib/python/nb.pyc differ