set image attributes from MediaWiki API:Imageinfo response
190739
def _set_imageinfo_data(self):
        
        data = self._load_response('imageinfo')
        pages = data['query'].get('pages')

        normalized = []
        if 'normalized' in data['query']:
            normalized = data['query']['normalized']

        for page in pages:
            title = page.get('title')
            imageinfo = page.get('imageinfo')
            if imageinfo:
                self.__pull_image_info(title, imageinfo, normalized)

        # Mark missing imageinfo to prevent duplicate requests
        for img in self.data['image']:
            if 'url' not in img:
                img['url'] = 'MISSED'
817771
def svs_description_metadata(description):
    
    if not description.startswith('Aperio Image Library '):
        raise ValueError('invalid Aperio image description')
    result = {}
    lines = description.split('\n')
    key, value = lines[0].strip().rsplit(None, 1)  # 'Aperio Image Library'
    result[key.strip()] = value.strip()
    if len(lines) == 1:
        return result
    items = lines[1].split('|')
    result[''] = items[0].strip()  # TODO: parse this?
    for item in items[1:]:
        key, value = item.split(' = ')
        result[key.strip()] = astype(value.strip())
    return result
541744
public void getImageAttributes(
        final Map<String, String> attributes,
        final I_CmsSimpleCallback<Map<String, String>> callback) {

        boolean requiresLink = false;

        for (Entry<Attribute, I_CmsFormWidget> entry : m_fields.entrySet()) {
            String val = entry.getValue().getFormValueAsString();
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(val)) {
                continue;
            }
            if (entry.getKey() == Attribute.linkPath) {
                requiresLink = true;
            } else {
                attributes.put(entry.getKey().name(), val);
            }
        }
        if (requiresLink) {
            CmsCoreProvider.get().substituteLinkForRootPath(
                m_fields.get(Attribute.linkPath).getFormValueAsString(),
                new I_CmsSimpleCallback<String>() {

                    public void execute(String arg) {

                        attributes.put(Attribute.linkPath.name(), arg);
                        callback.execute(attributes);
                    }
                });
        } else {
            callback.execute(attributes);
        }
    }
73233
def normalize_api_url(self):
        
        def tester(self, api_url):
            """
            Attempts to fetch general information about the MediaWiki instance
            in order to test whether *api_url* will return JSON.
            """
            data = self._fetch_http(api_url, {'action': 'query',
                                              'meta': 'siteinfo'})
            try:
                data_json = json.loads(data)
                return (data, data_json)
            except ValueError:
                return (data, None)

        data, data_json = tester(self, self._api_url)
        if data_json:
            return self._api_url
        else:
            # if there's an index.php in the URL, we might find the API
            if 'index.php' in self._api_url:
                test_api_url = self._api_url.split('index.php')[0] + 'api.php'
                test_data, test_data_json = tester(self, test_api_url)
                if test_data_json:
                    self._api_url = test_api_url
                    return self._api_url
            return None
219160
def get_image_info_by_image_id(self, image_id):
        
        logger.info("getting info about provided image specified by image_id '%s'", image_id)
        logger.debug("image_id = '%s'", image_id)
        # returns list of
        # {u'Created': 1414577076,
        #  u'Id': u'3ab9a7ed8a169ab89b09fb3e12a14a390d3c662703b65b4541c0c7bde0ee97eb',
        #  u'ParentId': u'a79ad4dac406fcf85b9c7315fe08de5b620c1f7a12f45c8185c843f4b4a49c4e',
        #  u'RepoTags': [u'buildroot-fedora:latest'],
        #  u'Size': 0,
        #  u'VirtualSize': 856564160}
        images = self.d.images()
        try:
            image_dict = [i for i in images if i['Id'] == image_id][0]
        except IndexError:
            logger.info("image not found")
            return None
        else:
            return image_dict
1349042
def _set_query_image(self, page):
        
        pageimage = page.get('pageimage')
        thumbnail = page.get('thumbnail')

        if pageimage or thumbnail:
            if 'image' not in self.data:
                self.data['image'] = []

        if pageimage:
            self.data['image'].append({
                'kind': 'query-pageimage',
                'file': pageimage})

        if thumbnail:
            qthumb = {'kind': 'query-thumbnail'}
            qthumb.update(thumbnail)
            qthumb['url'] = thumbnail.get('source')
            del qthumb['source']
            qthumb['file'] = qthumb['url'].split('/')[-2]
            self.data['image'].append(qthumb)
