Called by ``docx.opc.package.PartFactory`` to load an image part from
        a package being opened by ``Document(...)`` call.
509392
def load(cls, partname, content_type, blob, package):
        
        return cls(partname, content_type, blob)
1174098
def to_file(package, directory):
        
        opf_filepath = os.path.join(directory, package.name)

        # Create the directory structure
        for name in ('contents', 'resources',):
            path = os.path.join(directory, name)
            if not os.path.exists(path):
                os.mkdir(path)

        # Write the items to the filesystem
        locations = {}  # Used when rendering
        for item in package:
            if item.media_type == 'application/xhtml+xml':
                base = os.path.join(directory, 'contents')
            else:
                base = os.path.join(directory, 'resources')
            filename = item.name
            filepath = os.path.join(base, filename)
            locations[item] = os.path.relpath(filepath, directory)
            with open(filepath, 'wb') as item_file:
                item_file.write(item.data.read())

        # Write the OPF
        template = jinja2.Template(OPF_TEMPLATE,
                                   trim_blocks=True, lstrip_blocks=True)
        with open(opf_filepath, 'wb') as opf_file:
            opf = template.render(package=package, locations=locations)
            if not isinstance(opf, bytes):
                opf = opf.encode('utf-8')
            opf_file.write(opf)

        return opf_filepath
186558
private Part createErrorPart(Attachment a) {
        return Part.builder().setName(String.valueOf(a.hashCode())).setSize(0).setType(Attachment.LOCAL_PART_TYPE_ERROR).setUrl(null).setData(a.getError().getLocalizedMessage()).build();
    }
254669
def _get_part_reader(self, headers: 'CIMultiDictProxy[str]') -> Any:
        
        ctype = headers.get(CONTENT_TYPE, '')
        mimetype = parse_mimetype(ctype)

        if mimetype.type == 'multipart':
            if self.multipart_reader_cls is None:
                return type(self)(headers, self._content)
            return self.multipart_reader_cls(
                headers, self._content, _newline=self._newline
            )
        else:
            return self.part_reader_cls(
                self._boundary, headers, self._content, _newline=self._newline
            )
1348604
def add_footer_part(self):
        """"""
        footer_part = FooterPart.new(self.package)
        rId = self.relate_to(footer_part, RT.FOOTER)
        return footer_part, rId
350591
def get_or_add_media_part(self, media):
        
        media_part = self._find_by_sha1(media.sha1)
        if media_part is None:
            media_part = MediaPart.new(self._package, media)
        return media_part
652040
public void loadSystem() {
		chooser.setDialogTitle("Open");
		int resp = chooser.showOpenDialog(this);
		if (resp == JFileChooser.APPROVE_OPTION) {
			File file = chooser.getSelectedFile();
			File path = file.getParentFile();
			
			try {
				ParticleSystem system = ParticleIO.loadConfiguredSystem(file);
				game.setSystem(system);
				emitters.clear();
				
				for (int i=0;i<system.getEmitterCount();i++) {
					final ConfigurableEmitter emitter = (ConfigurableEmitter) system.getEmitter(i);
					
					if (emitter.getImageName() != null) {
						File possible = new File(path, emitter.getImageName());
						if (possible.exists()) {
							emitter.setImageName(possible.getAbsolutePath());
						} else {
							chooser.setDialogTitle("Locate the image: "+emitter.getImageName());
							FileFilter filter = new FileFilter() {
								public boolean accept(File f) {
									if (f.isDirectory()) {
										return true;
									}
									
									return (f.getName().equals(emitter.getImageName()));
								}
	
								public String getDescription() {
									return emitter.getImageName();
								}
							};
							
							chooser.addChoosableFileFilter(filter);
							resp = chooser.showOpenDialog(this);
							if (resp == JFileChooser.APPROVE_OPTION) {
								File image = chooser.getSelectedFile();
								emitter.setImageName(image.getAbsolutePath());
								path = image.getParentFile();
							}
							chooser.setDialogTitle("Open");
							chooser.resetChoosableFileFilters();
							chooser.addChoosableFileFilter(xmlFileFilter);
						}
					}
					
					emitters.add(emitter);
				}
				additive.setSelected(system.getBlendingMode() == ParticleSystem.BLEND_ADDITIVE);
				pointsEnabled.setSelected(system.usePoints());
				
				emitters.setSelected(0);
			} catch (IOException e) {
				Log.error(e);
				JOptionPane.showMessageDialog(this, e.getMessage());
			}
		}
	}
