<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Script to copy files to Anaconda paths so can import and use scripts
Step1:  find main path for install
Step2:  make list of paths need to copy files to & add main path
Step3:  add paths to list for conda environments currently available
MAKE SURE HAS 'module name' AT END OF PATH!!
Step5:  function to  copy files to list of paths
Step6:  Run code for each location
<ASSISTANT_TASK:>
Python Code:
module_name = 'bradlib'
Explanation: Script to copy files to Anaconda paths so can import and use scripts
End of explanation
from distutils.sysconfig import get_python_lib #; print(get_python_lib())
path_main = get_python_lib()
path_main
path_main.split('Anaconda3')
Explanation: find main path for install
End of explanation
dest_paths_list = []
dest_paths_list.append(path_main + '\\' + module_name)
dest_paths_list
Explanation: make list of paths need to copy files to & add main path
End of explanation
x = !conda env list
#x[2:-2]
print('------------------------------------------------')
print('Conda envrionments found which will install to:')
for i in x[2:-2]:
    y = i.split(' ')
    print(y[0])
    new_path = path_main.split('Anaconda3')[0] +'Anaconda3\\envs\\'+y[0]+'\\Lib\\site-packages\\' + module_name
    #print(new_path)
    dest_paths_list.append(new_path)
#dest_paths_list
Explanation: add paths to list for conda environments currently available
MAKE SURE HAS 'module name' AT END OF PATH!!
End of explanation
import os
def copy_to_paths(source,dest):
    
    Function takes source and destination folders and copies files.
    #Source and dest needed in fomrat below: 
    #source = ".\\bradlib"
    #dest = "C:\\Users\\bjk1y13\\dev\\garbage\\bradlib"
    
    #### Remove __pycache__ folder as is not required
    pycache_loc = source + "\\__pycache__"
    if os.path.isdir(pycache_loc) == True:
        print("__pycache__ found in source and being deleted...")
        !rmdir $pycache_loc /S /Q
                
    #### Copy files to new destination
    
    print('------------------------')
    print('Destination: ', dest)
    print('---------')
    folder_exists = os.path.isdir(dest)
    if folder_exists == True:
        print('Folder exists')
        ### delete older version folder
        print('Deleting old folder...')
        !rmdir $dest /S /Q
        print('Copying new folder...')
        !xcopy $source $dest /E /I
        
    elif folder_exists == False:
        print('Folder does not exist')
        print('Copying new folder...')
        !xcopy $source $dest /E /I
    else:
        print('Something has gone wrong!!')
    
    print('COMPLETE')
    print('------------------------')
    return
source = ".\\" + module_name
Explanation: function to  copy files to list of paths
End of explanation
for destination in dest_paths_list:
    print(destination)
    copy_to_paths(source, destination)
print('INSTALL SUCCESSFUL')
Explanation: Run code for each location
End of explanation
<END_TASK>