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 2017 Ville Rantanen
|
||||
#
|
||||
@@ -23,7 +23,7 @@ __author__ = "Ville Rantanen"
|
||||
__version__ = "0.1"
|
||||
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser
|
||||
import unicodedata, re
|
||||
import subprocess
|
||||
|
||||
@@ -46,12 +46,12 @@ def which(program):
|
||||
|
||||
class SCReader:
|
||||
""" Class for reading SC files.
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
def __init__(self,data):
|
||||
self.data=data.split('\n')
|
||||
self.parserre=re.compile('.* ([A-Z]+)([0-9]+) = (.*)')
|
||||
|
||||
|
||||
def _parse_row(self,string):
|
||||
col=None
|
||||
row=None
|
||||
@@ -62,14 +62,14 @@ class SCReader:
|
||||
row=self.try_int(m.group(2))
|
||||
content=m.group(3)
|
||||
return col,row,content
|
||||
|
||||
|
||||
def try_int(self,string):
|
||||
|
||||
|
||||
try:
|
||||
return int(string)
|
||||
except:
|
||||
return string
|
||||
|
||||
|
||||
def alpha_to_column(self,alpha):
|
||||
''' Returns a column number from spreadsheet column alphabet '''
|
||||
n=0
|
||||
@@ -78,7 +78,7 @@ class SCReader:
|
||||
o+=(ord(char.upper())-64)*(26**n)
|
||||
n+=1
|
||||
return int(o-1)
|
||||
|
||||
|
||||
def next(self):
|
||||
''' Returns the next row in the table, three items: column, row, content'''
|
||||
return self._parse_row(self.reader.next())
|
||||
@@ -89,7 +89,7 @@ class SCReader:
|
||||
|
||||
def setup_options():
|
||||
''' Setup the command line options '''
|
||||
|
||||
|
||||
parser=ArgumentParser()
|
||||
parser.add_argument("-v","--version",action='version', version=__version__)
|
||||
parser.add_argument("-d",type=str,dest="delimiter",default="\t",
|
||||
@@ -97,8 +97,8 @@ def setup_options():
|
||||
parser.add_argument("sc",type=str,action="store",
|
||||
help="SC file to convert")
|
||||
options=parser.parse_args()
|
||||
return options
|
||||
|
||||
return options
|
||||
|
||||
def tsv_write(screader,fileout,delim):
|
||||
''' writes a TSV from SCReader iterator '''
|
||||
content=[]
|
||||
|
||||
Reference in New Issue
Block a user