PR #3277 <https://github.com/leo-editor/leo-editor/pull/3277> proposes 
changes to various path-related functions in leoGlobals.py.

These changes will affect leoJS. I don't expect them to expect Leo's users!

Thomas quite rightly raised some concerns. This Engineering Notebook post 
gives my response. Thomas's gadfly questions caused me to think more 
deeply, create better unit tests, and improve the related code.

*Overview of the PR*

The PR changes many files. Here are the highlights:

- Rename *g.of_path_finalize* to *g.finalize*, retaining the old name for 
compatibility. 
- Rename *g.os_path_finalize_join* to *g.finalize_join*, retaining the old 
name for compatibility.
- Make *g.os_path_expand_user* a synonym for g.finalize.
- *Slightly* generalize g.finalize and g.finalize_join compared with legacy 
code.


*Testing*


*test_g_finalize* and *test_g_finalize_join* were responses to Thomas's 
compatibility concerns. I worked on these two tests for several days before 
realizing that these tests weren't the whole story!


The very first test case in test_g_finalize_join shows the problem. 
g.finalize('a.py') must return an absolute path relative to os.getcwd(), 
*not* the directory containing the outline! In other words, the *callers *of 
g.finalize_join are responsible for specifying the absolute path.


The PR lists all the places where arguments to these functions have 
changed. The PR's correctness depends on just those places.


*Compatibility*


Thomas suggested that better docstrings would help. I have just added 
improved docstrings for the two new functions. However, the code itself is 
likely easier to understand than the words.


I have given careful thought to the question of retaining the legacy code. 
I have chosen not to do so. There is no plausible scenario in which the 
legacy code could be superior to the new code. 


*Summary*


Imo, Leo would be better off with the new code. This PR *might* cause 
compatibility problems, but the likelihood is small. 


I plan to merge the new code in a few days, but I'll wait for Thomas and 
Félix to comment first. There is no rush. All comments are welcome.


Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/8faaf86d-41d3-4a29-b386-6935298f0089n%40googlegroups.com.

Reply via email to