Show More
@@ -82,7 +82,7 b' class Config(dict):' | |||
|
82 | 82 | def _merge(self, other): |
|
83 | 83 | to_update = {} |
|
84 | 84 | for k, v in other.iteritems(): |
|
85 |
if not self |
|
|
85 | if k not in self: | |
|
86 | 86 | to_update[k] = v |
|
87 | 87 | else: # I have this key |
|
88 | 88 | if isinstance(v, Config): |
@@ -204,11 +204,11 b' class TestConfig(TestCase):' | |||
|
204 | 204 | c = Config() |
|
205 | 205 | c.a = 10 |
|
206 | 206 | self.assertEquals(c.a, 10) |
|
207 |
self.assertEquals( |
|
|
207 | self.assertEquals('b' in c, False) | |
|
208 | 208 | |
|
209 | 209 | def test_auto_section(self): |
|
210 | 210 | c = Config() |
|
211 |
self.assertEquals( |
|
|
211 | self.assertEquals('A' in c, True) | |
|
212 | 212 | self.assertEquals(c._has_section('A'), False) |
|
213 | 213 | A = c.A |
|
214 | 214 | A.foo = 'hi there' |
@@ -164,7 +164,7 b' class AliasManager(Configurable):' | |||
|
164 | 164 | self.alias_table[name] = (nargs, cmd) |
|
165 | 165 | |
|
166 | 166 | def undefine_alias(self, name): |
|
167 |
if self.alias_table |
|
|
167 | if name in self.alias_table: | |
|
168 | 168 | del self.alias_table[name] |
|
169 | 169 | |
|
170 | 170 | def validate_alias(self, name, cmd): |
@@ -102,7 +102,7 b' class DisplayPublisher(Configurable):' | |||
|
102 | 102 | """ |
|
103 | 103 | |
|
104 | 104 | # The default is to simply write the plain text data using io.stdout. |
|
105 |
if |
|
|
105 | if 'text/plain' in data: | |
|
106 | 106 | print(data['text/plain'], file=io.stdout) |
|
107 | 107 | |
|
108 | 108 | def clear_output(self, stdout=True, stderr=True, other=True): |
@@ -228,7 +228,7 b' class CodeMagics(Magics):' | |||
|
228 | 228 | |
|
229 | 229 | if opts_prev: |
|
230 | 230 | args = '_%s' % last_call[0] |
|
231 |
if not shell.user_ns |
|
|
231 | if args not in shell.user_ns: | |
|
232 | 232 | args = last_call[1] |
|
233 | 233 | |
|
234 | 234 | # use last_call to remember the state of the previous call, but don't |
@@ -263,7 +263,7 b' python-profiler package from non-free.""")' | |||
|
263 | 263 | print '\n*** Profile printout saved to text file',\ |
|
264 | 264 | repr(text_file)+'.',sys_exit |
|
265 | 265 | |
|
266 |
if |
|
|
266 | if 'r' in opts: | |
|
267 | 267 | return stats |
|
268 | 268 | else: |
|
269 | 269 | return None |
@@ -214,9 +214,9 b' class NamespaceMagics(Magics):' | |||
|
214 | 214 | psearch = shell.inspector.psearch |
|
215 | 215 | |
|
216 | 216 | # select case options |
|
217 |
if |
|
|
217 | if 'i' in opts: | |
|
218 | 218 | ignore_case = True |
|
219 |
elif |
|
|
219 | elif 'c' in opts: | |
|
220 | 220 | ignore_case = False |
|
221 | 221 | else: |
|
222 | 222 | ignore_case = not shell.wildcards_case_sensitive |
@@ -656,7 +656,7 b' class NamespaceMagics(Magics):' | |||
|
656 | 656 | |
|
657 | 657 | opts, regex = self.parse_options(parameter_s,'f') |
|
658 | 658 | |
|
659 |
if |
|
|
659 | if 'f' in opts: | |
|
660 | 660 | ans = True |
|
661 | 661 | else: |
|
662 | 662 | try: |
@@ -35,7 +35,7 b' class PluginManager(Configurable):' | |||
|
35 | 35 | def register_plugin(self, name, plugin): |
|
36 | 36 | if not isinstance(plugin, Plugin): |
|
37 | 37 | raise TypeError('Expected Plugin, got: %r' % plugin) |
|
38 |
if self.plugins |
|
|
38 | if name in self.plugins: | |
|
39 | 39 | raise KeyError('Plugin with name already exists: %r' % name) |
|
40 | 40 | self.plugins[name] = plugin |
|
41 | 41 |
@@ -892,7 +892,7 b' class VerboseTB(TBTools):' | |||
|
892 | 892 | for name_full in unique_names: |
|
893 | 893 | name_base = name_full.split('.',1)[0] |
|
894 | 894 | if name_base in frame.f_code.co_varnames: |
|
895 |
if locals |
|
|
895 | if name_base in locals: | |
|
896 | 896 | try: |
|
897 | 897 | value = repr(eval(name_full,locals)) |
|
898 | 898 | except: |
@@ -901,7 +901,7 b' class VerboseTB(TBTools):' | |||
|
901 | 901 | value = undefined |
|
902 | 902 | name = tpl_local_var % name_full |
|
903 | 903 | else: |
|
904 |
if frame.f_globals |
|
|
904 | if name_base in frame.f_globals: | |
|
905 | 905 | try: |
|
906 | 906 | value = repr(eval(name_full,frame.f_globals)) |
|
907 | 907 | except: |
@@ -119,7 +119,7 b' class StoreMagics(Magics):' | |||
|
119 | 119 | ip = self.shell |
|
120 | 120 | db = ip.db |
|
121 | 121 | # delete |
|
122 |
if |
|
|
122 | if 'd' in opts: | |
|
123 | 123 | try: |
|
124 | 124 | todel = args[0] |
|
125 | 125 | except IndexError: |
@@ -130,11 +130,11 b' class StoreMagics(Magics):' | |||
|
130 | 130 | except: |
|
131 | 131 | raise UsageError("Can't delete variable '%s'" % todel) |
|
132 | 132 | # reset |
|
133 |
elif |
|
|
133 | elif 'z' in opts: | |
|
134 | 134 | for k in db.keys('autorestore/*'): |
|
135 | 135 | del db[k] |
|
136 | 136 | |
|
137 |
elif |
|
|
137 | elif 'r' in opts: | |
|
138 | 138 | refresh_variables(ip) |
|
139 | 139 | |
|
140 | 140 |
@@ -1832,7 +1832,7 b' def which (filename):' | |||
|
1832 | 1832 | if os.access (filename, os.X_OK): |
|
1833 | 1833 | return filename |
|
1834 | 1834 | |
|
1835 |
if not os.environ |
|
|
1835 | if 'PATH' not in os.environ or os.environ['PATH'] == '': | |
|
1836 | 1836 | p = os.defpath |
|
1837 | 1837 | else: |
|
1838 | 1838 | p = os.environ['PATH'] |
@@ -216,13 +216,13 b' class IPythonWidget(FrontendWidget):' | |||
|
216 | 216 | content = msg['content'] |
|
217 | 217 | prompt_number = content.get('execution_count', 0) |
|
218 | 218 | data = content['data'] |
|
219 |
if |
|
|
219 | if 'text/html' in data: | |
|
220 | 220 | self._append_plain_text(self.output_sep, True) |
|
221 | 221 | self._append_html(self._make_out_prompt(prompt_number), True) |
|
222 | 222 | html = data['text/html'] |
|
223 | 223 | self._append_plain_text('\n', True) |
|
224 | 224 | self._append_html(html + self.output_sep2, True) |
|
225 |
elif |
|
|
225 | elif 'text/plain' in data: | |
|
226 | 226 | self._append_plain_text(self.output_sep, True) |
|
227 | 227 | self._append_html(self._make_out_prompt(prompt_number), True) |
|
228 | 228 | text = data['text/plain'] |
@@ -245,10 +245,10 b' class IPythonWidget(FrontendWidget):' | |||
|
245 | 245 | metadata = msg['content']['metadata'] |
|
246 | 246 | # In the regular IPythonWidget, we simply print the plain text |
|
247 | 247 | # representation. |
|
248 |
if |
|
|
248 | if 'text/html' in data: | |
|
249 | 249 | html = data['text/html'] |
|
250 | 250 | self._append_html(html, True) |
|
251 |
elif |
|
|
251 | elif 'text/plain' in data: | |
|
252 | 252 | text = data['text/plain'] |
|
253 | 253 | self._append_plain_text(text, True) |
|
254 | 254 | # This newline seems to be needed for text and html output. |
@@ -117,15 +117,15 b' class RichIPythonWidget(IPythonWidget):' | |||
|
117 | 117 | content = msg['content'] |
|
118 | 118 | prompt_number = content.get('execution_count', 0) |
|
119 | 119 | data = content['data'] |
|
120 |
if |
|
|
120 | if 'image/svg+xml' in data: | |
|
121 | 121 | self._pre_image_append(msg, prompt_number) |
|
122 | 122 | self._append_svg(data['image/svg+xml'], True) |
|
123 | 123 | self._append_html(self.output_sep2, True) |
|
124 |
elif |
|
|
124 | elif 'image/png' in data: | |
|
125 | 125 | self._pre_image_append(msg, prompt_number) |
|
126 | 126 | self._append_png(decodestring(data['image/png'].encode('ascii')), True) |
|
127 | 127 | self._append_html(self.output_sep2, True) |
|
128 |
elif |
|
|
128 | elif 'image/jpeg' in data and self._jpg_supported: | |
|
129 | 129 | self._pre_image_append(msg, prompt_number) |
|
130 | 130 | self._append_jpg(decodestring(data['image/jpeg'].encode('ascii')), True) |
|
131 | 131 | self._append_html(self.output_sep2, True) |
@@ -142,17 +142,17 b' class RichIPythonWidget(IPythonWidget):' | |||
|
142 | 142 | metadata = msg['content']['metadata'] |
|
143 | 143 | # Try to use the svg or html representations. |
|
144 | 144 | # FIXME: Is this the right ordering of things to try? |
|
145 |
if |
|
|
145 | if 'image/svg+xml' in data: | |
|
146 | 146 | self.log.debug("display: %s", msg.get('content', '')) |
|
147 | 147 | svg = data['image/svg+xml'] |
|
148 | 148 | self._append_svg(svg, True) |
|
149 |
elif |
|
|
149 | elif 'image/png' in data: | |
|
150 | 150 | self.log.debug("display: %s", msg.get('content', '')) |
|
151 | 151 | # PNG data is base64 encoded as it passes over the network |
|
152 | 152 | # in a JSON structure so we decode it. |
|
153 | 153 | png = decodestring(data['image/png'].encode('ascii')) |
|
154 | 154 | self._append_png(png, True) |
|
155 |
elif |
|
|
155 | elif 'image/jpeg' in data and self._jpg_supported: | |
|
156 | 156 | self.log.debug("display: %s", msg.get('content', '')) |
|
157 | 157 | jpg = decodestring(data['image/jpeg'].encode('ascii')) |
|
158 | 158 | self._append_jpg(jpg, True) |
@@ -77,7 +77,7 b' def get_app_wx(*args, **kwargs):' | |||
|
77 | 77 | import wx |
|
78 | 78 | app = wx.GetApp() |
|
79 | 79 | if app is None: |
|
80 | if not kwargs.has_key('redirect'): | |
|
80 | if 'redirect' not in kwargs: | |
|
81 | 81 | kwargs['redirect'] = False |
|
82 | 82 | app = wx.PySimpleApp(*args, **kwargs) |
|
83 | 83 | return app |
@@ -176,7 +176,7 b' class InputHookManager(object):' | |||
|
176 | 176 | """ |
|
177 | 177 | if gui is None: |
|
178 | 178 | self._apps = {} |
|
179 |
elif self._apps |
|
|
179 | elif gui in self._apps: | |
|
180 | 180 | del self._apps[gui] |
|
181 | 181 | |
|
182 | 182 | def enable_wx(self, app=None): |
@@ -225,7 +225,7 b' class InputHookManager(object):' | |||
|
225 | 225 | |
|
226 | 226 | This merely sets PyOS_InputHook to NULL. |
|
227 | 227 | """ |
|
228 |
if self._apps |
|
|
228 | if GUI_WX in self._apps: | |
|
229 | 229 | self._apps[GUI_WX]._in_event_loop = False |
|
230 | 230 | self.clear_inputhook() |
|
231 | 231 | |
@@ -265,7 +265,7 b' class InputHookManager(object):' | |||
|
265 | 265 | |
|
266 | 266 | This merely sets PyOS_InputHook to NULL. |
|
267 | 267 | """ |
|
268 |
if self._apps |
|
|
268 | if GUI_QT4 in self._apps: | |
|
269 | 269 | self._apps[GUI_QT4]._in_event_loop = False |
|
270 | 270 | self.clear_inputhook() |
|
271 | 271 | |
@@ -364,7 +364,7 b' class InputHookManager(object):' | |||
|
364 | 364 | glut_close, glut_display, \ |
|
365 | 365 | glut_idle, inputhook_glut |
|
366 | 366 | |
|
367 |
if not self._apps |
|
|
367 | if GUI_GLUT not in self._apps: | |
|
368 | 368 | glut.glutInit( sys.argv ) |
|
369 | 369 | glut.glutInitDisplayMode( glut_display_mode ) |
|
370 | 370 | # This is specific to freeglut |
@@ -133,7 +133,7 b' class DictDB(BaseDB):' | |||
|
133 | 133 | |
|
134 | 134 | def add_record(self, msg_id, rec): |
|
135 | 135 | """Add a new Task Record, by msg_id.""" |
|
136 |
if self._records |
|
|
136 | if msg_id in self._records: | |
|
137 | 137 | raise KeyError("Already have msg_id %r"%(msg_id)) |
|
138 | 138 | self._records[msg_id] = rec |
|
139 | 139 |
@@ -243,11 +243,11 b' def _pull(keys):' | |||
|
243 | 243 | user_ns = globals() |
|
244 | 244 | if isinstance(keys, (list,tuple, set)): |
|
245 | 245 | for key in keys: |
|
246 |
if not user_ns |
|
|
246 | if key not in user_ns: | |
|
247 | 247 | raise NameError("name '%s' is not defined"%key) |
|
248 | 248 | return map(user_ns.get, keys) |
|
249 | 249 | else: |
|
250 |
if not user_ns |
|
|
250 | if keys not in user_ns: | |
|
251 | 251 | raise NameError("name '%s' is not defined"%keys) |
|
252 | 252 | return user_ns.get(keys) |
|
253 | 253 |
@@ -84,7 +84,7 b' class Struct(dict):' | |||
|
84 | 84 | ... |
|
85 | 85 | this is not allowed |
|
86 | 86 | """ |
|
87 |
if not self._allownew and not self |
|
|
87 | if not self._allownew and key not in self: | |
|
88 | 88 | raise KeyError( |
|
89 | 89 | "can't create new attribute %s when allow_new_attr(False)" % key) |
|
90 | 90 | dict.__setitem__(self, key, value) |
@@ -212,7 +212,7 b' class Struct(dict):' | |||
|
212 | 212 | {'b': 30} |
|
213 | 213 | """ |
|
214 | 214 | for k in other.keys(): |
|
215 |
if self |
|
|
215 | if k in self: | |
|
216 | 216 | del self[k] |
|
217 | 217 | return self |
|
218 | 218 | |
@@ -262,7 +262,7 b' class Struct(dict):' | |||
|
262 | 262 | >>> s.hasattr('get') |
|
263 | 263 | False |
|
264 | 264 | """ |
|
265 |
return self |
|
|
265 | return key in self | |
|
266 | 266 | |
|
267 | 267 | def allow_new_attr(self, allow = True): |
|
268 | 268 | """Set whether new attributes can be created in this Struct. |
@@ -465,7 +465,7 b' class HasTraits(object):' | |||
|
465 | 465 | |
|
466 | 466 | |
|
467 | 467 | def _add_notifiers(self, handler, name): |
|
468 |
if not self._trait_notifiers |
|
|
468 | if name not in self._trait_notifiers: | |
|
469 | 469 | nlist = [] |
|
470 | 470 | self._trait_notifiers[name] = nlist |
|
471 | 471 | else: |
@@ -474,7 +474,7 b' class HasTraits(object):' | |||
|
474 | 474 | nlist.append(handler) |
|
475 | 475 | |
|
476 | 476 | def _remove_notifiers(self, handler, name): |
|
477 |
if self._trait_notifiers |
|
|
477 | if name in self._trait_notifiers: | |
|
478 | 478 | nlist = self._trait_notifiers[name] |
|
479 | 479 | try: |
|
480 | 480 | index = nlist.index(handler) |
@@ -269,10 +269,11 b" if 'setuptools' in sys.modules:" | |||
|
269 | 269 | # so we explicitly disable some 2to3 fixes to be sure we aren't forgetting |
|
270 | 270 | # anything. |
|
271 | 271 | setuptools_extra_args['use_2to3_exclude_fixers'] = [ |
|
272 | 'lib2to3.fixes.fix_except', | |
|
273 | 272 | 'lib2to3.fixes.fix_apply', |
|
274 |
'lib2to3.fixes.fix_ |
|
|
273 | 'lib2to3.fixes.fix_except', | |
|
274 | 'lib2to3.fixes.fix_has_key', | |
|
275 | 275 | 'lib2to3.fixes.fix_next', |
|
276 | 'lib2to3.fixes.fix_repr', | |
|
276 | 277 | ] |
|
277 | 278 | from setuptools.command.build_py import build_py |
|
278 | 279 | setup_args['cmdclass'] = {'build_py': record_commit_info('IPython', build_cmd=build_py)} |
General Comments 0
You need to be logged in to leave comments.
Login now