Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 566c6ff

Browse files
committed
Added a license file reading routine
1 parent 54bf6cd commit 566c6ff

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

python/utilities.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Helper Functions for the Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler
3+
4+
ACIS and SAT are registered trademarks of Spatial Corporation.
5+
6+
The Python module is developed by Onur R. Bingol and released under MIT license.
7+
Please see the LICENSE file for details.
8+
"""
9+
10+
import re
11+
12+
13+
def read_spa_license_key(filename=''):
14+
regex_seq = re.compile(r'\s?\"(.*)\"')
15+
16+
license_text = ""
17+
search_obj = None
18+
19+
try:
20+
with open(filename, 'r') as fp:
21+
license_code = fp.read()
22+
search_obj = regex_seq.finditer(license_code.strip())
23+
fp.close()
24+
except IOError:
25+
raise IOError('Cannot open file: ' + filename)
26+
27+
if search_obj:
28+
for line in search_obj:
29+
license_text = license_text + line.group(1)
30+
else:
31+
raise ValueError('The file "' + filename + '" does not contain the unlock key!')
32+
33+
return license_text

0 commit comments

Comments
 (0)