[Jython-checkins] jython: Code style fixes.

nicholas.riley jython-checkins at python.org
Wed Mar 21 22:02:05 CET 2012


http://hg.python.org/jython/rev/18c409c93590
changeset:   6464:18c409c93590
user:        Nicholas Riley <njriley at illinois.edu>
date:        Wed Mar 21 17:01:39 2012 -0400
summary:
  Code style fixes.

files:
  .idea/codeStyleSettings.xml                                 |   9 +++++
  src/org/python/core/PyFloat.java                            |   7 ++-
  src/org/python/core/PyInteger.java                          |   2 +
  src/org/python/core/PyObject.java                           |   3 +-
  src/org/python/core/PyString.java                           |   9 +++-
  src/org/python/core/stringlib/InternalFormatSpecParser.java |   8 ++--
  src/org/python/core/stringlib/MarkupIterator.java           |  17 ++++++---
  7 files changed, 38 insertions(+), 17 deletions(-)


diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -3,7 +3,16 @@
   <component name="ProjectCodeStyleSettingsManager">
     <option name="PER_PROJECT_SETTINGS">
       <value>
+        <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
+        <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
+        <XML>
+          <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+        </XML>
         <codeStyleSettings language="JAVA">
+          <option name="IF_BRACE_FORCE" value="3" />
+          <option name="DOWHILE_BRACE_FORCE" value="3" />
+          <option name="WHILE_BRACE_FORCE" value="3" />
+          <option name="FOR_BRACE_FORCE" value="3" />
           <indentOptions>
             <option name="TAB_SIZE" value="8" />
           </indentOptions>
diff --git a/src/org/python/core/PyFloat.java b/src/org/python/core/PyFloat.java
--- a/src/org/python/core/PyFloat.java
+++ b/src/org/python/core/PyFloat.java
@@ -122,12 +122,13 @@
     }
 
     private String formatDouble(int precision) {
-        if (Double.isNaN(value))
+        if (Double.isNaN(value)) {
             return "nan";
-        else if (value == Double.NEGATIVE_INFINITY)
+        } else if (value == Double.NEGATIVE_INFINITY) {
             return "-inf";
-        else if (value == Double.POSITIVE_INFINITY)
+        } else if (value == Double.POSITIVE_INFINITY) {
             return "inf";
+        }
 
         String result = String.format("%%.%dg", precision);
         result = Py.newString(result).__mod__(this).toString();
diff --git a/src/org/python/core/PyInteger.java b/src/org/python/core/PyInteger.java
--- a/src/org/python/core/PyInteger.java
+++ b/src/org/python/core/PyInteger.java
@@ -6,6 +6,8 @@
 
 import java.io.Serializable;
 import java.math.BigInteger;
+import java.text.NumberFormat;
+import java.util.Locale;
 
 import org.python.core.stringlib.InternalFormatSpec;
 import org.python.core.stringlib.InternalFormatSpecParser;
diff --git a/src/org/python/core/PyObject.java b/src/org/python/core/PyObject.java
--- a/src/org/python/core/PyObject.java
+++ b/src/org/python/core/PyObject.java
@@ -1716,8 +1716,9 @@
 
     @ExposedMethod(doc = BuiltinDocs.object___format___doc)
     final PyObject object___format__(PyObject formatSpec) {
-        if (formatSpec != null && formatSpec instanceof PyString && !((PyString)formatSpec).getString().isEmpty())
+        if (formatSpec != null && formatSpec instanceof PyString && !((PyString)formatSpec).getString().isEmpty()) {
             Py.warning(Py.PendingDeprecationWarning, "object.__format__ with a non-empty format string is deprecated");
+        }
         return __str__().__format__(formatSpec);
     }
 
diff --git a/src/org/python/core/PyString.java b/src/org/python/core/PyString.java
--- a/src/org/python/core/PyString.java
+++ b/src/org/python/core/PyString.java
@@ -3196,14 +3196,16 @@
             case 'e':
             case 'E':
                 string = formatFloatExponential(arg, c, false);
-                if (c == 'E')
+                if (c == 'E') {
                     string = string.toUpperCase();
+                }
                 break;
             case 'f':
             case 'F':
                 string = formatFloatDecimal(asDouble(arg), false);
-                if (c == 'F')
+                if (c == 'F') {
                     string = string.toUpperCase();
+                }
                 break;
             case 'g':
             case 'G':
@@ -3241,8 +3243,9 @@
                     precision--;
                     string = formatFloatExponential(arg, (char)(c-2), !altFlag);
                 }
-                if (c == 'G')
+                if (c == 'G') {
                     string = string.toUpperCase();
+                }
                 break;
             case 'c':
                 fill = ' ';
diff --git a/src/org/python/core/stringlib/InternalFormatSpecParser.java b/src/org/python/core/stringlib/InternalFormatSpecParser.java
--- a/src/org/python/core/stringlib/InternalFormatSpecParser.java
+++ b/src/org/python/core/stringlib/InternalFormatSpecParser.java
@@ -44,8 +44,9 @@
         }
         if (result.fill_char == '\0' && isAt("0")) {
             result.fill_char = '0';
-            if (result.align == '\0')
+            if (result.align == '\0') {
                 result.align = '=';
+            }
             index++;
         }
         result.width = getInteger();
@@ -66,9 +67,8 @@
                 throw new IllegalArgumentException("Invalid conversion specification");
             }
         }
-        if (result.thousands_separators) {
-            if ("defgEG%F\0".indexOf(result.type) == -1)
-                throw new IllegalArgumentException("Cannot specify ',' with '" + result.type + "'.");
+        if (result.thousands_separators && "defgEG%F\0".indexOf(result.type) == -1) {
+            throw new IllegalArgumentException("Cannot specify ',' with '" + result.type + "'.");
         }
         return result;
     }
diff --git a/src/org/python/core/stringlib/MarkupIterator.java b/src/org/python/core/stringlib/MarkupIterator.java
--- a/src/org/python/core/stringlib/MarkupIterator.java
+++ b/src/org/python/core/stringlib/MarkupIterator.java
@@ -26,10 +26,11 @@
 
     public MarkupIterator(String markup, MarkupIterator enclosingIterator) {
         this.markup = markup;
-        if (enclosingIterator != null)
+        if (enclosingIterator != null) {
             numbering = enclosingIterator.numbering;
-        else
+        } else {
             numbering = new FieldNumbering();
+        }
     }
 
     @Override
@@ -158,8 +159,9 @@
             result.fieldName = numbering.nextAutomaticFieldNumber() + result.fieldName;
             return;
         }
-        if (Character.isDigit(c))
+        if (Character.isDigit(c)) {
             numbering.useManualFieldNumbering();
+        }
     }
 
     private int indexOfFirst(String s, int start, char c1, char c2) {
@@ -179,15 +181,18 @@
         private int automaticFieldNumber = 0;
 
         String nextAutomaticFieldNumber() {
-            if (manualFieldNumberSpecified)
+            if (manualFieldNumberSpecified) {
                 throw new IllegalArgumentException("cannot switch from manual field specification to automatic field numbering");
+            }
             return Integer.toString(automaticFieldNumber++);
         }
         void useManualFieldNumbering() {
-            if (manualFieldNumberSpecified)
+            if (manualFieldNumberSpecified) {
                 return;
-            if (automaticFieldNumber != 0)
+            }
+            if (automaticFieldNumber != 0) {
                 throw new IllegalArgumentException("cannot switch from automatic field numbering to manual field specification");
+            }
             manualFieldNumberSpecified = true;
         }
     }

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list