Add incremental import/export, library support, UTF-8 encoding, and per-file logging#3
Open
Roden69 wants to merge 4 commits into
Open
Add incremental import/export, library support, UTF-8 encoding, and per-file logging#3Roden69 wants to merge 4 commits into
Roden69 wants to merge 4 commits into
Conversation
- Replace open() with io.open(encoding="utf-8") to support Unicode characters (e.g. ≠, °, µ) in import_export.py and import_from_files.py - Remove str(f.read()) in import_st and import_st_decl_only to avoid Unicode data loss on Python 2.7 - Add library project fallback in script_export_to_files.py, import_from_files.py and script_save_as_template.py for projects without a Device/Application node - Fix PROJECT_EXT in project_template.py to support .library extension - Add safety check in script_update_from_template.py when no template file is found - Remove unused get_library_entrypoint() from entrypoint.py Signed-off-by: dmatthes <daniel.matthes@megmeet.com>
Signed-off-by: dmatthes <daniel.matthes@megmeet.com>
- export: sync_folder now returns lists of changed/new/removed relative paths and prints each file under the summary line - import: incremental_import splits new vs. changed files and logs each one (new/changed/deleted) Signed-off-by: dmatthes <daniel.matthes@megmeet.com>
Signed-off-by: dmatthes <daniel.matthes@megmeet.com>
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.
Changes
Incremental Export
Instead of wiping and rewriting the entire source folder on every export,
the export now uses a file-hash manifest to only write files that actually
changed, add new files, and remove deleted ones. This results in much
cleaner git diffs — unchanged files no longer show up as modified.
Incremental Import
Import now uses the same manifest to only re-import files that changed
since the last export/import. New files are created, deleted files are
removed, unchanged files are skipped. Falls back to a full import when
no manifest exists yet.
Subfolder Import/Export
For library projects, import and export can be scoped to a single
subfolder (e.g.
POUs/Math) instead of the whole project. Useful forlarge libraries where only one area was touched.
Full Library Project Support
Projects with a
.libraryextension (or projects containing no devices)are now correctly treated as library projects and imported/exported from
the project root.
UTF-8 Encoding
All file reads and writes now use
encoding="utf-8"to correctly handlespecial characters (e.g. German umlauts) in variable names and comments.
Per-file Logging
Import and export now log each individual file as
+ new,~ changed,or
- deleted/removedin the CODESYS output window, not just the totalcounts.
Testing
Tested on CODESYS V3.5 SP21 Patch 2 with IFM CR711s project structure.
Reviewed and developed with the assistance of Claude Code (Anthropic).