to be removed when the minimum required version of Twig is >= 3.0
324798
protected function templateExists($template)
    {
        $template = (string) $template;

        $loader = $this->twig->getLoader();
        if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) {
            return $loader->exists($template);
        }

        try {
            $loader->getSourceContext($template)->getCode();

            return true;
        } catch (LoaderError $e) {
        }

        return false;
    }
1292535
function skip() {
    rimraf(file, function() {})
    delete f.versions[v]
    if (f._attachments)
      delete f._attachments[file]
    need.splice(need.indexOf(v), 1)
    maybeDone(null)
  }
1003373
function getMinimumIeVersionUsage(asset, stack = []) {
      if (asset.type === 'Html') {
        return 1;
      }
      if (minimumIeVersionByAsset.has(asset)) {
        return minimumIeVersionByAsset.get(asset);
      }
      stack.push(asset);
      const minimumIeVersion = Math.min(
        ...asset.incomingRelations
          .filter(incomingRelation => !stack.includes(incomingRelation.from))
          .map(incomingRelation => {
            let matchCondition;
            if (incomingRelation.type === 'HtmlConditionalComment') {
              matchCondition = incomingRelation.condition.match(
                /^(gte?|lte?)\s+IE\s+(\d+)$/i
              );
            } else if (
              incomingRelation.conditionalComments &&
              incomingRelation.conditionalComments.length > 0
            ) {
              matchCondition = incomingRelation.conditionalComments[0].nodeValue.match(
                /^\[if\s+(gte?|lte?)\s+IE\s+(\d+)\s*\]\s*>\s*<\s*!\s*$/i
              );
            }
            if (matchCondition) {
              if (matchCondition[1].substr(0, 2) === 'lt') {
                return 1;
              } else {
                return (
                  parseInt(matchCondition[2], 10) +
                  (matchCondition[1].toLowerCase() === 'gt' ? 1 : 0)
                );
              }
            } else {
              return getMinimumIeVersionUsage(incomingRelation.from, stack);
            }
          })
      );
      minimumIeVersionByAsset.set(asset, minimumIeVersion);
      return minimumIeVersion;
    }
364830
private String addVersionQualifierToQualifiers(String qualifiers) {
        int versionQualifierApiLevel = ResBundle.getVersionQualifierApiLevel(qualifiers);
        if (versionQualifierApiLevel == -1) {
            if (qualifiers.length() > 0) {
                qualifiers += "-";
            }
            qualifiers += "v" + sdkConfig.getApiLevel();
        }
        return qualifiers;
    }
361516
public static function clearCompiledTemplates()
    {
        $twig = StaticContainer::get(Twig::class);
        $environment = $twig->getTwigEnvironment();
        $environment->clearTemplateCache();

        $cacheDirectory = $environment->getCache();
        if (!empty($cacheDirectory)
            && is_dir($cacheDirectory)
        ) {
            $environment->clearCacheFiles();
        }
    }
333949
function _stripOldVersionInfo(versionInfo, buildNumber) {
        // Do a simple linear search. Since we are going in reverse-chronological order, we
        // should get through the search quickly.
        var lastIndex = 0;
        var len = versionInfo.length;
        var versionEntry;
        var validBuildEntries;

        while (lastIndex < len) {
            versionEntry = versionInfo[lastIndex];
            if (versionEntry.buildNumber <= buildNumber) {
                break;
            }
            lastIndex++;
        }

        if (lastIndex > 0) {
            // Filter recent update entries based on applicability to current platform
            validBuildEntries = versionInfo.slice(0, lastIndex).filter(_checkBuildApplicability);
        }

        return validBuildEntries;
    }
35172
function remove( $removeAttributes = false, $version = eZContentClass::VERSION_STATUS_DEFINED )
    {
        // If we are not allowed to remove just return false
        if ( $this->Version == eZContentClass::VERSION_STATUS_DEFINED && !$this->isRemovable() )
            return false;

        if ( is_array( $removeAttributes ) or $removeAttributes )
            $this->removeAttributes( $removeAttributes );

        $this->NameList->remove( $this );
        parent::remove();
    }
