# 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
        if os.path.isdir(dircheck):
            source = check_for_sip(args.source)
            destination = os.path.join(args.destination, os.path.basename(args.source))
            os.makedirs(destination)
    else:
        source = os.path.abspath(args.source)
        destination = args.destination
    normpath = os.path.normpath(source)
    #is there any benefit to this over os.path.basename
    dirname = os.path.split(os.path.basename(source))[1]
    if dirname == '':
        rootpos = 'y'
        '''
        dirname = raw_input(
            'What do you want your destination folder to be called?\n'
        )
        '''
    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

# 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

        if os.path.isdir(dircheck):
            source = check_for_sip(args.source)
            destination = os.path.join(args.destination, os.path.basename(args.source))
            os.makedirs(destination)
    else:
        source = os.path.abspath(args.source)
        destination = args.destination
    normpath = os.path.normpath(source)
    #is there any benefit to this over os.path.basename
    dirname = os.path.split(os.path.basename(source))[1]
    if dirname == '':
        rootpos = 'y'
        '''
        dirname = raw_input(
            'What do you want your destination folder to be called?\n'
        )
        '''
    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()