Skip to content

Commit

Permalink
UNICODE CLEANUP: Avoid usage of future import "unicode_literals".
Browse files Browse the repository at this point in the history
  • Loading branch information
jenisys committed Oct 1, 2016
1 parent b494d28 commit 3c47bf5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 54 deletions.
1 change: 0 additions & 1 deletion behave/i18n.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: UTF-8 -*-
# -- FILE GENERATED BY: convert_i18n_yaml.py with i18n.yml
# pylint: disable=line-too-long
from __future__ import unicode_literals

languages = \
{'ar': {'and': [u'*', u'\u0648'],
Expand Down
2 changes: 1 addition & 1 deletion behave/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* ...
"""

from __future__ import absolute_import, with_statement, unicode_literals
from __future__ import absolute_import, with_statement
import copy
import difflib
import logging
Expand Down
46 changes: 1 addition & 45 deletions behave/tag_matcher.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import
import re
import operator
import warnings
Expand Down Expand Up @@ -216,50 +216,6 @@ def should_exclude_with(self, tags):
# -- LOGICAL-AND: All parts are True
return False # SHOULD-EXCLUDE: not enabled = not True

# -- OLD-IMPLEMENTATION:
# def should_exclude_with(self, tags):
# exclude_decision_map = {}
# exclude_reasons = []
# for category_tag, tag_match in self.select_active_tags(tags):
# # -- FASTER: tag_prefix, category, _, tag_value = tag_match.groups()
# tag_prefix = tag_match.group("prefix")
# category = tag_match.group("category")
# tag_value = tag_match.group("value")
# is_category_tag_switched_on = operator.eq # equal_to
# if self.is_tag_negated(tag_prefix):
# is_category_tag_switched_on = operator.ne # not_equal_to
#
# current_value = self.value_provider.get(category, None)
# if current_value is None and self.ignore_unknown_categories:
# # -- CASE: Unknown category, ignore it.
# continue
# elif is_category_tag_switched_on(tag_value, current_value):
# # -- CASE: Active tag is switched ON, decision: should run.
# # NOTE: No change, if category is already in exclusion map:
# # disabled_result := not enabled_result = not (e1 and e2 ...)
# # := (not e1) or (not e2) ...
# #
# # disabled_result1 := True or False = True
# # disabled_result2 := False or False = False (same tag twice)
# if category not in exclude_decision_map:
# exclude_decision_map[category] = False
# else:
# # -- CASE: Active tag is switched OFF, decision: exclude it.
# # disabled_result1 := True or True = True
# # disabled_result2 := False or True = True
# exclude_decision_map[category] = True
# if self.use_exclude_reason:
# reason = "%s (but: %s)" % (category_tag, current_value)
# exclude_reasons.append(reason)
#
# self.exclude_reason = None
# if exclude_reasons:
# # -- DIAGNOSTICS:
# self.exclude_reason = ", ".join(exclude_reasons)
# # -- EXCLUDE-DECISION:
# # disabled_result := (not e1) or (not e2) ... = not (e1 and e2 ...)
# return any(exclude_decision_map.values())

def select_active_tags(self, tags):
"""Select all active tags that match the tag schema pattern.
Expand Down
3 changes: 1 addition & 2 deletions bin/convert_i18n_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* PyYAML
"""

from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
import argparse
import os.path
import six
Expand Down Expand Up @@ -57,7 +57,6 @@ def main(args=None):
contents = u"""# -*- coding: UTF-8 -*-
# -- FILE GENERATED BY: convert_i18n_yaml.py with i18n.yml
# pylint: disable=line-too-long
from __future__ import unicode_literals
languages = \\
"""
Expand Down
9 changes: 4 additions & 5 deletions features/steps/behave_active_tags_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"""

from __future__ import unicode_literals
from behave import given, when, then, step
from behave.tag_matcher import ActiveTagMatcher
from behave.tag_expression import TagExpression
Expand All @@ -32,7 +31,7 @@ def normalize_tags(tags):
# -----------------------------------------------------------------------------
# STEP DEFINITIONS:
# -----------------------------------------------------------------------------
@given('I setup the current values for active tags with')
@given(u'I setup the current values for active tags with')
def step_given_setup_the_current_values_for_active_tags_with(context):
assert context.table, "REQUIRE: table"
context.table.require_columns(["category", "value"])
Expand All @@ -48,7 +47,7 @@ def step_given_setup_the_current_values_for_active_tags_with(context):
active_values[category] = value


@then('the following active tag combinations are enabled')
@then(u'the following active tag combinations are enabled')
def step_then_following_active_tags_combinations_are_enabled(context):
assert context.table, "REQUIRE: table"
assert context.active_value_provider, "REQUIRE: active_value_provider"
Expand Down Expand Up @@ -78,10 +77,10 @@ def step_then_following_active_tags_combinations_are_enabled(context):
assert_that(mismatched_rows, equal_to([]), "No mismatched rows:")


@step('unknown categories are ignored in active tags')
@step(u'unknown categories are ignored in active tags')
def step_unknown_categories_are_ignored_in_active_tags(context):
context.active_tags_ignore_unknown_categories = True

@step('unknown categories are not ignored in active tags')
@step(u'unknown categories are not ignored in active tags')
def step_unknown_categories_are_not_ignored_in_active_tags(context):
context.active_tags_ignore_unknown_categories = False

0 comments on commit 3c47bf5

Please sign in to comment.