Skip to content

[add] sort_by - Option to ignore leading articles#1831

Merged
liiight merged 3 commits intodevelopfrom
sort-articles
May 20, 2017
Merged

[add] sort_by - Option to ignore leading articles#1831
liiight merged 3 commits intodevelopfrom
sort-articles

Conversation

@tubedogg
Copy link
Copy Markdown
Contributor

@tubedogg tubedogg commented May 20, 2017

Motivation for changes:

I wanted to sort my series without regard to leading articles.

Detailed changes:

  • Adds an additional option, ignore_articles:
    • When set to yes, the sort will ignore the English articles ‘the’, ‘a’, and ‘an’ when they appear as the first word in the field to be sorted.
    • Alternatively, you can specify a custom regular expression to be used, for use with other languages or to otherwise customize the articles that are ignored.
  • Added tests for both bool and custom regex forms of ignore_articles options.
  • All tests now run from one function through use of @pytest.mark.parametrize.

Config usage if relevant (new plugin or updated schema):

sort_by:
  field: title
  ignore_articles: yes

sort_by:
  field: title
  ignore_articles: '^(ignore|other|words)\s'

Tests

Added two tests to test_sort_by.py for ignore_articles: yes and ignore_articles: '^(the|a)\s'.

tubedogg added 2 commits May 19, 2017 20:16
Adds an additional option, `ignore_articles`. When set to yes, the sort
will ignore the English articles ‘the’, ‘a’, and ‘an’ when they appear
as the first word in the field to be sorted. Alternatively, you can
also specify a custom regular expression to be used, for use with other
languages or to otherwise customize the articles that are ignored.
Added tests for both bool and custom regex forms of `ignore_articles`
options.
All tests now run from one function through use of
pytest.mark.parametrize.
}

def on_task_filter(self, task, config):
re_articles = '^(the|a|an)\s'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move this to a const


def on_task_filter(self, task, config):
re_articles = '^(the|a|an)\s'
if isinstance(config, basestring):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know it was already there but change basestring into str

@liiight liiight merged commit a929d46 into develop May 20, 2017
@tubedogg tubedogg deleted the sort-articles branch May 24, 2017 19:05
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.

2 participants