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

Different Path objects may point to the same file #419

Open
airallergy opened this issue Apr 22, 2023 · 0 comments
Open

Different Path objects may point to the same file #419

airallergy opened this issue Apr 22, 2023 · 0 comments

Comments

@airallergy
Copy link
Contributor

@santoshphilip, it is great that eppy starts to support Path objects at some point! One issue I found is that the comparison (==) of two Path objects does not link to the actual files. For instance, Path("/Applications/EnergyPlus-23-1-0/Energy+.idd") == Path("ep23.1/Energy+.idd") will give False, though ep23.1 is a symbolic link to /Applications/EnergyPlus-23-1-0. I am not sure if many would come across this issue (having to deal with different Path objects that point to the same file), but the fix should be fairly simple, just resolving the path at the beginning of the setiddname function.

if isinstance(iddname, Path):
    iddname = iddname.resolve(strict=True)

For reference, the resolve() method of Path objects will 1. make paths absolute and 2. resolve any symlinks.

If this looks good to you, I can send in a quick PR. One thing to consider is whether to set strict=True. This might not be desired if you think it is better to handle file non-existence later on, together with paths that are passed in as str (I did not check where that is, but I assume there is one, or maybe you just give it to open() to throw exceptions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant