prepare media regarding Mtt policy
496698
private function getMedia($timetable, $externalStopPointId = false)
    {
        $seasonCategory = $this->getSeasonCategory(
            $timetable->getLineConfig()->getSeason()->getPerimeter()->getExternalNetworkId(),
            $timetable->getExternalRouteId(),
            $timetable->getLineConfig()->getSeason()->getId(),
            $externalStopPointId
        );

        $media = new Media();
        $media->setCategory($seasonCategory);
        $media->setCompany($this->mediaDataCollector->getCompany());

        return $media;
    }
471643
function (media_hash_id, new_media_data, cb) {

            if (new_media_data) {
                new_media_data._method = 'PUT';
            }

            _util.buildQuery('medias/' + media_hash_id, new_media_data, function (error, data) {

                return cb(error, data);

            });

        }
1332004
protected void prepareMandArcDetection() {
		// RECYCLING ccTp is used to model the compressed path
		ISet nei;
		for (int i = 0; i < n; i++) {
			ccTp[i] = -1;
		}
		useful.clear();
		useful.set(0);
		int k = 1;
		useful.set(k);
		ccTp[k] = k;
		int first = 0;
		int last = first;
		fifo[last++] = k;
		while (first < last) {
			k = fifo[first++];
			nei = Tree.getNeighOf(k);
			for (int s : nei) {
				if (ccTp[s] == -1) {
					ccTp[s] = k;
					map[s][k] = map[k][s] = -1;
					if (!useful.get(s)) {
						fifo[last++] = s;
						useful.set(s);
					}
				}
			}
		}
	}
557373
def prepare(self):
        """"""
        SCons.Node.Node.prepare(self)

        if self.get_state() != SCons.Node.up_to_date:
            if self.exists():
                if self.is_derived() and not self.precious:
                    self._rmv_existing()
            else:
                try:
                    self._createDir()
                except SCons.Errors.StopError as drive:
                    raise SCons.Errors.StopError("No drive `{}' for target `{}'.".format(drive, self))
251740
def _prtfmt(self, item_id, dashes):
        """"""
        ntprt = self.id2nt[item_id]
        dct = ntprt._asdict()
        self.prt.write('{DASHES:{N}}'.format(
            DASHES=self.fmt_dashes.format(DASHES=dashes, ID=self.nm2prtfmt['ID'].format(**dct)),
            N=self.dash_len))
        self.prt.write("{INFO}\n".format(INFO=self.nm2prtfmt['ITEM'].format(**dct)))
678728
def make_stmt(stmt_cls, tf_agent, target_agent, pmid):
    """"""
    ev = Evidence(source_api='trrust', pmid=pmid)
    return stmt_cls(deepcopy(tf_agent), deepcopy(target_agent),
                    evidence=[ev])
971056
protected function prepareContent()
    {
        $html = $this->getHtmlContent();

        if (class_exists("\\DOMDocument")) {
            $doc = new \DOMDocument();
            $doc->loadHTML($html);
        } else {
            throw new \RuntimeException("Required extension 'dom' seems to be missing.");
        }

        // Extract styles and remove style tags (optionally added again later).
        //
        // IMPORTANT: The style nodes need to be saved in an array first, or
        //            the replacement won't work correctly.
        $styleString = "";
        $styleNodes = [];
        foreach($doc->getElementsByTagName('style') as $styleNode) {
            $styleNodes[] = $styleNode;
        }
        foreach($styleNodes as $styleNode) {
            $skip = false;

            // Check if type is 'text/css' (defaults to it if not)
            $typeAttribute = $styleNode->attributes->getNamedItem("type");
            if ($typeAttribute !== null && (string)$typeAttribute->nodeValue !== "text/css") {
                $skip = true;
            }

            // Check media type is allowed (defaults to 'all')
            if ($skip === false) {
                $mediaAttribute = $styleNode->attributes->getNamedItem("media");
                if ($mediaAttribute !== null) {
                    $mediaAttribute = str_replace(" ", "", (string)$mediaAttribute->nodeValue);
                    $mediaTypes = explode(",", $mediaAttribute);
                    if (!in_array("all", $mediaTypes) && !in_array("screen", $mediaTypes)) {
                        $skip = true;
                    }
                }
            }

            // Add CSS if allowed
            if ($skip === false) {
                $styleString .= $styleNode->nodeValue . "\r\n";
            }

            $styleNode->parentNode->removeChild($styleNode);
        }

        // Prepare some variables
        $xpath = new \DOMXpath($doc);
        $reader = new CssString($styleString);
        $reader->setEnvironmentEncoding($this->getCharset());
        $rules = $reader->getStyleSheet()->getRules();

        // Set pseudo classes that can be set in a style attribute
        // and that are supported by the Symfony CssSelector (doesn't support CSS4 yet).
        $allowedPseudoClasses = [
            StyleSelector::PSEUDO_CLASS_FIRST_CHILD,
            StyleSelector::PSEUDO_CLASS_ROOT,
            StyleSelector::PSEUDO_CLASS_NTH_CHILD,
            StyleSelector::PSEUDO_CLASS_NTH_LAST_CHILD,
            StyleSelector::PSEUDO_CLASS_NTH_OF_TYPE,
            StyleSelector::PSEUDO_CLASS_NTH_LAST_OF_TYPE,
            StyleSelector::PSEUDO_CLASS_LAST_CHILD,
            StyleSelector::PSEUDO_CLASS_FIRST_OF_TYPE,
            StyleSelector::PSEUDO_CLASS_LAST_OF_TYPE,
            StyleSelector::PSEUDO_CLASS_ONLY_CHILD,
            StyleSelector::PSEUDO_CLASS_ONLY_OF_TYPE,
            StyleSelector::PSEUDO_CLASS_EMPTY,
            StyleSelector::PSEUDO_CLASS_NOT,
        ];

        // Extract all relevant style declarations
        $selectors = [];
        foreach ($this->getRelevantStyleRules($rules) as $styleRule) {
            foreach ($styleRule->getSelectors() as $selector) {
                // Check if the selector contains pseudo classes/elements that cannot
                // be mapped to elements
                $skip = false;
                foreach($selector->getPseudoClasses() as $pseudoClass) {
                    if (!in_array($pseudoClass, $allowedPseudoClasses)) {
                        $skip = true;
                        break;
                    }
                }
                if ($skip === false) {
                    $specificity = $selector->getSpecificity();
                    if (!isset($selectors[$specificity])) {
                        $selectors[$specificity] = [];
                    }
                    $selectorString = $selector->getValue();
                    if (!isset($selectors[$specificity][$selectorString])) {
                        $selectors[$specificity][$selectorString] = [];
                    }
                    foreach ($styleRule->getDeclarations() as $declaration) {
                        $selectors[$specificity][$selectorString][] = $declaration;
                    }
                }
            }
        }

        // Get all specificity values (to process the declarations in the correct order,
        // without sorting the array by key, which perhaps could result in a changed
        // order of selectors within the specificity).
        $specificityKeys = array_keys($selectors);
        sort($specificityKeys);

        // Temporary remove all existing style attributes, because they always have the highest priority
        // and are added again after all styles have been applied to the elements
        $elements = $xpath->query("descendant-or-self::*[@style]");
        /** @var \DOMElement $element */
        foreach ($elements as $element) {
            if ($element->attributes !== null) {
                $styleAttribute = $element->attributes->getNamedItem("style");

                $styleValue = "";
                if ($styleAttribute !== null) {
                    $styleValue = (string)$styleAttribute->nodeValue;
                }

                if ($styleValue !== "") {
                    $element->setAttribute('data-pre-mailer-original-style', $styleValue);
                    $element->removeAttribute('style');
                }
            }
        }

        // Process all style declarations in the correct order
        foreach ($specificityKeys as $specificityKey) {
            /** @var StyleDeclaration[] $declarations */
            foreach ($selectors[$specificityKey] as $selectorString => $declarations) {
                $xpathQuery = CssSelector::toXPath($selectorString);
                $elements = $xpath->query($xpathQuery);
                /** @var \DOMElement $element */
                foreach ($elements as $element) {
                    if ($element->attributes !== null) {
                        $styleAttribute = $element->attributes->getNamedItem("style");

                        $styleValue = "";
                        if ($styleAttribute !== null) {
                            $styleValue = (string)$styleAttribute->nodeValue;
                        }

                        $concat = ($styleValue === "") ? "" : ";";
                        foreach ($declarations as $declaration) {
                            $styleValue .= $concat . $declaration->getProperty() . ":" . $declaration->getValue();
                            $concat = ";";
                        }

                        $element->setAttribute('style', $styleValue);
                    }
                }
            }
        }

        // Add temporarily removed style attributes again, after all styles have been applied to the elements
        $elements = $xpath->query("descendant-or-self::*[@data-pre-mailer-original-style]");
        /** @var \DOMElement $element */
        foreach ($elements as $element) {
            if ($element->attributes !== null) {
                $styleAttribute = $element->attributes->getNamedItem("style");
                $styleValue = "";
                if ($styleAttribute !== null) {
                    $styleValue = (string)$styleAttribute->nodeValue;
                }

                $originalStyleAttribute = $element->attributes->getNamedItem("data-pre-mailer-original-style");
                $originalStyleValue = "";
                if ($originalStyleAttribute !== null) {
                    $originalStyleValue = (string)$originalStyleAttribute->nodeValue;
                }

                if ($styleValue !== "" || $originalStyleValue !== "") {
                    $styleValue = ($styleValue !== "" ? $styleValue . ";" : "") . $originalStyleValue;
                    $element->setAttribute('style', $styleValue);
                    $element->removeAttribute('data-pre-mailer-original-style');
                }
            }
        }

        // Optionally remove class attributes in HTML tags
        $optionHtmlClasses = $this->getOption(self::OPTION_HTML_CLASSES);
        if ($optionHtmlClasses === self::OPTION_HTML_CLASSES_REMOVE) {
            $nodesWithClass = [];
            foreach ($xpath->query('descendant-or-self::*[@class]') as $nodeWithClass) {
                $nodesWithClass[] = $nodeWithClass;
            }
            /** @var \DOMElement $nodeWithClass */
            foreach ($nodesWithClass as $nodeWithClass) {
                $nodeWithClass->removeAttribute('class');
            }
        }

        // Optionally remove HTML comments
        $optionHtmlComments = $this->getOption(self::OPTION_HTML_COMMENTS);
        if ($optionHtmlComments === self::OPTION_HTML_COMMENTS_REMOVE) {
            $commentNodes = [];
            foreach ($xpath->query('//comment()') as $comment) {
                $commentNodes[] = $comment;
            }
            foreach ($commentNodes as $commentNode) {
                $commentNode->parentNode->removeChild($commentNode);
            }
        }

        // Write XPath document back to DOM document
        $newDoc = $xpath->document;

        // Generate text version (before adding the styles again)
        $this->text = $this->prepareText($newDoc);

        // Optionally add styles tag to the HEAD or the BODY of the document
        $optionStyleTag = $this->getOption(self::OPTION_STYLE_TAG);
        if ($optionStyleTag === self::OPTION_STYLE_TAG_BODY || $optionStyleTag === self::OPTION_STYLE_TAG_HEAD) {
            $cssWriterClass = $this->getOption(self::OPTION_CSS_WRITER_CLASS);
            /** @var WriterAbstract $cssWriter */
            $cssWriter = new $cssWriterClass($reader->getStyleSheet());
            $styleNode = $newDoc->createElement("style");
            $styleNode->nodeValue = $cssWriter->getContent();

            if ($optionStyleTag === self::OPTION_STYLE_TAG_BODY) {
                /** @var \DOMNode $bodyNode */
                foreach($newDoc->getElementsByTagName('body') as $bodyNode) {
                    $bodyNode->insertBefore($styleNode, $bodyNode->firstChild);
                    break;
                }
            } elseif ($optionStyleTag === self::OPTION_STYLE_TAG_HEAD) {
                /** @var \DOMNode $headNode */
                foreach($newDoc->getElementsByTagName('head') as $headNode) {
                    $headNode->appendChild($styleNode);
                    break;
                }
            }
        }

        // Generate HTML version
        $this->html = $newDoc->saveHTML();
    }
776306
def prepare(self):
        """"""
        self.target = self.fn
        self.targetheader = reader.get_tsv_header(self.target)
        self.decoyheader = reader.get_tsv_header(self.decoyfn)
942968
function(media) {
      if (options.use_external) {
        media.forEach(function(item) {
          strMediaStyles += processMedia(item);
        });
      } else {
        media.forEach(function(item) {
          strStyles += processMedia(item);
        });
      }

    }
265338
private void handleMediaContent(String tag, Article article) {
		String url = xmlParser.getAttributeValue(null, "url");
		if(url == null) {
			throw new IllegalArgumentException("Url argument must not be null");
		}

		Article.MediaContent mc = new Article.MediaContent();
		article.addMediaContent(mc);
		mc.setUrl(url);

		if(xmlParser.getAttributeValue(null, "type") != null) {
			mc.setType(xmlParser.getAttributeValue(null, "type"));
		}

		if(xmlParser.getAttributeValue(null, "fileSize") != null) {
			mc.setFileSize(Integer.parseInt(xmlParser.getAttributeValue(null, "fileSize")));
		}


		if(xmlParser.getAttributeValue(null, "medium") != null) {
			mc.setMedium(xmlParser.getAttributeValue(null, "medium"));
		}

		if(xmlParser.getAttributeValue(null, "isDefault") != null) {
			mc.setIsDefault(Boolean.parseBoolean(xmlParser.getAttributeValue(null, "isDefault")));
		}

		if(xmlParser.getAttributeValue(null, "expression") != null) {
			mc.setExpression(xmlParser.getAttributeValue(null, "expression"));
		}

		if(xmlParser.getAttributeValue(null, "bitrate") != null) {
			mc.setBitrate(Integer.parseInt(xmlParser.getAttributeValue(null, "bitrate")));
		}

		if(xmlParser.getAttributeValue(null, "framerate") != null) {
			mc.setFramerate(Integer.parseInt(xmlParser.getAttributeValue(null, "framerate")));
		}

		if(xmlParser.getAttributeValue(null, "samplingrate") != null) {
			mc.setSamplingrate(Integer.parseInt(xmlParser.getAttributeValue(null, "samplingrate")));
		}

		if(xmlParser.getAttributeValue(null, "channels") != null) {
			mc.setChannels(Integer.parseInt(xmlParser.getAttributeValue(null, "channels")));
		}

		if(xmlParser.getAttributeValue(null, "duration") != null) {
			mc.setDuration(Integer.parseInt(xmlParser.getAttributeValue(null, "duration")));
		}

		if(xmlParser.getAttributeValue(null, "height") != null) {
			mc.setHeight(Integer.parseInt(xmlParser.getAttributeValue(null, "height")));
		}

		if(xmlParser.getAttributeValue(null, "width") != null) {
			mc.setWidth(Integer.parseInt(xmlParser.getAttributeValue(null, "width")));
		}

		if(xmlParser.getAttributeValue(null, "lang") != null) {
			mc.setLang(xmlParser.getAttributeValue(null, "lang"));
		}
	}
