refactor: use pathlib for the paths pymake builds - #336
Merged
Conversation
os.path is replaced by pathlib where a path is built or a file is removed in pymake.py, which is 15 of the 28 calls. The rest are left because os.path does something pathlib does not. os.path.normpath takes the parent directories out of a path and pathlib does not, and it is what tidies the extrafiles paths that are written to a build file. os.path.splitext keeps the directory in the name it returns where Path.stem does not. os.path.dirname returns an empty string for the directory of a bare file name where Path.parent returns a dot, which is compared with appdir to decide where a target is written. os.path.abspath does not resolve a symbolic link where Path.resolve does, and it decides whether a target has been built already.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #336 +/- ##
=============================================
- Coverage 80.231% 80.170% -0.061%
=============================================
Files 20 20
Lines 3283 3283
=============================================
- Hits 2634 2632 -2
- Misses 649 651 +2
🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
os.pathis replaced bypathlibwhere a path is built or a file is removed inpymake.py, which is 15 of the 28 calls.The rest are left because
os.pathdoes something pathlib does not, and each was checked rather than assumed:os.pathpathlibnormpath('a/../b')ba/../b, the parent directories are keptsplitext('bin/mf6.exe')[0]bin/mf6.stemismf6, the directory is droppeddirname('mf6').abspath.resolve()follows itnormpathtidies the extrafiles paths that are written to a build file,dirnameis compared withappdirto decide where a target is written, andabspathdecides whether a target has been built already, so converting any of them changes what pymake does.Checked with the 67 base tests, by writing the mfusg makefile and comparing it, and by building triangle into an appdir, which is what the
dirnamecomparison decides.