Problem with moving images files - Using the shutil method to copy folders#548
Closed
Problem with moving images files - Using the shutil method to copy folders#548
Conversation
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.
It is possible to change the directory of
DHCfromBuildings.Experimental.DHCtoBuildings.DHCthanks to the functionmove_class. During the process, the images are moved recursively via the function_move_class_directorythat calls for each folder the function_move_images_directory. To move the folders, the command linegit mvis used.For example, the package
Buildings. Experimental .DHC.EnergyTransferStations.Combinedhas 2 images,PartialParallelandChillerBorefield.During the first iteration, for
BaseClasses.PartialParallel,Resources\Images\Experimental\DHC\EnergyTransferStations\Combined\BaseClassesis moved toResources\Images\DHC\EnergyTransferStations\Combined\BaseClasses, which is the expected behavior.BUT during the second iteration for
ChillerBorefield, instead of moving toResources\Images\DHC\EnergyTransferStations\Combined, the image goes toResources\Images\DHC\EnergyTransferStations\Combined\Combinedbecause of the behavior ofgit mv(Resources\Images\DHC\EnergyTransferStations\Combinedalready exists).The proposed alternative is to use
shutilpackage (part of the standard Python distribution, OS agnostic) instead ofgit mv.At the moment the function
_git_moveis only used with the variable_shutil=Truewithin the function_move_images_directory, but it may fully replace thegit mvmethod.The downside is that it is not considered in
gitas a "rename" but as a new file (new folder)/deleted file (old folder).Also, the function used may be refined to adapt to every context.
Finally, for
gituse, the following could be used:Instead of
shutil.rmtree(source)