# -*- coding: utf-8 -*-
""" A class to create files """
import os
from shutil import copyfile
from pathlib import Path


class FileHandler:
  """ Class handles the creation of Files"""

  def __init__(self):
    """ TODO remove if not deeded, use super Constructing the FileHandler"""

  @classmethod
  def create_file_path(cls,path: os.path, name: str, suffix: str) -> os.path:
    """ Creates the file path out of the directory path, filename and suffix."""
    return os.path.join(path, name + "." + suffix)

  @staticmethod
  def _create_folder(directory_path):
    """ creates a folder 
    
    only to be called if the target folder does not yet exists"""
    os.makedirs(directory_path)

  def create_file(self, directory_path: os.path, file_name: str, filename_suffix: str):
    """ creates a empty file

    :param directory_path: The path to the directory the file should be created.
    :param file_name: the name of the new file.
    :param filename_suffix: the suffix of the new file.
    """
    file_path = self.create_file_path(directory_path, file_name,
      filename_suffix)
    if not os.path.exists(file_path):
      self._create_folder(directory_path)

    Path(file_path).touch()

  def create_file_from_path(self, file_path: os.path) -> os.path:
    """
    creates a empty file

    :param file_path: the path to the file.
    :return: the path of the created file
    """
    self.__create_folder_for_file_path_if_not_exist(self, file_path)
    Path(file_path).touch()
    return file_path

  def copy_file(self, source:os.path, destination:os.path) -> os.path:
    """ Copies a database file

    :param source: the source path of the database
    :param destination: the destination path of the database
    :return: he path of the copied file
    """
    self.__create_folder_for_file_path_if_not_exist(self, destination)
    copyfile(source, destination)
    return destination

  def create_or_modify_file_with_content(self, source: os.path, content: str):
    self.__create_folder_for_file_path_if_not_exist(self, source)
    self._add_content_to_file(source, content)

  @staticmethod
  def add_content(source: os.path, content: str) -> os.path:
    """ Add content to a file and create file if non existing

    :param source: The path of the file to edit.
    :param content: The content to append to the file.
    :return: The path of the edited file.
    """
    with open(source, "a") as file:
      file.write(content)

    return source

  @staticmethod
  def __create_folder_for_file_path_if_not_exist(self, file_path: os.path):
    """Creates folders for the given file if it does not exist"""
    if not os.path.exists(os.path.dirname(file_path)):
      self._create_folder(os.path.dirname(file_path))

@@ -321,29 +321,26 @@
 ath(cls,
+ 
 path: 
-os.path
+str
 , name: 
@@ -352,39 +352,35 @@
 suffix: str) -%3E 
-os.path
+str
 :%0A    %22%22%22 Create
@@ -497,30 +497,29 @@
 suffix)%0A%0A  @
-static
+class
 method%0A  def
@@ -526,32 +526,37 @@
  _create_folder(
+cls, 
 directory_path):
@@ -726,23 +726,19 @@
 y_path: 
-os.path
+str
 , file_n
@@ -1236,35 +1236,27 @@
 e_path: 
-os.path) -%3E os.path
+str) -%3E str
 :%0A    %22%22
@@ -1525,23 +1525,19 @@
  source:
-os.path
+str
 , destin
@@ -1546,27 +1546,19 @@
 ion:
-os.path) -%3E os.path
+str) -%3E str
 :%0A  
@@ -1923,39 +1923,35 @@
 t(self, source: 
-os.path
+str
 , content: str):
@@ -2064,30 +2064,29 @@
 ontent)%0A%0A  @
-static
+class
 method%0A  def
@@ -2098,24 +2098,29 @@
 content(
+cls, 
 source: 
 os.path,
@@ -2111,23 +2111,19 @@
 source: 
-os.path
+str
 , conten
@@ -2133,23 +2133,19 @@
 str) -%3E 
-os.path
+str
 :%0A    %22%22
@@ -2444,14 +2444,13 @@
 %0A  @
-static
+class
 meth
@@ -2493,32 +2493,37 @@
 th_if_not_exist(
+cls, 
 self, file_path:
@@ -2523,23 +2523,19 @@
 e_path: 
-os.path
+str
 ):%0A    %22

change type from os.path to str