Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making path more compatible with pathlib #223

Merged
merged 9 commits into from
Oct 7, 2015
Merged

Making path more compatible with pathlib #223

merged 9 commits into from
Oct 7, 2015

Conversation

henryiii
Copy link
Collaborator

The stdlib (in newer Python 3's) has a pathlib module, with object oriented paths. I've been working at making Plumbum's Path more like pathlib.Path.

Added:

    .stem           # The last component of a path, without extension
    .root           # The root of the path ('/' or '\\')
    .drive          # The drive letter ('' on unix)
    .parts          # The split path, including the root
    .iterdir()      # Directory iterator, slightly faster than list on Python 3.5
    .as_uri()       # The URI of a path

Renamed:

    .isdir()  -> .is_dir()
    .islink() -> .is_symlink()
    .isfile() -> .is_file()
    .basename -> .name

For the renames, old names still work, but emit a DepreciationWarning. Also, I just assumed a remote path should have a ftp URI, but am open to suggestions there. Drive and root are always '' and '/' for remote paths. If pathlib exists, several features, including the ones above, are tested against it.

I also rooted out and killed a bug for skipIf that was incorrectly masking tests on Python 2.6.

… match

Added:
```
    .stem
    .root
    .drive
    .parts
    .iterdir()
```

Renamed:
```
    .isdir() -> .is_dir()
    .islink() -> is_symlink()
    .isfile() -> is_file()
    .basename -> .name
```

The old methods still work.
@tomerfiliba
Copy link
Owner

interesting. but why do you think the URI should be ftp and not ssh? or sftp?

@henryiii
Copy link
Collaborator Author

I'm open to that, I wasn't sure what would be most useful. I chose ftp because it is easier to add an s than remove one. Maybe ssh would be better for a default? I can add a parameter to set that, something like as_uri(scheme='ssh').

@henryiii henryiii mentioned this pull request Sep 21, 2015
5 tasks
@henryiii henryiii added this to the v1.6.0 milestone Sep 21, 2015
@henryiii henryiii assigned henryiii and tomerfiliba and unassigned henryiii Sep 30, 2015
tomerfiliba added a commit that referenced this pull request Oct 7, 2015
Making path more compatible with pathlib
@tomerfiliba tomerfiliba merged commit dbab16f into master Oct 7, 2015
@henryiii henryiii deleted the dev branch October 13, 2015 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants