add dncli to the family

This commit is contained in:
2022-09-21 08:09:03 -04:00
parent c0397934e2
commit 0833acd067
3 changed files with 182 additions and 0 deletions
+36
View File
@@ -96,6 +96,39 @@ COLOR_THEME = ''' { "heading": ("yellow","blue"),
now = time.time()
YEAR = 3600*24*365
#
# deal with the odd aspects of MacOS
#
# xattr is loaded as a separate library, with different argument names
# to set/get the comments in Finder, we need to call osascript
#
if sys.platform == "darwin":
# we get xattr from PyPi
try:
import xattr
except:
print("This program requires the 'xattr' package. Please use 'pip3 install xattr' to install the package")
sys.exit(1)
def do_setxattr(file_name, attr_name, attr_content):
if attr_name.endswith("omment"):
p = Popen(['osascript','-'] + f'tell application "Finder" to set comment of (POSIX file "{file_name}" as alias) to "{attr_content}"')
p.communicate()
else:
xattr.setxattr(file_name, attr_name, plistlib.dumps(attr_content))
os.setxattr = do_setxattr
#os.setxattr = xattr.setxattr
def do_getxattr(file_name, attr_name):
attr_data = xattr.getxattr(file_name, attr_name)
if attr_name.endswith("omment"):
return plistlib.loads(attr_data)
else:
return attr_data
os.getxattr = xattr.getxattr
else:
pass
class Pane:
''' holds the whole display: handles file list directly,
fills a child pad with the file info,
@@ -919,3 +952,6 @@ cwd = args.directory
curses.wrapper(main, cwd)
# dirnotes database is name, date, size, comment, comment_date, author
# symlinks: follow_symlinks should always be True, because symlinks in Linux
# can't have xattr....it appears to be the same in darwin