Skip to content

Commit

Permalink
Asdftool edit (#873)
Browse files Browse the repository at this point in the history
* Adding basic edit command to asdftool.

* Updating the edit.py file.

* Pushing an error trying to expose a function in asdf.py to be used in edit.py

* Corrected importation of internal function error in edit.py.

* Correcting name formatting of internal use only functions.

* Adding utility functions by refactoring class methods.

* Part of the way through asdf.py refactor for code reuse in edit.py.

* Completed '-e' option for the asdftool 'edit' subcommand.

* The edit command is almost finished.  For a rewritten ASDF file, due to larger edited text, the block index at the end will need to be re-computed.  Currently, if one exists, it is simply written out, but it is wrong.

* Finished the asdftool edit subcommand for edited YAML text with the same or fewer YAML characters as in the original ASDF file.

* Completed the 'save' portion of the 'edit' subcommand for asdftool.  It now rewrites small files, with a buffer for future editing, as well as a newly computed block index.

* Adding a check to make sure the block checks don't go out of bounds.

* Making formatting and usage changes based on feedback on pull request.

* Removing debug tracing.

* Removing comment.

* Integrating feedback from the pull request.

* Changing edit subcommand based on pull request feedback.

* Correcting python formatting based on flake8 report.

* Changing formatting of files and removing unnecessary comments.

* Adding function comments.

* Reverting to original asdf.py file.

* Reverting commands/__init__.py to original style.

* Adding basic edit command to asdftool.

* Adding pytest for the edit subcommand for asdftool.

* Adding coverage for a smaller YAML edited file.

* Adding parametrization the edit test to test all supported versions.

* Removing hardcoded path used for local testing.

* Refactored the automated tester for the edit subcommand of asdftool.

* Reformatting the tests and changing some values in the tree.

* Adding formatting changes and checks using feed back from code review.

* Formatting changes based on black and tox.

* Adding changes based on pull request feedback.

* Adding file closures that may have been causing problems during testing, as well as modified file name usage, so each test had its own set of unique file names that may have been causing problems during testings.

* Updating user messages to properly reflect changes to how edit works.

* The Windows tests are still failing, so I added the 'with' idiom when creating the base ASDF file.

* The method 'os.rename' always raises an error on Windows.  Switching to using 'os.replace'.

* There are still Travis-CI failures on Windows.  Changing the way to create the ASDF file to be edited by using asdf.write_to instead of simply copying the base ASDF using shutil.

* Adding binary read and writes to the test to hopefully fix the test on Windows.

* Adding formatting change to conform with style standards.

* Incorporating PR feedback and correctly implementing padding.  The cases for edited YAML portions smaller or equal to the existing YAML in an ASDF file are complete.

* Added changes to the edit subcommand based on PR feedback.

* Adding rewrite functionality to the 'save' option, including for the streaming case.  Added a test for pytesting.

* Changed docstrings to conform with standard formatting.  Removed extraneous comments.

* Format changes based on 'black' tool.

* Correcting style for formatted strings and removed extraneous comments.

* Removed the use of a global variable and changed the way the search for the first binary block occurs.

* Updating the edit subcommand to handle trying to edit ASDF file containing no binary blocks.  Added tests for these conditions.

Co-authored-by: Kenneth Macdonald <[email protected]>
  • Loading branch information
kmacdonald-stsci and Kenneth Macdonald authored Oct 9, 2020
1 parent c446d90 commit f329d1e
Show file tree
Hide file tree
Showing 3 changed files with 919 additions and 1 deletion.
3 changes: 2 additions & 1 deletion asdf/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from .tags import list_tags
from .extension import find_extensions
from .info import info
from .edit import edit


__all__ = ['implode', 'explode', 'to_yaml', 'defragment', 'diff', 'list_tags',
'find_extensions', 'info']
'find_extensions', 'info', 'edit']


# Extracting ASDF-in-FITS files requires Astropy
Expand Down
Loading

0 comments on commit f329d1e

Please sign in to comment.