def get_osx_tags(path): try: tags = mac_tag.get([path]) return tags[path] except Exception as e: print('exeption: ', e) return False
def get_finder_tags_for_path(path: str) -> [dict]: """Returns the Finder tags for a given file or folder. :param path: The path of the file of folder to examine. :raise FileNotFoundError: If the path does not points to anything reachable. :return: A list of tags as a dict with their titles and colors names. """ try: tags_dict = mac_tag.get(path) tags = [] """Access in a unnatural way due to some conflicts with complicated paths... It is known that the dict will only contain one value""" for e in tags_dict: tags.extend(tags_dict[e]) return tags except FileNotFoundError: raise FileNotFoundError(path)
#!/usr/bin/env python # -*- coding: utf-8 -*- import mac_tag tags = ["Red", "Blue"] path = [__file__] mac_tag.add(tags, path) mac_tag.remove(["Red"], path) mac_tag.remove(["*"], path) tags = mac_tag.get(path) print(tags)
def get_tags(paths): return mac_tag.get(paths)
#!/usr/bin/env python # -*- coding: utf-8 -*- import mac_tag tags = ["Red", "Blue"] path = [__file__] mac_tag.add(tags, path) print(mac_tag.get(path))
sys.stdout.write(question + prompt) choice = input().lower() if default is not None and choice == '': return valid[default] elif choice in valid: return valid[choice] else: sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n") filepath = sys.argv[1] jpgFiles = [ f for f in listdir(filepath) if isfile(join(filepath, f)) and mac_tag.get(join(filepath, f))[join(filepath, f)] == ["Keep.Photo"] ] rawFiles = [f[:-3] + "ORF" for f in jpgFiles] deletedFiles = [] # Delete un-tagged jpg files for f in listdir(filepath): if ".JPG" in f and f not in set(jpgFiles): deletedFiles.append(filepath + "/" + f) # Delete un-tagged RAW/ORF files for f in listdir(filepath + "/raw"): if f not in set(rawFiles): deletedFiles.append(filepath + "/raw/" + f)