def doi_main(files):
    """
    Main function that controls the script. Take in directory containing the .lpd file(s). Loop for each file.
    :return None:
    """
    logger_doi_main.info("enter doi_main")

    print("Found {0} {1} file(s)".format(str(len(files[".lpd"])), 'LiPD'))
    force = prompt_force()
    for file in files[".lpd"]:

        # Unzip file and get tmp directory path
        dir_tmp = create_tmp_dir()
        unzipper(file["filename_ext"], dir_tmp)

        # Force DOI update?
        if force:
            # Update file. Forcing updates for all files.
            print('processing: {}'.format(file["filename_ext"]))
            logger_doi_main.info("processing: {}".format(file["filename_ext"]))
            # dir: dir_root -> dir_tmp
            process_lpd(file["filename_no_ext"], dir_tmp)
            # dir: dir_tmp -> dir_root
            os.chdir(file["dir"])
            # Zip the directory containing the updated files. Created in dir_root directory
            zipper(path_name_ext=file["filename_ext"], root_dir=dir_tmp, name=file["filename_no_ext"])
            # Cleanup and remove tmp directory
            shutil.rmtree(dir_tmp)

        if not force:
            # Don't Update File. Flag found and we're not forcing updates.
            if resolved_flag(open_bag(os.path.join(dir_tmp, file["filename_no_ext"]))):
                print('skipping: {}'.format(file["filename_ext"]))
                logger_doi_main.info("skipping: {}".format(file["filename_ext"]))
                shutil.rmtree(dir_tmp)

            # Update File. No flag found and hasn't been processed before.
            else:
                print('processing: {}'.format(file["filename_ext"]))
                logger_doi_main.info("processing: {}".format(file["filename_ext"]))
                # dir: dir_root -> dir_tmp
                process_lpd(file["filename_no_ext"], dir_tmp)
                # dir: dir_tmp -> dir_root
                os.chdir(file["dir"])
                # Zip the directory containing the updated files. Created in dir_root directory
                zipper(path_name_ext=file["filename_ext"], root_dir=dir_tmp, name=file["filename_no_ext"])
                # Cleanup and remove tmp directory
                shutil.rmtree(dir_tmp)
    logger_doi_main.info("exit doi_main")
    print("Process Complete")
    return
def doi_main ( files ) : logger_doi_main . info ( "enter doi_main" ) print ( "Found {0} {1} file(s)" . format ( str ( len ( files [ ".lpd" ] ) ) , 'LiPD' ) ) force = prompt_force ( ) for file in files [ ".lpd" ] : dir_tmp = create_tmp_dir ( ) unzipper ( file [ "filename_ext" ] , dir_tmp ) if force : print ( 'processing: {}' . format ( file [ "filename_ext" ] ) ) logger_doi_main . info ( "processing: {}" . format ( file [ "filename_ext" ] ) ) process_lpd ( file [ "filename_no_ext" ] , dir_tmp ) os . chdir ( file [ "dir" ] ) zipper ( path_name_ext = file [ "filename_ext" ] , root_dir = dir_tmp , name = file [ "filename_no_ext" ] ) shutil . rmtree ( dir_tmp ) if not force : if resolved_flag ( open_bag ( os . path . join ( dir_tmp , file [ "filename_no_ext" ] ) ) ) : print ( 'skipping: {}' . format ( file [ "filename_ext" ] ) ) logger_doi_main . info ( "skipping: {}" . format ( file [ "filename_ext" ] ) ) shutil . rmtree ( dir_tmp ) else : print ( 'processing: {}' . format ( file [ "filename_ext" ] ) ) logger_doi_main . info ( "processing: {}" . format ( file [ "filename_ext" ] ) ) process_lpd ( file [ "filename_no_ext" ] , dir_tmp ) os . chdir ( file [ "dir" ] ) zipper ( path_name_ext = file [ "filename_ext" ] , root_dir = dir_tmp , name = file [ "filename_no_ext" ] ) shutil . rmtree ( dir_tmp ) logger_doi_main . info ( "exit doi_main" ) print ( "Process Complete" ) return
Main function that controls the script. Take in directory containing the .lpd file(s). Loop for each file.
    :return None: