722
722
_format_date(t, offset, timezone, date_fmt, show_offset)
723
723
date_str = time.strftime(date_fmt, tt)
724
724
if not isinstance(date_str, unicode):
725
date_str = date_str.decode(bzrlib.user_encoding, 'replace')
725
date_str = date_str.decode(get_user_encoding(), 'replace')
726
726
return date_str + offset_str
728
728
def _format_date(t, offset, timezone, date_fmt, show_offset):
927
927
shutil.copyfile(src, dest)
930
# Look Before You Leap (LBYL) is appropriate here instead of Easier to Ask for
931
# Forgiveness than Permission (EAFP) because:
932
# - root can damage a solaris file system by using unlink,
933
# - unlink raises different exceptions on different OSes (linux: EISDIR, win32:
934
# EACCES, OSX: EPERM) when invoked on a directory.
935
930
def delete_any(path):
936
"""Delete a file or directory."""
931
"""Delete a file, symlink or directory.
933
Will delete even if readonly.
936
_delete_file_or_dir(path)
937
except (OSError, IOError), e:
938
if e.errno in (errno.EPERM, errno.EACCES):
939
# make writable and try again
942
except (OSError, IOError):
944
_delete_file_or_dir(path)
949
def _delete_file_or_dir(path):
950
# Look Before You Leap (LBYL) is appropriate here instead of Easier to Ask for
951
# Forgiveness than Permission (EAFP) because:
952
# - root can damage a solaris file system by using unlink,
953
# - unlink raises different exceptions on different OSes (linux: EISDIR, win32:
954
# EACCES, OSX: EPERM) when invoked on a directory.
937
955
if isdir(path): # Takes care of symlinks
1025
while len(head) >= len(base):
1044
if len(head) <= len(base) and head != base:
1045
raise errors.PathNotChild(rp, base)
1026
1046
if head == base:
1028
head, tail = os.path.split(head)
1048
head, tail = split(head)
1032
raise errors.PathNotChild(rp, base)
1053
return pathjoin(*reversed(s))