<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Swatches\Test\Unit\Block\Product\Renderer\Listing;

use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Swatches\Block\Product\Renderer\Configurable;

/**
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 * @SuppressWarnings(PHPMD.TooManyFields)
 */
class ConfigurableTest extends \PHPUnit\Framework\TestCase
{
    /** @var Configurable */
    private $configurable;

    /** @var \Magento\Framework\Stdlib\ArrayUtils|\PHPUnit_Framework_MockObject_MockObject */
    private $arrayUtils;

    /** @var \Magento\Framework\Json\EncoderInterface|\PHPUnit_Framework_MockObject_MockObject */
    private $jsonEncoder;

    /** @var \Magento\ConfigurableProduct\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */
    private $helper;

    /** @var \Magento\Swatches\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */
    private $swatchHelper;

    /** @var \Magento\Swatches\Helper\Media|\PHPUnit_Framework_MockObject_MockObject */
    private $swatchMediaHelper;

    /** @var \Magento\Catalog\Helper\Product|\PHPUnit_Framework_MockObject_MockObject */
    private $catalogProduct;

    /** @var \Magento\Customer\Helper\Session\CurrentCustomer|\PHPUnit_Framework_MockObject_MockObject */
    private $currentCustomer;

    /** @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject */
    private $priceCurrency;

    /** @var \Magento\ConfigurableProduct\Model\ConfigurableAttributeData|\PHPUnit_Framework_MockObject_MockObject */
    private $configurableAttributeData;

    /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
    private $product;

    /** @var \Magento\Catalog\Model\Product\Type\AbstractType|\PHPUnit_Framework_MockObject_MockObject */
    private $typeInstance;

    /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
    private $scopeConfig;

    /** @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject */
    private $imageHelper;

    /** @var \Magento\Catalog\Model\Product\Image\UrlBuilder|\PHPUnit_Framework_MockObject_MockObject  */
    private $imageUrlBuilder;

    /** @var \PHPUnit_Framework_MockObject_MockObject */
    private $variationPricesMock;

    public function setUp()
    {
        $this->arrayUtils = $this->createMock(\Magento\Framework\Stdlib\ArrayUtils::class);
        $this->jsonEncoder = $this->createMock(\Magento\Framework\Json\EncoderInterface::class);
        $this->helper = $this->createMock(\Magento\ConfigurableProduct\Helper\Data::class);
        $this->swatchHelper = $this->createMock(\Magento\Swatches\Helper\Data::class);
        $this->swatchMediaHelper = $this->createMock(\Magento\Swatches\Helper\Media::class);
        $this->catalogProduct = $this->createMock(\Magento\Catalog\Helper\Product::class);
        $this->currentCustomer = $this->createMock(\Magento\Customer\Helper\Session\CurrentCustomer::class);
        $this->priceCurrency = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
        $this->configurableAttributeData = $this->createMock(
            \Magento\ConfigurableProduct\Model\ConfigurableAttributeData::class
        );
        $this->product = $this->createMock(\Magento\Catalog\Model\Product::class);
        $this->typeInstance = $this->createMock(\Magento\Catalog\Model\Product\Type\AbstractType::class);
        $this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
        $this->imageHelper = $this->createMock(\Magento\Catalog\Helper\Image::class);
        $this->imageUrlBuilder = $this->createMock(\Magento\Catalog\Model\Product\Image\UrlBuilder::class);
        $this->variationPricesMock = $this->createMock(
            \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices::class
        );

        $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
        $this->configurable = $objectManagerHelper->getObject(
            \Magento\Swatches\Block\Product\Renderer\Listing\Configurable::class,
            [
                'scopeConfig' => $this->scopeConfig,
                'imageHelper' => $this->imageHelper,
                'imageUrlBuilder' => $this->imageUrlBuilder,
                'arrayUtils' => $this->arrayUtils,
                'jsonEncoder' => $this->jsonEncoder,
                'helper' => $this->helper,
                'swatchHelper' => $this->swatchHelper,
                'swatchMediaHelper' => $this->swatchMediaHelper,
                'catalogProduct' => $this->catalogProduct,
                'currentCustomer' => $this->currentCustomer,
                'priceCurrency' => $this->priceCurrency,
                'configurableAttributeData' => $this->configurableAttributeData,
                'data' => [],
                'variationPrices' => $this->variationPricesMock
            ]
        );
    }

    /**
     * @covers Magento\Swatches\Block\Product\Renderer\Listing\Configurable::getSwatchAttributesData
     */
    public function testGetJsonSwatchConfigWithoutSwatches()
    {
        $this->prepareGetJsonSwatchConfig();
        $this->configurable->setProduct($this->product);
        $this->swatchHelper->expects($this->once())->method('getSwatchAttributesAsArray')
            ->with($this->product)
            ->willReturn([]);
        $this->swatchHelper->expects($this->once())->method('getSwatchesByOptionsId')
            ->willReturn([]);
        $this->jsonEncoder->expects($this->once())->method('encode')->with([]);
        $this->configurable->getJsonSwatchConfig();
    }

    /**
     * @covers Magento\Swatches\Block\Product\Renderer\Listing\Configurable::getSwatchAttributesData
     */
    public function testGetJsonSwatchNotUsedInProductListing()
    {
        $this->prepareGetJsonSwatchConfig();
        $this->configurable->setProduct($this->product);
        $this->swatchHelper->expects($this->once())->method('getSwatchAttributesAsArray')
            ->with($this->product)
            ->willReturn(
                [
                    1 => [
                        'options' => [1 => 'testA', 3 => 'testB'],
                        'use_product_image_for_swatch' => true,
                        'used_in_product_listing' => false,
                        'attribute_code' => 'code',
                    ],
                ]
            );
        $this->swatchHelper->expects($this->once())->method('getSwatchesByOptionsId')
            ->willReturn([]);
        $this->jsonEncoder->expects($this->once())->method('encode')->with([]);
        $this->configurable->getJsonSwatchConfig();
    }

    /**
     * @covers Magento\Swatches\Block\Product\Renderer\Listing\Configurable::getSwatchAttributesData
     */
    public function testGetJsonSwatchUsedInProductListing()
    {
        $products = [
            1 => 'testA',
            3 => 'testB'
        ];
        $expected =
            [
                'type' => null,
                'value' => 'hello',
                'label' => $products[3]
            ];
        $this->prepareGetJsonSwatchConfig();
        $this->configurable->setProduct($this->product);
        $this->swatchHelper->expects($this->once())->method('getSwatchAttributesAsArray')
            ->with($this->product)
            ->willReturn(
                [
                    1 => [
                        'options' => $products,
                        'use_product_image_for_swatch' => true,
                        'used_in_product_listing' => true,
                        'attribute_code' => 'code',
                    ],
                ]
            );
        $this->swatchHelper->expects($this->once())->method('getSwatchesByOptionsId')
            ->with([1, 3])
            ->willReturn([3 => ['type' => $expected['type'], 'value' => $expected['value']]]);
        $this->jsonEncoder->expects($this->once())->method('encode');
        $this->configurable->getJsonSwatchConfig();
    }

    private function prepareGetJsonSwatchConfig()
    {
        $product1 = $this->createMock(\Magento\Catalog\Model\Product::class);
        $product1->expects($this->any())->method('isSaleable')->willReturn(true);
        $product1->expects($this->atLeastOnce())->method('getStatus')->willReturn(Status::STATUS_ENABLED);
        $product1->expects($this->any())->method('getData')->with('code')->willReturn(1);

        $product2 = $this->createMock(\Magento\Catalog\Model\Product::class);
        $product2->expects($this->any())->method('isSaleable')->willReturn(true);
        $product2->expects($this->atLeastOnce())->method('getStatus')->willReturn(Status::STATUS_ENABLED);
        $product2->expects($this->any())->method('getData')->with('code')->willReturn(3);

        $simpleProducts = [$product1, $product2];
        $configurableType = $this->createMock(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::class);
        $configurableType->expects($this->atLeastOnce())->method('getUsedProducts')->with($this->product, null)
            ->willReturn($simpleProducts);
        $this->product->expects($this->any())->method('getTypeInstance')->willReturn($configurableType);

        $productAttribute1 = $this->createMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class);
        $productAttribute1->expects($this->any())->method('getId')->willReturn(1);
        $productAttribute1->expects($this->any())->method('getAttributeCode')->willReturn('code');

        $attribute1 = $this->createPartialMock(
            \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute::class,
            ['getProductAttribute']
        );
        $attribute1->expects($this->any())->method('getProductAttribute')->willReturn($productAttribute1);

        $this->helper->expects($this->any())->method('getAllowAttributes')->with($this->product)
            ->willReturn([$attribute1]);
    }

    public function testGetPricesJson()
    {
        $expectedPrices = [
            'oldPrice' => [
                'amount' => 10,
            ],
            'basePrice' => [
                'amount' => 15,
            ],
            'finalPrice' => [
                'amount' => 20,
            ],
        ];

        $priceInfoMock = $this->createMock(\Magento\Framework\Pricing\PriceInfo\Base::class);
        $this->configurable->setProduct($this->product);
        $this->product->expects($this->once())->method('getPriceInfo')->willReturn($priceInfoMock);
        $this->variationPricesMock->expects($this->once())
            ->method('getFormattedPrices')
            ->with($priceInfoMock)
            ->willReturn($expectedPrices);

        $this->jsonEncoder->expects($this->once())->method('encode')->with($expectedPrices);
        $this->configurable->getPricesJson();
    }
}

{'repo_name': 'magento/graphql-ce', 'stars': '136', 'repo_language': 'PHP', 'file_name': 'report.phtml', 'mime_type': 'text/x-php', 'hash': -6153964248628323461, 'source_dataset': 'data'}


# Generated from applications/luci-ddns/luasrc/model/cbi/ddns/ddns.lua
#
msgid ""
msgstr ""
"Project-Id-Version: luci-app-ddns 2.4.0-1\n"
"POT-Creation-Date: 2016-01-30 11:07+0100\n"
"PO-Revision-Date: 2020-03-11 01:51+0000\n"
"Last-Translator: Tomas Greif <greif.tomas@gmail.com>\n"
"Language-Team: Czech <https://hosted.weblate.org/projects/openwrt/"
"luciapplicationsddns/cs/>\n"
"Language: cs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
"X-Generator: Weblate 4.0-dev\n"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:327
msgid "\"../\" not allowed in path for Security Reason."
msgstr "\".. /\"není v cestě povoleno z bezpečnostních důvodů."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:351
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:380
msgid "Add new services..."
msgstr "Přidat nové služby..."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:500
msgid "Advanced Settings"
msgstr "Pokročilá nastavení"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:296
msgid "Allow non-public IP's"
msgstr "Povolit neveřejné adresy IP"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:499
msgid "Basic Settings"
msgstr "Základní nastavení"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:766
msgid "Bind Network"
msgstr "Vytvořit vazbu mezi sítí"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:227
msgid "Binding to a specific network not supported"
msgstr "Vazba na určitou síť není podporována"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:254
msgid ""
"BusyBox's nslookup and Wget do not support to specify the IP version to use "
"for communication with DDNS Provider!"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:265
msgid ""
"BusyBox's nslookup and hostip do not support to specify to use TCP instead "
"of default UDP when requesting DNS server!"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:276
msgid ""
"BusyBox's nslookup in the current compiled version does not handle given DNS "
"Servers correctly!"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:386
msgid "Cancel"
msgstr "Storno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:844
msgid "Check Interval"
msgstr "Interval kontroly"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:859
msgid "Check Unit"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:27
msgid "Configuration"
msgstr "Nastavení"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:91
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:455
msgid "Configuration Error"
msgstr "Chyba nastavení"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:399
msgid "Create service"
msgstr "Vytvořit službu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:309
msgid "Current setting:"
msgstr "Současné nastavení:"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:75
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:167
msgid "Currently DDNS updates are not started at boot or on interface events."
msgstr ""
"V současné době nejsou aktualizace DDNS spouštěny při spuštění zařízení nebo "
"při událostech rozhraní."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:600
msgid "Custom update script to be used for updating your DDNS Provider."
msgstr "Vlastní aktualizační skript, který bude použit pro aktualizaci DDNS."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:579
msgid "Custom update-URL"
msgstr "Vlastní aktualizační-URL"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:599
msgid "Custom update-script"
msgstr "Vlastní aktualizační skript"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:73
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:170
msgid "DDNS Autostart disabled"
msgstr "Automatické spuštění DDNS je zakázáno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:72
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:170
msgid "DDNS Autostart enabled"
msgstr "Automatické spuštění DDNS povoleno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:533
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:552
msgid "DDNS Service provider"
msgstr "Poskytovatel služeb DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:186
msgid "DDns"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:484
msgid "DDns Service"
msgstr "Služba DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:264
msgid "DNS requests via TCP not supported"
msgstr "Požadavky DNS přes TCP nejsou podporovány"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:787
msgid "DNS-Server"
msgstr "Server DNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:305
msgid "Date format"
msgstr "Formát data"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:716
msgid "Defines the Web page to read systems IP-Address from."
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:726
msgid "Defines the interface to read systems IP-Address from"
msgstr "Definuje rozhraní pro zjištění systémové IP adresy z"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:708
msgid "Defines the network to read systems IP-Address from"
msgstr "Definuje síť pro zjištění systémové IP adres z"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:670
msgid ""
"Defines the source to read systems IP-Address from, that will be send to the "
"DDNS provider"
msgstr ""
"Definuje zdroj pro zjištění systémových IP adres, který bude odeslán "
"poskytovateli DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:523
msgid "Defines which IP address 'IPv4/IPv6' is send to the DDNS provider"
msgstr "Určuje, která IP adresa (IPv4/IPv6) bude odeslána poskytovateli DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:321
msgid "Directory contains Log files for each running section."
msgstr "Adresář obsahuje soubory protokolu pro každou běžící sekci."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:315
msgid ""
"Directory contains PID and other status information for each running section."
msgstr ""
"Adresář obsahuje PID a další stavové informace pro každou běžící sekci."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:18
msgid "Disabled"
msgstr "Zakázáno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:617
msgid "Domain"
msgstr "Doména"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:151
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:7
#: applications/luci-app-ddns/root/usr/share/luci/menu.d/luci-app-ddns.json:3
msgid "Dynamic DNS"
msgstr "Dynamické DNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:158
msgid "Dynamic DNS Version"
msgstr "Verze Dynamic DNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:408
msgid "Edit"
msgstr "Upravit"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:650
msgid "Enable secure communication with DDNS provider"
msgstr "Povolit zabezpečenou komunikaci s poskytovatelem DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:463
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:505
msgid "Enabled"
msgstr "Zapnuto"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:829
msgid "Error"
msgstr "Chyba"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:904
msgid "Error Retry Counter"
msgstr "Čítač opakování chyb"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:914
msgid "Error Retry Interval"
msgstr "Interval opakování chyby"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:740
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:749
msgid "Event Network"
msgstr "Síťové rozhraní"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:718
msgid "Example for IPv4"
msgstr "Příklad pro IPv4"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:720
msgid "Example for IPv6"
msgstr "Příklad pro IPv6"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:838
msgid "File"
msgstr "Soubor"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:582
msgid "Follow instructions you will find on their WEB page."
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:307
msgid "For supported codes look here"
msgstr "Podporované kódy najdete zde"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:778
msgid "Force IP Version"
msgstr "Vynutit verzi IP"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:253
msgid "Force IP Version not supported"
msgstr "Vynucená verze IP není podporována"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:868
msgid "Force Interval"
msgstr "Interval vynucení"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:799
msgid "Force TCP on DNS"
msgstr "Vynucení protokolu TCP u služby DNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:894
msgid "Force Unit"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:811
msgid "Format"
msgstr "Formát"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:790
msgid "Format: IP or FQDN"
msgstr "Formát: IP nebo FQDN"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:232
msgid ""
"GNU Wget will use the IP of given network, cURL will use the physical "
"interface."
msgstr "GNU Wget použije IP dané sítě, cURL použije fyzické rozhraní."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:156
msgid "Global Settings"
msgstr ""

