[Checkins] SVN: z3c.schema/trunk/ - Added doctests to ``long_description`` so they appear on PyPI.

Michael Howitz mh at gocept.com
Mon Oct 18 03:46:55 EDT 2010


Log message for revision 117614:
  - Added doctests to ``long_description`` so they appear on PyPI.
  - Fixed rest of doctests.
  
  

Changed:
  U   z3c.schema/trunk/CHANGES.txt
  U   z3c.schema/trunk/setup.py
  U   z3c.schema/trunk/src/z3c/schema/payments/README.txt

-=-
Modified: z3c.schema/trunk/CHANGES.txt
===================================================================
--- z3c.schema/trunk/CHANGES.txt	2010-10-17 13:53:25 UTC (rev 117613)
+++ z3c.schema/trunk/CHANGES.txt	2010-10-18 07:46:55 UTC (rev 117614)
@@ -5,8 +5,11 @@
 Version 0.6.1 (unreleased)
 --------------------------
 
-- Added french translations
+- Added french translations.
 
+- Added doctests to ``long_description`` so they appear on PyPI.
+
+
 Version 0.6.0 (2009-01-26)
 --------------------------
 

Modified: z3c.schema/trunk/setup.py
===================================================================
--- z3c.schema/trunk/setup.py	2010-10-17 13:53:25 UTC (rev 117613)
+++ z3c.schema/trunk/setup.py	2010-10-18 07:46:55 UTC (rev 117614)
@@ -21,7 +21,7 @@
 
 def read(*rnames):
     text = open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-    return xml.sax.saxutils.escape(text)
+    return text + '\n\n'
 
 setup(
     name = 'z3c.schema',
@@ -30,9 +30,17 @@
       author_email = "zope-dev at zope.org",
       description = "Additional schema fields for Zope 3",
     long_description=(
-        read('README.txt')
-        + '\n\n' +
-        read('CHANGES.txt')
+        read('README.txt') +
+        '.. contents::\n\n'+
+        read('CHANGES.txt') +
+        read('src', 'z3c', 'schema', 'baseurl', 'README.txt') +
+        read('src', 'z3c', 'schema', 'dateselect', 'README.txt') +
+        read('src', 'z3c', 'schema', 'email', 'README.txt') +
+        read('src', 'z3c', 'schema', 'hostname', 'README.txt') +
+        read('src', 'z3c', 'schema', 'ip', 'README.txt') +
+        read('src', 'z3c', 'schema', 'optchoice', 'README.txt') +
+        read('src', 'z3c', 'schema', 'payments', 'README.txt') +
+        read('src', 'z3c', 'schema', 'regex', 'README.txt')
         ),
     license = 'ZPL 2.1',
     keywords = 'zope zope3 z3c schema',

Modified: z3c.schema/trunk/src/z3c/schema/payments/README.txt
===================================================================
--- z3c.schema/trunk/src/z3c/schema/payments/README.txt	2010-10-17 13:53:25 UTC (rev 117613)
+++ z3c.schema/trunk/src/z3c/schema/payments/README.txt	2010-10-18 07:46:55 UTC (rev 117614)
@@ -2,22 +2,21 @@
 z3c.schema.payments
 ===================
 
-z3c.schema.payments provides some level of error detection in payment data 
-prior to storing the information or sending it to a payment processor. 
+z3c.schema.payments provides some level of error detection in payment data
+prior to storing the information or sending it to a payment processor.
 Currently this module only supports validation of credit card numbers, but
 this could conceivably be extended to other payment forms
 
 
-------------
 Credit Cards
 ------------
 
 Credit card numbering specifications are defined in ISO 7812-1:1983. Verifying
-that the credit card number supplied by a user conforms to the ISO standard 
-provides some error checking which can catch typographical errors, 
-transposition, etc. This does not validate the card against the financial 
-networks as a valid account. However, verifying that the card number is well 
-formed is fast and catching typographical errors in this way is much faster 
+that the credit card number supplied by a user conforms to the ISO standard
+provides some error checking which can catch typographical errors,
+transposition, etc. This does not validate the card against the financial
+networks as a valid account. However, verifying that the card number is well
+formed is fast and catching typographical errors in this way is much faster
 than sending the card number to a credit card processor.
 
 First, let's setup a credit card field:
@@ -27,12 +26,12 @@
     >>> cc = CreditCard()
     >>> interfaces.IISO7812CreditCard.providedBy(cc)
     True
-    
+
 The simple restrictions are quick to check. Credit cards should be all numeric, no alpha characters allowed:
-    
+
     >>> cc.constraint('44444444444AAAA8')
     False
-    
+
     >>> cc.constraint('4444444444444448')
     True
 
@@ -40,53 +39,53 @@
 
     >>> cc.constraint('444444444444\n4448')
     False
-    
+
     >>> cc.constraint('44444444\r44444448')
     False
 
-One of the first specifications of ISO 7812 is a "Major Industry Identifier," 
+One of the first specifications of ISO 7812 is a "Major Industry Identifier,"
 which is the first number of an ISO 7812 compliant account number. Originally,
-banking, financial, and merchandizing (store account) cards were limited to 
-the  major industry identifiers 4, 5, and 6. However American Express, Diner's 
-Club, and Carte Blanche were all assigned a major industry number 3. So a 
-valid card must start with one of these numbers: 
+banking, financial, and merchandizing (store account) cards were limited to
+the  major industry identifiers 4, 5, and 6. However American Express, Diner's
+Club, and Carte Blanche were all assigned a major industry number 3. So a
+valid card must start with one of these numbers:
 
     >>> cc.validate(u'0000000000000000')
     Traceback (most recent call last):
     ...
     NotValidISO7812CreditCard: 0000000000000000
-    
+
     >>> cc.validate(u'1111111111111117')
     Traceback (most recent call last):
     ...
     NotValidISO7812CreditCard: 1111111111111117
-    
+
     >>> cc.validate(u'2222222222222224')
     Traceback (most recent call last):
     ...
     NotValidISO7812CreditCard: 2222222222222224
-    
+
     >>> cc.validate(u'3333333333333331')
     >>> cc.validate(u'4444444444444448')
     >>> cc.validate(u'5555555555555557')
     >>> cc.validate(u'3333333333333331')
     >>> cc.validate(u'6666666666666664')
-    
+
     >>> cc.validate(u'7777777777777771')
     Traceback (most recent call last):
     ...
     NotValidISO7812CreditCard: 7777777777777771
-    
+
     >>> cc.validate(u'8888888888888888')
     Traceback (most recent call last):
     ...
     NotValidISO7812CreditCard: 8888888888888888
-    
+
     >>> cc.validate(u'9999999999999995')
     Traceback (most recent call last):
     ...
     NotValidISO7812CreditCard: 9999999999999995
-    
+
 The ISO specification also defines a check digit which should always
 be the last digit of a card number. The check digit is calculated using the
 Luhn (Mod 10) formula. In this way, each credit card number contains its own
@@ -95,30 +94,34 @@
 
 Validating a number with a check digit that uses the LUHN formula:
 
-Step 1: 
-Starting with the next-to-last digit and moving left, double the value of 
-every other digit. The calculation starts with the next-to-last digit because 
+Step 1:
+Starting with the next-to-last digit and moving left, double the value of
+every other digit. The calculation starts with the next-to-last digit because
 the last digit is the check digit.
 
-* When selecting every other digit, always work right-to-left and do not start 
-with the rightmost digit (since that is the check digit).
+* When selecting every other digit, always work right-to-left and do not start
+  with the rightmost digit (since that is the check digit).
+
 * The last digit (check digit) is considered #1 (odd number) and the
-next-to-last digit is #2 (even number). You will only double the values of the even-numbered digits.
+  next-to-last digit is #2 (even number). You will only double the values of
+  the even-numbered digits.
 
-Step 2: 
+Step 2:
 Add all unaffected digits to the values obtained in Step 1.
 
-* If any of the values resulting from Step 1 are double-digits, do not add the double-digit value to the total, but rather add the two digits, and add this sum to the total.
+* If any of the values resulting from Step 1 are double-digits, do not add
+  the double-digit value to the total, but rather add the two digits, and
+  add this sum to the total.
 
-Result: 
-The total obtained in Step 2 must be a number ending in zero (exactly 
+Result:
+The total obtained in Step 2 must be a number ending in zero (exactly
 divisible by 10) for the number to be valid.
 
 The validate method of z3c.schema.payments.ISO7812CreditCard does the Luhn
 calculation on the provided card number. If the calculation fails, there is
 either an error in the number or the card is simply not valid. We use in our
 tests here and above numbers that technically meet the criteria of the ISO
-specification without the risk of the number actually being a valid card 
+specification without the risk of the number actually being a valid card
 number registered with a financial institution:
 
     >>> cc.validate(u'4444444444444448')
@@ -126,5 +129,4 @@
     Traceback (most recent call last):
     ...
     NotValidISO7812CreditCard: 4444444444444449
-    
-    
\ No newline at end of file
+



More information about the checkins mailing list