Handle parsing of OData Atom result and return an array of Entry classes
544331
def handle_collection_result(result)
    results = build_classes_from_result(result)
    while partial? && @options[:eager_partial]
      results.concat handle_partial
    end
    results
  end
708479
def ParseObjs(self, objs, type_names):
    """"""
    for obj in objs:
      for type_name in self._RDFTypes(type_names):
        if isinstance(obj, self._GetClass(type_name)):
          yield obj
931187
private JsonSimple parsedFormData(String oid) {
		// Get our data from Storage
		Payload payload = null;
		try {
			DigitalObject object = storage.getObject(oid);
			payload = getDataPayload(object);
		} catch (StorageException ex) {
			log.error("Error accessing object '{}' in storage: ", oid, ex);
			return null;
		}

		// Parse the JSON
		try {
			try {
				return FormDataParser.parse(payload.open());
			} catch (IOException ex) {
				log.error("Error parsing data '{}': ", oid, ex);
				return null;
			} finally {
				payload.close();
			}
		} catch (StorageException ex) {
			log.error("Error accessing data '{}' in storage: ", oid, ex);
			return null;
		}
	}
1016546
def _parse_properties(response, result_class):
    '''
    
    '''

    if response is None or response.headers is None:
        return None

    props = result_class()
    for key, value in response.headers:
        info = GET_PROPERTIES_ATTRIBUTE_MAP.get(key)
        if info:
            if info[0] is None:
                setattr(props, info[1], info[2](value))
            else:
                attr = getattr(props, info[0])
                setattr(attr, info[1], info[2](value))

    return props
169284
function entitiesToDatastore(entities, options) {
    const multiple = is.array(entities);
    entities = arrify(entities);

    if (entities[0].className !== 'Entity') {
        // Not an entity instance, nothing to do here...
        return entities;
    }

    const result = entities.map(e => toDatastore(e, options));

    return multiple ? result : result[0];
}
1022085
def to_api_data(self):
        
        data = {'@odata.type': self._gk(
            '{}_attachment_type'.format(self.attachment_type)),
            self._cc('name'): self.name}

        if self.attachment_type == 'file':
            data[self._cc('contentBytes')] = self.content
        else:
            data[self._cc('item')] = self.content

        return data
728161
function getReportHtml(oData) {
		return getResources().then(function () {
			var styles = [],
				scripts = [],
				html = '',
				i,
				template = {},
				reportContext = {};

			for (i = 0; i < arguments.length; i++) {
				switch (arguments[i].type) {
					case 'template': html = arguments[i].content; break;
					case 'css': styles.push(arguments[i].content); break;
					case 'js': scripts.push(arguments[i].content); break;
				}
			}

			template = Handlebars.compile(html);

			reportContext = {
				technicalInfo: oData.technical,
				issues: oData.issues,
				appInfo: oData.application,
				rules: oData.rules,
				rulePreset: oData.rulePreset,
				metadata: {
					title: oData.name + ' Analysis Results',
					title_TechnicalInfo: 'Technical Information',
					title_Issues: 'Issues',
					title_AppInfo: 'Application Information',
					title_SelectedRules: 'Available and (<span class="checked"></span>) Selected Rules',
					timestamp: new Date(),
					scope: oData.scope,
					analysisDuration: oData.analysisDuration,
					analysisDurationTitle: oData.analysisDurationTitle,
					styles: styles,
					scripts: scripts
				}
			};

			return template(reportContext);
		});
	}
762545
def parse(data, eventer):
    """"""
    parser = etree.XMLParser(target=ODMTargetParser(eventer))
    return etree.XML(data, parser)
489546
def element_to_objects(payload: Dict) -> List:
    
    entities = []
    cls = MAPPINGS.get(payload.get('type'))
    if not cls:
        return []

    transformed = transform_attributes(payload, cls)
    entity = cls(**transformed)

    if hasattr(entity, "post_receive"):
        entity.post_receive()

    entities.append(entity)

    return entities
926087
function _parse(loc, type, data, callback) {
  // explicit type
  if(type && type !== 'auto') {
    return _typedParse(loc, type, data, callback);
  }
  // typed via text-like extension
  if(loc && (endsWith(loc, '.txt'))) {
    return _typedParse(loc, 'text', data, callback);
  }
  // typed via JSON-like extension
  if(loc && (endsWith(loc, '.json') ||
    endsWith(loc, '.jsonld') ||
    endsWith(loc, '.json-ld'))) {
    return _typedParse(loc, 'json', data, callback);
  }
  // typed via HTML-like extension
  if(loc && (endsWith(loc, '.xml') ||
    endsWith(loc, '.html') ||
    endsWith(loc, '.xhtml'))) {
    return _typedParse(loc, 'html', data, callback);
  }
  // try ~JSON
  _typedParse(loc, 'application/ld+json', data, function(err, data) {
    if(err) {
      // try ~HTML
      return _typedParse(loc, 'text/html', data, function(err, data) {
        if(err) {
          return callback({
            message: 'Unable to auto-detect format.',
            url: loc
          });
        }
        callback(null, data);
      });
    }
    callback(null, data);
  });
}
1064826
function parseUnits(response) {
  let entities = {};
  Object.keys(response).forEach(key => {
    entities[key] = parseUnit(response[key]);
  });
  return entities;
}
1243795
def extract_objects_from_source(self, text, type_filter=None):
    '''
    '''
    objects = parse_vhdl(text)
    self._register_array_types(objects)

    if type_filter:
      objects = [o for o in objects if isinstance(o, type_filter)]

    return objects
749711
async def parseResults(self, api_data):
    
    results = []

    # parse page
    parser = lxml.etree.HTMLParser()
    html = lxml.etree.XML(api_data.decode("utf-8", "ignore"), parser)

    for page_struct_version, result_selector in enumerate(__class__.RESULTS_SELECTORS):
      result_nodes = result_selector(html)
      if result_nodes:
        break

    for rank, result_node in enumerate(result_nodes, 1):
      try:
        img_node = __class__.IMG_SELECTORS[page_struct_version](result_node)[0]
      except IndexError:
        # no image for that product
        continue
      # get thumbnail & full image url
      thumbnail_url = img_node.get("src")
      url_parts = thumbnail_url.rsplit(".", 2)
      img_url = ".".join((url_parts[0], url_parts[2]))
      # assume size is fixed
      size = (500, 500)
      check_metadata = CoverImageMetadata.SIZE
      # try to get higher res image...
      if ((self.target_size > size[0]) and  # ...only if needed
              (rank <= 3)):  # and only for first 3 results because this is time
                             # consuming (1 more GET request per result)
        product_url = __class__.PRODUCT_LINK_SELECTORS[page_struct_version](result_node)[0].get("href")
        product_url_split = urllib.parse.urlsplit(product_url)
        if not product_url_split.scheme:
          # relative redirect url
          product_url_query = urllib.parse.parse_qsl(product_url_split.query)
          product_url_query = collections.OrderedDict(product_url_query)
          try:
            # needed if page_struct_version == 1
            product_url = product_url_query["url"]
          except KeyError:
            # page_struct_version == 0, make url absolute
            product_url = urllib.parse.urljoin(self.base_url, product_url)
          product_url_split = urllib.parse.urlsplit(product_url)
        product_url_query = urllib.parse.parse_qsl(product_url_split.query)
        product_url_query = collections.OrderedDict(product_url_query)
        try:
          # remove timestamp from url to improve future cache hit rate
          del product_url_query["qid"]
        except KeyError:
          pass
        product_url_query = urllib.parse.urlencode(product_url_query)
        product_url_no_ts = urllib.parse.urlunsplit(product_url_split[:3] + (product_url_query,) + product_url_split[4:])
        store_in_cache_callback, product_page_data = await self.fetchResults(product_url_no_ts)
        product_page_html = lxml.etree.XML(product_page_data.decode("latin-1"), parser)
        try:
          img_node = __class__.PRODUCT_PAGE_IMG_SELECTOR(product_page_html)[0]
        except IndexError:
          # unable to get better image
          pass
        else:
          better_img_url = img_node.get("data-old-hires")
          # img_node.get("data-a-dynamic-image") contains json with image urls too, but they are not larger than
          # previous 500px image and are often covered by autorip badges (can be removed by cleaning url though)
          if better_img_url:
            img_url = better_img_url
            size_url_hint = img_url.rsplit(".", 2)[1].strip("_")
            assert(size_url_hint.startswith("SL"))
            size_url_hint = int(size_url_hint[2:])
            size = (size_url_hint, size_url_hint)
            check_metadata = CoverImageMetadata.NONE
          await store_in_cache_callback()

      # assume format is always jpg
      format = CoverImageFormat.JPEG
      # add result
      results.append(AmazonCdCoverSourceResult(img_url,
                                               size,
                                               format,
                                               thumbnail_url=thumbnail_url,
                                               source=self,
                                               rank=rank,
                                               check_metadata=check_metadata))

    return results
1012767
def _parse_properties(response, result_class):
    '''
    
    '''

    if response is None or response.headers is None:
        return None

    props = result_class()
    for key, value in response.headers.items():
        info = GET_PROPERTIES_ATTRIBUTE_MAP.get(key)
        if info:
            if info[0] is None:
                setattr(props, info[1], info[2](value))
            else:
                attr = getattr(props, info[0])
                setattr(attr, info[1], info[2](value))

    if hasattr(props, 'blob_type') and props.blob_type == 'PageBlob' and hasattr(props, 'blob_tier') and props.blob_tier is not None:
        props.blob_tier = _to_upper_str(props.blob_tier)
    return props
554019
function parse (buffer, doc, options, key) {
  switch (doc.type) {
    case 'text':
      return [...buffer, doc.content]
    case 'tag': {
      let children = reactify(doc.children, options, key)
      if (!children.length) {
        children = null
      }
      if (doc.name.startsWith(COMMENT_TAG)) {
        return [...buffer, ...children]
      }
      const tag = options.mappings[doc.name] || DEFAULT_TAG
      if (tag.fromMarkup) {
        doc.attrs = tag.fromMarkup(doc.attrs)
      }
      if (tag === DEFAULT_TAG && !doc.attrs.as) {
        doc.attrs.as = doc.name
      }
      if (doc.attrs.class) {
        // Rename class to className for React compatibility
        doc.attrs.className = doc.attrs.class
        delete doc.attrs.class
      }
      return [...buffer, createElement(tag, { key, ...doc.attrs }, children)]
    }
    default:
      return buffer
  }
}
620615
def _parse_odata_timestamp(in_date):
    
    timestamp = int(in_date.replace('/Date(', '').replace(')/', ''))
    seconds = timestamp // 1000
    ms = timestamp % 1000
    return datetime.utcfromtimestamp(seconds) + timedelta(milliseconds=ms)
1149275
function handleClassesAndId(str) {
	return str.replace(/(.*?)([\.|#].[^|]*)(.*)/, function (fullStr, tag, classAndIds, end) {
		if (classAndIds[0] === '|') {
			return fullStr;
		}
		const clsIdArr = classAndIds.split(/(\..[^\.|#]*)/).filter(Boolean);
		const returnArr = [];
		let i = clsIdArr.length;
		while (i--) {
			returnArr.push(`|${attrType[clsIdArr[i][0]]}=${clsIdArr[i].substr(1)}`);
		}

		return tag + returnArr.join('') + end;
	});
}