#: applications/luci-app-ddns/root/usr/share/rpcd/acl.d/luci-app-ddns.json:3
msgid "Grant access to ddns procedures"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:215
msgid "HTTPS not supported"
msgstr "Protokol HTTPS není podporován"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:515
msgid "Hostname/FQDN to validate, if IP update happen or necessary"
msgstr ""
"Název hostitele / FQDN k ověření, pokud dojde k aktualizaci IP nebo je-li to "
"nutné"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:669
msgid "IP address source"
msgstr "Zdrojová IP adresa"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:522
msgid "IP address version"
msgstr "Verze IP adresy"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:527
msgid "IPv4-Address"
msgstr "IPv4 adresa"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:813
msgid "IPv6 address must be given in square brackets"
msgstr "Adresa IPv6 musí být uvedena v hranatých závorkách"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:206
msgid "IPv6 is currently not (fully) supported by this system"
msgstr "Protokol IPv6 momentálně není (plně) podporován tímto systémem"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:205
msgid "IPv6 not supported"
msgstr "Protokol IPv6 není podporován"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:529
msgid "IPv6-Address"
msgstr "IPv6 adresa"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:340
msgid ""
"If Wget and cURL package are installed, Wget is used for communication by "
"default."
msgstr ""
"Pokud jsou nainstalovány balíčky Wget a cURL, standardně se pro komunikaci "
"použije Wget."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:506
msgid "If this service section is disabled it could not be started."
msgstr "Pokud je tato část služby zakázána, nelze ji spustit."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:288
msgid "If using secure communication you should verify server certificates!"
msgstr ""
"Pokud používáte zabezpečenou komunikaci, měli byste ověřit serverové "
"certifikáty!"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:220
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:234
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:246
msgid ""
"In some versions cURL/libcurl in OpenWrt is compiled without proxy support."
msgstr ""
"V některých verzích je cURL / libcurl v OpenWrt kompilován bez podpory proxy."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:826
msgid "Info"
msgstr "Informace"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:155
msgid "Information"
msgstr "Informace"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:592
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:610
msgid "Insert a Update Script OR a Update URL"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:290
msgid ""
"Install 'ca-certificates' package or needed certificates by hand into /etc/"
"ssl/certs default directory"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:675
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:725
msgid "Interface"
msgstr "Rozhraní"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:869
msgid "Interval to force updates send to DDNS Provider"
msgstr ""
"Interval, po jehož uplynutí budou aktualizace odeslány zprostředkovateli DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:860
msgid "Interval unit to check for changed IP"
msgstr "Jednotka intervalu pro kontrolu změněné adresy IP"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:895
msgid "Interval unit to force updates send to DDNS Provider"
msgstr ""
"Jednotka intervalu, která vynutí odeslání aktualizací zprostředkovateli DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:468
msgid "Last Update"
msgstr "Poslední aktualizace"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:502
msgid "Log File Viewer"
msgstr "Prohlížeč souborů protokolu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:320
msgid "Log directory"
msgstr "Adresář protokolu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:332
msgid "Log length"
msgstr "Délka protokolu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:832
msgid "Log to file"
msgstr "Protokolovat do souboru"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:820
msgid "Log to syslog"
msgstr "Protokolovat do syslog"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:451
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:514
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:29
msgid "Lookup Hostname"
msgstr "Doménové jméno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:368
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:445
msgid "Name"
msgstr "Název"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:228
msgid ""
"Neither GNU Wget with SSL nor cURL installed to select a network to use for "
"communication."
msgstr ""
"Není nainstalován GNU Wget s SSL ani cURL pro výběr sítě, která má být "
"použita ke komunikaci."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:216
msgid ""
"Neither GNU Wget with SSL nor cURL installed to support secure updates via "
"HTTPS protocol."
msgstr ""
"Není nainstalován GNU Wget s SSL ani cURL pro podporu bezpečných aktualizací "
"pomocí protokolu HTTPS."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:508
msgid "Neither from LuCI interface nor from console."
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:673
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:707
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:31
msgid "Network"
msgstr "Síť"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:741
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:750
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:769
msgid "Network on which the ddns-updater scripts will be started"
msgstr "Síť, na které budou spuštěny skripty ddns-updater"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:93
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:472
msgid "Never"
msgstr "Nikdy"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:371
msgid "New DDns Service…"
msgstr "Nová služba DDNS…"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:468
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:28
msgid "Next Update"
msgstr "Další aktualizace"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:92
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:456
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:40
msgid "No Data"
msgstr "Žádná data"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:287
msgid "No certificates found"
msgstr "Nebyly nalezeny žádné certifikáty"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:825
msgid "No logging"
msgstr "Žádné protokolování"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:297
msgid "Non-public and by default blocked IP's"
msgstr "Neveřejné a implicitně blokované adresy IP"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:95
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:490
msgid "Not Running"
msgstr "Není spuštěno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:827
msgid "Notice"
msgstr "Oznámení"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:333
msgid "Number of last lines stored in log files"
msgstr "Počet posledních řádků uložených v souborech protokolu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:779
msgid "OPTIONAL: Force the usage of pure IPv4/IPv6 only communication."
msgstr "VOLITELNÉ: Vynutit použití pouze čisté IPv4/IPv6 komunikace."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:800
msgid "OPTIONAL: Force the use of TCP instead of default UDP on DNS requests."
msgstr ""
"VOLITELNÉ: Vynutit použití protokolu TCP místo výchozího UDP na DNS dotazy."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:767
msgid "OPTIONAL: Network to use for communication"
msgstr "VOLITELNÉ: Síť používaná pro komunikaci"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:809
msgid "OPTIONAL: Proxy-Server for detection and updates."
msgstr "VOLITELNÉ: Proxy-server pro detekci a aktualizace."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:788
msgid "OPTIONAL: Use non-default DNS-Server to detect 'Registered IP'."
msgstr ""
"VOLITELNÉ: pro rozpoznání registrované adresy IP použít nevýchozí server DNS."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:925
msgid "On Error the script will retry the failed action after given time"
msgstr "Při chybě skript zopakuje neúspěšnou akci po daném čase"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:905
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:915
msgid "On Error the script will stop execution after given number of retrys"
msgstr "Při chybě skript zastaví provádění po daném počtu opakování"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:636
msgid "Optional Encoded Parameter"
msgstr "Volitelný kódovaný parametr"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:642
msgid "Optional Parameter"
msgstr "Volitelný parametr"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:637
msgid "Optional: Replaces [PARAMENC] in Update-URL (URL-encoded)"
msgstr "Volitelné: Nahradí [PARAMENC] v Update-URL (URL kódování)"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:643
msgid "Optional: Replaces [PARAMOPT] in Update-URL (NOT URL-encoded)"
msgstr "Volitelné: Nahradí [PARAMOPT] v Update-URL (nikoli v kódování URL)"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:808
msgid "PROXY-Server"
msgstr "Proxy server"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:629
msgid "Password"
msgstr "Heslo"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:655
msgid "Path to CA-Certificate"
msgstr "Cesta k certifikátu CA"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:207
msgid ""
"Please follow the instructions on OpenWrt's homepage to enable IPv6 support"
msgstr ""
"Chcete-li povolit podporu protokolu IPv6, postupujte podle pokynů na "
"domovské stránce OpenWrt"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:958
msgid "Please press [Read] button"
msgstr "Prosím, stiskněte tlačítko [Načíst]"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:944
msgid "Read / Reread log file"
msgstr "Načíst / znovu načíst soubor protokolu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:451
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:30
msgid "Registered IP"
msgstr "Registrovaná IP adresa"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:436
msgid "Reload"
msgstr "Znovu načíst"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:416
msgid "Reload this service"
msgstr "Znovu načíst tuto službu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:630
msgid "Replaces [PASSWORD] in Update-URL (URL-encoded)"
msgstr "Nahradí [PASSWORD] v Update-URL (kódování URL)"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:618
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:624
msgid "Replaces [USERNAME] in Update-URL (URL-encoded)"
msgstr "Nahradí [USERNAME] v Update-URL (kódování URL)"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:197
msgid "Restart DDns"
msgstr "Restartovat DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:924
msgid "Retry Unit"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:17
msgid "Run once"
msgstr "Spustit jednou"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:106
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:493
msgid "Running"
msgstr "Spuštěno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:676
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:733
msgid "Script"
msgstr "Skript"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:348
msgid "Services"
msgstr "Služby"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:871
msgid "Setting this parameter to 0 will force the script to only run once"
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:68
msgid "Start DDNS"
msgstr "Spustit DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:163
msgid "State"
msgstr "Stav"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:487
msgid "Status"
msgstr "Stav"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:314
msgid "Status directory"
msgstr "Stavový adresář"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:435
msgid "Stop"
msgstr "Zastavit"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:68
msgid "Stop DDNS"
msgstr "Zastavit DDNS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:424
msgid "Stop this service"
msgstr "Zastavit tuto službu"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:19
msgid "Stopped"
msgstr "Zastaveno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:907
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:917
msgid "The default setting of '0' will retry infinite."
msgstr "Výchozí nastavení '0' znamená nekonečné opakování."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:374
msgid "The service name is already used"
msgstr "Název služby je již používán"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:43
msgid "There is no service configured."
msgstr "Není nakonfigurována žádná služba."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:957
msgid "This is the current content of the log file in"
msgstr "Toto je aktuální obsah souboru protokolu v"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:76
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:168
msgid ""
"This is the default if you run DDNS scripts by yourself (i.e. via cron with "
"force_interval set to '0')"
msgstr ""
"Toto je výchozí nastavení, pokud spouštíte skripty DDNS sami (tj. přes cron "
"s force_interval nastaveným na '0')"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:756
msgid "This will be autoset to the selected interface"
msgstr "Tato možnost bude automaticky nastavena na vybrané rozhraní"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:501
msgid "Timer Settings"
msgstr "Nastavení časovače"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:674
msgid "URL"
msgstr "URL"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:715
msgid "URL to detect"
msgstr "Adresa URL pro rozpoznání"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:94
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:472
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/status/include/70_ddns.js:38
msgid "Unknown"
msgstr "Neznámé"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:580
msgid "Update URL to be used for updating your DDNS Provider."
msgstr "Adresa URL použitá zprostředkovatelem DDNS pro aktualizaci."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:649
msgid "Use HTTP Secure"
msgstr "Použít zabezpečený protokol HTTPS"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:339
msgid "Use cURL"
msgstr "Použít cURL"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:734
msgid "User defined script to read systems IP-Address"
msgstr "Uživatelem definovaný skript pro čtení systémových IP adres"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:623
msgid "Username"
msgstr "Uživatelské jméno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:275
msgid "Using specific DNS Server not supported"
msgstr "Použití specifického serveru DNS není podporováno"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:853
msgid "Values below 5 minutes == 300 seconds are not supported"
msgstr "Hodnoty nižší než 5 minut (= 300 sekund) nejsou podporovány"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:888
msgid "Values lower 'Check Interval' except '0' are not supported"
msgstr ""
"Hodnoty nižší než 'Interval kontroly' s výjimkou '0' nejsou podporovány"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:16
msgid "Verify"
msgstr "Ověřit"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:828
msgid "Warning"
msgstr "Varování"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:837
msgid ""
"Writes detailed messages to log file. File will be truncated automatically."
msgstr ""
"Zapisuje podrobné zprávy do souboru protokolu. Soubor bude automaticky "
"zkrácen."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:821
msgid ""
"Writes log messages to syslog. Critical Errors will always be written to "
"syslog."
msgstr ""
"Zapisuje zprávy protokolu do syslogu. Kritické chyby budou vždy zapsány do "
"syslogu."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:279
msgid ""
"You should install 'bind-host' or 'knot-host' or 'drill' or 'hostip' "
"package, if you need to specify a DNS server to detect your registered IP."
msgstr ""

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:268
msgid ""
"You should install 'bind-host' or 'knot-host' or 'drill' package for DNS "
"requests."
msgstr ""
"Měli byste nainstalovat balíček 'bind-host' nebo 'knot-host' nebo 'drill' "
"pro DNS dotazy."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:256
msgid "You should install 'wget' or 'curl' or 'uclient-fetch' package."
msgstr ""
"Měli byste nainstalovat balíček 'wget' nebo 'curl' nebo 'uclient-fetch'."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:218
msgid ""
"You should install 'wget' or 'curl' or 'uclient-fetch' with 'libustream-"
"*ssl' package."
msgstr ""
"Měli byste nainstalovat balíček 'wget' nebo 'curl' nebo 'uclient-fetch' s "
"balíčkem 'libustream-*ssl'."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:230
msgid "You should install 'wget' or 'curl' package."
msgstr "Měli byste nainstalovat balíček 'wget' nebo 'curl'."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:244
msgid ""
"You should install 'wget' or 'uclient-fetch' package or replace libcurl."
msgstr ""
"Měli byste nainstalovat balíček 'wget' nebo 'uclient-fetch' nebo nahradit "
"libcurl."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:242
msgid "cURL is installed, but libcurl was compiled without proxy support."
msgstr "cURL je nainstalován, ale libcurl byl kompilován bez podpory proxy."

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:241
msgid "cURL without Proxy Support"
msgstr "cURL bez podpory proxy"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:536
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:555
msgid "custom"
msgstr "vlastní"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:901
msgid "days"
msgstr "dny/dnů"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:656
msgid "directory or path/file"
msgstr "adresář, nebo cesta/soubor"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:865
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:900
msgid "hours"
msgstr "hodiny/hodin"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:864
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:899
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:930
msgid "minutes"
msgstr "minuty/minut"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:658
msgid "or"
msgstr "nebo"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:208
msgid "or update your system to the latest OpenWrt Release"
msgstr "nebo aktualizujte systém na nejnovější verzi OpenWrt"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:863
#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:929
msgid "seconds"
msgstr "sekundy/sekund"

#: applications/luci-app-ddns/htdocs/luci-static/resources/view/ddns/overview.js:660
msgid "to run HTTPS without verification of server certificates (insecure)"
msgstr "k použití HTTPS bez ověření serverových certifikátů (nedůvěryhodné)"

#~ msgid ""
#~ "Configure here the details for all Dynamic DNS services including this "
#~ "LuCI application."
#~ msgstr ""
#~ "Zde nastavte podrobnosti pro všechny dynamické služby DNS včetně této "
#~ "aplikace LuCI."

#~ msgid "For detailed information about parameter settings look here."
#~ msgstr "Podrobné informace o nastavení parametrů najdete zde."

#~ msgid "Global Configuration"
#~ msgstr "Globální nastavení"

#~ msgid ""
#~ "It is NOT recommended for casual users to change settings on this page."
#~ msgstr ""
#~ "Pro příležitostné uživatele NENÍ doporučeno měnit nastavení na této "
#~ "stránce."

#~ msgid "BusyBox's nslookup and Wget do not support to specify"
#~ msgstr "Nástroje nslookup a wget pro BusyBox nepodporuje specifikaci"

#~ msgid "BusyBox's nslookup and hostip do not support to specify to use TCP"
#~ msgstr "Nástroje nslookup a hostip pro BusyBox nepodporují použití TCP"

#~ msgid "BusyBox's nslookup in the current compiled version"
#~ msgstr "Nástroj nslookup pro BusyBox v aktuální kompilované verzi"

#~ msgid "Defines the Web page to read systems IP-Address from"
#~ msgstr "Definuje webovou stránku pro zjištění systémové IP adresy z"

#~ msgid "Install 'ca-certificates' package or needed certificates"
#~ msgstr "Nainstalujte balíček 'ca-certificates' nebo potřebné certifikáty"

#~ msgid ""
#~ "You should install 'bind-host' or 'knot-host' or 'drill' or 'hostip' "
#~ "package,"
#~ msgstr ""
#~ "Měli byste nainstalovat balíček 'bind-host' nebo 'knot-host' nebo 'drill' "
#~ "nebo 'hostip',"

#~ msgid ""
#~ "Dynamic DNS allows that your router can be reached with a fixed hostname "
#~ "while having a dynamically changing IP address."
#~ msgstr ""
#~ "Dynamické DNS umožňuje, aby mohl být váš router dostupný pod pevným "
#~ "hostname, zatímco se jeho IP adresa dynamicky mění."

{'repo_name': 'openwrt/luci', 'stars': '2747', 'repo_language': 'JavaScript', 'file_name': 'mime.luadoc', 'mime_type': 'text/plain', 'hash': -8000518162792078605, 'source_dataset': 'data'}


# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license

# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
# provided that the above copyright notice and this permission notice
# appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

"""DNS Zones."""

import contextlib
import io
import os

import dns.exception
import dns.name
import dns.node
import dns.rdataclass
import dns.rdatatype
import dns.rdata
import dns.rdtypes.ANY.SOA
import dns.rrset
import dns.tokenizer
import dns.transaction
import dns.ttl
import dns.grange
import dns.zonefile

class BadZone(dns.exception.DNSException):

    """The DNS zone is malformed."""

class NoSOA(BadZone):

    """The DNS zone has no SOA RR at its origin."""

class NoNS(BadZone):

    """The DNS zone has no NS RRset at its origin."""

class UnknownOrigin(BadZone):

    """The DNS zone's origin is unknown."""

class Zone(dns.transaction.TransactionManager):

    """A DNS zone.

    A ``Zone`` is a mapping from names to nodes.  The zone object may be
    treated like a Python dictionary, e.g. ``zone[name]`` will retrieve
    the node associated with that name.  The *name* may be a
    ``dns.name.Name object``, or it may be a string.  In either case,
    if the name is relative it is treated as relative to the origin of
    the zone.
    """

    node_factory = dns.node.Node

    __slots__ = ['rdclass', 'origin', 'nodes', 'relativize']

    def __init__(self, origin, rdclass=dns.rdataclass.IN, relativize=True):
        """Initialize a zone object.

        *origin* is the origin of the zone.  It may be a ``dns.name.Name``,
        a ``str``, or ``None``.  If ``None``, then the zone's origin will
        be set by the first ``$ORIGIN`` line in a zone file.

        *rdclass*, an ``int``, the zone's rdata class; the default is class IN.

        *relativize*, a ``bool``, determine's whether domain names are
        relativized to the zone's origin.  The default is ``True``.
        """

        if origin is not None:
            if isinstance(origin, str):
                origin = dns.name.from_text(origin)
            elif not isinstance(origin, dns.name.Name):
                raise ValueError("origin parameter must be convertible to a "
                                 "DNS name")
            if not origin.is_absolute():
                raise ValueError("origin parameter must be an absolute name")
        self.origin = origin
        self.rdclass = rdclass
        self.nodes = {}
        self.relativize = relativize

    def __eq__(self, other):
        """Two zones are equal if they have the same origin, class, and
        nodes.

        Returns a ``bool``.
        """

        if not isinstance(other, Zone):
            return False
        if self.rdclass != other.rdclass or \
           self.origin != other.origin or \
           self.nodes != other.nodes:
            return False
        return True

    def __ne__(self, other):
        """Are two zones not equal?

        Returns a ``bool``.
        """

        return not self.__eq__(other)

    def _validate_name(self, name):
        if isinstance(name, str):
            name = dns.name.from_text(name, None)
        elif not isinstance(name, dns.name.Name):
            raise KeyError("name parameter must be convertible to a DNS name")
        if name.is_absolute():
            if not name.is_subdomain(self.origin):
                raise KeyError(
                    "name parameter must be a subdomain of the zone origin")
            if self.relativize:
                name = name.relativize(self.origin)
        return name

    def __getitem__(self, key):
        key = self._validate_name(key)
        return self.nodes[key]

    def __setitem__(self, key, value):
        key = self._validate_name(key)
        self.nodes[key] = value

    def __delitem__(self, key):
        key = self._validate_name(key)
        del self.nodes[key]

    def __iter__(self):
        return self.nodes.__iter__()

    def keys(self):
        return self.nodes.keys()  # pylint: disable=dict-keys-not-iterating

    def values(self):
        return self.nodes.values()  # pylint: disable=dict-values-not-iterating

    def items(self):
        return self.nodes.items()  # pylint: disable=dict-items-not-iterating

    def get(self, key):
        key = self._validate_name(key)
        return self.nodes.get(key)

    def __contains__(self, other):
        return other in self.nodes

    def find_node(self, name, create=False):
        """Find a node in the zone, possibly creating it.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *create*, a ``bool``.  If true, the node will be created if it does
        not exist.

        Raises ``KeyError`` if the name is not known and create was
        not specified, or if the name was not a subdomain of the origin.

        Returns a ``dns.node.Node``.
        """

        name = self._validate_name(name)
        node = self.nodes.get(name)
        if node is None:
            if not create:
                raise KeyError
            node = self.node_factory()
            self.nodes[name] = node
        return node

    def get_node(self, name, create=False):
        """Get a node in the zone, possibly creating it.

        This method is like ``find_node()``, except it returns None instead
        of raising an exception if the node does not exist and creation
        has not been requested.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *create*, a ``bool``.  If true, the node will be created if it does
        not exist.

        Raises ``KeyError`` if the name is not known and create was
        not specified, or if the name was not a subdomain of the origin.

        Returns a ``dns.node.Node`` or ``None``.
        """

        try:
            node = self.find_node(name, create)
        except KeyError:
            node = None
        return node

    def delete_node(self, name):
        """Delete the specified node if it exists.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        It is not an error if the node does not exist.
        """

        name = self._validate_name(name)
        if name in self.nodes:
            del self.nodes[name]

    def find_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE,
                      create=False):
        """Look for an rdataset with the specified name and type in the zone,
        and return an rdataset encapsulating it.

        The rdataset returned is not a copy; changes to it will change
        the zone.

        KeyError is raised if the name or type are not found.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *rdtype*, an ``int`` or ``str``, the rdata type desired.

        *covers*, an ``int`` or ``str`` or ``None``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.

        *create*, a ``bool``.  If true, the node will be created if it does
        not exist.

        Raises ``KeyError`` if the name is not known and create was
        not specified, or if the name was not a subdomain of the origin.

        Returns a ``dns.rdataset.Rdataset``.
        """

        name = self._validate_name(name)
        rdtype = dns.rdatatype.RdataType.make(rdtype)
        if covers is not None:
            covers = dns.rdatatype.RdataType.make(covers)
        node = self.find_node(name, create)
        return node.find_rdataset(self.rdclass, rdtype, covers, create)

    def get_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE,
                     create=False):
        """Look for an rdataset with the specified name and type in the zone.

        This method is like ``find_rdataset()``, except it returns None instead
        of raising an exception if the rdataset does not exist and creation
        has not been requested.

        The rdataset returned is not a copy; changes to it will change
        the zone.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *rdtype*, an ``int`` or ``str``, the rdata type desired.

        *covers*, an ``int`` or ``str`` or ``None``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.

        *create*, a ``bool``.  If true, the node will be created if it does
        not exist.

        Raises ``KeyError`` if the name is not known and create was
        not specified, or if the name was not a subdomain of the origin.

        Returns a ``dns.rdataset.Rdataset`` or ``None``.
        """

        try:
            rdataset = self.find_rdataset(name, rdtype, covers, create)
        except KeyError:
            rdataset = None
        return rdataset

    def delete_rdataset(self, name, rdtype, covers=dns.rdatatype.NONE):
        """Delete the rdataset matching *rdtype* and *covers*, if it
        exists at the node specified by *name*.

        It is not an error if the node does not exist, or if there is no
        matching rdataset at the node.

        If the node has no rdatasets after the deletion, it will itself
        be deleted.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *rdtype*, an ``int`` or ``str``, the rdata type desired.

        *covers*, an ``int`` or ``str`` or ``None``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.
        """

        name = self._validate_name(name)
        rdtype = dns.rdatatype.RdataType.make(rdtype)
        if covers is not None:
            covers = dns.rdatatype.RdataType.make(covers)
        node = self.get_node(name)
        if node is not None:
            node.delete_rdataset(self.rdclass, rdtype, covers)
            if len(node) == 0:
                self.delete_node(name)

    def replace_rdataset(self, name, replacement):
        """Replace an rdataset at name.

        It is not an error if there is no rdataset matching I{replacement}.

        Ownership of the *replacement* object is transferred to the zone;
        in other words, this method does not store a copy of *replacement*
        at the node, it stores *replacement* itself.

        If the node does not exist, it is created.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *replacement*, a ``dns.rdataset.Rdataset``, the replacement rdataset.
        """

        if replacement.rdclass != self.rdclass:
            raise ValueError('replacement.rdclass != zone.rdclass')
        node = self.find_node(name, True)
        node.replace_rdataset(replacement)

    def find_rrset(self, name, rdtype, covers=dns.rdatatype.NONE):
        """Look for an rdataset with the specified name and type in the zone,
        and return an RRset encapsulating it.

        This method is less efficient than the similar
        ``find_rdataset()`` because it creates an RRset instead of
        returning the matching rdataset.  It may be more convenient
        for some uses since it returns an object which binds the owner
        name to the rdataset.

        This method may not be used to create new nodes or rdatasets;
        use ``find_rdataset`` instead.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *rdtype*, an ``int`` or ``str``, the rdata type desired.

        *covers*, an ``int`` or ``str`` or ``None``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.

        *create*, a ``bool``.  If true, the node will be created if it does
        not exist.

        Raises ``KeyError`` if the name is not known and create was
        not specified, or if the name was not a subdomain of the origin.

        Returns a ``dns.rrset.RRset`` or ``None``.
        """

        name = self._validate_name(name)
        rdtype = dns.rdatatype.RdataType.make(rdtype)
        if covers is not None:
            covers = dns.rdatatype.RdataType.make(covers)
        rdataset = self.nodes[name].find_rdataset(self.rdclass, rdtype, covers)
        rrset = dns.rrset.RRset(name, self.rdclass, rdtype, covers)
        rrset.update(rdataset)
        return rrset

    def get_rrset(self, name, rdtype, covers=dns.rdatatype.NONE):
        """Look for an rdataset with the specified name and type in the zone,
        and return an RRset encapsulating it.

        This method is less efficient than the similar ``get_rdataset()``
        because it creates an RRset instead of returning the matching
        rdataset.  It may be more convenient for some uses since it
        returns an object which binds the owner name to the rdataset.

        This method may not be used to create new nodes or rdatasets;
        use ``get_rdataset()`` instead.

        *name*: the name of the node to find.
        The value may be a ``dns.name.Name`` or a ``str``.  If absolute, the
        name must be a subdomain of the zone's origin.  If ``zone.relativize``
        is ``True``, then the name will be relativized.

        *rdtype*, an ``int`` or ``str``, the rdata type desired.

        *covers*, an ``int`` or ``str`` or ``None``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.

        *create*, a ``bool``.  If true, the node will be created if it does
        not exist.

        Raises ``KeyError`` if the name is not known and create was
        not specified, or if the name was not a subdomain of the origin.

        Returns a ``dns.rrset.RRset`` or ``None``.
        """

        try:
            rrset = self.find_rrset(name, rdtype, covers)
        except KeyError:
            rrset = None
        return rrset

    def iterate_rdatasets(self, rdtype=dns.rdatatype.ANY,
                          covers=dns.rdatatype.NONE):
        """Return a generator which yields (name, rdataset) tuples for
        all rdatasets in the zone which have the specified *rdtype*
        and *covers*.  If *rdtype* is ``dns.rdatatype.ANY``, the default,
        then all rdatasets will be matched.

        *rdtype*, an ``int`` or ``str``, the rdata type desired.

        *covers*, an ``int`` or ``str`` or ``None``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.
        """

        rdtype = dns.rdatatype.RdataType.make(rdtype)
        if covers is not None:
            covers = dns.rdatatype.RdataType.make(covers)
        for (name, node) in self.items():
            for rds in node:
                if rdtype == dns.rdatatype.ANY or \
                   (rds.rdtype == rdtype and rds.covers == covers):
                    yield (name, rds)

    def iterate_rdatas(self, rdtype=dns.rdatatype.ANY,
                       covers=dns.rdatatype.NONE):
        """Return a generator which yields (name, ttl, rdata) tuples for
        all rdatas in the zone which have the specified *rdtype*
        and *covers*.  If *rdtype* is ``dns.rdatatype.ANY``, the default,
        then all rdatas will be matched.

        *rdtype*, an ``int`` or ``str``, the rdata type desired.

        *covers*, an ``int`` or ``str`` or ``None``, the covered type.
        Usually this value is ``dns.rdatatype.NONE``, but if the
        rdtype is ``dns.rdatatype.SIG`` or ``dns.rdatatype.RRSIG``,
        then the covers value will be the rdata type the SIG/RRSIG
        covers.  The library treats the SIG and RRSIG types as if they
        were a family of types, e.g. RRSIG(A), RRSIG(NS), RRSIG(SOA).
        This makes RRSIGs much easier to work with than if RRSIGs
        covering different rdata types were aggregated into a single
        RRSIG rdataset.
        """

        rdtype = dns.rdatatype.RdataType.make(rdtype)
        if covers is not None:
            covers = dns.rdatatype.RdataType.make(covers)
        for (name, node) in self.items():
            for rds in node:
                if rdtype == dns.rdatatype.ANY or \
                   (rds.rdtype == rdtype and rds.covers == covers):
                    for rdata in rds:
                        yield (name, rds.ttl, rdata)

    def to_file(self, f, sorted=True, relativize=True, nl=None,
                want_comments=False):
        """Write a zone to a file.

        *f*, a file or `str`.  If *f* is a string, it is treated
        as the name of a file to open.

        *sorted*, a ``bool``.  If True, the default, then the file
        will be written with the names sorted in DNSSEC order from
        least to greatest.  Otherwise the names will be written in
        whatever order they happen to have in the zone's dictionary.

        *relativize*, a ``bool``.  If True, the default, then domain
        names in the output will be relativized to the zone's origin
        if possible.

        *nl*, a ``str`` or None.  The end of line string.  If not
        ``None``, the output will use the platform's native
        end-of-line marker (i.e. LF on POSIX, CRLF on Windows).

        *want_comments*, a ``bool``.  If ``True``, emit end-of-line comments
        as part of writing the file.  If ``False``, the default, do not
        emit them.
        """

        with contextlib.ExitStack() as stack:
            if isinstance(f, str):
                f = stack.enter_context(open(f, 'wb'))

            # must be in this way, f.encoding may contain None, or even
            # attribute may not be there
            file_enc = getattr(f, 'encoding', None)
            if file_enc is None:
                file_enc = 'utf-8'

            if nl is None:
                # binary mode, '\n' is not enough
                nl_b = os.linesep.encode(file_enc)
                nl = '\n'
            elif isinstance(nl, str):
                nl_b = nl.encode(file_enc)
            else:
                nl_b = nl
                nl = nl.decode()

            if sorted:
                names = list(self.keys())
                names.sort()
            else:
                names = self.keys()
            for n in names:
                l = self[n].to_text(n, origin=self.origin,
                                    relativize=relativize,
                                    want_comments=want_comments)
                l_b = l.encode(file_enc)

                try:
                    f.write(l_b)
                    f.write(nl_b)
                except TypeError:  # textual mode
                    f.write(l)
                    f.write(nl)

    def to_text(self, sorted=True, relativize=True, nl=None,
                want_comments=False):
        """Return a zone's text as though it were written to a file.

        *sorted*, a ``bool``.  If True, the default, then the file
        will be written with the names sorted in DNSSEC order from
        least to greatest.  Otherwise the names will be written in
        whatever order they happen to have in the zone's dictionary.

        *relativize*, a ``bool``.  If True, the default, then domain
        names in the output will be relativized to the zone's origin
        if possible.

        *nl*, a ``str`` or None.  The end of line string.  If not
        ``None``, the output will use the platform's native
        end-of-line marker (i.e. LF on POSIX, CRLF on Windows).

        *want_comments*, a ``bool``.  If ``True``, emit end-of-line comments
        as part of writing the file.  If ``False``, the default, do not
        emit them.

        Returns a ``str``.
        """
        temp_buffer = io.StringIO()
        self.to_file(temp_buffer, sorted, relativize, nl, want_comments)
        return_value = temp_buffer.getvalue()
        temp_buffer.close()
        return return_value

    def check_origin(self):
        """Do some simple checking of the zone's origin.

        Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

        Raises ``dns.zone.NoNS`` if there is no NS RRset.

        Raises ``KeyError`` if there is no origin node.
        """
        if self.relativize:
            name = dns.name.empty
        else:
            name = self.origin
        if self.get_rdataset(name, dns.rdatatype.SOA) is None:
            raise NoSOA
        if self.get_rdataset(name, dns.rdatatype.NS) is None:
            raise NoNS

    # TransactionManager methods

    def reader(self):
        return Transaction(self, False, True)

    def writer(self, replacement=False):
        return Transaction(self, replacement, False)

    def origin_information(self):
        if self.relativize:
            effective = dns.name.empty
        else:
            effective = self.origin
        return (self.origin, self.relativize, effective)

    def get_class(self):
        return self.rdclass

