# Path: masscopy.py
# def analyze_log(logfile):
#     '''
#     Analyzes logfiles on the desktop and summarises the outcome.
#     '''
#     outcome = ''
#     with open(logfile, 'r') as fo:
#         log_lines = fo.readlines()
#         for line in log_lines:
#             if 'EVENT = File Transfer Judgement - Success' in line:
#                 outcome = 'success'
#             if 'EVENT = File Transfer Outcome - Failure' in line:
#                 outcome = 'failure'
#             if 'EVENT = Existing source manifest check - Failure' in line:
#                 outcome = 'failure - might be outdated manifests in use'
#         return outcome


import os
import argparse
import sys
import shutil
import datetime
import time
import copyit
import ififuncs
import package_update
import accession
import manifest
import makezip
import accession
    import dicttoxml
            import clairmeta
from masscopy import analyze_log
    from clairmeta.utils.xml import prettyprint_xml
    from clairmeta import DCP
                            line = line.replace(os.path.basename(item), os.path.basename(new_path))
                            updated_lines.append(line)
                with open(manifest, 'w') as fo:
                    for lines in updated_lines:
                        fo.write(lines)
    consolidate_logs(log_names, sip_path)
    return log_names


def log_report(log_names):
    '''
    Analyzes all the moveit.py logs on the desktop and print a report.
    '''
    desktop_logs_dir = ififuncs.make_desktop_logs_dir()
    for i in log_names:
        if os.path.isfile(i):
            print(("%-*s   :  copyit job was a %s" % (50, os.path.basename(i)[:-24], analyze_log(i))))
        else:
            print((i, 'can\'t find log file, trying again...'))
            log_names.remove(i)
            for logs in os.listdir(desktop_logs_dir):
                # look at log filename minus the seconds and '.log'
                if os.path.basename(i)[:-7] in logs:
                    # 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" % (

# Path: masscopy.py
# def analyze_log(logfile):
#     '''
#     Analyzes logfiles on the desktop and summarises the outcome.
#     '''
#     outcome = ''
#     with open(logfile, 'r') as fo:
#         log_lines = fo.readlines()
#         for line in log_lines:
#             if 'EVENT = File Transfer Judgement - Success' in line:
#                 outcome = 'success'
#             if 'EVENT = File Transfer Outcome - Failure' in line:
#                 outcome = 'failure'
#             if 'EVENT = Existing source manifest check - Failure' in line:
#                 outcome = 'failure - might be outdated manifests in use'
#         return outcome


# Path: sipcreator.py
import os
import argparse
import sys
import shutil
import datetime
import time
import copyit
import ififuncs
import package_update
import accession
import manifest
import makezip
import accession
    import dicttoxml
            import clairmeta
from masscopy import analyze_log
    from clairmeta.utils.xml import prettyprint_xml
    from clairmeta import DCP

                            line = line.replace(os.path.basename(item), os.path.basename(new_path))
                            updated_lines.append(line)
                with open(manifest, 'w') as fo:
                    for lines in updated_lines:
                        fo.write(lines)
    consolidate_logs(log_names, sip_path)
    return log_names


def log_report(log_names):
    '''
    Analyzes all the moveit.py logs on the desktop and print a report.
    '''
    desktop_logs_dir = ififuncs.make_desktop_logs_dir()
    for i in log_names:
        if os.path.isfile(i):
            print(("%-*s   :  copyit job was a %s" % (50, os.path.basename(i)[:-24], analyze_log(i))))
        else:
            print((i, 'can\'t find log file, trying again...'))
            log_names.remove(i)
            for logs in os.listdir(desktop_logs_dir):
                # look at log filename minus the seconds and '.log'
                if os.path.basename(i)[:-7] in logs:
                    # 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(