889744
public static function printMainMedia(Fact $fact, $level): void
    {
        $factrec = $fact->gedcom();
        $parent  = $fact->record();
        $tree    = $parent->tree();

        if ($fact->isPendingAddition()) {
            $styleadd = 'wt-new';
            $can_edit = $level == 1 && $fact->canEdit();
        } elseif ($fact->isPendingDeletion()) {
            $styleadd = 'wt-old';
            $can_edit = false;
        } else {
            $styleadd = '';
            $can_edit = $level == 1 && $fact->canEdit();
        }

        // -- find source for each fact
        preg_match_all('/(?:^|\n)' . $level . ' OBJE @(.*)@/', $factrec, $matches);
        foreach ($matches[1] as $xref) {
            $media = Media::getInstance($xref, $tree);
            // Allow access to "1 OBJE @non_existent_source@", so it can be corrected/deleted
            if (!$media || $media->canShow()) {
                echo '<tr>';
                echo '<th scope="row" class="';
                if ($level > 1) {
                    echo 'rela ';
                }
                echo $styleadd, '">';
                preg_match("/^\d (\w*)/", $factrec, $factname);
                $factlines = explode("\n", $factrec); // 1 BIRT Y\n2 SOUR ...
                $factwords = explode(' ', $factlines[0]); // 1 BIRT Y
                $factname  = $factwords[1]; // BIRT
                if ($factname === 'EVEN' || $factname === 'FACT') {
                    // Add ' EVEN' to provide sensible output for an event with an empty TYPE record
                    $ct = preg_match('/2 TYPE (.*)/', $factrec, $ematch);
                    if ($ct > 0) {
                        $factname = $ematch[1];
                        echo $factname;
                    } else {
                        echo GedcomTag::getLabel($factname, $parent);
                    }
                } elseif ($can_edit) {
                    echo GedcomTag::getLabel($factname, $parent);
                    echo '<div class="editfacts">';
                    echo view('edit/icon-fact-copy', ['fact' => $fact]);
                    echo view('edit/icon-fact-delete', ['fact' => $fact]);
                    echo '</div>';
                } else {
                    echo GedcomTag::getLabel($factname, $parent);
                }
                echo '</th>';
                echo '<td class="', $styleadd, '">';
                if ($media) {
                    echo '<span class="field">';
                    foreach ($media->mediaFiles() as $media_file) {
                        echo $media_file->displayImage(100, 100, 'contain', []);
                    }
                    echo '<a href="' . e($media->url()) . '"> ';
                    echo '<em>';
                    foreach ($media->getAllNames() as $name) {
                        if ($name['type'] !== 'TITL') {
                            echo '<br>';
                        }
                        echo $name['full'];
                    }
                    echo '</em>';
                    echo '</a>';
                    echo '</span>';

                    echo FunctionsPrint::printFactNotes($tree, $media->gedcom(), 1);
                    echo self::printFactSources($tree, $media->gedcom(), 1);
                } else {
                    echo $xref;
                }
                echo '</td></tr>';
            }
        }
    }
