"""Functions regarding file and directory operations."""
# Do not call this script inside this directory.

import os
import time
from shutil import copyfile

# Define file estructure with date format
path_structure = 'entities/' + time.strftime('%Y/%m/%d')

def check_dir_exist():
    if os.path.isdir(path_structure):
        return True
    else:
        return False

def create_dir():
    if check_dir_exist():
        pass
    else:
        print("Directory '" + path_structure + "' does not exist. Creating...")
        os.makedirs(path_structure)

def create_entity(new_entity = 'draft_entity', AM = False, PEP = False, overwrite = False):
    """check if file exist. if not, then proceed to create."""

    empty_template = 'templates/empty_template.md'
    am_template = 'templates/am_template.md'
    am_pep_template = 'templates/am_pep_template.md'

    # Ask for new entity
    new_entity_estructure = path_structure + '/' + new_entity + '.md'

    # checks if file exist, if false: create new entity.
    if os.path.isfile(new_entity_estructure):
        return False

    elif AM == False and PEP == False:
        # copy empty skeleton
        create_dir()
        copyfile(empty_template, new_entity_estructure)
        return True

    elif AM == True and PEP == False:
        # copy adverse media only template
        create_dir()
        copyfile(am_template, new_entity_estructure)
        return True

    elif AM == True and PEP == True:
        # copy PEP template with adverse media
        create_dir
        copyfile(am_pep_template, new_entity_estructure)
        return True

    else:
        return False

@@ -595,16 +595,23 @@
 ntity', 
+entity_
 AM = Fal
@@ -614,16 +614,23 @@
  False, 
+entity_
 PEP = Fa
@@ -717,17 +717,16 @@
 ate.%22%22%22%0A
-%0A
     empt
@@ -862,25 +862,71 @@
 emplate.md'%0A
+    pep_template = 'templates/pep_template.md'
 %0A
-
     # Ask fo
@@ -1017,138 +1017,18 @@
     
-# checks if file exist, if false: create new entity.%0A    if os.path.isfile(new_entity_estructure):%0A        return False%0A%0A    elif 
+if entity_
 AM =
@@ -1035,24 +1035,31 @@
 = False and 
+entity_
 PEP == False
@@ -1189,32 +1189,39 @@
  True%0A%0A    elif 
+entity_
 AM == True and P
@@ -1215,24 +1215,31 @@
 == True and 
+entity_
 PEP == False
@@ -1387,16 +1387,23 @@
    elif 
+entity_
 AM == Tr
@@ -1409,16 +1409,23 @@
 rue and 
+entity_
 PEP == T
@@ -1444,16 +1444,23 @@
  # copy 
+entity_
 PEP temp
@@ -1501,16 +1501,18 @@
 eate_dir
+()
 %0A       
@@ -1578,24 +1578,229 @@
 eturn True%0A%0A
+    elif entity_AM == False and entity_PEP == True:%0A        # copy entity_PEP template with no adverse media%0A        create_dir()%0A        copyfile(pep_template, new_entity_estructure)%0A        return True%0A%0A
     else:%0A  

Create different templates