diff --git a/community-resources/src/idea/IdeaApplicationInfo.xml b/community-resources/src/idea/IdeaApplicationInfo.xml
index e2e23db1b52a..cfc65273f914 100644
--- a/community-resources/src/idea/IdeaApplicationInfo.xml
+++ b/community-resources/src/idea/IdeaApplicationInfo.xml
@@ -4,7 +4,7 @@
-
+
diff --git a/community-resources/src/idea_community_about.png b/community-resources/src/idea_community_about.png
index 7e9e496d6d21..a474783912da 100644
Binary files a/community-resources/src/idea_community_about.png and b/community-resources/src/idea_community_about.png differ
diff --git a/community-resources/src/idea_community_about@2x.png b/community-resources/src/idea_community_about@2x.png
index b5553ec2a21e..c8e0fadae88d 100644
Binary files a/community-resources/src/idea_community_about@2x.png and b/community-resources/src/idea_community_about@2x.png differ
diff --git a/community-resources/src/idea_community_logo.png b/community-resources/src/idea_community_logo.png
index 8a5a6785e534..ff26535f7394 100644
Binary files a/community-resources/src/idea_community_logo.png and b/community-resources/src/idea_community_logo.png differ
diff --git a/community-resources/src/idea_community_logo@2x.png b/community-resources/src/idea_community_logo@2x.png
index c20626941378..74457686ab1d 100644
Binary files a/community-resources/src/idea_community_logo@2x.png and b/community-resources/src/idea_community_logo@2x.png differ
diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java
index e6991736c0e3..192a64cf8d29 100644
--- a/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java
+++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/CopyPasteReferenceProcessor.java
@@ -28,6 +28,7 @@ import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
+import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -206,7 +207,7 @@ public abstract class CopyPasteReferenceProcessor exten
for (int i = 0; i < referenceData.length; i++) {
PsiElement ref = refs[i];
if (ref != null) {
- LOG.assertTrue(ref.isValid());
+ PsiUtilCore.ensureValid(ref);
Object refObject = refObjects[i];
boolean found = false;
for (Object selected : selectedObjects) {
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java
index b5ca2ea117c3..b0ae2ef73af8 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/JavaTreeGenerator.java
@@ -49,7 +49,7 @@ public class JavaTreeGenerator implements TreeGenerator {
@Override
@Nullable
- public TreeElement generateTreeFor(PsiElement original, final CharTable table, final PsiManager manager) {
+ public TreeElement generateTreeFor(@NotNull PsiElement original, @NotNull final CharTable table, @NotNull final PsiManager manager) {
if (original instanceof PsiKeyword || original instanceof PsiIdentifier) {
final String text = original.getText();
return createLeafFromText(text, table, manager, original, ((PsiJavaToken)original).getTokenType());
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/typing/ClearingHighlightersOnType.xml b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/typing/ClearingHighlightersOnType.xml
deleted file mode 100644
index 067abae0829e..000000000000
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/typing/ClearingHighlightersOnType.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- rtetre tretre
- rrr aksjdb sadkj fgrrretyr re tre tre tre t
-
-
-
-
-
-
-
-
-
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
index fefe621beba1..d49eae4f0367 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/impl/DaemonRespondToChangesTest.java
@@ -604,21 +604,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
assertEquals(3, markers.size());
}
-
- public void testClearingHighlightersOnType() throws Exception {
- configureByFile(BASE_PATH + getTestName(false) + ".xml");
-
- Collection errors = highlightErrors();
- assertEquals(1, errors.size());
- assertEquals("Element dddddddddd is not allowed here", errors.iterator().next().getDescription());
-
- commentLine();
-
- List afterTyping = DaemonCodeAnalyzerImpl.getHighlights(getEditor().getDocument(), HighlightSeverity.ERROR, getProject());
- HighlightInfo error = assertOneElement(afterTyping);
- assertEquals("Element dddddddddd is not allowed here", error.getDescription());
- }
-
private static void commentLine() {
WriteCommandAction.runWriteCommandAction(null, () -> {
CommentByLineCommentAction action = new CommentByLineCommentAction();
@@ -628,7 +613,6 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
public void testChangeXmlIncludeLeadsToRehighlight() throws Exception {
-
LanguageFilter[] extensions = ((CompositeLanguage)StdLanguages.XML).getLanguageExtensions();
for (LanguageFilter extension : extensions) {
((CompositeLanguage)StdLanguages.XML).unregisterLanguageExtension(extension);
diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java
index a106c2a0f277..312a1edf4d3b 100644
--- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java
+++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarFileSystem.java
@@ -19,17 +19,24 @@ import com.intellij.openapi.util.Couple;
import com.intellij.openapi.vfs.DeprecatedVirtualFileSystem;
import com.intellij.openapi.vfs.StandardFileSystems;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.containers.ConcurrentFactoryMap;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
-import java.util.HashMap;
import java.util.Map;
/**
* @author yole
*/
public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
- private final Map myHandlers = new HashMap();
+ private final Map myHandlers = new ConcurrentFactoryMap() {
+ @Nullable
+ @Override
+ protected CoreJarHandler create(String key) {
+ return new CoreJarHandler(CoreJarFileSystem.this, key);
+ }
+ };
@NotNull
@Override
@@ -40,7 +47,7 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
@Override
public VirtualFile findFileByPath(@NotNull @NonNls String path) {
Couple pair = splitPath(path);
- return getHandler(pair.first).findFileByPath(pair.second);
+ return myHandlers.get(pair.first).findFileByPath(pair.second);
}
@NotNull
@@ -54,16 +61,6 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
return Couple.of(localPath, pathInJar);
}
- @NotNull
- private CoreJarHandler getHandler(String localPath) {
- CoreJarHandler handler = myHandlers.get(localPath);
- if (handler == null) {
- handler = new CoreJarHandler(this, localPath);
- myHandlers.put(localPath, handler);
- }
- return handler;
- }
-
@Override
public void refresh(boolean asynchronous) { }
@@ -71,4 +68,9 @@ public class CoreJarFileSystem extends DeprecatedVirtualFileSystem {
public VirtualFile refreshAndFindFileByPath(@NotNull String path) {
return findFileByPath(path);
}
+
+ @SuppressWarnings("unused") // used in Kotlin
+ public void clearHandlersCache() {
+ myHandlers.clear();
+ }
}
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/ChangeUtil.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/ChangeUtil.java
index 56e01ca4fa8d..13ca96e9df26 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/ChangeUtil.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/ChangeUtil.java
@@ -144,7 +144,8 @@ public class ChangeUtil {
}
@Nullable
- public static TreeElement generateTreeElement(PsiElement original, CharTable table, final PsiManager manager) {
+ public static TreeElement generateTreeElement(@Nullable PsiElement original, @NotNull CharTable table, @NotNull final PsiManager manager) {
+ if (original == null) return null;
PsiUtilCore.ensureValid(original);
if (SourceTreeToPsiMap.hasTreeElement(original)) {
return copyElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(original), table);
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeGenerator.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeGenerator.java
index c6528ba7aeb3..20f27f3d5a39 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeGenerator.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/TreeGenerator.java
@@ -23,11 +23,12 @@ import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.util.CharTable;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface TreeGenerator {
ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.treeGenerator");
@Nullable
- TreeElement generateTreeFor(PsiElement original, CharTable table, final PsiManager manager);
+ TreeElement generateTreeFor(@NotNull PsiElement original, @NotNull CharTable table, @NotNull final PsiManager manager);
}
\ No newline at end of file
diff --git a/platform/core-impl/src/com/intellij/util/DebugReflectionUtil.java b/platform/core-impl/src/com/intellij/util/DebugReflectionUtil.java
index 21f93312a751..6d071a885e6c 100644
--- a/platform/core-impl/src/com/intellij/util/DebugReflectionUtil.java
+++ b/platform/core-impl/src/com/intellij/util/DebugReflectionUtil.java
@@ -127,7 +127,7 @@ public class DebugReflectionUtil {
return true;
}
- private static boolean isLoadedAlready(Class root) {
+ private static boolean isLoadedAlready(@NotNull Class root) {
if (Unsafe_shouldBeInitialized == null) return false;
boolean isLoadedAlready = false;
try {
@@ -140,7 +140,7 @@ public class DebugReflectionUtil {
}
public static class BackLink {
- public final Object value;
+ @NotNull public final Object value;
private final Field field;
private final BackLink backLink;
@@ -158,15 +158,17 @@ public class DebugReflectionUtil {
String valueStr;
try {
valueStr = backLink.value instanceof FList
- ? "FList" : backLink.value instanceof Collection ? "Collection" : String.valueOf(backLink.value);
+ ? "FList (size="+((FList)backLink.value).size()+")" :
+ backLink.value instanceof Collection ? "Collection (size="+((Collection)backLink.value).size()+")" :
+ String.valueOf(backLink.value);
valueStr = StringUtil.trimLog(StringUtil.convertLineSeparators(valueStr, "//"), 100);
}
catch (Throwable e) {
valueStr = "(" + e.getMessage() + " while computing .toString())";
}
Field field = backLink.field;
- String fieldStr = field == null ? "?" : field.getName() + " of " + field.getDeclaringClass();
- result += "via " + fieldStr + "; Value: " + valueStr + " of " + backLink.value.getClass() + "\n";
+ String fieldName = field == null ? "?" : field.getDeclaringClass().getName()+"."+field.getName();
+ result += "via '" + fieldName + "'; Value: '" + valueStr + "' of " + backLink.value.getClass() + "\n";
backLink = backLink.backLink;
}
return result;
diff --git a/platform/diff-impl/src/com/intellij/diff/tools/util/base/ListenerDiffViewerBase.java b/platform/diff-impl/src/com/intellij/diff/tools/util/base/ListenerDiffViewerBase.java
index d6385862296c..4b9bff7c64a9 100644
--- a/platform/diff-impl/src/com/intellij/diff/tools/util/base/ListenerDiffViewerBase.java
+++ b/platform/diff-impl/src/com/intellij/diff/tools/util/base/ListenerDiffViewerBase.java
@@ -42,7 +42,11 @@ public abstract class ListenerDiffViewerBase extends DiffViewerBase {
super(context, request);
myDocumentListener = createDocumentListener();
myFileListener = createFileListener(request);
+ }
+ @Override
+ protected void onInit() {
+ super.onInit();
if (myFileListener != null) VirtualFileManager.getInstance().addVirtualFileListener(myFileListener);
for (Document document : getDocuments()) {
diff --git a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeAction.java b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeAction.java
index 60dbb83474f5..9c1a0a8a0b60 100644
--- a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeAction.java
+++ b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeAction.java
@@ -16,9 +16,9 @@
package com.intellij.openapi.diff.impl.dir.actions;
import com.intellij.ide.diff.DirDiffSettings;
-import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
+import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.EmptyIcon;
@@ -27,7 +27,7 @@ import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
-class ChangeCompareModeAction extends AnAction {
+class ChangeCompareModeAction extends DumbAwareAction {
private final static Icon ON = PlatformIcons.CHECK_ICON;
private final static Icon ON_SELECTED = PlatformIcons.CHECK_ICON_SELECTED;
private final static Icon OFF = EmptyIcon.create(ON.getIconHeight());
diff --git a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeGroup.java b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeGroup.java
index 89a6c7e823c0..fe97eec6079f 100644
--- a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeGroup.java
+++ b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/ChangeCompareModeGroup.java
@@ -19,6 +19,7 @@ import com.intellij.ide.diff.DirDiffSettings;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
+import com.intellij.openapi.project.DumbAware;
import com.intellij.ui.IdeBorderFactory;
import org.jetbrains.annotations.NotNull;
@@ -29,7 +30,7 @@ import java.util.ArrayList;
/**
* @author Konstantin Bulenkov
*/
-public class ChangeCompareModeGroup extends ComboBoxAction implements ShortcutProvider{
+public class ChangeCompareModeGroup extends ComboBoxAction implements ShortcutProvider, DumbAware {
private final DefaultActionGroup myGroup;
private DirDiffSettings mySettings;
private JButton myButton;
diff --git a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffAction.java b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffAction.java
index f7a79838fd0a..abf938e5a623 100644
--- a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffAction.java
+++ b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/DirDiffAction.java
@@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.ShortcutProvider;
import com.intellij.openapi.actionSystem.ShortcutSet;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
+import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
@@ -27,7 +28,7 @@ import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
-public abstract class DirDiffAction extends ToggleAction implements ShortcutProvider {
+public abstract class DirDiffAction extends ToggleAction implements ShortcutProvider, DumbAware {
private final DirDiffTableModel myModel;
protected DirDiffAction(DirDiffTableModel model) {
diff --git a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java
index c1c57e1b441c..c31a07ce5cbd 100644
--- a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java
+++ b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetNoOperation.java
@@ -16,10 +16,10 @@
package com.intellij.openapi.diff.impl.dir.actions.popup;
import com.intellij.ide.diff.DirDiffOperation;
-import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.impl.dir.DirDiffElementImpl;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
+import com.intellij.openapi.project.DumbAwareAction;
import javax.swing.*;
@@ -27,7 +27,7 @@ import javax.swing.*;
* @author lene
* Date: 23.04.12
*/
-public class SetNoOperation extends AnAction {
+public class SetNoOperation extends DumbAwareAction {
@Override
public void actionPerformed(AnActionEvent e) {
final DirDiffTableModel model = SetOperationToBase.getModel(e);
diff --git a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java
index 81e1968caded..747f5252b736 100644
--- a/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java
+++ b/platform/diff-impl/src/com/intellij/openapi/diff/impl/dir/actions/popup/SetOperationToBase.java
@@ -17,11 +17,11 @@ package com.intellij.openapi.diff.impl.dir.actions.popup;
import com.intellij.ide.diff.DirDiffElement;
import com.intellij.ide.diff.DirDiffOperation;
-import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.diff.impl.dir.DirDiffElementImpl;
import com.intellij.openapi.diff.impl.dir.DirDiffPanel;
import com.intellij.openapi.diff.impl.dir.DirDiffTableModel;
+import com.intellij.openapi.project.DumbAwareAction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,7 +30,7 @@ import javax.swing.*;
/**
* @author Konstantin Bulenkov
*/
-public abstract class SetOperationToBase extends AnAction {
+public abstract class SetOperationToBase extends DumbAwareAction {
@Override
public void actionPerformed(AnActionEvent e) {
DirDiffOperation operation = getOperation();
diff --git a/platform/diff-impl/tests/com/intellij/diff/DiffColorSettingsTest.kt b/platform/diff-impl/tests/com/intellij/diff/DiffColorSettingsTest.kt
new file mode 100644
index 000000000000..1c2be0a7e4e4
--- /dev/null
+++ b/platform/diff-impl/tests/com/intellij/diff/DiffColorSettingsTest.kt
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.diff
+
+import com.intellij.diff.tools.simple.SimpleThreesideDiffViewer
+import com.intellij.diff.util.TextDiffType
+import com.intellij.openapi.diff.impl.settings.DiffPreviewPanel
+import com.intellij.openapi.editor.ex.EditorEx
+import com.intellij.openapi.editor.markup.RangeHighlighter
+import com.intellij.openapi.util.Disposer
+import com.intellij.testFramework.fixtures.IdeaProjectTestFixture
+import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
+
+class DiffColorSettingsTest : DiffTestCase() {
+ private var projectFixture: IdeaProjectTestFixture? = null
+
+ override fun setUp() {
+ super.setUp()
+ projectFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getTestName(true)).getFixture()
+ projectFixture!!.setUp()
+ }
+
+ override fun tearDown() {
+ projectFixture?.tearDown()
+ super.tearDown()
+ }
+
+ fun testChanges() {
+ val disposable = Disposer.newDisposable()
+ try {
+ val panel = DiffPreviewPanel(disposable)
+ val viewer = panel.testGetViewer()
+
+ assertEquals(viewer.changes.size, 6)
+ assertContainsRange(viewer, TextDiffType.MODIFIED)
+ assertContainsRange(viewer, TextDiffType.INSERTED)
+ assertContainsRange(viewer, TextDiffType.DELETED)
+ assertContainsRange(viewer, TextDiffType.CONFLICT)
+
+ assertContainsBackgroundColor(viewer, TextDiffType.MODIFIED, true)
+ assertContainsBackgroundColor(viewer, TextDiffType.INSERTED, true)
+ assertContainsBackgroundColor(viewer, TextDiffType.DELETED, true)
+ assertContainsBackgroundColor(viewer, TextDiffType.CONFLICT, true)
+
+ assertContainsBackgroundColor(viewer, TextDiffType.MODIFIED, false)
+ assertContainsBackgroundColor(viewer, TextDiffType.INSERTED, false)
+ assertContainsBackgroundColor(viewer, TextDiffType.DELETED, false)
+ assertContainsBackgroundColor(viewer, TextDiffType.CONFLICT, false)
+
+ assertContainsMarkerColor(viewer, TextDiffType.MODIFIED)
+ assertContainsMarkerColor(viewer, TextDiffType.INSERTED)
+ assertContainsMarkerColor(viewer, TextDiffType.DELETED)
+ assertContainsMarkerColor(viewer, TextDiffType.CONFLICT)
+ }
+ finally {
+ Disposer.dispose(disposable)
+ }
+ }
+
+ private fun assertContainsRange(viewer: SimpleThreesideDiffViewer, type: TextDiffType) {
+ assertNotNull(viewer.changes.find { change ->
+ change.diffType == type
+ })
+ }
+
+ private fun assertContainsBackgroundColor(viewer: SimpleThreesideDiffViewer, type: TextDiffType, isIgnored: Boolean) {
+ assertContainsBackgroundColor(viewer) { editor, highlighter ->
+ val actual = highlighter.textAttributes?.backgroundColor
+ val expected = if (isIgnored) type.getIgnoredColor(editor) else type.getColor(editor)
+ actual == expected
+ }
+ }
+
+ private fun assertContainsMarkerColor(viewer: SimpleThreesideDiffViewer, type: TextDiffType) {
+ assertContainsBackgroundColor(viewer) { editor, highlighter ->
+ highlighter.textAttributes?.errorStripeColor == type.getMarkerColor(editor)
+ }
+ }
+
+ private fun assertContainsBackgroundColor(viewer: SimpleThreesideDiffViewer, condition: (EditorEx, RangeHighlighter) -> Boolean) {
+ val ranges = viewer.editors.flatMap { editor ->
+ listOfNotNull(editor.markupModel.allHighlighters.map { highlighter ->
+ return@map if (condition(editor, highlighter)) highlighter else null
+ })
+ }
+ assertTrue(ranges.isNotEmpty())
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java
index cff59c10fddf..122967f09e88 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionLookupArranger.java
@@ -51,8 +51,9 @@ public class CompletionLookupArranger extends LookupArranger {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.CompletionLookupArranger");
@Nullable private static StatisticsUpdate ourPendingUpdate;
private static final Alarm ourStatsAlarm = new Alarm(ApplicationManager.getApplication());
- private static final Key PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
- private static final Comparator BY_PRESENTATION_COMPARATOR = new Comparator() {
+ private static final Key GLOBAL_PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
+ private final Key PRESENTATION_INVARIANT = Key.create("PRESENTATION_INVARIANT");
+ private final Comparator BY_PRESENTATION_COMPARATOR = new Comparator() {
@Override
public int compare(LookupElement o1, LookupElement o2) {
String invariant = PRESENTATION_INVARIANT.get(o1);
@@ -152,6 +153,7 @@ public class CompletionLookupArranger extends LookupArranger {
final String invariant = presentation.getItemText() + "\0###" + getTailTextOrSpace(presentation) + "###" + presentation.getTypeText();
element.putUserData(PRESENTATION_INVARIANT, invariant);
+ element.putUserData(GLOBAL_PRESENTATION_INVARIANT, invariant);
CompletionSorterImpl sorter = obtainSorter(element);
Classifier classifier = myClassifiers.get(sorter);
@@ -208,7 +210,7 @@ public class CompletionLookupArranger extends LookupArranger {
return tailText == null || tailText.isEmpty() ? " " : tailText;
}
- private static List sortByPresentation(Iterable source, LookupImpl lookup) {
+ private List sortByPresentation(Iterable source, LookupImpl lookup) {
ArrayList startMatches = ContainerUtil.newArrayList();
ArrayList middleMatches = ContainerUtil.newArrayList();
for (LookupElement element : source) {
@@ -369,7 +371,7 @@ public class CompletionLookupArranger extends LookupArranger {
return new CompletionLookupArranger(myParameters, myProcess);
}
- private static int getItemToSelect(LookupImpl lookup, List items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) {
+ private int getItemToSelect(LookupImpl lookup, List items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) {
if (items.isEmpty() || lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) {
return 0;
}
@@ -391,7 +393,7 @@ public class CompletionLookupArranger extends LookupArranger {
for (int i = 0; i < items.size(); i++) {
String invariant = PRESENTATION_INVARIANT.get(items.get(i));
- if (invariant != null && invariant.equals(PRESENTATION_INVARIANT.get(lastSelection))) {
+ if (invariant != null && invariant.equals(GLOBAL_PRESENTATION_INVARIANT.get(lastSelection))) {
return i;
}
}
@@ -577,7 +579,7 @@ public class CompletionLookupArranger extends LookupArranger {
}
}
- private static class AlphaClassifier extends Classifier {
+ private class AlphaClassifier extends Classifier {
private final LookupImpl myLookup;
private AlphaClassifier(LookupImpl lookup) {
diff --git a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java
index 2e84ade5dae7..e7ee5311220e 100644
--- a/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java
+++ b/platform/lang-impl/src/com/intellij/openapi/diff/impl/settings/DiffPreviewPanel.java
@@ -45,6 +45,7 @@ import com.intellij.util.EventDispatcher;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
import java.awt.*;
import java.util.List;
@@ -229,4 +230,10 @@ public class DiffPreviewPanel implements PreviewPanel {
@Override
public void disposeUIResources() {
}
+
+ @NotNull
+ @TestOnly
+ public SimpleThreesideDiffViewer testGetViewer() {
+ return myViewer;
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java
index c698c4bfb138..85d6150dbbbd 100644
--- a/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java
+++ b/platform/lang-impl/src/com/intellij/webcore/packaging/InstalledPackagesPanel.java
@@ -7,6 +7,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.text.StringUtil;
@@ -38,6 +39,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class InstalledPackagesPanel extends JPanel {
+ private static final Logger LOG = Logger.getInstance(InstalledPackagesPanel.class);
private final AnActionButton myUpgradeButton;
protected final AnActionButton myInstallButton;
private final AnActionButton myUninstallButton;
@@ -418,7 +420,7 @@ public class InstalledPackagesPanel extends JPanel {
packages = packageManagementService.getInstalledPackages();
}
catch (IOException e) {
- // do nothing, we already have an empty list
+ LOG.warn(e.getMessage()); // do nothing, we already have an empty list
}
finally {
final Collection finalPackages = packages;
diff --git a/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java b/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java
index 2d6b32ae5a01..a398efccbdec 100644
--- a/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java
+++ b/platform/platform-impl/src/com/intellij/codeInsight/hint/EditorFragmentComponent.java
@@ -25,6 +25,8 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.ex.FoldingModelEx;
import com.intellij.openapi.editor.ex.util.EditorUIUtil;
+import com.intellij.openapi.editor.ex.util.EditorUtil;
+import com.intellij.openapi.editor.impl.EditorImpl;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.HintHint;
@@ -57,8 +59,12 @@ public class EditorFragmentComponent extends JPanel {
private void doInit(EditorEx editor, int startLine, int endLine, boolean showFolding, boolean showGutter) {
Document doc = editor.getDocument();
final int endOffset = endLine < doc.getLineCount() ? doc.getLineEndOffset(endLine) : doc.getTextLength();
- final int textImageWidth = Math.min(editor.getMaxWidthInRange(doc.getLineStartOffset(startLine), endOffset), ScreenUtil
- .getScreenRectangle(1, 1).width);
+ boolean newRendering = editor instanceof EditorImpl && ((EditorImpl)editor).myUseNewRendering;
+ int widthAdjustment = newRendering ? EditorUtil.getSpaceWidth(Font.PLAIN, editor) : 0;
+ final int textImageWidth = Math.min(
+ editor.getMaxWidthInRange(doc.getLineStartOffset(startLine), endOffset) + widthAdjustment,
+ ScreenUtil.getScreenRectangle(1, 1).width
+ );
LOG.assertTrue(textImageWidth > 0, "TextWidth: "+textImageWidth+"; startLine:" + startLine + "; endLine:" + endLine + ";");
FoldingModelEx foldingModel = editor.getFoldingModel();
@@ -74,7 +80,7 @@ public class EditorFragmentComponent extends JPanel {
final int textImageHeight = y2 - y1 == 0 ? editor.getLineHeight() : y2 - y1;
LOG.assertTrue(textImageHeight > 0, "Height: " + textImageHeight + "; startLine:" + startLine + "; endLine:" + endLine + "; p1:" + p1 + "; p2:" + p2);
- int savedScrollOffset = editor.getScrollingModel().getHorizontalScrollOffset();
+ int savedScrollOffset = newRendering ? 0 : editor.getScrollingModel().getHorizontalScrollOffset();
if (savedScrollOffset > 0) {
editor.getScrollingModel().scrollHorizontally(0);
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
index 19b009d06e63..836a5a4f2fe8 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
@@ -3152,7 +3152,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
+ ", soft wraps data: " + getSoftWrapModel().dumpState()
+ "\n\nfolding data: " + getFoldingModel().dumpState()
+ (myDocument instanceof DocumentImpl ? "\n\ndocument info: " + ((DocumentImpl)myDocument).dumpState() : "")
- + "\nfont preferences: " + myScheme.getFontPreferences();
+ + "\nfont preferences: " + myScheme.getFontPreferences()
+ + "\npure painting mode: " + myPurePaintingMode
+ + (myView == null ? "" : "\nview: " + myView.dumpState());
}
private class CachedFontContent {
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorSizeManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorSizeManager.java
index e757a717042e..25f0b0c0989c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorSizeManager.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorSizeManager.java
@@ -15,7 +15,10 @@
*/
package com.intellij.openapi.editor.impl.view;
+import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.diagnostic.Attachment;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.EditorLinePainter;
import com.intellij.openapi.editor.FoldRegion;
@@ -45,7 +48,9 @@ import java.util.List;
/**
* Calculates width (in pixels) of editor contents.
*/
-class EditorSizeManager implements PrioritizedDocumentListener, Disposable, FoldingListener {
+class EditorSizeManager implements PrioritizedDocumentListener, Disposable, FoldingListener, Dumpable {
+ private static final Logger LOG = Logger.getInstance(EditorSizeManager.class);
+
private static final int UNKNOWN_WIDTH = Integer.MAX_VALUE;
private final EditorView myView;
@@ -197,6 +202,10 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
}
private int calculatePreferredWidth() {
+ if (myLineWidths.size() != myEditor.getVisibleLineCount()) {
+ LOG.error("Inconsistent state", new Attachment("editor.txt", myEditor.dumpState()));
+ reset();
+ }
assert myLineWidths.size() == myEditor.getVisibleLineCount();
VisualLinesIterator iterator = new VisualLinesIterator(myView, 0);
int maxWidth = 0;
@@ -324,4 +333,10 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
myEditor.getFoldingModel().setFoldingEnabled(foldingEnabled);
}
}
+
+ @NotNull
+ @Override
+ public String dumpState() {
+ return "[line widths: " + myLineWidths + "]";
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java
index b5556ec6ece6..01e81ece567b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/view/EditorView.java
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.editor.impl.view;
+import com.intellij.diagnostic.Dumpable;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.FoldRegion;
@@ -44,7 +45,7 @@ import java.awt.image.BufferedImage;
*
* Also contains a cache of several font-related quantities (line height, space width, etc).
*/
-public class EditorView implements TextDrawingCallback, Disposable {
+public class EditorView implements TextDrawingCallback, Disposable, Dumpable {
private static Key FOLD_REGION_TEXT_LAYOUT = Key.create("text.layout");
private final EditorImpl myEditor;
@@ -244,6 +245,7 @@ public class EditorView implements TextDrawingCallback, Disposable {
public Dimension getPreferredSize() {
assertIsDispatchThread();
+ assert !myEditor.isPurePaintingMode();
myEditor.getSoftWrapModel().prepareToMapping();
return mySizeManager.getPreferredSize();
}
@@ -467,4 +469,10 @@ public class EditorView implements TextDrawingCallback, Disposable {
public void drawChars(@NotNull Graphics g, @NotNull char[] data, int start, int end, int x, int y, Color color, FontInfo fontInfo) {
myPainter.drawChars(g, data, start, end, x, y, color, fontInfo);
}
+
+ @NotNull
+ @Override
+ public String dumpState() {
+ return "[Size manager: " + mySizeManager.dumpState() + "]";
+ }
}
diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java
index ed9185a43230..202999b53b90 100644
--- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java
+++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/IdeKeyEventDispatcher.java
@@ -173,7 +173,7 @@ public final class IdeKeyEventDispatcher implements Disposable {
return false;
}
if (focusOwner instanceof JTextComponent && ((JTextComponent)focusOwner).isEditable()) {
- if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && e.getKeyChar() != KeyEvent.VK_ESCAPE) {
+ if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && e.getKeyCode() != KeyEvent.VK_ESCAPE) {
MacUIUtil.hideCursor();
}
}
diff --git a/platform/platform-resources/src/META-INF/xdebugger.xml b/platform/platform-resources/src/META-INF/xdebugger.xml
index fef5c275b5cd..511f4f24856b 100644
--- a/platform/platform-resources/src/META-INF/xdebugger.xml
+++ b/platform/platform-resources/src/META-INF/xdebugger.xml
@@ -30,7 +30,7 @@
-
diff --git a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java
index 56f5617480b2..296942efd5d5 100644
--- a/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java
+++ b/platform/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java
@@ -10,6 +10,7 @@ import com.intellij.openapi.fileTypes.FileTypes;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentIterator;
import com.intellij.openapi.util.Computable;
@@ -47,7 +48,7 @@ public class MatcherImpl {
private static final Logger LOG = Logger.getInstance("#com.intellij.structuralsearch.impl.matcher.MatcherImpl");
// project being worked on
private final Project project;
- private final PsiDocumentManager documentManager;
+ private final DumbService myDumbService;
// context of matching
private final MatchContext matchContext;
@@ -70,7 +71,7 @@ public class MatcherImpl {
matchContext.setOptions(matchOptions);
cacheCompiledPattern(matchOptions, PatternCompiler.compilePattern(project,matchOptions));
}
- documentManager = PsiDocumentManager.getInstance(this.project);
+ myDumbService = DumbService.getInstance(project);
}
static class LastMatchData {
@@ -523,7 +524,7 @@ public class MatcherImpl {
matchContext.getSink().processFile((PsiFile)file);
}
- documentManager.commitAndRunReadAction(new Runnable() {
+ myDumbService.runReadActionInSmartMode(new Runnable() {
@Override
public void run() {
if (!file.isValid()) return;
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/AnnotationGutterActionProvider.java b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/AnnotationGutterActionProvider.java
index d3bc6fcda482..a9fa4e022e4f 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/AnnotationGutterActionProvider.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/annotate/AnnotationGutterActionProvider.java
@@ -20,9 +20,7 @@ import com.intellij.openapi.extensions.ExtensionPointName;
import org.jetbrains.annotations.NotNull;
/**
- * Implement this to add additional custom actions to the popup invoked by right-clicking on the annotation gutter.
- *
- * @author Kirill Likhodedov
+ * Implement this to add an additional custom action to the annotation gutter popup (invoked by right-click to an annotation).
*/
public interface AnnotationGutterActionProvider {
@@ -30,10 +28,11 @@ public interface AnnotationGutterActionProvider {
/**
* Create an action that will be added to the annotation gutter popup.
+ *
* @param annotation annotation which is currently shown on the gutter.
* @return new action that can be invoked from the annotation gutter popup.
*/
@NotNull
- AnAction createAction(FileAnnotation annotation);
+ AnAction createAction(@NotNull FileAnnotation annotation);
}
diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.java b/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.java
index 4a8574d48ea7..1d8fd2d654ad 100644
--- a/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.java
+++ b/platform/vcs-api/src/com/intellij/openapi/vcs/merge/MergeDialogCustomizer.java
@@ -26,7 +26,6 @@ import java.util.Collection;
/**
* Provides custom titles and messages used in MultipleFileMergeDialog and DiffTool invoked from it.
- * @author Kirill Likhodedov
*/
public class MergeDialogCustomizer {
@@ -34,7 +33,7 @@ public class MergeDialogCustomizer {
* @param files files that have conflicted changes and are shown in the dialog.
* @return description that is shows above the list of conflicted files. Null (which is equivalent to empty) by default.
*/
- public @Nullable String getMultipleFileMergeDescription(Collection files) {
+ @Nullable public String getMultipleFileMergeDescription(@NotNull Collection files) {
return null;
}
@@ -42,7 +41,7 @@ public class MergeDialogCustomizer {
* @param file file that is merged.
* @return title of the merge dialog invoked for a 3-way merge of a file.
*/
- public @Nullable String getMergeWindowTitle(VirtualFile file) {
+ @Nullable public String getMergeWindowTitle(@NotNull VirtualFile file) {
return VcsBundle.message("multiple.file.merge.request.title", FileUtil.toSystemDependentName(file.getPresentableUrl()));
}
@@ -50,7 +49,7 @@ public class MergeDialogCustomizer {
* @param file file that is merged.
* @return title that is shown above the left panel in the 3-way merge dialog. "Local changes" by default.
*/
- public @Nullable String getLeftPanelTitle(VirtualFile file) {
+ @Nullable public String getLeftPanelTitle(@NotNull VirtualFile file) {
return VcsBundle.message("merge.version.title.local.changes");
}
@@ -58,18 +57,18 @@ public class MergeDialogCustomizer {
* @param file file that is merged.
* @return title that is shown above the center panel in the 3-way merge dialog. "Merge result" by default.
*/
- public @Nullable String getCenterPanelTitle(VirtualFile file) {
+ @Nullable public String getCenterPanelTitle(@NotNull VirtualFile file) {
return VcsBundle.message("merge.version.title.merge.result");
}
/**
- * @param file file that is merged.
- * @param lastRevisionNumber
+ * @param file file that is being merged.
+ * @param revisionNumber revision number of the file at the right, can be null if unknown.
* @return title that is shown above the right panel in the 3-way merge dialog. "Changes from server" with the revision number by default.
*/
- public @Nullable String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
- if (lastRevisionNumber != null) {
- return VcsBundle.message("merge.version.title.last.version.number", lastRevisionNumber.asString());
+ @Nullable public String getRightPanelTitle(@NotNull VirtualFile file, @Nullable VcsRevisionNumber revisionNumber) {
+ if (revisionNumber != null) {
+ return VcsBundle.message("merge.version.title.last.version.number", revisionNumber.asString());
} else {
return VcsBundle.message("merge.version.title.last.version");
}
@@ -77,11 +76,9 @@ public class MergeDialogCustomizer {
/**
* @return The title of multiple files merge dialog.
- * Don't mix with {@link #getMergeWindowTitle(com.intellij.openapi.vfs.VirtualFile)} which is the title of a 3-way merge dialog
- * displayed for a single file.
+ * Don't mix with {@link #getMergeWindowTitle(VirtualFile)} which is the title of a 3-way merge dialog displayed for a single file.
*/
- public @NotNull String getMultipleFileDialogTitle() {
+ @NotNull public String getMultipleFileDialogTitle() {
return VcsBundle.message("multiple.file.merge.title");
}
-
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/abstraction/CastToConcreteClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/abstraction/CastToConcreteClassInspection.java
index 7aed6e23badd..05beec35ecf7 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/abstraction/CastToConcreteClassInspection.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/abstraction/CastToConcreteClassInspection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2012 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
+import com.siyeh.ig.psiutils.CloneUtils;
import com.siyeh.ig.psiutils.MethodUtils;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -33,7 +34,7 @@ public class CastToConcreteClassInspection extends BaseInspection {
public boolean ignoreAbstractClasses = false;
@SuppressWarnings("PublicField")
- public boolean ignoreInEquals = true;
+ public boolean ignoreInEquals = true; // keep for compatibility
@Override
@NotNull
@@ -73,11 +74,9 @@ public class CastToConcreteClassInspection extends BaseInspection {
if (!ConcreteClassUtil.typeIsConcreteClass(typeElement, ignoreAbstractClasses)) {
return;
}
- if (ignoreInEquals) {
- final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
- if (MethodUtils.isEquals(method)) {
- return;
- }
+ final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
+ if (MethodUtils.isEquals(method) || CloneUtils.isClone(method)) {
+ return;
}
registerError(typeElement, typeElement.getType());
}
@@ -116,11 +115,9 @@ public class CastToConcreteClassInspection extends BaseInspection {
if (!ConcreteClassUtil.typeIsConcreteClass(parameter, ignoreAbstractClasses)) {
return;
}
- if (ignoreInEquals) {
- final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
- if (MethodUtils.isEquals(method)) {
- return;
- }
+ final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
+ if (MethodUtils.isEquals(method) || CloneUtils.isClone(method)) {
+ return;
}
registerMethodCallError(expression, parameter);
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UnnecessaryInitCauseInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UnnecessaryInitCauseInspectionBase.java
index 917a29cf687d..f2c5bb3e63c3 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UnnecessaryInitCauseInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/errorhandling/UnnecessaryInitCauseInspectionBase.java
@@ -15,8 +15,11 @@
*/
package com.siyeh.ig.errorhandling;
+import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
+import com.intellij.psi.controlFlow.DefUseUtil;
import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiTreeUtil;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
@@ -60,13 +63,7 @@ public class UnnecessaryInitCauseInspectionBase extends BaseInspection {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
- if (!ExpressionUtils.hasExpressionCount(argumentList, 1)) {
- return;
- }
- final PsiExpression argument = ExpressionUtils.getFirstExpressionInList(argumentList);
- if (argument == null) {
- return;
- }
+ final PsiExpression argument = ExpressionUtils.getOnlyExpressionInList(argumentList);
if (!TypeUtils.expressionHasTypeOrSubtype(argument, CommonClassNames.JAVA_LANG_THROWABLE)) {
return;
}
@@ -80,12 +77,42 @@ public class UnnecessaryInitCauseInspectionBase extends BaseInspection {
}
final PsiExpression qualifier = ParenthesesUtils.stripParentheses(methodExpression.getQualifierExpression());
final PsiNewExpression newExpression = findNewExpression(qualifier);
- if (!isCauseConstructorAvailable(newExpression)) {
+ if (!isCauseConstructorAvailable(newExpression) || !canExpressionBeMovedBackwards(argument, newExpression)) {
return;
}
registerMethodCallError(expression);
}
+ private static boolean canExpressionBeMovedBackwards(final PsiExpression cause, final PsiExpression newLocation) {
+ if (cause == null || newLocation == null) return false;
+ assert cause.getTextOffset() > newLocation.getTextOffset();
+ final PsiCodeBlock block = PsiTreeUtil.getParentOfType(cause, PsiCodeBlock.class);
+ final PsiCodeBlock newBlock = PsiTreeUtil.getParentOfType(newLocation, PsiCodeBlock.class);
+ if (block == null || newBlock == null || !PsiTreeUtil.isAncestor(block, newBlock, false)) return false;
+ final int offset = newLocation.getTextOffset();
+ final Ref result = new Ref(Boolean.TRUE);
+ cause.accept(new JavaRecursiveElementWalkingVisitor() {
+ @Override
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
+ if (!result.get().booleanValue()) {
+ return;
+ }
+ super.visitReferenceExpression(expression);
+ final PsiElement target = expression.resolve();
+ if (!(target instanceof PsiVariable)) {
+ return;
+ }
+ final PsiElement[] defs = DefUseUtil.getDefs(block, (PsiVariable)target, cause);
+ for (PsiElement def : defs) {
+ if (def.getTextOffset() > offset) {
+ result.set(Boolean.FALSE);
+ }
+ }
+ }
+ });
+ return result.get().booleanValue();
+ }
+
public static boolean isCauseConstructorAvailable(PsiNewExpression newExpression) {
if (newExpression == null) {
return false;
@@ -140,10 +167,25 @@ public class UnnecessaryInitCauseInspectionBase extends BaseInspection {
}
final PsiVariable variable = (PsiVariable)target;
final PsiExpression initializer = variable.getInitializer();
- if (!(initializer instanceof PsiNewExpression)) {
+ if ((initializer instanceof PsiNewExpression)) {
+ return (PsiNewExpression)initializer;
+ }
+ final PsiCodeBlock block = PsiTreeUtil.getParentOfType(target, PsiCodeBlock.class);
+ final PsiElement[] defs = DefUseUtil.getDefs(block, variable, expression);
+ if (defs.length != 1) {
return null;
}
- return (PsiNewExpression)initializer;
+ final PsiElement def = defs[0];
+ if (!(def instanceof PsiReferenceExpression) || !(def.getParent() instanceof PsiAssignmentExpression)) {
+ return null;
+ }
+ final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)def.getParent();
+ if (assignmentExpression.getOperationTokenType() != JavaTokenType.EQ) return null;
+ final PsiExpression rhs = ParenthesesUtils.stripParentheses(assignmentExpression.getRExpression());
+ if (!(rhs instanceof PsiNewExpression)) {
+ return null;
+ }
+ return (PsiNewExpression)rhs;
}
return null;
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ControlFlowUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ControlFlowUtils.java
index 7010e63084bc..a09e2143f4ab 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ControlFlowUtils.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ControlFlowUtils.java
@@ -478,7 +478,7 @@ public class ControlFlowUtils {
return getOnlyChildOfType(codeBlock, PsiStatement.class);
}
- private static T getOnlyChildOfType(@Nullable PsiElement element, @NotNull Class aClass) {
+ static T getOnlyChildOfType(@Nullable PsiElement element, @NotNull Class aClass) {
if (element == null) return null;
T result = null;
for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java
index 294ff8bbb583..799f3dac1aff 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ExpressionUtils.java
@@ -72,6 +72,11 @@ public class ExpressionUtils {
return PsiTreeUtil.getChildOfType(expressionList, PsiExpression.class);
}
+ @Nullable
+ public static PsiExpression getOnlyExpressionInList(@Nullable PsiExpressionList expressionList) {
+ return ControlFlowUtils.getOnlyChildOfType(expressionList, PsiExpression.class);
+ }
+
public static boolean isDeclaredConstant(PsiExpression expression) {
PsiField field =
PsiTreeUtil.getParentOfType(expression, PsiField.class);
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html
index 1ae40923ea45..503c2af6c0d2 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CastToConcreteClass.html
@@ -2,12 +2,10 @@
Reports casting a value to a concrete class, rather than an interface.
Such declarations may represent a failure of abstraction, and may make testing more difficult.
-Declarations whose classes come from system or third-party libraries will not be reported by this inspection.
+Casts to system or library classes and casts inside equals() and clone() methods will not be reported by this inspection.
-Use the first checkbox below to have this inspection ignore casts to abstract classes.
-
-Use the second checkbox below to have this inspection ignore casts inside equals() methods.
+Use the checkbox below to have this inspection ignore casts to abstract classes.
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.after.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.after.java
index 8332ee58e6e7..1b89ce8810e5 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.after.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.after.java
@@ -7,7 +7,7 @@ class Indirect {
new FileInputStream("asdf");
} catch (FileNotFoundException e) {
final RuntimeException exception = new RuntimeException(e);
- throw e;
+ throw exception;
}
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.java b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.java
index fe3b01bd1126..2a0ca17c13d0 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igfixes/errorhandling/unnecessary_init_cause/Indirect.java
@@ -8,7 +8,7 @@ class Indirect {
} catch (FileNotFoundException e) {
final RuntimeException exception = new RuntimeException();
exception.initCause(e);
- throw e;
+ throw exception;
}
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/cast_to_concrete_class/CastToConcreteClass.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/cast_to_concrete_class/CastToConcreteClass.java
index a4868a962999..aa6ce961a68e 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/cast_to_concrete_class/CastToConcreteClass.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/cast_to_concrete_class/CastToConcreteClass.java
@@ -14,10 +14,15 @@ class CastToConcreteClass {
}
}
+ @Override
+ public CastToConcreteClass clone() throws CloneNotSupportedException {
+ return (CastToConcreteClass) super.clone();
+ }
+
void foo(Object o) {
- CastToConcreteClass c = (CastToConcreteClass)o;
- CastToConcreteClass c2 = CastToConcreteClass.class.cast(o);
+ CastToConcreteClass c = (CastToConcreteClass)o;
+ CastToConcreteClass c2 = CastToConcreteClass.class.cast(o);
final Class aClass = CastToConcreteClass.class;
- final CastToConcreteClass c3 = aClass.cast(o);
+ final CastToConcreteClass c3 = aClass.cast(o);
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/cast_to_concrete_class/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/cast_to_concrete_class/expected.xml
deleted file mode 100644
index 76af465c4b12..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/abstraction/cast_to_concrete_class/expected.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- CastToConcreteClass.java
- 18
- Cast to a concrete class
- Cast to concrete class <code>CastToConcreteClass</code> #loc
-
-
-
- CastToConcreteClass.java
- 19
- Cast to a concrete class
- Cast to concrete class <code>CastToConcreteClass</code> #loc
-
-
-
- CastToConcreteClass.java
- 21
- Cast to a concrete class
- Cast to concrete class <code>CastToConcreteClass</code> #loc
-
-
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/object_to_string/ObjectToString.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/object_to_string/ObjectToString.java
index 4fda0ef30cb3..2953f4c898d2 100644
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/object_to_string/ObjectToString.java
+++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/object_to_string/ObjectToString.java
@@ -17,10 +17,10 @@ class ObjectToString
class N {}
void foo(N n) {
- n.toString();
+ n.toString();
}
String bar(N n) {
- return "n: " + n + "a";
+ return "n: " + n + "a";
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/object_to_string/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/object_to_string/expected.xml
deleted file mode 100644
index 2628b6f1f6b7..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/object_to_string/expected.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- ObjectToString.java
- 20
- Call to default 'toString()'
- Call to default 'toString()' on <code>n</code> #loc
-
-
-
- ObjectToString.java
- 24
- Call to default 'toString()'
- Call to default 'toString()' on <code>n</code> #loc
-
-
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/CastToConcreteClassInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/CastToConcreteClassInspectionTest.java
index bd9e6e35ba9a..b5ae8b31a4a8 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/CastToConcreteClassInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/abstraction/CastToConcreteClassInspectionTest.java
@@ -1,12 +1,20 @@
package com.siyeh.ig.abstraction;
-import com.siyeh.ig.IGInspectionTestCase;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
-public class CastToConcreteClassInspectionTest extends IGInspectionTestCase {
+public class CastToConcreteClassInspectionTest extends LightInspectionTestCase {
- public void test() throws Exception {
- final CastToConcreteClassInspection tool = new CastToConcreteClassInspection();
- tool.ignoreInEquals = true;
- doTest("com/siyeh/igtest/abstraction/cast_to_concrete_class", tool);
+ public void testCastToConcreteClass() {
+ doTest();
+ }
+
+ @Nullable
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ final CastToConcreteClassInspection inspection = new CastToConcreteClassInspection();
+ inspection.ignoreInEquals = true;
+ return inspection;
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ObjectToStringInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ObjectToStringInspectionTest.java
index d81471cf88a0..36c47f491c7c 100644
--- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ObjectToStringInspectionTest.java
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/bugs/ObjectToStringInspectionTest.java
@@ -1,11 +1,18 @@
package com.siyeh.ig.bugs;
-import com.siyeh.ig.IGInspectionTestCase;
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
-public class ObjectToStringInspectionTest extends IGInspectionTestCase {
+public class ObjectToStringInspectionTest extends LightInspectionTestCase {
- public void test() throws Exception {
- doTest("com/siyeh/igtest/bugs/object_to_string",
- new ObjectToStringInspection());
+ public void testObjectToString() throws Exception {
+ doTest();
+ }
+
+ @Nullable
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new ObjectToStringInspection();
}
}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/UnnecessaryInitCauseInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/UnnecessaryInitCauseInspectionTest.java
new file mode 100644
index 000000000000..2e3a36d80ac4
--- /dev/null
+++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/errorhandling/UnnecessaryInitCauseInspectionTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.errorhandling;
+
+import com.intellij.codeInspection.InspectionProfileEntry;
+import com.siyeh.ig.LightInspectionTestCase;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class UnnecessaryInitCauseInspectionTest extends LightInspectionTestCase {
+
+ public void testSplitDeclarationAssignment() {
+ doMemberTest("void foo() {\n" +
+ " RuntimeException exception = null;\n" +
+ " try {\n" +
+ " new java.io.FileInputStream(\"asdf\");\n" +
+ " } catch (java.io.FileNotFoundException e) {\n" +
+ " exception = new RuntimeException();\n" +
+ " exception./*Unnecessary 'Throwable.initCause()' call*/initCause/**/(e);\n" +
+ " } catch (RuntimeException e) {\n" +
+ " exception = e;\n" +
+ " }\n" +
+ " throw exception;\n" +
+ "}");
+ }
+
+ public void testReassigned() {
+ doMemberTest("void foo() {\n" +
+ " try {\n" +
+ " new java.io.FileInputStream(\"asdf\");\n" +
+ " } catch (java.io.FileNotFoundException e) {\n" +
+ " RuntimeException exception = new RuntimeException();\n" +
+ " e = null;\n" +
+ " exception.initCause(e);\n" +
+ " throw exception;\n" +
+ " }\n" +
+ "}");
+ }
+
+ @Nullable
+ @Override
+ protected InspectionProfileEntry getInspection() {
+ return new UnnecessaryInitCauseInspection();
+ }
+}
\ No newline at end of file
diff --git a/plugins/git4idea/src/META-INF/plugin.xml b/plugins/git4idea/src/META-INF/plugin.xml
index 80b942563d93..d35bd926eea0 100644
--- a/plugins/git4idea/src/META-INF/plugin.xml
+++ b/plugins/git4idea/src/META-INF/plugin.xml
@@ -137,6 +137,7 @@
+ files) {
+ public String getMultipleFileMergeDescription(@NotNull Collection files) {
return "Conflicts during cherry-picking commit " + myCommitHash + " made by " + myCommitAuthor + " " +
"\"" + myCommitMessage + "\"";
}
@Override
- public String getLeftPanelTitle(VirtualFile file) {
+ public String getLeftPanelTitle(@NotNull VirtualFile file) {
return "Local changes";
}
@Override
- public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
+ public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return "Changes from cherry-pick " + myCommitHash + "";
}
}
diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java
index 27d22010dcd8..982ad2572b43 100644
--- a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java
+++ b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java
@@ -38,7 +38,7 @@ import git4idea.GitVcs;
import git4idea.changes.GitChangeUtils;
import git4idea.config.GitExecutableValidator;
import git4idea.history.browser.SHAHash;
-import git4idea.history.wholeTree.SelectRevisionInGitLogAction;
+import git4idea.log.GitShowCommitInLogAction;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
import org.jetbrains.annotations.NotNull;
@@ -69,7 +69,7 @@ public class GitHistoryProvider implements VcsHistoryProviderEx, VcsCacheableHis
return new AnAction[] {
ShowAllAffectedGenericAction.getInstance(),
ActionManager.getInstance().getAction(VcsActions.ACTION_COPY_REVISION_NUMBER),
- new SelectRevisionInGitLogAction() };
+ new GitShowCommitInLogAction() };
}
public boolean isDateOmittable() {
diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/SelectRevisionInGitLogAction.java b/plugins/git4idea/src/git4idea/log/GitShowCommitInLogAction.java
similarity index 83%
rename from plugins/git4idea/src/git4idea/history/wholeTree/SelectRevisionInGitLogAction.java
rename to plugins/git4idea/src/git4idea/log/GitShowCommitInLogAction.java
index 0d4c66a44f8e..e2aa69d0ff80 100644
--- a/plugins/git4idea/src/git4idea/history/wholeTree/SelectRevisionInGitLogAction.java
+++ b/plugins/git4idea/src/git4idea/log/GitShowCommitInLogAction.java
@@ -1,4 +1,19 @@
-package git4idea.history.wholeTree;
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package git4idea.log;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -31,11 +46,11 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-public class SelectRevisionInGitLogAction extends DumbAwareAction {
- private static final Logger LOG = Logger.getInstance(SelectRevisionInGitLogAction.class);
+public class GitShowCommitInLogAction extends DumbAwareAction {
+ private static final Logger LOG = Logger.getInstance(GitShowCommitInLogAction.class);
- public SelectRevisionInGitLogAction() {
- super(GitBundle.getString("vcs.history.action.gitlog"), GitBundle.getString("vcs.history.action.gitlog"), null);
+ public GitShowCommitInLogAction() {
+ super(GitBundle.getString("vcs.history.action.gitlog"));
}
@Override
@@ -106,7 +121,7 @@ public class SelectRevisionInGitLogAction extends DumbAwareAction {
}
@Nullable
- private static VcsRevisionNumber getRevisionNumber(@NotNull AnActionEvent event) {
+ protected VcsRevisionNumber getRevisionNumber(@NotNull AnActionEvent event) {
VcsRevisionNumber revision = event.getData(VcsDataKeys.VCS_REVISION_NUMBER);
if (revision == null) {
VcsFileRevision fileRevision = event.getData(VcsDataKeys.VCS_FILE_REVISION);
@@ -122,8 +137,7 @@ public class SelectRevisionInGitLogAction extends DumbAwareAction {
super.update(e);
e.getPresentation().setEnabled(e.getProject() != null &&
VcsLogContentProvider.findLogManager(e.getProject()) != null &&
- (e.getData(VcsDataKeys.VCS_FILE_REVISION) != null ||
- e.getData(VcsDataKeys.VCS_REVISION_NUMBER) != null));
+ getRevisionNumber(e) != null);
}
@Nullable
diff --git a/plugins/git4idea/src/git4idea/merge/GitConflictResolver.java b/plugins/git4idea/src/git4idea/merge/GitConflictResolver.java
index f04946b75170..1ccbc7ad3258 100644
--- a/plugins/git4idea/src/git4idea/merge/GitConflictResolver.java
+++ b/plugins/git4idea/src/git4idea/merge/GitConflictResolver.java
@@ -74,7 +74,7 @@ public class GitConflictResolver {
private String myErrorNotificationAdditionalDescription = "";
private String myMergeDescription = "";
private MergeDialogCustomizer myMergeDialogCustomizer = new MergeDialogCustomizer() {
- @Override public String getMultipleFileMergeDescription(Collection files) {
+ @Override public String getMultipleFileMergeDescription(@NotNull Collection files) {
return myMergeDescription;
}
};
diff --git a/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java b/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java
index 38db08222aea..06a32772cefb 100644
--- a/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java
+++ b/plugins/git4idea/src/git4idea/stash/GitStashChangesSaver.java
@@ -216,17 +216,17 @@ public class GitStashChangesSaver extends GitChangesSaver {
private static class UnstashMergeDialogCustomizer extends MergeDialogCustomizer {
@Override
- public String getMultipleFileMergeDescription(Collection files) {
+ public String getMultipleFileMergeDescription(@NotNull Collection files) {
return "Uncommitted changes that were stashed before update have conflicts with updated files.";
}
@Override
- public String getLeftPanelTitle(VirtualFile file) {
+ public String getLeftPanelTitle(@NotNull VirtualFile file) {
return getConflictLeftPanelTitle();
}
@Override
- public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
+ public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return getConflictRightPanelTitle();
}
}
diff --git a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java
index ec5c56b37347..9be52ed5cf57 100644
--- a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java
+++ b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java
@@ -444,17 +444,17 @@ public class GitUnstashDialog extends DialogWrapper {
}
@Override
- public String getMultipleFileMergeDescription(Collection files) {
+ public String getMultipleFileMergeDescription(@NotNull Collection files) {
return "Conflicts during unstashing " + myStashInfo.getStash() + "\"" + myStashInfo.getMessage() + "\"";
}
@Override
- public String getLeftPanelTitle(VirtualFile file) {
+ public String getLeftPanelTitle(@NotNull VirtualFile file) {
return "Local changes";
}
@Override
- public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
+ public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return "Changes from stash";
}
}
diff --git a/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java b/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java
index bec4da6cd0cf..93e472baae2b 100644
--- a/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java
+++ b/plugins/git4idea/src/git4idea/util/GitPreservingProcess.java
@@ -125,19 +125,19 @@ public class GitPreservingProcess {
GitChangesSaver saver = GitChangesSaver.getSaver(myProject, myFacade, myGit, myProgressIndicator, myStashMessage, saveMethod);
MergeDialogCustomizer mergeDialogCustomizer = new MergeDialogCustomizer() {
@Override
- public String getMultipleFileMergeDescription(Collection files) {
+ public String getMultipleFileMergeDescription(@NotNull Collection files) {
return String.format(
"Uncommitted changes that were saved before %s have conflicts with files from %s",
myOperationTitle, myDestinationName);
}
@Override
- public String getLeftPanelTitle(VirtualFile file) {
+ public String getLeftPanelTitle(@NotNull VirtualFile file) {
return "Uncommitted changes from stash";
}
@Override
- public String getRightPanelTitle(VirtualFile file, VcsRevisionNumber lastRevisionNumber) {
+ public String getRightPanelTitle(@NotNull VirtualFile file, VcsRevisionNumber revisionNumber) {
return String.format("Changes from %s", myDestinationName);
}
};
diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java
index ed8de64b39b7..4700d3b8b174 100644
--- a/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java
+++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShowCommitInBrowserFromAnnotateAction.java
@@ -51,8 +51,7 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
e.getPresentation().setVisible(false);
return;
}
- int corrected = eventData.getCorrectedLineNumber();
- e.getPresentation().setEnabled(corrected >= 0 && myAnnotation.getLineRevisionNumber(corrected) != null);
+ e.getPresentation().setEnabled(myLineNumber >= 0 && myAnnotation.getLineRevisionNumber(myLineNumber) != null);
e.getPresentation().setVisible(GithubUtil.isRepositoryOnGitHub(eventData.getRepository()));
}
@@ -63,7 +62,7 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
return;
}
- final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(eventData.getCorrectedLineNumber());
+ final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(myLineNumber);
if (revisionNumber != null) {
openInBrowser(eventData.getProject(), eventData.getRepository(), revisionNumber.asString());
}
@@ -86,7 +85,7 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
return null;
}
- return new EventData(project, repository, lineNumber);
+ return new EventData(project, repository);
}
@Override
@@ -97,12 +96,10 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
private static class EventData {
@NotNull private final Project myProject;
@NotNull private final GitRepository myRepository;
- private final int myCorrectedLineNumber;
- private EventData(@NotNull Project project, @NotNull GitRepository repository, int correctedLineNumber) {
+ private EventData(@NotNull Project project, @NotNull GitRepository repository) {
myProject = project;
myRepository = repository;
- myCorrectedLineNumber = correctedLineNumber;
}
@NotNull
@@ -114,10 +111,5 @@ public class GithubShowCommitInBrowserFromAnnotateAction extends GithubShowCommi
public GitRepository getRepository() {
return myRepository;
}
-
- private int getCorrectedLineNumber() {
- return myCorrectedLineNumber;
- }
}
-
}
diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/source/impl/GroovyTreeGenerator.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/source/impl/GroovyTreeGenerator.java
index c1a08cc3a593..97d48f1229fc 100644
--- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/source/impl/GroovyTreeGenerator.java
+++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/source/impl/GroovyTreeGenerator.java
@@ -20,12 +20,13 @@ import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.psi.impl.source.tree.TreeGenerator;
import com.intellij.util.CharTable;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
public class GroovyTreeGenerator implements TreeGenerator {
@Override
- public TreeElement generateTreeFor(PsiElement original, CharTable table, PsiManager manager) {
+ public TreeElement generateTreeFor(@NotNull PsiElement original, @NotNull CharTable table, @NotNull PsiManager manager) {
if (original instanceof GrModifierList) {
final String text = original.getText();
diff --git a/python/helpers/docutils/__init__.py b/python/helpers/py2only/docutils/__init__.py
similarity index 100%
rename from python/helpers/docutils/__init__.py
rename to python/helpers/py2only/docutils/__init__.py
diff --git a/python/helpers/docutils/_compat.py b/python/helpers/py2only/docutils/_compat.py
similarity index 96%
rename from python/helpers/docutils/_compat.py
rename to python/helpers/py2only/docutils/_compat.py
index 87f46da972ce..518f8961650c 100644
--- a/python/helpers/docutils/_compat.py
+++ b/python/helpers/py2only/docutils/_compat.py
@@ -19,7 +19,6 @@ import sys
if sys.version_info < (3,0):
b = bytes = str
u_prefix = 'u'
- from StringIO import StringIO as BytesIO
else:
import builtins
bytes = builtins.bytes
diff --git a/python/helpers/docutils/_string_template_compat.py b/python/helpers/py2only/docutils/_string_template_compat.py
similarity index 100%
rename from python/helpers/docutils/_string_template_compat.py
rename to python/helpers/py2only/docutils/_string_template_compat.py
diff --git a/python/helpers/docutils/core.py b/python/helpers/py2only/docutils/core.py
similarity index 99%
rename from python/helpers/docutils/core.py
rename to python/helpers/py2only/docutils/core.py
index 68928fb20076..5d3d46aea31b 100644
--- a/python/helpers/docutils/core.py
+++ b/python/helpers/py2only/docutils/core.py
@@ -14,13 +14,13 @@ custom component objects first, and pass *them* to
__docformat__ = 'reStructuredText'
-import sys
import pprint
-from docutils import __version__, __version_details__, SettingsSpec
-from docutils import frontend, io, utils, readers, writers
-from docutils.frontend import OptionParser
-from docutils.transforms import Transformer
+import sys
+
import docutils.readers.doctree
+from docutils import __version__, __version_details__, SettingsSpec
+from docutils import io, utils, readers, writers
+from docutils.frontend import OptionParser
class Publisher:
diff --git a/python/helpers/docutils/docutils.conf b/python/helpers/py2only/docutils/docutils.conf
similarity index 100%
rename from python/helpers/docutils/docutils.conf
rename to python/helpers/py2only/docutils/docutils.conf
diff --git a/python/helpers/docutils/examples.py b/python/helpers/py2only/docutils/examples.py
similarity index 100%
rename from python/helpers/docutils/examples.py
rename to python/helpers/py2only/docutils/examples.py
diff --git a/python/helpers/docutils/frontend.py b/python/helpers/py2only/docutils/frontend.py
similarity index 99%
rename from python/helpers/docutils/frontend.py
rename to python/helpers/py2only/docutils/frontend.py
index f274150205ed..9eadd2278f37 100644
--- a/python/helpers/docutils/frontend.py
+++ b/python/helpers/py2only/docutils/frontend.py
@@ -27,18 +27,19 @@ Also exports the following functions:
__docformat__ = 'reStructuredText'
+import ConfigParser as CP
+import codecs
+import optparse
import os
import os.path
import sys
import warnings
-import ConfigParser as CP
-import codecs
-import docutils
-import docutils.utils
-import docutils.nodes
-import optparse
from optparse import SUPPRESS_HELP
+import docutils
+import docutils.nodes
+import docutils.utils
+
def store_multiple(option, opt, value, parser, *args, **kwargs):
"""
diff --git a/python/helpers/docutils/io.py b/python/helpers/py2only/docutils/io.py
similarity index 100%
rename from python/helpers/docutils/io.py
rename to python/helpers/py2only/docutils/io.py
diff --git a/python/helpers/docutils/languages/__init__.py b/python/helpers/py2only/docutils/languages/__init__.py
similarity index 100%
rename from python/helpers/docutils/languages/__init__.py
rename to python/helpers/py2only/docutils/languages/__init__.py
diff --git a/python/helpers/docutils/languages/en.py b/python/helpers/py2only/docutils/languages/en.py
similarity index 100%
rename from python/helpers/docutils/languages/en.py
rename to python/helpers/py2only/docutils/languages/en.py
diff --git a/python/helpers/docutils/nodes.py b/python/helpers/py2only/docutils/nodes.py
similarity index 99%
rename from python/helpers/docutils/nodes.py
rename to python/helpers/py2only/docutils/nodes.py
index c43fa3de8649..cdebc29f3b26 100644
--- a/python/helpers/docutils/nodes.py
+++ b/python/helpers/py2only/docutils/nodes.py
@@ -21,12 +21,12 @@ hierarchy.
__docformat__ = 'reStructuredText'
-import sys
-import os
import re
-import warnings
+import sys
import types
import unicodedata
+import warnings
+
# ==============================
# Functional Node Base Classes
diff --git a/python/helpers/docutils/parsers/__init__.py b/python/helpers/py2only/docutils/parsers/__init__.py
similarity index 100%
rename from python/helpers/docutils/parsers/__init__.py
rename to python/helpers/py2only/docutils/parsers/__init__.py
diff --git a/python/helpers/docutils/parsers/null.py b/python/helpers/py2only/docutils/parsers/null.py
similarity index 100%
rename from python/helpers/docutils/parsers/null.py
rename to python/helpers/py2only/docutils/parsers/null.py
diff --git a/python/helpers/docutils/parsers/rst/__init__.py b/python/helpers/py2only/docutils/parsers/rst/__init__.py
similarity index 99%
rename from python/helpers/docutils/parsers/rst/__init__.py
rename to python/helpers/py2only/docutils/parsers/rst/__init__.py
index de8e2ab5ff56..afcee7965ffc 100644
--- a/python/helpers/docutils/parsers/rst/__init__.py
+++ b/python/helpers/py2only/docutils/parsers/rst/__init__.py
@@ -69,11 +69,10 @@ appropriate).
__docformat__ = 'reStructuredText'
-
import docutils.parsers
import docutils.statemachine
+from docutils import frontend
from docutils.parsers.rst import states
-from docutils import frontend, nodes
class Parser(docutils.parsers.Parser):
diff --git a/python/helpers/docutils/parsers/rst/directives/__init__.py b/python/helpers/py2only/docutils/parsers/rst/directives/__init__.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/directives/__init__.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/__init__.py
index 8ab69998e385..481456e7cd69 100644
--- a/python/helpers/docutils/parsers/rst/directives/__init__.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/__init__.py
@@ -8,12 +8,12 @@ This package contains directive implementation modules.
__docformat__ = 'reStructuredText'
-import re
import codecs
+import re
+
from docutils import nodes
from docutils.parsers.rst.languages import en as _fallback_language_module
-
_directive_registry = {
'attention': ('admonitions', 'Attention'),
'caution': ('admonitions', 'Caution'),
diff --git a/python/helpers/docutils/parsers/rst/directives/admonitions.py b/python/helpers/py2only/docutils/parsers/rst/directives/admonitions.py
similarity index 97%
rename from python/helpers/docutils/parsers/rst/directives/admonitions.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/admonitions.py
index e7ba007921af..1ab8097a6a36 100644
--- a/python/helpers/docutils/parsers/rst/directives/admonitions.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/admonitions.py
@@ -8,10 +8,9 @@ Admonition directives.
__docformat__ = 'reStructuredText'
-
-from docutils.parsers.rst import Directive
-from docutils.parsers.rst import states, directives
from docutils import nodes
+from docutils.parsers.rst import Directive
+from docutils.parsers.rst import directives
class BaseAdmonition(Directive):
diff --git a/python/helpers/docutils/parsers/rst/directives/body.py b/python/helpers/py2only/docutils/parsers/rst/directives/body.py
similarity index 99%
rename from python/helpers/docutils/parsers/rst/directives/body.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/body.py
index 13fc06c7b09d..0946d7f935be 100644
--- a/python/helpers/docutils/parsers/rst/directives/body.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/body.py
@@ -10,8 +10,6 @@ See `docutils.parsers.rst.directives` for API details.
__docformat__ = 'reStructuredText'
-
-import sys
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
diff --git a/python/helpers/docutils/parsers/rst/directives/html.py b/python/helpers/py2only/docutils/parsers/rst/directives/html.py
similarity index 99%
rename from python/helpers/docutils/parsers/rst/directives/html.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/html.py
index 97dfdadf9c43..6128a026611e 100644
--- a/python/helpers/docutils/parsers/rst/directives/html.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/html.py
@@ -8,7 +8,6 @@ Directives for typically HTML-specific constructs.
__docformat__ = 'reStructuredText'
-import sys
from docutils import nodes, utils
from docutils.parsers.rst import Directive
from docutils.parsers.rst import states
diff --git a/python/helpers/docutils/parsers/rst/directives/images.py b/python/helpers/py2only/docutils/parsers/rst/directives/images.py
similarity index 99%
rename from python/helpers/docutils/parsers/rst/directives/images.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/images.py
index 6356102de3d2..7fe576f05b95 100644
--- a/python/helpers/docutils/parsers/rst/directives/images.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/images.py
@@ -8,12 +8,10 @@ Directives for figures and simple images.
__docformat__ = 'reStructuredText'
-
-import sys
-from docutils import nodes, utils
+from docutils import nodes
+from docutils.nodes import fully_normalize_name, whitespace_normalize_name
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives, states
-from docutils.nodes import fully_normalize_name, whitespace_normalize_name
from docutils.parsers.rst.roles import set_classes
try:
diff --git a/python/helpers/docutils/parsers/rst/directives/misc.py b/python/helpers/py2only/docutils/parsers/rst/directives/misc.py
similarity index 99%
rename from python/helpers/docutils/parsers/rst/directives/misc.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/misc.py
index 63afc7556850..2907a559ee87 100644
--- a/python/helpers/docutils/parsers/rst/directives/misc.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/misc.py
@@ -6,15 +6,16 @@
__docformat__ = 'reStructuredText'
-import sys
import os.path
import re
import time
+
from docutils import io, nodes, statemachine, utils
from docutils.parsers.rst import Directive, convert_directive_function
from docutils.parsers.rst import directives, roles, states
from docutils.transforms import misc
+
class Include(Directive):
"""
diff --git a/python/helpers/docutils/parsers/rst/directives/parts.py b/python/helpers/py2only/docutils/parsers/rst/directives/parts.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/directives/parts.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/parts.py
index 425ddc714f19..b723049d48b4 100644
--- a/python/helpers/docutils/parsers/rst/directives/parts.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/parts.py
@@ -9,9 +9,9 @@ Directives for document parts.
__docformat__ = 'reStructuredText'
from docutils import nodes, languages
-from docutils.transforms import parts
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
+from docutils.transforms import parts
class Contents(Directive):
diff --git a/python/helpers/docutils/parsers/rst/directives/references.py b/python/helpers/py2only/docutils/parsers/rst/directives/references.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/directives/references.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/references.py
index b77f9c5ae800..e62dc534a270 100644
--- a/python/helpers/docutils/parsers/rst/directives/references.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/references.py
@@ -9,9 +9,9 @@ Directives for references and targets.
__docformat__ = 'reStructuredText'
from docutils import nodes
-from docutils.transforms import references
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
+from docutils.transforms import references
class TargetNotes(Directive):
diff --git a/python/helpers/docutils/parsers/rst/directives/tables.py b/python/helpers/py2only/docutils/parsers/rst/directives/tables.py
similarity index 99%
rename from python/helpers/docutils/parsers/rst/directives/tables.py
rename to python/helpers/py2only/docutils/parsers/rst/directives/tables.py
index a2242fda4674..35e71bdf2cc6 100644
--- a/python/helpers/docutils/parsers/rst/directives/tables.py
+++ b/python/helpers/py2only/docutils/parsers/rst/directives/tables.py
@@ -8,15 +8,14 @@ Directives for table elements.
__docformat__ = 'reStructuredText'
-
-import sys
-import os.path
import csv
+import os.path
+import sys
from docutils import io, nodes, statemachine, utils
-from docutils.utils import SystemMessagePropagation
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
+from docutils.utils import SystemMessagePropagation
class Table(Directive):
diff --git a/python/helpers/docutils/parsers/rst/include/README.txt b/python/helpers/py2only/docutils/parsers/rst/include/README.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/README.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/README.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isoamsa.txt b/python/helpers/py2only/docutils/parsers/rst/include/isoamsa.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isoamsa.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isoamsa.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isoamsb.txt b/python/helpers/py2only/docutils/parsers/rst/include/isoamsb.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isoamsb.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isoamsb.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isoamsc.txt b/python/helpers/py2only/docutils/parsers/rst/include/isoamsc.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isoamsc.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isoamsc.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isoamsn.txt b/python/helpers/py2only/docutils/parsers/rst/include/isoamsn.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isoamsn.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isoamsn.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isoamso.txt b/python/helpers/py2only/docutils/parsers/rst/include/isoamso.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isoamso.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isoamso.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isoamsr.txt b/python/helpers/py2only/docutils/parsers/rst/include/isoamsr.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isoamsr.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isoamsr.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isobox.txt b/python/helpers/py2only/docutils/parsers/rst/include/isobox.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isobox.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isobox.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isocyr1.txt b/python/helpers/py2only/docutils/parsers/rst/include/isocyr1.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isocyr1.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isocyr1.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isocyr2.txt b/python/helpers/py2only/docutils/parsers/rst/include/isocyr2.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isocyr2.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isocyr2.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isodia.txt b/python/helpers/py2only/docutils/parsers/rst/include/isodia.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isodia.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isodia.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isogrk1.txt b/python/helpers/py2only/docutils/parsers/rst/include/isogrk1.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isogrk1.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isogrk1.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isogrk2.txt b/python/helpers/py2only/docutils/parsers/rst/include/isogrk2.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isogrk2.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isogrk2.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isogrk3.txt b/python/helpers/py2only/docutils/parsers/rst/include/isogrk3.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isogrk3.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isogrk3.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isogrk4-wide.txt b/python/helpers/py2only/docutils/parsers/rst/include/isogrk4-wide.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isogrk4-wide.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isogrk4-wide.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isogrk4.txt b/python/helpers/py2only/docutils/parsers/rst/include/isogrk4.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isogrk4.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isogrk4.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isolat1.txt b/python/helpers/py2only/docutils/parsers/rst/include/isolat1.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isolat1.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isolat1.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isolat2.txt b/python/helpers/py2only/docutils/parsers/rst/include/isolat2.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isolat2.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isolat2.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isomfrk-wide.txt b/python/helpers/py2only/docutils/parsers/rst/include/isomfrk-wide.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isomfrk-wide.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isomfrk-wide.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isomfrk.txt b/python/helpers/py2only/docutils/parsers/rst/include/isomfrk.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isomfrk.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isomfrk.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isomopf-wide.txt b/python/helpers/py2only/docutils/parsers/rst/include/isomopf-wide.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isomopf-wide.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isomopf-wide.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isomopf.txt b/python/helpers/py2only/docutils/parsers/rst/include/isomopf.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isomopf.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isomopf.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isomscr-wide.txt b/python/helpers/py2only/docutils/parsers/rst/include/isomscr-wide.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isomscr-wide.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isomscr-wide.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isomscr.txt b/python/helpers/py2only/docutils/parsers/rst/include/isomscr.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isomscr.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isomscr.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isonum.txt b/python/helpers/py2only/docutils/parsers/rst/include/isonum.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isonum.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isonum.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isopub.txt b/python/helpers/py2only/docutils/parsers/rst/include/isopub.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isopub.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isopub.txt
diff --git a/python/helpers/docutils/parsers/rst/include/isotech.txt b/python/helpers/py2only/docutils/parsers/rst/include/isotech.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/isotech.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/isotech.txt
diff --git a/python/helpers/docutils/parsers/rst/include/mmlalias.txt b/python/helpers/py2only/docutils/parsers/rst/include/mmlalias.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/mmlalias.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/mmlalias.txt
diff --git a/python/helpers/docutils/parsers/rst/include/mmlextra-wide.txt b/python/helpers/py2only/docutils/parsers/rst/include/mmlextra-wide.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/mmlextra-wide.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/mmlextra-wide.txt
diff --git a/python/helpers/docutils/parsers/rst/include/mmlextra.txt b/python/helpers/py2only/docutils/parsers/rst/include/mmlextra.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/mmlextra.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/mmlextra.txt
diff --git a/python/helpers/docutils/parsers/rst/include/s5defs.txt b/python/helpers/py2only/docutils/parsers/rst/include/s5defs.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/s5defs.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/s5defs.txt
diff --git a/python/helpers/docutils/parsers/rst/include/xhtml1-lat1.txt b/python/helpers/py2only/docutils/parsers/rst/include/xhtml1-lat1.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/xhtml1-lat1.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/xhtml1-lat1.txt
diff --git a/python/helpers/docutils/parsers/rst/include/xhtml1-special.txt b/python/helpers/py2only/docutils/parsers/rst/include/xhtml1-special.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/xhtml1-special.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/xhtml1-special.txt
diff --git a/python/helpers/docutils/parsers/rst/include/xhtml1-symbol.txt b/python/helpers/py2only/docutils/parsers/rst/include/xhtml1-symbol.txt
similarity index 100%
rename from python/helpers/docutils/parsers/rst/include/xhtml1-symbol.txt
rename to python/helpers/py2only/docutils/parsers/rst/include/xhtml1-symbol.txt
diff --git a/python/helpers/docutils/parsers/rst/languages/__init__.py b/python/helpers/py2only/docutils/parsers/rst/languages/__init__.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/__init__.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/__init__.py
diff --git a/python/helpers/docutils/parsers/rst/languages/af.py b/python/helpers/py2only/docutils/parsers/rst/languages/af.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/af.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/af.py
diff --git a/python/helpers/docutils/parsers/rst/languages/ca.py b/python/helpers/py2only/docutils/parsers/rst/languages/ca.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/ca.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/ca.py
diff --git a/python/helpers/docutils/parsers/rst/languages/cs.py b/python/helpers/py2only/docutils/parsers/rst/languages/cs.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/cs.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/cs.py
diff --git a/python/helpers/docutils/parsers/rst/languages/de.py b/python/helpers/py2only/docutils/parsers/rst/languages/de.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/de.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/de.py
diff --git a/python/helpers/docutils/parsers/rst/languages/en.py b/python/helpers/py2only/docutils/parsers/rst/languages/en.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/en.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/en.py
diff --git a/python/helpers/docutils/parsers/rst/languages/eo.py b/python/helpers/py2only/docutils/parsers/rst/languages/eo.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/eo.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/eo.py
diff --git a/python/helpers/docutils/parsers/rst/languages/es.py b/python/helpers/py2only/docutils/parsers/rst/languages/es.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/es.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/es.py
diff --git a/python/helpers/docutils/parsers/rst/languages/fi.py b/python/helpers/py2only/docutils/parsers/rst/languages/fi.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/fi.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/fi.py
diff --git a/python/helpers/docutils/parsers/rst/languages/fr.py b/python/helpers/py2only/docutils/parsers/rst/languages/fr.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/fr.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/fr.py
diff --git a/python/helpers/docutils/parsers/rst/languages/gl.py b/python/helpers/py2only/docutils/parsers/rst/languages/gl.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/gl.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/gl.py
diff --git a/python/helpers/docutils/parsers/rst/languages/he.py b/python/helpers/py2only/docutils/parsers/rst/languages/he.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/he.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/he.py
diff --git a/python/helpers/docutils/parsers/rst/languages/it.py b/python/helpers/py2only/docutils/parsers/rst/languages/it.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/it.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/it.py
diff --git a/python/helpers/docutils/parsers/rst/languages/ja.py b/python/helpers/py2only/docutils/parsers/rst/languages/ja.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/ja.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/ja.py
diff --git a/python/helpers/docutils/parsers/rst/languages/nl.py b/python/helpers/py2only/docutils/parsers/rst/languages/nl.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/nl.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/nl.py
diff --git a/python/helpers/docutils/parsers/rst/languages/pl.py b/python/helpers/py2only/docutils/parsers/rst/languages/pl.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/pl.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/pl.py
diff --git a/python/helpers/docutils/parsers/rst/languages/pt_br.py b/python/helpers/py2only/docutils/parsers/rst/languages/pt_br.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/pt_br.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/pt_br.py
diff --git a/python/helpers/docutils/parsers/rst/languages/ru.py b/python/helpers/py2only/docutils/parsers/rst/languages/ru.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/ru.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/ru.py
diff --git a/python/helpers/docutils/parsers/rst/languages/sk.py b/python/helpers/py2only/docutils/parsers/rst/languages/sk.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/sk.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/sk.py
diff --git a/python/helpers/docutils/parsers/rst/languages/sv.py b/python/helpers/py2only/docutils/parsers/rst/languages/sv.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/sv.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/sv.py
diff --git a/python/helpers/docutils/parsers/rst/languages/zh_cn.py b/python/helpers/py2only/docutils/parsers/rst/languages/zh_cn.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/zh_cn.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/zh_cn.py
diff --git a/python/helpers/docutils/parsers/rst/languages/zh_tw.py b/python/helpers/py2only/docutils/parsers/rst/languages/zh_tw.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/languages/zh_tw.py
rename to python/helpers/py2only/docutils/parsers/rst/languages/zh_tw.py
diff --git a/python/helpers/docutils/parsers/rst/roles.py b/python/helpers/py2only/docutils/parsers/rst/roles.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/roles.py
rename to python/helpers/py2only/docutils/parsers/rst/roles.py
diff --git a/python/helpers/docutils/parsers/rst/states.py b/python/helpers/py2only/docutils/parsers/rst/states.py
similarity index 99%
rename from python/helpers/docutils/parsers/rst/states.py
rename to python/helpers/py2only/docutils/parsers/rst/states.py
index f3ad67939443..c88139c58428 100644
--- a/python/helpers/docutils/parsers/rst/states.py
+++ b/python/helpers/py2only/docutils/parsers/rst/states.py
@@ -102,20 +102,18 @@ Parsing proceeds as follows:
__docformat__ = 'reStructuredText'
-
-import sys
import re
-import roman
from types import FunctionType, MethodType
-from docutils import nodes, statemachine, utils, urischemes
+
+import docutils.parsers.rst
+import roman
from docutils import ApplicationError, DataError
-from docutils.statemachine import StateMachineWS, StateWS
+from docutils import nodes, statemachine, utils, urischemes
from docutils.nodes import fully_normalize_name as normalize_name
from docutils.nodes import whitespace_normalize_name
-from docutils.utils import escape2null, unescape, column_width
-import docutils.parsers.rst
from docutils.parsers.rst import directives, languages, tableparser, roles
-from docutils.parsers.rst.languages import en as _fallback_language_module
+from docutils.statemachine import StateMachineWS, StateWS
+from docutils.utils import escape2null, unescape, column_width
class MarkupError(DataError): pass
diff --git a/python/helpers/docutils/parsers/rst/tableparser.py b/python/helpers/py2only/docutils/parsers/rst/tableparser.py
similarity index 100%
rename from python/helpers/docutils/parsers/rst/tableparser.py
rename to python/helpers/py2only/docutils/parsers/rst/tableparser.py
index 5de124a55309..fafd467bdfb4 100644
--- a/python/helpers/docutils/parsers/rst/tableparser.py
+++ b/python/helpers/py2only/docutils/parsers/rst/tableparser.py
@@ -19,9 +19,9 @@ and produce a well-formed data structure suitable for building a CALS table.
__docformat__ = 'reStructuredText'
-
import re
import sys
+
from docutils import DataError
diff --git a/python/helpers/docutils/readers/__init__.py b/python/helpers/py2only/docutils/readers/__init__.py
similarity index 100%
rename from python/helpers/docutils/readers/__init__.py
rename to python/helpers/py2only/docutils/readers/__init__.py
diff --git a/python/helpers/docutils/readers/doctree.py b/python/helpers/py2only/docutils/readers/doctree.py
similarity index 100%
rename from python/helpers/docutils/readers/doctree.py
rename to python/helpers/py2only/docutils/readers/doctree.py
diff --git a/python/helpers/docutils/readers/pep.py b/python/helpers/py2only/docutils/readers/pep.py
similarity index 95%
rename from python/helpers/docutils/readers/pep.py
rename to python/helpers/py2only/docutils/readers/pep.py
index d6fed72e80ae..a66169bb9431 100644
--- a/python/helpers/docutils/readers/pep.py
+++ b/python/helpers/py2only/docutils/readers/pep.py
@@ -8,10 +8,9 @@ Python Enhancement Proposal (PEP) Reader.
__docformat__ = 'reStructuredText'
-
-from docutils.readers import standalone
-from docutils.transforms import peps, references, misc, frontmatter
from docutils.parsers import rst
+from docutils.readers import standalone
+from docutils.transforms import peps, frontmatter
class Reader(standalone.Reader):
diff --git a/python/helpers/docutils/readers/python/__init__.py b/python/helpers/py2only/docutils/readers/python/__init__.py
similarity index 99%
rename from python/helpers/docutils/readers/python/__init__.py
rename to python/helpers/py2only/docutils/readers/python/__init__.py
index f0461447b8f5..4718d87452cb 100644
--- a/python/helpers/docutils/readers/python/__init__.py
+++ b/python/helpers/py2only/docutils/readers/python/__init__.py
@@ -8,14 +8,12 @@ This package contains the Python Source Reader modules.
__docformat__ = 'reStructuredText'
-
-import sys
import docutils.readers
-from docutils.readers.python import moduleparser
-from docutils import parsers
from docutils import nodes
+from docutils import parsers
+from docutils.readers.python import moduleparser
from docutils.readers.python import pynodes
-from docutils import readers
+
class Reader(docutils.readers.Reader):
diff --git a/python/helpers/docutils/readers/python/moduleparser.py b/python/helpers/py2only/docutils/readers/python/moduleparser.py
similarity index 99%
rename from python/helpers/docutils/readers/python/moduleparser.py
rename to python/helpers/py2only/docutils/readers/python/moduleparser.py
index 182327273685..f0275c44b4b9 100644
--- a/python/helpers/docutils/readers/python/moduleparser.py
+++ b/python/helpers/py2only/docutils/readers/python/moduleparser.py
@@ -207,15 +207,14 @@ Issues
__docformat__ = 'reStructuredText'
-import sys
import compiler
import compiler.ast
-import tokenize
import token
-from compiler.consts import OP_ASSIGN
+import tokenize
from compiler.visitor import ASTVisitor
-from docutils.readers.python import pynodes
+
from docutils.nodes import Text
+from docutils.readers.python import pynodes
def parse_module(module_text, filename):
diff --git a/python/helpers/docutils/readers/python/pynodes.py b/python/helpers/py2only/docutils/readers/python/pynodes.py
similarity index 97%
rename from python/helpers/docutils/readers/python/pynodes.py
rename to python/helpers/py2only/docutils/readers/python/pynodes.py
index e90314dc230c..4b69be849187 100644
--- a/python/helpers/docutils/readers/python/pynodes.py
+++ b/python/helpers/py2only/docutils/readers/python/pynodes.py
@@ -3,11 +3,12 @@
# Author: David Goodger
# Copyright: This module has been placed in the public domain.
-from docutils import nodes
-from docutils.nodes import Element, TextElement, Structural, Inline, Part, \
- Text
import types
+from docutils import nodes
+from docutils.nodes import Element, TextElement, Structural
+
+
# This is the parent class of all the other pynode classes:
class PythonStructural(Structural): pass
diff --git a/python/helpers/docutils/readers/standalone.py b/python/helpers/py2only/docutils/readers/standalone.py
similarity index 99%
rename from python/helpers/docutils/readers/standalone.py
rename to python/helpers/py2only/docutils/readers/standalone.py
index 3c302ed346c6..27feef64f3f4 100644
--- a/python/helpers/docutils/readers/standalone.py
+++ b/python/helpers/py2only/docutils/readers/standalone.py
@@ -8,8 +8,6 @@ Standalone file Reader for the reStructuredText markup syntax.
__docformat__ = 'reStructuredText'
-
-import sys
from docutils import frontend, readers
from docutils.transforms import frontmatter, references, misc
diff --git a/python/helpers/docutils/statemachine.py b/python/helpers/py2only/docutils/statemachine.py
similarity index 100%
rename from python/helpers/docutils/statemachine.py
rename to python/helpers/py2only/docutils/statemachine.py
index aa9d2c00b38e..18d0592e5a66 100644
--- a/python/helpers/docutils/statemachine.py
+++ b/python/helpers/py2only/docutils/statemachine.py
@@ -106,8 +106,8 @@ How To Use This Module
__docformat__ = 'restructuredtext'
-import sys
import re
+import sys
import types
import unicodedata
diff --git a/python/helpers/docutils/transforms/__init__.py b/python/helpers/py2only/docutils/transforms/__init__.py
similarity index 100%
rename from python/helpers/docutils/transforms/__init__.py
rename to python/helpers/py2only/docutils/transforms/__init__.py
diff --git a/python/helpers/docutils/transforms/components.py b/python/helpers/py2only/docutils/transforms/components.py
similarity index 90%
rename from python/helpers/docutils/transforms/components.py
rename to python/helpers/py2only/docutils/transforms/components.py
index d3e548c4f205..c90d866a1bcc 100644
--- a/python/helpers/docutils/transforms/components.py
+++ b/python/helpers/py2only/docutils/transforms/components.py
@@ -8,13 +8,7 @@ Docutils component-related transforms.
__docformat__ = 'reStructuredText'
-import sys
-import os
-import re
-import time
-from docutils import nodes, utils
-from docutils import ApplicationError, DataError
-from docutils.transforms import Transform, TransformError
+from docutils.transforms import Transform
class Filter(Transform):
diff --git a/python/helpers/docutils/transforms/frontmatter.py b/python/helpers/py2only/docutils/transforms/frontmatter.py
similarity index 99%
rename from python/helpers/docutils/transforms/frontmatter.py
rename to python/helpers/py2only/docutils/transforms/frontmatter.py
index 63ae55d2b20b..c4617a3a6b78 100644
--- a/python/helpers/docutils/transforms/frontmatter.py
+++ b/python/helpers/py2only/docutils/transforms/frontmatter.py
@@ -22,6 +22,7 @@ Transforms related to the front matter of a document or a section
__docformat__ = 'reStructuredText'
import re
+
from docutils import nodes, utils
from docutils.transforms import TransformError, Transform
diff --git a/python/helpers/docutils/transforms/misc.py b/python/helpers/py2only/docutils/transforms/misc.py
similarity index 98%
rename from python/helpers/docutils/transforms/misc.py
rename to python/helpers/py2only/docutils/transforms/misc.py
index cd68ee150388..6caa703e06ee 100644
--- a/python/helpers/docutils/transforms/misc.py
+++ b/python/helpers/py2only/docutils/transforms/misc.py
@@ -9,7 +9,7 @@ Miscellaneous transforms.
__docformat__ = 'reStructuredText'
from docutils import nodes
-from docutils.transforms import Transform, TransformError
+from docutils.transforms import Transform
class CallBack(Transform):
diff --git a/python/helpers/docutils/transforms/parts.py b/python/helpers/py2only/docutils/transforms/parts.py
similarity index 98%
rename from python/helpers/docutils/transforms/parts.py
rename to python/helpers/py2only/docutils/transforms/parts.py
index ec6eda373e6b..913eabc8cf99 100644
--- a/python/helpers/docutils/transforms/parts.py
+++ b/python/helpers/py2only/docutils/transforms/parts.py
@@ -8,11 +8,10 @@ Transforms related to document parts.
__docformat__ = 'reStructuredText'
-
-import re
import sys
-from docutils import nodes, utils
-from docutils.transforms import TransformError, Transform
+
+from docutils import nodes
+from docutils.transforms import Transform
class SectNum(Transform):
diff --git a/python/helpers/docutils/transforms/peps.py b/python/helpers/py2only/docutils/transforms/peps.py
similarity index 98%
rename from python/helpers/docutils/transforms/peps.py
rename to python/helpers/py2only/docutils/transforms/peps.py
index b19248bbe9bc..504d09bf1884 100644
--- a/python/helpers/docutils/transforms/peps.py
+++ b/python/helpers/py2only/docutils/transforms/peps.py
@@ -13,13 +13,13 @@ Transforms for PEP processing.
__docformat__ = 'reStructuredText'
-import sys
import os
import re
import time
+
+from docutils import DataError
from docutils import nodes, utils, languages
-from docutils import ApplicationError, DataError
-from docutils.transforms import Transform, TransformError
+from docutils.transforms import Transform
from docutils.transforms import parts, references, misc
diff --git a/python/helpers/docutils/transforms/references.py b/python/helpers/py2only/docutils/transforms/references.py
similarity index 99%
rename from python/helpers/docutils/transforms/references.py
rename to python/helpers/py2only/docutils/transforms/references.py
index 4d8a716df985..ef235b3f99e6 100644
--- a/python/helpers/docutils/transforms/references.py
+++ b/python/helpers/py2only/docutils/transforms/references.py
@@ -8,10 +8,8 @@ Transforms for resolving references.
__docformat__ = 'reStructuredText'
-import sys
-import re
from docutils import nodes, utils
-from docutils.transforms import TransformError, Transform
+from docutils.transforms import Transform
class PropagateTargets(Transform):
diff --git a/python/helpers/docutils/transforms/universal.py b/python/helpers/py2only/docutils/transforms/universal.py
similarity index 98%
rename from python/helpers/docutils/transforms/universal.py
rename to python/helpers/py2only/docutils/transforms/universal.py
index 0e8f2c72cfee..02c8cc1c4e46 100644
--- a/python/helpers/docutils/transforms/universal.py
+++ b/python/helpers/py2only/docutils/transforms/universal.py
@@ -14,11 +14,10 @@ Transforms needed by most or all documents:
__docformat__ = 'reStructuredText'
-import re
-import sys
import time
+
from docutils import nodes, utils
-from docutils.transforms import TransformError, Transform
+from docutils.transforms import Transform
class Decorations(Transform):
diff --git a/python/helpers/docutils/transforms/writer_aux.py b/python/helpers/py2only/docutils/transforms/writer_aux.py
similarity index 98%
rename from python/helpers/docutils/transforms/writer_aux.py
rename to python/helpers/py2only/docutils/transforms/writer_aux.py
index 8045703d57ae..28e0d3a3b0a9 100644
--- a/python/helpers/docutils/transforms/writer_aux.py
+++ b/python/helpers/py2only/docutils/transforms/writer_aux.py
@@ -14,7 +14,7 @@ conflicting imports like this one::
__docformat__ = 'reStructuredText'
-from docutils import nodes, utils, languages
+from docutils import nodes, languages
from docutils.transforms import Transform
diff --git a/python/helpers/docutils/urischemes.py b/python/helpers/py2only/docutils/urischemes.py
similarity index 100%
rename from python/helpers/docutils/urischemes.py
rename to python/helpers/py2only/docutils/urischemes.py
diff --git a/python/helpers/docutils/utils.py b/python/helpers/py2only/docutils/utils.py
similarity index 99%
rename from python/helpers/docutils/utils.py
rename to python/helpers/py2only/docutils/utils.py
index e5443bd74617..dd0cc3fedccf 100644
--- a/python/helpers/docutils/utils.py
+++ b/python/helpers/py2only/docutils/utils.py
@@ -8,11 +8,12 @@ Miscellaneous utilities for the documentation utilities.
__docformat__ = 'reStructuredText'
-import sys
import os
import os.path
-import warnings
+import sys
import unicodedata
+import warnings
+
from docutils import ApplicationError, DataError
from docutils import nodes
from docutils._compat import bytes
diff --git a/python/helpers/docutils/writers/__init__.py b/python/helpers/py2only/docutils/writers/__init__.py
similarity index 99%
rename from python/helpers/docutils/writers/__init__.py
rename to python/helpers/py2only/docutils/writers/__init__.py
index cc80d844cac1..e1a89f4a1146 100644
--- a/python/helpers/docutils/writers/__init__.py
+++ b/python/helpers/py2only/docutils/writers/__init__.py
@@ -8,8 +8,6 @@ This package contains Docutils Writer modules.
__docformat__ = 'reStructuredText'
-
-import os.path
import docutils
from docutils import languages, Component
from docutils.transforms import universal
diff --git a/python/helpers/docutils/writers/docutils_xml.py b/python/helpers/py2only/docutils/writers/docutils_xml.py
similarity index 100%
rename from python/helpers/docutils/writers/docutils_xml.py
rename to python/helpers/py2only/docutils/writers/docutils_xml.py
diff --git a/python/helpers/docutils/writers/html4css1/__init__.py b/python/helpers/py2only/docutils/writers/html4css1/__init__.py
similarity index 99%
rename from python/helpers/docutils/writers/html4css1/__init__.py
rename to python/helpers/py2only/docutils/writers/html4css1/__init__.py
index c1fa360b7c11..3955f10ff4c5 100644
--- a/python/helpers/docutils/writers/html4css1/__init__.py
+++ b/python/helpers/py2only/docutils/writers/html4css1/__init__.py
@@ -13,11 +13,8 @@ for proper viewing with a modern graphical browser.
__docformat__ = 'reStructuredText'
-
-import sys
import os
import os.path
-import time
import re
try:
import Image # check for the Python Imaging Library
diff --git a/python/helpers/docutils/writers/html4css1/html4css1.css b/python/helpers/py2only/docutils/writers/html4css1/html4css1.css
similarity index 100%
rename from python/helpers/docutils/writers/html4css1/html4css1.css
rename to python/helpers/py2only/docutils/writers/html4css1/html4css1.css
diff --git a/python/helpers/docutils/writers/html4css1/template.txt b/python/helpers/py2only/docutils/writers/html4css1/template.txt
similarity index 100%
rename from python/helpers/docutils/writers/html4css1/template.txt
rename to python/helpers/py2only/docutils/writers/html4css1/template.txt
diff --git a/python/helpers/docutils/writers/latex2e/__init__.py b/python/helpers/py2only/docutils/writers/latex2e/__init__.py
similarity index 99%
rename from python/helpers/docutils/writers/latex2e/__init__.py
rename to python/helpers/py2only/docutils/writers/latex2e/__init__.py
index c8ef32ef6879..b6bd419007f6 100644
--- a/python/helpers/docutils/writers/latex2e/__init__.py
+++ b/python/helpers/py2only/docutils/writers/latex2e/__init__.py
@@ -12,11 +12,10 @@ __docformat__ = 'reStructuredText'
#
# convention deactivate code by two # i.e. ##.
-import sys
import os
-import time
import re
import string
+
from docutils import frontend, nodes, languages, writers, utils, io
from docutils.transforms import writer_aux
diff --git a/python/helpers/docutils/writers/latex2e/default.tex b/python/helpers/py2only/docutils/writers/latex2e/default.tex
similarity index 100%
rename from python/helpers/docutils/writers/latex2e/default.tex
rename to python/helpers/py2only/docutils/writers/latex2e/default.tex
diff --git a/python/helpers/docutils/writers/latex2e/docutils-05-compat.sty b/python/helpers/py2only/docutils/writers/latex2e/docutils-05-compat.sty
similarity index 100%
rename from python/helpers/docutils/writers/latex2e/docutils-05-compat.sty
rename to python/helpers/py2only/docutils/writers/latex2e/docutils-05-compat.sty
diff --git a/python/helpers/docutils/writers/latex2e/titlepage.tex b/python/helpers/py2only/docutils/writers/latex2e/titlepage.tex
similarity index 100%
rename from python/helpers/docutils/writers/latex2e/titlepage.tex
rename to python/helpers/py2only/docutils/writers/latex2e/titlepage.tex
diff --git a/python/helpers/docutils/writers/manpage.py b/python/helpers/py2only/docutils/writers/manpage.py
similarity index 99%
rename from python/helpers/docutils/writers/manpage.py
rename to python/helpers/py2only/docutils/writers/manpage.py
index e4e46b389219..d2085ea1dbeb 100644
--- a/python/helpers/docutils/writers/manpage.py
+++ b/python/helpers/py2only/docutils/writers/manpage.py
@@ -46,9 +46,8 @@ __docformat__ = 'reStructuredText'
import re
-import docutils
-from docutils import nodes, writers, languages
import roman
+from docutils import nodes, writers, languages
FIELD_LIST_INDENT = 7
DEFINITION_LIST_INDENT = 7
diff --git a/python/helpers/docutils/writers/newlatex2e/__init__.py b/python/helpers/py2only/docutils/writers/newlatex2e/__init__.py
similarity index 99%
rename from python/helpers/docutils/writers/newlatex2e/__init__.py
rename to python/helpers/py2only/docutils/writers/newlatex2e/__init__.py
index c04208df7fe0..e2274612f9bd 100644
--- a/python/helpers/docutils/writers/newlatex2e/__init__.py
+++ b/python/helpers/py2only/docutils/writers/newlatex2e/__init__.py
@@ -12,14 +12,13 @@ LaTeX2e document tree Writer.
__docformat__ = 'reStructuredText'
-
-import re
import os.path
+import re
import docutils
from docutils import nodes, writers, utils
-from docutils.writers.newlatex2e import unicode_map
from docutils.transforms import writer_aux
+from docutils.writers.newlatex2e import unicode_map
class Writer(writers.Writer):
diff --git a/python/helpers/docutils/writers/newlatex2e/base.tex b/python/helpers/py2only/docutils/writers/newlatex2e/base.tex
similarity index 100%
rename from python/helpers/docutils/writers/newlatex2e/base.tex
rename to python/helpers/py2only/docutils/writers/newlatex2e/base.tex
diff --git a/python/helpers/docutils/writers/newlatex2e/notes.txt b/python/helpers/py2only/docutils/writers/newlatex2e/notes.txt
similarity index 100%
rename from python/helpers/docutils/writers/newlatex2e/notes.txt
rename to python/helpers/py2only/docutils/writers/newlatex2e/notes.txt
diff --git a/python/helpers/docutils/writers/newlatex2e/tests.txt b/python/helpers/py2only/docutils/writers/newlatex2e/tests.txt
similarity index 100%
rename from python/helpers/docutils/writers/newlatex2e/tests.txt
rename to python/helpers/py2only/docutils/writers/newlatex2e/tests.txt
diff --git a/python/helpers/docutils/writers/newlatex2e/unicode_map.py b/python/helpers/py2only/docutils/writers/newlatex2e/unicode_map.py
similarity index 100%
rename from python/helpers/docutils/writers/newlatex2e/unicode_map.py
rename to python/helpers/py2only/docutils/writers/newlatex2e/unicode_map.py
diff --git a/python/helpers/docutils/writers/null.py b/python/helpers/py2only/docutils/writers/null.py
similarity index 100%
rename from python/helpers/docutils/writers/null.py
rename to python/helpers/py2only/docutils/writers/null.py
diff --git a/python/helpers/docutils/writers/odf_odt/__init__.py b/python/helpers/py2only/docutils/writers/odf_odt/__init__.py
similarity index 99%
rename from python/helpers/docutils/writers/odf_odt/__init__.py
rename to python/helpers/py2only/docutils/writers/odf_odt/__init__.py
index f7a41bf7ec7a..5b2d6c688868 100644
--- a/python/helpers/docutils/writers/odf_odt/__init__.py
+++ b/python/helpers/py2only/docutils/writers/odf_odt/__init__.py
@@ -11,26 +11,21 @@ VERSION = '1.0a'
__docformat__ = 'reStructuredText'
-
-import sys
+import StringIO
+import copy
import os
import os.path
+import re
import tempfile
+import time
import zipfile
from xml.dom import minidom
-import time
-import re
-import StringIO
-import inspect
-import imp
-import copy
+
import docutils
-from docutils import frontend, nodes, utils, writers, languages
-from docutils.parsers import rst
+from docutils import frontend, nodes, utils, writers
from docutils.readers import standalone
from docutils.transforms import references
-
WhichElementTree = ''
try:
# 1. Try to use lxml.
diff --git a/python/helpers/docutils/writers/odf_odt/pygmentsformatter.py b/python/helpers/py2only/docutils/writers/odf_odt/pygmentsformatter.py
similarity index 100%
rename from python/helpers/docutils/writers/odf_odt/pygmentsformatter.py
rename to python/helpers/py2only/docutils/writers/odf_odt/pygmentsformatter.py
diff --git a/python/helpers/docutils/writers/odf_odt/styles.odt b/python/helpers/py2only/docutils/writers/odf_odt/styles.odt
similarity index 100%
rename from python/helpers/docutils/writers/odf_odt/styles.odt
rename to python/helpers/py2only/docutils/writers/odf_odt/styles.odt
diff --git a/python/helpers/docutils/writers/pep_html/__init__.py b/python/helpers/py2only/docutils/writers/pep_html/__init__.py
similarity index 97%
rename from python/helpers/docutils/writers/pep_html/__init__.py
rename to python/helpers/py2only/docutils/writers/pep_html/__init__.py
index 503fa17bfe6f..e4776dbb2886 100644
--- a/python/helpers/docutils/writers/pep_html/__init__.py
+++ b/python/helpers/py2only/docutils/writers/pep_html/__init__.py
@@ -8,13 +8,10 @@ PEP HTML Writer.
__docformat__ = 'reStructuredText'
-
-import sys
import os
import os.path
-import codecs
-import docutils
-from docutils import frontend, nodes, utils, writers
+
+from docutils import frontend, nodes, utils
from docutils.writers import html4css1
diff --git a/python/helpers/docutils/writers/pep_html/pep.css b/python/helpers/py2only/docutils/writers/pep_html/pep.css
similarity index 100%
rename from python/helpers/docutils/writers/pep_html/pep.css
rename to python/helpers/py2only/docutils/writers/pep_html/pep.css
diff --git a/python/helpers/docutils/writers/pep_html/template.txt b/python/helpers/py2only/docutils/writers/pep_html/template.txt
similarity index 100%
rename from python/helpers/docutils/writers/pep_html/template.txt
rename to python/helpers/py2only/docutils/writers/pep_html/template.txt
diff --git a/python/helpers/docutils/writers/pseudoxml.py b/python/helpers/py2only/docutils/writers/pseudoxml.py
similarity index 100%
rename from python/helpers/docutils/writers/pseudoxml.py
rename to python/helpers/py2only/docutils/writers/pseudoxml.py
diff --git a/python/helpers/docutils/writers/s5_html/__init__.py b/python/helpers/py2only/docutils/writers/s5_html/__init__.py
similarity index 99%
rename from python/helpers/docutils/writers/s5_html/__init__.py
rename to python/helpers/py2only/docutils/writers/s5_html/__init__.py
index 12647bc78353..9e641f6e504e 100644
--- a/python/helpers/docutils/writers/s5_html/__init__.py
+++ b/python/helpers/py2only/docutils/writers/s5_html/__init__.py
@@ -9,15 +9,14 @@ S5/HTML Slideshow Writer.
__docformat__ = 'reStructuredText'
-
-import sys
import os
import re
+import sys
+
import docutils
from docutils import frontend, nodes, utils
-from docutils.writers import html4css1
-from docutils.parsers.rst import directives
from docutils._compat import b
+from docutils.writers import html4css1
themes_dir_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
diff --git a/python/helpers/docutils/writers/s5_html/themes/README.txt b/python/helpers/py2only/docutils/writers/s5_html/themes/README.txt
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/README.txt
rename to python/helpers/py2only/docutils/writers/s5_html/themes/README.txt
diff --git a/python/helpers/docutils/writers/s5_html/themes/big-black/__base__ b/python/helpers/py2only/docutils/writers/s5_html/themes/big-black/__base__
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/big-black/__base__
rename to python/helpers/py2only/docutils/writers/s5_html/themes/big-black/__base__
diff --git a/python/helpers/docutils/writers/s5_html/themes/big-black/framing.css b/python/helpers/py2only/docutils/writers/s5_html/themes/big-black/framing.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/big-black/framing.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/big-black/framing.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/big-black/pretty.css b/python/helpers/py2only/docutils/writers/s5_html/themes/big-black/pretty.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/big-black/pretty.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/big-black/pretty.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/big-white/framing.css b/python/helpers/py2only/docutils/writers/s5_html/themes/big-white/framing.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/big-white/framing.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/big-white/framing.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/big-white/pretty.css b/python/helpers/py2only/docutils/writers/s5_html/themes/big-white/pretty.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/big-white/pretty.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/big-white/pretty.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/blank.gif b/python/helpers/py2only/docutils/writers/s5_html/themes/default/blank.gif
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/blank.gif
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/blank.gif
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/framing.css b/python/helpers/py2only/docutils/writers/s5_html/themes/default/framing.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/framing.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/framing.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/iepngfix.htc b/python/helpers/py2only/docutils/writers/s5_html/themes/default/iepngfix.htc
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/iepngfix.htc
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/iepngfix.htc
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/opera.css b/python/helpers/py2only/docutils/writers/s5_html/themes/default/opera.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/opera.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/opera.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/outline.css b/python/helpers/py2only/docutils/writers/s5_html/themes/default/outline.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/outline.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/outline.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/pretty.css b/python/helpers/py2only/docutils/writers/s5_html/themes/default/pretty.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/pretty.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/pretty.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/print.css b/python/helpers/py2only/docutils/writers/s5_html/themes/default/print.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/print.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/print.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/s5-core.css b/python/helpers/py2only/docutils/writers/s5_html/themes/default/s5-core.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/s5-core.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/s5-core.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/slides.css b/python/helpers/py2only/docutils/writers/s5_html/themes/default/slides.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/default/slides.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/slides.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/default/slides.js b/python/helpers/py2only/docutils/writers/s5_html/themes/default/slides.js
similarity index 99%
rename from python/helpers/docutils/writers/s5_html/themes/default/slides.js
rename to python/helpers/py2only/docutils/writers/s5_html/themes/default/slides.js
index 81e04e5d442f..2ebbbd8e3e7a 100644
--- a/python/helpers/docutils/writers/s5_html/themes/default/slides.js
+++ b/python/helpers/py2only/docutils/writers/s5_html/themes/default/slides.js
@@ -8,7 +8,7 @@ var undef;
var slideCSS = '';
var snum = 0;
var smax = 1;
-var slideIDs = new Array();
+var slideIDs = [];
var incpos = 0;
var number = undef;
var s5mode = true;
@@ -45,7 +45,7 @@ function addClass(object,className) {
function GetElementsWithClassName(elementName,className) {
var allElements = document.getElementsByTagName(elementName);
- var elemColl = new Array();
+ var elemColl = [];
for (var i = 0; i< allElements.length; i++) {
if (hasClass(allElements[i], className)) {
elemColl[elemColl.length] = allElements[i];
@@ -465,7 +465,7 @@ function notOperaFix() {
}
function getIncrementals(obj) {
- var incrementals = new Array();
+ var incrementals = [];
if (!obj)
return incrementals;
var children = obj.childNodes;
@@ -500,7 +500,7 @@ function getIncrementals(obj) {
}
function createIncrementals() {
- var incrementals = new Array();
+ var incrementals = [];
for (var i = 0; i < smax; i++) {
incrementals[i] = getIncrementals(document.getElementById(slideIDs[i]));
}
diff --git a/python/helpers/docutils/writers/s5_html/themes/medium-black/__base__ b/python/helpers/py2only/docutils/writers/s5_html/themes/medium-black/__base__
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/medium-black/__base__
rename to python/helpers/py2only/docutils/writers/s5_html/themes/medium-black/__base__
diff --git a/python/helpers/docutils/writers/s5_html/themes/medium-black/pretty.css b/python/helpers/py2only/docutils/writers/s5_html/themes/medium-black/pretty.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/medium-black/pretty.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/medium-black/pretty.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/medium-white/framing.css b/python/helpers/py2only/docutils/writers/s5_html/themes/medium-white/framing.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/medium-white/framing.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/medium-white/framing.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/medium-white/pretty.css b/python/helpers/py2only/docutils/writers/s5_html/themes/medium-white/pretty.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/medium-white/pretty.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/medium-white/pretty.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/small-black/__base__ b/python/helpers/py2only/docutils/writers/s5_html/themes/small-black/__base__
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/small-black/__base__
rename to python/helpers/py2only/docutils/writers/s5_html/themes/small-black/__base__
diff --git a/python/helpers/docutils/writers/s5_html/themes/small-black/pretty.css b/python/helpers/py2only/docutils/writers/s5_html/themes/small-black/pretty.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/small-black/pretty.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/small-black/pretty.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/small-white/framing.css b/python/helpers/py2only/docutils/writers/s5_html/themes/small-white/framing.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/small-white/framing.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/small-white/framing.css
diff --git a/python/helpers/docutils/writers/s5_html/themes/small-white/pretty.css b/python/helpers/py2only/docutils/writers/s5_html/themes/small-white/pretty.css
similarity index 100%
rename from python/helpers/docutils/writers/s5_html/themes/small-white/pretty.css
rename to python/helpers/py2only/docutils/writers/s5_html/themes/small-white/pretty.css
diff --git a/python/helpers/py3only/docutils/__init__.py b/python/helpers/py3only/docutils/__init__.py
new file mode 100644
index 000000000000..0bcc6a4af264
--- /dev/null
+++ b/python/helpers/py3only/docutils/__init__.py
@@ -0,0 +1,217 @@
+# $Id: __init__.py 7756 2014-07-06 11:48:05Z grubert $
+# Author: David Goodger
+# Copyright: This module has been placed in the public domain.
+
+"""
+This is the Docutils (Python Documentation Utilities) package.
+
+Package Structure
+=================
+
+Modules:
+
+- __init__.py: Contains component base classes, exception classes, and
+ Docutils version information.
+
+- core.py: Contains the ``Publisher`` class and ``publish_*()`` convenience
+ functions.
+
+- frontend.py: Runtime settings (command-line interface, configuration files)
+ processing, for Docutils front-ends.
+
+- io.py: Provides a uniform API for low-level input and output.
+
+- nodes.py: Docutils document tree (doctree) node class library.
+
+- statemachine.py: A finite state machine specialized for
+ regular-expression-based text filters.
+
+Subpackages:
+
+- languages: Language-specific mappings of terms.
+
+- parsers: Syntax-specific input parser modules or packages.
+
+- readers: Context-specific input handlers which understand the data
+ source and manage a parser.
+
+- transforms: Modules used by readers and writers to modify DPS
+ doctrees.
+
+- utils: Contains the ``Reporter`` system warning class and miscellaneous
+ utilities used by readers, writers, and transforms.
+
+ utils/urischemes.py: Contains a complete mapping of known URI addressing
+ scheme names to descriptions.
+
+- utils/math: Contains functions for conversion of mathematical notation
+ between different formats (LaTeX, MathML, text, ...).
+
+- writers: Format-specific output translators.
+"""
+
+__docformat__ = 'reStructuredText'
+
+__version__ = '0.12'
+"""``major.minor.micro`` version number. The micro number is bumped for API
+changes, for new functionality, and for interim project releases. The minor
+number is bumped whenever there is a significant project release. The major
+number will be bumped when the project is feature-complete, and perhaps if
+there is a major change in the design."""
+
+__version_details__ = 'release'
+"""Extra version details (e.g. 'snapshot 2005-05-29, r3410', 'repository',
+'release'), modified automatically & manually."""
+
+import sys
+
+class ApplicationError(Exception):
+ # Workaround:
+ # In Python < 2.6, unicode() calls `str` on the
+ # arg and therefore, e.g., unicode(StandardError(u'\u234')) fails
+ # with UnicodeDecodeError.
+ if sys.version_info < (2,6):
+ def __unicode__(self):
+ return ', '.join(self.args)
+
+class DataError(ApplicationError): pass
+
+
+class SettingsSpec:
+
+ """
+ Runtime setting specification base class.
+
+ SettingsSpec subclass objects used by `docutils.frontend.OptionParser`.
+ """
+
+ settings_spec = ()
+ """Runtime settings specification. Override in subclasses.
+
+ Defines runtime settings and associated command-line options, as used by
+ `docutils.frontend.OptionParser`. This is a tuple of:
+
+ - Option group title (string or `None` which implies no group, just a list
+ of single options).
+
+ - Description (string or `None`).
+
+ - A sequence of option tuples. Each consists of:
+
+ - Help text (string)
+
+ - List of option strings (e.g. ``['-Q', '--quux']``).
+
+ - Dictionary of keyword arguments sent to the OptionParser/OptionGroup
+ ``add_option`` method.
+
+ Runtime setting names are derived implicitly from long option names
+ ('--a-setting' becomes ``settings.a_setting``) or explicitly from the
+ 'dest' keyword argument.
+
+ Most settings will also have a 'validator' keyword & function. The
+ validator function validates setting values (from configuration files
+ and command-line option arguments) and converts them to appropriate
+ types. For example, the ``docutils.frontend.validate_boolean``
+ function, **required by all boolean settings**, converts true values
+ ('1', 'on', 'yes', and 'true') to 1 and false values ('0', 'off',
+ 'no', 'false', and '') to 0. Validators need only be set once per
+ setting. See the `docutils.frontend.validate_*` functions.
+
+ See the optparse docs for more details.
+
+ - More triples of group title, description, options, as many times as
+ needed. Thus, `settings_spec` tuples can be simply concatenated.
+ """
+
+ settings_defaults = None
+ """A dictionary of defaults for settings not in `settings_spec` (internal
+ settings, intended to be inaccessible by command-line and config file).
+ Override in subclasses."""
+
+ settings_default_overrides = None
+ """A dictionary of auxiliary defaults, to override defaults for settings
+ defined in other components. Override in subclasses."""
+
+ relative_path_settings = ()
+ """Settings containing filesystem paths. Override in subclasses.
+ Settings listed here are to be interpreted relative to the current working
+ directory."""
+
+ config_section = None
+ """The name of the config file section specific to this component
+ (lowercase, no brackets). Override in subclasses."""
+
+ config_section_dependencies = None
+ """A list of names of config file sections that are to be applied before
+ `config_section`, in order (from general to specific). In other words,
+ the settings in `config_section` are to be overlaid on top of the settings
+ from these sections. The "general" section is assumed implicitly.
+ Override in subclasses."""
+
+
+class TransformSpec:
+
+ """
+ Runtime transform specification base class.
+
+ TransformSpec subclass objects used by `docutils.transforms.Transformer`.
+ """
+
+ def get_transforms(self):
+ """Transforms required by this class. Override in subclasses."""
+ if self.default_transforms != ():
+ import warnings
+ warnings.warn('default_transforms attribute deprecated.\n'
+ 'Use get_transforms() method instead.',
+ DeprecationWarning)
+ return list(self.default_transforms)
+ return []
+
+ # Deprecated; for compatibility.
+ default_transforms = ()
+
+ unknown_reference_resolvers = ()
+ """List of functions to try to resolve unknown references. Unknown
+ references have a 'refname' attribute which doesn't correspond to any
+ target in the document. Called when the transforms in
+ `docutils.tranforms.references` are unable to find a correct target. The
+ list should contain functions which will try to resolve unknown
+ references, with the following signature::
+
+ def reference_resolver(node):
+ '''Returns boolean: true if resolved, false if not.'''
+
+ If the function is able to resolve the reference, it should also remove
+ the 'refname' attribute and mark the node as resolved::
+
+ del node['refname']
+ node.resolved = 1
+
+ Each function must have a "priority" attribute which will affect the order
+ the unknown_reference_resolvers are run::
+
+ reference_resolver.priority = 100
+
+ Override in subclasses."""
+
+
+class Component(SettingsSpec, TransformSpec):
+
+ """Base class for Docutils components."""
+
+ component_type = None
+ """Name of the component type ('reader', 'parser', 'writer'). Override in
+ subclasses."""
+
+ supported = ()
+ """Names for this component. Override in subclasses."""
+
+ def supports(self, format):
+ """
+ Is `format` supported by this component?
+
+ To be used by transforms to ask the dependent component if it supports
+ a certain input context or output format.
+ """
+ return format in self.supported
diff --git a/python/helpers/py3only/docutils/_compat.py b/python/helpers/py3only/docutils/_compat.py
new file mode 100644
index 000000000000..3c942816debf
--- /dev/null
+++ b/python/helpers/py3only/docutils/_compat.py
@@ -0,0 +1,47 @@
+# $Id: _compat.py 7486 2012-07-11 12:25:14Z milde $
+# Author: Georg Brandl
+# Copyright: This module has been placed in the public domain.
+
+"""
+Python 2/3 compatibility definitions.
+
+This module currently provides the following helper symbols:
+
+* bytes (name of byte string type; str in 2.x, bytes in 3.x)
+* b (function converting a string literal to an ASCII byte string;
+ can be also used to convert a Unicode string into a byte string)
+* u_prefix (unicode repr prefix: 'u' in 2.x, '' in 3.x)
+ (Required in docutils/test/test_publisher.py)
+* BytesIO (a StringIO class that works with bytestrings)
+"""
+
+import sys
+
+if sys.version_info < (3,0):
+ b = bytes = str
+ u_prefix = 'u'
+else:
+ import builtins
+ bytes = builtins.bytes
+ u_prefix = ''
+ def b(s):
+ if isinstance(s, str):
+ return s.encode('latin1')
+ elif isinstance(s, bytes):
+ return s
+ else:
+ raise TypeError("Invalid argument %r for b()" % (s,))
+ # using this hack since 2to3 "fixes" the relative import
+ # when using ``from io import BytesIO``
+ BytesIO = __import__('io').BytesIO
+
+if sys.version_info < (2,5):
+ import builtins
+
+ def __import__(name, globals={}, locals={}, fromlist=[], level=-1):
+ """Compatibility definition for Python 2.4.
+
+ Silently ignore the `level` argument missing in Python < 2.5.
+ """
+ # we need the level arg because the default changed in Python 3.3
+ return builtins.__import__(name, globals, locals, fromlist)
diff --git a/python/helpers/py3only/docutils/core.py b/python/helpers/py3only/docutils/core.py
new file mode 100644
index 000000000000..ac26350c12fa
--- /dev/null
+++ b/python/helpers/py3only/docutils/core.py
@@ -0,0 +1,664 @@
+# $Id: core.py 7466 2012-06-25 14:56:51Z milde $
+# Author: David Goodger
+# Copyright: This module has been placed in the public domain.
+
+"""
+Calling the ``publish_*`` convenience functions (or instantiating a
+`Publisher` object) with component names will result in default
+behavior. For custom behavior (setting component options), create
+custom component objects first, and pass *them* to
+``publish_*``/`Publisher`. See `The Docutils Publisher`_.
+
+.. _The Docutils Publisher: http://docutils.sf.net/docs/api/publisher.html
+"""
+
+__docformat__ = 'reStructuredText'
+
+import pprint
+import sys
+
+import docutils.readers.doctree
+from docutils import __version__, __version_details__, SettingsSpec
+from docutils import frontend, io, utils, readers, writers
+from docutils.frontend import OptionParser
+from docutils.utils.error_reporting import ErrorOutput, ErrorString
+
+
+class Publisher:
+
+ """
+ A facade encapsulating the high-level logic of a Docutils system.
+ """
+
+ def __init__(self, reader=None, parser=None, writer=None,
+ source=None, source_class=io.FileInput,
+ destination=None, destination_class=io.FileOutput,
+ settings=None):
+ """
+ Initial setup. If any of `reader`, `parser`, or `writer` are not
+ specified, the corresponding ``set_...`` method should be called with
+ a component name (`set_reader` sets the parser as well).
+ """
+
+ self.document = None
+ """The document tree (`docutils.nodes` objects)."""
+
+ self.reader = reader
+ """A `docutils.readers.Reader` instance."""
+
+ self.parser = parser
+ """A `docutils.parsers.Parser` instance."""
+
+ self.writer = writer
+ """A `docutils.writers.Writer` instance."""
+
+ for component in 'reader', 'parser', 'writer':
+ assert not isinstance(getattr(self, component), str), (
+ 'passed string "%s" as "%s" parameter; pass an instance, '
+ 'or use the "%s_name" parameter instead (in '
+ 'docutils.core.publish_* convenience functions).'
+ % (getattr(self, component), component, component))
+
+ self.source = source
+ """The source of input data, a `docutils.io.Input` instance."""
+
+ self.source_class = source_class
+ """The class for dynamically created source objects."""
+
+ self.destination = destination
+ """The destination for docutils output, a `docutils.io.Output`
+ instance."""
+
+ self.destination_class = destination_class
+ """The class for dynamically created destination objects."""
+
+ self.settings = settings
+ """An object containing Docutils settings as instance attributes.
+ Set by `self.process_command_line()` or `self.get_settings()`."""
+
+ self._stderr = ErrorOutput()
+
+ def set_reader(self, reader_name, parser, parser_name):
+ """Set `self.reader` by name."""
+ reader_class = readers.get_reader_class(reader_name)
+ self.reader = reader_class(parser, parser_name)
+ self.parser = self.reader.parser
+
+ def set_writer(self, writer_name):
+ """Set `self.writer` by name."""
+ writer_class = writers.get_writer_class(writer_name)
+ self.writer = writer_class()
+
+ def set_components(self, reader_name, parser_name, writer_name):
+ if self.reader is None:
+ self.set_reader(reader_name, self.parser, parser_name)
+ if self.parser is None:
+ if self.reader.parser is None:
+ self.reader.set_parser(parser_name)
+ self.parser = self.reader.parser
+ if self.writer is None:
+ self.set_writer(writer_name)
+
+ def setup_option_parser(self, usage=None, description=None,
+ settings_spec=None, config_section=None,
+ **defaults):
+ if config_section:
+ if not settings_spec:
+ settings_spec = SettingsSpec()
+ settings_spec.config_section = config_section
+ parts = config_section.split()
+ if len(parts) > 1 and parts[-1] == 'application':
+ settings_spec.config_section_dependencies = ['applications']
+ #@@@ Add self.source & self.destination to components in future?
+ option_parser = OptionParser(
+ components=(self.parser, self.reader, self.writer, settings_spec),
+ defaults=defaults, read_config_files=True,
+ usage=usage, description=description)
+ return option_parser
+
+ def get_settings(self, usage=None, description=None,
+ settings_spec=None, config_section=None, **defaults):
+ """
+ Set and return default settings (overrides in `defaults` dict).
+
+ Set components first (`self.set_reader` & `self.set_writer`).
+ Explicitly setting `self.settings` disables command line option
+ processing from `self.publish()`.
+ """
+ option_parser = self.setup_option_parser(
+ usage, description, settings_spec, config_section, **defaults)
+ self.settings = option_parser.get_default_values()
+ return self.settings
+
+ def process_programmatic_settings(self, settings_spec,
+ settings_overrides,
+ config_section):
+ if self.settings is None:
+ defaults = (settings_overrides or {}).copy()
+ # Propagate exceptions by default when used programmatically:
+ defaults.setdefault('traceback', True)
+ self.get_settings(settings_spec=settings_spec,
+ config_section=config_section,
+ **defaults)
+
+ def process_command_line(self, argv=None, usage=None, description=None,
+ settings_spec=None, config_section=None,
+ **defaults):
+ """
+ Pass an empty list to `argv` to avoid reading `sys.argv` (the
+ default).
+
+ Set components first (`self.set_reader` & `self.set_writer`).
+ """
+ option_parser = self.setup_option_parser(
+ usage, description, settings_spec, config_section, **defaults)
+ if argv is None:
+ argv = sys.argv[1:]
+ # converting to Unicode (Python 3 does this automatically):
+ if sys.version_info < (3,0):
+ # TODO: make this failsafe and reversible?
+ argv_encoding = (frontend.locale_encoding or 'ascii')
+ argv = [a.decode(argv_encoding) for a in argv]
+ self.settings = option_parser.parse_args(argv)
+
+ def set_io(self, source_path=None, destination_path=None):
+ if self.source is None:
+ self.set_source(source_path=source_path)
+ if self.destination is None:
+ self.set_destination(destination_path=destination_path)
+
+ def set_source(self, source=None, source_path=None):
+ if source_path is None:
+ source_path = self.settings._source
+ else:
+ self.settings._source = source_path
+ # Raise IOError instead of system exit with `tracback == True`
+ # TODO: change io.FileInput's default behaviour and remove this hack
+ try:
+ self.source = self.source_class(
+ source=source, source_path=source_path,
+ encoding=self.settings.input_encoding)
+ except TypeError:
+ self.source = self.source_class(
+ source=source, source_path=source_path,
+ encoding=self.settings.input_encoding)
+
+ def set_destination(self, destination=None, destination_path=None):
+ if destination_path is None:
+ destination_path = self.settings._destination
+ else:
+ self.settings._destination = destination_path
+ self.destination = self.destination_class(
+ destination=destination, destination_path=destination_path,
+ encoding=self.settings.output_encoding,
+ error_handler=self.settings.output_encoding_error_handler)
+
+ def apply_transforms(self):
+ self.document.transformer.populate_from_components(
+ (self.source, self.reader, self.reader.parser, self.writer,
+ self.destination))
+ self.document.transformer.apply_transforms()
+
+ def publish(self, argv=None, usage=None, description=None,
+ settings_spec=None, settings_overrides=None,
+ config_section=None, enable_exit_status=False):
+ """
+ Process command line options and arguments (if `self.settings` not
+ already set), run `self.reader` and then `self.writer`. Return
+ `self.writer`'s output.
+ """
+ exit = None
+ try:
+ if self.settings is None:
+ self.process_command_line(
+ argv, usage, description, settings_spec, config_section,
+ **(settings_overrides or {}))
+ self.set_io()
+ self.document = self.reader.read(self.source, self.parser,
+ self.settings)
+ self.apply_transforms()
+ output = self.writer.write(self.document, self.destination)
+ self.writer.assemble_parts()
+ except SystemExit as error:
+ exit = 1
+ exit_status = error.code
+ except Exception as error:
+ if not self.settings: # exception too early to report nicely
+ raise
+ if self.settings.traceback: # Propagate exceptions?
+ self.debugging_dumps()
+ raise
+ self.report_Exception(error)
+ exit = True
+ exit_status = 1
+ self.debugging_dumps()
+ if (enable_exit_status and self.document
+ and (self.document.reporter.max_level
+ >= self.settings.exit_status_level)):
+ sys.exit(self.document.reporter.max_level + 10)
+ elif exit:
+ sys.exit(exit_status)
+ return output
+
+ def debugging_dumps(self):
+ if not self.document:
+ return
+ if self.settings.dump_settings:
+ print('\n::: Runtime settings:', file=self._stderr)
+ print(pprint.pformat(self.settings.__dict__), file=self._stderr)
+ if self.settings.dump_internals:
+ print('\n::: Document internals:', file=self._stderr)
+ print(pprint.pformat(self.document.__dict__), file=self._stderr)
+ if self.settings.dump_transforms:
+ print('\n::: Transforms applied:', file=self._stderr)
+ print((' (priority, transform class, '
+ 'pending node details, keyword args)'), file=self._stderr)
+ print(pprint.pformat(
+ [(priority, '%s.%s' % (xclass.__module__, xclass.__name__),
+ pending and pending.details, kwargs)
+ for priority, xclass, pending, kwargs
+ in self.document.transformer.applied]), file=self._stderr)
+ if self.settings.dump_pseudo_xml:
+ print('\n::: Pseudo-XML:', file=self._stderr)
+ print(self.document.pformat().encode(
+ 'raw_unicode_escape'), file=self._stderr)
+
+ def report_Exception(self, error):
+ if isinstance(error, utils.SystemMessage):
+ self.report_SystemMessage(error)
+ elif isinstance(error, UnicodeEncodeError):
+ self.report_UnicodeError(error)
+ elif isinstance(error, io.InputError):
+ self._stderr.write('Unable to open source file for reading:\n'
+ ' %s\n' % ErrorString(error))
+ elif isinstance(error, io.OutputError):
+ self._stderr.write(
+ 'Unable to open destination file for writing:\n'
+ ' %s\n' % ErrorString(error))
+ else:
+ print('%s' % ErrorString(error), file=self._stderr)
+ print(("""\
+Exiting due to error. Use "--traceback" to diagnose.
+Please report errors to .
+Include "--traceback" output, Docutils version (%s [%s]),
+Python version (%s), your OS type & version, and the
+command line used.""" % (__version__, __version_details__,
+ sys.version.split()[0])), file=self._stderr)
+
+ def report_SystemMessage(self, error):
+ print(('Exiting due to level-%s (%s) system message.'
+ % (error.level,
+ utils.Reporter.levels[error.level])), file=self._stderr)
+
+ def report_UnicodeError(self, error):
+ data = error.object[error.start:error.end]
+ self._stderr.write(
+ '%s\n'
+ '\n'
+ 'The specified output encoding (%s) cannot\n'
+ 'handle all of the output.\n'
+ 'Try setting "--output-encoding-error-handler" to\n'
+ '\n'
+ '* "xmlcharrefreplace" (for HTML & XML output);\n'
+ ' the output will contain "%s" and should be usable.\n'
+ '* "backslashreplace" (for other output formats);\n'
+ ' look for "%s" in the output.\n'
+ '* "replace"; look for "?" in the output.\n'
+ '\n'
+ '"--output-encoding-error-handler" is currently set to "%s".\n'
+ '\n'
+ 'Exiting due to error. Use "--traceback" to diagnose.\n'
+ 'If the advice above doesn\'t eliminate the error,\n'
+ 'please report it to .\n'
+ 'Include "--traceback" output, Docutils version (%s),\n'
+ 'Python version (%s), your OS type & version, and the\n'
+ 'command line used.\n'
+ % (ErrorString(error),
+ self.settings.output_encoding,
+ data.encode('ascii', 'xmlcharrefreplace'),
+ data.encode('ascii', 'backslashreplace'),
+ self.settings.output_encoding_error_handler,
+ __version__, sys.version.split()[0]))
+
+default_usage = '%prog [options] [ []]'
+default_description = ('Reads from (default is stdin) and writes to '
+ ' (default is stdout). See '
+ ' for '
+ 'the full reference.')
+
+def publish_cmdline(reader=None, reader_name='standalone',
+ parser=None, parser_name='restructuredtext',
+ writer=None, writer_name='pseudoxml',
+ settings=None, settings_spec=None,
+ settings_overrides=None, config_section=None,
+ enable_exit_status=True, argv=None,
+ usage=default_usage, description=default_description):
+ """
+ Set up & run a `Publisher` for command-line-based file I/O (input and
+ output file paths taken automatically from the command line). Return the
+ encoded string output also.
+
+ Parameters: see `publish_programmatically` for the remainder.
+
+ - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
+ - `usage`: Usage string, output if there's a problem parsing the command
+ line.
+ - `description`: Program description, output for the "--help" option
+ (along with command-line option descriptions).
+ """
+ pub = Publisher(reader, parser, writer, settings=settings)
+ pub.set_components(reader_name, parser_name, writer_name)
+ output = pub.publish(
+ argv, usage, description, settings_spec, settings_overrides,
+ config_section=config_section, enable_exit_status=enable_exit_status)
+ return output
+
+def publish_file(source=None, source_path=None,
+ destination=None, destination_path=None,
+ reader=None, reader_name='standalone',
+ parser=None, parser_name='restructuredtext',
+ writer=None, writer_name='pseudoxml',
+ settings=None, settings_spec=None, settings_overrides=None,
+ config_section=None, enable_exit_status=False):
+ """
+ Set up & run a `Publisher` for programmatic use with file-like I/O.
+ Return the encoded string output also.
+
+ Parameters: see `publish_programmatically`.
+ """
+ output, pub = publish_programmatically(
+ source_class=io.FileInput, source=source, source_path=source_path,
+ destination_class=io.FileOutput,
+ destination=destination, destination_path=destination_path,
+ reader=reader, reader_name=reader_name,
+ parser=parser, parser_name=parser_name,
+ writer=writer, writer_name=writer_name,
+ settings=settings, settings_spec=settings_spec,
+ settings_overrides=settings_overrides,
+ config_section=config_section,
+ enable_exit_status=enable_exit_status)
+ return output
+
+def publish_string(source, source_path=None, destination_path=None,
+ reader=None, reader_name='standalone',
+ parser=None, parser_name='restructuredtext',
+ writer=None, writer_name='pseudoxml',
+ settings=None, settings_spec=None,
+ settings_overrides=None, config_section=None,
+ enable_exit_status=False):
+ """
+ Set up & run a `Publisher` for programmatic use with string I/O. Return
+ the encoded string or Unicode string output.
+
+ For encoded string output, be sure to set the 'output_encoding' setting to
+ the desired encoding. Set it to 'unicode' for unencoded Unicode string
+ output. Here's one way::
+
+ publish_string(..., settings_overrides={'output_encoding': 'unicode'})
+
+ Similarly for Unicode string input (`source`)::
+
+ publish_string(..., settings_overrides={'input_encoding': 'unicode'})
+
+ Parameters: see `publish_programmatically`.
+ """
+ output, pub = publish_programmatically(
+ source_class=io.StringInput, source=source, source_path=source_path,
+ destination_class=io.StringOutput,
+ destination=None, destination_path=destination_path,
+ reader=reader, reader_name=reader_name,
+ parser=parser, parser_name=parser_name,
+ writer=writer, writer_name=writer_name,
+ settings=settings, settings_spec=settings_spec,
+ settings_overrides=settings_overrides,
+ config_section=config_section,
+ enable_exit_status=enable_exit_status)
+ return output
+
+def publish_parts(source, source_path=None, source_class=io.StringInput,
+ destination_path=None,
+ reader=None, reader_name='standalone',
+ parser=None, parser_name='restructuredtext',
+ writer=None, writer_name='pseudoxml',
+ settings=None, settings_spec=None,
+ settings_overrides=None, config_section=None,
+ enable_exit_status=False):
+ """
+ Set up & run a `Publisher`, and return a dictionary of document parts.
+ Dictionary keys are the names of parts, and values are Unicode strings;
+ encoding is up to the client. For programmatic use with string I/O.
+
+ For encoded string input, be sure to set the 'input_encoding' setting to
+ the desired encoding. Set it to 'unicode' for unencoded Unicode string
+ input. Here's how::
+
+ publish_parts(..., settings_overrides={'input_encoding': 'unicode'})
+
+ Parameters: see `publish_programmatically`.
+ """
+ output, pub = publish_programmatically(
+ source=source, source_path=source_path, source_class=source_class,
+ destination_class=io.StringOutput,
+ destination=None, destination_path=destination_path,
+ reader=reader, reader_name=reader_name,
+ parser=parser, parser_name=parser_name,
+ writer=writer, writer_name=writer_name,
+ settings=settings, settings_spec=settings_spec,
+ settings_overrides=settings_overrides,
+ config_section=config_section,
+ enable_exit_status=enable_exit_status)
+ return pub.writer.parts
+
+def publish_doctree(source, source_path=None,
+ source_class=io.StringInput,
+ reader=None, reader_name='standalone',
+ parser=None, parser_name='restructuredtext',
+ settings=None, settings_spec=None,
+ settings_overrides=None, config_section=None,
+ enable_exit_status=False):
+ """
+ Set up & run a `Publisher` for programmatic use with string I/O.
+ Return the document tree.
+
+ For encoded string input, be sure to set the 'input_encoding' setting to
+ the desired encoding. Set it to 'unicode' for unencoded Unicode string
+ input. Here's one way::
+
+ publish_doctree(..., settings_overrides={'input_encoding': 'unicode'})
+
+ Parameters: see `publish_programmatically`.
+ """
+ pub = Publisher(reader=reader, parser=parser, writer=None,
+ settings=settings,
+ source_class=source_class,
+ destination_class=io.NullOutput)
+ pub.set_components(reader_name, parser_name, 'null')
+ pub.process_programmatic_settings(
+ settings_spec, settings_overrides, config_section)
+ pub.set_source(source, source_path)
+ pub.set_destination(None, None)
+ output = pub.publish(enable_exit_status=enable_exit_status)
+ return pub.document
+
+def publish_from_doctree(document, destination_path=None,
+ writer=None, writer_name='pseudoxml',
+ settings=None, settings_spec=None,
+ settings_overrides=None, config_section=None,
+ enable_exit_status=False):
+ """
+ Set up & run a `Publisher` to render from an existing document
+ tree data structure, for programmatic use with string I/O. Return
+ the encoded string output.
+
+ Note that document.settings is overridden; if you want to use the settings
+ of the original `document`, pass settings=document.settings.
+
+ Also, new document.transformer and document.reporter objects are
+ generated.
+
+ For encoded string output, be sure to set the 'output_encoding' setting to
+ the desired encoding. Set it to 'unicode' for unencoded Unicode string
+ output. Here's one way::
+
+ publish_from_doctree(
+ ..., settings_overrides={'output_encoding': 'unicode'})
+
+ Parameters: `document` is a `docutils.nodes.document` object, an existing
+ document tree.
+
+ Other parameters: see `publish_programmatically`.
+ """
+ reader = docutils.readers.doctree.Reader(parser_name='null')
+ pub = Publisher(reader, None, writer,
+ source=io.DocTreeInput(document),
+ destination_class=io.StringOutput, settings=settings)
+ if not writer and writer_name:
+ pub.set_writer(writer_name)
+ pub.process_programmatic_settings(
+ settings_spec, settings_overrides, config_section)
+ pub.set_destination(None, destination_path)
+ return pub.publish(enable_exit_status=enable_exit_status)
+
+def publish_cmdline_to_binary(reader=None, reader_name='standalone',
+ parser=None, parser_name='restructuredtext',
+ writer=None, writer_name='pseudoxml',
+ settings=None, settings_spec=None,
+ settings_overrides=None, config_section=None,
+ enable_exit_status=True, argv=None,
+ usage=default_usage, description=default_description,
+ destination=None, destination_class=io.BinaryFileOutput
+ ):
+ """
+ Set up & run a `Publisher` for command-line-based file I/O (input and
+ output file paths taken automatically from the command line). Return the
+ encoded string output also.
+
+ This is just like publish_cmdline, except that it uses
+ io.BinaryFileOutput instead of io.FileOutput.
+
+ Parameters: see `publish_programmatically` for the remainder.
+
+ - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
+ - `usage`: Usage string, output if there's a problem parsing the command
+ line.
+ - `description`: Program description, output for the "--help" option
+ (along with command-line option descriptions).
+ """
+ pub = Publisher(reader, parser, writer, settings=settings,
+ destination_class=destination_class)
+ pub.set_components(reader_name, parser_name, writer_name)
+ output = pub.publish(
+ argv, usage, description, settings_spec, settings_overrides,
+ config_section=config_section, enable_exit_status=enable_exit_status)
+ return output
+
+def publish_programmatically(source_class, source, source_path,
+ destination_class, destination, destination_path,
+ reader, reader_name,
+ parser, parser_name,
+ writer, writer_name,
+ settings, settings_spec,
+ settings_overrides, config_section,
+ enable_exit_status):
+ """
+ Set up & run a `Publisher` for custom programmatic use. Return the
+ encoded string output and the Publisher object.
+
+ Applications should not need to call this function directly. If it does
+ seem to be necessary to call this function directly, please write to the
+ Docutils-develop mailing list
+ .
+
+ Parameters:
+
+ * `source_class` **required**: The class for dynamically created source
+ objects. Typically `io.FileInput` or `io.StringInput`.
+
+ * `source`: Type depends on `source_class`:
+
+ - If `source_class` is `io.FileInput`: Either a file-like object
+ (must have 'read' and 'close' methods), or ``None``
+ (`source_path` is opened). If neither `source` nor
+ `source_path` are supplied, `sys.stdin` is used.
+
+ - If `source_class` is `io.StringInput` **required**: The input
+ string, either an encoded 8-bit string (set the
+ 'input_encoding' setting to the correct encoding) or a Unicode
+ string (set the 'input_encoding' setting to 'unicode').
+
+ * `source_path`: Type depends on `source_class`:
+
+ - `io.FileInput`: Path to the input file, opened if no `source`
+ supplied.
+
+ - `io.StringInput`: Optional. Path to the file or object that produced
+ `source`. Only used for diagnostic output.
+
+ * `destination_class` **required**: The class for dynamically created
+ destination objects. Typically `io.FileOutput` or `io.StringOutput`.
+
+ * `destination`: Type depends on `destination_class`:
+
+ - `io.FileOutput`: Either a file-like object (must have 'write' and
+ 'close' methods), or ``None`` (`destination_path` is opened). If
+ neither `destination` nor `destination_path` are supplied,
+ `sys.stdout` is used.
+
+ - `io.StringOutput`: Not used; pass ``None``.
+
+ * `destination_path`: Type depends on `destination_class`:
+
+ - `io.FileOutput`: Path to the output file. Opened if no `destination`
+ supplied.
+
+ - `io.StringOutput`: Path to the file or object which will receive the
+ output; optional. Used for determining relative paths (stylesheets,
+ source links, etc.).
+
+ * `reader`: A `docutils.readers.Reader` object.
+
+ * `reader_name`: Name or alias of the Reader class to be instantiated if
+ no `reader` supplied.
+
+ * `parser`: A `docutils.parsers.Parser` object.
+
+ * `parser_name`: Name or alias of the Parser class to be instantiated if
+ no `parser` supplied.
+
+ * `writer`: A `docutils.writers.Writer` object.
+
+ * `writer_name`: Name or alias of the Writer class to be instantiated if
+ no `writer` supplied.
+
+ * `settings`: A runtime settings (`docutils.frontend.Values`) object, for
+ dotted-attribute access to runtime settings. It's the end result of the
+ `SettingsSpec`, config file, and option processing. If `settings` is
+ passed, it's assumed to be complete and no further setting/config/option
+ processing is done.
+
+ * `settings_spec`: A `docutils.SettingsSpec` subclass or object. Provides
+ extra application-specific settings definitions independently of
+ components. In other words, the application becomes a component, and
+ its settings data is processed along with that of the other components.
+ Used only if no `settings` specified.
+
+ * `settings_overrides`: A dictionary containing application-specific
+ settings defaults that override the defaults of other components.
+ Used only if no `settings` specified.
+
+ * `config_section`: A string, the name of the configuration file section
+ for this application. Overrides the ``config_section`` attribute
+ defined by `settings_spec`. Used only if no `settings` specified.
+
+ * `enable_exit_status`: Boolean; enable exit status at end of processing?
+ """
+ pub = Publisher(reader, parser, writer, settings=settings,
+ source_class=source_class,
+ destination_class=destination_class)
+ pub.set_components(reader_name, parser_name, writer_name)
+ pub.process_programmatic_settings(
+ settings_spec, settings_overrides, config_section)
+ pub.set_source(source, source_path)
+ pub.set_destination(destination, destination_path)
+ output = pub.publish(enable_exit_status=enable_exit_status)
+ return output, pub
diff --git a/python/helpers/py3only/docutils/examples.py b/python/helpers/py3only/docutils/examples.py
new file mode 100644
index 000000000000..395dbbf14fc2
--- /dev/null
+++ b/python/helpers/py3only/docutils/examples.py
@@ -0,0 +1,97 @@
+# $Id: examples.py 7320 2012-01-19 22:33:02Z milde $
+# Author: David Goodger
+# Copyright: This module has been placed in the public domain.
+
+"""
+This module contains practical examples of Docutils client code.
+
+Importing this module from client code is not recommended; its contents are
+subject to change in future Docutils releases. Instead, it is recommended
+that you copy and paste the parts you need into your own code, modifying as
+necessary.
+"""
+
+from docutils import core, io
+
+
+def html_parts(input_string, source_path=None, destination_path=None,
+ input_encoding='unicode', doctitle=True,
+ initial_header_level=1):
+ """
+ Given an input string, returns a dictionary of HTML document parts.
+
+ Dictionary keys are the names of parts, and values are Unicode strings;
+ encoding is up to the client.
+
+ Parameters:
+
+ - `input_string`: A multi-line text string; required.
+ - `source_path`: Path to the source file or object. Optional, but useful
+ for diagnostic output (system messages).
+ - `destination_path`: Path to the file or object which will receive the
+ output; optional. Used for determining relative paths (stylesheets,
+ source links, etc.).
+ - `input_encoding`: The encoding of `input_string`. If it is an encoded
+ 8-bit string, provide the correct encoding. If it is a Unicode string,
+ use "unicode", the default.
+ - `doctitle`: Disable the promotion of a lone top-level section title to
+ document title (and subsequent section title to document subtitle
+ promotion); enabled by default.
+ - `initial_header_level`: The initial level for header elements (e.g. 1
+ for "
").
+ """
+ overrides = {'input_encoding': input_encoding,
+ 'doctitle_xform': doctitle,
+ 'initial_header_level': initial_header_level}
+ parts = core.publish_parts(
+ source=input_string, source_path=source_path,
+ destination_path=destination_path,
+ writer_name='html', settings_overrides=overrides)
+ return parts
+
+def html_body(input_string, source_path=None, destination_path=None,
+ input_encoding='unicode', output_encoding='unicode',
+ doctitle=True, initial_header_level=1):
+ """
+ Given an input string, returns an HTML fragment as a string.
+
+ The return value is the contents of the element.
+
+ Parameters (see `html_parts()` for the remainder):
+
+ - `output_encoding`: The desired encoding of the output. If a Unicode
+ string is desired, use the default value of "unicode" .
+ """
+ parts = html_parts(
+ input_string=input_string, source_path=source_path,
+ destination_path=destination_path,
+ input_encoding=input_encoding, doctitle=doctitle,
+ initial_header_level=initial_header_level)
+ fragment = parts['html_body']
+ if output_encoding != 'unicode':
+ fragment = fragment.encode(output_encoding)
+ return fragment
+
+def internals(input_string, source_path=None, destination_path=None,
+ input_encoding='unicode', settings_overrides=None):
+ """
+ Return the document tree and publisher, for exploring Docutils internals.
+
+ Parameters: see `html_parts()`.
+ """
+ if settings_overrides:
+ overrides = settings_overrides.copy()
+ else:
+ overrides = {}
+ overrides['input_encoding'] = input_encoding
+ output, pub = core.publish_programmatically(
+ source_class=io.StringInput, source=input_string,
+ source_path=source_path,
+ destination_class=io.NullOutput, destination=None,
+ destination_path=destination_path,
+ reader=None, reader_name='standalone',
+ parser=None, parser_name='restructuredtext',
+ writer=None, writer_name='null',
+ settings=None, settings_spec=None, settings_overrides=overrides,
+ config_section=None, enable_exit_status=None)
+ return pub.writer.document, pub
diff --git a/python/helpers/py3only/docutils/frontend.py b/python/helpers/py3only/docutils/frontend.py
new file mode 100644
index 000000000000..0fdfa639a382
--- /dev/null
+++ b/python/helpers/py3only/docutils/frontend.py
@@ -0,0 +1,818 @@
+# $Id: frontend.py 7584 2013-01-01 20:00:21Z milde $
+# Author: David Goodger
+# Copyright: This module has been placed in the public domain.
+
+"""
+Command-line and common processing for Docutils front-end tools.
+
+Exports the following classes:
+
+* `OptionParser`: Standard Docutils command-line processing.
+* `Option`: Customized version of `optparse.Option`; validation support.
+* `Values`: Runtime settings; objects are simple structs
+ (``object.attribute``). Supports cumulative list settings (attributes).
+* `ConfigParser`: Standard Docutils config file processing.
+
+Also exports the following functions:
+
+* Option callbacks: `store_multiple`, `read_config_file`.
+* Setting validators: `validate_encoding`,
+ `validate_encoding_error_handler`,
+ `validate_encoding_and_error_handler`,
+ `validate_boolean`, `validate_ternary`, `validate_threshold`,
+ `validate_colon_separated_string_list`,
+ `validate_comma_separated_string_list`,
+ `validate_dependency_file`.
+* `make_paths_absolute`.
+* SettingSpec manipulation: `filter_settings_spec`.
+"""
+
+__docformat__ = 'reStructuredText'
+
+import codecs
+import optparse
+import os
+import os.path
+import sys
+import warnings
+from optparse import SUPPRESS_HELP
+
+import configparser as CP
+
+import docutils
+import docutils.nodes
+import docutils.utils
+from docutils.utils.error_reporting import locale_encoding, ErrorOutput, ErrorString
+
+
+def store_multiple(option, opt, value, parser, *args, **kwargs):
+ """
+ Store multiple values in `parser.values`. (Option callback.)
+
+ Store `None` for each attribute named in `args`, and store the value for
+ each key (attribute name) in `kwargs`.
+ """
+ for attribute in args:
+ setattr(parser.values, attribute, None)
+ for key, value in list(kwargs.items()):
+ setattr(parser.values, key, value)
+
+def read_config_file(option, opt, value, parser):
+ """
+ Read a configuration file during option processing. (Option callback.)
+ """
+ try:
+ new_settings = parser.get_config_file_settings(value)
+ except ValueError as error:
+ parser.error(error)
+ parser.values.update(new_settings, parser)
+
+def validate_encoding(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ try:
+ codecs.lookup(value)
+ except LookupError:
+ raise LookupError('setting "%s": unknown encoding: "%s"'
+ % (setting, value))
+ return value
+
+def validate_encoding_error_handler(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ try:
+ codecs.lookup_error(value)
+ except LookupError:
+ raise LookupError(
+ 'unknown encoding error handler: "%s" (choices: '
+ '"strict", "ignore", "replace", "backslashreplace", '
+ '"xmlcharrefreplace", and possibly others; see documentation for '
+ 'the Python ``codecs`` module)' % value)
+ return value
+
+def validate_encoding_and_error_handler(
+ setting, value, option_parser, config_parser=None, config_section=None):
+ """
+ Side-effect: if an error handler is included in the value, it is inserted
+ into the appropriate place as if it was a separate setting/option.
+ """
+ if ':' in value:
+ encoding, handler = value.split(':')
+ validate_encoding_error_handler(
+ setting + '_error_handler', handler, option_parser,
+ config_parser, config_section)
+ if config_parser:
+ config_parser.set(config_section, setting + '_error_handler',
+ handler)
+ else:
+ setattr(option_parser.values, setting + '_error_handler', handler)
+ else:
+ encoding = value
+ validate_encoding(setting, encoding, option_parser,
+ config_parser, config_section)
+ return encoding
+
+def validate_boolean(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ """Check/normalize boolean settings:
+ True: '1', 'on', 'yes', 'true'
+ False: '0', 'off', 'no','false', ''
+ """
+ if isinstance(value, bool):
+ return value
+ try:
+ return option_parser.booleans[value.strip().lower()]
+ except KeyError:
+ raise LookupError('unknown boolean value: "%s"' % value)
+
+def validate_ternary(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ """Check/normalize three-value settings:
+ True: '1', 'on', 'yes', 'true'
+ False: '0', 'off', 'no','false', ''
+ any other value: returned as-is.
+ """
+ if isinstance(value, bool) or value is None:
+ return value
+ try:
+ return option_parser.booleans[value.strip().lower()]
+ except KeyError:
+ return value
+
+def validate_nonnegative_int(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ value = int(value)
+ if value < 0:
+ raise ValueError('negative value; must be positive or zero')
+ return value
+
+def validate_threshold(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ try:
+ return int(value)
+ except ValueError:
+ try:
+ return option_parser.thresholds[value.lower()]
+ except (KeyError, AttributeError):
+ raise LookupError('unknown threshold: %r.' % value)
+
+def validate_colon_separated_string_list(
+ setting, value, option_parser, config_parser=None, config_section=None):
+ if not isinstance(value, list):
+ value = value.split(':')
+ else:
+ last = value.pop()
+ value.extend(last.split(':'))
+ return value
+
+def validate_comma_separated_list(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ """Check/normalize list arguments (split at "," and strip whitespace).
+ """
+ # `value` is already a ``list`` when given as command line option
+ # and "action" is "append" and ``unicode`` or ``str`` else.
+ if not isinstance(value, list):
+ value = [value]
+ # this function is called for every option added to `value`
+ # -> split the last item and append the result:
+ last = value.pop()
+ items = [i.strip(' \t\n') for i in last.split(',') if i.strip(' \t\n')]
+ value.extend(items)
+ return value
+
+def validate_url_trailing_slash(
+ setting, value, option_parser, config_parser=None, config_section=None):
+ if not value:
+ return './'
+ elif value.endswith('/'):
+ return value
+ else:
+ return value + '/'
+
+def validate_dependency_file(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ try:
+ return docutils.utils.DependencyList(value)
+ except IOError:
+ return docutils.utils.DependencyList(None)
+
+def validate_strip_class(setting, value, option_parser,
+ config_parser=None, config_section=None):
+ # value is a comma separated string list:
+ value = validate_comma_separated_list(setting, value, option_parser,
+ config_parser, config_section)
+ # validate list elements:
+ for cls in value:
+ normalized = docutils.nodes.make_id(cls)
+ if cls != normalized:
+ raise ValueError('invalid class value %r (perhaps %r?)'
+ % (cls, normalized))
+ return value
+
+def make_paths_absolute(pathdict, keys, base_path=None):
+ """
+ Interpret filesystem path settings relative to the `base_path` given.
+
+ Paths are values in `pathdict` whose keys are in `keys`. Get `keys` from
+ `OptionParser.relative_path_settings`.
+ """
+ if base_path is None:
+ base_path = os.getcwd() # type(base_path) == unicode
+ # to allow combining non-ASCII cwd with unicode values in `pathdict`
+ for key in keys:
+ if key in pathdict:
+ value = pathdict[key]
+ if isinstance(value, list):
+ value = [make_one_path_absolute(base_path, path)
+ for path in value]
+ elif value:
+ value = make_one_path_absolute(base_path, value)
+ pathdict[key] = value
+
+def make_one_path_absolute(base_path, path):
+ return os.path.abspath(os.path.join(base_path, path))
+
+def filter_settings_spec(settings_spec, *exclude, **replace):
+ """Return a copy of `settings_spec` excluding/replacing some settings.
+
+ `settings_spec` is a tuple of configuration settings with a structure
+ described for docutils.SettingsSpec.settings_spec.
+
+ Optional positional arguments are names of to-be-excluded settings.
+ Keyword arguments are option specification replacements.
+ (See the html4strict writer for an example.)
+ """
+ settings = list(settings_spec)
+ # every third item is a sequence of option tuples
+ for i in range(2, len(settings), 3):
+ newopts = []
+ for opt_spec in settings[i]:
+ # opt_spec is ("", [