Read the data files from the same path where the script resides.

This commit is contained in:
Sei Lisa 2015-03-06 20:29:54 +01:00
parent ac9f0c30a5
commit a9179f2779
2 changed files with 9 additions and 2 deletions

View file

@ -21,6 +21,7 @@
# TODO: Add info to be able to propagate error position to the source. # TODO: Add info to be able to propagate error position to the source.
from lslcommon import Key, Vector, Quaternion from lslcommon import Key, Vector, Quaternion
import lslcommon
import lslfuncs import lslfuncs
import sys, re import sys, re
from base64 import b64encode from base64 import b64encode
@ -2326,7 +2327,7 @@ list lazy_list_set(list L, integer i, list v)
parse_num_re = re.compile(r'^\s*(-?(?=[0-9]|\.[0-9])[0-9]*((?:\.[0-9]*)?(?:[Ee][+-]?[0-9]+)?))\s*$') parse_num_re = re.compile(r'^\s*(-?(?=[0-9]|\.[0-9])[0-9]*((?:\.[0-9]*)?(?:[Ee][+-]?[0-9]+)?))\s*$')
parse_str_re = re.compile(ur'^"((?:[^"\\]|\\.)*)"$') parse_str_re = re.compile(ur'^"((?:[^"\\]|\\.)*)"$')
f = open('builtins.txt', 'rb') f = open(lslcommon.DataPath + 'builtins.txt', 'rb')
try: try:
while True: while True:
line = f.readline() line = f.readline()
@ -2443,7 +2444,7 @@ list lazy_list_set(list L, integer i, list v)
f.close() f.close()
# Load the side-effect-free table as well. # Load the side-effect-free table as well.
f = open('seftable.txt', 'rb') f = open(lslcommon.DataPath + 'seftable.txt', 'rb')
try: try:
while True: while True:
line = f.readline() line = f.readline()

View file

@ -23,6 +23,8 @@ from lslopt.lslparse import parser,EParse
from lslopt.lsloutput import outscript from lslopt.lsloutput import outscript
from lslopt.lsloptimizer import optimizer from lslopt.lsloptimizer import optimizer
import sys import sys
import os
import lslopt.lslcommon
def main(): def main():
if len(sys.argv) < 2: if len(sys.argv) < 2:
@ -129,6 +131,10 @@ Options (+ means active by default, - means inactive by default):
'optsigns','optfloats','constfold','dcr' 'optsigns','optfloats','constfold','dcr'
)) ))
# If it's good to append the basename to it, it's good to append the
# auxiliary files' names to it.
lslopt.lslcommon.DataPath = __file__[:-len(os.path.basename(__file__))]
if sys.argv[1] == '-O': if sys.argv[1] == '-O':
if len(sys.argv) < 4: if len(sys.argv) < 4:
sys.stderr.write('Command line: Not enough parameters\n') sys.stderr.write('Command line: Not enough parameters\n')