951799
public function Upgrade182to183()
    {
        $this->_batch->addTask('Db_CreateNewTables');
        $this->_batch->addTask('Db_AddPatches', 61);

        // Use AddTask task to execute after patches
        $this->_batch->addTask('AddTask', 'Echo', $this->_('Make sure to read the changelog as it contains important instructions'));
        $this->_batch->addTask('AddTask', 'Echo', $this->_('Check the Code compatibility report for any issues with project specific code!'));

        return true;
    }
1331127
private void enforceVersionSupported()
    {
        if ( _versionSupported != null )
        {
            int majorSupported = _versionSupported.major();
            int minorSupported = _versionSupported.minor();

            if ( majorSupported < 0 )    // no real version support requirement
                return;

            AptControlInterface ci = getControlInterface();
            if ( ci == null )
                return;

            int majorPresent = -1;
            int minorPresent = -1;
            Version ciVersion = ci.getVersion();
            if ( ciVersion != null )
            {
                majorPresent = ciVersion.major();
                minorPresent = ciVersion.minor();

                if ( majorSupported >= majorPresent &&
                     (minorSupported < 0 || minorSupported >= minorPresent) )
                {
                    // Version requirement is satisfied
                    return;
                }
            }

            //
            // Version requirement failed
            //

            _ap.printError( _implDecl, "versionsupported.failed", _implDecl.getSimpleName(), majorSupported, minorSupported,
                            majorPresent, minorPresent );
        }
    }
719715
function compareVersions(v1, v2) {
    if (semver.gt(v1.tag, v2.tag)) {
        return -1;
    }
    if (semver.lt(v1.tag, v2.tag)) {
        return 1;
    }
    return 0;
}
1094484
private void enforceVersionRequired()
    {
        if ( _versionRequired != null )
        {
            if ( !isExtension() )
            {
                _ap.printError( _intfDecl, "versionrequired.illegal.usage" );
                return;
            }

            int majorRequired = _versionRequired.major();
            int minorRequired = _versionRequired.minor();

            if ( majorRequired < 0 )    // no real version requirement
                return;

            AptControlInterface ci = getMostDerivedInterface();
            if ( ci == null )
                return;

            int majorPresent = -1;
            int minorPresent = -1;
            Version ciVersion = ci._version;
            if ( ciVersion != null )
            {
                majorPresent = ciVersion.major();
                minorPresent = ciVersion.minor();

                if ( majorRequired <= majorPresent &&
                     (minorRequired < 0 || minorRequired <= minorPresent) )
                {
                    // Version requirement is satisfied
                    return;
                }
            }

            //
            // Version requirement failed
            //
            _ap.printError( _intfDecl, "versionrequired.failed", _intfDecl.getSimpleName(),
                    majorRequired, minorRequired, majorPresent, minorPresent );
        }
    }
309887
private function purgeOldVersions()
    {
        $keep = isset($this->keepOldVersions) ? $this->keepOldVersions : 0;
        $count = $this->versions()->count();

        if ((int)$keep > 0 && $count > $keep) {
            $oldVersions = $this->versions()
                ->latest()
                ->take($count)
                ->skip($keep)
                ->get()
                ->each(function ($version) {
                $version->delete();
            });
        }
    }
186720
def validate_version(err, value, source):
    ''


    field_name = '<em:version>' if source == 'install.rdf' else 'version'

    err.metadata['version'] = value

    # May not be longer than 32 characters
    if len(value) > 32:
        err.error(
            ('metadata_helpers', '_test_version', 'too_long'),
            'The value of {name} is too long'.format(name=field_name),
            'Values supplied for {name} in the {source} file must be 32 '
            'characters or less.'.format(name=field_name, source=source),
            source)

    # Must be a valid version number.
    if not VERSION_PATTERN.match(value):
        err.error(
            ('metadata_helpers', '_test_version', 'invalid_format'),
            'The value of {name} is invalid'.format(name=field_name),
            'The values supplied for version in the {source} file is not a '
            'valid version string. It can only contain letters, numbers, and '
            'the symbols +*.-_.'.format(name=field_name, source=source),
            source)
