@@ -746,11 +746,9 @@ def copy_or_shift_logic(
746746 )
747747
748748 # Modify `sep` of from_paths and to_paths
749- transfer_indicator = False
750- tree_sep = tree .sep
751- if to_tree :
752- transfer_indicator = True
753- tree_sep = to_tree .sep
749+ if not to_tree :
750+ to_tree = tree
751+ tree_sep = to_tree .sep
754752 from_paths = [path .rstrip (sep ).replace (sep , tree .sep ) for path in from_paths ]
755753 to_paths = [
756754 path .rstrip (sep ).replace (sep , tree_sep ) if path else None for path in to_paths
@@ -777,28 +775,16 @@ def copy_or_shift_logic(
777775 "Check your `from_paths` parameter, alternatively set `with_full_path=False` to shift "
778776 "partial path instead of full path."
779777 )
780- if transfer_indicator :
781- if not all (
782- [
783- path .lstrip (tree_sep ).split (tree_sep )[0 ] == to_tree .root .node_name
784- for path in to_paths
785- if path
786- ]
787- ):
788- raise ValueError (
789- "Invalid path in `to_paths` not starting with the root node. Check your `to_paths` parameter."
790- )
791- else :
792- if not all (
793- [
794- path .lstrip (tree_sep ).split (tree_sep )[0 ] == tree .root .node_name
795- for path in to_paths
796- if path
797- ]
798- ):
799- raise ValueError (
800- "Invalid path in `to_paths` not starting with the root node. Check your `to_paths` parameter."
801- )
778+ if not all (
779+ [
780+ path .lstrip (tree_sep ).split (tree_sep )[0 ] == to_tree .root .node_name
781+ for path in to_paths
782+ if path
783+ ]
784+ ):
785+ raise ValueError (
786+ "Invalid path in `to_paths` not starting with the root node. Check your `to_paths` parameter."
787+ )
802788
803789 # Perform shifting
804790 for from_path , to_path in zip (from_paths , to_paths ):
@@ -824,10 +810,7 @@ def copy_or_shift_logic(
824810 to_node = None
825811 # Node to be copied/shifted
826812 else :
827- if transfer_indicator :
828- to_node = find_full_path (to_tree , to_path )
829- else :
830- to_node = find_full_path (tree , to_path )
813+ to_node = find_full_path (to_tree , to_path )
831814
832815 # To node found
833816 if to_node :
@@ -887,12 +870,7 @@ def copy_or_shift_logic(
887870 else :
888871 # Find parent node, create intermediate parent node if applicable
889872 to_path_parent = tree_sep .join (to_path .split (tree_sep )[:- 1 ])
890- if transfer_indicator :
891- to_node = add_path_to_tree (
892- to_tree , to_path_parent , sep = tree_sep
893- )
894- else :
895- to_node = add_path_to_tree (tree , to_path_parent , sep = tree_sep )
873+ to_node = add_path_to_tree (to_tree , to_path_parent , sep = tree_sep )
896874
897875 # Reassign from_node to new parent
898876 if copy :
0 commit comments