# Path: siman/small_functions.py
# def makedir(path, renew_folder=False):
#     """
#     *path* - path to some file 
#     Make dirname(path) directory if it does not exist
#     """
#     import shutil as S
# 
#     dirname = os.path.dirname(path)
# 
#     if renew_folder and os.path.exists(dirname): S.rmtree(path)
#     else: pass
# 
#     if dirname and not os.path.exists(dirname):
#         os.makedirs(dirname)
#         printlog("Directory", dirname, " was created", imp = 'y')
#     return


import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib.gridspec import GridSpec
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.core import Spin, OrbitalType
from siman.small_functions import makedir
    from siman.small_functions import makedir
    This function is used to build plot of the electronic band structure along with
    the density of states (DOS) plot. It has feature to provide contributions from different
    elements to both band structure and DOS. In addition, the band gap (in eV) is automatically
    calculated.

    INPUT:
        - vasprun_dos (str) - path to the vasprun file of the DOS calculation
        - vasprun_band (str) - path to the vasprun file of the band structure calculation
        - kpoints (str) - path to the KPOINTS file of the band structure calculation
        - element (str) - label of the chemical element, for which the contribution
                          to the band structure and DOS
        - ylim (tuple of floats) - energy range of the band structure and DOS plots, units are eV
        - folder (str) - directory where all the results will be built
        - renew_folder (bool) - if True then the folder will be renewed with removing old one
        - vb_top (int) - number of the last occupied band (valence band) (count starts from '1')
        - vbm_pos (int) - supposed number of the k-point in the IBZKPT file, at which the valence band maximum (VBM) is located (count starts from '0')
        - cb_bottom (int) - number of the first unoccupied band (conduction band) (count starts from '1')
        - cbm_pos (int) - supposed number of the k-point in the IBZKPT file, at which the conduction band minimum (CBM) is located (count starts from '0')
 
    RETURN:
        None
    SOURCE:
        Credit https://github.com/gVallverdu/bandstructureplots
    TODO:
        Some improvements
    """    

    # The folder to collect data necessary for graph building
    full_name_folder_data = folder+vasprun_bands.split('/')[-2]
    print('bands.py, string 274, full_name_folder_data ', full_name_folder_data)

# Path: siman/small_functions.py
# def makedir(path, renew_folder=False):
#     """
#     *path* - path to some file 
#     Make dirname(path) directory if it does not exist
#     """
#     import shutil as S
# 
#     dirname = os.path.dirname(path)
# 
#     if renew_folder and os.path.exists(dirname): S.rmtree(path)
#     else: pass
# 
#     if dirname and not os.path.exists(dirname):
#         os.makedirs(dirname)
#         printlog("Directory", dirname, " was created", imp = 'y')
#     return


# Path: siman/bands.py
import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
from matplotlib.gridspec import GridSpec
from pymatgen.io.vasp import Vasprun
from pymatgen.electronic_structure.core import Spin, OrbitalType
from siman.small_functions import makedir
    from siman.small_functions import makedir

    This function is used to build plot of the electronic band structure along with
    the density of states (DOS) plot. It has feature to provide contributions from different
    elements to both band structure and DOS. In addition, the band gap (in eV) is automatically
    calculated.

    INPUT:
        - vasprun_dos (str) - path to the vasprun file of the DOS calculation
        - vasprun_band (str) - path to the vasprun file of the band structure calculation
        - kpoints (str) - path to the KPOINTS file of the band structure calculation
        - element (str) - label of the chemical element, for which the contribution
                          to the band structure and DOS
        - ylim (tuple of floats) - energy range of the band structure and DOS plots, units are eV
        - folder (str) - directory where all the results will be built
        - renew_folder (bool) - if True then the folder will be renewed with removing old one
        - vb_top (int) - number of the last occupied band (valence band) (count starts from '1')
        - vbm_pos (int) - supposed number of the k-point in the IBZKPT file, at which the valence band maximum (VBM) is located (count starts from '0')
        - cb_bottom (int) - number of the first unoccupied band (conduction band) (count starts from '1')
        - cbm_pos (int) - supposed number of the k-point in the IBZKPT file, at which the conduction band minimum (CBM) is located (count starts from '0')
 
    RETURN:
        None
    SOURCE:
        Credit https://github.com/gVallverdu/bandstructureplots
    TODO:
        Some improvements
    """    

    # The folder to collect data necessary for graph building
    full_name_folder_data = folder+vasprun_bands.split('/')[-2]
    print('bands.py, string 274, full_name_folder_data ', full_name_folder_data)

    makedir(full_name_folder_data+'/', renew_folder = renew_folder)