google-code-export / beets

Automatically exported from code.google.com/p/beets
MIT License
0 stars 0 forks source link

inline: allow blocks in addition to expressions #487

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In pathfields, I have: lntitle: re.sub(r'[^a-zA-Z0-9_.()-]+', '_', 
title).lower()

This raises an InlineError because re isn't defined, I've fixed this locally by 
adding import re and values['re'] = re before the eval() call but this is 
obviously not a proper fix. Some people may also want to use other modules.

Original issue reported on code.google.com by florent....@gmail.com on 4 Jan 2013 at 12:05

GoogleCodeExporter commented 9 years ago
This is a good point -- currently, the inline Python code must be an 
expression, not a statement or a block. This precludes stuff like imports. It 
would be nice to support longer programs that look like function bodies 
(wherein import statements would be allowed). But we'll need an idea for how to 
distinguish between the two forms.

For this purpose, however, you might want to look at the "replace" config 
option (which does character substitutions like this).

Original comment by adrian.sampson on 4 Jan 2013 at 3:24

GoogleCodeExporter commented 9 years ago
Pull request at: https://github.com/sampsyo/beets/pull/72

Original comment by florent....@gmail.com on 5 Jan 2013 at 11:15

GoogleCodeExporter commented 9 years ago
Merged! Thanks.

Original comment by adrian.sampson on 6 Jan 2013 at 1:51