- acls = None
- def_acls = None
- try:
- if posix1e.has_extended(path):
- acl = posix1e.ACL(file=path)
- acls = [acl, acl] # txt and num are the same
- if stat.S_ISDIR(st.st_mode):
- def_acl = posix1e.ACL(filedef=path)
- def_acls = [def_acl, def_acl]
- except EnvironmentError as e:
- if e.errno not in (errno.EOPNOTSUPP, errno.ENOSYS):
- raise
- if acls:
- txt_flags = posix1e.TEXT_ABBREVIATE
- num_flags = posix1e.TEXT_ABBREVIATE | posix1e.TEXT_NUMERIC_IDS
- acl_rep = [acls[0].to_any_text('', '\n', txt_flags),
- acls[1].to_any_text('', '\n', num_flags)]
- if def_acls:
- acl_rep.append(def_acls[0].to_any_text('', '\n', txt_flags))
- acl_rep.append(def_acls[1].to_any_text('', '\n', num_flags))
- self.posix1e_acl = acl_rep
+ isdir = 1 if stat.S_ISDIR(st.st_mode) else 0
+ self.posix1e_acl = read_acl(path, isdir)