forcing everything python3, might end up with bugs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright 2015 Ville Rantanen
|
||||
#
|
||||
@@ -17,13 +17,14 @@
|
||||
#
|
||||
|
||||
'''simple tail for tsv/csv files.'''
|
||||
from __future__ import print_function
|
||||
|
||||
__author__ = "Ville Rantanen <ville.q.rantanen@gmail.com>"
|
||||
|
||||
__version__ = "0.1"
|
||||
|
||||
import sys,os,argparse
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser
|
||||
|
||||
def setup_options():
|
||||
''' Create command line options '''
|
||||
@@ -31,7 +32,7 @@ def setup_options():
|
||||
simple implementation of tail, keeping the header row
|
||||
|
||||
'''
|
||||
|
||||
|
||||
parser=ArgumentParser(description=usage,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog="\n".join(["Version: "+__version__,__author__]))
|
||||
@@ -64,7 +65,7 @@ def tail(fileob,opts):
|
||||
tail_ordinary(fileob, opts.lines)
|
||||
else:
|
||||
tail_allbutfirst(fileob, -opts.lines)
|
||||
|
||||
|
||||
def tail_allbutfirst(fileob, lines):
|
||||
for i,row in enumerate(fileob):
|
||||
if i<lines-1:
|
||||
@@ -86,12 +87,13 @@ def main():
|
||||
tail(sys.stdin, opts)
|
||||
for fi in opts.file:
|
||||
tail(open(fi,'r'), opts)
|
||||
except IOError as (n,e):
|
||||
except IOError as xxx_todo_changeme:
|
||||
(n,e) = xxx_todo_changeme.args
|
||||
if n==32:
|
||||
pass
|
||||
else:
|
||||
import traceback
|
||||
print traceback.format_exc()
|
||||
print(traceback.format_exc())
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user