-
Notifications
You must be signed in to change notification settings - Fork 58
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
support- new path type in-plugin-registration by converting to string… #377
Merged
mottosso
merged 16 commits into
pyblish:master
from
hannesdelbeke:feature/support-path-in-plugin-registration
Oct 27, 2021
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0baed4f
support- new path type in-plugin-registration by converting to string…
hannesdelbeke d5fecd3
pathlib test
hannesdelbeke 3772887
add missing unittest import
hannesdelbeke 3127cc2
skip update
hannesdelbeke 286506c
update the tester, helper func was picked up by the test framework
hannesdelbeke ca53e03
add encoding
hannesdelbeke b43e0f7
add to assert message
hannesdelbeke 94a7cf0
add unicode encoding
hannesdelbeke 27116a1
add pathlib support for python 3.4+
hannesdelbeke 09afb18
python 2 NotImplementedError to importError
hannesdelbeke 91bbb2e
add normpath
hannesdelbeke 803df44
fix errors in except
hannesdelbeke 5f3f2be
add /t to test more string stuff
hannesdelbeke 23ddb78
remove binary string from test
hannesdelbeke 7e5c2ff
disabling binary string
hannesdelbeke 0dbd091
implement feedback
hannesdelbeke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mess. :S
str()
If we really must special-case pathlib, then maybe we could duck-type it instead?
That way, we don't need any imports and we account for any other library that follows a similar convention to pathlib of having a
as_posix()
call that converts an object into something posix compliant; i.e. a plain well-formatted path as a string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Mottosso, you are right it is a mess.
your if stament looks a lot cleaner
but not sure if the second part will work, since we now always convert to posix. always returning forward slashes (/)
about str(), the docs for pathlib say:
would be more correct I believe since this would choose the correct slashes based on your OS when using Path, and maintain the slashes of your pathtype if passing specific types of path. instead of always returning posixpath style slashes
or we could go with the first suggestion you had and compare with all pathtype names
i went with the try except because it would support any new pathtypes in future pathlib upgrades. and python's idiom "it's easier to ask for forgiveness than permission”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we would not convert to string and use paths directly,
and convert any string to paths.
but then pyblish would rely on pathlib which introducing dependency issues instead for python 2 and <3.4
+the amount of work is a lot more making this not realistic
quick comparison: if we take this part of the discover function
rewritten with pathlib would be something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's focus on what we want to achieve, which to clarify is being able to do this:
Is that right? If so, then..
..will get you there with a minimal amount of code that is neither ambiguous, add additional imports or logic and won't need any additional tests. The following call to
normpath
will translate any slashes to what is appropriate the platform.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if normpath does that then all should be good with that approach