104
def rename(path_from, path_to):
105
"""Basically the same as os.rename() just special for win32"""
106
if sys.platform == 'win32':
110
if e.errno != e.ENOENT:
112
os.rename(path_from, path_to)
135
121
def is_inside(dir, fname):
136
122
"""True if fname is inside dir.
138
The parameters should typically be passed to os.path.normpath first, so
139
that . and .. and repeated slashes are eliminated, and the separators
140
are canonical for the platform.
142
The empty string as a dir name is taken as top-of-tree and matches
145
>>> is_inside('src', 'src/foo.c')
147
>>> is_inside('src', 'srccontrol')
149
>>> is_inside('src', 'src/a/a/a/foo.c')
151
>>> is_inside('foo.c', 'foo.c')
153
>>> is_inside('foo.c', '')
155
>>> is_inside('', 'foo.c')
158
# XXX: Most callers of this can actually do something smarter by
159
# looking at the inventory
166
if dir[-1] != os.sep:
169
return fname.startswith(dir)
124
return os.path.commonprefix([dir, fname]) == dir
172
127
def is_inside_any(dir_list, fname):
173
128
"""True if fname is inside any of given dirs."""
129
# quick scan for perfect match
130
if fname in dir_list:
174
133
for dirname in dir_list:
175
134
if is_inside(dirname, fname):
367
326
tt = time.localtime(t)
368
327
offset = local_time_offset(t)
370
raise BzrError("unsupported timezone format %r" % timezone,
371
['options are "utc", "original", "local"'])
329
raise BzrError("unsupported timezone format %r",
330
['options are "utc", "original", "local"'])
373
332
return (time.strftime("%a %Y-%m-%d %H:%M:%S", tt)
374
333
+ ' %+03d%02d' % (offset / 3600, (offset / 60) % 60))