Skip to content

Commit

Permalink
Merge pull request OmegaK2#17 from Turmfalke2/fix_relative_paths
Browse files Browse the repository at this point in the history
turn relative paths for out_dir and tmp_dir into absolute paths
  • Loading branch information
pm5k authored Oct 28, 2021
2 parents 18759cc + 60fc012 commit 1819dd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions PyPoE/cli/exporter/wiki/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
class WikiHandler(BaseHandler):
def __init__(self, sub_parser):
# Config Options
config.add_option('temp_dir', 'is_directory(exists=True)')
config.add_option('out_dir', 'is_directory(exists=True)')
config.add_option('temp_dir', 'is_directory(exists=True, make_absolute=True)')
config.add_option('out_dir', 'is_directory(exists=True, make_absolute=True)')
config.register_setup('temp_dir', self._setup)
config.add_setup_variable('temp_dir', 'hash', 'string(default="")')
config.add_setup_listener('version', self._ver_dist_changed)
Expand Down
6 changes: 5 additions & 1 deletion PyPoE/shared/config/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def is_file(value, *args, exists=True, allow_empty=False, **kwargs):
return value


def is_directory(value, *args, exists=True, allow_empty=False, **kwargs):
def is_directory(value, *args, exists=True, allow_empty=False, make_absolute=False, **kwargs):
"""
Checks whether the value is a valid directory path (and optionally whether
it exists).
Expand All @@ -227,6 +227,8 @@ def is_directory(value, *args, exists=True, allow_empty=False, **kwargs):
whether the directory is required to exist to pass the validation check
allow_empty : bool
whether empty strings are allowed
make_absolute : bool
whether to turn a potentional relative path into an absolute one
Returns
-------
Expand All @@ -244,6 +246,8 @@ def is_directory(value, *args, exists=True, allow_empty=False, **kwargs):
_exists(value, exists)
if not os.path.isdir(value):
raise ValidateError('"%s" is not a directory.' % value)
if make_absolute:
value = os.path.abspath(value)
return value

# =============================================================================
Expand Down

0 comments on commit 1819dd5

Please sign in to comment.