Skip to content

Commit

Permalink
Massive code reformat with IntelliJ IDEA
Browse files Browse the repository at this point in the history
- Some small manual intervention to clear the ‘boolean expression could
be simplified’ errors, a misordered ‘static private’ access modifier,
some misplaced semicolons, overenthusiastic removal of blank lines, and
missing newlines at end of file.
- Unfortunately it applies the continuation indent setting equally to
method invocations which have the ending ) at the same level, as to
those which don’t, so it looks a little weird on the @org.python.Method
annotations.
- Disable two more checkstyle rules
  - EmptyBlock: there are a few finally blocks that just contain a
  commented out debug statement.
  - HideUtilityClassConstructor: it thinks org.Python is a utility class
  which ought to have a different access modifier.
  • Loading branch information
cflee committed Mar 8, 2017
1 parent 31449de commit 3df1353
Show file tree
Hide file tree
Showing 124 changed files with 3,047 additions and 3,180 deletions.
9 changes: 6 additions & 3 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="Indentation">
<property name="lineWrappingIndentation" value="8"/>
</module>

<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
Expand All @@ -136,7 +139,7 @@
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<!--<module name="EmptyBlock"/>-->
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
Expand All @@ -158,7 +161,7 @@
<!-- See http://checkstyle.sf.net/config_design.html -->
<!-- <module name="DesignForExtension"/> -->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<!--<module name="HideUtilityClassConstructor"/>-->
<module name="InterfaceIsType"/>
<!-- <module name="VisibilityModifier"/> -->

Expand All @@ -171,4 +174,4 @@

</module>

</module>
</module>
1 change: 0 additions & 1 deletion python/android/python/platform/AndroidPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.os.Debug;


public class AndroidPlatform implements python.Platform {
private org.python.stdlib._io.TextIOWrapper _stderr;
private org.python.stdlib._io.TextIOWrapper _stdout;
Expand Down
3 changes: 1 addition & 2 deletions python/android/python/platform/LogStream.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package python.platform;


public class LogStream extends java.io.OutputStream {
protected java.lang.String tag;
protected byte[] buf;
Expand All @@ -27,4 +26,4 @@ public void write(int b) {
count = 0;
}
}
}
}
1,066 changes: 533 additions & 533 deletions python/common/org/Python.java

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions python/common/org/python/Callable.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.python;


public interface Callable {
public org.python.Object invoke(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs);
public org.python.Object invoke(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs);
}
2 changes: 1 addition & 1 deletion python/common/org/python/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
public @interface Class {
java.lang.String __doc__() default "";
java.lang.String __doc__() default "";
}
26 changes: 13 additions & 13 deletions python/common/org/python/ImportLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static org.python.types.Module __import__(
java.lang.String python_name,
java.util.Map<java.lang.String, org.python.Object> globals,
java.util.Map<java.lang.String, org.python.Object> locals,
java.lang.String [] from_list,
java.lang.String[] from_list,
int level) {
// Create an array containing the module path.
// org.Python.debug("Import from " + python_name + " level " + level);
Expand All @@ -22,11 +22,11 @@ public static org.python.types.Module __import__(
// org.Python.debug("locals = " + locals);
boolean native_import;

java.lang.String [] path;
java.lang.String[] path;
if (level == 0) {
path = python_name.split("\\.");
} else {
java.lang.String [] context = ((java.lang.String) globals.get("__name__").toJava()).split("\\.");
java.lang.String[] context = ((java.lang.String) globals.get("__name__").toJava()).split("\\.");
// org.Python.debug("context");
// for (java.lang.String s: context) {
// org.Python.debug(" " + s);
Expand All @@ -43,18 +43,18 @@ public static org.python.types.Module __import__(
}

if (python_name != null) {
java.lang.String [] import_path = python_name.split("\\.");
java.lang.String[] import_path = python_name.split("\\.");
// org.Python.debug("import_path");
// for (java.lang.String s: import_path) {
// org.Python.debug(" " + s);
// }

path = new java.lang.String [import_path.length + context_length];
path = new java.lang.String[import_path.length + context_length];

System.arraycopy(context, 0, path, 0, context_length);
System.arraycopy(import_path, 0, path, context_length, import_path.length);
} else {
path = new java.lang.String [context.length - level];
path = new java.lang.String[context.length - level];
System.arraycopy(context, 0, path, 0, context.length - level);
}
}
Expand Down Expand Up @@ -88,7 +88,7 @@ public static org.python.types.Module __import__(
} else {
// If the package name isn't clearly identifiable as a java package path,
// put it in the python namespace.
if ( path[0].equals("java")
if (path[0].equals("java")
|| path[0].equals("javax")
|| path[0].equals("org")
|| path[0].equals("com")
Expand All @@ -102,7 +102,7 @@ public static org.python.types.Module __import__(

// Iterate down the full dotted path, making sure that each module
// along the way has been imported.
for (java.lang.String name: path) {
for (java.lang.String name : path) {
if (import_name.length() > 0) {
import_name.append(".");
}
Expand Down Expand Up @@ -130,7 +130,6 @@ public static org.python.types.Module __import__(
// org.Python.debug("handle NATIVE IMPORT as fallback", mod_name);
python_module = importNativeModule(mod_name);
}

}
} catch (java.lang.ClassNotFoundException e) {
throw new org.python.exceptions.ImportError("No module named '" + python_name + "'");
Expand Down Expand Up @@ -162,7 +161,7 @@ public static org.python.types.Module __import__(
// unless the symbol is *, in which case we know it exists.
return_module = python_module;
import_name.append(".");
for (java.lang.String name: from_list) {
for (java.lang.String name : from_list) {
// org.Python.debug("IMPORT NAME", name);
if (!name.equals("*")) {
java.lang.String mod_name = import_name.toString() + name;
Expand Down Expand Up @@ -275,7 +274,7 @@ public static java.util.Map importAll(org.python.types.Module module) {
java.util.Map<java.lang.String, org.python.Object> exports = new java.util.HashMap<java.lang.String, org.python.Object>();
org.python.Object all_obj = module.__getattribute_null("__all__");
if (all_obj == null) {
for (java.lang.String name: module.__dict__.keySet()) {
for (java.lang.String name : module.__dict__.keySet()) {
if (!name.startsWith("_")) {
exports.put(name, module.__dict__.get(name));
}
Expand All @@ -287,8 +286,9 @@ public static java.util.Map importAll(org.python.types.Module module) {
java.lang.String name = ((org.python.types.Str) iter.__next__()).value;
exports.put(name, module.__dict__.get(name));
}
} catch (org.python.exceptions.StopIteration e) {}
} catch (org.python.exceptions.StopIteration e) {
}
}
return exports;
}
}
}
2 changes: 0 additions & 2 deletions python/common/org/python/Iterable.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.python;


public interface Iterable {
public org.python.Iterable __iter__();

public org.python.Object __next__();
}
6 changes: 3 additions & 3 deletions python/common/org/python/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
public @interface Method {
java.lang.String name() default "";
java.lang.String __doc__() default "";
java.lang.String [] args() default {};
java.lang.String[] args() default {};
java.lang.String varargs() default "";
java.lang.String [] default_args() default {};
java.lang.String [] kwonlyargs() default {};
java.lang.String[] default_args() default {};
java.lang.String[] kwonlyargs() default {};
java.lang.String kwargs() default "";
}
1 change: 0 additions & 1 deletion python/common/org/python/Object.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.python;


public interface Object extends Comparable {
/**
* Return a Java object that is the underlying data representation
Expand Down
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/ArithmeticError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public ArithmeticError(String msg) {
super(msg);
}

public ArithmeticError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public ArithmeticError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/AssertionError.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public AssertionError(org.python.Object msg) {
super(msg.toString());
}

public AssertionError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public AssertionError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
3 changes: 1 addition & 2 deletions python/common/org/python/exceptions/AttributeError.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.python.exceptions;


public class AttributeError extends org.python.exceptions.Exception {
public AttributeError(java.lang.String msg) {
super(msg);
Expand All @@ -14,7 +13,7 @@ public AttributeError(java.lang.Class klass, java.lang.String attr) {
super("'" + org.python.types.Type.pythonType(klass).typeName() + "' object has no attribute '" + attr + "'");
}

public AttributeError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public AttributeError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super("'" + args[0] + "' object has no attribute '" + args[1] + "'");
}
}
9 changes: 4 additions & 5 deletions python/common/org/python/exceptions/BaseException.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.python.exceptions;

@org.python.Class(
__doc__ = "Common base class for all exceptions"
__doc__ = "Common base class for all exceptions"
)
public class BaseException extends org.python.types.Object {

public BaseException() {
super();
// System.out.println("EX: " + this);
Expand All @@ -15,19 +14,19 @@ public BaseException(String msg) {
// System.out.println("EX: " + this);
}

public BaseException(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public BaseException(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args[0].toString());
}

@org.python.Method(
__doc__ = "Return repr(self)."
__doc__ = "Return repr(self)."
)
public org.python.Object __repr__() {
return new org.python.types.Str(this.getClass().getSimpleName() + "(\"" + this.getMessage() + "\",)");
}

@org.python.Method(
__doc__ = "Return str(self)."
__doc__ = "Return str(self)."
)
public org.python.Object __str__() {
return new org.python.types.Str(this.getMessage());
Expand Down
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/BlockingIOError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public BlockingIOError(String msg) {
super(msg);
}

public BlockingIOError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public BlockingIOError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/BrokenPipeError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public BrokenPipeError(String msg) {
super(msg);
}

public BrokenPipeError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public BrokenPipeError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/BufferError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public BufferError(String msg) {
super(msg);
}

public BufferError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public BufferError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/BytesWarning.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public BytesWarning(String msg) {
super(msg);
}

public BytesWarning(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public BytesWarning(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/ChildProcessError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public ChildProcessError(String msg) {
super(msg);
}

public ChildProcessError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public ChildProcessError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public ConnectionAbortedError(String msg) {
super(msg);
}

public ConnectionAbortedError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public ConnectionAbortedError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/ConnectionError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public ConnectionError(String msg) {
super(msg);
}

public ConnectionError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public ConnectionError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public ConnectionRefusedError(String msg) {
super(msg);
}

public ConnectionRefusedError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public ConnectionRefusedError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public ConnectionResetError(String msg) {
super(msg);
}

public ConnectionResetError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public ConnectionResetError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public DeprecationWarning(String msg) {
super(msg);
}

public DeprecationWarning(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public DeprecationWarning(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/EOFError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public EOFError(String msg) {
super(msg);
}

public EOFError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public EOFError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/Exception.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public Exception(java.lang.String msg) {
super(msg);
}

public Exception(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public Exception(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/FileExistsError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public FileExistsError(String msg) {
super(msg);
}

public FileExistsError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public FileExistsError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
2 changes: 1 addition & 1 deletion python/common/org/python/exceptions/FileNotFoundError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public FileNotFoundError(String msg) {
super(msg);
}

public FileNotFoundError(org.python.Object [] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
public FileNotFoundError(org.python.Object[] args, java.util.Map<java.lang.String, org.python.Object> kwargs) {
super(args, kwargs);
}
}
Loading

0 comments on commit 3df1353

Please sign in to comment.