# 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
        '''
    relative_path = normpath.split(os.sep)[-1]
    # or hardcode
    destination_final_path = os.path.join(destination, dirname)
    if rootpos == 'y':
        manifest_destination = os.path.dirname(destination) + '/%s_manifest.md5' % os.path.basename(destination)
    else:
        manifest_destination = destination + '/%s_manifest.md5' % dirname
    if os.path.isfile(manifest_destination):
        print('Destination manifest already exists')
    if rootpos == 'y':
        manifest_filename = '%s_manifest.md5' % os.path.basename(destination)
    else:
        manifest_filename = '%s_manifest.md5' % dirname
    desktop_manifest_dir = make_desktop_manifest_dir()
    # manifest = desktop manifest, looks like this can get rewritten later.
    manifest = os.path.join(
        desktop_manifest_dir, manifest_filename
    )
    manifest_sidecar = os.path.join(
        os.path.dirname(source), relative_path + '_manifest.md5'
    )
    manifest_root = source + '/%s_manifest.md5' % os.path.basename(source)
    log_name_filename = dirname + time.strftime("_%Y_%m_%dT%H_%M_%S")
    desktop_logs_dir = make_desktop_logs_dir()
    log_name_source = "%s/%s.log" % (desktop_logs_dir, log_name_filename)
    generate_log(log_name_source, 'copyit.py started.')
    ififuncs.generate_log(
        log_name_source,
        'eventDetail=copyit.py %s' % ififuncs.get_script_version('copyit.py'))

# 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

        '''
    relative_path = normpath.split(os.sep)[-1]
    # or hardcode
    destination_final_path = os.path.join(destination, dirname)
    if rootpos == 'y':
        manifest_destination = os.path.dirname(destination) + '/%s_manifest.md5' % os.path.basename(destination)
    else:
        manifest_destination = destination + '/%s_manifest.md5' % dirname
    if os.path.isfile(manifest_destination):
        print('Destination manifest already exists')
    if rootpos == 'y':
        manifest_filename = '%s_manifest.md5' % os.path.basename(destination)
    else:
        manifest_filename = '%s_manifest.md5' % dirname
    desktop_manifest_dir = make_desktop_manifest_dir()
    # manifest = desktop manifest, looks like this can get rewritten later.
    manifest = os.path.join(
        desktop_manifest_dir, manifest_filename
    )
    manifest_sidecar = os.path.join(
        os.path.dirname(source), relative_path + '_manifest.md5'
    )
    manifest_root = source + '/%s_manifest.md5' % os.path.basename(source)
    log_name_filename = dirname + time.strftime("_%Y_%m_%dT%H_%M_%S")
    desktop_logs_dir = make_desktop_logs_dir()
    log_name_source = "%s/%s.log" % (desktop_logs_dir, log_name_filename)
    generate_log(log_name_source, 'copyit.py started.')
    ififuncs.generate_log(
        log_name_source,
        'eventDetail=copyit.py %s' % ififuncs.get_script_version('copyit.py'))

    generate_log(log_name_source, 'Source: %s' % source)