WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.6% of users enabled 2FA.

Commit 9fd54adc authored by Stefan Marr's avatar Stefan Marr
Browse files

Use Python file objects directly as input



- fix wrong separator between path and filename
Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 191fdb60
import os import os
from StringIO import StringIO
def compile_class_from_file(path, filename, system_class, universe): def compile_class_from_file(path, filename, system_class, universe):
return _SourcecodeCompiler().compile(path, filename, system_class, universe) return _SourcecodeCompiler().compile(path, filename, system_class, universe)
...@@ -12,13 +13,11 @@ class _SourcecodeCompiler(object): ...@@ -12,13 +13,11 @@ class _SourcecodeCompiler(object):
self._parser = None self._parser = None
def compile(self, path, filename, system_class, universe): def compile(self, path, filename, system_class, universe):
result = system_class fname = path + os.sep + filename + ".som"
fname = path + os.pathsep + filename + ".som" with open(fname, "r") as input_file:
self._parser = Parser(input_file, universe)
self._parser = Parser(FileReader(fname), universe) result = self._compile(system_class, universe)
result = self._compile(system_class, universe)
cname = result.get_name() cname = result.get_name()
cnameC = cname.get_string() cnameC = cname.get_string()
...@@ -29,7 +28,7 @@ class _SourcecodeCompiler(object): ...@@ -29,7 +28,7 @@ class _SourcecodeCompiler(object):
return result return result
def compile_class_string(self, stream, system_class, universe): def compile_class_string(self, stream, system_class, universe):
self._parser = Parser(StringReader(stream), universe) self._parser = Parser(StringIO(stream), universe)
result = self._compile(system_class, universe) result = self._compile(system_class, universe)
return result return result
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment