forked from johnzero7/XNALaraMesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ascii_ops.py
57 lines (40 loc) · 959 Bytes
/
ascii_ops.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
# <pep8 compliant>
from . import xps_const
def readline(file):
line = file.readline()
line = line.strip()
return line
def getFloat(value):
if value:
try:
return float(value)
except ValueError:
return float('NaN')
return value
def getInt(value):
try:
return int(value)
except ValueError:
return None
def ignoreComment(line):
line = line.replace('#', ' ')
line = line.split()[0]
return line
def ignoreStringComment(line):
line = line.split('#')[0].strip()
return line
def readInt(file):
line = readline(file)
value = ignoreComment(line)
number = getInt(value)
return number
def readString(file):
# String Lenght
line = readline(file)
string = ignoreStringComment(line)
return string
def splitValues(line):
line = line.replace('#', ' ')
values = line.split()
return values