1127268
def _get_image_information(self):
        
        result = yield from self.manager.query("GET", "images/{}/json".format(self._image))
        return result
1101852
def image_show(id=None, name=None, profile=None):  # pylint: disable=C0103
    '''
    
    '''
    g_client = _auth(profile)
    ret = {}
    if name:
        for image in g_client.images.list():
            if image.name == name:
                id = image.id  # pylint: disable=C0103
                continue
    if not id:
        return {
            'result': False,
            'comment':
                'Unable to resolve image ID '
                'for name \'{0}\''.format(name)
            }
    try:
        image = g_client.images.get(id)
    except exc.HTTPNotFound:
        return {
            'result': False,
            'comment': 'No image with ID {0}'.format(id)
            }
    log.debug(
        'Properties of image %s:\n%s',
        image.name, pprint.PrettyPrinter(indent=4).pformat(image)
    )

    schema = image_schema(profile=profile)
    if len(schema.keys()) == 1:
        schema = schema['image']
    for key in schema:
        if key in image:
            ret[key] = image[key]
    return ret
1275621
public void setImageUrlAttribute(String name, String value) {
		ensureValue();
		Attribute attribute = new ImageUrlAttribute(value);
		attribute.setEditable(isEditable(name));
		getValue().getAllAttributes().put(name, attribute);
	}
420984
def get(self, show=True, proxy=None, timeout=0):
        
        wikibase = self.params.get('wikibase')

        if wikibase:

            self.flags['defer_imageinfo'] = True

            self.get_wikidata(False, proxy, timeout)
            self.get_query(False, proxy, timeout)
            self.get_parse(False, proxy, timeout)

            self.flags['defer_imageinfo'] = False

            self.get_restbase('/page/summary/', False, proxy, timeout)

            if show and not self.flags.get('silent'):
                self.show()

        else:

            self.flags['defer_imageinfo'] = True

            self.get_query(False, proxy, timeout)
            self.get_parse(False, proxy, timeout)

            if not self.data.get('wikibase'):
                self.skip_action('wikidata')

            self.get_wikidata(False, proxy, timeout)

            self.flags['defer_imageinfo'] = False

            wiki = self.params.get('wiki')
            if wiki and 'wikipedia.org' not in wiki:
                self.skip_action('restbase')

            self.get_restbase('/page/summary/', False, proxy, timeout)

            if show and not self.flags.get('silent'):
                self.show()

        return self
1304937
def get_media_requests(self, item, info):
        
        key_generator = item.get(self.QINIU_KEY_GENERATOR_FIELD)
        return [Request(x, meta={'qiniu_key_generator': key_generator}) for x in item.get(self.FILES_URLS_FIELD, [])]
1158314
def image_show(self, image_id):
        '''
        
        '''
        nt_ks = self.compute_conn
        image = nt_ks.images.get(image_id)
        links = {}
        for link in image.links:
            links[link['rel']] = link['href']
        ret = {
            'name': image.name,
            'id': image.id,
            'status': image.status,
            'progress': image.progress,
            'created': image.created,
            'updated': image.updated,
            'metadata': image.metadata,
            'links': links,
        }
        if hasattr(image, 'minDisk'):
            ret['minDisk'] = image.minDisk
        if hasattr(image, 'minRam'):
            ret['minRam'] = image.minRam

        return ret
1121435
def put_changes_images_with_http_info(request)
      raise ArgumentError, 'Incorrect request type' unless request.is_a? PutChangesImagesRequest

      @api_client.config.logger.debug 'Calling API: ChangesApi.put_changes_images ...' if @api_client.config.debugging
      # resource path
      local_var_path = '/comparison/compareDocuments/changes/images'

      # query parameters
      query_params = {}
      if local_var_path.include? ('{' + downcase_first_letter('OutFolder') + '}')
        local_var_path = local_var_path.sub('{' + downcase_first_letter('OutFolder') + '}', request.out_folder.to_s)
      else
        query_params[downcase_first_letter('OutFolder')] = request.out_folder unless request.out_folder.nil?
      end

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(request.request)
      data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
                                                        header_params: header_params,
                                                        query_params: query_params,
                                                        form_params: form_params,
                                                        body: post_body,
                                                        access_token: get_access_token,
                                                        return_type: 'Array<Link>')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called:
        ChangesApi#put_changes_images\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      [data, status_code, headers]
    end
