コード例 #1
0
def clean_bag(bag_dir):
    if not is_bag(bag_dir.path):
        LOGGER.warning(_("%s is not a bag. Not cleaning."), bag_dir.path)
        return

    bag = bagit.Bag(bag_dir.path)
    if bag.compare_manifests_with_fs()[1]:
        for payload_file in bag.compare_manifests_with_fs()[1]:
            if grabbags.utils.is_system_file(payload_file):
                LOGGER.info("Removing {}".format(bag_dir.path))
                os.remove(payload_file)
            else:
                LOGGER.warning("Not removing {}".format(bag_dir.path))
コード例 #2
0
def make_bag(bag_dir, args):
    if is_bag(bag_dir.path):
        LOGGER.warning(_("%s is already a bag. Skipped."), bag_dir.path)
        return

    if args.no_system_files is True:
        LOGGER.info(_("Cleaning %s of system files"), bag_dir.path)
        grabbags.utils.remove_system_files(root=bag_dir.path)

    bag = bagit.make_bag(bag_dir.path,
                         bag_info=args.bag_info,
                         processes=args.processes,
                         checksums=args.checksums)
    successes.append(bag_dir.path)
    LOGGER.info(_("Bagged %s"), bag.path)
コード例 #3
0
ファイル: grabbags.py プロジェクト: jyw321/grabbags
def clean_bag(bag_dir):
    if not is_bag(bag_dir.path):
        LOGGER.warning(_("%s is not a bag. Not cleaning."), bag_dir.path)
        return

    bag = bagit.Bag(bag_dir.path)
    if bag.compare_manifests_with_fs()[1]:
        for payload_file in bag.compare_manifests_with_fs()[1]:
            if grabbags.utils.is_system_file(payload_file):
                LOGGER.info("Removing system files from {}".format(
                    bag_dir.path))
                os.remove(os.path.join(bag_dir.path, payload_file))
            else:
                LOGGER.warning(
                    "Found file not in manifest: {}".format(payload_file))
    else:
        LOGGER.info("No system files located in {}".format(bag_dir.path))
コード例 #4
0
ファイル: grabbags.py プロジェクト: jyw321/grabbags
def make_bag(bag_dir: "os.DirEntry[str]", args):
    if len(os.listdir(bag_dir.path)) == 0:
        LOGGER.warning(_("%s is an empty directory. Skipped."), bag_dir.path)
        return

    if is_bag(bag_dir.path):
        LOGGER.warning(_("%s is already a bag. Skipped."), bag_dir.path)
        return

    if args.no_system_files is True:
        LOGGER.info(_("Cleaning %s of system files"), bag_dir.path)
        grabbags.utils.remove_system_files(root=bag_dir.path)

    bag = bagit.make_bag(bag_dir.path,
                         bag_info=args.bag_info,
                         processes=args.processes,
                         checksums=args.checksums)
    successes.append(bag_dir.path)
    LOGGER.info(_("Bagged %s"), bag.path)
コード例 #5
0
ファイル: grabbags.py プロジェクト: brynknowles/grabbags
def validate_bag(bag_dir, args):
    if not is_bag(bag_dir.path):
        LOGGER.warn(_("%s is not a bag. Skipped."), bag_dir.path)
        return

    bag = bagit.Bag(bag_dir.path)
    # validate throws a BagError or BagValidationError
    bag.validate(
        processes=args.processes,
        fast=args.fast,
        completeness_only=args.no_checksums,
    )
    if args.fast:
        LOGGER.info(_("%s valid according to Payload-Oxum"), bag_dir.path)
    elif args.no_checksums:
        LOGGER.info(_("%s valid according to Payload-Oxum and file manifest"),
                    bag_dir.path)
    else:
        LOGGER.info(_("%s is valid"), bag_dir.path)