~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/timestamp.py

  • Committer: Vincent Ladeuil
  • Date: 2007-11-04 15:24:27 UTC
  • mto: (2961.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2962.
  • Revision ID: v.ladeuil+lp@free.fr-20071104152427-p9k7e4toywa87wfc
Review feedback.

* doc/en/user-guide/authentication_conf.txt: 
New file. Authentication configuration file documentation.

* doc/en/user-guide/configuration.txt: 
Slight modifications, add authentication.conf reference.

* doc/en/mini-tutorial/index.txt: 
Fix make docs warning.

* doc/developers/authentication-ring.txt: 
Small cleanups noticed during
doc/en/user-guide/authentication_conf.txt redaction.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib._perform): Use a dict() instead of {} syntax.

* bzrlib/tests/blackbox/test_whoami.py:
(TestWhoami.test_whoami_branch): Delete BZREMAIL related tests.

* bzrlib/config.py:
(Config.username): BZREMAIL deleted, has been obsolete for more
than a year.
(AuthenticationConfig.__init__): Review feedback, since keeping a
callback as an attribute is useless, call it now and keep the
filename itself as an attribute.
(AuthenticationConfig.get_credentials): Use a dict() instead of {}
syntax.

* NEWS: 
Updated as per Martin's suggestion.

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
 
    if not isinstance(t, float):
51
 
        raise ValueError(t)
 
50
    assert isinstance(t, float)
52
51
 
53
52
    # This has to be formatted for "original" date, so that the
54
53
    # revision XML entry will be reproduced faithfully.
56
55
        offset = 0
57
56
    tt = time.gmtime(t + offset)
58
57
 
59
 
    return (osutils.weekdays[tt[6]] +
60
 
            time.strftime(" %Y-%m-%d %H:%M:%S", tt)
 
58
    return (time.strftime("%a %Y-%m-%d %H:%M:%S", tt)
61
59
            # Get the high-res seconds, but ignore the 0
62
60
            + ('%.9f' % (t - int(t)))[1:]
63
61
            + ' %+03d%02d' % (offset / 3600, (offset / 60) % 60))
101
99
    ...      break
102
100
 
103
101
    """
104
 
    # Weekday parsing is locale sensitive, so drop the weekday
105
 
    space_loc = date.find(' ')
106
 
    if space_loc == -1 or date[:space_loc] not in osutils.weekdays:
107
 
        raise ValueError(
108
 
            'Date string does not contain a day of week: %r' % date)
109
102
    # Up until the first period is a datestamp that is generated
110
103
    # as normal from time.strftime, so use time.strptime to
111
104
    # parse it
113
106
    if dot_loc == -1:
114
107
        raise ValueError(
115
108
            'Date string does not contain high-precision seconds: %r' % date)
116
 
    base_time = time.strptime(date[space_loc:dot_loc], " %Y-%m-%d %H:%M:%S")
 
109
    base_time = time.strptime(date[:dot_loc], "%a %Y-%m-%d %H:%M:%S")
117
110
    fract_seconds, offset = date[dot_loc:].split()
118
111
    fract_seconds = float(fract_seconds)
119
112
 
136
129
 
137
130
    Inverse of parse_patch_date.
138
131
    """
139
 
    if offset % 60 != 0:
140
 
        raise ValueError(
141
 
        "can't represent timezone %s offset by fractional minutes" % offset)
 
132
    assert offset % 60 == 0, \
 
133
        "can't represent timezone %s offset by fractional minutes" % offset
142
134
    # so that we don't need to do calculations on pre-epoch times, 
143
135
    # which doesn't work with win32 python gmtime, we always
144
136
    # give the epoch in utc
159
151
    """
160
152
    secs_str = date_str[:-6]
161
153
    offset_str = date_str[-5:]
162
 
    if len(offset_str) != 5:
163
 
        raise ValueError(
164
 
            "invalid timezone %r" % offset_str)
 
154
    assert len(offset_str) == 5, \
 
155
            "invalid timezone %r" % offset_str
165
156
    offset_hours, offset_mins = offset_str[:3], offset_str[3:]
166
157
    offset = int(offset_hours) * 3600 + int(offset_mins) * 60
167
158
    tm_time = time.strptime(secs_str, '%Y-%m-%d %H:%M:%S')