##// END OF EJS Templates
Some code cleanup in javascript and python...
Matthias Bussonnier -
Show More
@@ -243,8 +243,6 b' class InteractiveShell(SingletonConfigurable):'
243 """
243 """
244 )
244 )
245
245
246 banner = Unicode('')
247
248 banner1 = Unicode(default_banner, config=True,
246 banner1 = Unicode(default_banner, config=True,
249 help="""The part of the banner to be printed before the profile"""
247 help="""The part of the banner to be printed before the profile"""
250 )
248 )
@@ -1,8 +1,7 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define(['require'
4 define(function(require){
5 ], function(require) {
6 "use strict";
5 "use strict";
7
6
8 var ActionHandler = function (env) {
7 var ActionHandler = function (env) {
@@ -36,7 +35,7 b" define(['require'"
36 * but is considered undefined behavior.
35 * but is considered undefined behavior.
37 *
36 *
38 **/
37 **/
39 var _action = {
38 var _actions = {
40 'run-select-next': {
39 'run-select-next': {
41 icon: 'fa-play',
40 icon: 'fa-play',
42 help : 'run cell, select below',
41 help : 'run cell, select below',
@@ -387,11 +386,13 b" define(['require'"
387 // Will actually generate/register all the IPython actions
386 // Will actually generate/register all the IPython actions
388 var fun = function(){
387 var fun = function(){
389 var final_actions = {};
388 var final_actions = {};
390 for(var k in _action){
389 var k;
390 for(k in _actions){
391 if(_actions.hasOwnProperty(k)){
391 // Js closure are function level not block level need to wrap in a IIFE
392 // Js closure are function level not block level need to wrap in a IIFE
392 // and append ipython to event name these things do intercept event so are wrapped
393 // and append ipython to event name these things do intercept event so are wrapped
393 // in a function that return false.
394 // in a function that return false.
394 var handler = _prepare_handler(final_actions, k, _action);
395 var handler = _prepare_handler(final_actions, k, _actions);
395 (function(key, handler){
396 (function(key, handler){
396 final_actions['ipython.'+key].handler = function(env, event){
397 final_actions['ipython.'+key].handler = function(env, event){
397 handler(env);
398 handler(env);
@@ -402,10 +403,12 b" define(['require'"
402 };
403 };
403 })(k, handler);
404 })(k, handler);
404 }
405 }
406 }
405
407
406 for(var k in custom_ignore){
408 for(k in custom_ignore){
407 // Js closure are function level not block level need to wrap in a IIFE
409 // Js closure are function level not block level need to wrap in a IIFE
408 // same as above, but decide for themselves wether or not they intercept events.
410 // same as above, but decide for themselves wether or not they intercept events.
411 if(custom_ignore.hasOwnProperty(k)){
409 var handler = _prepare_handler(final_actions, k, custom_ignore);
412 var handler = _prepare_handler(final_actions, k, custom_ignore);
410 (function(key, handler){
413 (function(key, handler){
411 final_actions['ipython.'+key].handler = function(env, event){
414 final_actions['ipython.'+key].handler = function(env, event){
@@ -413,6 +416,7 b" define(['require'"
413 };
416 };
414 })(k, handler);
417 })(k, handler);
415 }
418 }
419 }
416
420
417 return final_actions;
421 return final_actions;
418 };
422 };
@@ -40,7 +40,7 b' define(['
40 var Cell = cell.Cell;
40 var Cell = cell.Cell;
41
41
42 /* local util for codemirror */
42 /* local util for codemirror */
43 var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;};
43 var posEq = function(a, b) {return a.line === b.line && a.ch === b.ch;};
44
44
45 /**
45 /**
46 *
46 *
@@ -332,7 +332,7 b' define(['
332 // whatever key is pressed, first, cancel the tooltip request before
332 // whatever key is pressed, first, cancel the tooltip request before
333 // they are sent, and remove tooltip if any, except for tab again
333 // they are sent, and remove tooltip if any, except for tab again
334 var tooltip_closed = null;
334 var tooltip_closed = null;
335 if (event.type === 'keydown' && event.which != keycodes.tab ) {
335 if (event.type === 'keydown' && event.which !== keycodes.tab ) {
336 tooltip_closed = this.tooltip.remove_and_cancel_tooltip();
336 tooltip_closed = this.tooltip.remove_and_cancel_tooltip();
337 }
337 }
338
338
@@ -366,7 +366,7 b' define(['
366 if (editor.somethingSelected() || editor.getSelections().length !== 1){
366 if (editor.somethingSelected() || editor.getSelections().length !== 1){
367 var anchor = editor.getCursor("anchor");
367 var anchor = editor.getCursor("anchor");
368 var head = editor.getCursor("head");
368 var head = editor.getCursor("head");
369 if( anchor.line != head.line){
369 if( anchor.line !== head.line){
370 return false;
370 return false;
371 }
371 }
372 }
372 }
@@ -374,7 +374,7 b' define(['
374 event.codemirrorIgnore = true;
374 event.codemirrorIgnore = true;
375 event.preventDefault();
375 event.preventDefault();
376 return true;
376 return true;
377 } else if (event.keyCode === keycodes.tab && event.type == 'keydown') {
377 } else if (event.keyCode === keycodes.tab && event.type === 'keydown') {
378 // Tab completion.
378 // Tab completion.
379 this.tooltip.remove_and_cancel_tooltip();
379 this.tooltip.remove_and_cancel_tooltip();
380
380
@@ -371,7 +371,6 b' define(['
371 * Set the 'Download as foo' menu option for the relevant language.
371 * Set the 'Download as foo' menu option for the relevant language.
372 */
372 */
373 var el = this.element.find('#download_script');
373 var el = this.element.find('#download_script');
374 var that = this;
375
374
376 // Set menu entry text to e.g. "Python (.py)"
375 // Set menu entry text to e.g. "Python (.py)"
377 var langname = (langinfo.name || 'Script')
376 var langname = (langinfo.name || 'Script')
@@ -347,7 +347,7 b' define(['
347 if (value === undefined) {
347 if (value === undefined) {
348 value = true;
348 value = true;
349 }
349 }
350 if (this.dirty == value) {
350 if (this.dirty === value) {
351 return;
351 return;
352 }
352 }
353 this.events.trigger('set_dirty.Notebook', {value: value});
353 this.events.trigger('set_dirty.Notebook', {value: value});
@@ -1792,7 +1792,7 b' define(['
1792 cell_data = new_cells[i];
1792 cell_data = new_cells[i];
1793 new_cell = this.insert_cell_at_index(cell_data.cell_type, i);
1793 new_cell = this.insert_cell_at_index(cell_data.cell_type, i);
1794 new_cell.fromJSON(cell_data);
1794 new_cell.fromJSON(cell_data);
1795 if (new_cell.cell_type == 'code' && !new_cell.output_area.trusted) {
1795 if (new_cell.cell_type === 'code' && !new_cell.output_area.trusted) {
1796 trusted = false;
1796 trusted = false;
1797 }
1797 }
1798 }
1798 }
@@ -1818,7 +1818,7 b' define(['
1818 var trusted = true;
1818 var trusted = true;
1819 for (var i=0; i<ncells; i++) {
1819 for (var i=0; i<ncells; i++) {
1820 var cell = cells[i];
1820 var cell = cells[i];
1821 if (cell.cell_type == 'code' && !cell.output_area.trusted) {
1821 if (cell.cell_type === 'code' && !cell.output_area.trusted) {
1822 trusted = false;
1822 trusted = false;
1823 }
1823 }
1824 cell_array[i] = cell.toJSON();
1824 cell_array[i] = cell.toJSON();
@@ -1829,7 +1829,7 b' define(['
1829 nbformat: this.nbformat,
1829 nbformat: this.nbformat,
1830 nbformat_minor: this.nbformat_minor
1830 nbformat_minor: this.nbformat_minor
1831 };
1831 };
1832 if (trusted != this.trusted) {
1832 if (trusted !== this.trusted) {
1833 this.trusted = trusted;
1833 this.trusted = trusted;
1834 this.events.trigger("trust_changed.Notebook", trusted);
1834 this.events.trigger("trust_changed.Notebook", trusted);
1835 }
1835 }
@@ -1957,7 +1957,7 b' define(['
1957 // round to 10 seconds, otherwise we will be setting a new interval too often
1957 // round to 10 seconds, otherwise we will be setting a new interval too often
1958 interval = 10000 * Math.round(interval / 10000);
1958 interval = 10000 * Math.round(interval / 10000);
1959 // set new interval, if it's changed
1959 // set new interval, if it's changed
1960 if (interval != this.autosave_interval) {
1960 if (interval !== this.autosave_interval) {
1961 this.set_autosave_interval(interval);
1961 this.set_autosave_interval(interval);
1962 }
1962 }
1963 }
1963 }
@@ -1997,7 +1997,7 b' define(['
1997 var cells = nb.get_cells();
1997 var cells = nb.get_cells();
1998 for (var i = 0; i < cells.length; i++) {
1998 for (var i = 0; i < cells.length; i++) {
1999 var cell = cells[i];
1999 var cell = cells[i];
2000 if (cell.cell_type == 'code') {
2000 if (cell.cell_type === 'code') {
2001 cell.output_area.trusted = true;
2001 cell.output_area.trusted = true;
2002 }
2002 }
2003 }
2003 }
@@ -2264,7 +2264,7 b' define(['
2264 var found = false;
2264 var found = false;
2265 for (var i = 0; i < this.checkpoints.length; i++) {
2265 for (var i = 0; i < this.checkpoints.length; i++) {
2266 var existing = this.checkpoints[i];
2266 var existing = this.checkpoints[i];
2267 if (existing.id == checkpoint.id) {
2267 if (existing.id === checkpoint.id) {
2268 found = true;
2268 found = true;
2269 this.checkpoints[i] = checkpoint;
2269 this.checkpoints[i] = checkpoint;
2270 break;
2270 break;
@@ -125,7 +125,6 b' define(['
125 var cont = Cell.prototype.unrender.apply(this);
125 var cont = Cell.prototype.unrender.apply(this);
126 if (cont) {
126 if (cont) {
127 var text_cell = this.element;
127 var text_cell = this.element;
128 var output = text_cell.find("div.text_cell_render");
129 if (this.get_text() === this.placeholder) {
128 if (this.get_text() === this.placeholder) {
130 this.set_text('');
129 this.set_text('');
131 }
130 }
@@ -15,6 +15,7 b' require(['
15 page,
15 page,
16 terminado
16 terminado
17 ){
17 ){
18 "use strict";
18 page = new page.Page();
19 page = new page.Page();
19 // Test size: 25x80
20 // Test size: 25x80
20 var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
21 var termRowHeight = function(){ return 1.00 * $("#dummy-screen")[0].offsetHeight / 25;};
@@ -28,8 +29,8 b' require(['
28
29
29 var header = $("#header")[0]
30 var header = $("#header")[0]
30 function calculate_size() {
31 function calculate_size() {
31 height = window.innerHeight - header.offsetHeight;
32 var height = window.innerHeight - header.offsetHeight;
32 width = $('#terminado-container').width();
33 var width = $('#terminado-container').width();
33 var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1));
34 var rows = Math.min(1000, Math.max(20, Math.floor(height/termRowHeight())-1));
34 var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1));
35 var cols = Math.min(1000, Math.max(40, Math.floor(width/termColWidth())-1));
35 console.log("resize to :", rows , 'rows by ', cols, 'columns');
36 console.log("resize to :", rows , 'rows by ', cols, 'columns');
@@ -38,7 +39,7 b' require(['
38
39
39 page.show_header();
40 page.show_header();
40
41
41 size = calculate_size();
42 var size = calculate_size();
42 var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url);
43 var terminal = terminado.make_terminal($("#terminado-container")[0], size, ws_url);
43
44
44 page.show_site();
45 page.show_site();
@@ -1,4 +1,5 b''
1 define ([], function() {
1 define ([], function() {
2 "use strict";
2 function make_terminal(element, size, ws_url) {
3 function make_terminal(element, size, ws_url) {
3 var ws = new WebSocket(ws_url);
4 var ws = new WebSocket(ws_url);
4 var term = new Terminal({
5 var term = new Terminal({
@@ -21,7 +22,7 b' define ([], function() {'
21 term.open(element);
22 term.open(element);
22
23
23 ws.onmessage = function(event) {
24 ws.onmessage = function(event) {
24 json_msg = JSON.parse(event.data);
25 var json_msg = JSON.parse(event.data);
25 switch(json_msg[0]) {
26 switch(json_msg[0]) {
26 case "stdout":
27 case "stdout":
27 term.write(json_msg[1]);
28 term.write(json_msg[1]);
@@ -64,7 +64,6 b' define(['
64 };
64 };
65
65
66 TerminalList.prototype.load_terminals = function() {
66 TerminalList.prototype.load_terminals = function() {
67 var that = this;
68 var url = utils.url_join_encode(this.base_url, 'api/terminals');
67 var url = utils.url_join_encode(this.base_url, 'api/terminals');
69 $.ajax(url, {
68 $.ajax(url, {
70 type: "GET",
69 type: "GET",
@@ -78,7 +77,7 b' define(['
78 TerminalList.prototype.terminals_loaded = function (data) {
77 TerminalList.prototype.terminals_loaded = function (data) {
79 this.terminals = data;
78 this.terminals = data;
80 this.clear_list();
79 this.clear_list();
81 var item, path_name, term;
80 var item, term;
82 for (var i=0; i < this.terminals.length; i++) {
81 for (var i=0; i < this.terminals.length; i++) {
83 term = this.terminals[i];
82 term = this.terminals[i];
84 item = this.new_item(-1);
83 item = this.new_item(-1);
@@ -8,6 +8,7 b' define(["widgets/js/manager",'
8 "base/js/utils",
8 "base/js/utils",
9 "base/js/namespace",
9 "base/js/namespace",
10 ], function(widgetmanager, _, Backbone, $, utils, IPython){
10 ], function(widgetmanager, _, Backbone, $, utils, IPython){
11 "use strict";
11
12
12 var WidgetModel = Backbone.Model.extend({
13 var WidgetModel = Backbone.Model.extend({
13 constructor: function (widget_manager, model_id, comm) {
14 constructor: function (widget_manager, model_id, comm) {
@@ -175,7 +176,7 b' define(["widgets/js/manager",'
175
176
176 get_state: function() {
177 get_state: function() {
177 // Get the serializable state of the model.
178 // Get the serializable state of the model.
178 state = this.toJSON();
179 var state = this.toJSON();
179 for (var key in state) {
180 for (var key in state) {
180 if (state.hasOwnProperty(key)) {
181 if (state.hasOwnProperty(key)) {
181 state[key] = this._pack_models(state[key]);
182 state[key] = this._pack_models(state[key]);
@@ -587,7 +588,6 b' define(["widgets/js/manager",'
587 /**
588 /**
588 * Update the css styling of this view.
589 * Update the css styling of this view.
589 */
590 */
590 var e = this.$el;
591 if (css === undefined) {return;}
591 if (css === undefined) {return;}
592 for (var i = 0; i < css.length; i++) {
592 for (var i = 0; i < css.length; i++) {
593 // Apply the css traits to all elements that match the selector.
593 // Apply the css traits to all elements that match the selector.
@@ -705,7 +705,7 b' define(["widgets/js/manager",'
705 */
705 */
706 var remove = remove_view || this._remove_view;
706 var remove = remove_view || this._remove_view;
707 var create = create_view || this._create_view;
707 var create = create_view || this._create_view;
708 var context = context || this._handler_context;
708 context = context || this._handler_context;
709 var i = 0;
709 var i = 0;
710 // first, skip past the beginning of the lists if they are identical
710 // first, skip past the beginning of the lists if they are identical
711 for (; i < new_models.length; i++) {
711 for (; i < new_models.length; i++) {
@@ -7,6 +7,7 b' define(['
7 "base/js/utils",
7 "base/js/utils",
8 "bootstrap",
8 "bootstrap",
9 ], function(widget, $, utils){
9 ], function(widget, $, utils){
10 "use strict";
10
11
11 var BoxView = widget.DOMWidgetView.extend({
12 var BoxView = widget.DOMWidgetView.extend({
12 initialize: function(){
13 initialize: function(){
@@ -260,11 +260,12 b' define(['
260 * Calling model.set will trigger all of the other views of the
260 * Calling model.set will trigger all of the other views of the
261 * model to update.
261 * model to update.
262 */
262 */
263 var actual_value;
263 if (this.model.get("_range")) {
264 if (this.model.get("_range")) {
264 var actual_value = ui.values.map(this._validate_slide_value);
265 actual_value = ui.values.map(this._validate_slide_value);
265 this.$readout.text(actual_value.join("-"));
266 this.$readout.text(actual_value.join("-"));
266 } else {
267 } else {
267 var actual_value = this._validate_slide_value(ui.value);
268 actual_value = this._validate_slide_value(ui.value);
268 this.$readout.text(actual_value);
269 this.$readout.text(actual_value);
269 }
270 }
270 this.model.set('value', actual_value, {updated_view: this});
271 this.model.set('value', actual_value, {updated_view: this});
@@ -168,7 +168,6 b' define(['
168 * Called when view is rendered.
168 * Called when view is rendered.
169 */
169 */
170 var uuid = 'tabs'+utils.uuid();
170 var uuid = 'tabs'+utils.uuid();
171 var that = this;
172 this.$tabs = $('<div />', {id: uuid})
171 this.$tabs = $('<div />', {id: uuid})
173 .addClass('nav')
172 .addClass('nav')
174 .addClass('nav-tabs')
173 .addClass('nav-tabs')
@@ -2,6 +2,7 b''
2 // Test that a Markdown cell is rendered to HTML.
2 // Test that a Markdown cell is rendered to HTML.
3 //
3 //
4 casper.notebook_test(function () {
4 casper.notebook_test(function () {
5 "use strict";
5 // Test JavaScript models.
6 // Test JavaScript models.
6 var output = this.evaluate(function () {
7 var output = this.evaluate(function () {
7 IPython.notebook.to_markdown();
8 IPython.notebook.to_markdown();
@@ -56,7 +57,7 b' casper.notebook_test(function () {'
56 for (var idx=0; idx < levels.length; idx++) {
57 for (var idx=0; idx < levels.length; idx++) {
57 var level = levels[idx];
58 var level = levels[idx];
58 level_text = set_level(level);
59 level_text = set_level(level);
59 hashes = new Array(level + 1).join('#');
60 var hashes = new Array(level + 1).join('#');
60 this.test.assertEquals(level_text, hashes + ' ' + text, 'markdown set_heading_level ' + level);
61 this.test.assertEquals(level_text, hashes + ' ' + text, 'markdown set_heading_level ' + level);
61 }
62 }
62 });
63 });
@@ -23,7 +23,7 b' var svg = "\\"<svg width=\'1cm\' height=\'1cm\' viewBox=\'0 0 1000 500\'><defs><style>r'
23 // represetnation, while the original in-memory cell retains its long mimetype
23 // represetnation, while the original in-memory cell retains its long mimetype
24 // name, and that fromJSON also gets its long mimetype name
24 // name, and that fromJSON also gets its long mimetype name
25 function assert_has(short_name, json, result, result2) {
25 function assert_has(short_name, json, result, result2) {
26 long_name = mime[short_name];
26 var long_name = mime[short_name];
27 this.test.assertFalse(json[0].data.hasOwnProperty(short_name),
27 this.test.assertFalse(json[0].data.hasOwnProperty(short_name),
28 "toJSON() representation doesn't use " + short_name);
28 "toJSON() representation doesn't use " + short_name);
29 this.test.assertTrue(json[0].data.hasOwnProperty(long_name),
29 this.test.assertTrue(json[0].data.hasOwnProperty(long_name),
@@ -40,7 +40,7 b' function assert_has(short_name, json, result, result2) {'
40 // 'png', etc) are not used.
40 // 'png', etc) are not used.
41 function check_output_area(output_type, keys) {
41 function check_output_area(output_type, keys) {
42 this.wait_for_output(0);
42 this.wait_for_output(0);
43 json = this.evaluate(function() {
43 var json = this.evaluate(function() {
44 var json = IPython.notebook.get_cell(0).output_area.toJSON();
44 var json = IPython.notebook.get_cell(0).output_area.toJSON();
45 // appended cell will initially be empty, let's add some output
45 // appended cell will initially be empty, let's add some output
46 IPython.notebook.get_cell(1).output_area.fromJSON(json);
46 IPython.notebook.get_cell(1).output_area.fromJSON(json);
@@ -422,8 +422,9 b' casper.click_cell_editor = function(index) {'
422 // region of codemirror that the user can focus.
422 // region of codemirror that the user can focus.
423 this.evaluate(function (i) {
423 this.evaluate(function (i) {
424 var cm = IPython.notebook.get_cell(i).code_mirror;
424 var cm = IPython.notebook.get_cell(i).code_mirror;
425 if (cm.options.readOnly != "nocursor" && (document.activeElement != cm.display.input))
425 if (cm.options.readOnly != "nocursor" && (document.activeElement != cm.display.input)){
426 cm.display.input.focus();
426 cm.display.input.focus();
427 }
427 }, {i: index});
428 }, {i: index});
428 };
429 };
429
430
@@ -591,7 +592,7 b' casper.assert_colors_equal = function (hex_color, local_color, msg) {'
591
592
592 // If the local color is rgb, clean it up and replace
593 // If the local color is rgb, clean it up and replace
593 if (local_color.substr(0,3).toLowerCase() == 'rgb') {
594 if (local_color.substr(0,3).toLowerCase() == 'rgb') {
594 components = local_color.substr(3).split(',');
595 var components = local_color.substr(3).split(',');
595 local_color = '';
596 local_color = '';
596 for (var i = 0; i < components.length; i++) {
597 for (var i = 0; i < components.length; i++) {
597 var part = parseInt(components[i]).toString(16);
598 var part = parseInt(components[i]).toString(16);
@@ -1,5 +1,6 b''
1 // Test widget bool class
1 // Test widget bool class
2 casper.notebook_test(function () {
2 casper.notebook_test(function () {
3 "use strict";
3
4
4 // Create a checkbox and togglebutton.
5 // Create a checkbox and togglebutton.
5 var bool_index = this.append_cell(
6 var bool_index = this.append_cell(
@@ -57,7 +58,7 b' casper.notebook_test(function () {'
57 });
58 });
58
59
59 // Try changing the state of the widgets programatically.
60 // Try changing the state of the widgets programatically.
60 index = this.append_cell(
61 var index = this.append_cell(
61 'bool_widgets[0].value = False\n' +
62 'bool_widgets[0].value = False\n' +
62 'bool_widgets[1].value = False\n' +
63 'bool_widgets[1].value = False\n' +
63 'print("Success")');
64 'print("Success")');
@@ -1,6 +1,7 b''
1 // Test image class
1 // Test image class
2 casper.notebook_test(function () {
2 casper.notebook_test(function () {
3 index = this.append_cell(
3 "use strict";
4 var index = this.append_cell(
4 'from IPython.html import widgets\n' +
5 'from IPython.html import widgets\n' +
5 'from IPython.display import display, clear_output\n' +
6 'from IPython.display import display, clear_output\n' +
6 'print("Success")');
7 'print("Success")');
@@ -27,10 +27,6 b' from IPython.utils import py3compat'
27
27
28 fs_encoding = sys.getfilesystemencoding()
28 fs_encoding = sys.getfilesystemencoding()
29
29
30 def _get_long_path_name(path):
31 """Dummy no-op."""
32 return path
33
34 def _writable_dir(path):
30 def _writable_dir(path):
35 """Whether `path` is a directory, to which the user has write access."""
31 """Whether `path` is a directory, to which the user has write access."""
36 return os.path.isdir(path) and os.access(path, os.W_OK)
32 return os.path.isdir(path) and os.access(path, os.W_OK)
@@ -61,6 +57,11 b" if sys.platform == 'win32':"
61 return path
57 return path
62 else:
58 else:
63 return buf.value
59 return buf.value
60 else:
61 def _get_long_path_name(path):
62 """Dummy no-op."""
63 return path
64
64
65
65
66
66 def get_long_path_name(path):
67 def get_long_path_name(path):
@@ -35,23 +35,18 b' from . import py3compat'
35 ignore_termtitle = True
35 ignore_termtitle = True
36
36
37
37
38 def _term_clear():
39 pass
40
41
38
42 if os.name == 'posix':
39 if os.name == 'posix':
43 def _term_clear():
40 def _term_clear():
44 os.system('clear')
41 os.system('clear')
45
42 elif sys.platform == 'win32':
46
47 if sys.platform == 'win32':
48 def _term_clear():
43 def _term_clear():
49 os.system('cls')
44 os.system('cls')
45 else:
46 def _term_clear():
47 pass
50
48
51
49
52 def term_clear():
53 _term_clear()
54
55
50
56 def toggle_set_term_title(val):
51 def toggle_set_term_title(val):
57 """Control whether set_term_title is active or not.
52 """Control whether set_term_title is active or not.
@@ -85,9 +80,7 b" if os.name == 'posix':"
85 TERM = os.environ.get('TERM','')
80 TERM = os.environ.get('TERM','')
86 if TERM.startswith('xterm'):
81 if TERM.startswith('xterm'):
87 _set_term_title = _set_term_title_xterm
82 _set_term_title = _set_term_title_xterm
88
83 elif sys.platform == 'win32':
89
90 if sys.platform == 'win32':
91 try:
84 try:
92 import ctypes
85 import ctypes
93
86
@@ -127,10 +120,6 b' def freeze_term_title():'
127 ignore_termtitle = True
120 ignore_termtitle = True
128
121
129
122
130 def get_terminal_size(defaultx=80, defaulty=25):
131 return defaultx, defaulty
132
133
134 if sys.platform == 'win32':
123 if sys.platform == 'win32':
135 def get_terminal_size(defaultx=80, defaulty=25):
124 def get_terminal_size(defaultx=80, defaulty=25):
136 """Return size of current terminal console.
125 """Return size of current terminal console.
@@ -161,4 +150,7 b" if sys.platform == 'win32':"
161 return (sizex, sizey)
150 return (sizex, sizey)
162 else:
151 else:
163 return (defaultx, defaulty)
152 return (defaultx, defaulty)
153 else:
154 def get_terminal_size(defaultx=80, defaulty=25):
155 return defaultx, defaulty
164
156
@@ -16,7 +16,6 b' def expect_token(expected, cell, cursor_pos):'
16 offset += len(line)
16 offset += len(line)
17 column = cursor_pos - offset
17 column = cursor_pos - offset
18 line_with_cursor = '%s|%s' % (line[:column], line[column:])
18 line_with_cursor = '%s|%s' % (line[:column], line[column:])
19 line
20 nt.assert_equal(token, expected,
19 nt.assert_equal(token, expected,
21 "Expected %r, got %r in: %r (pos %i)" % (
20 "Expected %r, got %r in: %r (pos %i)" % (
22 expected, token, line_with_cursor, cursor_pos)
21 expected, token, line_with_cursor, cursor_pos)
@@ -298,7 +298,7 b" if 'setuptools' in sys.modules:"
298 if 'bdist_wininst' in sys.argv:
298 if 'bdist_wininst' in sys.argv:
299 if len(sys.argv) > 2 and \
299 if len(sys.argv) > 2 and \
300 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
300 ('sdist' in sys.argv or 'bdist_rpm' in sys.argv):
301 print >> sys.stderr, "ERROR: bdist_wininst must be run alone. Exiting."
301 print("ERROR: bdist_wininst must be run alone. Exiting.", file=sys.stderr)
302 sys.exit(1)
302 sys.exit(1)
303 setup_args['data_files'].append(
303 setup_args['data_files'].append(
304 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
304 ['Scripts', ('scripts/ipython.ico', 'scripts/ipython_nb.ico')])
General Comments 0
You need to be logged in to leave comments. Login now