1176447
def can_be_updated(cls, dist, latest_version):
        """"""
        scheme = get_scheme('default')
        name = dist.project_name
        dependants = cls.get_dependants(name)
        for dependant in dependants:
            requires = dependant.requires()
            for requirement in cls.get_requirement(name, requires):
                req = parse_requirement(requirement)
                # Ignore error if version in requirement spec can't be parsed
                try:
                    matcher = scheme.matcher(req.requirement)
                except UnsupportedVersionError:
                    continue
                if not matcher.match(str(latest_version)):
                    return False

        return True
993699
public function isGitMinimumVersionSatisfied($minimum_version) {
    exec("git --version | cut -d' ' -f3", $output, $exit_code);
    if (version_compare($output[0], $minimum_version, '>=')) {
      return TRUE;
    }
    return FALSE;
  }
780071
protected function createTwigLintCommand() {
    $twig = new Environment(new FilesystemLoader());

    $repo_root = $this->getConfigValue('repo.root');
    $extension_file_contents = file_get_contents($repo_root . '/docroot/core/lib/Drupal/Core/Template/TwigExtension.php');

    // Get any custom defined Twig filters to be ignored by linter.
    $twig_filters = (array) $this->getConfigValue('validate.twig.filters');

    // Add Twig filters from Drupal TwigExtension to be ignored.
    $drupal_filters = [];
    if ($matches_count = preg_match_all("#new \\\\Twig_SimpleFilter\('([^']+)',#", $extension_file_contents, $matches)) {
      $drupal_filters = $matches[1];
    }
    $twig_filters = array_merge($twig_filters, $drupal_filters);
    foreach ($twig_filters as $filter) {
      // Add two default arguments and set to variadic so that filters with
      // named arguments will be whitelisted.
      // @see \TwigNode_Expression_Call::getArguments
      // @see \TwigNode_Expression_Call::call()
      $twig->addFilter(new \Twig_SimpleFilter($filter, function ($node = '', array $args = []) {}, [
        'is_variadic' => TRUE,
      ]));
    }

    // Get any custom defined Twig functions to be ignored by linter.
    $twig_functions = (array) $this->getConfigValue('validate.twig.functions');

    // Add Twig functions from Drupal TwigExtension to be ignored.
    $drupal_functions = [];
    if ($matches_count = preg_match_all("#new \\\\Twig_SimpleFunction\('([^']+)',#", $extension_file_contents, $matches)) {
      $drupal_functions = $matches[1];
    }
    $twig_functions = array_merge($twig_functions, $drupal_functions);
    foreach ($twig_functions as $function) {
      // Add default argument and set to variadic so that functions with named
      // arguments will be whitelisted.
      // @see \TwigNode_Expression_Call::getArguments
      // @see \TwigNode_Expression_Call::call()
      $twig->addFunction(new \Twig_SimpleFunction($function, function (array $args = []) {}, [
        'is_variadic' => TRUE,
      ]));
    }

    // Add Drupal Twig parser to include trans tag.
    $token_parser_filename = $repo_root . '/docroot/core/lib/Drupal/Core/Template/TwigTransTokenParser.php';
    if (file_exists($token_parser_filename)) {
      require_once $token_parser_filename;
      $twig->addTokenParser(new TwigTransTokenParser());
    }

    $command = new TwigLintCommand();
    $command->setTwigEnvironment($twig);

    return $command;
  }
1112923
def freeze(plugins_directory):
    '''
    
    '''
    # Check existing version (if any).
    package_versions = []
    for plugin_path_i in plugins_directory.dirs():
        try:
            plugin_metadata = yaml.load(plugin_path_i
                                        .joinpath('properties.yml').bytes())
            if plugin_path_i.name != plugin_metadata['package_name']:
                continue
            package_versions.append((plugin_metadata['package_name'],
                                     plugin_metadata['version']))
        except:
            continue
    return ['%s==%s' % v for v in package_versions]