Commit graph

6487 commits

Author SHA1 Message Date
Adrian Sampson
437959018c Pass through certain "safe" types to YAML
This avoids some round-tripping problems with types (such as ScaledInt) that
are not represented in strings with 100% fidelity. It also makes the syntax
nicer when editing numbers and booleans: they no longer appear to be
needlessly surrounded by quotes in the YAML.
2015-11-19 16:07:20 -08:00
Adrian Sampson
6a99eaae35 Fix a test for the new output format 2015-11-19 15:45:06 -08:00
Adrian Sampson
0e20770cc3 Convert YAML keys and values back to strings
I hadn't quite realized before that the user could also change the *keys* to
be non-strings too! This also prevents against that by just reinterpreting
everything as strings.
2015-11-19 15:38:20 -08:00
Adrian Sampson
0873d31419 Catch unexpected YAML type
We need a sequence of dictionaries back; validate this assumption.
2015-11-19 15:34:49 -08:00
Adrian Sampson
3176b83cd7 Use type-based formatting and parsing
All editable values are now strings and are parsed from strings. This closely
matches the behavior of the `modify` command, for example.
2015-11-19 15:25:49 -08:00
Peter Kessen
49a1e3c5d5 Merge pull request #1733 from pkess/fix_encoding
Fixed missing encoding definition in python files
closes #1722
2015-11-19 21:16:40 +01:00
Adrian Sampson
27b5b407c2 Fix #1732 by importing ctypes on demand 2015-11-19 10:10:17 -08:00
Peter Kessen
0e5a1e6b00 added encoding to beet itself 2015-11-19 19:09:11 +01:00
Adrian Sampson
7233173507 Fix some outdated comments 2015-11-19 10:08:37 -08:00
Peter Kessen
f5eca77117 added encoding as comment
last file for encoding check
python3 file without license
2015-11-19 18:54:02 +01:00
Peter Kessen
6b408507f6 added encoding as comment in files
added line like
# -*- coding: utf-8 -*-
to all files without license
2015-11-19 18:52:57 +01:00
Peter Kessen
3eb8008b11 added encoding as comment in files
added line like
# -*- coding: utf-8 -*-
to all files with correct license in header
2015-11-19 18:41:01 +01:00
Diego Moreda
40bfed756b Revise not query syntax, cleanup, modify docstring
* Revise the NotQuery syntax, replacing the '¬' character with '^'. Fix tests
to conform to this change, and cleanup the PARSE_QUERY_PART_REGEX.
* Modify parse_query_part() docstring to mention the negate parameter on the
returned tuple, and added an example.
2015-11-19 18:04:47 +01:00
Diego Moreda
e69b3b3c5d Fix NotQuery assertion by using sets, not lists
* Fix issue with an assertion that was order-sensitive and caused a problem on
some tox runs.
2015-11-18 17:40:47 +01:00
Diego Moreda
e457479558 Add NotQuery syntax tests
* Add tests to NotQueryTest for testing the results of using queries with
negation.
* Fix issue on test_dbcore due to the modifications on the tuple returned by
parse_query_part (the number of elements was changed from 3 to 4).
2015-11-18 17:27:22 +01:00
Diego Moreda
0293504a24 Update negation query syntax, prefix always first
* Update the negation query sintax so that the negation prefix ("-" or "¬") is
always the first part of a query, instead of after the ":" separator.
* Modify queryparse, so that the detection of the negation is done inside
parse_query_part() (using the modified PARSE_QUERY_PART_REGEX, and returning
the negation flag) instead of construct_query_part.
* Revert the prefixes dict on beets.library to the original dict (only one item,
with the RegexpQuery prefix).
2015-11-18 16:59:50 +01:00
Diego Moreda
dd8b80e320 Make NotQuery subclass Query, update tests
* Modify NotQuery so it subclasses Query instead of MutableCollectionQuery.
* Update instances where NotQuery objects are created on tests and queryparse,
as NotQuery expects a single Query as a parameter to the constructor instead of
a list of Queries.
2015-11-18 14:54:20 +01:00
Adrian Sampson
775a48eb28 --extra/-e is now --field/-f 2015-11-17 14:40:52 -08:00
Adrian Sampson
b33d25a0ad --extra option can use any field
Not just the built-in fields.
2015-11-17 14:39:40 -08:00
Adrian Sampson
f68dc4652a Fix a typo 2015-11-17 13:14:15 -08:00
Adrian Sampson
8e9d335a87 Tear down Item.write mock 2015-11-17 10:26:36 -08:00
Adrian Sampson
0d459752d9 Update edit plugin tests 2015-11-16 13:55:12 -08:00
Adrian Sampson
4db91c8bd2 Fix a too-long line 2015-11-16 13:03:50 -08:00
Adrian Sampson
f767f1c2a3 New confirmation prompt
We now ask for a trinary edit/apply/cancel confirmation *after* showing the
updates. This lets you decide whether you're done based on a "preview" of the
changes and keep editing if they don't look right.
2015-11-16 13:01:24 -08:00
Adrian Sampson
d87a747477 Condense edit plugin documentation
Also avoided adding some unused command-line options.
2015-11-16 12:43:59 -08:00
Diego Moreda
f2c8e9ff07 Add "not" query operator, initial draft
* Add support for user friendly "not" operator in queries without requiring to
use regular expressions, via adding NotQuery to beets.dbcore.query.
* Update the prefix list at library.parse_query_parts() and the query parsing
mechanisms in order to create a NotQuery when the prefix is found.
* Add two TestCases, NotQueryMatchTest as the negated version of MatchTest, and
the more generic NotQueryTest for testing the integration of the NotQuery with
the rest of the existing Query subclasses.
2015-11-16 21:36:42 +01:00
Adrian Sampson
c679e3f307 Merge branch 'editor' of github.com:sampsyo/beets into editor 2015-11-16 12:28:35 -08:00
Adrian Sampson
feabf1a6ef Offer a chance to fix YAML parse errors
An alternative to 749ef85638 by @jmwatte.
2015-11-16 12:27:32 -08:00
jmwatte
bb39cd509d cleaned up edit.rst 2015-11-16 10:37:38 -08:00
Adrian Sampson
52c2b3f479 Merge pull request #1727 from diego-plan9/editor
Editor: update extra fields test, save only dirty items
2015-11-16 10:32:45 -08:00
Diego Moreda
917628340e edit: save only items with changes
* Modify save_write() so only the items that do have pending changes (ie. dirty
items) are saved to the database.
2015-11-16 14:48:05 +01:00
Diego Moreda
e31680123b edit: update extra fields in yaml test
* Update test for extra fields in edited yaml, allowing the user to add fields
while editing. Rename the test to test_single_edit_add_field to reflect its
purpose more accurately.
2015-11-16 14:46:13 +01:00
Diego Moreda
2adf70209f edit: add test for extra fields on user yaml
* Add test_invalid_yaml_extra_field, testing the handling of user appended
fields (in particular, a non existing field) during the yaml editing.
2015-11-15 18:36:24 +01:00
Diego Moreda
5f2e5d73cc edit: update unit tests
* Update unit tests in order to reflect the changes on the last refactor of
edit.py (patch edit.edit instead of EditPlugin.get_editor, revise stdin strings
to match current version, remove TODO on docstrings from malformed and invalid
yaml tests).
2015-11-15 18:09:20 +01:00
Peter Kessen
ecbd337c47 Added file encoding definition to badfiles.py 2015-11-15 14:51:12 +01:00
Adrian Sampson
e39dede8b4 Merge pull request #1720 from Schweinepriester/master
Replace PIL with Pillow
2015-11-15 00:18:27 -08:00
Kai
61e992fd47 Replace PIL with Pillow 2015-11-15 04:25:42 +01:00
Adrian Sampson
cfba04bc9d Don't ask for confirmation if nothing changed 2015-11-14 14:58:53 -08:00
Adrian Sampson
80facbab6f More robust forbidden-change detection 2015-11-14 14:57:32 -08:00
Adrian Sampson
1c44969255 Simplify interfaces and add docs 2015-11-14 14:50:24 -08:00
Adrian Sampson
eb1bb132b1 Simplify metadata application 2015-11-14 14:48:10 -08:00
Adrian Sampson
58205e1bef Simplify data filtering 2015-11-14 14:33:04 -08:00
Adrian Sampson
029915814b Abort if nothing changed 2015-11-14 14:28:00 -08:00
Adrian Sampson
5096653483 Simpler serialization
Just use a dictionary instead of a list of tiny one-key dictionaries. Still
need to update the deserialization.
2015-11-14 14:23:57 -08:00
Adrian Sampson
9848b51008 Simplify field selection 2015-11-14 14:19:09 -08:00
Adrian Sampson
105cd73906 Start expunging opts carry-through
A dedicated command function takes care of the options and turns them into
normal variables.
2015-11-14 14:05:40 -08:00
Adrian Sampson
3c01c49a2c Less chatty interface
Removed three prompts:
1. The "really edit?" prompt. If you don't want to edit, you can just not make
   any changes.
2. The "done?" loop. This seems unnecessary; we'll confirm afterward anyway.
3. The YAML checker. This removal could indeed make things inconvenient, since
   your changes get thrown away if you make a YAML mistake. For the moment,
   simplicity is taking priority.
2015-11-14 13:53:25 -08:00
Adrian Sampson
ce31c2df23 Remove some dead code and hoist utility functions 2015-11-14 13:43:58 -08:00
Adrian Sampson
f27c486389 Remove separator and not_fields from docs
The `separator` option has already been removed. `not_fields` is an internal
detail and doesn't need to be documented (yet).
2015-11-14 13:39:30 -08:00
Adrian Sampson
de6813eab5 Remove vestigial editor config option
We now just use $EDITOR.
2015-11-14 13:38:41 -08:00