576730
def attach(self, media: typing.Union[InputMedia, typing.Dict]):
        
        if isinstance(media, dict):
            if 'type' not in media:
                raise ValueError(f"Invalid media!")

            media_type = media['type']
            if media_type == 'photo':
                media = InputMediaPhoto(**media)
            elif media_type == 'video':
                media = InputMediaVideo(**media)
            # elif media_type == 'document':
            #     media = InputMediaDocument(**media)
            # elif media_type == 'audio':
            #     media = InputMediaAudio(**media)
            # elif media_type == 'animation':
            #     media = InputMediaAnimation(**media)
            else:
                raise TypeError(f"Invalid media type '{media_type}'!")

        elif not isinstance(media, InputMedia):
            raise TypeError(f"Media must be an instance of InputMedia or dict, not {type(media).__name__}")

        elif media.type in ['document', 'audio', 'animation']:
            raise ValueError(f"This type of media is not supported by media groups!")

        self.media.append(media)
780052
private void emitEndTag() throws TTIOException {
        final long nodeKey = mRtx.getNode().getDataKey();
        mEvent = mFac.createEndElement(mRtx.getQNameOfCurrentNode(), new NamespaceIterator(mRtx));
        mRtx.moveTo(nodeKey);
    }
1058164
public void if_tcmpgt(TypeMirror type, String target) throws IOException
    {
        pushType(type);
        if_tcmpgt(target);
        popType();
    }
1023786
def apply(self, model):
        """"""
        model.medium = {row.exchange: row.uptake
                        for row in self.data.itertuples(index=False)}
324825
def _acquire_media_transport(self, path, access_type):
        
        transport = BTMediaTransport(path=path)
        (fd, read_mtu, write_mtu) = transport.acquire(access_type)
        self.fd = fd.take()   # We must do the clean-up later
        self.write_mtu = write_mtu
        self.read_mtu = read_mtu
        self.access_type = access_type
        self.path = path
        self._install_transport_ready()
839887
public void setTargetedContentMetadata(com.google.api.ads.admanager.axis.v201811.ContentMetadataKeyHierarchyTargeting[] targetedContentMetadata) {
        this.targetedContentMetadata = targetedContentMetadata;
    }