示例#1
0
def addImages(dict_tree,image_src):
    '''
    Returns a dict_tree where all the images from image_src has been inserted
    into the physical struct map and file section
    
    :param dict_tree: dict tree to insert images
    :param image_src: folder in which the images exist
    '''
    dict_tree = dmd_sec_tools.fixPathimagefiles(dict_tree, image_src)
    images = fs_tools.getImages(image_src)
    ## Handle Physical Stuct Map
    # Get physical struct map
    physical_struct_map = phys_struct_map_tools.get(dict_tree)
    # Check the struct map exists
    if physical_struct_map is None:
        raise ValueError('physical_struct_map is missing from dict_tree')
    if (phys_struct_map_tools.isEmpty(physical_struct_map) or
        not phys_struct_map_tools.isValid(physical_struct_map, image_src)):
        # Clear existing physical struct map
        physical_struct_map = phys_struct_map_tools.clear(physical_struct_map)
        # Add pages to empty physical struct map
        physical_struct_map = phys_struct_map_tools.create(physical_struct_map,
                                                     len(images))
    file_section = file_sec_tools.get(dict_tree)
    file_section = file_sec_tools.create(file_section,images)
    dict_tree = file_sec_tools.insert(dict_tree, file_section)
    return dict_tree
示例#2
0
def containsImages(dict_tree):

    # legr: returns True if the meta.xml's file section is empty
    # legr: (file section maps actual file path to ID="FILE_nnnn")
    empty_file_sec = file_sec_tools.isEmpty(file_sec_tools.get(dict_tree))
    # legr: returns True if the meta.xml's physical struct map section is empty
    # legr: (structMap TYPE="PHYSICAL" maps the above FILE_nnnn to PHYS_nnnn and adds ORDER and ORDERLABEL
    empty_phys_struct_map = phys_struct_map_tools.isEmpty(phys_struct_map_tools.get(dict_tree))
    # Both file_sec_tools and physical struct map must be non empty
    # legr: returns False if one or both are empty
    return not empty_file_sec and not empty_phys_struct_map
def containsImages(dict_tree):

    empty_file_sec = file_sec_tools.isEmpty(file_sec_tools.get(dict_tree))
    empty_phys_struct_map = phys_struct_map_tools.isEmpty(phys_struct_map_tools.get(dict_tree))
    # Both file_sec_tools and physical struct map must be non empty
    return (not empty_file_sec and not empty_phys_struct_map)