Skip to content

Automatic expanduser for path #915

@BoPeng

Description

@BoPeng

Our path type is derived from pathlib.Path with additional format operators, and like Path, we will have to use expanduser() to expand ~:

>>> path(os.path.expanduser('~/.bashrc')).exists()
True
>>> path('~/.bashrc').exists()
False
>>> path('~/.bashrc').expanduser().exists()
True

Since path is a SoS type and SoS automatically expand ~, I believe we should treat

path('~/.bashrc').exists()

as

path('~/.bashrc').expanduser().exists()

The problem is that we will have to redefine many functions such as exists, is_dir, is_file, ..., and it does not look right if we automatically change the string representation of input path

>>> str(path('~/.bashrc').expanduser())
'/Users/bpeng1/.bashrc'
>>> str(path('~/.bashrc'))
'~/.bashrc'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions