On Thu, Aug 20, 2020 at 1:20 PM k-hen <[email protected]> wrote:
The file sync is making me very nervous because (and I'm sure I did
> something wrong) the file didn't import correctly and blew away my changes.
> Fortunately I had a backup but this just isn't acceptable for me :-/
>
There are many ways around this kind of problem. For initial imports, I
recommend using a recursive import script. The c.recursiveImport method
provides the support for the following script:
'''Recursively import all python files in a directory and clean the
result.'''
@tabwidth -4 # For a better match.
dir_ = r'<<path to the root directory>>' <----- change as needed
g.cls()
c.recursiveImport(
add_context=True, # Override setting only if True/False
add_file_context=False, # Override setting only if True/False
dir_=dir_,
kind = '@clean', # '@auto', '@clean', '@nosent','@file',
add_path = True,
recursive = True,
safe_at_file = True, # Creates @@clean instead of @clean
theTypes = ['.py', ] # ['.py', '.rs', '.ts', '.js','.vue',], #etc.
)
This script only *adds* to your .leo file. It never changes existing nodes.
If you import to @clean nodes, you should definitely use something like git
to control the original files. After writing the new @clean nodes, you can
use git to revert any unwanted changes. Then you reload Leo, and manually
tweak the @clean nodes. Repeat until writing the files does not change
anything.
Important: Both @clean and @auto perform strong "perfect import" checks. If
for any reason these checks fail, Leo will insert @ignore nodes, to prevent
unwanted changes when you change the .leo file.
In short, Leo provides significant protection for your files. However, I
recommend using git to provide an additional level of safety.
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/CAMF8tS3XDg0HgbNwsa2Tsc9HzXc-z%3DenP-tBiPi2vs6R-CbYmg%40mail.gmail.com.