##// END OF EJS Templates
add Integer traitlet...
MinRK -
Show More
@@ -34,7 +34,7 b' from IPython.config.loader import ('
34 )
34 )
35
35
36 from IPython.utils.traitlets import (
36 from IPython.utils.traitlets import (
37 Unicode, List, Int, Enum, Dict, Instance, TraitError
37 Unicode, List, Enum, Dict, Instance, TraitError
38 )
38 )
39 from IPython.utils.importstring import import_item
39 from IPython.utils.importstring import import_item
40 from IPython.utils.text import indent, wrap_paragraphs, dedent
40 from IPython.utils.text import indent, wrap_paragraphs, dedent
@@ -28,7 +28,7 b' from IPython.config.application import ('
28 )
28 )
29
29
30 from IPython.utils.traitlets import (
30 from IPython.utils.traitlets import (
31 Bool, Unicode, Int, Float, List, Dict
31 Bool, Unicode, Integer, Float, List, Dict
32 )
32 )
33
33
34 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
@@ -37,14 +37,14 b' from IPython.utils.traitlets import ('
37
37
38 class Foo(Configurable):
38 class Foo(Configurable):
39
39
40 i = Int(0, config=True, help="The integer i.")
40 i = Integer(0, config=True, help="The integer i.")
41 j = Int(1, config=True, help="The integer j.")
41 j = Integer(1, config=True, help="The integer j.")
42 name = Unicode(u'Brian', config=True, help="First name.")
42 name = Unicode(u'Brian', config=True, help="First name.")
43
43
44
44
45 class Bar(Configurable):
45 class Bar(Configurable):
46
46
47 b = Int(0, config=True, help="The integer b.")
47 b = Integer(0, config=True, help="The integer b.")
48 enabled = Bool(True, config=True, help="Enable bar.")
48 enabled = Bool(True, config=True, help="Enable bar.")
49
49
50
50
@@ -27,7 +27,7 b' from IPython.config.configurable import ('
27 )
27 )
28
28
29 from IPython.utils.traitlets import (
29 from IPython.utils.traitlets import (
30 Int, Float, Unicode
30 Integer, Float, Unicode
31 )
31 )
32
32
33 from IPython.config.loader import Config
33 from IPython.config.loader import Config
@@ -39,14 +39,14 b' from IPython.config.loader import Config'
39
39
40
40
41 class MyConfigurable(Configurable):
41 class MyConfigurable(Configurable):
42 a = Int(1, config=True, help="The integer a.")
42 a = Integer(1, config=True, help="The integer a.")
43 b = Float(1.0, config=True, help="The integer b.")
43 b = Float(1.0, config=True, help="The integer b.")
44 c = Unicode('no config')
44 c = Unicode('no config')
45
45
46
46
47 mc_help=u"""MyConfigurable options
47 mc_help=u"""MyConfigurable options
48 ----------------------
48 ----------------------
49 --MyConfigurable.a=<Int>
49 --MyConfigurable.a=<Integer>
50 Default: 1
50 Default: 1
51 The integer a.
51 The integer a.
52 --MyConfigurable.b=<Float>
52 --MyConfigurable.b=<Float>
@@ -55,7 +55,7 b' mc_help=u"""MyConfigurable options'
55
55
56 mc_help_inst=u"""MyConfigurable options
56 mc_help_inst=u"""MyConfigurable options
57 ----------------------
57 ----------------------
58 --MyConfigurable.a=<Int>
58 --MyConfigurable.a=<Integer>
59 Current: 5
59 Current: 5
60 The integer a.
60 The integer a.
61 --MyConfigurable.b=<Float>
61 --MyConfigurable.b=<Float>
@@ -63,7 +63,7 b' mc_help_inst=u"""MyConfigurable options'
63 The integer b."""
63 The integer b."""
64
64
65 class Foo(Configurable):
65 class Foo(Configurable):
66 a = Int(0, config=True, help="The integer a.")
66 a = Integer(0, config=True, help="The integer a.")
67 b = Unicode('nope', config=True)
67 b = Unicode('nope', config=True)
68
68
69
69
@@ -28,7 +28,7 b' from nose import SkipTest'
28
28
29 from IPython.testing.tools import mute_warn
29 from IPython.testing.tools import mute_warn
30
30
31 from IPython.utils.traitlets import Int, Unicode
31 from IPython.utils.traitlets import Unicode
32 from IPython.config.configurable import Configurable
32 from IPython.config.configurable import Configurable
33 from IPython.config.loader import (
33 from IPython.config.loader import (
34 Config,
34 Config,
@@ -28,7 +28,7 b' from StringIO import StringIO'
28 # Our own imports
28 # Our own imports
29 from IPython.config.configurable import Configurable
29 from IPython.config.configurable import Configurable
30 from IPython.lib import pretty
30 from IPython.lib import pretty
31 from IPython.utils.traitlets import Bool, Dict, Int, Unicode, CUnicode, ObjectName
31 from IPython.utils.traitlets import Bool, Dict, Integer, Unicode, CUnicode, ObjectName
32 from IPython.utils.py3compat import unicode_to_str
32 from IPython.utils.py3compat import unicode_to_str
33
33
34
34
@@ -357,7 +357,7 b' class PlainTextFormatter(BaseFormatter):'
357 verbose = Bool(False, config=True)
357 verbose = Bool(False, config=True)
358
358
359 # The maximum width.
359 # The maximum width.
360 max_width = Int(79, config=True)
360 max_width = Integer(79, config=True)
361
361
362 # The newline character.
362 # The newline character.
363 newline = Unicode('\n', config=True)
363 newline = Unicode('\n', config=True)
@@ -29,7 +29,7 b' from IPython.external.decorator import decorator'
29 from IPython.testing.skipdoctest import skip_doctest
29 from IPython.testing.skipdoctest import skip_doctest
30 from IPython.utils import io
30 from IPython.utils import io
31 from IPython.utils.path import locate_profile
31 from IPython.utils.path import locate_profile
32 from IPython.utils.traitlets import Bool, Dict, Instance, Int, CInt, List, Unicode
32 from IPython.utils.traitlets import Bool, Dict, Instance, Integer, List, Unicode
33 from IPython.utils.warn import warn
33 from IPython.utils.warn import warn
34
34
35 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
@@ -361,12 +361,12 b' class HistoryManager(HistoryAccessor):'
361 output_hist_reprs = Dict()
361 output_hist_reprs = Dict()
362
362
363 # The number of the current session in the history database
363 # The number of the current session in the history database
364 session_number = CInt()
364 session_number = Integer()
365 # Should we log output to the database? (default no)
365 # Should we log output to the database? (default no)
366 db_log_output = Bool(False, config=True)
366 db_log_output = Bool(False, config=True)
367 # Write to database every x commands (higher values save disk access & power)
367 # Write to database every x commands (higher values save disk access & power)
368 # Values of 1 or less effectively disable caching.
368 # Values of 1 or less effectively disable caching.
369 db_cache_size = Int(0, config=True)
369 db_cache_size = Integer(0, config=True)
370 # The input and output caches
370 # The input and output caches
371 db_input_cache = List()
371 db_input_cache = List()
372 db_output_cache = List()
372 db_output_cache = List()
@@ -74,7 +74,7 b' from IPython.utils.process import system, getoutput'
74 from IPython.utils.strdispatch import StrDispatch
74 from IPython.utils.strdispatch import StrDispatch
75 from IPython.utils.syspathcontext import prepended_to_syspath
75 from IPython.utils.syspathcontext import prepended_to_syspath
76 from IPython.utils.text import num_ini_spaces, format_screen, LSString, SList
76 from IPython.utils.text import num_ini_spaces, format_screen, LSString, SList
77 from IPython.utils.traitlets import (Int, CBool, CaselessStrEnum, Enum,
77 from IPython.utils.traitlets import (Integer, CBool, CaselessStrEnum, Enum,
78 List, Unicode, Instance, Type)
78 List, Unicode, Instance, Type)
79 from IPython.utils.warn import warn, error, fatal
79 from IPython.utils.warn import warn, error, fatal
80 import IPython.core.hooks
80 import IPython.core.hooks
@@ -226,7 +226,7 b' class InteractiveShell(SingletonConfigurable, Magic):'
226 Enable magic commands to be called without the leading %.
226 Enable magic commands to be called without the leading %.
227 """
227 """
228 )
228 )
229 cache_size = Int(1000, config=True, help=
229 cache_size = Integer(1000, config=True, help=
230 """
230 """
231 Set the size of the output cache. The default is 1000, you can
231 Set the size of the output cache. The default is 1000, you can
232 change it permanently in your config file. Setting it to 0 completely
232 change it permanently in your config file. Setting it to 0 completely
@@ -277,7 +277,7 b' class InteractiveShell(SingletonConfigurable, Magic):'
277 def _exiter_default(self):
277 def _exiter_default(self):
278 return ExitAutocall(self)
278 return ExitAutocall(self)
279 # Monotonically increasing execution counter
279 # Monotonically increasing execution counter
280 execution_count = Int(1)
280 execution_count = Integer(1)
281 filename = Unicode("<ipython console>")
281 filename = Unicode("<ipython console>")
282 ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__
282 ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__
283
283
@@ -317,7 +317,7 b' class InteractiveShell(SingletonConfigurable, Magic):'
317 prompts_pad_left = CBool(True, config=True)
317 prompts_pad_left = CBool(True, config=True)
318 quiet = CBool(False, config=True)
318 quiet = CBool(False, config=True)
319
319
320 history_length = Int(10000, config=True)
320 history_length = Integer(10000, config=True)
321
321
322 # The readline stuff will eventually be moved to the terminal subclass
322 # The readline stuff will eventually be moved to the terminal subclass
323 # but for now, we can't do that as readline is welded in everywhere.
323 # but for now, we can't do that as readline is welded in everywhere.
@@ -35,7 +35,7 b' from IPython.core.macro import Macro'
35 from IPython.core.splitinput import split_user_input, LineInfo
35 from IPython.core.splitinput import split_user_input, LineInfo
36 from IPython.core import page
36 from IPython.core import page
37
37
38 from IPython.utils.traitlets import List, Int, Any, Unicode, CBool, Bool, Instance
38 from IPython.utils.traitlets import List, Integer, Any, Unicode, CBool, Bool, Instance
39 from IPython.utils.text import make_quoted_expr
39 from IPython.utils.text import make_quoted_expr
40 from IPython.utils.autoattr import auto_attr
40 from IPython.utils.autoattr import auto_attr
41
41
@@ -369,7 +369,7 b' class PrefilterManager(Configurable):'
369 class PrefilterTransformer(Configurable):
369 class PrefilterTransformer(Configurable):
370 """Transform a line of user input."""
370 """Transform a line of user input."""
371
371
372 priority = Int(100, config=True)
372 priority = Integer(100, config=True)
373 # Transformers don't currently use shell or prefilter_manager, but as we
373 # Transformers don't currently use shell or prefilter_manager, but as we
374 # move away from checkers and handlers, they will need them.
374 # move away from checkers and handlers, they will need them.
375 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
375 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
@@ -398,7 +398,7 b" _assign_system_re = re.compile(r'(?P<lhs>(\\s*)([\\w\\.]+)((\\s*,\\s*[\\w\\.]+)*))'"
398 class AssignSystemTransformer(PrefilterTransformer):
398 class AssignSystemTransformer(PrefilterTransformer):
399 """Handle the `files = !ls` syntax."""
399 """Handle the `files = !ls` syntax."""
400
400
401 priority = Int(100, config=True)
401 priority = Integer(100, config=True)
402
402
403 def transform(self, line, continue_prompt):
403 def transform(self, line, continue_prompt):
404 m = _assign_system_re.match(line)
404 m = _assign_system_re.match(line)
@@ -417,7 +417,7 b" _assign_magic_re = re.compile(r'(?P<lhs>(\\s*)([\\w\\.]+)((\\s*,\\s*[\\w\\.]+)*))'"
417 class AssignMagicTransformer(PrefilterTransformer):
417 class AssignMagicTransformer(PrefilterTransformer):
418 """Handle the `a = %who` syntax."""
418 """Handle the `a = %who` syntax."""
419
419
420 priority = Int(200, config=True)
420 priority = Integer(200, config=True)
421
421
422 def transform(self, line, continue_prompt):
422 def transform(self, line, continue_prompt):
423 m = _assign_magic_re.match(line)
423 m = _assign_magic_re.match(line)
@@ -435,7 +435,7 b" _classic_prompt_re = re.compile(r'(^[ \\t]*>>> |^[ \\t]*\\.\\.\\. )')"
435 class PyPromptTransformer(PrefilterTransformer):
435 class PyPromptTransformer(PrefilterTransformer):
436 """Handle inputs that start with '>>> ' syntax."""
436 """Handle inputs that start with '>>> ' syntax."""
437
437
438 priority = Int(50, config=True)
438 priority = Integer(50, config=True)
439
439
440 def transform(self, line, continue_prompt):
440 def transform(self, line, continue_prompt):
441
441
@@ -456,7 +456,7 b" _ipy_prompt_re = re.compile(r'(^[ \\t]*In \\[\\d+\\]: |^[ \\t]*\\ \\ \\ \\.\\.\\.+: )')"
456 class IPyPromptTransformer(PrefilterTransformer):
456 class IPyPromptTransformer(PrefilterTransformer):
457 """Handle inputs that start classic IPython prompt syntax."""
457 """Handle inputs that start classic IPython prompt syntax."""
458
458
459 priority = Int(50, config=True)
459 priority = Integer(50, config=True)
460
460
461 def transform(self, line, continue_prompt):
461 def transform(self, line, continue_prompt):
462
462
@@ -479,7 +479,7 b' class IPyPromptTransformer(PrefilterTransformer):'
479 class PrefilterChecker(Configurable):
479 class PrefilterChecker(Configurable):
480 """Inspect an input line and return a handler for that line."""
480 """Inspect an input line and return a handler for that line."""
481
481
482 priority = Int(100, config=True)
482 priority = Integer(100, config=True)
483 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
483 shell = Instance('IPython.core.interactiveshell.InteractiveShellABC')
484 prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager')
484 prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager')
485 enabled = Bool(True, config=True)
485 enabled = Bool(True, config=True)
@@ -501,7 +501,7 b' class PrefilterChecker(Configurable):'
501
501
502 class EmacsChecker(PrefilterChecker):
502 class EmacsChecker(PrefilterChecker):
503
503
504 priority = Int(100, config=True)
504 priority = Integer(100, config=True)
505 enabled = Bool(False, config=True)
505 enabled = Bool(False, config=True)
506
506
507 def check(self, line_info):
507 def check(self, line_info):
@@ -514,7 +514,7 b' class EmacsChecker(PrefilterChecker):'
514
514
515 class ShellEscapeChecker(PrefilterChecker):
515 class ShellEscapeChecker(PrefilterChecker):
516
516
517 priority = Int(200, config=True)
517 priority = Integer(200, config=True)
518
518
519 def check(self, line_info):
519 def check(self, line_info):
520 if line_info.line.lstrip().startswith(ESC_SHELL):
520 if line_info.line.lstrip().startswith(ESC_SHELL):
@@ -523,7 +523,7 b' class ShellEscapeChecker(PrefilterChecker):'
523
523
524 class MacroChecker(PrefilterChecker):
524 class MacroChecker(PrefilterChecker):
525
525
526 priority = Int(250, config=True)
526 priority = Integer(250, config=True)
527
527
528 def check(self, line_info):
528 def check(self, line_info):
529 obj = self.shell.user_ns.get(line_info.ifun)
529 obj = self.shell.user_ns.get(line_info.ifun)
@@ -535,7 +535,7 b' class MacroChecker(PrefilterChecker):'
535
535
536 class IPyAutocallChecker(PrefilterChecker):
536 class IPyAutocallChecker(PrefilterChecker):
537
537
538 priority = Int(300, config=True)
538 priority = Integer(300, config=True)
539
539
540 def check(self, line_info):
540 def check(self, line_info):
541 "Instances of IPyAutocall in user_ns get autocalled immediately"
541 "Instances of IPyAutocall in user_ns get autocalled immediately"
@@ -549,7 +549,7 b' class IPyAutocallChecker(PrefilterChecker):'
549
549
550 class MultiLineMagicChecker(PrefilterChecker):
550 class MultiLineMagicChecker(PrefilterChecker):
551
551
552 priority = Int(400, config=True)
552 priority = Integer(400, config=True)
553
553
554 def check(self, line_info):
554 def check(self, line_info):
555 "Allow ! and !! in multi-line statements if multi_line_specials is on"
555 "Allow ! and !! in multi-line statements if multi_line_specials is on"
@@ -566,7 +566,7 b' class MultiLineMagicChecker(PrefilterChecker):'
566
566
567 class EscCharsChecker(PrefilterChecker):
567 class EscCharsChecker(PrefilterChecker):
568
568
569 priority = Int(500, config=True)
569 priority = Integer(500, config=True)
570
570
571 def check(self, line_info):
571 def check(self, line_info):
572 """Check for escape character and return either a handler to handle it,
572 """Check for escape character and return either a handler to handle it,
@@ -586,7 +586,7 b' class EscCharsChecker(PrefilterChecker):'
586
586
587 class AssignmentChecker(PrefilterChecker):
587 class AssignmentChecker(PrefilterChecker):
588
588
589 priority = Int(600, config=True)
589 priority = Integer(600, config=True)
590
590
591 def check(self, line_info):
591 def check(self, line_info):
592 """Check to see if user is assigning to a var for the first time, in
592 """Check to see if user is assigning to a var for the first time, in
@@ -604,7 +604,7 b' class AssignmentChecker(PrefilterChecker):'
604
604
605 class AutoMagicChecker(PrefilterChecker):
605 class AutoMagicChecker(PrefilterChecker):
606
606
607 priority = Int(700, config=True)
607 priority = Integer(700, config=True)
608
608
609 def check(self, line_info):
609 def check(self, line_info):
610 """If the ifun is magic, and automagic is on, run it. Note: normal,
610 """If the ifun is magic, and automagic is on, run it. Note: normal,
@@ -628,7 +628,7 b' class AutoMagicChecker(PrefilterChecker):'
628
628
629 class AliasChecker(PrefilterChecker):
629 class AliasChecker(PrefilterChecker):
630
630
631 priority = Int(800, config=True)
631 priority = Integer(800, config=True)
632
632
633 def check(self, line_info):
633 def check(self, line_info):
634 "Check if the initital identifier on the line is an alias."
634 "Check if the initital identifier on the line is an alias."
@@ -644,7 +644,7 b' class AliasChecker(PrefilterChecker):'
644
644
645 class PythonOpsChecker(PrefilterChecker):
645 class PythonOpsChecker(PrefilterChecker):
646
646
647 priority = Int(900, config=True)
647 priority = Integer(900, config=True)
648
648
649 def check(self, line_info):
649 def check(self, line_info):
650 """If the 'rest' of the line begins with a function call or pretty much
650 """If the 'rest' of the line begins with a function call or pretty much
@@ -659,7 +659,7 b' class PythonOpsChecker(PrefilterChecker):'
659
659
660 class AutocallChecker(PrefilterChecker):
660 class AutocallChecker(PrefilterChecker):
661
661
662 priority = Int(1000, config=True)
662 priority = Integer(1000, config=True)
663
663
664 def check(self, line_info):
664 def check(self, line_info):
665 "Check if the initial word/function is callable and autocall is on."
665 "Check if the initial word/function is callable and autocall is on."
@@ -29,7 +29,7 b' from tornado import web'
29 from IPython.config.configurable import LoggingConfigurable
29 from IPython.config.configurable import LoggingConfigurable
30 from IPython.zmq.ipkernel import launch_kernel
30 from IPython.zmq.ipkernel import launch_kernel
31 from IPython.zmq.kernelmanager import KernelManager
31 from IPython.zmq.kernelmanager import KernelManager
32 from IPython.utils.traitlets import Instance, Dict, List, Unicode, Float, Int
32 from IPython.utils.traitlets import Instance, Dict, List, Unicode, Float, Integer
33
33
34 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
35 # Classes
35 # Classes
@@ -196,7 +196,7 b' class MappingKernelManager(MultiKernelManager):'
196 kernel_argv = List(Unicode)
196 kernel_argv = List(Unicode)
197 kernel_manager = Instance(KernelManager)
197 kernel_manager = Instance(KernelManager)
198 time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
198 time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
199 max_msg_size = Int(65536, config=True, help="""
199 max_msg_size = Integer(65536, config=True, help="""
200 The max raw message size accepted from the browser
200 The max raw message size accepted from the browser
201 over a WebSocket connection.
201 over a WebSocket connection.
202 """)
202 """)
@@ -57,7 +57,7 b' from IPython.zmq.ipkernel import ('
57 aliases as ipkernel_aliases,
57 aliases as ipkernel_aliases,
58 IPKernelApp
58 IPKernelApp
59 )
59 )
60 from IPython.utils.traitlets import Dict, Unicode, Int, List, Enum, Bool
60 from IPython.utils.traitlets import Dict, Unicode, Integer, List, Enum, Bool
61
61
62 #-----------------------------------------------------------------------------
62 #-----------------------------------------------------------------------------
63 # Module globals
63 # Module globals
@@ -195,7 +195,7 b' class NotebookApp(BaseIPythonApplication):'
195 def _ip_changed(self, name, old, new):
195 def _ip_changed(self, name, old, new):
196 if new == u'*': self.ip = u''
196 if new == u'*': self.ip = u''
197
197
198 port = Int(8888, config=True,
198 port = Integer(8888, config=True,
199 help="The port the notebook server will listen on."
199 help="The port the notebook server will listen on."
200 )
200 )
201
201
@@ -20,7 +20,7 b' from IPython.config.configurable import LoggingConfigurable'
20 from IPython.frontend.qt.rich_text import HtmlExporter
20 from IPython.frontend.qt.rich_text import HtmlExporter
21 from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font
21 from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font
22 from IPython.utils.text import columnize
22 from IPython.utils.text import columnize
23 from IPython.utils.traitlets import Bool, Enum, Int, Unicode
23 from IPython.utils.traitlets import Bool, Enum, Integer, Unicode
24 from ansi_code_processor import QtAnsiCodeProcessor
24 from ansi_code_processor import QtAnsiCodeProcessor
25 from completion_widget import CompletionWidget
25 from completion_widget import CompletionWidget
26 from kill_ring import QtKillRing
26 from kill_ring import QtKillRing
@@ -59,7 +59,7 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):'
59 ansi_codes = Bool(True, config=True,
59 ansi_codes = Bool(True, config=True,
60 help="Whether to process ANSI escape codes."
60 help="Whether to process ANSI escape codes."
61 )
61 )
62 buffer_size = Int(500, config=True,
62 buffer_size = Integer(500, config=True,
63 help="""
63 help="""
64 The maximum number of lines of text before truncation. Specifying a
64 The maximum number of lines of text before truncation. Specifying a
65 non-positive number disables text truncation (not recommended).
65 non-positive number disables text truncation (not recommended).
@@ -112,7 +112,7 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):'
112 # Monospace should always exist, no need for a fallback
112 # Monospace should always exist, no need for a fallback
113 return 'Monospace'
113 return 'Monospace'
114
114
115 font_size = Int(config=True,
115 font_size = Integer(config=True,
116 help="""The font size. If unconfigured, Qt will be entrusted
116 help="""The font size. If unconfigured, Qt will be entrusted
117 with the size of the font.
117 with the size of the font.
118 """)
118 """)
@@ -42,7 +42,7 b' from IPython.frontend.qt.kernelmanager import QtKernelManager'
42 from IPython.utils.path import filefind
42 from IPython.utils.path import filefind
43 from IPython.utils.py3compat import str_to_bytes
43 from IPython.utils.py3compat import str_to_bytes
44 from IPython.utils.traitlets import (
44 from IPython.utils.traitlets import (
45 Dict, List, Unicode, Int, CaselessStrEnum, CBool, Any
45 Dict, List, Unicode, Integer, CaselessStrEnum, CBool, Any
46 )
46 )
47 from IPython.zmq.ipkernel import (
47 from IPython.zmq.ipkernel import (
48 flags as ipkernel_flags,
48 flags as ipkernel_flags,
@@ -168,13 +168,13 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
168 sshkey = Unicode('', config=True,
168 sshkey = Unicode('', config=True,
169 help="""Path to the ssh key to use for logging in to the ssh server.""")
169 help="""Path to the ssh key to use for logging in to the ssh server.""")
170
170
171 hb_port = Int(0, config=True,
171 hb_port = Integer(0, config=True,
172 help="set the heartbeat port [default: random]")
172 help="set the heartbeat port [default: random]")
173 shell_port = Int(0, config=True,
173 shell_port = Integer(0, config=True,
174 help="set the shell (XREP) port [default: random]")
174 help="set the shell (XREP) port [default: random]")
175 iopub_port = Int(0, config=True,
175 iopub_port = Integer(0, config=True,
176 help="set the iopub (PUB) port [default: random]")
176 help="set the iopub (PUB) port [default: random]")
177 stdin_port = Int(0, config=True,
177 stdin_port = Integer(0, config=True,
178 help="set the stdin (XREQ) port [default: random]")
178 help="set the stdin (XREQ) port [default: random]")
179 connection_file = Unicode('', config=True,
179 connection_file = Unicode('', config=True,
180 help="""JSON file in which to store connection info [default: kernel-<pid>.json]
180 help="""JSON file in which to store connection info [default: kernel-<pid>.json]
@@ -36,7 +36,7 b' from IPython.utils.terminal import toggle_set_term_title, set_term_title'
36 from IPython.utils.process import abbrev_cwd
36 from IPython.utils.process import abbrev_cwd
37 from IPython.utils.warn import warn
37 from IPython.utils.warn import warn
38 from IPython.utils.text import num_ini_spaces
38 from IPython.utils.text import num_ini_spaces
39 from IPython.utils.traitlets import Int, CBool, Unicode
39 from IPython.utils.traitlets import Integer, CBool, Unicode
40
40
41 #-----------------------------------------------------------------------------
41 #-----------------------------------------------------------------------------
42 # Utilities
42 # Utilities
@@ -87,7 +87,7 b' class TerminalInteractiveShell(InteractiveShell):'
87 pager = Unicode('less', config=True,
87 pager = Unicode('less', config=True,
88 help="The shell program to be used for paging.")
88 help="The shell program to be used for paging.")
89
89
90 screen_length = Int(0, config=True,
90 screen_length = Integer(0, config=True,
91 help=
91 help=
92 """Number of lines of your screen, used to control printing of very
92 """Number of lines of your screen, used to control printing of very
93 long strings. Strings longer than this number of lines will be sent
93 long strings. Strings longer than this number of lines will be sent
@@ -38,7 +38,7 b' from IPython.core.profiledir import ProfileDir'
38 from IPython.utils.daemonize import daemonize
38 from IPython.utils.daemonize import daemonize
39 from IPython.utils.importstring import import_item
39 from IPython.utils.importstring import import_item
40 from IPython.utils.sysinfo import num_cpus
40 from IPython.utils.sysinfo import num_cpus
41 from IPython.utils.traitlets import (Int, Unicode, Bool, CFloat, Dict, List, Any,
41 from IPython.utils.traitlets import (Integer, Unicode, Bool, CFloat, Dict, List, Any,
42 DottedObjectName)
42 DottedObjectName)
43
43
44 from IPython.parallel.apps.baseapp import (
44 from IPython.parallel.apps.baseapp import (
@@ -151,7 +151,7 b' class IPClusterStop(BaseParallelApplication):'
151 examples = _stop_examples
151 examples = _stop_examples
152 config_file_name = Unicode(default_config_file_name)
152 config_file_name = Unicode(default_config_file_name)
153
153
154 signal = Int(signal.SIGINT, config=True,
154 signal = Integer(signal.SIGINT, config=True,
155 help="signal to use for stopping processes.")
155 help="signal to use for stopping processes.")
156
156
157 aliases = Dict(stop_aliases)
157 aliases = Dict(stop_aliases)
@@ -229,7 +229,7 b' class IPClusterEngines(BaseParallelApplication):'
229 eslaunchers = [ l for l in launchers if 'EngineSet' in l.__name__]
229 eslaunchers = [ l for l in launchers if 'EngineSet' in l.__name__]
230 return [ProfileDir]+eslaunchers
230 return [ProfileDir]+eslaunchers
231
231
232 n = Int(num_cpus(), config=True,
232 n = Integer(num_cpus(), config=True,
233 help="""The number of engines to start. The default is to use one for each
233 help="""The number of engines to start. The default is to use one for each
234 CPU on your machine""")
234 CPU on your machine""")
235
235
@@ -282,7 +282,7 b' class IPClusterEngines(BaseParallelApplication):'
282 if new:
282 if new:
283 self.log_to_file = True
283 self.log_to_file = True
284
284
285 early_shutdown = Int(30, config=True, help="The timeout (in seconds)")
285 early_shutdown = Integer(30, config=True, help="The timeout (in seconds)")
286 _stopping = False
286 _stopping = False
287
287
288 aliases = Dict(engine_aliases)
288 aliases = Dict(engine_aliases)
@@ -58,7 +58,7 b' from IPython.config.application import Application'
58 from IPython.config.configurable import LoggingConfigurable
58 from IPython.config.configurable import LoggingConfigurable
59 from IPython.utils.text import EvalFormatter
59 from IPython.utils.text import EvalFormatter
60 from IPython.utils.traitlets import (
60 from IPython.utils.traitlets import (
61 Any, Int, CFloat, List, Unicode, Dict, Instance, HasTraits,
61 Any, Integer, CFloat, List, Unicode, Dict, Instance, HasTraits,
62 )
62 )
63 from IPython.utils.path import get_ipython_module_path
63 from IPython.utils.path import get_ipython_module_path
64 from IPython.utils.process import find_cmd, pycmd2argv, FindCmdError
64 from IPython.utils.process import find_cmd, pycmd2argv, FindCmdError
@@ -258,7 +258,7 b' class LocalProcessLauncher(BaseLauncher):'
258 # This is used to to construct self.args, which is passed to
258 # This is used to to construct self.args, which is passed to
259 # spawnProcess.
259 # spawnProcess.
260 cmd_and_args = List([])
260 cmd_and_args = List([])
261 poll_frequency = Int(100) # in ms
261 poll_frequency = Integer(100) # in ms
262
262
263 def __init__(self, work_dir=u'.', config=None, **kwargs):
263 def __init__(self, work_dir=u'.', config=None, **kwargs):
264 super(LocalProcessLauncher, self).__init__(
264 super(LocalProcessLauncher, self).__init__(
@@ -458,7 +458,7 b' class MPIExecLauncher(LocalProcessLauncher):'
458 program_args = List([],
458 program_args = List([],
459 help="The command line argument to the program."
459 help="The command line argument to the program."
460 )
460 )
461 n = Int(1)
461 n = Integer(1)
462
462
463 def find_args(self):
463 def find_args(self):
464 """Build self.args using all the fields."""
464 """Build self.args using all the fields."""
@@ -854,7 +854,7 b' class BatchSystemLauncher(BaseLauncher):'
854 def _queue_changed(self, name, old, new):
854 def _queue_changed(self, name, old, new):
855 self.context[name] = new
855 self.context[name] = new
856
856
857 n = Int(1)
857 n = Integer(1)
858 _n_changed = _queue_changed
858 _n_changed = _queue_changed
859
859
860 # not configurable, override in subclasses
860 # not configurable, override in subclasses
@@ -1129,7 +1129,7 b' class IPClusterLauncher(LocalProcessLauncher):'
1129 ['--clean-logs', '--log-to-file', '--log-level=%i'%logging.INFO], config=True,
1129 ['--clean-logs', '--log-to-file', '--log-level=%i'%logging.INFO], config=True,
1130 help="Command line arguments to pass to ipcluster.")
1130 help="Command line arguments to pass to ipcluster.")
1131 ipcluster_subcommand = Unicode('start')
1131 ipcluster_subcommand = Unicode('start')
1132 ipcluster_n = Int(2)
1132 ipcluster_n = Integer(2)
1133
1133
1134 def find_args(self):
1134 def find_args(self):
1135 return self.ipcluster_cmd + [self.ipcluster_subcommand] + \
1135 return self.ipcluster_cmd + [self.ipcluster_subcommand] + \
@@ -29,7 +29,7 b' from xml.etree import ElementTree as ET'
29
29
30 from IPython.config.configurable import Configurable
30 from IPython.config.configurable import Configurable
31 from IPython.utils.traitlets import (
31 from IPython.utils.traitlets import (
32 Unicode, Int, List, Instance,
32 Unicode, Integer, List, Instance,
33 Enum, Bool
33 Enum, Bool
34 )
34 )
35
35
@@ -81,12 +81,12 b' class WinHPCJob(Configurable):'
81
81
82 job_id = Unicode('')
82 job_id = Unicode('')
83 job_name = Unicode('MyJob', config=True)
83 job_name = Unicode('MyJob', config=True)
84 min_cores = Int(1, config=True)
84 min_cores = Integer(1, config=True)
85 max_cores = Int(1, config=True)
85 max_cores = Integer(1, config=True)
86 min_sockets = Int(1, config=True)
86 min_sockets = Integer(1, config=True)
87 max_sockets = Int(1, config=True)
87 max_sockets = Integer(1, config=True)
88 min_nodes = Int(1, config=True)
88 min_nodes = Integer(1, config=True)
89 max_nodes = Int(1, config=True)
89 max_nodes = Integer(1, config=True)
90 unit_type = Unicode("Core", config=True)
90 unit_type = Unicode("Core", config=True)
91 auto_calculate_min = Bool(True, config=True)
91 auto_calculate_min = Bool(True, config=True)
92 auto_calculate_max = Bool(True, config=True)
92 auto_calculate_max = Bool(True, config=True)
@@ -173,12 +173,12 b' class WinHPCTask(Configurable):'
173 task_id = Unicode('')
173 task_id = Unicode('')
174 task_name = Unicode('')
174 task_name = Unicode('')
175 version = Unicode("2.000")
175 version = Unicode("2.000")
176 min_cores = Int(1, config=True)
176 min_cores = Integer(1, config=True)
177 max_cores = Int(1, config=True)
177 max_cores = Integer(1, config=True)
178 min_sockets = Int(1, config=True)
178 min_sockets = Integer(1, config=True)
179 max_sockets = Int(1, config=True)
179 max_sockets = Integer(1, config=True)
180 min_nodes = Int(1, config=True)
180 min_nodes = Integer(1, config=True)
181 max_nodes = Int(1, config=True)
181 max_nodes = Integer(1, config=True)
182 unit_type = Unicode("Core", config=True)
182 unit_type = Unicode("Core", config=True)
183 command_line = Unicode('', config=True)
183 command_line = Unicode('', config=True)
184 work_directory = Unicode('', config=True)
184 work_directory = Unicode('', config=True)
@@ -255,12 +255,12 b' class IPControllerTask(WinHPCTask):'
255 # I don't want these to be configurable
255 # I don't want these to be configurable
256 std_out_file_path = Unicode('', config=False)
256 std_out_file_path = Unicode('', config=False)
257 std_err_file_path = Unicode('', config=False)
257 std_err_file_path = Unicode('', config=False)
258 min_cores = Int(1, config=False)
258 min_cores = Integer(1, config=False)
259 max_cores = Int(1, config=False)
259 max_cores = Integer(1, config=False)
260 min_sockets = Int(1, config=False)
260 min_sockets = Integer(1, config=False)
261 max_sockets = Int(1, config=False)
261 max_sockets = Integer(1, config=False)
262 min_nodes = Int(1, config=False)
262 min_nodes = Integer(1, config=False)
263 max_nodes = Int(1, config=False)
263 max_nodes = Integer(1, config=False)
264 unit_type = Unicode("Core", config=False)
264 unit_type = Unicode("Core", config=False)
265 work_directory = Unicode('', config=False)
265 work_directory = Unicode('', config=False)
266
266
@@ -283,12 +283,12 b' class IPEngineTask(WinHPCTask):'
283 # I don't want these to be configurable
283 # I don't want these to be configurable
284 std_out_file_path = Unicode('', config=False)
284 std_out_file_path = Unicode('', config=False)
285 std_err_file_path = Unicode('', config=False)
285 std_err_file_path = Unicode('', config=False)
286 min_cores = Int(1, config=False)
286 min_cores = Integer(1, config=False)
287 max_cores = Int(1, config=False)
287 max_cores = Integer(1, config=False)
288 min_sockets = Int(1, config=False)
288 min_sockets = Integer(1, config=False)
289 max_sockets = Int(1, config=False)
289 max_sockets = Integer(1, config=False)
290 min_nodes = Int(1, config=False)
290 min_nodes = Integer(1, config=False)
291 max_nodes = Int(1, config=False)
291 max_nodes = Integer(1, config=False)
292 unit_type = Unicode("Core", config=False)
292 unit_type = Unicode("Core", config=False)
293 work_directory = Unicode('', config=False)
293 work_directory = Unicode('', config=False)
294
294
@@ -35,7 +35,7 b' from IPython.core.application import BaseIPythonApplication'
35 from IPython.utils.jsonutil import rekey
35 from IPython.utils.jsonutil import rekey
36 from IPython.utils.localinterfaces import LOCAL_IPS
36 from IPython.utils.localinterfaces import LOCAL_IPS
37 from IPython.utils.path import get_ipython_dir
37 from IPython.utils.path import get_ipython_dir
38 from IPython.utils.traitlets import (HasTraits, Int, Instance, Unicode,
38 from IPython.utils.traitlets import (HasTraits, Integer, Instance, Unicode,
39 Dict, List, Bool, Set)
39 Dict, List, Bool, Set)
40 from IPython.external.decorator import decorator
40 from IPython.external.decorator import decorator
41 from IPython.external.ssh import tunnel
41 from IPython.external.ssh import tunnel
@@ -279,8 +279,8 b' class Client(HasTraits):'
279 _task_socket=Instance('zmq.Socket')
279 _task_socket=Instance('zmq.Socket')
280 _task_scheme=Unicode()
280 _task_scheme=Unicode()
281 _closed = False
281 _closed = False
282 _ignored_control_replies=Int(0)
282 _ignored_control_replies=Integer(0)
283 _ignored_hub_replies=Int(0)
283 _ignored_hub_replies=Integer(0)
284
284
285 def __new__(self, *args, **kw):
285 def __new__(self, *args, **kw):
286 # don't raise on positional args
286 # don't raise on positional args
@@ -24,7 +24,9 b' from types import ModuleType'
24 import zmq
24 import zmq
25
25
26 from IPython.testing.skipdoctest import skip_doctest
26 from IPython.testing.skipdoctest import skip_doctest
27 from IPython.utils.traitlets import HasTraits, Any, Bool, List, Dict, Set, Int, Instance, CFloat, CInt
27 from IPython.utils.traitlets import (
28 HasTraits, Any, Bool, List, Dict, Set, Instance, CFloat, Integer
29 )
28 from IPython.external.decorator import decorator
30 from IPython.external.decorator import decorator
29
31
30 from IPython.parallel import util
32 from IPython.parallel import util
@@ -795,7 +797,7 b' class LoadBalancedView(View):'
795 follow=Any()
797 follow=Any()
796 after=Any()
798 after=Any()
797 timeout=CFloat()
799 timeout=CFloat()
798 retries = CInt(0)
800 retries = Integer(0)
799
801
800 _task_scheme = Any()
802 _task_scheme = Any()
801 _flag_names = List(['targets', 'block', 'track', 'follow', 'after', 'timeout', 'retries'])
803 _flag_names = List(['targets', 'block', 'track', 'follow', 'after', 'timeout', 'retries'])
@@ -29,7 +29,7 b' from zmq.eventloop.zmqstream import ZMQStream'
29 # internal:
29 # internal:
30 from IPython.utils.importstring import import_item
30 from IPython.utils.importstring import import_item
31 from IPython.utils.traitlets import (
31 from IPython.utils.traitlets import (
32 HasTraits, Instance, Int, Unicode, Dict, Set, Tuple, CBytes, DottedObjectName
32 HasTraits, Instance, Integer, Unicode, Dict, Set, Tuple, CBytes, DottedObjectName
33 )
33 )
34
34
35 from IPython.parallel import error, util
35 from IPython.parallel import error, util
@@ -109,7 +109,7 b' class EngineConnector(HasTraits):'
109 registration (str): identity of registration XREQ socket
109 registration (str): identity of registration XREQ socket
110 heartbeat (str): identity of heartbeat XREQ socket
110 heartbeat (str): identity of heartbeat XREQ socket
111 """
111 """
112 id=Int(0)
112 id=Integer(0)
113 queue=CBytes()
113 queue=CBytes()
114 control=CBytes()
114 control=CBytes()
115 registration=CBytes()
115 registration=CBytes()
@@ -120,42 +120,42 b' class HubFactory(RegistrationFactory):'
120 """The Configurable for setting up a Hub."""
120 """The Configurable for setting up a Hub."""
121
121
122 # port-pairs for monitoredqueues:
122 # port-pairs for monitoredqueues:
123 hb = Tuple(Int,Int,config=True,
123 hb = Tuple(Integer,Integer,config=True,
124 help="""XREQ/SUB Port pair for Engine heartbeats""")
124 help="""XREQ/SUB Port pair for Engine heartbeats""")
125 def _hb_default(self):
125 def _hb_default(self):
126 return tuple(util.select_random_ports(2))
126 return tuple(util.select_random_ports(2))
127
127
128 mux = Tuple(Int,Int,config=True,
128 mux = Tuple(Integer,Integer,config=True,
129 help="""Engine/Client Port pair for MUX queue""")
129 help="""Engine/Client Port pair for MUX queue""")
130
130
131 def _mux_default(self):
131 def _mux_default(self):
132 return tuple(util.select_random_ports(2))
132 return tuple(util.select_random_ports(2))
133
133
134 task = Tuple(Int,Int,config=True,
134 task = Tuple(Integer,Integer,config=True,
135 help="""Engine/Client Port pair for Task queue""")
135 help="""Engine/Client Port pair for Task queue""")
136 def _task_default(self):
136 def _task_default(self):
137 return tuple(util.select_random_ports(2))
137 return tuple(util.select_random_ports(2))
138
138
139 control = Tuple(Int,Int,config=True,
139 control = Tuple(Integer,Integer,config=True,
140 help="""Engine/Client Port pair for Control queue""")
140 help="""Engine/Client Port pair for Control queue""")
141
141
142 def _control_default(self):
142 def _control_default(self):
143 return tuple(util.select_random_ports(2))
143 return tuple(util.select_random_ports(2))
144
144
145 iopub = Tuple(Int,Int,config=True,
145 iopub = Tuple(Integer,Integer,config=True,
146 help="""Engine/Client Port pair for IOPub relay""")
146 help="""Engine/Client Port pair for IOPub relay""")
147
147
148 def _iopub_default(self):
148 def _iopub_default(self):
149 return tuple(util.select_random_ports(2))
149 return tuple(util.select_random_ports(2))
150
150
151 # single ports:
151 # single ports:
152 mon_port = Int(config=True,
152 mon_port = Integer(config=True,
153 help="""Monitor (SUB) port for queue traffic""")
153 help="""Monitor (SUB) port for queue traffic""")
154
154
155 def _mon_port_default(self):
155 def _mon_port_default(self):
156 return util.select_random_ports(1)[0]
156 return util.select_random_ports(1)[0]
157
157
158 notifier_port = Int(config=True,
158 notifier_port = Integer(config=True,
159 help="""PUB port for sending engine status notifications""")
159 help="""PUB port for sending engine status notifications""")
160
160
161 def _notifier_port_default(self):
161 def _notifier_port_default(self):
@@ -331,8 +331,8 b' class Hub(SessionFactory):'
331 dead_engines=Set() # completed msg_ids keyed by engine_id
331 dead_engines=Set() # completed msg_ids keyed by engine_id
332 unassigned=Set() # set of task msg_ds not yet assigned a destination
332 unassigned=Set() # set of task msg_ds not yet assigned a destination
333 incoming_registrations=Dict()
333 incoming_registrations=Dict()
334 registration_timeout=Int()
334 registration_timeout=Integer()
335 _idcounter=Int(0)
335 _idcounter=Integer(0)
336
336
337 # objects from constructor:
337 # objects from constructor:
338 query=Instance(ZMQStream)
338 query=Instance(ZMQStream)
@@ -40,7 +40,7 b' from zmq.eventloop import ioloop, zmqstream'
40 from IPython.external.decorator import decorator
40 from IPython.external.decorator import decorator
41 from IPython.config.application import Application
41 from IPython.config.application import Application
42 from IPython.config.loader import Config
42 from IPython.config.loader import Config
43 from IPython.utils.traitlets import Instance, Dict, List, Set, Int, Enum, CBytes
43 from IPython.utils.traitlets import Instance, Dict, List, Set, Integer, Enum, CBytes
44
44
45 from IPython.parallel import error
45 from IPython.parallel import error
46 from IPython.parallel.factory import SessionFactory
46 from IPython.parallel.factory import SessionFactory
@@ -131,7 +131,7 b' class TaskScheduler(SessionFactory):'
131
131
132 """
132 """
133
133
134 hwm = Int(0, config=True, shortname='hwm',
134 hwm = Integer(0, config=True, shortname='hwm',
135 help="""specify the High Water Mark (HWM) for the downstream
135 help="""specify the High Water Mark (HWM) for the downstream
136 socket in the Task scheduler. This is the maximum number
136 socket in the Task scheduler. This is the maximum number
137 of allowed outstanding tasks on each engine."""
137 of allowed outstanding tasks on each engine."""
@@ -25,7 +25,7 b' from zmq.eventloop import ioloop, zmqstream'
25 from IPython.external.ssh import tunnel
25 from IPython.external.ssh import tunnel
26 # internal
26 # internal
27 from IPython.utils.traitlets import (
27 from IPython.utils.traitlets import (
28 Instance, Dict, Int, Type, CFloat, Unicode, CBytes, Bool
28 Instance, Dict, Integer, Type, CFloat, Unicode, CBytes, Bool
29 )
29 )
30 # from IPython.utils.localinterfaces import LOCALHOST
30 # from IPython.utils.localinterfaces import LOCALHOST
31
31
@@ -63,7 +63,7 b' class EngineFactory(RegistrationFactory):'
63
63
64 # not configurable:
64 # not configurable:
65 user_ns=Dict()
65 user_ns=Dict()
66 id=Int(allow_none=True)
66 id=Integer(allow_none=True)
67 registrar=Instance('zmq.eventloop.zmqstream.ZMQStream')
67 registrar=Instance('zmq.eventloop.zmqstream.ZMQStream')
68 kernel=Instance(Kernel)
68 kernel=Instance(Kernel)
69
69
@@ -34,7 +34,7 b' import zmq'
34 from zmq.eventloop import ioloop, zmqstream
34 from zmq.eventloop import ioloop, zmqstream
35
35
36 # Local imports.
36 # Local imports.
37 from IPython.utils.traitlets import Instance, List, Int, Dict, Set, Unicode, CBytes
37 from IPython.utils.traitlets import Instance, List, Integer, Dict, Set, Unicode, CBytes
38 from IPython.zmq.completer import KernelCompleter
38 from IPython.zmq.completer import KernelCompleter
39
39
40 from IPython.parallel.error import wrap_exception
40 from IPython.parallel.error import wrap_exception
@@ -74,7 +74,7 b' class Kernel(SessionFactory):'
74 help="List of lines to execute")
74 help="List of lines to execute")
75
75
76 # identities:
76 # identities:
77 int_id = Int(-1)
77 int_id = Integer(-1)
78 bident = CBytes()
78 bident = CBytes()
79 ident = Unicode()
79 ident = Unicode()
80 def _ident_changed(self, name, old, new):
80 def _ident_changed(self, name, old, new):
@@ -24,7 +24,7 b' import zmq'
24 from zmq.eventloop.ioloop import IOLoop
24 from zmq.eventloop.ioloop import IOLoop
25
25
26 from IPython.config.configurable import Configurable
26 from IPython.config.configurable import Configurable
27 from IPython.utils.traitlets import Int, Instance, Unicode
27 from IPython.utils.traitlets import Integer, Instance, Unicode
28
28
29 from IPython.parallel.util import select_random_ports
29 from IPython.parallel.util import select_random_ports
30 from IPython.zmq.session import Session, SessionFactory
30 from IPython.zmq.session import Session, SessionFactory
@@ -48,7 +48,7 b' class RegistrationFactory(SessionFactory):'
48 help="""The IP address for registration. This is generally either
48 help="""The IP address for registration. This is generally either
49 '127.0.0.1' for loopback only or '*' for all interfaces.
49 '127.0.0.1' for loopback only or '*' for all interfaces.
50 [default: '127.0.0.1']""")
50 [default: '127.0.0.1']""")
51 regport = Int(config=True,
51 regport = Integer(config=True,
52 help="""The port on which the Hub listens for registration.""")
52 help="""The port on which the Hub listens for registration.""")
53 def _regport_default(self):
53 def _regport_default(self):
54 return select_random_ports(1)[0]
54 return select_random_ports(1)[0]
@@ -26,11 +26,12 b' from unittest import TestCase'
26
26
27 from IPython.utils.traitlets import (
27 from IPython.utils.traitlets import (
28 HasTraits, MetaHasTraits, TraitType, Any, CBytes,
28 HasTraits, MetaHasTraits, TraitType, Any, CBytes,
29 Int, Long, Float, Complex, Bytes, Unicode, TraitError,
29 Int, Long, Integer, Float, Complex, Bytes, Unicode, TraitError,
30 Undefined, Type, This, Instance, TCPAddress, List, Tuple,
30 Undefined, Type, This, Instance, TCPAddress, List, Tuple,
31 ObjectName, DottedObjectName
31 ObjectName, DottedObjectName
32 )
32 )
33 from IPython.utils import py3compat
33 from IPython.utils import py3compat
34 from IPython.testing.decorators import skipif
34
35
35 #-----------------------------------------------------------------------------
36 #-----------------------------------------------------------------------------
36 # Helper classes for testing
37 # Helper classes for testing
@@ -631,6 +632,11 b' class TraitTestBase(TestCase):'
631 if hasattr(self, '_default_value'):
632 if hasattr(self, '_default_value'):
632 self.assertEquals(self._default_value, self.obj.value)
633 self.assertEquals(self._default_value, self.obj.value)
633
634
635 def tearDown(self):
636 # restore default value after tests, if set
637 if hasattr(self, '_default_value'):
638 self.obj.value = self._default_value
639
634
640
635 class AnyTrait(HasTraits):
641 class AnyTrait(HasTraits):
636
642
@@ -658,7 +664,7 b' class TestInt(TraitTestBase):'
658 10.1, -10.1, '10L', '-10L', '10.1', '-10.1', u'10L',
664 10.1, -10.1, '10L', '-10L', '10.1', '-10.1', u'10L',
659 u'-10L', u'10.1', u'-10.1', '10', '-10', u'10', u'-10']
665 u'-10L', u'10.1', u'-10.1', '10', '-10', u'10', u'-10']
660 if not py3compat.PY3:
666 if not py3compat.PY3:
661 _bad_values.extend([10L, -10L])
667 _bad_values.extend([10L, -10L, 10*sys.maxint, -10*sys.maxint])
662
668
663
669
664 class LongTrait(HasTraits):
670 class LongTrait(HasTraits):
@@ -675,6 +681,35 b' class TestLong(TraitTestBase):'
675 None, 1j, 10.1, -10.1, '10', '-10', '10L', '-10L', '10.1',
681 None, 1j, 10.1, -10.1, '10', '-10', '10L', '-10L', '10.1',
676 '-10.1', u'10', u'-10', u'10L', u'-10L', u'10.1',
682 '-10.1', u'10', u'-10', u'10L', u'-10L', u'10.1',
677 u'-10.1']
683 u'-10.1']
684 if not py3compat.PY3:
685 # maxint undefined on py3, because int == long
686 _good_values.extend([10*sys.maxint, -10*sys.maxint])
687
688 @skipif(py3compat.PY3, "not relevant on py3")
689 def test_cast_small(self):
690 """Long casts ints to long"""
691 self.obj.value = 10
692 self.assertEquals(type(self.obj.value), long)
693
694
695 class IntegerTrait(HasTraits):
696 value = Integer(1)
697
698 class TestInteger(TestLong):
699 obj = IntegerTrait()
700 _default_value = 1
701
702 def coerce(self, n):
703 return int(n)
704
705 @skipif(py3compat.PY3, "not relevant on py3")
706 def test_cast_small(self):
707 """Integer casts small longs to int"""
708 if py3compat.PY3:
709 raise SkipTest("not relevant on py3")
710
711 self.obj.value = 100L
712 self.assertEquals(type(self.obj.value), int)
678
713
679
714
680 class FloatTrait(HasTraits):
715 class FloatTrait(HasTraits):
@@ -863,10 +863,10 b' class Any(TraitType):'
863
863
864
864
865 class Int(TraitType):
865 class Int(TraitType):
866 """A integer trait."""
866 """An int trait."""
867
867
868 default_value = 0
868 default_value = 0
869 info_text = 'an integer'
869 info_text = 'an int'
870
870
871 def validate(self, obj, value):
871 def validate(self, obj, value):
872 if isinstance(value, int):
872 if isinstance(value, int):
@@ -884,6 +884,7 b' class CInt(Int):'
884
884
885 if py3compat.PY3:
885 if py3compat.PY3:
886 Long, CLong = Int, CInt
886 Long, CLong = Int, CInt
887 Integer = Int
887 else:
888 else:
888 class Long(TraitType):
889 class Long(TraitType):
889 """A long integer trait."""
890 """A long integer trait."""
@@ -908,6 +909,24 b' else:'
908 except:
909 except:
909 self.error(obj, value)
910 self.error(obj, value)
910
911
912 class Integer(TraitType):
913 """An integer trait.
914
915 Longs that are unnecessary (<= sys.maxint) are cast to ints."""
916
917 default_value = 0
918 info_text = 'an integer'
919
920 def validate(self, obj, value):
921 if isinstance(value, int):
922 return value
923 elif isinstance(value, long):
924 # downcast longs that fit in int:
925 # note that int(n > sys.maxint) returns a long, so
926 # we don't need a condition on this cast
927 return int(value)
928 self.error(obj, value)
929
911
930
912 class Float(TraitType):
931 class Float(TraitType):
913 """A float trait."""
932 """A float trait."""
@@ -39,7 +39,7 b' from IPython.utils import py3compat'
39 from IPython.utils.jsonutil import json_clean
39 from IPython.utils.jsonutil import json_clean
40 from IPython.lib import pylabtools
40 from IPython.lib import pylabtools
41 from IPython.utils.traitlets import (
41 from IPython.utils.traitlets import (
42 Any, List, Instance, Float, Dict, Bool, Int, Unicode, CaselessStrEnum
42 Any, List, Instance, Float, Dict, Bool, Unicode, CaselessStrEnum
43 )
43 )
44
44
45 from entry_point import base_launch_kernel
45 from entry_point import base_launch_kernel
@@ -32,7 +32,7 b' from IPython.utils import io'
32 from IPython.utils.localinterfaces import LOCALHOST
32 from IPython.utils.localinterfaces import LOCALHOST
33 from IPython.utils.path import filefind
33 from IPython.utils.path import filefind
34 from IPython.utils.py3compat import str_to_bytes
34 from IPython.utils.py3compat import str_to_bytes
35 from IPython.utils.traitlets import (Any, Instance, Dict, Unicode, Int, Bool,
35 from IPython.utils.traitlets import (Any, Instance, Dict, Unicode, Integer, Bool,
36 DottedObjectName)
36 DottedObjectName)
37 from IPython.utils.importstring import import_item
37 from IPython.utils.importstring import import_item
38 # local imports
38 # local imports
@@ -107,10 +107,10 b' class KernelApp(BaseIPythonApplication):'
107 # connection info:
107 # connection info:
108 ip = Unicode(LOCALHOST, config=True,
108 ip = Unicode(LOCALHOST, config=True,
109 help="Set the IP or interface on which the kernel will listen.")
109 help="Set the IP or interface on which the kernel will listen.")
110 hb_port = Int(0, config=True, help="set the heartbeat port [default: random]")
110 hb_port = Integer(0, config=True, help="set the heartbeat port [default: random]")
111 shell_port = Int(0, config=True, help="set the shell (XREP) port [default: random]")
111 shell_port = Integer(0, config=True, help="set the shell (XREP) port [default: random]")
112 iopub_port = Int(0, config=True, help="set the iopub (PUB) port [default: random]")
112 iopub_port = Integer(0, config=True, help="set the iopub (PUB) port [default: random]")
113 stdin_port = Int(0, config=True, help="set the stdin (XREQ) port [default: random]")
113 stdin_port = Integer(0, config=True, help="set the stdin (XREQ) port [default: random]")
114 connection_file = Unicode('', config=True,
114 connection_file = Unicode('', config=True,
115 help="""JSON file in which to store connection info [default: kernel-<pid>.json]
115 help="""JSON file in which to store connection info [default: kernel-<pid>.json]
116
116
@@ -128,11 +128,11 b' class KernelApp(BaseIPythonApplication):'
128 config=True, help="The importstring for the DisplayHook factory")
128 config=True, help="The importstring for the DisplayHook factory")
129
129
130 # polling
130 # polling
131 parent = Int(0, config=True,
131 parent = Integer(0, config=True,
132 help="""kill this process if its parent dies. On Windows, the argument
132 help="""kill this process if its parent dies. On Windows, the argument
133 specifies the HANDLE of the parent process, otherwise it is simply boolean.
133 specifies the HANDLE of the parent process, otherwise it is simply boolean.
134 """)
134 """)
135 interrupt = Int(0, config=True,
135 interrupt = Integer(0, config=True,
136 help="""ONLY USED ON WINDOWS
136 help="""ONLY USED ON WINDOWS
137 Interrupt this process when the parent is signalled.
137 Interrupt this process when the parent is signalled.
138 """)
138 """)
@@ -35,7 +35,7 b' from zmq.eventloop import ioloop'
35 from IPython.config.loader import Config
35 from IPython.config.loader import Config
36 from IPython.utils.localinterfaces import LOCALHOST, LOCAL_IPS
36 from IPython.utils.localinterfaces import LOCALHOST, LOCAL_IPS
37 from IPython.utils.traitlets import (
37 from IPython.utils.traitlets import (
38 HasTraits, Any, Instance, Type, Unicode, Int, Bool
38 HasTraits, Any, Instance, Type, Unicode, Integer, Bool
39 )
39 )
40 from IPython.utils.py3compat import str_to_bytes
40 from IPython.utils.py3compat import str_to_bytes
41 from IPython.zmq.entry_point import write_connection_file
41 from IPython.zmq.entry_point import write_connection_file
@@ -713,10 +713,10 b' class KernelManager(HasTraits):'
713 def _ip_changed(self, name, old, new):
713 def _ip_changed(self, name, old, new):
714 if new == '*':
714 if new == '*':
715 self.ip = '0.0.0.0'
715 self.ip = '0.0.0.0'
716 shell_port = Int(0)
716 shell_port = Integer(0)
717 iopub_port = Int(0)
717 iopub_port = Integer(0)
718 stdin_port = Int(0)
718 stdin_port = Integer(0)
719 hb_port = Int(0)
719 hb_port = Integer(0)
720
720
721 # The classes to use for the various channels.
721 # The classes to use for the various channels.
722 shell_channel_class = Type(ShellSocketChannel)
722 shell_channel_class = Type(ShellSocketChannel)
General Comments 0
You need to be logged in to leave comments. Login now