text:
import sys
import unittest

import requests

if sys.version_info >= (3, 0):
    from unittest.mock import MagicMock, patch
else:
    from mock import patch, MagicMock

from shellfoundry.exceptions import NoVersionsHaveBeenFoundException
from shellfoundry.utilities.template_versions import TemplateVersions

def mock_get_branches_from_github(is_empty_response=False):
    if is_empty_response:
        response_content = "[]"
    else:
        response_content = """[
      {
        "name": "5.0.0",
        "commit": {
          "sha": "efe253280a3346c2be23b1a9af4113f2b989f26c",
          "url": "https://api.github.com/repos/user/repo/commits/efe253280a3346c2be23b1a9af4113f2b989f26c"
        }
      },
      {
        "name": "5.0.1",
        "commit": {
          "sha": "e67ec4de2f00fabfe7be35fe412ec400847ccc7d",
          "url": "https://api.github.com/repos/user/repo/commits/e67ec4de2f00fabfe7be35fe412ec400847ccc7d"
        }
      },
      {
        "name": "5.0.2",
        "commit": {
          "sha": "421c20b231b11672411f39f813c93d0f82723f3a",
          "url": "https://api.github.com/repos/user/repo/commits/421c20b231b11672411f39f813c93d0f82723f3a"
        }
      },
      {
        "name": "master",
        "commit": {
          "sha": "b8687aef6a15a4fd9c6daa6b7549470e9e3c4c11",
          "url": "https://api.github.com/repos/user/repo/commits/b8687aef6a15a4fd9c6daa6b7549470e9e3c4c11"
        }
      }
    ]
    """  # noqa E501
    response = requests.models.Response()
    response.status_code = 200
    response._content = str.encode(response_content)
    return response

class TestTemplateVersions(unittest.TestCase):
    def setUp(self):
        self.template_version = TemplateVersions("user", "repo")

    @patch(
        "shellfoundry.utilities.template_versions.requests.get",
        MagicMock(side_effect=requests.HTTPError("Failed to receive versions")),
    )
    def test_get_versions_of_template_error_due_to_request_failed(self):
        with self.assertRaises(requests.HTTPError) as context:
            self.template_version.get_versions_of_template()

        # Assert
        self.assertEqual(str(context.exception), "Failed to receive versions")

    @patch(
        "shellfoundry.utilities.template_versions.requests.get",
        MagicMock(return_value=mock_get_branches_from_github(is_empty_response=True)),
    )
    def test_get_versions_of_template_and_has_no_versions_failure(self):
        with self.assertRaises(NoVersionsHaveBeenFoundException) as context:
            self.template_version.get_versions_of_template()

            # Assert
            self.assertEqual(
                str(context.exception), "No versions have been found for this template"
            )

    @patch(
        "shellfoundry.utilities.template_versions.requests.get",
        MagicMock(return_value=mock_get_branches_from_github()),
    )
    def test_get_versions_of_template_reversed_success(self):
        # Act
        versions = self.template_version.get_versions_of_template()

        # Assert
        self.assertSequenceEqual(versions, ["5.0.2", "5.0.1", "5.0.0", "master"])


text:
using System.Collections.Generic;
using Mono.Cecil;
using SystemCF.Reflection;
using SystemCF.Reflection.Emit;

namespace SystemCF.Reflection
{
	/// <summary>
	/// Describes the constraints on a generic type parameter of a generic type or method.
	/// </summary>
	[System.Flags]
	public enum GenericParameterAttributes
	{
		/// <summary>
		/// A type can be substituted for the generic type parameter only if it has a parameterless constructor.
		/// </summary>
		None = 0,
		/// <summary>
		/// The generic type parameter is covariant. A covariant type parameter can appear as the result type of a method, the type of a read-only field, a declared base type, or an implemented interface.
		/// </summary>
		Covariant = 1,
		/// <summary>
		/// The generic type parameter is contravariant. A contravariant type parameter can appear as a parameter type in method signatures.
		/// </summary>
		Contravariant = 2,
		/// <summary>
		/// Selects the combination of all variance flags. This value is the result of using logical OR to combine the following flags: <see cref="Contravariant"/> and <see cref="Covariant"/>.
		/// </summary>
		VarianceMask = 3,
		/// <summary>
		/// A type can be substituted for the generic type parameter only if it is a reference type.
		/// </summary>
		ReferenceTypeConstraint = 4,
		/// <summary>
		/// A type can be substituted for the generic type parameter only if it is a value type and is not nullable.
		/// </summary>
		NotNullableValueTypeConstraint = 8,
		/// <summary>
		/// A type can be substituted for the generic type parameter only if it has a parameterless constructor.
		/// </summary>
		DefaultConstructorConstraint = 0x10,
		/// <summary>
		/// Selects the combination of all special constraint flags. This value is the result of using logical OR to combine the following flags: <see cref="DefaultConstructorConstraint"/>, <see cref="ReferenceTypeConstraint"/>, and <see cref="NotNullableValueTypeConstraint"/>.
		/// </summary>
		SpecialConstraintMask = 0x1c,
	}

	internal class GenericParameterAttributesConverter
	{
		static bool Match(Mono.Cecil.GenericParameterAttributes value, Mono.Cecil.GenericParameterAttributes @enum) { return (value & @enum) == @enum; }
		static bool Match(GenericParameterAttributes value, GenericParameterAttributes @enum) { return (value & @enum) == @enum; }

		public static GenericParameterAttributes Convert(Mono.Cecil.GenericParameterAttributes peAttrs)
		{
			GenericParameterAttributes attrs = (GenericParameterAttributes)0;
			if (Match(peAttrs, Mono.Cecil.GenericParameterAttributes.Contravariant)) attrs |= GenericParameterAttributes.Contravariant;
			if (Match(peAttrs, Mono.Cecil.GenericParameterAttributes.Covariant)) attrs |= GenericParameterAttributes.Covariant;
			if (Match(peAttrs, Mono.Cecil.GenericParameterAttributes.DefaultConstructorConstraint)) attrs |= GenericParameterAttributes.DefaultConstructorConstraint;
			if (Match(peAttrs, Mono.Cecil.GenericParameterAttributes.NotNullableValueTypeConstraint)) attrs |= GenericParameterAttributes.NotNullableValueTypeConstraint;
			if (Match(peAttrs, Mono.Cecil.GenericParameterAttributes.ReferenceTypeConstraint)) attrs |= GenericParameterAttributes.ReferenceTypeConstraint;
			return attrs;
		}

		public static Mono.Cecil.GenericParameterAttributes Convert(GenericParameterAttributes attrs)
		{
			Mono.Cecil.GenericParameterAttributes peAttrs = (Mono.Cecil.GenericParameterAttributes)0;
			if (Match(attrs, GenericParameterAttributes.Contravariant)) peAttrs |= Mono.Cecil.GenericParameterAttributes.Contravariant;
			if (Match(attrs, GenericParameterAttributes.Covariant)) peAttrs |= Mono.Cecil.GenericParameterAttributes.Covariant;
			if (Match(attrs, GenericParameterAttributes.DefaultConstructorConstraint)) peAttrs |= Mono.Cecil.GenericParameterAttributes.DefaultConstructorConstraint;
			if (Match(attrs, GenericParameterAttributes.NotNullableValueTypeConstraint)) peAttrs |= Mono.Cecil.GenericParameterAttributes.NotNullableValueTypeConstraint;
			if (Match(attrs, GenericParameterAttributes.ReferenceTypeConstraint)) peAttrs |= Mono.Cecil.GenericParameterAttributes.ReferenceTypeConstraint;
			return peAttrs;
		}
	}
}

redpajama_set_name: RedPajamaGithub


text:
#ifndef TNT_FILAMENT_SAMPLERINTERFACEBLOCK_H
#define TNT_FILAMENT_SAMPLERINTERFACEBLOCK_H

#include <backend/DriverEnums.h>

#include <utils/compiler.h>
#include <utils/CString.h>
#include <utils/FixedCapacityVector.h>

#include <initializer_list>
#include <unordered_map>
#include <string_view>

namespace filament {

class SamplerInterfaceBlock {
public:
    SamplerInterfaceBlock();

    SamplerInterfaceBlock(const SamplerInterfaceBlock& rhs) = delete;
    SamplerInterfaceBlock(SamplerInterfaceBlock&& rhs) noexcept;

    SamplerInterfaceBlock& operator=(const SamplerInterfaceBlock& rhs) = delete;
    SamplerInterfaceBlock& operator=(SamplerInterfaceBlock&& rhs) noexcept;

    ~SamplerInterfaceBlock() noexcept;

    using Type = backend::SamplerType;
    using Format = backend::SamplerFormat;
    using Precision = backend::Precision;
    using SamplerParams = backend::SamplerParams;

    struct SamplerInfo { // NOLINT(cppcoreguidelines-pro-type-member-init)
        utils::CString name;        // name of this sampler
        utils::CString uniformName; // name of the uniform holding this sampler (needed for glsl/MSL)
        uint8_t offset;             // offset in "Sampler" of this sampler in the buffer
        Type type;                  // type of this sampler
        Format format;              // format of this sampler
        Precision precision;        // precision of this sampler
        bool multisample;           // multisample capable
    };

    class Builder {
    public:
        Builder();
        ~Builder() noexcept;

        Builder(Builder const& rhs) = default;
        Builder(Builder&& rhs) noexcept = default;
        Builder& operator=(Builder const& rhs) = default;
        Builder& operator=(Builder&& rhs) noexcept = default;

