This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Resolve path to macOS alias file | |
Given a path to a file that is a macOS alias, resolve the path to the original file | |
Requires: pip install pyobjc-core | |
""" | |
from Foundation import ( | |
NSURL, | |
NSData, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Resolve path to original file pointed to by macOS alias | |
To use: | |
pip install pyobjc-core | |
python3 resolve_macos_alias_path.py /path/to/alias | |
""" | |
from Foundation import ( | |
NSURL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Given a PyPI package name, print the latest version number of the package. | |
This uses the standard library instead of requests to avoid adding a dependency to the project. | |
""" | |
from __future__ import annotations | |
import json | |
import ssl | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# PyApp Runner | |
# This script is used to build and copy the PyApp executable | |
# See https://ofek.dev/pyapp/latest/how-to/ for more information on PyApp. | |
# Change this to the path where pyapp is installed | |
PYAPP="/path/to/pyapp-latest" | |
# Check that both arguments are provided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# PyApp Runner | |
# This script is used to build and copy the PyApp executable from a remote server. | |
# See https://ofek.dev/pyapp/latest/how-to/ for more information on PyApp. | |
# The remote server must have PYAPP defined in the ~/.zshenv file | |
# to point to the install location of pyapp. | |
# For example: | |
# echo 'export PYAPP="/Users/johndoe/code/pyapp-latest"' >> ~/.zshenv | |
# For code signing to work via ssh, you must first run this one time on the machine via GUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Implements a minimalist Cocoa application using pyobjc | |
Based on the example found here: | |
https://www.cocoawithlove.com/2010/09/minimalist-cocoa-programming.html | |
To run this: | |
- save as minimal.py | |
- pip3 install pyobjc | |
- python3 minimal.py | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Get EXIF/IPTC/XMP metadata from an image file on macOS using CoreGraphics via pyobjc. | |
Requires installation of the following [pyobjc](https://pyobjc.readthedocs.io/en/latest/index.html) packages: | |
`pip install pyobjc-core pyobjc-framework-Quartz` | |
This module provides 3 public functions: | |
- get_image_properties(): Returns the metadata properties dictionary from the image at the given path. | |
- get_image_xmp_metadata(): Returns the XMP metadata dictionary from the image at the given path. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Change symlink to Python version in /usr/local/bin/python to point to a | |
# specified version as installed by the official python.org installer for macOS | |
# usage: ./pyver.sh <version> | |
# when called without arguments, prints the currently linked Python version | |
# This is useful for use with pyenv (https://github.com/pyenv/pyenv) which can only | |
# handle a single "system" python version and offers no way to switch between multiple | |
# system pythons |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Copy a file on macOS using native API. | |
This allows copied files to use copy-on-write when used on a volume formatted with APFS. | |
When used on an APFS volume, a file copied with this function will be copied almost instantly | |
and will not use any additional disk space until the file is modified. | |
To use, you will need to install pyobjc-core and pyobjc-framework-Cocoa: | |
`python3 -m pip install pyobjc-core pyobjc-framework-Cocoa` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Count photos for a given query criteria""" | |
from __future__ import annotations | |
import osxphotos | |
from osxphotos.cli import query_command | |
@query_command | |
def count_photos(photos: list[osxphotos.PhotoInfo], **kwargs): |
NewerOlder