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.2% of users enabled 2FA.

Commit a3f5a54b authored by Stefan Marr's avatar Stefan Marr
Browse files

Move RPython-specific code into its own library module



Let's try to have all theses things in one place, to reduce the differences between PySOM a RPySOM to a minimum.
Signed-off-by: default avatarStefan Marr <git@stefan-marr.de>
parent 3651c376
"""Compatibility library for RPython
This module contains ad hoc implementations and workarounds for Python
library functions that is not directly supported by RPython.
"""
\ No newline at end of file
class Exit(BaseException):
"""
Use an exit exception to end program execution.
We don't use sys.exit because it is a little problematic with RPython.
"""
def __init__(self, code):
BaseException.__init__(self)
self.code = code
\ No newline at end of file
import os
def path_split(path):
"""This is a replacement for the combined use of os.path.split and
os.path.splitext to decompose a relative path into its components.
"""
path_and_file = path.rsplit(os.sep, 1)
if len(path_and_file) <= 1:
path = ""
else:
path = path_and_file[0]
file_and_ext = path_and_file[-1].rsplit(".", 1)
if len(file_and_ext) <= 1:
ext = ""
else:
ext = file_and_ext[-1]
file_name = file_and_ext[0]
return (path, file_name, ext)
\ No newline at end of file
......@@ -19,13 +19,8 @@ import som.compiler.sourcecode_compiler as sourcecode_compiler
import os
class Exit(BaseException):
"""
Use an exit exception to end program execution.
We don't use sys.exit because it is a little problematic with RPython.
"""
def __init__(self, code):
self.code = code
from rlib.exit import Exit
from rlib.osext import path_split
class Universe(object):
......@@ -178,18 +173,7 @@ class Universe(object):
# take argument of the form "../foo/Test.som" and return
# "../foo", "Test", "som"
def _get_path_class_ext(self, path):
path_and_file = path.rsplit(os.sep, 1)
if len(path_and_file) <= 1:
path = ""
else:
path = path_and_file[0]
file_and_ext = path_and_file[-1].rsplit(".", 1)
if len(file_and_ext) <= 1:
ext = ""
else:
ext = file_and_ext[-1]
file_name = file_and_ext[0]
return (path, file_name, ext)
return path_split(path)
def _print_usage_and_exit(self):
# Print the usage
......
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