This Engineering Notebook post reviews the present state of Leo's g.os_path functions and discusses various ideas for improving them.
tl;dr: Leo's g.os_path wrappers should be deprecated, but they will remain in Leo's core.
Background
Leo's g.os_path wrappers contain redundant and confusing code, but cleaning up this mess will be dangerous. PR
#3264 broke @path expressions because of an invalid rewrite of expand_path_expression. This method must
not finalize the path by calling (directly or indirectly) os.path.abspath
or os.path.normpath.
PR
#3275
makes the minimum changes necessary to make @path work again. This PR
retains all other calls to the os.path wrappers, even when redundancies
are apparent.
Removing redundancy
The challenge: remove the redundancies while ensuring that Leo:
- calls os.path.expanduser and os.path wherever needed.
- never calls os.path.normpath inappropriately.
Finalizing a path too soon can cause bugs.
Deprecating the wrappers
These wrappers are faux helpers. Leo's core can tolerate the g.os_path wrappers because they enforce standards. Plugins and scripts will likely be easier to understand if they call os.path functions directly.
Summary
Leo's core can tolerate the g.os_path wrappers because they enforce standards. I plan to deprecate these wrappers for general use.
Revising these wrappers is dangerous. The work might not become part of Leo 6.7.3.
Your comments, please.
Edward