Some more cleanup of paths for batchprocessors
This commit is contained in:
parent
3848a789a7
commit
e399c418e5
2 changed files with 15 additions and 7 deletions
|
|
@ -186,11 +186,12 @@ CODE_INFO_HEADER = re.compile(r"\(.*?\)")
|
||||||
def read_batchfile(pythonpath, file_ending='.py'):
|
def read_batchfile(pythonpath, file_ending='.py'):
|
||||||
"""
|
"""
|
||||||
This reads the contents of a batch-file.
|
This reads the contents of a batch-file.
|
||||||
Filename is considered to be the name of the batch file
|
Filename is considered to be a python path to a batch file
|
||||||
relative the directory specified in settings.py.
|
relative the directory specified in settings.py.
|
||||||
|
|
||||||
file_ending specify which batchfile ending should be
|
file_ending specify which batchfile ending should be
|
||||||
assumed (.ev or .py).
|
assumed (.ev or .py). The ending should not be included
|
||||||
|
in the python path.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# open the file
|
# open the file
|
||||||
|
|
|
||||||
|
|
@ -289,10 +289,17 @@ def get_evennia_version():
|
||||||
def pypath_to_realpath(python_path, file_ending='.py'):
|
def pypath_to_realpath(python_path, file_ending='.py'):
|
||||||
"""
|
"""
|
||||||
Converts a path on dot python form (e.g. 'src.objects.models') to
|
Converts a path on dot python form (e.g. 'src.objects.models') to
|
||||||
a system path ($BASE_PATH/src/objects/models.py). Calculates all paths as
|
a system path ($BASE_PATH/src/objects/models.py). Calculates all
|
||||||
absoulte paths starting from the evennia main directory.
|
paths as absoulte paths starting from the evennia main directory.
|
||||||
|
|
||||||
|
Since it seems to be a common mistake to include the file ending
|
||||||
|
when entering filename for things like batchprocess, we handle the
|
||||||
|
case of erroneously adding the file ending too.
|
||||||
"""
|
"""
|
||||||
pathsplit = python_path.strip().split('.')
|
pathsplit = python_path.strip().split('.')
|
||||||
|
if python_path.endswith(file_ending):
|
||||||
|
# this is actually a malformed path ...
|
||||||
|
pathsplit = pathsplit[:-1]
|
||||||
if not pathsplit:
|
if not pathsplit:
|
||||||
return python_path
|
return python_path
|
||||||
path = settings.BASE_PATH
|
path = settings.BASE_PATH
|
||||||
|
|
@ -305,9 +312,9 @@ def pypath_to_realpath(python_path, file_ending='.py'):
|
||||||
|
|
||||||
def dbref(dbref, reqhash=True):
|
def dbref(dbref, reqhash=True):
|
||||||
"""
|
"""
|
||||||
Converts/checks if input is a valid dbref.
|
Converts/checks if input is a valid dbref. If reqhash is set,
|
||||||
If reqhash is set, only input strings on the form '#N', where N is an
|
only input strings on the form '#N', where N is an integer is
|
||||||
integer is accepted. Otherwise strings '#N', 'N' and integers N are all
|
accepted. Otherwise strings '#N', 'N' and integers N are all
|
||||||
accepted.
|
accepted.
|
||||||
Output is the integer part.
|
Output is the integer part.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue