1 package org.python.core; 3 4 9 public class Options 10 { 11 14 18 public static boolean showJavaExceptions = false; 19 20 28 public static boolean showPythonProxyExceptions = false; 29 30 34 public static boolean skipCompile = true; 35 36 40 public static boolean pollStandardIn = false; 41 42 48 public static boolean respectJavaAccessibility = true; 49 50 54 public static boolean importSite = true; 55 56 61 public static int verbose = Py.MESSAGE; 62 63 67 public static boolean deprecatedKeywordMangling = false; 68 69 74 public static String proxyDebugDirectory = null; 75 76 82 public static boolean caseok = false; 83 84 87 public static boolean Qnew = false; 88 89 97 public static int divisionWarning = 0; 98 99 103 private Options() { ; } 104 105 private static boolean getBooleanOption(String name, boolean defaultValue) 106 { 107 String prop = PySystemState.registry.getProperty("python."+name); 108 if (prop == null) 109 return defaultValue; 110 return prop.equalsIgnoreCase("true") || prop.equalsIgnoreCase("yes"); 111 } 112 113 private static String getStringOption(String name, String defaultValue) { 114 String prop = PySystemState.registry.getProperty("python."+name); 115 if (prop == null) 116 return defaultValue; 117 return prop; 118 } 119 120 121 124 public static void setFromRegistry() { 125 Options.showJavaExceptions = 127 getBooleanOption("options.showJavaExceptions", 128 Options.showJavaExceptions); 129 130 Options.showPythonProxyExceptions = 131 getBooleanOption("options.showPythonProxyExceptions", 132 Options.showPythonProxyExceptions); 133 134 Options.skipCompile = 135 getBooleanOption("options.skipCompile", Options.skipCompile); 136 137 Options.deprecatedKeywordMangling = 138 getBooleanOption("deprecated.keywordMangling", 139 Options.deprecatedKeywordMangling); 140 141 Options.pollStandardIn = 142 getBooleanOption("console.poll", Options.pollStandardIn); 143 144 Options.respectJavaAccessibility = 145 getBooleanOption("security.respectJavaAccessibility", 146 Options.respectJavaAccessibility); 147 148 Options.proxyDebugDirectory = 149 getStringOption("options.proxyDebugDirectory", 150 Options.proxyDebugDirectory); 151 152 String prop = PySystemState.registry.getProperty("python.verbose"); 154 if (prop != null) { 155 if (prop.equalsIgnoreCase("error")) 156 Options.verbose = Py.ERROR; 157 else if (prop.equalsIgnoreCase("warning")) 158 Options.verbose = Py.WARNING; 159 else if (prop.equalsIgnoreCase("message")) 160 Options.verbose = Py.MESSAGE; 161 else if (prop.equalsIgnoreCase("comment")) 162 Options.verbose = Py.COMMENT; 163 else if (prop.equalsIgnoreCase("debug")) 164 Options.verbose = Py.DEBUG; 165 else 166 throw Py.ValueError("Illegal verbose option setting: '"+ 167 prop+"'"); 168 } 169 170 Options.caseok = 171 getBooleanOption("options.caseok", Options.caseok); 172 173 Options.Qnew = 174 getBooleanOption("options.Qnew", Options.Qnew); 175 176 prop = PySystemState.registry.getProperty("python.divisionWarning"); 177 if (prop != null) { 178 if (prop.equalsIgnoreCase("old")) 179 Options.divisionWarning = 0; 180 else if (prop.equalsIgnoreCase("warn")) 181 Options.divisionWarning = 1; 182 else if (prop.equalsIgnoreCase("warnall")) 183 Options.divisionWarning = 2; 184 else 185 throw Py.ValueError("Illegal divisionWarning option " + 186 "setting: '"+ prop+"'"); 187 } 188 JavaAccessibility.initialize(); 191 } 192 } 193 | Popular Tags |