From ac845ebd2f2dd89b01948e1df43847dd18d64f84 Mon Sep 17 00:00:00 2001 From: Maxim Avanov Date: Fri, 14 Sep 2012 03:34:45 +0400 Subject: [PATCH 1/6] Fix github bug #13 --- formencode/i18n/FormEncode.pot | 1094 ++++++++--------- formencode/i18n/ru/LC_MESSAGES/FormEncode.mo | Bin 12923 -> 13017 bytes formencode/i18n/ru/LC_MESSAGES/FormEncode.po | 1120 +++++++++--------- formencode/schema.py | 44 +- tests/test_schema.py | 53 +- 5 files changed, 1202 insertions(+), 1109 deletions(-) diff --git a/formencode/i18n/FormEncode.pot b/formencode/i18n/FormEncode.pot index 392434c5..dde45135 100644 --- a/formencode/i18n/FormEncode.pot +++ b/formencode/i18n/FormEncode.pot @@ -1,543 +1,551 @@ -# Translations template for FormEncode. -# Copyright (C) 2010 ORGANIZATION -# This file is distributed under the same license as the FormEncode project. -# FIRST AUTHOR , 2010. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: FormEncode 1.2.3\n" -"Report-Msgid-Bugs-To: formencode-discuss@lists.sf.net\n" -"POT-Creation-Date: 2010-05-16 19:56+0200\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 1.0dev-r546\n" - -#: formencode/api.py:394 formencode/validators.py:418 -msgid "Please enter a value" -msgstr "" - -#: formencode/api.py:395 -#, python-format -msgid "The input must be a string (not a %(type)s: %(value)r)" -msgstr "" - -#: formencode/api.py:396 -msgid "The input must be a string (not None)" -msgstr "" - -#: formencode/national.py:29 -msgid "Belarus" -msgstr "" - -#: formencode/national.py:30 -msgid "Montenegro" -msgstr "" - -#: formencode/national.py:31 -msgid "Tasmania" -msgstr "" - -#: formencode/national.py:37 -msgid "Britain" -msgstr "" - -#: formencode/national.py:38 -msgid "Great Britain" -msgstr "" - -#: formencode/national.py:39 -msgid "Cote de Ivoire" -msgstr "" - -#: formencode/national.py:144 -#, python-format -msgid "%d digits" -msgstr "" - -#: formencode/national.py:165 -#, python-format -msgid "Please enter a zip code (%(format)s)" -msgstr "" - -#: formencode/national.py:229 formencode/national.py:263 -#, python-format -msgid "Please enter a zip code (%s)" -msgstr "" - -#: formencode/national.py:229 -msgid "LnnnnLLL" -msgstr "" - -#: formencode/national.py:263 -msgid "LnL nLn" -msgstr "" - -#: formencode/national.py:297 -msgid "Please enter a valid postal code (for format see BS 7666)" -msgstr "" - -#: formencode/national.py:338 -msgid "That country is not listed in ISO 3166" -msgstr "" - -#: formencode/national.py:393 -msgid "Given postal code does not match the country's format." -msgstr "" - -#: formencode/national.py:484 -msgid "Please enter a state code" -msgstr "" - -#: formencode/national.py:485 -msgid "Please enter a state code with TWO letters" -msgstr "" - -#: formencode/national.py:486 -msgid "That is not a valid state code" -msgstr "" - -#: formencode/national.py:539 -msgid "" -"Please enter a number, with area code, in the form ###-###-####, optionally " -"with \"ext.####\"" -msgstr "" - -#: formencode/national.py:646 -msgid "Please enter a number, with area code, in the form +##-###-#######." -msgstr "" - -#: formencode/national.py:725 -msgid "That language is not listed in ISO 639" -msgstr "" - -#: formencode/schema.py:63 -#, python-format -msgid "The input field %(name)s was not expected." -msgstr "" - -#: formencode/schema.py:64 -msgid "Missing value" -msgstr "" - -#: formencode/schema.py:65 -#, python-format -msgid "The input must be dict-like (not a %(type)s: %(value)r)" -msgstr "" - -#: formencode/validators.py:147 -#, python-format -msgid "%(object)r is not a subclass of %(subclass)s" -msgstr "" - -#: formencode/validators.py:148 -#, python-format -msgid "%(object)r is not a subclass of one of the types %(subclassList)s" -msgstr "" - -#: formencode/validators.py:149 -#, python-format -msgid "%(object)r must be one of the types %(typeList)s" -msgstr "" - -#: formencode/validators.py:150 -#, python-format -msgid "%(object)r must be of the type %(type)s" -msgstr "" - -#: formencode/validators.py:330 -#, python-format -msgid "Enter a value less than %(maxLength)i characters long" -msgstr "" - -#: formencode/validators.py:331 formencode/validators.py:385 -msgid "Invalid value (value with length expected)" -msgstr "" - -#: formencode/validators.py:384 -#, python-format -msgid "Enter a value at least %(minLength)i characters long" -msgstr "" - -#: formencode/validators.py:441 -msgid "You cannot enter a value here" -msgstr "" - -#: formencode/validators.py:490 -msgid "The input is not valid" -msgstr "" - -#: formencode/validators.py:543 -msgid "Enter only letters, numbers, or _ (underscore)" -msgstr "" - -#: formencode/validators.py:581 -msgid "Invalid value" -msgstr "" - -#: formencode/validators.py:582 -#, python-format -msgid "Value must be one of: %(items)s (not %(value)r)" -msgstr "" - -#: formencode/validators.py:640 -msgid "Choose something" -msgstr "" - -#: formencode/validators.py:641 -#, python-format -msgid "Enter a value from: %(items)s" -msgstr "" - -#: formencode/validators.py:642 -msgid "That value is not known" -msgstr "" - -#: formencode/validators.py:643 -#, python-format -msgid "" -"Nothing in my dictionary goes by the value %(value)s. Choose one of: " -"%(items)s" -msgstr "" - -#: formencode/validators.py:705 -msgid "Must be an integer index" -msgstr "" - -#: formencode/validators.py:706 -msgid "Index out of range" -msgstr "" - -#: formencode/validators.py:707 -#, python-format -msgid "Item %(value)s was not found in the list" -msgstr "" - -#: formencode/validators.py:777 -#, python-format -msgid "Date must be after %(date)s" -msgstr "" - -#: formencode/validators.py:778 -#, python-format -msgid "Date must be before %(date)s" -msgstr "" - -#: formencode/validators.py:780 -#, python-format -msgid "%%A, %%d %%B %%Y" -msgstr "" - -#: formencode/validators.py:781 -msgid "The date must be sometime in the future" -msgstr "" - -#: formencode/validators.py:882 -#, python-format -msgid "Please enter a number that is %(min)s or greater" -msgstr "" - -#: formencode/validators.py:883 -#, python-format -msgid "Please enter a number that is %(max)s or smaller" -msgstr "" - -#: formencode/validators.py:920 -msgid "Please enter an integer value" -msgstr "" - -#: formencode/validators.py:958 -msgid "Please enter a number" -msgstr "" - -#: formencode/validators.py:1019 -#, python-format -msgid "Enter a value not more than %(max)i characters long" -msgstr "" - -#: formencode/validators.py:1020 -#, python-format -msgid "Enter a value %(min)i characters long or more" -msgstr "" - -#: formencode/validators.py:1095 -msgid "Invalid data or incorrect encoding" -msgstr "" - -#: formencode/validators.py:1267 -msgid "Please enter an email address" -msgstr "" - -#: formencode/validators.py:1268 -msgid "An email address must contain a single @" -msgstr "" - -#: formencode/validators.py:1269 -#, python-format -msgid "" -"The username portion of the email address is invalid (the portion before the " -"@: %(username)s)" -msgstr "" - -#: formencode/validators.py:1271 formencode/validators.py:1413 -#, python-format -msgid "An error occured when trying to connect to the server: %(error)s" -msgstr "" - -#: formencode/validators.py:1273 -#, python-format -msgid "" -"The domain portion of the email address is invalid (the portion after the @: " -"%(domain)s)" -msgstr "" - -#: formencode/validators.py:1275 -#, python-format -msgid "" -"The domain of the email address does not exist (the portion after the @: " -"%(domain)s)" -msgstr "" - -#: formencode/validators.py:1409 -msgid "You must start your URL with http://, https://, etc" -msgstr "" - -#: formencode/validators.py:1410 -msgid "That is not a valid URL" -msgstr "" - -#: formencode/validators.py:1411 -#, python-format -msgid "An error occurred when trying to access the URL: %(error)s" -msgstr "" - -#: formencode/validators.py:1415 -msgid "The server responded that the page could not be found" -msgstr "" - -#: formencode/validators.py:1416 -#, python-format -msgid "The server responded with a bad status code (%(status)s)" -msgstr "" - -#: formencode/validators.py:1417 -#, python-format -msgid "You must provide a full domain name (like %(domain)s.com)" -msgstr "" - -#: formencode/validators.py:1544 -msgid "" -"The type of i-name is not defined; it may be either individual or " -"organizational" -msgstr "" - -#: formencode/validators.py:1546 -msgid "Dots and dashes may not be repeated consecutively" -msgstr "" - -#: formencode/validators.py:1547 -#, python-format -msgid "\"%(iname)s\" is an invalid i-name" -msgstr "" - -#: formencode/validators.py:1548 -msgid "i-names may not start with numbers nor punctuation marks" -msgstr "" - -#: formencode/validators.py:1550 -#, python-format -msgid "\"%(inumber)s\" is an invalid i-number" -msgstr "" - -#: formencode/validators.py:1551 -#, python-format -msgid "The XRI must be a string (not a %(type)s: %(value)r)" -msgstr "" - -#: formencode/validators.py:1552 -#, python-format -msgid "\"%(xri_type)s\" is not a valid type of XRI" -msgstr "" - -#: formencode/validators.py:1651 -#, python-format -msgid "\"%(id)s\" is not a valid OpenId (it is neither an URL nor an XRI)" -msgstr "" - -#: formencode/validators.py:1882 formencode/validators.py:1890 -#, python-format -msgid "Please enter the date in the form %(format)s" -msgstr "" - -#: formencode/validators.py:1883 -msgid "Please enter a month from 1 to 12" -msgstr "" - -#: formencode/validators.py:1884 -msgid "Please enter a valid day" -msgstr "" - -#: formencode/validators.py:1885 -#, python-format -msgid "That month only has %(days)i days" -msgstr "" - -#: formencode/validators.py:1886 -#, python-format -msgid "That is not a valid day (%(exception)s)" -msgstr "" - -#: formencode/validators.py:1887 -#, python-format -msgid "Unknown month name: %(month)s" -msgstr "" - -#: formencode/validators.py:1888 -msgid "Please enter a number for the year" -msgstr "" - -#: formencode/validators.py:1889 -msgid "Please enter a four-digit year after 1899" -msgstr "" - -#: formencode/validators.py:2070 -msgid "You must indicate AM or PM" -msgstr "" - -#: formencode/validators.py:2071 -msgid "There are too many :'s" -msgstr "" - -#: formencode/validators.py:2072 -msgid "You may not enter seconds" -msgstr "" - -#: formencode/validators.py:2073 -msgid "You must enter seconds" -msgstr "" - -#: formencode/validators.py:2074 -msgid "You must enter minutes (after a :)" -msgstr "" - -#: formencode/validators.py:2075 -#, python-format -msgid "The %(part)s value you gave is not a number: %(number)r" -msgstr "" - -#: formencode/validators.py:2076 -#, python-format -msgid "You must enter an hour in the range %(range)s" -msgstr "" - -#: formencode/validators.py:2077 -msgid "You must enter a minute in the range 0-59" -msgstr "" - -#: formencode/validators.py:2078 -msgid "You must enter a second in the range 0-59" -msgstr "" - -#: formencode/validators.py:2224 -#, python-format -msgid "The name %(name)s is missing" -msgstr "" - -#: formencode/validators.py:2267 -#, python-format -msgid "Value should be %(true)r or %(false)r" -msgstr "" - -#: formencode/validators.py:2302 -msgid "Value does not contain a signature" -msgstr "" - -#: formencode/validators.py:2303 -msgid "Signature is not correct" -msgstr "" - -#: formencode/validators.py:2378 -msgid "Please enter a valid IP address (a.b.c.d)" -msgstr "" - -#: formencode/validators.py:2379 -#, python-format -msgid "The octets must be within the range of 0-255 (not %(octet)r)" -msgstr "" - -#: formencode/validators.py:2426 -msgid "Please enter a valid IP address (a.b.c.d) or IP network (a.b.c.d/e)" -msgstr "" - -#: formencode/validators.py:2428 -#, python-format -msgid "The network size (bits) must be within the range of 8-32 (not %(bits)r)" -msgstr "" - -#: formencode/validators.py:2477 -#, python-format -msgid "" -"A MAC address must contain 12 digits and A-F; the value you gave has " -"%(length)s characters" -msgstr "" - -#: formencode/validators.py:2479 -#, python-format -msgid "MAC addresses may only contain 0-9 and A-F (and optionally :), not %(char)r" -msgstr "" - -#: formencode/validators.py:2586 -#, python-format -msgid "You must give a value for %s" -msgstr "" - -#: formencode/validators.py:2619 -#, python-format -msgid "Fields do not match (should be %(match)s)" -msgstr "" - -#: formencode/validators.py:2620 -msgid "Fields do not match" -msgstr "" - -#: formencode/validators.py:2621 -msgid "Fields should be a dictionary" -msgstr "" - -#: formencode/validators.py:2697 -msgid "Please enter only the number, no other characters" -msgstr "" - -#: formencode/validators.py:2698 -msgid "You did not enter a valid number of digits" -msgstr "" - -#: formencode/validators.py:2699 -msgid "That number is not valid" -msgstr "" - -#: formencode/validators.py:2700 -#, python-format -msgid "The field %(key)s is missing" -msgstr "" - -#: formencode/validators.py:2816 -msgid "Please enter numbers only for month and year" -msgstr "" - -#: formencode/validators.py:2817 -msgid "Invalid Expiration Date" -msgstr "" - -#: formencode/validators.py:2892 -msgid "Please enter numbers only for credit card security code" -msgstr "" - -#: formencode/validators.py:2893 -msgid "Invalid credit card security code length" -msgstr "" - +# Translations template for FormEncode. +# Copyright (C) 2012 ORGANIZATION +# This file is distributed under the same license as the FormEncode project. +# FIRST AUTHOR , 2012. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: FormEncode 1.2.4\n" +"Report-Msgid-Bugs-To: formencode-discuss@lists.sf.net\n" +"POT-Creation-Date: 2012-09-14 03:22+0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.6\n" + +#: formencode/api.py:401 formencode/validators.py:432 +msgid "Please enter a value" +msgstr "" + +#: formencode/api.py:402 +#, python-format +msgid "The input must be a string (not a %(type)s: %(value)r)" +msgstr "" + +#: formencode/api.py:403 +msgid "The input must be a string (not None)" +msgstr "" + +#: formencode/national.py:31 +msgid "Belarus" +msgstr "" + +#: formencode/national.py:32 +msgid "Montenegro" +msgstr "" + +#: formencode/national.py:33 +msgid "Tasmania" +msgstr "" + +#: formencode/national.py:39 +msgid "Britain" +msgstr "" + +#: formencode/national.py:40 +msgid "Great Britain" +msgstr "" + +#: formencode/national.py:41 +msgid "Cote de Ivoire" +msgstr "" + +#: formencode/national.py:146 +#, python-format +msgid "%d digits" +msgstr "" + +#: formencode/national.py:167 +#, python-format +msgid "Please enter a zip code (%(format)s)" +msgstr "" + +#: formencode/national.py:231 formencode/national.py:265 +#, python-format +msgid "Please enter a zip code (%s)" +msgstr "" + +#: formencode/national.py:231 +msgid "LnnnnLLL" +msgstr "" + +#: formencode/national.py:265 +msgid "LnL nLn" +msgstr "" + +#: formencode/national.py:299 +msgid "Please enter a valid postal code (for format see BS 7666)" +msgstr "" + +#: formencode/national.py:340 +msgid "That country is not listed in ISO 3166" +msgstr "" + +#: formencode/national.py:395 +msgid "Given postal code does not match the country's format." +msgstr "" + +#: formencode/national.py:486 +msgid "Please enter a state code" +msgstr "" + +#: formencode/national.py:487 +msgid "Please enter a state code with TWO letters" +msgstr "" + +#: formencode/national.py:488 +msgid "That is not a valid state code" +msgstr "" + +#: formencode/national.py:541 +msgid "" +"Please enter a number, with area code, in the form ###-###-####, optionally " +"with \"ext.####\"" +msgstr "" + +#: formencode/national.py:648 +msgid "Please enter a number, with area code, in the form +##-###-#######." +msgstr "" + +#: formencode/national.py:727 +msgid "That language is not listed in ISO 639" +msgstr "" + +#: formencode/schema.py:68 +#, python-format +msgid "The input field %(name)s was not expected." +msgstr "" + +#: formencode/schema.py:69 +msgid "Missing value" +msgstr "" + +#: formencode/schema.py:70 +#, python-format +msgid "The input must be dict-like (not a %(type)s: %(value)r)" +msgstr "" + +#: formencode/schema.py:72 +msgid "Please provide only one value" +msgstr "" + +#: formencode/validators.py:150 +#, python-format +msgid "%(object)r is not a subclass of %(subclass)s" +msgstr "" + +#: formencode/validators.py:151 +#, python-format +msgid "%(object)r is not a subclass of one of the types %(subclassList)s" +msgstr "" + +#: formencode/validators.py:152 +#, python-format +msgid "%(object)r must be one of the types %(typeList)s" +msgstr "" + +#: formencode/validators.py:153 +#, python-format +msgid "%(object)r must be of the type %(type)s" +msgstr "" + +#: formencode/validators.py:344 +#, python-format +msgid "Enter a value less than %(maxLength)i characters long" +msgstr "" + +#: formencode/validators.py:345 formencode/validators.py:399 +msgid "Invalid value (value with length expected)" +msgstr "" + +#: formencode/validators.py:398 +#, python-format +msgid "Enter a value at least %(minLength)i characters long" +msgstr "" + +#: formencode/validators.py:455 +msgid "You cannot enter a value here" +msgstr "" + +#: formencode/validators.py:504 +msgid "The input is not valid" +msgstr "" + +#: formencode/validators.py:557 +msgid "Enter only letters, numbers, or _ (underscore)" +msgstr "" + +#: formencode/validators.py:595 +msgid "Invalid value" +msgstr "" + +#: formencode/validators.py:596 +#, python-format +msgid "Value must be one of: %(items)s (not %(value)r)" +msgstr "" + +#: formencode/validators.py:657 +msgid "Choose something" +msgstr "" + +#: formencode/validators.py:658 +#, python-format +msgid "Enter a value from: %(items)s" +msgstr "" + +#: formencode/validators.py:659 +msgid "That value is not known" +msgstr "" + +#: formencode/validators.py:660 +#, python-format +msgid "" +"Nothing in my dictionary goes by the value %(value)s. Choose one of: " +"%(items)s" +msgstr "" + +#: formencode/validators.py:724 +msgid "Must be an integer index" +msgstr "" + +#: formencode/validators.py:725 +msgid "Index out of range" +msgstr "" + +#: formencode/validators.py:726 +#, python-format +msgid "Item %(value)s was not found in the list" +msgstr "" + +#: formencode/validators.py:796 +#, python-format +msgid "Date must be after %(date)s" +msgstr "" + +#: formencode/validators.py:797 +#, python-format +msgid "Date must be before %(date)s" +msgstr "" + +#: formencode/validators.py:799 +#, python-format +msgid "%%A, %%d %%B %%Y" +msgstr "" + +#: formencode/validators.py:800 +msgid "The date must be sometime in the future" +msgstr "" + +#: formencode/validators.py:901 +#, python-format +msgid "Please enter a number that is %(min)s or greater" +msgstr "" + +#: formencode/validators.py:902 +#, python-format +msgid "Please enter a number that is %(max)s or smaller" +msgstr "" + +#: formencode/validators.py:939 +msgid "Please enter an integer value" +msgstr "" + +#: formencode/validators.py:975 +msgid "Please enter a number" +msgstr "" + +#: formencode/validators.py:1036 +#, python-format +msgid "Enter a value not more than %(max)i characters long" +msgstr "" + +#: formencode/validators.py:1037 +#, python-format +msgid "Enter a value %(min)i characters long or more" +msgstr "" + +#: formencode/validators.py:1119 +msgid "Invalid data or incorrect encoding" +msgstr "" + +#: formencode/validators.py:1290 +msgid "Please enter an email address" +msgstr "" + +#: formencode/validators.py:1291 +msgid "An email address must contain a single @" +msgstr "" + +#: formencode/validators.py:1292 +#, python-format +msgid "" +"The username portion of the email address is invalid (the portion before the " +"@: %(username)s)" +msgstr "" + +#: formencode/validators.py:1294 formencode/validators.py:1457 +#, python-format +msgid "An error occured when trying to connect to the server: %(error)s" +msgstr "" + +#: formencode/validators.py:1296 +#, python-format +msgid "" +"The domain portion of the email address is invalid (the portion after the @: " +"%(domain)s)" +msgstr "" + +#: formencode/validators.py:1298 +#, python-format +msgid "" +"The domain of the email address does not exist (the portion after the @: " +"%(domain)s)" +msgstr "" + +#: formencode/validators.py:1453 +msgid "You must start your URL with http://, https://, etc" +msgstr "" + +#: formencode/validators.py:1454 +msgid "That is not a valid URL" +msgstr "" + +#: formencode/validators.py:1455 +#, python-format +msgid "An error occurred when trying to access the URL: %(error)s" +msgstr "" + +#: formencode/validators.py:1459 +msgid "The server responded that the page could not be found" +msgstr "" + +#: formencode/validators.py:1460 +#, python-format +msgid "The server responded with a bad status code (%(status)s)" +msgstr "" + +#: formencode/validators.py:1461 +#, python-format +msgid "You must provide a full domain name (like %(domain)s.com)" +msgstr "" + +#: formencode/validators.py:1602 +msgid "" +"The type of i-name is not defined; it may be either individual or " +"organizational" +msgstr "" + +#: formencode/validators.py:1604 +msgid "Dots and dashes may not be repeated consecutively" +msgstr "" + +#: formencode/validators.py:1605 +#, python-format +msgid "\"%(iname)s\" is an invalid i-name" +msgstr "" + +#: formencode/validators.py:1606 +msgid "i-names may not start with numbers nor punctuation marks" +msgstr "" + +#: formencode/validators.py:1608 +#, python-format +msgid "\"%(inumber)s\" is an invalid i-number" +msgstr "" + +#: formencode/validators.py:1609 +#, python-format +msgid "The XRI must be a string (not a %(type)s: %(value)r)" +msgstr "" + +#: formencode/validators.py:1610 +#, python-format +msgid "\"%(xri_type)s\" is not a valid type of XRI" +msgstr "" + +#: formencode/validators.py:1709 +#, python-format +msgid "\"%(id)s\" is not a valid OpenId (it is neither an URL nor an XRI)" +msgstr "" + +#: formencode/validators.py:1941 formencode/validators.py:1949 +#, python-format +msgid "Please enter the date in the form %(format)s" +msgstr "" + +#: formencode/validators.py:1942 +msgid "Please enter a month from 1 to 12" +msgstr "" + +#: formencode/validators.py:1943 +msgid "Please enter a valid day" +msgstr "" + +#: formencode/validators.py:1944 +#, python-format +msgid "That month only has %(days)i days" +msgstr "" + +#: formencode/validators.py:1945 +#, python-format +msgid "That is not a valid day (%(exception)s)" +msgstr "" + +#: formencode/validators.py:1946 +#, python-format +msgid "Unknown month name: %(month)s" +msgstr "" + +#: formencode/validators.py:1947 +msgid "Please enter a number for the year" +msgstr "" + +#: formencode/validators.py:1948 +msgid "Please enter a four-digit year after 1899" +msgstr "" + +#: formencode/validators.py:2131 +msgid "You must indicate AM or PM" +msgstr "" + +#: formencode/validators.py:2132 +msgid "There are too many :'s" +msgstr "" + +#: formencode/validators.py:2133 +msgid "You may not enter seconds" +msgstr "" + +#: formencode/validators.py:2134 +msgid "You must enter seconds" +msgstr "" + +#: formencode/validators.py:2135 +msgid "You must enter minutes (after a :)" +msgstr "" + +#: formencode/validators.py:2136 +#, python-format +msgid "The %(part)s value you gave is not a number: %(number)r" +msgstr "" + +#: formencode/validators.py:2137 +#, python-format +msgid "You must enter an hour in the range %(range)s" +msgstr "" + +#: formencode/validators.py:2138 +msgid "You must enter a minute in the range 0-59" +msgstr "" + +#: formencode/validators.py:2139 +msgid "You must enter a second in the range 0-59" +msgstr "" + +#: formencode/validators.py:2285 +#, python-format +msgid "The name %(name)s is missing" +msgstr "" + +#: formencode/validators.py:2328 +#, python-format +msgid "Value should be %(true)r or %(false)r" +msgstr "" + +#: formencode/validators.py:2363 +msgid "Value does not contain a signature" +msgstr "" + +#: formencode/validators.py:2364 +msgid "Signature is not correct" +msgstr "" + +#: formencode/validators.py:2439 +msgid "Please enter a valid IP address (a.b.c.d)" +msgstr "" + +#: formencode/validators.py:2440 +msgid "The octets must not have leading zeros" +msgstr "" + +#: formencode/validators.py:2441 +#, python-format +msgid "The octets must be within the range of 0-255 (not %(octet)r)" +msgstr "" + +#: formencode/validators.py:2496 +msgid "Please enter a valid IP address (a.b.c.d) or IP network (a.b.c.d/e)" +msgstr "" + +#: formencode/validators.py:2498 +#, python-format +msgid "The network size (bits) must be within the range of 8-32 (not %(bits)r)" +msgstr "" + +#: formencode/validators.py:2547 +#, python-format +msgid "" +"A MAC address must contain 12 digits and A-F; the value you gave has " +"%(length)s characters" +msgstr "" + +#: formencode/validators.py:2549 +#, python-format +msgid "MAC addresses may only contain 0-9 and A-F (and optionally :), not %(char)r" +msgstr "" + +#: formencode/validators.py:2657 +#, python-format +msgid "You must give a value for %s" +msgstr "" + +#: formencode/validators.py:2691 +#, python-format +msgid "Fields do not match (should be %(match)s)" +msgstr "" + +#: formencode/validators.py:2692 +msgid "Fields do not match" +msgstr "" + +#: formencode/validators.py:2693 +msgid "Fields should be a dictionary" +msgstr "" + +#: formencode/validators.py:2769 +msgid "Please enter only the number, no other characters" +msgstr "" + +#: formencode/validators.py:2770 +msgid "You did not enter a valid number of digits" +msgstr "" + +#: formencode/validators.py:2771 +msgid "That number is not valid" +msgstr "" + +#: formencode/validators.py:2772 +#, python-format +msgid "The field %(key)s is missing" +msgstr "" + +#: formencode/validators.py:2888 +msgid "Please enter numbers only for month and year" +msgstr "" + +#: formencode/validators.py:2889 +msgid "Invalid Expiration Date" +msgstr "" + +#: formencode/validators.py:2964 +msgid "Please enter numbers only for credit card security code" +msgstr "" + +#: formencode/validators.py:2965 +msgid "Invalid credit card security code length" +msgstr "" + diff --git a/formencode/i18n/ru/LC_MESSAGES/FormEncode.mo b/formencode/i18n/ru/LC_MESSAGES/FormEncode.mo index 7611b61efaf5f0078d7a50ca599e1166b4b59220..d1a7264a20f8fef898ea4585d7885e3e640c2f2a 100644 GIT binary patch delta 1922 zcma*me@N7K9LMo@q*+&MSz1|IUt8(5yz9KQmi_QF)YPChFACFsA6AsodAZTAYs;va zRAfOLk}DWngJK~vqa>pLVq+FWmeC&@NkP!>jcpBjzPN+_O*kK)&-eTNd_V6WpYMMg z?}nleMkky!{_6Rq^J^Wf*}K0tL(Bq9|3?QGCYepeH8>rcF$XVT5%yy?W(+m+VF?by zCalJN=*E5wm_;pty9Hb*LDt&7xQB2Q^J6#?&)`J-85QWSn2V3mgA-k5d037axEJ%W z9ldx9$KashvA|O?gZ-_L!EA2S;shh3*^Efg5$d43$_tYW*?P^XE|eT}!6^TKEqaf|yC&S7H+?(%(^;KEbg#js{LcFREoh z)N_Zi41dJ=_zV?*hxBy@g7^ux;4-|9wV0Ah{q^E7byp?6MwR{toQXG38~z)=@9?k! zT8L`JW>gFI$32f8=66uGwbJ|09FsaJscP@ZeiG3sFfYCbvx;CIDJ`5hP9deeG3&n0~^VoJk?NGQ_iY}?Toaq1f)&Zc!u zA!lo7-Nw!Jbb_2lL`zF7r+{|sMVXK;K;N>*@F$a#-9oXYt# F@hya+;t&7; delta 1833 zcmYMzeQ1?c7y$57)AnI2KW1(<*V3l0xp}8;b05KVt64U)n&Plow44!{43&%u?vxcl z1Fp8ZU!~tjLG=FrT)ZKrtnMXNv!O7hJGp_i+{5L3k85~>OIcc!Qie?|=5}u3 z5SQ@;vnl1$KN@W=GX#pl?{ zt1RQ{o2N^*o{_m-j0_!ME*c+dwD1I%vq0V>wHZc#fbrr3jL42~36C-|^c|z-f3u3^ zbEfaNFamp=F@Biw{2|7CN9V|Y44iafBj?C_AGb4B`Z*)gA9xE36|ja?jFR2Ucx z z_j%UqA7;GgBz@Cmf3d(KVc*IcMrpEK#TRoLvBHlyd0k59nbrTsEY+NAR2;Wej0yYL z$^CqaUvVXC9gX|h&ti^q3qQ_ZFR_Z~_ww3&jLn)mpKtudm}rXjO{x@jthA2p9AqQM zxS6LJrK(f#*ySVK$Wz?In%k!Xc$cx@V>BdPWiueYzN^d$TF8rSh0qh=X9 zC?em-C-?!|I7^-*f^Np9e2B4-&2&)G`z+y6cJny*v0(9Z>R(|+oc~WWvTmHtTP6)7 z`kPqI@7cmDjD@VSF}k>waXQ8rnL5cRMUiMCpmu+88U`rnw2v8%F*5ZnyUm}LIs!f1 z$p#){4EU1~S;?~L7tUkUu8mQO-Hc5+p1*&Jv9KwsVrsWquSk7-n!}6*T;L8?7@Uh* zy{Zudt}tF$UN?PiyBMh+WGwJ7EjnG|T9ygFgZ+GfhZrUNol&~1BQeT@jM`U;u8AFa zcQwd=Y^EbFWEp2K9$3R}?qwXS&)Cb0+{COf9^u=(hZpFZmPktkvYFA}!zj%-2lz81 zgPl>QMK#Nw**0-~;fm6UzOuzLW@qX%P4$h<)s3xfjg57gl@qU*-&Zy, 2008. -# -msgid "" -msgstr "" -"Project-Id-Version: FormEncode 0.6\n" -"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2010-05-16 19:11+0200\n" -"PO-Revision-Date: 2010-05-16 04:32+0200\n" -"Last-Translator: Oleg Deribas \n" -"Language-Team: RUSSIAN \n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " -"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 1.0dev-r546\n" - -#: formencode/api.py:394 formencode/validators.py:418 -msgid "Please enter a value" -msgstr "Необходимо ввести значение" - -#: formencode/api.py:395 -#, python-format -msgid "The input must be a string (not a %(type)s: %(value)r)" -msgstr "Необходимо ввести строку (а не %(type)s: %(value)r)" - -#: formencode/api.py:396 -msgid "The input must be a string (not None)" -msgstr "Необходимо ввести строку (не None)" - -#: formencode/national.py:29 -msgid "Belarus" -msgstr "" - -#: formencode/national.py:30 -msgid "Montenegro" -msgstr "" - -#: formencode/national.py:31 -msgid "Tasmania" -msgstr "" - -#: formencode/national.py:37 -msgid "Britain" -msgstr "" - -#: formencode/national.py:38 -msgid "Great Britain" -msgstr "" - -#: formencode/national.py:39 -msgid "Cote de Ivoire" -msgstr "" - -#: formencode/national.py:144 -#, python-format -msgid "%d digits" -msgstr "" - -#: formencode/national.py:165 -#, python-format -msgid "Please enter a zip code (%(format)s)" -msgstr "Введите zip-код (%(format)s)" - -#: formencode/national.py:229 formencode/national.py:263 -#, python-format -msgid "Please enter a zip code (%s)" -msgstr "Введите zip-код (%s)" - -#: formencode/national.py:229 -msgid "LnnnnLLL" -msgstr "" - -#: formencode/national.py:263 -msgid "LnL nLn" -msgstr "" - -#: formencode/national.py:297 -msgid "Please enter a valid postal code (for format see BS 7666)" -msgstr "" - -#: formencode/national.py:338 -msgid "That country is not listed in ISO 3166" -msgstr "" - -#: formencode/national.py:393 -msgid "Given postal code does not match the country's format." -msgstr "" - -#: formencode/national.py:484 -msgid "Please enter a state code" -msgstr "Введите код штата" - -#: formencode/national.py:485 -msgid "Please enter a state code with TWO letters" -msgstr "Введите код штата из ДВУХ букв" - -#: formencode/national.py:486 -msgid "That is not a valid state code" -msgstr "Неправильный код штата" - -#: formencode/national.py:539 -msgid "" -"Please enter a number, with area code, in the form ###-###-####, " -"optionally with \"ext.####\"" -msgstr "" -"Введите номер с кодом города в виде ###-###-####, возможно с дополнением " -"\"ext.####\"" - -#: formencode/national.py:646 -#, fuzzy -msgid "Please enter a number, with area code, in the form +##-###-#######." -msgstr "" -"Введите номер с кодом города в виде ###-###-####, возможно с дополнением " -"\"ext.####\"" - -#: formencode/national.py:725 -msgid "That language is not listed in ISO 639" -msgstr "" - -#: formencode/schema.py:63 -#, python-format -msgid "The input field %(name)s was not expected." -msgstr "" - -#: formencode/schema.py:64 -msgid "Missing value" -msgstr "" - -#: formencode/schema.py:65 -#, fuzzy, python-format -msgid "The input must be dict-like (not a %(type)s: %(value)r)" -msgstr "Необходимо ввести строку (а не %(type)s: %(value)r)" - -#: formencode/validators.py:147 -#, python-format -msgid "%(object)r is not a subclass of %(subclass)s" -msgstr "%(object)r не является подклассом %(subclass)s" - -#: formencode/validators.py:148 -#, python-format -msgid "%(object)r is not a subclass of one of the types %(subclassList)s" -msgstr "%(object)r не является подклассом одного из типов %(subclassList)s" - -#: formencode/validators.py:149 -#, python-format -msgid "%(object)r must be one of the types %(typeList)s" -msgstr "%(object)r должен быть одним из типов %(typeList)s" - -#: formencode/validators.py:150 -#, python-format -msgid "%(object)r must be of the type %(type)s" -msgstr "%(object)r должен быть типа %(type)s" - -#: formencode/validators.py:330 -#, python-format -msgid "Enter a value less than %(maxLength)i characters long" -msgstr "Введите значение меньшее чем %(maxLength)i символов" - -#: formencode/validators.py:331 formencode/validators.py:385 -msgid "Invalid value (value with length expected)" -msgstr "Неправильное значение (ожидается значение с длиной)" - -#: formencode/validators.py:384 -#, python-format -msgid "Enter a value at least %(minLength)i characters long" -msgstr "Длина значения должна быть не меньше чем %(minLength)i" - -#: formencode/validators.py:441 -msgid "You cannot enter a value here" -msgstr "Сюда значение вводить нельзя" - -#: formencode/validators.py:490 -msgid "The input is not valid" -msgstr "Неправильный ввод" - -#: formencode/validators.py:543 -msgid "Enter only letters, numbers, or _ (underscore)" -msgstr "Допускается ввод только букв, чисел или _ (знаков подчеркивания)" - -#: formencode/validators.py:581 -msgid "Invalid value" -msgstr "Неправильное значение" - -#: formencode/validators.py:582 -#, python-format -msgid "Value must be one of: %(items)s (not %(value)r)" -msgstr "Значение должно быть одним из: %(items)s (но не %(value)r)" - -#: formencode/validators.py:640 -msgid "Choose something" -msgstr "Выберите что-нибудь" - -#: formencode/validators.py:641 -#, python-format -msgid "Enter a value from: %(items)s" -msgstr "Введите одно из следующих значений: %(items)s" - -#: formencode/validators.py:642 -msgid "That value is not known" -msgstr "Неизвестное значение" - -#: formencode/validators.py:643 -#, python-format -msgid "" -"Nothing in my dictionary goes by the value %(value)s. Choose one of: " -"%(items)s" -msgstr "" -"В моем словаре нет совпадений с значением %(value)s. Выберите одно из: " -"%(items)s" - -#: formencode/validators.py:705 -msgid "Must be an integer index" -msgstr "Индекс должен быть числовым значением" - -#: formencode/validators.py:706 -msgid "Index out of range" -msgstr "Неправильный индекс " - -#: formencode/validators.py:707 -#, python-format -msgid "Item %(value)s was not found in the list" -msgstr "Пункт %(value)s отсутствуетв списке" - -#: formencode/validators.py:777 -#, python-format -msgid "Date must be after %(date)s" -msgstr "Дата должна быть позже чем %(date)s" - -#: formencode/validators.py:778 -#, python-format -msgid "Date must be before %(date)s" -msgstr "Дата должна быть раньше чем %(date)s" - -#: formencode/validators.py:780 -#, fuzzy, python-format -msgid "%%A, %%d %%B %%Y" -msgstr "" - -#: formencode/validators.py:781 -msgid "The date must be sometime in the future" -msgstr "Дата должна быть в будущем" - -#: formencode/validators.py:882 -#, python-format -msgid "Please enter a number that is %(min)s or greater" -msgstr "Введите число больше или равно %(min)s" - -#: formencode/validators.py:883 -#, fuzzy, python-format -msgid "Please enter a number that is %(max)s or smaller" -msgstr "Введите число меньше или равно %(max)s" - -#: formencode/validators.py:920 -msgid "Please enter an integer value" -msgstr "Введите числовое значение" - -#: formencode/validators.py:958 -msgid "Please enter a number" -msgstr "Введите число" - -#: formencode/validators.py:1019 -#, fuzzy, python-format -msgid "Enter a value not more than %(max)i characters long" -msgstr "Введите значение длиной не более %(max)i символов" - -#: formencode/validators.py:1020 -#, python-format -msgid "Enter a value %(min)i characters long or more" -msgstr "Введите значение длиной %(min)i или более символов" - -#: formencode/validators.py:1095 -msgid "Invalid data or incorrect encoding" -msgstr "Неправильные данные или неверная кодировка" - -#: formencode/validators.py:1267 -msgid "Please enter an email address" -msgstr "Введите email адрес" - -#: formencode/validators.py:1268 -msgid "An email address must contain a single @" -msgstr "email адрес должен содержать один символ @" - -#: formencode/validators.py:1269 -#, python-format -msgid "" -"The username portion of the email address is invalid (the portion before " -"the @: %(username)s)" -msgstr "" -"Неправильное имя пользователя в email адресе (часть адреса до символа @: " -"%(username)s)" - -#: formencode/validators.py:1271 formencode/validators.py:1413 -#, python-format -msgid "An error occured when trying to connect to the server: %(error)s" -msgstr "При подключении к серверу произошла ошибка: %(error)s" - -#: formencode/validators.py:1273 -#, python-format -msgid "" -"The domain portion of the email address is invalid (the portion after the" -" @: %(domain)s)" -msgstr "Неверная доменная часть email адреса (часть после символа @: %(domain)s)" - -#: formencode/validators.py:1275 -#, python-format -msgid "" -"The domain of the email address does not exist (the portion after the @: " -"%(domain)s)" -msgstr "Домен email адреса не существует (часть после символа @: %(domain)s)" - -#: formencode/validators.py:1409 -msgid "You must start your URL with http://, https://, etc" -msgstr "Сетевой адрес (URL) должен начинаться с http://, https://, и т. д." - -#: formencode/validators.py:1410 -msgid "That is not a valid URL" -msgstr "Неправильный сетевой адрес (URL)" - -#: formencode/validators.py:1411 -#, python-format -msgid "An error occurred when trying to access the URL: %(error)s" -msgstr "Ошибка доступа по адресу: %(error)s" - -#: formencode/validators.py:1415 -msgid "The server responded that the page could not be found" -msgstr "Сервер сообщает что страница не найдена" - -#: formencode/validators.py:1416 -#, python-format -msgid "The server responded with a bad status code (%(status)s)" -msgstr "Неправильный статусный код ответа сервера: (%(status)s)" - -#: formencode/validators.py:1417 -#, python-format -msgid "You must provide a full domain name (like %(domain)s.com)" -msgstr "" - -#: formencode/validators.py:1544 -msgid "" -"The type of i-name is not defined; it may be either individual or " -"organizational" -msgstr "" - -#: formencode/validators.py:1546 -msgid "Dots and dashes may not be repeated consecutively" -msgstr "" - -#: formencode/validators.py:1547 -#, python-format -msgid "\"%(iname)s\" is an invalid i-name" -msgstr "" - -#: formencode/validators.py:1548 -msgid "i-names may not start with numbers nor punctuation marks" -msgstr "" - -#: formencode/validators.py:1550 -#, python-format -msgid "\"%(inumber)s\" is an invalid i-number" -msgstr "" - -#: formencode/validators.py:1551 -#, fuzzy, python-format -msgid "The XRI must be a string (not a %(type)s: %(value)r)" -msgstr "Необходимо ввести строку (а не %(type)s: %(value)r)" - -#: formencode/validators.py:1552 -#, python-format -msgid "\"%(xri_type)s\" is not a valid type of XRI" -msgstr "" - -#: formencode/validators.py:1651 -#, python-format -msgid "\"%(id)s\" is not a valid OpenId (it is neither an URL nor an XRI)" -msgstr "" - -#: formencode/validators.py:1882 formencode/validators.py:1890 -#, python-format -msgid "Please enter the date in the form %(format)s" -msgstr "Введите дату в виде %(format)s" - -#: formencode/validators.py:1883 -msgid "Please enter a month from 1 to 12" -msgstr "ведите номер месяца от 1 до 12" - -#: formencode/validators.py:1884 -msgid "Please enter a valid day" -msgstr "Введите правильный день" - -#: formencode/validators.py:1885 -#, python-format -msgid "That month only has %(days)i days" -msgstr "Этот месяц содержит только %(days)i дней" - -#: formencode/validators.py:1886 -#, python-format -msgid "That is not a valid day (%(exception)s)" -msgstr "Неправильный день (%(exception)s)" - -#: formencode/validators.py:1887 -#, python-format -msgid "Unknown month name: %(month)s" -msgstr "Неизвестное имя месяца: %(month)s" - -#: formencode/validators.py:1888 -msgid "Please enter a number for the year" -msgstr "Введите числовое значение для года" - -#: formencode/validators.py:1889 -#, fuzzy -msgid "Please enter a four-digit year after 1899" -msgstr "Введите четырехзначный год" - -#: formencode/validators.py:2070 -msgid "You must indicate AM or PM" -msgstr "Необходимо указать AM или PM" - -#: formencode/validators.py:2071 -msgid "There are too many :'s" -msgstr "Слишком много :'s" - -#: formencode/validators.py:2072 -msgid "You may not enter seconds" -msgstr "Секунды можно не вводить" - -#: formencode/validators.py:2073 -msgid "You must enter seconds" -msgstr "Необходимо ввести секунды" - -#: formencode/validators.py:2074 -msgid "You must enter minutes (after a :)" -msgstr "Необходимо ввести минуты (после :)" - -#: formencode/validators.py:2075 -#, python-format -msgid "The %(part)s value you gave is not a number: %(number)r" -msgstr "Вы ввели значение %(part)s которое не является числом: %(number)r" - -#: formencode/validators.py:2076 -#, python-format -msgid "You must enter an hour in the range %(range)s" -msgstr "Значение часов должно быть в диапазоне %(range)s" - -#: formencode/validators.py:2077 -msgid "You must enter a minute in the range 0-59" -msgstr "Необходимо ввести минуты в диапазоне от 0 до 59" - -#: formencode/validators.py:2078 -msgid "You must enter a second in the range 0-59" -msgstr "Необходимо ввести секунды в диапазоне от 0 до 59" - -#: formencode/validators.py:2224 -#, python-format -msgid "The name %(name)s is missing" -msgstr "Отсутствует имя %(name)s" - -#: formencode/validators.py:2267 -#, python-format -msgid "Value should be %(true)r or %(false)r" -msgstr "Значение должно быть %(true)r или %(false)r" - -#: formencode/validators.py:2302 -msgid "Value does not contain a signature" -msgstr "Значение не содержит подписи" - -#: formencode/validators.py:2303 -msgid "Signature is not correct" -msgstr "Неверная подпись" - -#: formencode/validators.py:2378 -msgid "Please enter a valid IP address (a.b.c.d)" -msgstr "" - -#: formencode/validators.py:2379 -#, python-format -msgid "The octets must be within the range of 0-255 (not %(octet)r)" -msgstr "" - -#: formencode/validators.py:2426 -msgid "Please enter a valid IP address (a.b.c.d) or IP network (a.b.c.d/e)" -msgstr "" - -#: formencode/validators.py:2428 -#, python-format -msgid "The network size (bits) must be within the range of 8-32 (not %(bits)r)" -msgstr "" - -#: formencode/validators.py:2477 -#, python-format -msgid "" -"A MAC address must contain 12 digits and A-F; the value you gave has " -"%(length)s characters" -msgstr "" - -#: formencode/validators.py:2479 -#, python-format -msgid "" -"MAC addresses may only contain 0-9 and A-F (and optionally :), not " -"%(char)r" -msgstr "" - -#: formencode/validators.py:2586 -#, python-format -msgid "You must give a value for %s" -msgstr "" - -#: formencode/validators.py:2619 -#, python-format -msgid "Fields do not match (should be %(match)s)" -msgstr "Поля не совпадают (должно быть %(match)s)" - -#: formencode/validators.py:2620 -msgid "Fields do not match" -msgstr "Поля не совпадают" - -#: formencode/validators.py:2621 -msgid "Fields should be a dictionary" -msgstr "" - -#: formencode/validators.py:2697 -msgid "Please enter only the number, no other characters" -msgstr "Введите только номер, без прочих символов" - -#: formencode/validators.py:2698 -msgid "You did not enter a valid number of digits" -msgstr "Вы ввели неправильное количество цифр" - -#: formencode/validators.py:2699 -msgid "That number is not valid" -msgstr "Неверный номер " - -#: formencode/validators.py:2700 -#, python-format -msgid "The field %(key)s is missing" -msgstr "" - -#: formencode/validators.py:2816 -msgid "Please enter numbers only for month and year" -msgstr "Введите числа только для месяца и года" - -#: formencode/validators.py:2817 -msgid "Invalid Expiration Date" -msgstr "Неправильная дата окончания периода обслуживания" - -#: formencode/validators.py:2892 -msgid "Please enter numbers only for credit card security code" -msgstr "Введите числа только для кода кредитной карты" - -#: formencode/validators.py:2893 -msgid "Invalid credit card security code length" -msgstr "Неправильная длина кода кредитной карты" - +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2008 ORGANIZATION +# FIRST AUTHOR , 2008. +# +msgid "" +msgstr "" +"Project-Id-Version: FormEncode 0.6\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2012-09-14 03:22+0400\n" +"PO-Revision-Date: 2010-05-16 04:32+0200\n" +"Last-Translator: Oleg Deribas \n" +"Language-Team: RUSSIAN \n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 0.9.6\n" + +#: formencode/api.py:401 formencode/validators.py:432 +msgid "Please enter a value" +msgstr "Необходимо ввести значение" + +#: formencode/api.py:402 +#, python-format +msgid "The input must be a string (not a %(type)s: %(value)r)" +msgstr "Необходимо ввести строку (а не %(type)s: %(value)r)" + +#: formencode/api.py:403 +msgid "The input must be a string (not None)" +msgstr "Необходимо ввести строку (не None)" + +#: formencode/national.py:31 +msgid "Belarus" +msgstr "" + +#: formencode/national.py:32 +msgid "Montenegro" +msgstr "" + +#: formencode/national.py:33 +msgid "Tasmania" +msgstr "" + +#: formencode/national.py:39 +msgid "Britain" +msgstr "" + +#: formencode/national.py:40 +msgid "Great Britain" +msgstr "" + +#: formencode/national.py:41 +msgid "Cote de Ivoire" +msgstr "" + +#: formencode/national.py:146 +#, python-format +msgid "%d digits" +msgstr "" + +#: formencode/national.py:167 +#, python-format +msgid "Please enter a zip code (%(format)s)" +msgstr "Введите zip-код (%(format)s)" + +#: formencode/national.py:231 formencode/national.py:265 +#, python-format +msgid "Please enter a zip code (%s)" +msgstr "Введите zip-код (%s)" + +#: formencode/national.py:231 +msgid "LnnnnLLL" +msgstr "" + +#: formencode/national.py:265 +msgid "LnL nLn" +msgstr "" + +#: formencode/national.py:299 +msgid "Please enter a valid postal code (for format see BS 7666)" +msgstr "" + +#: formencode/national.py:340 +msgid "That country is not listed in ISO 3166" +msgstr "" + +#: formencode/national.py:395 +msgid "Given postal code does not match the country's format." +msgstr "" + +#: formencode/national.py:486 +msgid "Please enter a state code" +msgstr "Введите код штата" + +#: formencode/national.py:487 +msgid "Please enter a state code with TWO letters" +msgstr "Введите код штата из ДВУХ букв" + +#: formencode/national.py:488 +msgid "That is not a valid state code" +msgstr "Неправильный код штата" + +#: formencode/national.py:541 +msgid "" +"Please enter a number, with area code, in the form ###-###-####, " +"optionally with \"ext.####\"" +msgstr "" +"Введите номер с кодом города в виде ###-###-####, возможно с дополнением " +"\"ext.####\"" + +#: formencode/national.py:648 +#, fuzzy +msgid "Please enter a number, with area code, in the form +##-###-#######." +msgstr "" +"Введите номер с кодом города в виде ###-###-####, возможно с дополнением " +"\"ext.####\"" + +#: formencode/national.py:727 +msgid "That language is not listed in ISO 639" +msgstr "" + +#: formencode/schema.py:68 +#, python-format +msgid "The input field %(name)s was not expected." +msgstr "" + +#: formencode/schema.py:69 +msgid "Missing value" +msgstr "" + +#: formencode/schema.py:70 +#, fuzzy, python-format +msgid "The input must be dict-like (not a %(type)s: %(value)r)" +msgstr "Необходимо ввести строку (а не %(type)s: %(value)r)" + +#: formencode/schema.py:72 +#, fuzzy +#| msgid "Please enter a value" +msgid "Please provide only one value" +msgstr "Пожалуйста, укажите только одно значение" + +#: formencode/validators.py:150 +#, python-format +msgid "%(object)r is not a subclass of %(subclass)s" +msgstr "%(object)r не является подклассом %(subclass)s" + +#: formencode/validators.py:151 +#, python-format +msgid "%(object)r is not a subclass of one of the types %(subclassList)s" +msgstr "%(object)r не является подклассом одного из типов %(subclassList)s" + +#: formencode/validators.py:152 +#, python-format +msgid "%(object)r must be one of the types %(typeList)s" +msgstr "%(object)r должен быть одним из типов %(typeList)s" + +#: formencode/validators.py:153 +#, python-format +msgid "%(object)r must be of the type %(type)s" +msgstr "%(object)r должен быть типа %(type)s" + +#: formencode/validators.py:344 +#, python-format +msgid "Enter a value less than %(maxLength)i characters long" +msgstr "Введите значение меньшее чем %(maxLength)i символов" + +#: formencode/validators.py:345 formencode/validators.py:399 +msgid "Invalid value (value with length expected)" +msgstr "Неправильное значение (ожидается значение с длиной)" + +#: formencode/validators.py:398 +#, python-format +msgid "Enter a value at least %(minLength)i characters long" +msgstr "Длина значения должна быть не меньше чем %(minLength)i" + +#: formencode/validators.py:455 +msgid "You cannot enter a value here" +msgstr "Сюда значение вводить нельзя" + +#: formencode/validators.py:504 +msgid "The input is not valid" +msgstr "Неправильный ввод" + +#: formencode/validators.py:557 +msgid "Enter only letters, numbers, or _ (underscore)" +msgstr "Допускается ввод только букв, чисел или _ (знаков подчеркивания)" + +#: formencode/validators.py:595 +msgid "Invalid value" +msgstr "Неправильное значение" + +#: formencode/validators.py:596 +#, python-format +msgid "Value must be one of: %(items)s (not %(value)r)" +msgstr "Значение должно быть одним из: %(items)s (но не %(value)r)" + +#: formencode/validators.py:657 +msgid "Choose something" +msgstr "Выберите что-нибудь" + +#: formencode/validators.py:658 +#, python-format +msgid "Enter a value from: %(items)s" +msgstr "Введите одно из следующих значений: %(items)s" + +#: formencode/validators.py:659 +msgid "That value is not known" +msgstr "Неизвестное значение" + +#: formencode/validators.py:660 +#, python-format +msgid "" +"Nothing in my dictionary goes by the value %(value)s. Choose one of: " +"%(items)s" +msgstr "" +"В моем словаре нет совпадений с значением %(value)s. Выберите одно из: " +"%(items)s" + +#: formencode/validators.py:724 +msgid "Must be an integer index" +msgstr "Индекс должен быть числовым значением" + +#: formencode/validators.py:725 +msgid "Index out of range" +msgstr "Неправильный индекс " + +#: formencode/validators.py:726 +#, python-format +msgid "Item %(value)s was not found in the list" +msgstr "Пункт %(value)s отсутствуетв списке" + +#: formencode/validators.py:796 +#, python-format +msgid "Date must be after %(date)s" +msgstr "Дата должна быть позже чем %(date)s" + +#: formencode/validators.py:797 +#, python-format +msgid "Date must be before %(date)s" +msgstr "Дата должна быть раньше чем %(date)s" + +#: formencode/validators.py:799 +#, fuzzy, python-format +msgid "%%A, %%d %%B %%Y" +msgstr "" + +#: formencode/validators.py:800 +msgid "The date must be sometime in the future" +msgstr "Дата должна быть в будущем" + +#: formencode/validators.py:901 +#, python-format +msgid "Please enter a number that is %(min)s or greater" +msgstr "Введите число больше или равно %(min)s" + +#: formencode/validators.py:902 +#, fuzzy, python-format +msgid "Please enter a number that is %(max)s or smaller" +msgstr "Введите число меньше или равно %(max)s" + +#: formencode/validators.py:939 +msgid "Please enter an integer value" +msgstr "Введите числовое значение" + +#: formencode/validators.py:975 +msgid "Please enter a number" +msgstr "Введите число" + +#: formencode/validators.py:1036 +#, fuzzy, python-format +msgid "Enter a value not more than %(max)i characters long" +msgstr "Введите значение длиной не более %(max)i символов" + +#: formencode/validators.py:1037 +#, python-format +msgid "Enter a value %(min)i characters long or more" +msgstr "Введите значение длиной %(min)i или более символов" + +#: formencode/validators.py:1119 +msgid "Invalid data or incorrect encoding" +msgstr "Неправильные данные или неверная кодировка" + +#: formencode/validators.py:1290 +msgid "Please enter an email address" +msgstr "Введите email адрес" + +#: formencode/validators.py:1291 +msgid "An email address must contain a single @" +msgstr "email адрес должен содержать один символ @" + +#: formencode/validators.py:1292 +#, python-format +msgid "" +"The username portion of the email address is invalid (the portion before " +"the @: %(username)s)" +msgstr "" +"Неправильное имя пользователя в email адресе (часть адреса до символа @: " +"%(username)s)" + +#: formencode/validators.py:1294 formencode/validators.py:1457 +#, python-format +msgid "An error occured when trying to connect to the server: %(error)s" +msgstr "При подключении к серверу произошла ошибка: %(error)s" + +#: formencode/validators.py:1296 +#, python-format +msgid "" +"The domain portion of the email address is invalid (the portion after the" +" @: %(domain)s)" +msgstr "Неверная доменная часть email адреса (часть после символа @: %(domain)s)" + +#: formencode/validators.py:1298 +#, python-format +msgid "" +"The domain of the email address does not exist (the portion after the @: " +"%(domain)s)" +msgstr "Домен email адреса не существует (часть после символа @: %(domain)s)" + +#: formencode/validators.py:1453 +msgid "You must start your URL with http://, https://, etc" +msgstr "Сетевой адрес (URL) должен начинаться с http://, https://, и т. д." + +#: formencode/validators.py:1454 +msgid "That is not a valid URL" +msgstr "Неправильный сетевой адрес (URL)" + +#: formencode/validators.py:1455 +#, python-format +msgid "An error occurred when trying to access the URL: %(error)s" +msgstr "Ошибка доступа по адресу: %(error)s" + +#: formencode/validators.py:1459 +msgid "The server responded that the page could not be found" +msgstr "Сервер сообщает что страница не найдена" + +#: formencode/validators.py:1460 +#, python-format +msgid "The server responded with a bad status code (%(status)s)" +msgstr "Неправильный статусный код ответа сервера: (%(status)s)" + +#: formencode/validators.py:1461 +#, python-format +msgid "You must provide a full domain name (like %(domain)s.com)" +msgstr "" + +#: formencode/validators.py:1602 +msgid "" +"The type of i-name is not defined; it may be either individual or " +"organizational" +msgstr "" + +#: formencode/validators.py:1604 +msgid "Dots and dashes may not be repeated consecutively" +msgstr "" + +#: formencode/validators.py:1605 +#, python-format +msgid "\"%(iname)s\" is an invalid i-name" +msgstr "" + +#: formencode/validators.py:1606 +msgid "i-names may not start with numbers nor punctuation marks" +msgstr "" + +#: formencode/validators.py:1608 +#, python-format +msgid "\"%(inumber)s\" is an invalid i-number" +msgstr "" + +#: formencode/validators.py:1609 +#, fuzzy, python-format +msgid "The XRI must be a string (not a %(type)s: %(value)r)" +msgstr "Необходимо ввести строку (а не %(type)s: %(value)r)" + +#: formencode/validators.py:1610 +#, python-format +msgid "\"%(xri_type)s\" is not a valid type of XRI" +msgstr "" + +#: formencode/validators.py:1709 +#, python-format +msgid "\"%(id)s\" is not a valid OpenId (it is neither an URL nor an XRI)" +msgstr "" + +#: formencode/validators.py:1941 formencode/validators.py:1949 +#, python-format +msgid "Please enter the date in the form %(format)s" +msgstr "Введите дату в виде %(format)s" + +#: formencode/validators.py:1942 +msgid "Please enter a month from 1 to 12" +msgstr "ведите номер месяца от 1 до 12" + +#: formencode/validators.py:1943 +msgid "Please enter a valid day" +msgstr "Введите правильный день" + +#: formencode/validators.py:1944 +#, python-format +msgid "That month only has %(days)i days" +msgstr "Этот месяц содержит только %(days)i дней" + +#: formencode/validators.py:1945 +#, python-format +msgid "That is not a valid day (%(exception)s)" +msgstr "Неправильный день (%(exception)s)" + +#: formencode/validators.py:1946 +#, python-format +msgid "Unknown month name: %(month)s" +msgstr "Неизвестное имя месяца: %(month)s" + +#: formencode/validators.py:1947 +msgid "Please enter a number for the year" +msgstr "Введите числовое значение для года" + +#: formencode/validators.py:1948 +#, fuzzy +msgid "Please enter a four-digit year after 1899" +msgstr "Введите четырехзначный год" + +#: formencode/validators.py:2131 +msgid "You must indicate AM or PM" +msgstr "Необходимо указать AM или PM" + +#: formencode/validators.py:2132 +msgid "There are too many :'s" +msgstr "Слишком много :'s" + +#: formencode/validators.py:2133 +msgid "You may not enter seconds" +msgstr "Секунды можно не вводить" + +#: formencode/validators.py:2134 +msgid "You must enter seconds" +msgstr "Необходимо ввести секунды" + +#: formencode/validators.py:2135 +msgid "You must enter minutes (after a :)" +msgstr "Необходимо ввести минуты (после :)" + +#: formencode/validators.py:2136 +#, python-format +msgid "The %(part)s value you gave is not a number: %(number)r" +msgstr "Вы ввели значение %(part)s которое не является числом: %(number)r" + +#: formencode/validators.py:2137 +#, python-format +msgid "You must enter an hour in the range %(range)s" +msgstr "Значение часов должно быть в диапазоне %(range)s" + +#: formencode/validators.py:2138 +msgid "You must enter a minute in the range 0-59" +msgstr "Необходимо ввести минуты в диапазоне от 0 до 59" + +#: formencode/validators.py:2139 +msgid "You must enter a second in the range 0-59" +msgstr "Необходимо ввести секунды в диапазоне от 0 до 59" + +#: formencode/validators.py:2285 +#, python-format +msgid "The name %(name)s is missing" +msgstr "Отсутствует имя %(name)s" + +#: formencode/validators.py:2328 +#, python-format +msgid "Value should be %(true)r or %(false)r" +msgstr "Значение должно быть %(true)r или %(false)r" + +#: formencode/validators.py:2363 +msgid "Value does not contain a signature" +msgstr "Значение не содержит подписи" + +#: formencode/validators.py:2364 +msgid "Signature is not correct" +msgstr "Неверная подпись" + +#: formencode/validators.py:2439 +msgid "Please enter a valid IP address (a.b.c.d)" +msgstr "" + +#: formencode/validators.py:2440 +msgid "The octets must not have leading zeros" +msgstr "" + +#: formencode/validators.py:2441 +#, python-format +msgid "The octets must be within the range of 0-255 (not %(octet)r)" +msgstr "" + +#: formencode/validators.py:2496 +msgid "Please enter a valid IP address (a.b.c.d) or IP network (a.b.c.d/e)" +msgstr "" + +#: formencode/validators.py:2498 +#, python-format +msgid "The network size (bits) must be within the range of 8-32 (not %(bits)r)" +msgstr "" + +#: formencode/validators.py:2547 +#, python-format +msgid "" +"A MAC address must contain 12 digits and A-F; the value you gave has " +"%(length)s characters" +msgstr "" + +#: formencode/validators.py:2549 +#, python-format +msgid "" +"MAC addresses may only contain 0-9 and A-F (and optionally :), not " +"%(char)r" +msgstr "" + +#: formencode/validators.py:2657 +#, python-format +msgid "You must give a value for %s" +msgstr "" + +#: formencode/validators.py:2691 +#, python-format +msgid "Fields do not match (should be %(match)s)" +msgstr "Поля не совпадают (должно быть %(match)s)" + +#: formencode/validators.py:2692 +msgid "Fields do not match" +msgstr "Поля не совпадают" + +#: formencode/validators.py:2693 +msgid "Fields should be a dictionary" +msgstr "" + +#: formencode/validators.py:2769 +msgid "Please enter only the number, no other characters" +msgstr "Введите только номер, без прочих символов" + +#: formencode/validators.py:2770 +msgid "You did not enter a valid number of digits" +msgstr "Вы ввели неправильное количество цифр" + +#: formencode/validators.py:2771 +msgid "That number is not valid" +msgstr "Неверный номер " + +#: formencode/validators.py:2772 +#, python-format +msgid "The field %(key)s is missing" +msgstr "" + +#: formencode/validators.py:2888 +msgid "Please enter numbers only for month and year" +msgstr "Введите числа только для месяца и года" + +#: formencode/validators.py:2889 +msgid "Invalid Expiration Date" +msgstr "Неправильная дата окончания периода обслуживания" + +#: formencode/validators.py:2964 +msgid "Please enter numbers only for credit card security code" +msgstr "Введите числа только для кода кредитной карты" + +#: formencode/validators.py:2965 +msgid "Invalid credit card security code length" +msgstr "Неправильная длина кода кредитной карты" + diff --git a/formencode/schema.py b/formencode/schema.py index bd8a697d..967e5a8b 100644 --- a/formencode/schema.py +++ b/formencode/schema.py @@ -1,11 +1,14 @@ +import warnings from interfaces import * from api import * from api import _ +import foreach import declarative -import warnings from exc import FERuntimeWarning + + __all__ = ['Schema'] @@ -65,7 +68,8 @@ class MySubSchema(MySchema): notExpected=_('The input field %(name)s was not expected.'), missingValue=_('Missing value'), badDictType=_('The input must be dict-like' - ' (not a %(type)s: %(value)r)')) + ' (not a %(type)s: %(value)r)'), + singleValueExpected=_('Please provide only one value'),) __mutableattributes__ = ('fields', 'chained_validators', 'pre_validators') @@ -158,12 +162,38 @@ def _to_python(self, value_dict, state): new[name] = value continue validator = self.fields[name] + + # Some data types require an extra check to be performed + # in order to guarantee unambiguous connection between + # input and output data. + # Let's say we have to validate two different URLS: + # 1. "site.com/?username=['John', 'Mike']" and + # 2. "site.com/?username=John&username=Mike" + # Without the following check, + # formencode.validators.String (and all other inherited validators) + # will set the username value to "['John', 'Mike']" for both URLs. + # In terms of URL design, it is considered bad if the same + # resource is accessible by two different URLs. + # Therefore, if you really want to validate a field with multiple + # values, you have to set self.allow_extra_fields to True or + # wrap the username validator with formencode.validators.ForEach() + if not self.allow_extra_fields and isinstance(value, (list, tuple)): + try: + bad_type = not issubclass(validator, foreach.ForEach) + except TypeError: + # TypeError: issubclass() arg 1 must be a class + bad_type = not isinstance(validator, foreach.ForEach) + if bad_type: + raise Invalid( + self.message('singleValueExpected', state), + value_dict, state + ) if state is not None: state.key = name try: new[name] = validator.to_python(value, state) - except Invalid, e: + except Invalid as e: errors[name] = e for name in unused: @@ -186,7 +216,7 @@ def _to_python(self, value_dict, state): state.key = name try: new[name] = validator.to_python(self.if_key_missing, state) - except Invalid, e: + except Invalid as e: errors[name] = e else: new[name] = validator.if_missing @@ -199,7 +229,7 @@ def _to_python(self, value_dict, state): continue try: validator.validate_partial(value_dict, state) - except Invalid, e: + except Invalid as e: sub_errors = e.unpack_errors() if not isinstance(sub_errors, dict): # Can't do anything here @@ -255,7 +285,7 @@ def _from_python(self, value_dict, state): state.key = name try: new[name] = self.fields[name].from_python(value, state) - except Invalid, e: + except Invalid as e: errors[name] = e del __traceback_info__ @@ -266,7 +296,7 @@ def _from_python(self, value_dict, state): state.key = name try: new[name] = validator.from_python(None, state) - except Invalid, e: + except Invalid as e: errors[name] = e if errors: diff --git a/tests/test_schema.py b/tests/test_schema.py index 61712bd3..ea60ea94 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -1,3 +1,5 @@ +import unittest + from formencode import validators, foreach from formencode.schema import Schema, merge_dicts, SimpleFormValidator from formencode.api import * @@ -73,7 +75,7 @@ def test(self): print repr(self.raw_input) try: print repr(self.schema.to_python(self.input)) - except Invalid, e: + except Invalid as e: actual = e.unpack_errors() assert actual == self.output else: @@ -173,11 +175,11 @@ def test_multiple_chained_validators_errors(): s = ChainedTest() try: s.to_python({'a':'1', 'a_confirm':'2', 'b':'3', 'b_confirm':'4'}) - except Invalid, e: + except Invalid as e: assert 'a_confirm' in e.error_dict and 'b_confirm' in e.error_dict try: s.to_python({}) - except Invalid, e: + except Invalid as e: pass else: assert False @@ -269,9 +271,52 @@ def test_Schema_with_input_missing(self): # try: self.schema.to_python({}) - except Invalid, exc: + except Invalid as exc: error_message = exc.error_dict['agree'].msg assert self.not_empty_messages['missing'] == error_message, \ error_message else: assert False, 'missing input not detected' + + +class TestStrictSchemaWithMultipleEqualInputFields(unittest.TestCase): + """Tests to address github bug #13""" + + def setUp(self): + + class StrictSchema(Schema): + allow_extra_fields = False + + class IntegerTestSchema(StrictSchema): + field = validators.Int(not_empty=True) + + class StringTestSchema(StrictSchema): + field = validators.UnicodeString(not_empty=True) + + class CorrectStringTestSchema(StrictSchema): + field = foreach.ForEach(validators.UnicodeString(not_empty=True)) + + self.int_schema = IntegerTestSchema() + self.string_schema = StringTestSchema() + self.correct_schema = CorrectStringTestSchema + + + def test_single_integer_value(self): + params = cgi_parse('field=111') + data = self.int_schema.to_python(params) + + def test_multiple_integer_value(self): + params = cgi_parse('field=111&field=222') + self.assertRaises(Invalid, self.int_schema.to_python, params) + + def test_single_string_value(self): + params = cgi_parse('field=string') + data = self.string_schema.to_python(params) + + def test_multiple_string_value(self): + params = cgi_parse('field=string1&field=string2') + self.assertRaises(Invalid, self.string_schema.to_python, params) + + def test_correct_multiple_string_value(self): + params = cgi_parse('field=string1&field=string2') + data = self.correct_schema.to_python(params) From 3a0ce732e06a21484e53410b666bd2edb37b340e Mon Sep 17 00:00:00 2001 From: Maxim Avanov Date: Sat, 15 Sep 2012 00:14:54 +0400 Subject: [PATCH 2/6] Back to 2.5 --- formencode/schema.py | 10 +++++----- tests/test_schema.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/formencode/schema.py b/formencode/schema.py index 967e5a8b..cb5ff7b6 100644 --- a/formencode/schema.py +++ b/formencode/schema.py @@ -193,7 +193,7 @@ def _to_python(self, value_dict, state): state.key = name try: new[name] = validator.to_python(value, state) - except Invalid as e: + except Invalid, e: errors[name] = e for name in unused: @@ -216,7 +216,7 @@ def _to_python(self, value_dict, state): state.key = name try: new[name] = validator.to_python(self.if_key_missing, state) - except Invalid as e: + except Invalid, e: errors[name] = e else: new[name] = validator.if_missing @@ -229,7 +229,7 @@ def _to_python(self, value_dict, state): continue try: validator.validate_partial(value_dict, state) - except Invalid as e: + except Invalid, e: sub_errors = e.unpack_errors() if not isinstance(sub_errors, dict): # Can't do anything here @@ -285,7 +285,7 @@ def _from_python(self, value_dict, state): state.key = name try: new[name] = self.fields[name].from_python(value, state) - except Invalid as e: + except Invalid, e: errors[name] = e del __traceback_info__ @@ -296,7 +296,7 @@ def _from_python(self, value_dict, state): state.key = name try: new[name] = validator.from_python(None, state) - except Invalid as e: + except Invalid, e: errors[name] = e if errors: diff --git a/tests/test_schema.py b/tests/test_schema.py index ea60ea94..4bc756be 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -75,7 +75,7 @@ def test(self): print repr(self.raw_input) try: print repr(self.schema.to_python(self.input)) - except Invalid as e: + except Invalid, e: actual = e.unpack_errors() assert actual == self.output else: @@ -175,11 +175,11 @@ def test_multiple_chained_validators_errors(): s = ChainedTest() try: s.to_python({'a':'1', 'a_confirm':'2', 'b':'3', 'b_confirm':'4'}) - except Invalid as e: + except Invalid, e: assert 'a_confirm' in e.error_dict and 'b_confirm' in e.error_dict try: s.to_python({}) - except Invalid as e: + except Invalid: pass else: assert False @@ -271,7 +271,7 @@ def test_Schema_with_input_missing(self): # try: self.schema.to_python({}) - except Invalid as exc: + except Invalid, exc: error_message = exc.error_dict['agree'].msg assert self.not_empty_messages['missing'] == error_message, \ error_message From 7280533ecc4244a42885e1008ef0b83de3dbb75a Mon Sep 17 00:00:00 2001 From: Maxim Avanov Date: Sun, 16 Sep 2012 17:12:43 +0400 Subject: [PATCH 3/6] Add new API. --- .coverage | Bin 10773 -> 0 bytes .gitignore | 4 +- formencode/schema.py | 91 +++++++++++++++++++++++++++++++++++++------ tests/test_schema.py | 27 ++++++++++--- 4 files changed, 105 insertions(+), 17 deletions(-) delete mode 100644 .coverage diff --git a/.coverage b/.coverage deleted file mode 100644 index 12852c4d8bd9ad31bc9509c3b0dad0a00adfd58d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10773 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 diff --git a/.gitignore b/.gitignore index e3970e6a..997dc244 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,7 @@ dist/ # When you run ``python setup.py [test|nosetests]`` # from project's root tree, the script checks [and downloads, if necessary] # packages which are specified in setup.py -> tests_require. -# Therefore we must explicitly ignore all downloaded *.egg packages. +# Therefore we must explicitly ignore all downloaded *.egg packages +# as well as all coverage-related files. *.egg +*coverage* \ No newline at end of file diff --git a/formencode/schema.py b/formencode/schema.py index cb5ff7b6..c8c2830d 100644 --- a/formencode/schema.py +++ b/formencode/schema.py @@ -4,6 +4,8 @@ from api import * from api import _ import foreach +import compound +from validators import Set import declarative from exc import FERuntimeWarning @@ -63,6 +65,7 @@ class MySubSchema(MySchema): compound = True fields = {} order = [] + fields_accept_list_values = set() messages = dict( notExpected=_('The input field %(name)s was not expected.'), @@ -98,6 +101,8 @@ def __classinit__(cls, new_attrs): # from a superclass: elif key in cls.fields: del cls.fields[key] + + cls.fields_accept_list_values = set() for name, value in cls.fields.items(): cls.add_field(name, value) @@ -116,6 +121,8 @@ def __initargs__(self, new_attrs): # from a superclass: elif key in self.fields: del self.fields[key] + + self.fields_accept_list_values = set() for name, value in self.fields.items(): self.add_field(name, value) @@ -177,17 +184,10 @@ def _to_python(self, value_dict, state): # Therefore, if you really want to validate a field with multiple # values, you have to set self.allow_extra_fields to True or # wrap the username validator with formencode.validators.ForEach() - if not self.allow_extra_fields and isinstance(value, (list, tuple)): - try: - bad_type = not issubclass(validator, foreach.ForEach) - except TypeError: - # TypeError: issubclass() arg 1 must be a class - bad_type = not isinstance(validator, foreach.ForEach) - if bad_type: - raise Invalid( - self.message('singleValueExpected', state), - value_dict, state - ) + if isinstance(value, (list, tuple)): + if name not in self.fields_accept_list_values: + raise Invalid(self.message('singleValueExpected', state), + value_dict, state) if state is not None: state.key = name @@ -331,13 +331,82 @@ def add_chained_validator(self, cls, validator): add_chained_validator = declarative.classinstancemethod( add_chained_validator) + def if_validator_accepts_list(self, cls, validator, type_check): + these_accept_list = (foreach.ForEach, Set) + we_need_to_go_deeper = (compound.All, compound.Pipe) + + if type_check(validator, these_accept_list): + return True + + elif type_check(validator, compound.Any): + # Any() validator is valid if at least one of its sub-validators is valid + for sub_validator in validator.validators: + if type_check(sub_validator, these_accept_list): + return True + elif type_check(sub_validator, we_need_to_go_deeper): + return cls.if_validator_accepts_list(sub_validator, type_check) + return False + + elif type_check(validator, we_need_to_go_deeper): + # We have to check sub-sub-...-validators + sub_validators = validator.validators + if sub_validators: + # We need to check only the first validator. + # All() evaluates its sub-validators in reverse order. + significant_validator = type_check(validator, compound.All) and sub_validators[-1] or sub_validators[0] + if type_check(significant_validator, these_accept_list): + return True + elif type_check(significant_validator, we_need_to_go_deeper): + return cls.if_validator_accepts_list(significant_validator, type_check) + return False + return False + + elif type_check(validator, declarative.DeclarativeMeta): + # Cases like + # class SiteForm(Schema): + # class addresses(foreach.ForEach): + # class schema(Schema): + # name = Name() + # email = validators.Email() + # + # require a subclass-based check to be performed instead of instance-based. + return cls.if_validator_accepts_list(validator, issubclass) + + return False + if_validator_accepts_list = declarative.classinstancemethod(if_validator_accepts_list) + + def add_field(self, cls, name, validator): if self is not None: if self.fields is cls.fields: self.fields = cls.fields.copy() + self.accept_list_values = cls.fields_accept_list_values.copy() self.fields[name] = validator + if not self.allow_extra_fields: + accept_list = self.if_validator_accepts_list(validator, isinstance) + if accept_list: + self.fields_accept_list_values.add(name) + else: + try: + self.fields_accept_list_values.remove(name) + except KeyError: + pass + else: + self.fields_accept_list_values.add(name) + else: cls.fields[name] = validator + if not cls.allow_extra_fields: + accept_list = cls.if_validator_accepts_list(validator, isinstance) + if accept_list: + cls.fields_accept_list_values.add(name) + else: + try: + cls.fields_accept_list_values.remove(name) + except KeyError: + pass + else: + cls.fields_accept_list_values.add(name) add_field = declarative.classinstancemethod(add_field) diff --git a/tests/test_schema.py b/tests/test_schema.py index 4bc756be..4f445343 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -1,6 +1,6 @@ import unittest -from formencode import validators, foreach +from formencode import validators, foreach, compound from formencode.schema import Schema, merge_dicts, SimpleFormValidator from formencode.api import * from formencode.variabledecode import NestedVariables @@ -293,12 +293,21 @@ class IntegerTestSchema(StrictSchema): class StringTestSchema(StrictSchema): field = validators.UnicodeString(not_empty=True) - class CorrectStringTestSchema(StrictSchema): + class CorrectForEachStringTestSchema(StrictSchema): field = foreach.ForEach(validators.UnicodeString(not_empty=True)) + class CorrectSetTestSchema(StrictSchema): + field = validators.Set(not_empty=True) + + class CorrectSetTestPipeSchema(StrictSchema): + field = compound.Pipe(validators.Set(not_empty=True), foreach.ForEach(validators.UnicodeString(not_empty=True))) + + self.int_schema = IntegerTestSchema() self.string_schema = StringTestSchema() - self.correct_schema = CorrectStringTestSchema + self.foreach_schema = CorrectForEachStringTestSchema() + self.set_schema = CorrectSetTestSchema() + self.pipe_schema = CorrectSetTestPipeSchema() def test_single_integer_value(self): @@ -317,6 +326,14 @@ def test_multiple_string_value(self): params = cgi_parse('field=string1&field=string2') self.assertRaises(Invalid, self.string_schema.to_python, params) - def test_correct_multiple_string_value(self): + def test_correct_multiple_string_value_foreach(self): + params = cgi_parse('field=string1&field=string2') + data = self.foreach_schema.to_python(params) + + def test_correct_multiple_string_value_set(self): + params = cgi_parse('field=string1&field=string2') + data = self.set_schema.to_python(params) + + def test_correct_multiple_string_value_pipe(self): params = cgi_parse('field=string1&field=string2') - data = self.correct_schema.to_python(params) + data = self.pipe_schema.to_python(params) From 351eab967fd596c3b1993ba54480ab583b388e12 Mon Sep 17 00:00:00 2001 From: Maxim Avanov Date: Sun, 16 Sep 2012 17:16:57 +0400 Subject: [PATCH 4/6] Remove deprecated statement. --- formencode/schema.py | 1 - 1 file changed, 1 deletion(-) diff --git a/formencode/schema.py b/formencode/schema.py index c8c2830d..84f6bbe8 100644 --- a/formencode/schema.py +++ b/formencode/schema.py @@ -380,7 +380,6 @@ def add_field(self, cls, name, validator): if self is not None: if self.fields is cls.fields: self.fields = cls.fields.copy() - self.accept_list_values = cls.fields_accept_list_values.copy() self.fields[name] = validator if not self.allow_extra_fields: accept_list = self.if_validator_accepts_list(validator, isinstance) From 5516d9388ea425c970e784095e1b88039f4fbf00 Mon Sep 17 00:00:00 2001 From: Maxim Avanov Date: Sun, 16 Sep 2012 22:13:10 +0400 Subject: [PATCH 5/6] Some actions have no effect. --- formencode/schema.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/formencode/schema.py b/formencode/schema.py index 84f6bbe8..39729378 100644 --- a/formencode/schema.py +++ b/formencode/schema.py @@ -385,11 +385,6 @@ def add_field(self, cls, name, validator): accept_list = self.if_validator_accepts_list(validator, isinstance) if accept_list: self.fields_accept_list_values.add(name) - else: - try: - self.fields_accept_list_values.remove(name) - except KeyError: - pass else: self.fields_accept_list_values.add(name) @@ -399,11 +394,6 @@ def add_field(self, cls, name, validator): accept_list = cls.if_validator_accepts_list(validator, isinstance) if accept_list: cls.fields_accept_list_values.add(name) - else: - try: - cls.fields_accept_list_values.remove(name) - except KeyError: - pass else: cls.fields_accept_list_values.add(name) From df66b54722ea9fa49e76b37ec1db32a29b03d950 Mon Sep 17 00:00:00 2001 From: Christopher Lambacher Date: Sat, 15 Dec 2012 13:31:05 -0500 Subject: [PATCH 6/6] Make validators specify that they allow iterators --- formencode/api.py | 1 + formencode/compound.py | 15 ++++++ formencode/foreach.py | 1 + formencode/schema.py | 102 ++++++++------------------------------- formencode/validators.py | 1 + 5 files changed, 38 insertions(+), 82 deletions(-) diff --git a/formencode/api.py b/formencode/api.py index 7b2bb6f4..cbf1f446 100644 --- a/formencode/api.py +++ b/formencode/api.py @@ -195,6 +195,7 @@ class Validator(declarative.Declarative): if_missing = NoDefault repeating = False compound = False + accept_iterator = False gettextargs = {} use_builtins_gettext = True # In case you don't want to use __builtins__._ # although it may be defined, set this to False diff --git a/formencode/compound.py b/formencode/compound.py index 2890d54a..04dfea24 100644 --- a/formencode/compound.py +++ b/formencode/compound.py @@ -22,6 +22,7 @@ def from_python(validator, value, state): class CompoundValidator(FancyValidator): if_invalid = NoDefault + accept_iterator = False validators = [] @@ -105,6 +106,13 @@ def is_empty(self, value): # sub-validators should handle emptiness. return False + def accept_iterator__get(self): + accept_iterator = False + for validator in self.validators: + accept_iterator = accept_iterator or getattr(validator, 'accept_iterator', False) + return accept_iterator + accept_iterator = property(accept_iterator__get) + class All(CompoundValidator): """ @@ -201,6 +209,13 @@ def is_empty(self, value): # sub-validators should handle emptiness. return False + def accept_iterator__get(self): + accept_iterator = True + for validator in self.validators: + accept_iterator = accept_iterator and getattr(validator, 'accept_iterator', False) + return accept_iterator + accept_iterator = property(accept_iterator__get) + class Pipe(All): """ diff --git a/formencode/foreach.py b/formencode/foreach.py index af59a4f0..3740748d 100644 --- a/formencode/foreach.py +++ b/formencode/foreach.py @@ -49,6 +49,7 @@ class ForEach(CompoundValidator): convert_to_list = True if_empty = NoDefault + accept_iterator = True repeating = True _if_missing = () diff --git a/formencode/schema.py b/formencode/schema.py index 39729378..46e07993 100644 --- a/formencode/schema.py +++ b/formencode/schema.py @@ -65,7 +65,7 @@ class MySubSchema(MySchema): compound = True fields = {} order = [] - fields_accept_list_values = set() + accept_iterator = True messages = dict( notExpected=_('The input field %(name)s was not expected.'), @@ -102,7 +102,6 @@ def __classinit__(cls, new_attrs): elif key in cls.fields: del cls.fields[key] - cls.fields_accept_list_values = set() for name, value in cls.fields.items(): cls.add_field(name, value) @@ -121,10 +120,6 @@ def __initargs__(self, new_attrs): # from a superclass: elif key in self.fields: del self.fields[key] - - self.fields_accept_list_values = set() - for name, value in self.fields.items(): - self.add_field(name, value) def assert_dict(self, value, state): """ @@ -169,25 +164,11 @@ def _to_python(self, value_dict, state): new[name] = value continue validator = self.fields[name] - - # Some data types require an extra check to be performed - # in order to guarantee unambiguous connection between - # input and output data. - # Let's say we have to validate two different URLS: - # 1. "site.com/?username=['John', 'Mike']" and - # 2. "site.com/?username=John&username=Mike" - # Without the following check, - # formencode.validators.String (and all other inherited validators) - # will set the username value to "['John', 'Mike']" for both URLs. - # In terms of URL design, it is considered bad if the same - # resource is accessible by two different URLs. - # Therefore, if you really want to validate a field with multiple - # values, you have to set self.allow_extra_fields to True or - # wrap the username validator with formencode.validators.ForEach() - if isinstance(value, (list, tuple)): - if name not in self.fields_accept_list_values: - raise Invalid(self.message('singleValueExpected', state), - value_dict, state) + + # are iterators (list, tuple, set, etc) allowed? + if self._value_is_iterator(value) and not getattr(validator, 'accept_iterator', False): + errors[name] = Invalid(self.message('singleValueExpected', state), + value_dict, state) if state is not None: state.key = name @@ -331,71 +312,14 @@ def add_chained_validator(self, cls, validator): add_chained_validator = declarative.classinstancemethod( add_chained_validator) - def if_validator_accepts_list(self, cls, validator, type_check): - these_accept_list = (foreach.ForEach, Set) - we_need_to_go_deeper = (compound.All, compound.Pipe) - - if type_check(validator, these_accept_list): - return True - - elif type_check(validator, compound.Any): - # Any() validator is valid if at least one of its sub-validators is valid - for sub_validator in validator.validators: - if type_check(sub_validator, these_accept_list): - return True - elif type_check(sub_validator, we_need_to_go_deeper): - return cls.if_validator_accepts_list(sub_validator, type_check) - return False - - elif type_check(validator, we_need_to_go_deeper): - # We have to check sub-sub-...-validators - sub_validators = validator.validators - if sub_validators: - # We need to check only the first validator. - # All() evaluates its sub-validators in reverse order. - significant_validator = type_check(validator, compound.All) and sub_validators[-1] or sub_validators[0] - if type_check(significant_validator, these_accept_list): - return True - elif type_check(significant_validator, we_need_to_go_deeper): - return cls.if_validator_accepts_list(significant_validator, type_check) - return False - return False - - elif type_check(validator, declarative.DeclarativeMeta): - # Cases like - # class SiteForm(Schema): - # class addresses(foreach.ForEach): - # class schema(Schema): - # name = Name() - # email = validators.Email() - # - # require a subclass-based check to be performed instead of instance-based. - return cls.if_validator_accepts_list(validator, issubclass) - - return False - if_validator_accepts_list = declarative.classinstancemethod(if_validator_accepts_list) - - def add_field(self, cls, name, validator): if self is not None: if self.fields is cls.fields: self.fields = cls.fields.copy() self.fields[name] = validator - if not self.allow_extra_fields: - accept_list = self.if_validator_accepts_list(validator, isinstance) - if accept_list: - self.fields_accept_list_values.add(name) - else: - self.fields_accept_list_values.add(name) else: cls.fields[name] = validator - if not cls.allow_extra_fields: - accept_list = cls.if_validator_accepts_list(validator, isinstance) - if accept_list: - cls.fields_accept_list_values.add(name) - else: - cls.fields_accept_list_values.add(name) add_field = declarative.classinstancemethod(add_field) @@ -423,6 +347,20 @@ def is_empty(self, value): def empty_value(self, value): return {} + def _value_is_iterator(self, value): + if isinstance(value, (str, unicode)): + return False + elif isinstance(value, (list, tuple)): + return True + + try: + for n in value: + break + return True + ## @@: Should this catch any other errors?: + except TypeError: + return False + def format_compound_error(v, indent=0): if isinstance(v, Exception): diff --git a/formencode/validators.py b/formencode/validators.py index 4f4c6ed9..75573a6c 100644 --- a/formencode/validators.py +++ b/formencode/validators.py @@ -1191,6 +1191,7 @@ class Set(FancyValidator): use_set = False if_missing = () + accept_iterator = True def _to_python(self, value, state): if self.use_set: