Stop auto-correcting incorrect slashes. Instead error, and point to our docs.
Also, improve docs slightly to say to *always* use forward slashes See #906
This commit is contained in:
@@ -10,10 +10,15 @@ like this::
|
|||||||
|
|
||||||
overviewer.py --config=path/to/my_configfile
|
overviewer.py --config=path/to/my_configfile
|
||||||
|
|
||||||
|
|
||||||
The config file is formatted in Python syntax. If you aren't familiar with
|
The config file is formatted in Python syntax. If you aren't familiar with
|
||||||
Python, don't worry, it's pretty simple. Just follow the examples.
|
Python, don't worry, it's pretty simple. Just follow the examples.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
You should *always* use forward slashes ("/"), even on
|
||||||
|
Windows. This is required because the backslash ("\\") has special meaning
|
||||||
|
in Python.
|
||||||
|
|
||||||
A Simple Example
|
A Simple Example
|
||||||
================
|
================
|
||||||
|
|
||||||
@@ -193,6 +198,8 @@ the form ``key = value``. Two items take a different form:, ``worlds`` and
|
|||||||
|
|
||||||
**You must specify at least one world**
|
**You must specify at least one world**
|
||||||
|
|
||||||
|
*Reminder*: Always use forward slashes ("/"), even on Windows.
|
||||||
|
|
||||||
``renders``
|
``renders``
|
||||||
This is also pre-defined as an empty dictionary. The config file is expected
|
This is also pre-defined as an empty dictionary. The config file is expected
|
||||||
to add at least one item to it.
|
to add at least one item to it.
|
||||||
@@ -226,6 +233,8 @@ the form ``key = value``. Two items take a different form:, ``worlds`` and
|
|||||||
|
|
||||||
outputdir = "/path/to/output"
|
outputdir = "/path/to/output"
|
||||||
|
|
||||||
|
*Reminder*: Always use forward slashes ("/"), even on Windows.
|
||||||
|
|
||||||
**Required**
|
**Required**
|
||||||
|
|
||||||
.. _processes:
|
.. _processes:
|
||||||
|
|||||||
@@ -24,30 +24,26 @@ def expand_path(p):
|
|||||||
return p
|
return p
|
||||||
|
|
||||||
def checkBadEscape(s):
|
def checkBadEscape(s):
|
||||||
fixed = False
|
#If any of these weird characters are in the path, raise an exception instead of fixing
|
||||||
fixed_string = s
|
#this should help us educate our users about pathslashes
|
||||||
if "\a" in fixed_string:
|
if "\a" in s:
|
||||||
fixed_string = s.replace("\a", r"\a")
|
raise ValueError("Invalid character '\\a' in path. Please use forward slashes ('/'). Please see our docs for more info.")
|
||||||
fixed = True
|
if "\b" in s:
|
||||||
if "\b" in fixed_string:
|
raise ValueError("Invalid character '\\b' in path. Please use forward slashes ('/'). Please see our docs for more info.")
|
||||||
fixed_string = s.replace("\b", r"\b")
|
if "\t" in s:
|
||||||
fixed = True
|
raise ValueError("Invalid character '\\t' in path. Please use forward slashes ('/'). Please see our docs for more info.")
|
||||||
if "\t" in fixed_string:
|
if "\n" in s:
|
||||||
fixed_string = s.replace("\t", r"\t")
|
raise ValueError("Invalid character '\\n' in path. Please use forward slashes ('/'). Please see our docs for more info.")
|
||||||
fixed = True
|
if "\v" in s:
|
||||||
if "\n" in fixed_string:
|
raise ValueError("Invalid character '\\v' in path. Please use forward slashes ('/'). Please see our docs for more info.")
|
||||||
fixed_string = s.replace("\n", r"\n")
|
if "\f" in s:
|
||||||
fixed = True
|
raise ValueError("Invalid character '\\f' in path. Please use forward slashes ('/'). Please see our docs for more info.")
|
||||||
if "\v" in fixed_string:
|
if "\r" in s:
|
||||||
fixed_string = s.replace("\v", r"\v")
|
raise ValueError("Invalid character '\\r' in path. Please use forward slashes ('/'). Please see our docs for more info.")
|
||||||
fixed = True
|
for c in range(10):
|
||||||
if "\f" in fixed_string:
|
if chr(c) in s:
|
||||||
fixed_string = s.replace("\f", r"\f")
|
raise ValueError("Invalid character '\\%s' in path. Please use forward slashes ('/'). Please see our docs for more info." % c)
|
||||||
fixed = True
|
return s
|
||||||
if "\r" in fixed_string:
|
|
||||||
fixed_string = s.replace("\r", r"\r")
|
|
||||||
fixed = True
|
|
||||||
return (fixed, fixed_string)
|
|
||||||
|
|
||||||
def validateMarkers(filterlist):
|
def validateMarkers(filterlist):
|
||||||
if type(filterlist) != list:
|
if type(filterlist) != list:
|
||||||
@@ -72,7 +68,7 @@ def validateOverlays(renderlist):
|
|||||||
return renderlist
|
return renderlist
|
||||||
|
|
||||||
def validateWorldPath(worldpath):
|
def validateWorldPath(worldpath):
|
||||||
_, worldpath = checkBadEscape(worldpath)
|
checkBadEscape(worldpath)
|
||||||
abs_path = expand_path(worldpath)
|
abs_path = expand_path(worldpath)
|
||||||
if not os.path.exists(os.path.join(abs_path, "level.dat")):
|
if not os.path.exists(os.path.join(abs_path, "level.dat")):
|
||||||
raise ValidationException("No level.dat file in '%s'. Are you sure you have the right path?" % (abs_path,))
|
raise ValidationException("No level.dat file in '%s'. Are you sure you have the right path?" % (abs_path,))
|
||||||
@@ -199,7 +195,7 @@ def validateDimension(d):
|
|||||||
return (d, d)
|
return (d, d)
|
||||||
|
|
||||||
def validateOutputDir(d):
|
def validateOutputDir(d):
|
||||||
_, d = checkBadEscape(d)
|
checkBadEscape(d)
|
||||||
if not d.strip():
|
if not d.strip():
|
||||||
raise ValidationException("You must specify a valid output directory")
|
raise ValidationException("You must specify a valid output directory")
|
||||||
return expand_path(d)
|
return expand_path(d)
|
||||||
@@ -234,8 +230,8 @@ def validateWebAssetsPath(p):
|
|||||||
raise ValidationException("Bad custom web assets path: %s" % e.message)
|
raise ValidationException("Bad custom web assets path: %s" % e.message)
|
||||||
|
|
||||||
def validatePath(p):
|
def validatePath(p):
|
||||||
_, path = checkBadEscape(p)
|
checkBadEscape(p)
|
||||||
abs_path = expand_path(path)
|
abs_path = expand_path(p)
|
||||||
if not os.path.exists(abs_path):
|
if not os.path.exists(abs_path):
|
||||||
raise ValidationException("'%s' does not exist. Path initially given as '%s'" % (abs_path,p))
|
raise ValidationException("'%s' does not exist. Path initially given as '%s'" % (abs_path,p))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user