Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/raw-rev/4ecf6476a1c9
Дата изменения: Unknown
Дата индексирования: Tue Oct 2 08:07:33 2012
Кодировка:

# HG changeset patch
# User boris (netbook)
# Date 1298391156 -10800
# Node ID 4ecf6476a1c998e54f48b4ca40430310b494b321
# Parent 9c93dbf8cad29f493b380660d2ea8a22bb79a4fd
move argparse_validators.py to allpy (#33)

diff -r 9c93dbf8cad2 -r 4ecf6476a1c9 allpy/argparse_validators.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/allpy/argparse_validators.py Tue Feb 22 19:12:36 2011 +0300
@@ -0,0 +1,63 @@
+
+import argparse
+
+def f_nng(string):
+ """ Validates nonnegative (>=0) float """
+ try:
+ value = float(string)
+ except:
+ msg = "%r is wrong float" % string
+ raise argparse.ArgumentTypeError(msg)
+ if value < 0:
+ msg = "%r is negative" % string
+ raise argparse.ArgumentTypeError(msg)
+ return value
+
+def part(string):
+ """ Validates 0.0 <= float <= 1.0 """
+ try:
+ value = float(string)
+ except:
+ msg = "%r is wrong float" % string
+ raise argparse.ArgumentTypeError(msg)
+ if not (0.0 <= value <= 1.0):
+ msg = "%r is not float, representing part, ie in [0, 1]" % string
+ raise argparse.ArgumentTypeError(msg)
+ return value
+
+def timeout(string):
+ """ Validates int >= -1 """
+ try:
+ value = int(string)
+ except:
+ msg = "%r is wrong integer" % string
+ raise argparse.ArgumentTypeError(msg)
+ if value < -1:
+ msg = "integer %r is less than -1" % string
+ raise argparse.ArgumentTypeError(msg)
+ return value
+
+def pos(string):
+ """ Validates positive integer """
+ try:
+ value = int(string)
+ except:
+ msg = "%r is wrong integer" % string
+ raise argparse.ArgumentTypeError(msg)
+ if value < 1:
+ msg = "%r is not positive integer" % string
+ raise argparse.ArgumentTypeError(msg)
+ return value
+
+def i_nng(string):
+ """ Validates int >= 0 """
+ try:
+ value = int(string)
+ except:
+ msg = "%r is wrong integer" % string
+ raise argparse.ArgumentTypeError(msg)
+ if value < 0:
+ msg = "integer %r is less than 0" % string
+ raise argparse.ArgumentTypeError(msg)
+ return value
+
diff -r 9c93dbf8cad2 -r 4ecf6476a1c9 geometrical_core/argparse_validators.py
--- a/geometrical_core/argparse_validators.py Tue Feb 22 19:10:24 2011 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-
-import argparse
-
-def f_nng(string):
- """ Validates nonnegative (>=0) float """
- try:
- value = float(string)
- except:
- msg = "%r is wrong float" % string
- raise argparse.ArgumentTypeError(msg)
- if value < 0:
- msg = "%r is negative" % string
- raise argparse.ArgumentTypeError(msg)
- return value
-
-def part(string):
- """ Validates 0.0 <= float <= 1.0 """
- try:
- value = float(string)
- except:
- msg = "%r is wrong float" % string
- raise argparse.ArgumentTypeError(msg)
- if not (0.0 <= value <= 1.0):
- msg = "%r is not float, representing part, ie in [0, 1]" % string
- raise argparse.ArgumentTypeError(msg)
- return value
-
-def timeout(string):
- """ Validates int >= -1 """
- try:
- value = int(string)
- except:
- msg = "%r is wrong integer" % string
- raise argparse.ArgumentTypeError(msg)
- if value < -1:
- msg = "integer %r is less than -1" % string
- raise argparse.ArgumentTypeError(msg)
- return value
-
-def pos(string):
- """ Validates positive integer """
- try:
- value = int(string)
- except:
- msg = "%r is wrong integer" % string
- raise argparse.ArgumentTypeError(msg)
- if value < 1:
- msg = "%r is not positive integer" % string
- raise argparse.ArgumentTypeError(msg)
- return value
-
-def i_nng(string):
- """ Validates int >= 0 """
- try:
- value = int(string)
- except:
- msg = "%r is wrong integer" % string
- raise argparse.ArgumentTypeError(msg)
- if value < 0:
- msg = "integer %r is less than 0" % string
- raise argparse.ArgumentTypeError(msg)
- return value
-
diff -r 9c93dbf8cad2 -r 4ecf6476a1c9 geometrical_core/geometrical-core
--- a/geometrical_core/geometrical-core Tue Feb 22 19:10:24 2011 +0300
+++ b/geometrical_core/geometrical-core Tue Feb 22 19:12:36 2011 +0300
@@ -12,7 +12,8 @@
from allpy import markup
from allpy import fileio
from spt import gcs_to_spt
-from argparse_validators import f_nng, part, timeout, pos, i_nng
+
+from allpy.argparse_validators import f_nng, part, timeout, pos, i_nng

r = argparse.FileType('r')
w = argparse.FileType('w')