Parse a generated media object
    :param profile:
    :param page:
    :return:
964219
def get_profile_media(profile, page = 0):
    
    try:
        edges = profile['entry_data']['ProfilePage'][page]['graphql']['user']['edge_owner_to_timeline_media']['edges']
        return [edge['node'] for edge in edges]
    except KeyError:
        logging.exception("path to profile media not found")
1332561
def parse_path(path):
        
        import pymediainfo

        metadata = Metadata()
        log.debug('pymediainfo: parsing "{path}" ...'.format(path=path))
        parseRes = pymediainfo.MediaInfo.parse(str(path))
        log.debug('... parsing FINISHED')
        for track in parseRes.tracks:
            log.debug('... found track type: "{track_type}"'.format(track_type=track.track_type))
            if track.track_type == 'Video':
                duration_ms = track.duration
                framerate = track.frame_rate
                framecount = track.frame_count
                log.debug('mode={mode}'.format(mode=track.frame_rate_mode))
                if duration_ms is None or framerate is None:
                    log.debug('... Video track does not have duration and/or framerate.')
                    continue
                log.debug('... duration = {duration_ms} ms, framerate = {framerate} fps'.format(duration_ms=duration_ms,
                                                                                               framerate=framerate))
                metadata.add_metadata(
                    MetadataVideoTrack(
                        duration_ms=duration_ms,
                        framerate=float(framerate),
                        framecount=framecount
                    )
                )
        return metadata
183884
def get_page_objects_by_type(context, object_type):
    
    try:
        objects = context['page']['content'][object_type]
    except KeyError:
        raise template.TemplateSyntaxError('wrong content type: {0:>s}'.format(object_type))
    return objects
518495
def get_page_content(id):
    
    data = _json.loads(_api.rest("/" + str(id) + "?expand=body.storage"))
    return data["body"]["storage"]["value"]
1339453
def getMov(self, profile):
        
        # from . import mov
        import mov
        return mov.MoVScoring(profile, self.getScoringVector(profile))
996975
function(profiles) {
			profiles = utils.parseJSON(profiles);
			var snippets = {};
			Object.keys(profiles).forEach(function(syntax) {
				var options = profiles[syntax];
				if (!(syntax in snippets)) {
					snippets[syntax] = {};
				}
				snippets[syntax].profile = normalizeProfile(options);
			});

			this.loadSnippets(snippets);
		}
663348
def parseProfileLine(fp):
    '''
    
    '''
    nextLine = fp.readline()
    if nextLine == None or nextLine == '':
        return (None, None)
    else:
        pieces = nextLine.strip('\n').split(',')
        return (pieces[0], int(pieces[1]))
1164496
def get_page_object_by_name(context, name):
    
    selected_object = None

    try:
        for obj_type in context['page']['content']:
            for obj in context['page']['content'][obj_type]:
                if obj.name == name:
                    selected_object = obj
                    break
        if selected_object is None:
            for obj_type in context['page']['content']:
                for obj in context['page']['ext_content'][obj_type]:
                    if obj.name == name:
                        selected_object = obj
                        break
    except TypeError:
        pass
    return selected_object
194726
function Profile(options) {
  this.path = node_path.resolve(profile.resolveHomePath(options.path));
  this.schema = options.schema;
  this.context = options.context || null;
  this.raw_data = {};
  this.codec = this._get_codec(options.codec);

  this.options = options;
}
230701
def profile(func, stream=None):
    
    def wrapper(*args, **kwargs):
        prof = LineProfiler()
        val = prof(func)(*args, **kwargs)
        show_results(prof, stream=stream)
        return val
    return wrapper
778726
def load_media(self, max_pages=150):
        
        logger.info("loading media")

        # clear them all out so we don't get dupes
        if self.purge_first:
            logger.warning("purging ALL media from site %s", self.site_id)
            Media.objects.filter(site_id=self.site_id).delete()

        path = "sites/{}/media".format(self.site_id)
        params = {"number": 100}
        self.set_media_params_after(params)
        page = 1

        response = self.get(path, params)

        if not response.ok:
            logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)

        while response.ok and response.text and page < max_pages:
            logger.info(" - page: %d", page)

            api_medias = response.json().get("media")
            if not api_medias:
                # we're done here
                break

            medias = []
            for api_media in api_medias:

                # exclude media items that are not attached to posts (for now)
                if api_media["post_ID"] != 0:

                    # if it exists locally, update local version if anything has changed
                    existing_media = Media.objects.filter(site_id=self.site_id, wp_id=api_media["ID"]).first()
                    if existing_media:
                        self.update_existing_media(existing_media, api_media)
                    else:
                        medias.append(self.get_new_media(api_media))

            if medias:
                Media.objects.bulk_create(medias)

            # get next page
            page += 1
            params["page"] = page
            response = self.get(path, params)

            if not response.ok:
                logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)
                return
507160
def _parseAtMedia(self, src):
        
        ctxsrc = src
        src = src[len('@media '):].lstrip()
        mediums = []
        while src and src[0] != '{':
            medium, src = self._getIdent(src)
            if medium is None:
                raise self.ParseError('@media rule expected media identifier', src, ctxsrc)
            # make "and ... {" work
            if medium == 'and':
                # strip up to curly bracket
                pattern = re.compile('.*({.*)')
                match = re.match(pattern, src)
                src = src[match.end()-1:]
                break
            mediums.append(medium)
            if src[0] == ',':
                src = src[1:].lstrip()
            else:
                src = src.lstrip()

        if not src.startswith('{'):
            raise self.ParseError('Ruleset opening \'{\' not found', src, ctxsrc)
        src = src[1:].lstrip()

        stylesheetElements = []
        #while src and not src.startswith('}'):
        #    src, ruleset = self._parseRuleset(src)
        #    stylesheetElements.append(ruleset)
        #    src = src.lstrip()

        # Containing @ where not found and parsed
        while src and not src.startswith('}'):
            if src.startswith('@'):
                # @media, @page, @font-face
                src, atResults = self._parseAtKeyword(src)
                if atResults is not None:
                    stylesheetElements.extend(atResults)
            else:
                # ruleset
                src, ruleset = self._parseRuleset(src)
                stylesheetElements.append(ruleset)
            src = src.lstrip()

        if not src.startswith('}'):
            raise self.ParseError('Ruleset closing \'}\' not found', src, ctxsrc)
        else:
            src = src[1:].lstrip()

        result = self.cssBuilder.atMedia(mediums, stylesheetElements)
        return src, result
199068
def profile(request, username, template="accounts/account_profile.html",
            extra_context=None):
    
    lookup = {"username__iexact": username, "is_active": True}
    context = {"profile_user": get_object_or_404(User, **lookup)}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
1070161
def get_content_object(self, page, language, ctype):
        """"""
        params = {
            'language': language,
            'type': ctype,
            'page': None if page is fake_page else page
        }
        if page.freeze_date:
            params['creation_date__lte'] = page.freeze_date
        return self.filter(**params).latest()
258321
def load(self):
    
    media_page = self.session.session.get(u'http://myanimelist.net/' + self.__class__.__name__.lower() + u'/' + str(self.id)).text
    self.set(self.parse(utilities.get_clean_dom(media_page)))
    return self
136753
def profileFromPNG(inp):
    
    r = png.Reader(file=inp)
    _, chunk = r.chunk('iCCP')
    i = chunk.index(b'\x00')
    name = chunk[: i]
    compression = chunk[i + 1]
    assert compression == 0
    profile = zlib.decompress(chunk[i + 2:])
    return profile, name
1023634
def load(self):
    
    user_profile = self.session.session.get(u'http://myanimelist.net/profile/' + utilities.urlencode(self.username)).text
    self.set(self.parse(utilities.get_clean_dom(user_profile)))
    return self