mac_alias package

Classes

class mac_alias.Alias(appinfo=b'\x00\x00\x00\x00', version=2, volume=None, target=None, extra=[])
appinfo

Application specific information (four byte byte-string)

extra

A list of extra (tag, value) pairs

classmethod for_file(path)

Create an Alias that points at the specified file.

classmethod from_bytes(bytes)

Construct an Alias object given binary Alias data.

target

A TargetInfo object describing the target

to_bytes()

Returns the binary representation for this Alias.

version

Version (we support versions 2 and 3)

volume

A VolumeInfo object describing the target’s volume

class mac_alias.AppleShareInfo(zone=None, server=None, user=None)
server

The AFP server

user

The username

zone

The AppleShare zone

class mac_alias.VolumeInfo(name, creation_date, fs_type, disk_type, attribute_flags, fs_id, appleshare_info=None, driver_name=None, posix_path=None, disk_image_alias=None, dialup_info=None, network_mount_info=None)
appleshare_info

AppleShare information (for automatic remounting of network shares) (optional)

attribute_flags

Filesystem attribute flags (from HFS volume header)

creation_date

The creation date of the target’s volume

dialup_info

Dialup information (for automatic establishment of dialup connections)

disk_image_alias

Alias object pointing at the disk image on which the target’s volume resides (optional)

disk_type

The type of disk; should be one of

  • ALIAS_FIXED_DISK

  • ALIAS_NETWORK_DISK

  • ALIAS_400KB_FLOPPY_DISK

  • ALIAS_800KB_FLOPPY_DISK

  • ALIAS_1_44MB_FLOPPY_DISK

  • ALIAS_EJECTABLE_DISK

driver_name

Driver name (probably contains a disk driver name on older Macs) (optional)

property filesystem_type
fs_id

Filesystem identifier

fs_type

The filesystem type (for v2 aliases, this is a 2-character code; for v3 aliases, a 4-character code).

name

The name of the volume on which the target resides

network_mount_info

Network mount information (for automatic remounting)

posix_path

POSIX path of the mount point of the target’s volume (optional)

class mac_alias.TargetInfo(kind, filename, folder_cnid, cnid, creation_date, creator_code, type_code, levels_from=-1, levels_to=-1, folder_name=None, cnid_path=None, carbon_path=None, posix_path=None, user_home_prefix_len=None)
carbon_path

The Carbon path of the target (optional)

cnid

The CNID (Catalog Node ID) of the target

cnid_path

The path from the volume root as a sequence of CNIDs. (optional)

creation_date

The target’s creation date.

creator_code

The target’s Mac creator code (a four-character binary string)

filename

The filename of the target

folder_cnid

The CNID (Catalog Node ID) of the target’s containing folder; CNIDs are similar to but different than traditional UNIX inode numbers

folder_name

The (POSIX) name of the target’s containing folder. (optional)

kind

Either ALIAS_KIND_FILE or ALIAS_KIND_FOLDER

levels_from

The depth of the alias? Always seems to be -1 on OS X.

levels_to

The depth of the target? Always seems to be -1 on OS X.

posix_path

The POSIX path of the target relative to the volume root. Note that this may or may not have a leading ‘/’ character, but it is always relative to the containing volume. (optional)

type_code

The target’s Mac type code (a four-character binary string)

user_home_prefix_len

If the path points into a user’s home folder, the number of folders deep that we go before we get to that home folder. (optional)

class mac_alias.Bookmark(tocs=None)
classmethod for_file(path)

Construct a Bookmark for a given file.

classmethod from_bytes(data)

Create a Bookmark given byte data.

get(key, default=None)

Lookup the value for a given key, returning a default if not present.

to_bytes()

Convert this Bookmark to a byte representation.

tocs

The TOCs for this Bookmark

class mac_alias.Data(bytedata=None)
bytes

The bytes, stored as a byte string

class mac_alias.URL(base, rel=None)
property absolute

Return an absolute URL.

base

The base URL, if any (a URL)

relative

The rest of the URL (a string)

Constants

mac_alias.ALIAS_KIND_FILE
mac_alias.ALIAS_KIND_FOLDER

Values for the TargetInfo.kind attribute.

mac_alias.ALIAS_HFS_VOLUME_SIGNATURE

The volume signature for HFS+.

mac_alias.ALIAS_FILESYSTEM_UDF
mac_alias.ALIAS_FILESYSTEM_FAT32
mac_alias.ALIAS_FILESYSTEM_EXFAT
mac_alias.ALIAS_FILESYSTEM_HFSX
mac_alias.ALIAS_FILESYSTEM_HFSPLUS
mac_alias.ALIAS_FILESYSTEM_FTP
mac_alias.ALIAS_FILESYSTEM_NTFS
mac_alias.ALIAS_FILESYSTEM_UNKNOWN

Values returned by the VolumeInfo.filesystem_type attribute.

mac_alias.ALIAS_FIXED_DISK
mac_alias.ALIAS_NETWORK_DISK
mac_alias.ALIAS_400KB_FLOPPY_DISK
mac_alias.ALIAS_800KB_FLOPPY_DISK
mac_alias.ALIAS_1_44MB_FLOPPY_DISK
mac_alias.ALIAS_EJECTABLE_DISK

Disk type constants.

mac_alias.ALIAS_NO_CNID

A constant used where no CNID is present.

mac_alias.kBookmarkURL
mac_alias.kBookmarkPath
mac_alias.kBookmarkCNIDPath
mac_alias.kBookmarkFileProperties
mac_alias.kBookmarkFileName
mac_alias.kBookmarkFileID
mac_alias.kBookmarkFileCreationDate
mac_alias.kBookmarkTOCPath
mac_alias.kBookmarkVolumePath
mac_alias.kBookmarkVolumeURL
mac_alias.kBookmarkVolumeName
mac_alias.kBookmarkVolumeUUID
mac_alias.kBookmarkVolumeSize
mac_alias.kBookmarkVolumeCreationDate
mac_alias.kBookmarkVolumeProperties
mac_alias.kBookmarkContainingFolder
mac_alias.kBookmarkUserName
mac_alias.kBookmarkUID
mac_alias.kBookmarkWasFileReference
mac_alias.kBookmarkCreationOptions
mac_alias.kBookmarkURLLengths
mac_alias.kBookmarkDisplayName
mac_alias.kBookmarkIconData
mac_alias.kBookmarkIconRef
mac_alias.kBookmarkTypeBindingData
mac_alias.kBookmarkCreationTime
mac_alias.kBookmarkSandboxRwExtension
mac_alias.kBookmarkSandboxRoExtension
mac_alias.kBookmarkAliasData
mac_alias.kBookmarkSecurityExtension

Bookmark data keys. A Bookmark holds a set of TOCs (Tables of Contents), each of which maps a set of keys to a set of values. The keys are either numeric, like the ones represented by the above constants, or strings.

Bookmarks can hold strings, byte data, numbers, dates, booleans, arrays, dicts, UUIDs, URLs and NULLs (represented by Python None). If you store data in a bookmark using the string key functionality, the documentation for CF/NSURL recommends using reverse DNS for the keys to avoid clashes.