mishmash package¶
Subpackages¶
Submodules¶
mishmash.config module¶
mishmash.console module¶
mishmash.core module¶
-
class
mishmash.core.
Command
(subparsers=None, **kwargs)[source]¶ Bases:
nicfit.command.Command
Base class for MishMash commands.
Construct a command. Any kwargs are added to the class object using
setattr
. All commands have an ArgumentParser, either constructed here or whensubparsers
is given a new parser is created using itsadd_parser
method.
mishmash.database module¶
-
class
mishmash.database.
DatabaseInfo
(engine, SessionMaker, connection)¶ Bases:
tuple
Create new instance of DatabaseInfo(engine, SessionMaker, connection)
-
SessionMaker
¶ Alias for field number 1
-
connection
¶ Alias for field number 2
-
engine
¶ Alias for field number 0
-
mishmash.orm module¶
Object to relational database mappings for all tables.
-
class
mishmash.orm.
Album
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
,mishmash.orm.OrmObject
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
DATE_LIMIT
= 24¶
-
TITLE_LIMIT
= 256¶
-
artist
¶
-
artist_id
¶
-
date_added
¶
-
duration
¶
-
id
¶
-
images
¶ one-to-many album images.
-
lib_id
¶
-
library
¶
-
original_release_date
¶
-
recording_date
¶
-
release_date
¶
-
title
¶
-
tracks
¶
-
type
¶
-
-
class
mishmash.orm.
AlbumDate
(*args, **kwargs)[source]¶ Bases:
sqlalchemy.sql.type_api.TypeDecorator
Custom column type for eyed3.core.Date objects. That is, dates than can have empty rather than default date fields. For example, 1994 with no month and day is different than 1994-01-01, as datetime provides.
Construct a
TypeDecorator
.Arguments sent here are passed to the constructor of the class assigned to the
impl
class level attribute, assuming theimpl
is a callable, and the resulting object is assigned to theself.impl
instance attribute (thus overriding the class attribute of the same name).If the class level
impl
is not a callable (the unusual case), it will be assigned to the same instance attribute ‘as-is’, ignoring those arguments passed to the constructor.Subclasses can override this to customize the generation of
self.impl
entirely.-
impl
= String(length=24)¶
-
process_bind_param
(value, dialect)[source]¶ Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngine
object, and from there to the DBAPIexecute()
method.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
This operation should be designed with the reverse operation in mind, which would be the process_result_value method of this class.
Parameters: - value – Data to operate upon, of any type expected by
this method in the subclass. Can be
None
. - dialect – the
Dialect
in use.
- value – Data to operate upon, of any type expected by
this method in the subclass. Can be
-
process_result_value
(value, dialect)[source]¶ Receive a result-row column value to be converted.
Subclasses should implement this method to operate on data fetched from the database.
Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying
TypeEngine
object, originally from the DBAPI cursor methodfetchone()
or similar.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
Parameters: - value – Data to operate upon, of any type expected by
this method in the subclass. Can be
None
. - dialect – the
Dialect
in use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- value – Data to operate upon, of any type expected by
this method in the subclass. Can be
-
-
class
mishmash.orm.
Artist
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
,mishmash.orm.OrmObject
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
CITY_LIMIT
= 64¶
-
COUNTRY_LIMIT
= 3¶
-
NAME_LIMIT
= 256¶
-
SORT_NAME_LIMIT
= 258¶
-
STATE_LIMIT
= 32¶
-
albums
¶ all albums by the artist
-
date_added
¶
-
id
¶
-
images
¶ one-to-many artist images.
-
is_various_artist
¶
-
lib_id
¶
-
library
¶
-
name
¶
-
origin_city
¶
-
origin_country
¶
-
origin_state
¶
-
sort_name
¶
one-to-many (artist->tag) and many-to-one (tag->artist)
-
tracks
¶ all tracks by the artist
-
url_name
¶
-
-
class
mishmash.orm.
Image
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
,mishmash.orm.OrmObject
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
ARTIST_TYPE
= 'ARTIST'¶
-
BACK_COVER_TYPE
= 'BACK_COVER'¶
-
DESC_LIMIT
= 1024¶
-
FRONT_COVER_TYPE
= 'FRONT_COVER'¶
-
IMAGE_TYPES
= ['FRONT_COVER', 'BACK_COVER', 'MISC_COVER', 'LOGO', 'ARTIST', 'LIVE']¶
-
LIVE_TYPE
= 'LIVE'¶
-
LOGO_TYPE
= 'LOGO'¶
-
MD5_LIMIT
= 32¶
-
MIMETYPE_LIMIT
= 32¶
-
MISC_COVER_TYPE
= 'MISC_COVER'¶
-
data
¶
-
description
¶ The description will be the base file name when the source if a file.
-
id
¶
-
md5
¶
-
mime_type
¶
-
size
¶
-
type
¶
-
-
class
mishmash.orm.
Library
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
,mishmash.orm.OrmObject
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
NAME_LIMIT
= 64¶
-
id
¶
-
classmethod
iterall
(session, names=None)[source]¶ Iterate over all Library rows found in session. :param names: Optional sequence of names to filter on.
-
last_sync
¶
-
name
¶
-
-
class
mishmash.orm.
Meta
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
,mishmash.orm.OrmObject
Table
meta
used for storing database schema version, timestamps, and any other metadata about the music collection.A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
VERSION_LIMIT
= 32¶
-
last_sync
¶ A UTC timestamp of the last sync operation.
-
version
¶ The MishMash version defines the database schema.
-
-
class
mishmash.orm.
OrmObject
[source]¶ Bases:
object
Base classes for all other mishmash.orm classes.
-
mishmash.orm.
TABLES
= [Table('meta', MetaData(bind=None), Column('version', String(length=32), table=<meta>, primary_key=True, nullable=False), Column('last_sync', DateTime(), table=<meta>), schema=None), Table('libraries', MetaData(bind=None), Column('id', Integer(), table=<libraries>, primary_key=True, nullable=False, default=Sequence('libraries_id_seq', metadata=MetaData(bind=None))), Column('name', Unicode(length=64), table=<libraries>, nullable=False), Column('last_sync', DateTime(), table=<libraries>), schema=None), Table('tags', MetaData(bind=None), Column('id', Integer(), table=<tags>, primary_key=True, nullable=False, default=Sequence('tags_id_seq', metadata=MetaData(bind=None))), Column('name', Unicode(length=64), table=<tags>, nullable=False), Column('lib_id', Integer(), ForeignKey('libraries.id'), table=<tags>, nullable=False), schema=None), Table('artists', MetaData(bind=None), Column('id', Integer(), table=<artists>, primary_key=True, nullable=False, default=Sequence('artists_id_seq', metadata=MetaData(bind=None))), Column('name', Unicode(length=256), table=<artists>, nullable=False), Column('sort_name', Unicode(length=258), table=<artists>, nullable=False), Column('date_added', DateTime(), table=<artists>, nullable=False, default=ColumnDefault(<function datetime.now>)), Column('origin_city', Unicode(length=64), table=<artists>), Column('origin_state', Unicode(length=32), table=<artists>), Column('origin_country', String(length=3), table=<artists>), Column('lib_id', Integer(), ForeignKey('libraries.id'), table=<artists>, nullable=False), schema=None), Table('albums', MetaData(bind=None), Column('id', Integer(), table=<albums>, primary_key=True, nullable=False, default=Sequence('albums_id_seq', metadata=MetaData(bind=None))), Column('title', Unicode(length=256), table=<albums>, nullable=False), Column('type', Enum('lp', 'ep', 'compilation', 'live', 'various', 'demo', 'single', name='album_types'), table=<albums>, nullable=False, default=ColumnDefault('lp')), Column('date_added', DateTime(), table=<albums>, nullable=False, default=ColumnDefault(<function datetime.now>)), Column('release_date', AlbumDate(length=24), table=<albums>), Column('original_release_date', AlbumDate(length=24), table=<albums>), Column('recording_date', AlbumDate(length=24), table=<albums>), Column('artist_id', Integer(), ForeignKey('artists.id'), table=<albums>, nullable=False), Column('lib_id', Integer(), ForeignKey('libraries.id'), table=<albums>, nullable=False), schema=None), Table('tracks', MetaData(bind=None), Column('id', Integer(), table=<tracks>, primary_key=True, nullable=False, default=Sequence('tracks_id_seq', metadata=MetaData(bind=None))), Column('path', String(length=2048), table=<tracks>, nullable=False), Column('size_bytes', Integer(), table=<tracks>, nullable=False), Column('ctime', DateTime(), table=<tracks>, nullable=False), Column('mtime', DateTime(), table=<tracks>, nullable=False), Column('date_added', DateTime(), table=<tracks>, nullable=False, default=ColumnDefault(<function datetime.now>)), Column('time_secs', Float(), table=<tracks>, nullable=False), Column('title', Unicode(length=256), table=<tracks>, nullable=False), Column('track_num', SmallInteger(), table=<tracks>), Column('track_total', SmallInteger(), table=<tracks>), Column('media_num', SmallInteger(), table=<tracks>), Column('media_total', SmallInteger(), table=<tracks>), Column('bit_rate', SmallInteger(), table=<tracks>), Column('variable_bit_rate', Boolean(), table=<tracks>), Column('metadata_format', Enum('ID3v1.0', 'ID3v1.1', 'ID3v2.2', 'ID3v2.3', 'ID3v2.4', name='metadata_format'), table=<tracks>, nullable=False), Column('artist_id', Integer(), ForeignKey('artists.id'), table=<tracks>, nullable=False), Column('album_id', Integer(), ForeignKey('albums.id'), table=<tracks>), Column('lib_id', Integer(), ForeignKey('libraries.id'), table=<tracks>, nullable=False), schema=None), Table('images', MetaData(bind=None), Column('id', Integer(), table=<images>, primary_key=True, nullable=False, default=Sequence('images_id_seq', metadata=MetaData(bind=None))), Column('type', Enum('FRONT_COVER', 'BACK_COVER', 'MISC_COVER', 'LOGO', 'ARTIST', 'LIVE', name='image_types'), table=<images>, nullable=False), Column('mime_type', String(length=32), table=<images>, nullable=False), Column('md5', String(length=32), table=<images>, nullable=False), Column('size', Integer(), table=<images>, nullable=False), Column('description', String(length=1024), table=<images>, nullable=False), Column('data', LargeBinary(), table=<images>, nullable=False), schema=None), Table('artist_tags', MetaData(bind=None), Column('artist_id', Integer(), ForeignKey('artists.id'), table=<artist_tags>), Column('tag_id', Integer(), ForeignKey('tags.id'), table=<artist_tags>), schema=None), Table('album_tags', MetaData(bind=None), Column('album_id', Integer(), ForeignKey('albums.id'), table=<album_tags>), Column('tag_id', Integer(), ForeignKey('tags.id'), table=<album_tags>), schema=None), Table('track_tags', MetaData(bind=None), Column('track_id', Integer(), ForeignKey('tracks.id'), table=<track_tags>), Column('tag_id', Integer(), ForeignKey('tags.id'), table=<track_tags>), schema=None), Table('artist_images', MetaData(bind=None), Column('artist_id', Integer(), ForeignKey('artists.id'), table=<artist_images>), Column('img_id', Integer(), ForeignKey('images.id'), table=<artist_images>), schema=None), Table('album_images', MetaData(bind=None), Column('album_id', Integer(), ForeignKey('albums.id'), table=<album_images>), Column('img_id', Integer(), ForeignKey('images.id'), table=<album_images>), schema=None)]¶ All the table instances. Order matters (esp. for postgresql). The tables are created in normal order, and dropped in reverse order.
-
class
mishmash.orm.
Tag
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
,mishmash.orm.OrmObject
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
NAME_LIMIT
= 64¶
-
id
¶
-
lib_id
¶
-
library
¶
-
name
¶
-
-
class
mishmash.orm.
Track
(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base
,mishmash.orm.OrmObject
Along with the column args a
audio_file
keyword may be passed for this class to use for initialization.-
METADATA_FORMATS
= ['ID3v1.0', 'ID3v1.1', 'ID3v2.2', 'ID3v2.3', 'ID3v2.4']¶
-
PATH_LIMIT
= 2048¶
-
TITLE_LIMIT
= 256¶
-
album
¶
-
album_id
¶
-
artist
¶
-
artist_id
¶
-
bit_rate
¶
-
ctime
¶
-
date_added
¶
-
id
¶
-
lib_id
¶
-
library
¶
-
media_num
¶
-
media_total
¶
-
metadata_format
¶
-
mtime
¶
-
path
¶
-
size_bytes
¶
-
time_secs
¶
-
title
¶
-
track_num
¶
-
track_total
¶
-
variable_bit_rate
¶
-
-
mishmash.orm.
album_images
= Table('album_images', MetaData(bind=None), Column('album_id', Integer(), ForeignKey('albums.id'), table=<album_images>), Column('img_id', Integer(), ForeignKey('images.id'), table=<album_images>), schema=None)¶ Pivot table ‘album_images’ for mapping an album ID to a value in the images table.
Pivot table ‘album_tags’ for mapping an album ID to a value in the tags table.
-
mishmash.orm.
artist_images
= Table('artist_images', MetaData(bind=None), Column('artist_id', Integer(), ForeignKey('artists.id'), table=<artist_images>), Column('img_id', Integer(), ForeignKey('images.id'), table=<artist_images>), schema=None)¶ Pivot table ‘artist_images’ for mapping an artist ID to a value in the images table.
Pivot table ‘artist_tags’ for mapping an artist ID to a value in the tags table.
-
mishmash.orm.
set_sqlite_pragma
(dbapi_connection, connection_record)[source]¶ Allows foreign keys to work in sqlite.
Pivot table ‘track_tags’ for mapping a track ID to a value in the tags table.
mishmash.util module¶
-
mishmash.util.
mostCommonItem
(lst)[source]¶ Choose the most common item from the list, or the first item if all items are unique.
-
mishmash.util.
normalizeCountry
(country_str, target='iso3c', title_case=False)[source]¶ Return a normalized name/code for country in
country_str
. The input can be a code or name, thetarget
determines output value. 3 character ISO code is the default (iso3c), ‘country_name’, and ‘iso2c’ are common also. Seecountrycode.countrycode
for details and other options. RaisesValueError
if the country is unrecognized.