|
From: <mi...@us...> - 2020-02-06 12:46:46
|
Revision: 8482
http://sourceforge.net/p/docutils/code/8482
Author: milde
Date: 2020-02-06 12:46:45 +0000 (Thu, 06 Feb 2020)
Log Message:
-----------
Minor formatting updates.
Modified Paths:
--------------
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2020-01-31 08:17:24 UTC (rev 8481)
+++ trunk/docutils/docutils/nodes.py 2020-02-06 12:46:45 UTC (rev 8482)
@@ -620,6 +620,12 @@
def __len__(self):
return len(self.children)
+ def __contains__(self, key):
+ # Test for both, children and attributes with operator ``in``.
+ if isinstance(key, basestring):
+ return key in self.attributes
+ return key in self.children
+
def __getitem__(self, key):
if isinstance(key, basestring):
return self.attributes[key]
@@ -703,14 +709,6 @@
has_key = hasattr
- # support operator ``in``
- def __contains__(self, key):
- # support both membership test for children and attributes
- # (has_key is translated to "in" by 2to3)
- if isinstance(key, basestring):
- return key in self.attributes
- return key in self.children
-
def get_language_code(self, fallback=''):
"""Return node's language tag.
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2020-01-31 08:17:24 UTC (rev 8481)
+++ trunk/docutils/docutils/utils/__init__.py 2020-02-06 12:46:45 UTC (rev 8482)
@@ -681,7 +681,6 @@
# find all combinations of subtags
taglist = []
for n in range(len(subtags), 0, -1):
- # for tags in unique_combinations(subtags, n):
for tags in itertools.combinations(subtags, n):
taglist.append('-'.join(base_tag+tags))
taglist += base_tag
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2020-01-31 08:17:24 UTC (rev 8481)
+++ trunk/docutils/test/test_utils.py 2020-02-06 12:46:45 UTC (rev 8482)
@@ -267,9 +267,9 @@
['de-at', 'de'])
self.assertEqual(utils.normalize_language_tag('de-AT-1901'),
['de-at-1901', 'de-at', 'de-1901', 'de'])
- self.assertEqual(utils.normalize_language_tag('de-AT-1901-frak'),
- ['de-at-1901-frak', 'de-at-1901', 'de-at-frak',
- 'de-1901-frak', 'de-at', 'de-1901', 'de-frak', 'de'])
+ self.assertEqual(utils.normalize_language_tag('de-AT-1901-Latf'),
+ ['de-at-1901-latf', 'de-at-1901', 'de-at-latf',
+ 'de-1901-latf', 'de-at', 'de-1901', 'de-latf', 'de'])
self.assertEqual(utils.normalize_language_tag('grc-ibycus-x-altquot'),
['grc-ibycus-x-altquot', 'grc-ibycus',
'grc-x-altquot', 'grc'])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|