# Path: ififuncs.py
# def make_desktop_logs_dir():
#     desktop_logs_dir = os.path.expanduser("~/Desktop/ifiscripts_logs")
#     if not os.path.isdir(desktop_logs_dir):
#         #I should probably ask permission here, or ask for alternative location
#         os.makedirs(desktop_logs_dir)
#     return desktop_logs_dir
# 
# def make_desktop_manifest_dir():
#     desktop_manifest_dir = os.path.expanduser("~/Desktop/moveit_manifests")
#     if not os.path.isdir(desktop_manifest_dir):
#         #I should probably ask permission here, or ask for alternative location
#         os.makedirs(desktop_manifest_dir)
#         os.makedirs(os.path.join(desktop_manifest_dir, 'old_manifests'))
#     else:
#         if not os.path.isdir(os.path.join(desktop_manifest_dir, 'old_manifests')):
#             os.makedirs(os.path.join(desktop_manifest_dir, 'old_manifests'))
#     return desktop_manifest_dir
# 
# def generate_log(log, what2log):
#     if not os.path.isfile(log):
#         with open(log, "w", encoding='utf-8') as fo:
#             fo.write(time.strftime("%Y-%m-%dT%H:%M:%S ")
#                      + getpass.getuser()
#                      + ' ' + what2log + ' \n')
#     else:
#         with open(log, "a", encoding='utf-8') as fo:
#             fo.write(time.strftime("%Y-%m-%dT%H:%M:%S ")
#                      + getpass.getuser()
#                      + ' ' + what2log + ' \n')


import sys
import subprocess
import os
import filecmp
import tempfile
import time
import argparse
import hashlib
import shutil
import unicodedata
import ififuncs
from builtins import input
from ififuncs import make_desktop_logs_dir, make_desktop_manifest_dir, generate_log
    '''
    count_in_manifest = 0
    manifest_files = []
    proceed = 'n'
    if os.path.isfile(manifest_root):
        proceed = 'y'
        manifest_info = manifest_file_count(manifest_root)
        count_in_manifest = manifest_info[0]
        manifest_files = manifest_info[1]
    elif os.path.isfile(manifest_sidecar):
        manifest_info = manifest_file_count(manifest_sidecar)
        proceed = 'y'
        count_in_manifest = manifest_info[0]
        manifest_files = manifest_info[1]
    elif os.path.isfile(manifest):
        manifest_info = manifest_file_count(manifest)
        count_in_manifest = manifest_info[0]
        manifest_files = manifest_info[1]
        proceed = 'y'
    if proceed == 'y':
        if source_count != count_in_manifest:
            print('checking which files are different')
            for i in file_list:
                if i not in manifest_files:
                    print((i, 'is present in your source directory but not in the source manifest'))
            for i in manifest_files:
                if i not in file_list:
                    print((i, 'is present in manifest but is missing in your source files'))
            print('This manifest may be outdated as the number of files in your directory does not match the number of files in the manifest')
            print(('There are', source_count, 'files in your source directory', count_in_manifest, 'in the manifest'))

# Path: ififuncs.py
# def make_desktop_logs_dir():
#     desktop_logs_dir = os.path.expanduser("~/Desktop/ifiscripts_logs")
#     if not os.path.isdir(desktop_logs_dir):
#         #I should probably ask permission here, or ask for alternative location
#         os.makedirs(desktop_logs_dir)
#     return desktop_logs_dir
# 
# def make_desktop_manifest_dir():
#     desktop_manifest_dir = os.path.expanduser("~/Desktop/moveit_manifests")
#     if not os.path.isdir(desktop_manifest_dir):
#         #I should probably ask permission here, or ask for alternative location
#         os.makedirs(desktop_manifest_dir)
#         os.makedirs(os.path.join(desktop_manifest_dir, 'old_manifests'))
#     else:
#         if not os.path.isdir(os.path.join(desktop_manifest_dir, 'old_manifests')):
#             os.makedirs(os.path.join(desktop_manifest_dir, 'old_manifests'))
#     return desktop_manifest_dir
# 
# def generate_log(log, what2log):
#     if not os.path.isfile(log):
#         with open(log, "w", encoding='utf-8') as fo:
#             fo.write(time.strftime("%Y-%m-%dT%H:%M:%S ")
#                      + getpass.getuser()
#                      + ' ' + what2log + ' \n')
#     else:
#         with open(log, "a", encoding='utf-8') as fo:
#             fo.write(time.strftime("%Y-%m-%dT%H:%M:%S ")
#                      + getpass.getuser()
#                      + ' ' + what2log + ' \n')


# Path: copyit.py
import sys
import subprocess
import os
import filecmp
import tempfile
import time
import argparse
import hashlib
import shutil
import unicodedata
import ififuncs
from builtins import input
from ififuncs import make_desktop_logs_dir, make_desktop_manifest_dir, generate_log

    '''
    count_in_manifest = 0
    manifest_files = []
    proceed = 'n'
    if os.path.isfile(manifest_root):
        proceed = 'y'
        manifest_info = manifest_file_count(manifest_root)
        count_in_manifest = manifest_info[0]
        manifest_files = manifest_info[1]
    elif os.path.isfile(manifest_sidecar):
        manifest_info = manifest_file_count(manifest_sidecar)
        proceed = 'y'
        count_in_manifest = manifest_info[0]
        manifest_files = manifest_info[1]
    elif os.path.isfile(manifest):
        manifest_info = manifest_file_count(manifest)
        count_in_manifest = manifest_info[0]
        manifest_files = manifest_info[1]
        proceed = 'y'
    if proceed == 'y':
        if source_count != count_in_manifest:
            print('checking which files are different')
            for i in file_list:
                if i not in manifest_files:
                    print((i, 'is present in your source directory but not in the source manifest'))
            for i in manifest_files:
                if i not in file_list:
                    print((i, 'is present in manifest but is missing in your source files'))
            print('This manifest may be outdated as the number of files in your directory does not match the number of files in the manifest')
            print(('There are', source_count, 'files in your source directory', count_in_manifest, 'in the manifest'))

            generate_log(log_name_source, 'EVENT = Existing source manifest check - Failure - The number of files in the source directory is not equal to the number of files in the source manifest ')