Commit graph

418 commits

Author SHA1 Message Date
Thomas Scholtes
4b1a1e3d65 Remove ITEM_KEYS_WRITABLE 2014-04-04 00:03:40 +02:00
Thomas Scholtes
3c7dd13b72 Add Item.media_fields
This new property controls which fields to read from a media file.
2014-04-03 23:35:33 +02:00
Thomas Scholtes
c4f0928bf5 Read custom fields into database 2014-04-03 14:01:56 +02:00
Thomas Scholtes
b262edd972 Migrate ITEM_KEYS_META 2014-04-03 14:01:56 +02:00
Thomas Scholtes
5b6305b610 Compute ITEM_KEYS_WRITABLE
See 65d64a7d50612df4ee6127ff05e591ae6fcceac0 why this is possible.
2014-04-03 14:01:55 +02:00
Thomas Scholtes
bcb72becf8 Add MediaFile.update() method to supersede save() 2014-04-03 14:01:55 +02:00
Adrian Sampson
05ebd6d28e FileOperationError: also include the file path
This makes the errors fully self-descriptive, which simplifies logging them as
errors (you just have to `log.error(exc)` to get a reasonable message). We
also now handle these at the top level in case someone forgets to add a
handler. But in this case, we also send the full traceback to the debug log.
2014-03-25 22:41:28 -07:00
Adrian Sampson
3a26845f5e FileOperationError: include underlying exception
A primitive form of Python 3's "exception chaining", which is what we really
want here. Someday...
2014-03-25 22:14:50 -07:00
Adrian Sampson
3c8decc487 some reorg/docs for FileOperationError 2014-03-24 22:37:15 -07:00
Thomas Scholtes
574903e986 Add FileOperationError and handling in item.write() 2014-03-24 14:22:27 +01:00
Thomas Scholtes
a399f294e8 Handle exceptions in item.write and use plugin abort 2014-03-22 13:25:25 +01:00
Thomas Scholtes
ff9e4f4dcb Add after_write plugin event 2014-03-10 16:34:12 +01:00
Adrian Sampson
be31ac683a Model._parse() class method 2014-02-13 21:29:17 -08:00
Stig Inge Lea Bjørnsen
a27d83a4bf Refactor the date query from being a plugin to being part of Beets core.
Fields of the type DateType will now automatically be queried by DateQuery.
2014-02-03 18:21:23 +01:00
Adrian Sampson
0458d16e71 avoid NotImplementedError for the time being 2014-01-26 21:43:29 -08:00
Adrian Sampson
fbed9552ea less code to specify sql and query for Type
Declarative class members instead of super calls. Wins every time.
2014-01-26 21:17:55 -08:00
Adrian Sampson
f29fbe47da DBCore types: no functional-style Type constructor
This was getting more and more awkward. Also added a `parse` method (in
progress).
2014-01-26 21:12:48 -08:00
Adrian Sampson
83f981762c fix #508: crash when parsing empty query part
This is a regression created by my endeavor to have parse_query_part never
return None. Now the regular expression should really always match.
2014-01-26 10:51:58 -08:00
Adrian Sampson
15510b6187 new dbcore.types module
Now Type is proper, full-on class so we don't have to fit everything in a
lambda.
2014-01-23 19:36:18 -08:00
Adrian Sampson
975f77e056 type-based formatting: u'None' -> empty string 2014-01-21 21:21:51 -08:00
Adrian Sampson
83c6fed6c8 type-based formatting: tolerate null values in DB 2014-01-21 21:09:53 -08:00
Adrian Sampson
7aa4d1e5ba begin type-based formatting 2014-01-21 21:02:40 -08:00
Adrian Sampson
69905dde9b resolve FIXMEs from query refactor 2014-01-21 19:37:54 -08:00
Adrian Sampson
d44f9f7052 map comp queries declaratively
Woohoo! More removal of special cases.
2014-01-21 19:13:16 -08:00
Adrian Sampson
74d0dc8352 further paramaterize parse_query_part 2014-01-21 19:09:34 -08:00
Adrian Sampson
1cdb30fd56 remove superfluous py_type field from Type 2014-01-20 18:06:42 -08:00
Adrian Sampson
00829c1a6c use PathQueries declaratively
Now PathQuery is just another type-based query, just like NumericQuery.
2014-01-20 18:01:29 -08:00
Adrian Sampson
4026c4b707 add query field to types
This is starting to get at the heart of the matter: now each type gets to
declare which Query subclass it wants to use, starting with NumericQuery.
2014-01-20 17:47:02 -08:00
Adrian Sampson
9ee4adc5e1 move remaining generic Query types to dbcore.query
NumericQuery is still broken. This, of course, is the whole reason for the
change.
2014-01-20 16:40:50 -08:00
Adrian Sampson
dcee7b6219 dbcore: terminology
Replace "library" and "lib" references in dbcore with "database" and "db" for
short.
2014-01-18 16:36:04 -08:00
Adrian Sampson
a3a25612ea sort items by disc and track
Now album.items() returns results in a reasonable order.
2014-01-14 18:33:04 -08:00
Stig Inge Lea Bjørnsen
6ed430d730 Send a plugin event when a file is copied.
I use this event in a plugin that needs to know which file outside the
library an item was copied from during import.
2014-01-14 21:53:12 +01:00
Adrian Sampson
faa66dba0d dbcore: subsume schema setup, add Type class
Type will also include fields for parsing, emitting, and querying a given
type.
2014-01-13 17:11:50 -08:00
Adrian Sampson
cbbb38c417 new BytesQuery factors out MatchQuery's path logic 2014-01-13 16:17:30 -08:00
Adrian Sampson
7f3a8ac505 fix some mistakes introduced during refactor 2014-01-13 15:33:19 -08:00
Adrian Sampson
529d2db0ce move basic queries to dbcore
I don't yet know where to divide the query hierarchy: maybe we even need a new
"queries" module for all this.
2014-01-13 15:21:34 -08:00
Adrian Sampson
f46c8b0623 move database_change events back to library.py
dbcore is abstractable. Should not depend on any beets internals.
2014-01-13 15:04:48 -08:00
Adrian Sampson
c5b92919c6 new Database class in dbcore
This moves most of the abstract Library functionality. Much more to come. Some
stuff is temporarily broken, to be followed up on in the next few commits.
2014-01-13 15:02:16 -08:00
Adrian Sampson
a9ef11c311 begin database refactor: move Model to new module 2014-01-13 14:37:04 -08:00
Romuald Conty
f18481d427 events: add item_removed event 2014-01-09 15:14:50 +00:00
Adrian Sampson
55cea24b7b don't attempt to string-format strings 2014-01-02 09:46:01 -08:00
Adrian Sampson
cc5e3d489c item templates can use album flexattrs (fix #461) 2013-12-25 15:49:51 -08:00
Adrian Sampson
925a6178ba expunge pathmod parameter
I started using this a long time ago as a misguided attempt to make
path-related functions more testable. Harnessing is better.
2013-12-25 00:35:01 -08:00
Adrian Sampson
d6ff4308f9 fix tests for new path formatting
Slowly expunging the terrible idea that was `pathmod`...
2013-12-25 00:28:26 -08:00
Adrian Sampson
a9faa9bf74 restore correct formatting of paths
- don't sanitize paths (this is already done separately)
- album.path (or album['path']) is now an alias for album.item_dir(), which
  restores the formatting of $path in templates
2013-12-25 00:00:12 -08:00
Adrian Sampson
d752014708 shared formatting/templating logic 2013-12-24 23:50:24 -08:00
Adrian Sampson
141f29aad9 replace old add methods with unified logic 2013-12-24 22:28:01 -08:00
Adrian Sampson
b9d503f846 new Model.add() method
This will replace most of the functionality of Library.add and
Library.add_album, completing the set of CRUD methods available on Model
classes.
2013-12-24 16:45:13 -08:00
Adrian Sampson
3e59c158ff enable queries over computed attributes
This makes containment (field in obj) work with all attributes even though
other dict-like methods for iterating over the object don't expose computed
fields by default. I think this is the right compromise to avoid accidental
eager evaluation of computed fields.
2013-12-24 15:30:39 -08:00
Adrian Sampson
b38812b452 collapse model base classes
The artificial separation was hurting legibility/maintainability more than it
was helping.
2013-12-24 15:20:52 -08:00