# 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


import os
import argparse
import time
import copyit
from ififuncs import make_desktop_logs_dir
                    # make sure that the alternate log filename is more recent
                    if int(
                            os.path.basename(logs)[-12:-4].replace('_', '')) > int(os.path.basename(i)[-12:-4].replace('_', '')):
                        print(' - trying to analyze %s' % logs)
                        print(" - %-*s   : %s" % (50, os.path.basename(logs)[:-24], analyze_log(os.path.join(desktop_logs_dir, logs))))


def main():
    '''
    Launches the other functions wihch attempt to run multiple copyit.py
    instances if manifests and matching sidecar directories are found
    inside of the input directory.
    '''
    args = parse_args()
    all_files = find_manifest(args)
    processed_dirs = []
    log_names = []
    print('\n\n - **** All of these folders will be copied to %s\n' % args.o)
    for i in all_files:
        absolute_path = os.path.join(args.o, os.path.basename(i))
        if os.path.isdir(absolute_path):
            print(' - %s already exists, skipping' % absolute_path)
        else:
            print(' - %s will be copied' % i)
    time.sleep(2)
    for i in all_files:
        absolute_path = os.path.join(args.o, os.path.basename(i))
        if os.path.isdir(absolute_path):
            print(' - %s already exists, skipping' % absolute_path)
        else:

# 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


# Path: masscopy.py
import os
import argparse
import time
import copyit
from ififuncs import make_desktop_logs_dir

                    # make sure that the alternate log filename is more recent
                    if int(
                            os.path.basename(logs)[-12:-4].replace('_', '')) > int(os.path.basename(i)[-12:-4].replace('_', '')):
                        print(' - trying to analyze %s' % logs)
                        print(" - %-*s   : %s" % (50, os.path.basename(logs)[:-24], analyze_log(os.path.join(desktop_logs_dir, logs))))


def main():
    '''
    Launches the other functions wihch attempt to run multiple copyit.py
    instances if manifests and matching sidecar directories are found
    inside of the input directory.
    '''
    args = parse_args()
    all_files = find_manifest(args)
    processed_dirs = []
    log_names = []
    print('\n\n - **** All of these folders will be copied to %s\n' % args.o)
    for i in all_files:
        absolute_path = os.path.join(args.o, os.path.basename(i))
        if os.path.isdir(absolute_path):
            print(' - %s already exists, skipping' % absolute_path)
        else:
            print(' - %s will be copied' % i)
    time.sleep(2)
    for i in all_files:
        absolute_path = os.path.join(args.o, os.path.basename(i))
        if os.path.isdir(absolute_path):
            print(' - %s already exists, skipping' % absolute_path)
        else:

            desktop_logs_dir = make_desktop_logs_dir()