From e9a91e51b4215ce57d7986f6b13fe5cbc7608cce Mon Sep 17 00:00:00 2001 From: Kazephil Date: Sat, 16 Jul 2022 13:51:06 +0900 Subject: [PATCH] Move more shared code to this module. --- omegat_tools/common.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/omegat_tools/common.py b/omegat_tools/common.py index 64075f7..b8bf7c3 100644 --- a/omegat_tools/common.py +++ b/omegat_tools/common.py @@ -21,15 +21,22 @@ def read_config(configfile): return parser -def set_basepath(candidates): - '''Define the default starting path for documents.''' +def set_basepath(configpath): + '''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. # If not, use the user's 'Documents' folder if it exists, # and the user folder if not, as a default. + candidates = [configpath, DEFAULT_DOCHOME, USER_HOME] basepath = None + # Read each candidate path in term, and set the first valid path + # as the basepath while basepath is None: if candidates[0].exists(): basepath = candidates[0]