#now Chatur can work with files system....
""" This Prg developed By S Hegade,this helps to create html boiler plate and to create Javascript file and it will also include js file into the specified html file automatically"""
import os
import datetime
path="C:\\Users\\s\\documents"

def Auto_generator():
    
    """auto Genarater of html and Java script,css and linker"""
    print(" Chatur is online......")
    while True:
        ti=datetime.datetime.now().strftime("%H-%M-%S")
        path="C:\\Users\\SUBRAHMANYA\\documents"
        o=os.walk(path,followlinks=True)
        dirr=os.listdir(path)
        for i in o:
            for i1 in i[2]:
                i0=os.path.join(i[0], i1)
                ex=i0.split(".")[-1]
                if ex=="html":
                    f=open(i0,"br")
                    a=f.read()
                    f.close()
                    if "html" in str(a):
                        pass
                    else:
                        f=open(i0,"w+")
                        f.write(r'''<!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta http-equiv="X-UA-Compatible" content="ie=edge">
            <title>Document</title>
        </head>
        <body>
        <h1>hi there..</h1>   
        </body>
        </html>''') 
                        f.close()
                        path=i0
                        a1=path.split("\\")
                        a1=path.split("\\")[len(a1)-1]
                        a1=a1.split(".")[-2]
                        new=os.path.join(i[0], a1)
                        ao=path.split("\\")
                        ao=path.split("\\")[len(ao)-2]
                        if ao=="documents":
                            print("true")
                            jj=new+".js"
                            jjo=new+".js"
                        else:
                            print("flase")
                            jj=new+".js"
                            jjo=a1+".js"
                        f=open(jj,"w+")
                        f.write('''alert("hello")''')
                        f.close()
                        a11=path.split("\\")
                        a11=path.split("\\")[len(a11)-1]
                        a11=a11.split(".")[-2]
                        neww=os.path.join(i[0], a11)
                        if ao=="documents":
                            jjj=neww+".css"
                            rj=neww+".css"
                        else:
                            jjj=neww+".css"
                            rj=a11+".css"
                            
                        f=open(jjj,"w+")
                        f.write('''*{
box-sizing: border-box;
padding: 0;
margin: 0;
}
                
                ''')
                        f.close()
                        f=open(i0,"w")
                        f.write(f'''<!DOCTYPE html>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <meta http-equiv="X-UA-Compatible" content="ie=edge">
            <title>Document</title>
            <link rel="stylesheet" href="{rj}">
        </head>

        <body>
            <!-- this page is generated by Chatur -->
            <h1>hi there.. current time is{ti}</h1>  
        <script src="{jjo}"></script>
        </body>
        </html>''')
                    f.close()
                else:
                    pass
if __name__ == "__main__":
    Auto_generator()