#!/usr/bin/env python
# coding: utf-8

# In[1]:


import os
import sys
import shutil

def usage():
    sys.exit('Usage:\nInput:<base_directory>\nOutput:\nchecks if the aasana is matching the list in the "checklist"\nasks you to rename in case it dosent match\nenter the correct aasana name to RENAME it\nor else enter "0"')
# In[ ]:
if(len(sys.argv)!=2):
    usage()

checklist = [
    'Ardhachakrasana', # oneside
    'Garudasana', 
    'Gorakshasana', # oneside           
    'Katichakrasana',
    'Natarajasana',
    'Natavarasana',
    'Naukasana',
    'Padahastasana', # oneside
    'ParivrttaTrikonasana',
    'Pranamasana',
    'Santolanasana', # oneside
    'Still',
    'Tadasana', # oneside
    'TriyakTadasana',
    'Trikonasana',
    'Tuladandasana',
    # 'Tuladandsana':[20,15,50,15],
    'Utkatasana',
    'Virabhadrasana',
    'Vrikshasana',    
    ]
base_directory = sys.argv[1]
os.chdir(base_directory)
list_of_subjects = next(os.walk(os.getcwd()))[1]
for subjID in list_of_subjects:
    os.chdir(subjID)
    id_aasana_list = next(os.walk(os.getcwd()))[1]
    for id_aasana in id_aasana_list:
        print(id_aasana)
        aasana = id_aasana.split('_')[1]
        if(aasana not in checklist):
            corrected = raw_input('replace '+aasana+' with: ')
            if(corrected == '0'):
                continue
            newIDaasana = id_aasana.split('_')[0]+'_'+str(corrected)
            shutil.move(id_aasana,newIDaasana)
    os.chdir(base_directory)