521236
def unpack_from(cls, payload, expected_parts):
        """"""

        for num_part in iter_range(expected_parts):
            hdr = payload.read(cls.header_size)
            try:
                part_header = PartHeader(*cls.header_struct.unpack(hdr))
            except struct.error:
                raise InterfaceError("No valid part header")

            if part_header.payload_size % 8 != 0:
                part_payload_size = part_header.payload_size + 8 - (part_header.payload_size % 8)
            else:
                part_payload_size = part_header.payload_size
            pl = payload.read(part_payload_size)
            part_payload = io.BytesIO(pl)
            try:
                _PartClass = PART_MAPPING[part_header.part_kind]
            except KeyError:
                raise InterfaceError("Unknown part kind %s" % part_header.part_kind)

            debug('%s (%d/%d): %s', _PartClass.__name__, num_part+1, expected_parts, str(part_header))
            debug('Read %d bytes payload for part %d', part_payload_size, num_part + 1)

            init_arguments = _PartClass.unpack_data(part_header.argument_count, part_payload)
            debug('Part data: %s', init_arguments)
            part = _PartClass(*init_arguments)
            part.header = part_header
            part.attribute = part_header.part_attributes
            part.source = 'server'
            if pyhdb.tracing:
                part.trace_header = humanhexlify(hdr[:part_header.payload_size])
                part.trace_payload = humanhexlify(pl, 30)
            yield part
364587
def load_image_from_disk(img_spec):
    """"""

    if isinstance(img_spec, str):
        if pexists(realpath(img_spec)):
            hdr = nib.load(img_spec)
            # trying to stick to an orientation
            hdr = nib.as_closest_canonical(hdr)
            img = hdr.get_data()
        else:
            raise IOError('Given path to image does not exist!')
    elif isinstance(img_spec, np.ndarray):
        img = img_spec
    else:
        raise ValueError('Invalid input specified! '
                         'Input either a path to image data, or provide 3d Matrix directly.')

    return img
1054262
def extractImage(self, xref=0):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")

        return _fitz.Document_extractImage(self, xref)
1064251
private void openNewPartIfNecessary(long sizeThreshold) throws IOException {
		final long fileLength = fileStream.getPos();
		if (fileLength >= sizeThreshold) {
			lock();
			try {
				uploadCurrentAndOpenNewPart(fileLength);
			} finally {
				unlock();
			}
		}
	}
774784
def _new_theme_part(cls, package):
        
        partname = package.next_partname('/ppt/theme/theme%d.xml')
        content_type = CT.OFC_THEME
        theme = CT_OfficeStyleSheet.new_default()
        return XmlPart(partname, content_type, theme, package)
862796
def _load_image(cls, rkey):
        """"""

        v = cls._stock[rkey]
        img = None
        itype = v['type']
        if itype in ('stock', 'data'):
            img = tk.PhotoImage(format=v['format'], data=v['data'])
        elif itype == 'created':
            img = v['image']
        else:
            img = tk.PhotoImage(file=v['filename'])
        cls._cached[rkey] = img
        logger.info('Loaded resource %s.' % rkey)
        return img
431206
def get_file_contents(file_path):
  """"""
  full_path = os.path.join(package_dir, file_path)
  return open(full_path, 'r').read()
938165
public static SARLPackageExplorerPart openInActivePerspective() {
		try {
			return (SARLPackageExplorerPart) JavaPlugin.getActivePage().showView(ID_PACKAGES);
		} catch (PartInitException exception) {
			return null;
		}
	}
1353967
def load_img(self, img_path):
        
        with open_file(self.uuid, img_path) as f:
            return mpimg.imread(f)
1192096
def _load_contents(self, polib, resource):
        
        import struct
        try:
            return polib.mofile(resource)
        except (ValueError, AttributeError, struct.error) as e:
            self.rethrow(
                "Invalid resource {0}".format(resource),
                InvalidResourceException)