-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Add defaults tags for projects #113
Conversation
Please note that tags can contain spaces. You should probably either change the format of values in the |
@SpotlightKid I did not notice you could have spaces in tags. I'll see how I can solve this. |
I added the doc and the tests, so the PR should be ready for review. Should I rebase now to squash my commits now, or after the review? |
|
||
```ini | ||
[default_tags] | ||
voyager2 = nana 'space mission' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/nana/nasa
Fix the typos reported by @jmaupetit in jazzband#113
|
||
These automatically attached tags are defined in the `[default_tags]` section | ||
of the configuration. Each option bellow that section is a project to which | ||
tags should be attached. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have written something like:
Default tags are defined in the [default_tags]
section. Each entry should follow the pattern: project = tag1 tag2
.
same tags are always attached to a project. | ||
|
||
These automatically attached tags are defined in the `[default_tags]` section | ||
of the configuration. Each option bellow that section is a project to which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/bellow/below/
But "Each option in this section" is better, IMHO.
Include changes suggested by @SpotlightKid in jazzband#113
default_tags = [] | ||
if default_tags_raw is not None: | ||
default_tags = shlex.split(default_tags_raw) | ||
return default_tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would factor this out into a new method of the config.ConfigParser
class.
def getlist(self, section, option, default=None):
if not self.has_option(section, option):
return [] if default is None else default
value = self.get(section, option)
if '\n' in value:
return [item for item in value.splitlines() if item]
else:
return shlex.split(value)
This also allows an alternative syntax for lists of tags, some of which have spaces in them:
[default_tags]
interstellar travel = solar sail
cryogenics
fusion
watson =
issue 113
python
I'll prepare a separate PR for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this took quite some time, but #114 is now merged. Please update our PR, rebase it on the current master and squash the commits. Then it can be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take care of this latter this week.
Ping... |
Some projects are always used with the same tags. For instance, my 'python101' project should always have the 'teaching' tag attached to it. This commit adds a way to declare such default tags in the configuration file, and have them applied. Default tags are expected to be declared in a '[default_tags]' section: [default_tags] python101 = teaching watson = contrib python With the sample configuration above, the 'teaching' tag will always be attached to the 'python101' project, and the tags 'contrib' and 'python' will always be attached to the project 'watson'. Projects that do not appear in the '[default_tags]' section of the configuration will not be affected by the change. Note that the tags added by the new mechanism do not show in the output of `watson start`. However, they appear in the output of `watson status`, `watson log`, and of course `watson report`.
Use shlex to split the default tags from the configuration file. This allows to have quotes around tags, therefore allowing spaces. This is now valid: [default_tags] super project = fun 'random tag with spaces'
The output of `watson start` now displays the tags from the newly created frame rather than the tags from the input. This way, if default tags are added, they appears in the output of `watson start`.
`watson.start` has now a `restart` argument that let it know if it is called by `watson restart`. This allows to avoid tags to accumulate when restarting a project that has default tags.
Fix the typos reported by @jmaupetit in jazzband#113
Include changes suggested by @SpotlightKid in jazzband#113
Here it is. Sorry for the delay. |
|
||
def deduplicate(sequence): | ||
""" | ||
Return the input sequence without duplicate, keep the order. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More accurately:
Return a list with all items of the input sequence but duplicates removed.
Keeps the order of items in the input sequence.
Thanks! Can you address the few new comments I made, then I'll merge. You can squash you commits or I'll do it when merging. |
@jbarnoud : Hacktoberfest starts tomorrow 😉 |
@jbarnoud please let me know if you don't have time to finish this: I can give a hand! Once this PR has been merged, thanks to @SpotlightKid, we will release Watson 1.4.0 and prepare a RC for 2.0 (FTR, see this comment in #115). |
It get's to the top of my todo list. They are only a few items remaining On 04-10-16 09:40, Julien Maupetit wrote:
|
@SpotlightKid what is your feeling about postponing this feature to the 2.0 release? |
The PR is almost ready. We could also just fix these minor issues I commented on above ourselves. |
No need to postpone anything anymore. Sorry for the delay, my TODO list was going out of hands. |
Thank you @jbarnoud ; I felt bad about fixing your stuff myself. |
Some projects are always used with the same tags. For instance, my
'python101' project should always have the 'teaching' tag attached to
it.
This commit adds a way to declare such default tags in the configuration
file, and have them applied. Default tags are expected to be declared in
a '[default_tags]' section:
With the sample configuration above, the 'teaching' tag will always be
attached to the 'python101' project, and the tags 'contrib' and 'python'
will always be attached to the project 'watson'.
Projects that do not appear in the '[default_tags]' section of the
configuration will not be affected by the change.
Note that the tags added by the new mechanism do not show in the output
of
watson start
. However, they appear in the output ofwatson status
,watson log
, and of coursewatson report
.This pull request is still a work in progress. It still requires at least: