~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-09 06:49:00 UTC
  • Revision ID: mbp@sourcefrog.net-20050309064900-74935ffb7350b24b
import more files from baz

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
 
19
19
import os, types, re, time, types
20
 
from stat import S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE
 
20
from stat import S_ISREG, S_ISDIR, ST_MODE, ST_SIZE
21
21
 
22
22
from errors import bailout
23
23
 
51
51
        return 'file'
52
52
    elif S_ISDIR(mode):
53
53
        return 'directory'
54
 
    elif S_ISLNK(mode):
55
 
        return 'symlink'
56
54
    else:
57
 
        bailout("can't handle file kind with mode %o of %r" % (mode, f)) 
 
55
        bailout("can't handle file kind of %r" % fp)
58
56
 
59
57
 
60
58
 
135
133
        import pwd
136
134
        uid = os.getuid()
137
135
        w = pwd.getpwuid(uid)
138
 
        gecos = w.pw_gecos
139
 
        comma = gecos.find(',')
140
 
        if comma == -1:
141
 
            realname = gecos
142
 
        else:
143
 
            realname = gecos[:comma]
 
136
        realname, junk = w.pw_gecos.split(',', 1)
144
137
        return '%s <%s@%s>' % (realname, w.pw_name, socket.getfqdn())
145
138
    except ImportError:
146
139
        pass
192
185
        tt = time.gmtime(t)
193
186
        offset = 0
194
187
    elif timezone == 'original':
195
 
        if offset == None:
196
 
            offset = 0
197
 
        tt = time.gmtime(t + offset)
198
 
    elif timezone == 'local':
 
188
        tt = time.gmtime(t - offset)
 
189
    else:
 
190
        assert timezone == 'local'
199
191
        tt = time.localtime(t)
200
192
        offset = local_time_offset()
201
 
    else:
202
 
        bailout("unsupported timezone format %r",
203
 
                ['options are "utc", "original", "local"'])
204
193
 
205
194
    return (time.strftime("%a %Y-%m-%d %H:%M:%S", tt)
206
195
            + ' %+03d%02d' % (offset / 3600, (offset / 60) % 60))