_filemode was leftover from python2 backwards compatibility

This commit is contained in:
Andrew Hamilton 2015-12-19 12:39:16 +00:00
parent bbbe0aaeb6
commit 05732fa20e

View file

@ -185,19 +185,6 @@ def md5(path): # Deps: coreutils
return hashlib.md5(file.read()).hexdigest() return hashlib.md5(file.read()).hexdigest()
def _filemode(mode):
"""Convert a file's mode to a string of the form '-rwxrwxrwx'."""
perm = []
for table in stat._filemode_table:
for bit, char in table:
if mode & bit == bit:
perm.append(char)
break
else:
perm.append("-")
return "".join(perm)
def metadata(path): # Deps: file, coreutils def metadata(path): # Deps: file, coreutils
def _detail(value, unit): def _detail(value, unit):
@ -205,7 +192,7 @@ def metadata(path): # Deps: file, coreutils
(value, unit)) (value, unit))
is_symlink = "yes" if os.path.islink(path) else "no" is_symlink = "yes" if os.path.islink(path) else "no"
stat_result = os.stat(path) stat_result = os.stat(path)
permissions = _filemode(stat_result.st_mode) permissions = stat.filemode(stat_result.st_mode)
hardlinks = str(stat_result.st_nlink) hardlinks = str(stat_result.st_nlink)
group = [pwd.getpwuid(stat_result.st_gid).pw_name, group = [pwd.getpwuid(stat_result.st_gid).pw_name,
_detail(stat_result.st_gid, "gid")] _detail(stat_result.st_gid, "gid")]