class Transaction(dns.transaction.Transaction):

    _deleted_rdataset = dns.rdataset.Rdataset(dns.rdataclass.ANY,
                                              dns.rdatatype.ANY)

    def __init__(self, zone, replacement, read_only):
        super().__init__(zone, replacement, read_only)
        self.rdatasets = {}

    @property
    def zone(self):
        return self.manager

    def _get_rdataset(self, name, rdtype, covers):
        rdataset = self.rdatasets.get((name, rdtype, covers))
        if rdataset is self._deleted_rdataset:
            return None
        elif rdataset is None:
            rdataset = self.zone.get_rdataset(name, rdtype, covers)
        return rdataset

    def _put_rdataset(self, name, rdataset):
        assert not self.read_only
        self.zone._validate_name(name)
        self.rdatasets[(name, rdataset.rdtype, rdataset.covers)] = rdataset

    def _delete_name(self, name):
        assert not self.read_only
        # First remove any changes involving the name
        remove = []
        for key in self.rdatasets:
            if key[0] == name:
                remove.append(key)
        if len(remove) > 0:
            for key in remove:
                del self.rdatasets[key]
        # Next add deletion records for any rdatasets matching the
        # name in the zone
        node = self.zone.get_node(name)
        if node is not None:
            for rdataset in node.rdatasets:
                self.rdatasets[(name, rdataset.rdtype, rdataset.covers)] = \
                    self._deleted_rdataset

    def _delete_rdataset(self, name, rdtype, covers):
        assert not self.read_only
        try:
            del self.rdatasets[(name, rdtype, covers)]
        except KeyError:
            pass
        rdataset = self.zone.get_rdataset(name, rdtype, covers)
        if rdataset is not None:
            self.rdatasets[(name, rdataset.rdtype, rdataset.covers)] = \
                self._deleted_rdataset

    def _name_exists(self, name):
        for key, rdataset in self.rdatasets.items():
            if key[0] == name:
                if rdataset != self._deleted_rdataset:
                    return True
                else:
                    return None
        self.zone._validate_name(name)
        if self.zone.get_node(name):
            return True
        return False

    def _changed(self):
        if self.read_only:
            return False
        else:
            return len(self.rdatasets) > 0

    def _end_transaction(self, commit):
        if commit and self._changed():
            for (name, rdtype, covers), rdataset in \
                self.rdatasets.items():
                if rdataset is self._deleted_rdataset:
                    self.zone.delete_rdataset(name, rdtype, covers)
                else:
                    self.zone.replace_rdataset(name, rdataset)

    def _set_origin(self, origin):
        if self.zone.origin is None:
            self.zone.origin = origin

    def _iterate_rdatasets(self):
        # Expensive but simple!  Use a versioned zone for efficient txn
        # iteration.
        rdatasets = {}
        for (name, rdataset) in self.zone.iterate_rdatasets():
            rdatasets[(name, rdataset.rdtype, rdataset.covers)] = rdataset
        rdatasets.update(self.rdatasets)
        for (name, _, _), rdataset in rdatasets.items():
            yield (name, rdataset)

def from_text(text, origin=None, rdclass=dns.rdataclass.IN,
              relativize=True, zone_factory=Zone, filename=None,
              allow_include=False, check_origin=True, idna_codec=None):
    """Build a zone object from a zone file format string.

    *text*, a ``str``, the zone file format input.

    *origin*, a ``dns.name.Name``, a ``str``, or ``None``.  The origin
    of the zone; if not specified, the first ``$ORIGIN`` statement in the
    zone file will determine the origin of the zone.

    *rdclass*, an ``int``, the zone's rdata class; the default is class IN.

    *relativize*, a ``bool``, determine's whether domain names are
    relativized to the zone's origin.  The default is ``True``.

    *zone_factory*, the zone factory to use or ``None``.  If ``None``, then
    ``dns.zone.Zone`` will be used.  The value may be any class or callable
    that returns a subclass of ``dns.zone.Zone``.

    *filename*, a ``str`` or ``None``, the filename to emit when
    describing where an error occurred; the default is ``'<string>'``.

    *allow_include*, a ``bool``.  If ``True``, the default, then ``$INCLUDE``
    directives are permitted.  If ``False``, then encoutering a ``$INCLUDE``
    will raise a ``SyntaxError`` exception.

    *check_origin*, a ``bool``.  If ``True``, the default, then sanity
    checks of the origin node will be made by calling the zone's
    ``check_origin()`` method.

    *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA
    encoder/decoder.  If ``None``, the default IDNA 2003 encoder/decoder
    is used.

    Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

    Raises ``dns.zone.NoNS`` if there is no NS RRset.

    Raises ``KeyError`` if there is no origin node.

    Returns a subclass of ``dns.zone.Zone``.
    """

    # 'text' can also be a file, but we don't publish that fact
    # since it's an implementation detail.  The official file
    # interface is from_file().

    if filename is None:
        filename = '<string>'
    zone = zone_factory(origin, rdclass, relativize=relativize)
    with zone.writer(True) as txn:
        tok = dns.tokenizer.Tokenizer(text, filename, idna_codec=idna_codec)
        reader = dns.zonefile.Reader(tok, rdclass, txn,
                                     allow_include=allow_include)
        try:
            reader.read()
        except dns.zonefile.UnknownOrigin:
            # for backwards compatibility
            raise dns.zone.UnknownOrigin
    # Now that we're done reading, do some basic checking of the zone.
    if check_origin:
        zone.check_origin()
    return zone

def from_file(f, origin=None, rdclass=dns.rdataclass.IN,
              relativize=True, zone_factory=Zone, filename=None,
              allow_include=True, check_origin=True):
    """Read a zone file and build a zone object.

    *f*, a file or ``str``.  If *f* is a string, it is treated
    as the name of a file to open.

    *origin*, a ``dns.name.Name``, a ``str``, or ``None``.  The origin
    of the zone; if not specified, the first ``$ORIGIN`` statement in the
    zone file will determine the origin of the zone.

    *rdclass*, an ``int``, the zone's rdata class; the default is class IN.

    *relativize*, a ``bool``, determine's whether domain names are
    relativized to the zone's origin.  The default is ``True``.

    *zone_factory*, the zone factory to use or ``None``.  If ``None``, then
    ``dns.zone.Zone`` will be used.  The value may be any class or callable
    that returns a subclass of ``dns.zone.Zone``.

    *filename*, a ``str`` or ``None``, the filename to emit when
    describing where an error occurred; the default is ``'<string>'``.

    *allow_include*, a ``bool``.  If ``True``, the default, then ``$INCLUDE``
    directives are permitted.  If ``False``, then encoutering a ``$INCLUDE``
    will raise a ``SyntaxError`` exception.

    *check_origin*, a ``bool``.  If ``True``, the default, then sanity
    checks of the origin node will be made by calling the zone's
    ``check_origin()`` method.

    *idna_codec*, a ``dns.name.IDNACodec``, specifies the IDNA
    encoder/decoder.  If ``None``, the default IDNA 2003 encoder/decoder
    is used.

    Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

    Raises ``dns.zone.NoNS`` if there is no NS RRset.

    Raises ``KeyError`` if there is no origin node.

    Returns a subclass of ``dns.zone.Zone``.
    """

    with contextlib.ExitStack() as stack:
        if isinstance(f, str):
            if filename is None:
                filename = f
            f = stack.enter_context(open(f))
        return from_text(f, origin, rdclass, relativize, zone_factory,
                         filename, allow_include, check_origin)

def from_xfr(xfr, zone_factory=Zone, relativize=True, check_origin=True):
    """Convert the output of a zone transfer generator into a zone object.

    *xfr*, a generator of ``dns.message.Message`` objects, typically
    ``dns.query.xfr()``.

    *relativize*, a ``bool``, determine's whether domain names are
    relativized to the zone's origin.  The default is ``True``.
    It is essential that the relativize setting matches the one specified
    to the generator.

    *check_origin*, a ``bool``.  If ``True``, the default, then sanity
    checks of the origin node will be made by calling the zone's
    ``check_origin()`` method.

    Raises ``dns.zone.NoSOA`` if there is no SOA RRset.

    Raises ``dns.zone.NoNS`` if there is no NS RRset.

    Raises ``KeyError`` if there is no origin node.

    Returns a subclass of ``dns.zone.Zone``.
    """

    z = None
    for r in xfr:
        if z is None:
            if relativize:
                origin = r.origin
            else:
                origin = r.answer[0].name
            rdclass = r.answer[0].rdclass
            z = zone_factory(origin, rdclass, relativize=relativize)
        for rrset in r.answer:
            znode = z.nodes.get(rrset.name)
            if not znode:
                znode = z.node_factory()
                z.nodes[rrset.name] = znode
            zrds = znode.find_rdataset(rrset.rdclass, rrset.rdtype,
                                       rrset.covers, True)
            zrds.update_ttl(rrset.ttl)
            for rd in rrset:
                zrds.add(rd)
    if check_origin:
        z.check_origin()
    return z

{'repo_name': 'rthalley/dnspython', 'stars': '1544', 'repo_language': 'Python', 'file_name': 'auto-values.py', 'mime_type': 'text/x-python', 'hash': -3455276533214829235, 'source_dataset': 'data'}


Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Workbench Plug-in
Bundle-SymbolicName: org.locationtech.udig.tutorials.workbench;singleton:=true
Bundle-Version: 2.3.0.qualifier
Bundle-Activator: org.locationtech.udig.tutorials.workbench.Activator
Bundle-Vendor: udig.refractions.net
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.locationtech.udig.catalog,
 org.locationtech.udig.project
Eclipse-LazyStart: true

{'repo_name': 'locationtech/udig-platform', 'stars': '126', 'repo_language': 'Java', 'file_name': 'MANIFEST.MF', 'mime_type': 'text/plain', 'hash': 2598076736021581001, 'source_dataset': 'data'}


/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions Copyrighted [year] [name of copyright owner]".
 *
 * Copyright 2012-2016 ForgeRock AS.
 */

package org.forgerock.openam.oauth2;

import java.io.IOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;

import org.forgerock.oauth2.core.OAuth2Constants;
import org.forgerock.openam.rest.representations.JacksonRepresentationFactory;
import org.restlet.Context;
import org.restlet.Request;
import org.restlet.data.Form;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Reference;
import org.restlet.ext.jackson.JacksonRepresentation;
import org.restlet.ext.servlet.ServletUtils;
import org.restlet.representation.EmptyRepresentation;
import org.restlet.resource.ResourceException;
import org.restlet.routing.Redirector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class OAuth2Utils {

    public static final Logger DEBUG = LoggerFactory.getLogger("OAuth2Provider");

    public static final String SCOPE_DELIMITER = " ";

    private final JacksonRepresentationFactory jacksonRepresentationFactory;

    /**
     * Default constructor with guice provided variables.
     * @param jacksonRepresentationFactory The factory for {@code JacksonRepresentation} instances.
     */
    @Inject
    public OAuth2Utils(JacksonRepresentationFactory jacksonRepresentationFactory) {
        this.jacksonRepresentationFactory = jacksonRepresentationFactory;
    }

    /**
     * Gets the deployment URI of the OAuth2 authorization server
     * @param request the request to get the deployment uri of
     * @return
     */
    public String getDeploymentURL(HttpServletRequest request){
        String uri = request.getRequestURI();
        String deploymentURI = uri;
        int firstSlashIndex = uri.indexOf("/");
        int secondSlashIndex = uri.indexOf("/", firstSlashIndex + 1);
        if (secondSlashIndex != -1) {
            deploymentURI = uri.substring(0, secondSlashIndex);
        }
        StringBuffer sb = new StringBuffer(100);
        sb.append(request.getScheme()).append("://")
                .append(request.getServerName()).append(":")
                .append(request.getServerPort())
                .append(deploymentURI);
        return sb.toString();
    }

    /**
     * Determines if a string is empty. Empty is defined as null or empty
     * string.
     *

     *
     *

     *  OAuth2Utils.isEmpty(null)               = true
     *  OAuth2Utils.isEmpty("")       = true
     *  OAuth2Utils.isEmpty(" ")      = false
     *  OAuth2Utils.isEmpty("bob")    = false
     *  OAuth2Utils.isEmpty(" bob ")  = false
     *

     *
     * @param val
     *            string to evaluate as empty.
     * @return true if the string is empty else false.
     */
    public boolean isEmpty(String val) {
        return (val == null) ? true : "".equals(val) ? true : false;
    }

    /**
     *

     *      OAuth2Utils.isBlank(null)                = true
     *      OAuth2Utils.isBlank("")        = true
     *      OAuth2Utils.isBlank(" ")       = true
     *      OAuth2Utils.isBlank("bob")     = false
     *      OAuth2Utils.isBlank("  bob  ") = false
     *

     */
    public boolean isBlank(String val) {
        return (val == null) ? true : isEmpty(val.trim());
    }

    public boolean isNotBlank(String val) {
        return !isBlank(val);
    }

    public String join(Iterable<? extends Object> iterable, String delimiter) {
        if (null != iterable) {
            Iterator<? extends Object> iterator = iterable.iterator();
            if (!iterator.hasNext()) {
                return null;
            }
            StringBuilder buffer = new StringBuilder();
            buffer.append(iterator.next());
            String d = null != delimiter ? delimiter : SCOPE_DELIMITER;
            while (iterator.hasNext()) {
                buffer.append(d).append(iterator.next());
            }
            return buffer.toString();
        }
        return null;
    }

    public Set<String> split(String string, String delimiter) {
        if (isNotBlank(string)) {
            StringTokenizer tokenizer =
                    new StringTokenizer(string, null != delimiter ? delimiter : SCOPE_DELIMITER);
            Set<String> result = new TreeSet<String>();
            while (tokenizer.hasMoreTokens()) {
                result.add(tokenizer.nextToken());
            }
            return Collections.unmodifiableSet(result);
        } else {
            return Collections.emptySet();
        }
    }

    /**
     * Get the realm from the Attributes first and then look for the realm in
     * the request.
     *

     * Example: Restlet Template populates the realm into the
     * {@link Request#attributes} {@code TemplateRoute route =
     * router.attach("/oauth2/ realm}/authorize", (Restlet)authorization);}
     *

     * Example: Custom code fetches it from the query, the body or more secure
     * from the User Session
     *
     * @param request
     * @return
     */
    public String getRealm(Request request) {
        HttpServletRequest httpRequest = ServletUtils.getRequest(request);
        return getRealm(httpRequest);
    }

    public String getRealm(HttpServletRequest request) {
        Object realm = request.getParameter(OAuth2Constants.Custom.REALM);
        if (realm instanceof String) {
            return (String) realm;
        }
        return "/";
    }

    public String getLocale(Request request) {
        Object locale = request.getAttributes().get(OAuth2Constants.Custom.LOCALE);
        if (locale instanceof String) {
            return (String) locale;
        }
        return getRequestParameter(request, OAuth2Constants.Custom.LOCALE, String.class);
    }

    public <T> T getRequestParameter(Request request, String parameterName, Class<T> clazz) {
        Object value = getRequestParameters(request).get(parameterName);
        if (null != value && clazz.isAssignableFrom(value.getClass())) {
            return clazz.cast(value);
        }
        return null;
    }

    /**
     * It copies the given parameters only once!!!
     * way the CallResolver can use it and the FreeMarker can list and add all
     * into the generated form
     *
     * @param request
     *            incoming request object
     * @return The modifiable attributes map.
     */
    public Map<String, Object> getRequestParameters(Request request) {
        Map<String, String> parameters = null;
        if (request.getAttributes().get(OAuth2Constants.Params.class.getName()) instanceof Map == false) {
            parameters = getParameters(request);
            if (null != parameters) {
                // Copy the parameter for CallResolver
                request.getAttributes().putAll(parameters);
            }
            // Avoid reprocess the request next time.
            request.getAttributes().put(OAuth2Constants.Params.class.getName(), parameters);
        }
        return request.getAttributes();
    }

    /**
     * Get the parameters from the request.
     *

     * If the method is GET then the parameters are fetched from the query If
     * the request has no body/payload then the parameters are fetched from the
     * query If the content type is "application/x-www-form-urlencoded" then the
     * parameters are fetched from the body
     *
     * @param request
     *            incoming request object
     * @return null if the request does not contains any parameter
     */
    public Map<String, String> getParameters(Request request) {
        if (Method.GET.equals(request.getMethod())
                || request.getEntity() instanceof EmptyRepresentation) {
            return OAuth2Utils.ParameterLocation.HTTP_QUERY.getParameters(jacksonRepresentationFactory, request);
        } else {
            return OAuth2Utils.ParameterLocation.HTTP_QUERY.getParameters(jacksonRepresentationFactory, request);
        }
    }

    private enum ParameterLocation {
        HTTP_QUERY, HTTP_HEADER, HTTP_FRAGMENT, HTTP_BODY;

        @SuppressWarnings(value = "unchecked")
        private Map<String, String> getParameters(JacksonRepresentationFactory jacksonRepresentationFactory,
                Request request) {
            Map<String, String> result = null;
            switch (this) {
                case HTTP_FRAGMENT:
                    if (request.getReferrerRef() == null || request.getReferrerRef().getFragment() == null){
                        return null;
                    }
                    return new Form(request.getReferrerRef().getFragment()).getValuesMap();
                case HTTP_HEADER:
                    if (null != request.getChallengeResponse()
                            && !request.getChallengeResponse().getParameters().isEmpty()) {
                        return new Form(request.getChallengeResponse().getParameters()).getValuesMap();
                    }
                    return null;
                case HTTP_QUERY:
                    // Merge the parameterd from query and body
                    result = request.getResourceRef().getQueryAsForm().getValuesMap();
                case HTTP_BODY:
                    if (null == result) {
                        result = new LinkedHashMap<String, String>();
                    }
                    if (null != request.getEntity()) {
                        if (MediaType.APPLICATION_WWW_FORM.equals(request.getEntity().getMediaType())) {
                            Form form = new Form(request.getEntity());
                            // restore the entity body
                            request.setEntity(form.getWebRepresentation());
                            result.putAll(form.getValuesMap());
                        } else if (MediaType.APPLICATION_JSON
                                .equals(request.getEntity().getMediaType())) {
                            JacksonRepresentation<Map> representation =
                                    jacksonRepresentationFactory.create(request.getEntity(), Map.class);
                            try {
                                result.putAll(representation.getObject());
                            } catch (IOException e) {
                                throw new ResourceException(e);
                            }
                            request.setEntity(representation);
                        }
                    }
                    return result;
                default:
                    return null;
            }
        }

        /**
         *
         * @param context
         * @return
         */
        public Redirector getRedirector(Context context, OAuthProblemException exception) {
            /*
             * 3.1.2.4. Invalid Endpoint
             *
             * If an authorization request fails validation due to a missing,
             * invalid, or mismatching redirection URI, the authorization server
             * SHOULD inform the resource owner of the error, and MUST NOT
             * automatically redirect the user-agent to the invalid redirection
             * URI.
             */
            if (null != exception.getRedirectUri()) {
                Reference cb = new Reference(exception.getRedirectUri());
                switch (this) {
                    case HTTP_FRAGMENT: {
                        // Redirect URI can not contain Fragment so we can set it
                        cb.setFragment(exception.getErrorForm().getQueryString());
                        break;
                    }
                    case HTTP_QUERY: {
                        cb.addQueryParameters(exception.getErrorForm());
                        break;
                    }
                    default:
                        return null;
                }
                return new Redirector(context, cb.toString(), Redirector.MODE_CLIENT_FOUND);
            }
            return null;
        }
    }
}

{'repo_name': 'OpenRock/OpenAM', 'stars': '136', 'repo_language': 'Java', 'file_name': 'FSAccountManager.java', 'mime_type': 'text/x-java', 'hash': -3738444278205373843, 'source_dataset': 'data'}