1051833
def _update_images(self):
        
        wd_images = self.data['claims'].get('P18')  # image

        if wd_images:
            if not isinstance(wd_images, list):
                wd_images = [wd_images]

            if 'image' not in self.data:
                self.data['image'] = []

            for img_file in wd_images:
                self.data['image'].append({'file': img_file,
                                           'kind': 'wikidata-image'})
331500
def image_resolution(self) -> Optional[Tuple[int, int]]:
        

        """
        images = self.attributes.get('imageinfo', [])
        if images and isinstance(images, collections.abc.Sequence):
            img = images[0]
            return img['width'], img['height']
        return None
166823
def scanimage_metadata(self):
        """"""
        if not self.is_scanimage:
            return None
        result = {}
        try:
            framedata, roidata = read_scanimage_metadata(self._fh)
            result['FrameData'] = framedata
            result.update(roidata)
        except ValueError:
            pass
        # TODO: scanimage_artist_metadata
        try:
            result['Description'] = scanimage_description_metadata(
                self.pages[0].description)
        except Exception as exc:
            log.warning('ScanImage metadata: %s: %s',
                        exc.__class__.__name__, exc)
        return result
332100
private DescribeImagesResponseType describeImages(final Set<String> imageId) {
        DescribeImagesResponseType ret = new DescribeImagesResponseType();
        ret.setRequestId(UUID.randomUUID().toString());
        DescribeImagesResponseInfoType info = new DescribeImagesResponseInfoType();
        for (String ami : MOCK_AMIS) {
            if (imageId == null || imageId.isEmpty()) {
                DescribeImagesResponseItemType item = new DescribeImagesResponseItemType();
                item.setImageId(ami);
                item.setArchitecture("x86_64");
                item.setVirtualizationType("paravirtual");
                item.setName("My server");
                item.setHypervisor("xen");
                item.setRootDeviceType("ebs");
                item.setImageLocation("123456789012/My server");
                item.setKernelId("aki-88aa75e1");
                item.setImageOwnerId("123456789012");
                item.setRootDeviceName("/dev/sda1");
                item.setIsPublic(false);
                item.setImageType("machine");
                BlockDeviceMappingType blockDeviceMappingType = new BlockDeviceMappingType();
                BlockDeviceMappingItemType blockDeviceMapping = new BlockDeviceMappingItemType();
                blockDeviceMapping.setDeviceName("/dev/sda1");
                EbsBlockDeviceType ebs = new EbsBlockDeviceType();
                ebs.setDeleteOnTermination(true);
                ebs.setSnapshotId("snap-1234567890abcdef0");
                ebs.setVolumeSize(1);
                ebs.setVolumeType("standard");
                blockDeviceMapping.setEbs(ebs);
                blockDeviceMappingType.getItem().add(blockDeviceMapping);
                item.setBlockDeviceMapping(blockDeviceMappingType);
                info.getItem().add(item);
            } else if (imageId.contains(ami)) {
                DescribeImagesResponseItemType item = new DescribeImagesResponseItemType();
                item.setImageId(ami);
                item.setArchitecture("x86_64");
                item.setVirtualizationType("paravirtual");
                item.setName("My server");
                item.setHypervisor("xen");
                item.setRootDeviceType("ebs");
                item.setImageLocation("123456789012/My server");
                item.setKernelId("aki-88aa75e1");
                item.setImageOwnerId("123456789012");
                item.setRootDeviceName("/dev/sda1");
                item.setIsPublic(false);
                item.setImageType("machine");
                BlockDeviceMappingType blockDeviceMappingType = new BlockDeviceMappingType();
                BlockDeviceMappingItemType blockDeviceMapping = new BlockDeviceMappingItemType();
                blockDeviceMapping.setDeviceName("/dev/sda1");
                EbsBlockDeviceType ebs = new EbsBlockDeviceType();
                ebs.setDeleteOnTermination(true);
                ebs.setSnapshotId("snap-1234567890abcdef0");
                ebs.setVolumeSize(1);
                ebs.setVolumeType("standard");
                blockDeviceMapping.setEbs(ebs);
                blockDeviceMappingType.getItem().add(blockDeviceMapping);
                item.setBlockDeviceMapping(blockDeviceMappingType);
                info.getItem().add(item);
            }
        }
        ret.setImagesSet(info);

        return ret;
    }