metapho package

Subpackages

Submodules

metapho.metapho module

These are the base class for metapho images and taggers. Programs with better UI can inherit from these classes.

class metapho.metapho.Image(filename, displayed=True)[source]

Bases: object

An image, with additional info such as rotation and tags.

classmethod clean_up_nonexistent_files(topdir)[source]

For any file that was referenced in a tag file but doesn’t exist on disk, see if perhaps it’s been moved to a different subdirectory under topdir. If so, adjust file path appropriately.

delete()[source]

Delete the image file FROM DISK, and the image object from the imageList. DOES NOT ASK FOR CONFIRMATION – do that (if desired) from the calling program.

classmethod find_nonexistent_files()[source]

Returns a list of images in the imagelist that don’t exist on disk.

g_image_list = []
classmethod image_index(filename)[source]

Find a name in the global image list. Return index, or None.

class metapho.metapho.Tagger[source]

Bases: object

Manages tags for images.

IGNORE_DIRNAMES = ['html', 'web', 'bad']
SKIP_EXTENSIONS = ['.cr2', '.arw', '.xcf', '.mvi', '.avi', '.mov', '.thm', '.mp4', '.mkv', '.pto', '.txt', '.wav', '.mp3', '.xml']
add_tag(tag, img)[source]

Add a tag to the given image. img is a metapho.Image. tag may be a string, which can be a new string or an existing one, or an integer index into the tag list. Return the index (in the global tags list) of the tag just added, or None if error.

check_commondir(d)[source]

Keep track of the dir common to all directories we use: XXX commondir code is still somewhat experimental.

clear_tags(img)[source]
find_untagged_files(topdir)[source]

Return a list of untagged files and a list of directories in which nothing is tagged, under topdir.

classmethod ignore_directory(d, path=None)[source]

Detect directory names that don’t need to be indexed separately and aren’t likely to have a Tags file; for instance, those that likely contain copies of what’s in the parent, or small copies for a web page. Also, you can skip tagging by creating a file named NoTags.

match_tag(pattern)[source]

Return a list of tags matching the pattern.

static print_files_by_directory(filelist)[source]

Given a list of pathnames, group them by which directory they belong to and print them in an organized way.

process_tag(tagname, filenames)[source]

After reading a tag from a tags file, add it to the global tags list if it isn’t there already, and add the given filenames to it.

read_all_tags_for_images()[source]

Read tags in all directories used by known images, plus the common dir, plus .

read_tags(dirname, recursive=True)[source]

Read in tags from files named in the given directory, and tag images in the imagelist appropriately. Tags will be appended to the tag_list. If recursive is True, we’ll also look for Tags files in subdirectories.

remove_tag(tag, img)[source]
rename_category(old, new)[source]
static split_by_line_length(s, linelen, prefix='')[source]

Given a long string, split it into lines no longer than linelen, with each line optionally prefixed, e.g. with indentation. Currently this splits only at spaces, not tabs.

toggle_tag(tagno, img)[source]

Toggle tag number tagno for the given img.

write_tag_file()[source]

Save the current set of tags to a Tags file chosen from the top-level directory used in the images we’ve seen. If there was a previous Tags file there, it will be saved as Tags.bak.

metapho.metapho.Usage()[source]
metapho.metapho.commonprefix(paths)[source]
metapho.metapho.main()[source]

Read tags and report any inconsistencies: images in the Tags file that don’t exist on disk, images on disk that aren’t in ./Tags.

Module contents

metapho: an image tagger and viewer.

class metapho.Image(filename, displayed=True)[source]

Bases: object

An image, with additional info such as rotation and tags.

classmethod clean_up_nonexistent_files(topdir)[source]

For any file that was referenced in a tag file but doesn’t exist on disk, see if perhaps it’s been moved to a different subdirectory under topdir. If so, adjust file path appropriately.

delete()[source]

Delete the image file FROM DISK, and the image object from the imageList. DOES NOT ASK FOR CONFIRMATION – do that (if desired) from the calling program.

classmethod find_nonexistent_files()[source]

Returns a list of images in the imagelist that don’t exist on disk.

g_image_list = []
classmethod image_index(filename)[source]

Find a name in the global image list. Return index, or None.

class metapho.Tagger[source]

Bases: object

Manages tags for images.

IGNORE_DIRNAMES = ['html', 'web', 'bad']
SKIP_EXTENSIONS = ['.cr2', '.arw', '.xcf', '.mvi', '.avi', '.mov', '.thm', '.mp4', '.mkv', '.pto', '.txt', '.wav', '.mp3', '.xml']
add_tag(tag, img)[source]

Add a tag to the given image. img is a metapho.Image. tag may be a string, which can be a new string or an existing one, or an integer index into the tag list. Return the index (in the global tags list) of the tag just added, or None if error.

check_commondir(d)[source]

Keep track of the dir common to all directories we use: XXX commondir code is still somewhat experimental.

clear_tags(img)[source]
find_untagged_files(topdir)[source]

Return a list of untagged files and a list of directories in which nothing is tagged, under topdir.

classmethod ignore_directory(d, path=None)[source]

Detect directory names that don’t need to be indexed separately and aren’t likely to have a Tags file; for instance, those that likely contain copies of what’s in the parent, or small copies for a web page. Also, you can skip tagging by creating a file named NoTags.

match_tag(pattern)[source]

Return a list of tags matching the pattern.

static print_files_by_directory(filelist)[source]

Given a list of pathnames, group them by which directory they belong to and print them in an organized way.

process_tag(tagname, filenames)[source]

After reading a tag from a tags file, add it to the global tags list if it isn’t there already, and add the given filenames to it.

read_all_tags_for_images()[source]

Read tags in all directories used by known images, plus the common dir, plus .

read_tags(dirname, recursive=True)[source]

Read in tags from files named in the given directory, and tag images in the imagelist appropriately. Tags will be appended to the tag_list. If recursive is True, we’ll also look for Tags files in subdirectories.

remove_tag(tag, img)[source]
rename_category(old, new)[source]
static split_by_line_length(s, linelen, prefix='')[source]

Given a long string, split it into lines no longer than linelen, with each line optionally prefixed, e.g. with indentation. Currently this splits only at spaces, not tabs.

toggle_tag(tagno, img)[source]

Toggle tag number tagno for the given img.

write_tag_file()[source]

Save the current set of tags to a Tags file chosen from the top-level directory used in the images we’ve seen. If there was a previous Tags file there, it will be saved as Tags.bak.