mirror of
https://codeberg.org/kazephil/Little_CAT_Helpers.git
synced 2023-08-25 14:05:45 +02:00
Move more shared code to this module.
This commit is contained in:
parent
5c3a316311
commit
e9a91e51b4
@ -21,15 +21,22 @@ def read_config(configfile):
|
|||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def set_basepath(candidates):
|
def set_basepath(configpath):
|
||||||
'''Define the default starting path for documents.'''
|
'''Define the default starting path for documents.
|
||||||
|
|
||||||
|
Each tool reads the applicable configuration path from the
|
||||||
|
configuration file and passes it to this function.
|
||||||
|
'''
|
||||||
|
|
||||||
# Give priority to path set in config file, if valid.
|
# Give priority to path set in config file, if valid.
|
||||||
# If not, use the user's 'Documents' folder if it exists,
|
# If not, use the user's 'Documents' folder if it exists,
|
||||||
# and the user folder if not, as a default.
|
# and the user folder if not, as a default.
|
||||||
|
|
||||||
|
candidates = [configpath, DEFAULT_DOCHOME, USER_HOME]
|
||||||
basepath = None
|
basepath = None
|
||||||
|
|
||||||
|
# Read each candidate path in term, and set the first valid path
|
||||||
|
# as the basepath
|
||||||
while basepath is None:
|
while basepath is None:
|
||||||
if candidates[0].exists():
|
if candidates[0].exists():
|
||||||
basepath = candidates[0]
|
basepath = candidates[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user