        struct ListEntry { // NOLINT(cppcoreguidelines-pro-type-member-init)
            std::string_view name;          // name of this sampler
            Type type;                      // type of this sampler
            Format format;                  // format of this sampler
            Precision precision;            // precision of this sampler
            bool multisample = false;       // multisample capable
        };

        // Give a name to this sampler interface block
        Builder& name(std::string_view interfaceBlockName);

        Builder& stageFlags(backend::ShaderStageFlags stageFlags);

        // Add a sampler
        Builder& add(std::string_view samplerName, Type type, Format format,
                Precision precision = Precision::MEDIUM,
                bool multisample = false) noexcept;

        // Add multiple samplers
        Builder& add(std::initializer_list<ListEntry> list) noexcept;

        // build and return the SamplerInterfaceBlock
        SamplerInterfaceBlock build();
    private:
        friend class SamplerInterfaceBlock;
        utils::CString mName;
        backend::ShaderStageFlags mStageFlags = backend::ShaderStageFlags::ALL_SHADER_STAGE_FLAGS;
        std::vector<SamplerInfo> mEntries;
    };

    // name of this sampler interface block
    const utils::CString& getName() const noexcept { return mName; }

    backend::ShaderStageFlags getStageFlags() const noexcept { return mStageFlags; }

    // size needed to store the samplers described by this interface block in a SamplerGroup
    size_t getSize() const noexcept { return mSamplersInfoList.size(); }

    // list of information records for each sampler
    utils::FixedCapacityVector<SamplerInfo> const& getSamplerInfoList() const noexcept {
        return mSamplersInfoList;
    }

    // information record for sampler of the given name
    SamplerInfo const* getSamplerInfo(std::string_view name) const;

    bool hasSampler(std::string_view name) const noexcept {
        return mInfoMap.find(name) != mInfoMap.end();
    }

    bool isEmpty() const noexcept { return mSamplersInfoList.empty(); }

    static utils::CString generateUniformName(const char* group, const char* sampler) noexcept;

private:
    friend class Builder;

    explicit SamplerInterfaceBlock(Builder const& builder) noexcept;

    utils::CString mName;
    backend::ShaderStageFlags mStageFlags{}; // It's needed to check if MAX_SAMPLER_COUNT is exceeded.
    utils::FixedCapacityVector<SamplerInfo> mSamplersInfoList;
    std::unordered_map<std::string_view, uint32_t> mInfoMap;
};

} // namespace filament

#endif // TNT_FILAMENT_SAMPLERINTERFACEBLOCK_H


text:
<resources>
    <string name="app_name">AndroidAccumulationProject</string>
</resources>


text:
package org.ocpsoft.rewrite.config;

import java.util.regex.Pattern;

import org.ocpsoft.rewrite.param.Parameter;
import org.ocpsoft.rewrite.param.ParameterConfiguration;

/**
 * A {@link ConfigurationRuleParameter} with a where clause.
 *
 * @author Lincoln Baxter, III
 */
public interface ConfigurationRuleParameterWhere extends ParameterConfiguration<ConfigurationRuleParameterBuilder>
{
   /**
    * Configure the regular expression {@link Pattern} to which this {@link Parameter} must match.
    */
   ConfigurationRuleParameterMatches matches(String string);

}


text:
from django.core.management.base import BaseCommand

from core.mixins import ReadFromCSVMixin
from organisations.models import OrganisationDivisionSet, OrganisationDivision

class Command(ReadFromCSVMixin, BaseCommand):
    help = """Takes a CSV in the format name,seats_total and updates the
    seats_total for matching divisions"""

    def add_arguments(self, parser):
        super().add_arguments(parser)
        parser.add_argument(
            "--divisionset",
            action="store",
            help="PK for the DivisionSet to update",
            required=True,
        )
        parser.add_argument(
            "--override",
            action="store_true",
            help="Override existing values in seats_total",
        )

    def handle(self, *args, **options):
        division_set = OrganisationDivisionSet.objects.get(pk=options["divisionset"])
        csv_data = self.load_data(options)

        division_names = set(division_set.divisions.values_list("name", flat=True))
        csv_names = set([r["name"] for r in csv_data])
        if division_names != csv_names:
            self.stderr.write("Name mismatch")
            self.stderr.write("==============")
            self.stderr.write("Names in database not in CSV")
            self.stderr.write("\t" + "\n\t".join(division_names - csv_names))

            self.stderr.write("Names in CSV not in database")
            self.stderr.write("\t" + "\n\t".join(csv_names - division_names))

        for line in csv_data:
            division: OrganisationDivision = division_set.divisions.get(
                name=line["name"]
            )
            if division.seats_total and not options["override"]:
                self.stdout.write(
                    "Skipping division with existing "
                    "seats_total: {} ({})".format(division.name, division.pk)
                )
                continue

            division.seats_total = line["seats_total"]
            division.save()
            self.stdout.write(
                "Set seats_total to {} for {} ({})".format(
                    division.seats_total, division.name, division.pk
                )
            )