~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/timestamp.py

  • Committer: Martin Pool
  • Date: 2008-04-24 07:22:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080424072253-opmjij7xfy38w27f
Remove every assert statement from bzrlib!

Depending on the context they are:

 * turned into an explicit if/raise of either AssertionError 
   or something more specific -- particularly where they protect
   programming interfaces, complex invariants, or data file integrity
 * removed, if they're redundant with a later check, not protecting
   a meaningful invariant
 * turned into a selftest method on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    >>> format_highres_date(1152428738.867522, 19800)
48
48
    'Sun 2006-07-09 12:35:38.867522001 +0530'
49
49
    """
50
 
    assert isinstance(t, float)
 
50
    if not isinstance(t, float):
 
51
        raise ValueError(t)
51
52
 
52
53
    # This has to be formatted for "original" date, so that the
53
54
    # revision XML entry will be reproduced faithfully.
129
130
 
130
131
    Inverse of parse_patch_date.
131
132
    """
132
 
    assert offset % 60 == 0, \
133
 
        "can't represent timezone %s offset by fractional minutes" % offset
 
133
    if offset % 60 != 0:
 
134
        raise ValueError(
 
135
        "can't represent timezone %s offset by fractional minutes" % offset)
134
136
    # so that we don't need to do calculations on pre-epoch times, 
135
137
    # which doesn't work with win32 python gmtime, we always
136
138
    # give the epoch in utc
151
153
    """
152
154
    secs_str = date_str[:-6]
153
155
    offset_str = date_str[-5:]
154
 
    assert len(offset_str) == 5, \
155
 
            "invalid timezone %r" % offset_str
 
156
    if len(offset_str) != 5:
 
157
        raise ValueError(
 
158
            "invalid timezone %r" % offset_str)
156
159
    offset_hours, offset_mins = offset_str[:3], offset_str[3:]
157
160
    offset = int(offset_hours) * 3600 + int(offset_mins) * 60
158
161
    tm_time = time.strptime(secs_str, '%Y-%m-%d %H:%M:%S')