diff options
author | smerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2011-04-04 08:39:52 +0000 |
---|---|---|
committer | smerten <smerten@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2011-04-04 08:39:52 +0000 |
commit | 0a71a79312d183a65b18fff0b4bf404de202fb70 (patch) | |
tree | a10b40ce27f2fa7ea4eea3ceebef0e0235996573 /sandbox/rstdiff/rstdiff.py | |
parent | f043013fd470acac0b4089af89291ca73d0f133e (diff) | |
download | docutils-0a71a79312d183a65b18fff0b4bf404de202fb70.tar.gz |
Renamed option `--compare-sections-by-id` to
`--compare-sections-by-name` and comparison is done by name. This
works for duplicated section titles, too.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7000 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/rstdiff/rstdiff.py')
-rwxr-xr-x | sandbox/rstdiff/rstdiff.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sandbox/rstdiff/rstdiff.py b/sandbox/rstdiff/rstdiff.py index 2433c67ff..2981f5536 100755 --- a/sandbox/rstdiff/rstdiff.py +++ b/sandbox/rstdiff/rstdiff.py @@ -89,14 +89,14 @@ settings_spec = ( 'callback': switchOptionsCallback, 'callback_args': ( bothOption, ), }), - ('Compare sections by comparing their ids (default); ' + ('Compare sections by comparing their names (default); ' + 'useful when section titles are stable but sections change', - ['--compare-sections-by-id'], + ['--compare-sections-by-names'], { 'action': 'store_true', 'default': 1, 'validator': validate_boolean}), ('Compare sections normally; useful when section titles change', ['--compare-sections-normally'], - { 'action': 'store_false', 'dest': 'compare_sections_by_id'}), + { 'action': 'store_false', 'dest': 'compare_sections_by_names'}), ) ) @@ -671,12 +671,17 @@ class DocutilsDispatcher(HashableNodeImpl): ########################################################################### # section + def getSectionName(self, node): + if node['dupnames']: + return node['dupnames'][0] + if node['names'][0]: + return node['names'][0] + return node['ids'][0] + def rootEq_section(self, node, other): - """Compare sections by their first ids or normally.""" - # TODO Comparsion should be by names because they are richer - - # however, names seem not always to be present - if node.document.settings.compare_sections_by_id: - return node['ids'][0] == other['ids'][0] + """Compare sections by their names or normally.""" + if node.document.settings.compare_sections_by_names: + return self.getSectionName(node) == self.getSectionName(other) return True ########################################################################### |