Skip to content

Commit 30c9cc7

Browse files
author
Andrey Lebedev
committed
hope this will make Range class a little bit clearer
1 parent c0b105f commit 30c9cc7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

roundup/date.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: date.py,v 1.47 2003-03-10 00:22:20 richard Exp $
18+
# $Id: date.py,v 1.48 2003-03-10 20:32:53 kedder Exp $
1919

2020
__doc__ = """
2121
Date, time and time interval handling.
@@ -621,14 +621,18 @@ class Range:
621621
<Range from None to 2003-03-09.20:00:00>
622622
623623
"""
624-
def __init__(self, spec, type, **params):
625-
"""Initializes Range of type <type> from given <spec> string.
624+
def __init__(self, spec, Type, **params):
625+
"""Initializes Range of type <Type> from given <spec> string.
626626
627627
Sets two properties - from_value and to_value. None assigned to any of
628628
this properties means "infinitum" (-infinitum to from_value and
629-
+infinitum to to_value)
629+
+infinitum to to_value)
630+
631+
The Type parameter here should be class itself (e.g. Date), not a
632+
class instance.
633+
630634
"""
631-
self.range_type = type
635+
self.range_type = Type
632636
re_range = r'(?:^|(?:from)?(.+?))(?:to(.+?)$|$)'
633637
re_geek_range = r'(?:^|(.+?))(?:;(.+?)$|$)'
634638
# Check which syntax to use
@@ -641,9 +645,9 @@ def __init__(self, spec, type, **params):
641645
if mch_range:
642646
self.from_value, self.to_value = mch_range.groups()
643647
if self.from_value:
644-
self.from_value = type(self.from_value.strip(), **params)
648+
self.from_value = Type(self.from_value.strip(), **params)
645649
if self.to_value:
646-
self.to_value = type(self.to_value.strip(), **params)
650+
self.to_value = Type(self.to_value.strip(), **params)
647651
else:
648652
raise ValueError, "Invalid range"
649653

0 commit comments

Comments
 (0)