Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep work for adding a mopidy config --set ... type command. #548

Merged
merged 2 commits into from Oct 27, 2013

Conversation

adamcik
Copy link
Member

@adamcik adamcik commented Oct 27, 2013

Adds the forward and backwards transformations we need for modifying configs while keeping comments etc.

Adds markers to configs files that ensures configparser won't mangle comments
in the files. Will be combined with a postprocessor that undoes these changes.
Idea forward from here is that once we have a config sub command that we expose
a setting config values which will:

1. Run the preprocessor on the file to edit.
2. Load it into config parser.
3. Modify the value.
4. Write it to a io.ByteString
5. Run the postprocessor
6. Save the file with comments etc intact.
line = blank_line_re.sub(newlines, line)
line = section_re.sub(sections, line)
line = comment_re.sub(comments, line)
line = inline_comment_re.sub(inlinecomments, line)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must the regexps and transformations be applied in a specific order for it to work correctly?

I would like the functions and their use to be sorted in the same order.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order does matter because say # foo ; bar needs to become __HASH__ = foo\n__INLINE__ = bar or else the second part disappears as a comment.

@jodal
Copy link
Member

jodal commented Oct 27, 2013

LGTM. Merge now or after release, at your leisure. Probably no point in including it in 0.16 though, as it is still dead code.

jodal added a commit that referenced this pull request Oct 27, 2013
Prep work for adding a `mopidy config --set ...` type command.
@jodal jodal merged commit f9c09a8 into mopidy:develop Oct 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants