pyTagger package

Submodules

pyTagger.models module

pyTagger.models.makeEnum(name, *sequential, **named)[source]

Implement an enum type in python

Credit: https://stackoverflow.com/questions/36932/

pyTagger.models.COMPARISON

Enumerated values used with pyTagger.actions.where.process()

alias of Comparison

class pyTagger.models.FilterCondition[source]

Bases: pyTagger.models.FilterCondition_

A named tuple class that tracks WHERE conditions

Members:

field (str): The field to compare

comparison (COMPARISON): The type of comparision

value: The value to compare

class pyTagger.models.TrackMatch[source]

Bases: pyTagger.models.TrackMatch_

Instances of this class are generated by pyTagger.operations.find_duplicates.findIsonoms() and identify a possible match between two tracks.

Members:
status (str): Tracks the status of the match.

‘single’: There is only one match for newTags in the set

‘multiple’: There are multiple matches for newTags in the set

‘nothing’: There are no matches for newTags

‘insufficient’: An error occurred during matching

‘ready’: The match has been validated

‘manual’: The match will require manual editing

newPath (str): The file location of the track being matched

oldPath (str): The file location of a potential match

score (float): The strength of the match. Higher is better

newTags (dict): The tags of the track being matched

oldTags (dict): The tags of the potential match

class pyTagger.models.Snapshot[source]

Bases: object

The main data structure of the application. It is a dictionary of paths with each path holding a dictionary of ID3 tags

Example

{
  '/path/to/file1': {'artist': 'foo', 'album': 'bar'},
  '/path/to/file2': {'artist': 'foo', 'album': 'baz'}
}
basic = [‘title’, ‘track’, ‘totalTrack’, ‘artist’, ‘albumArtist’, ‘album’, ‘length’]

Tags for the most widely supported information about a track

songwriting = [‘bpm’, ‘composer’, ‘key’, ‘lyrics’, ‘language’]

Tags related to the composition and musical form of the track

production = [‘year’, ‘releaseDate’, ‘originalReleaseDate’, ‘recordingDate’, ‘conductor’, ‘remixer’, ‘publisher’]

Tags related to the publication and release of the track

distribution = [‘barcode’, ‘media’, ‘disc’, ‘totalDisc’]

Tags related to how this track was packaged

library = [‘genre’, ‘id’, ‘ufid’, ‘compilation’, ‘comments’, ‘playCount’, ‘group’, ‘subtitle’, ‘encodingDate’, ‘taggingDate’]

Tags useful to those who obsessively curate their music collection ;)

mp3Info = [‘bitRate’, ‘vbr’, ‘fileHash’, ‘version’]

Tags related to how this track is encoded

dltTags = [‘comments’, ‘lyrics’]

Tags that have the form: ‘Description’, ‘Language’ and ‘Text’

complexTags = [‘comments’, ‘lyrics’, ‘ufid’]

Tags that can have multiple instances in the same track

integerTags = [‘track’, ‘totalTrack’, ‘length’, ‘disc’, ‘totalDisc’, ‘compilation’, ‘playCount’, ‘bitRate’]

Numeric tags

static orderedAllColumns()[source]

Provides an ordered list of all supported ID3 tags

static columnsFromSnapshot(data)[source]

Determines the tags used in a snapshot

Args:
data (Snapshot): The snapshot to analyze
Returns:

A list of tags from the snapshot in the following order:

  1. The standard order
  2. Any unrecognized fields in alphanumeric order
static columnsFromArgs(args)[source]

Determines which tags are requested from command line options

Args:
args (argparse): The options parsed from the command line or configuration file
Returns:
An ordered list of all requested tags

If args does not contain any tag options, the basic set will be returned.

pyTagger.utils module

pyTagger.utils.defaultConfigFiles = [u’./config.ini’, u’~/pyTagger.ini’]

Possible locations for the configuration file

pyTagger.utils.configurationOptions(name)[source]

Gets the set of known arguments from a specific parser

Args:
name (str): The name of the parser to get options from
Returns:
An object with the options as attributes
pyTagger.utils.toAbsolute(path)[source]

Determines the absolute path from a relative path

Args:
path (str): A path relative to setup.py
Returns:
The absolute path
pyTagger.utils.loadJson(fileName)[source]

Provides an application-wide standard for loading JSON files

The application standard uses UTF-8 and no newline translation

Args:
fileName (str): The absolute path to a JSON file
Returns:
A fully-loaded, deserialized version of the JSON file
pyTagger.utils.saveJson(fileName, o)[source]

Provides an application-wide standard for saving JSON files

Args:

fileName (str): The absolute path to where the JSON file should be written

o (object): The object that will be written out

These steps are used for writing the JSON in the application’s standard:
  1. Convert the entire object to a JSON string
  2. Ensure the string is Unicode
  3. Write out to the filename using UTF-8 encoding
pyTagger.utils.saveJsonIncrementalArray(fileName)[source]

Provides a way to write an array to a JSON file, one item at a time

The JSON file is written using the same standards as saveJson()

Args:
fileName (str): The absolute path to where the JSON file should be written
Yields:
int: The current number of rows processed

Example Usage:

output = saveJsonIncrementalArray(fileName)

counted = next(output)

for row in someArray:
    counted = output.send(row)

output.close()
pyTagger.utils.saveJsonIncrementalDict(fileName, compact=False)[source]

Provides a way to write a dictionary to a JSON file, one item at a time

The JSON file is written using the same standards as saveJson()

Args:

fileName (str): The absolute path to where the JSON file should be written

compact (bool): True if the resulting JSON should be written as densely as possible

Yields:
int: The current number of rows processed

Example Usage:

output = saveJsonIncrementalDict(fileName)

counted = next(output)

for key, value in someDict.items():
    pair = (key, value)
    counted = output.send(pair)

output.close()
pyTagger.utils.generateUfid()[source]

Generate a unique identifer

Returns:
str: A 24 character string that should be unique across time and space
pyTagger.utils.fmap(fns, x)[source]

A version of the Haskell functor concept

Args:

fns (list[functions]): A list of functions to apply.

x (object): The object that will be passed to all functions

Returns:
The value of x after calling the last function

All the functions should have the same signature: def foo(x) -> x

Module contents