Python IPython.__version__() Examples

The following are 21 code examples of IPython.__version__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module IPython , or try the search function .
Example #1
Source File: ipython_support.py    From rekall with GNU General Public License v2.0 6 votes vote down vote up
def init_inspector(self):
        super(RekallShell, self).init_inspector()

        # This is a hack but seems the only way to make get_ipython() work
        # properly.
        InteractiveShell._instance = self
        ipython_version = IPython.__version__

        # IPython 5 (4 should work too) is the one we standardize on right
        # now. This means we support earlier ones but turn off the bells and
        # whistles.
        if "4.0.0" <= ipython_version < "7.0.0":
            self.inspector = RekallObjectInspector()

        else:
            self.user_ns.session.logging.warn(
                "Warning: IPython version %s not fully supported. "
                "We recommend installing IPython version 5.",
                ipython_version) 
Example #2
Source File: ipython_view.py    From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    '''
    Generate prompt depending on is_continuation value

    @param is_continuation
    @type is_continuation: boolean 

    @return: The prompt string representation
    @rtype: string

    '''

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #3
Source File: ipython_view.py    From ns3-load-balance with GNU General Public License v2.0 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    '''
    Generate prompt depending on is_continuation value

    @param is_continuation
    @type is_continuation: boolean 

    @return: The prompt string representation
    @rtype: string

    '''

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #4
Source File: ipython_view.py    From 802.11ah-ns3 with GNU General Public License v2.0 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    '''
    Generate prompt depending on is_continuation value

    @param is_continuation
    @type is_continuation: boolean 

    @return: The prompt string representation
    @rtype: string

    '''

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #5
Source File: ipython_view.py    From royal-chaos with MIT License 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    """!
    Generate prompt depending on is_continuation value

    @param is_continuation
    @return: The prompt string representation

    """

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #6
Source File: ipython_view.py    From ns-3-dev-git with GNU General Public License v2.0 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    '''
    Generate prompt depending on is_continuation value

    @param is_continuation
    @type is_continuation: boolean 

    @return: The prompt string representation
    @rtype: string

    '''

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #7
Source File: IPythonConf.py    From trappy with Apache License 2.0 6 votes vote down vote up
def get_ipython_dir(profile=None):
    """Returns the base directory of the IPython server

    :param profile: The name of the IPython profile
    :type profile: str
    """

    if not check_ipython():
        raise ImportError("Cannot Find IPython Environment")

    import IPython
    # IPython 4.0+ changes the position of files in the profile
    # directory
    if V(IPython.__version__) >= V('4.0.0'):
        from jupyter_core.paths import jupyter_data_dir
        return os.path.join(
            jupyter_data_dir(),
            IPYTHON_V4_BASE.strip("/"))
    else:
        if not profile:
            profile = get_profile_name()
        return os.path.join(
            IPython.utils.path.locate_profile(
                profile),
            IPYTHON_V3_BASE.strip("/")) 
Example #8
Source File: ipython_view.py    From Tocino with GNU General Public License v2.0 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    '''
    Generate prompt depending on is_continuation value

    @param is_continuation
    @type is_continuation: boolean 

    @return: The prompt string representation
    @rtype: string

    '''

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #9
Source File: IPythonConf.py    From trappy with Apache License 2.0 6 votes vote down vote up
def get_ipython_dir(profile=None):
    """Returns the base directory of the IPython server

    :param profile: The name of the IPython profile
    :type profile: str
    """

    if not check_ipython():
        raise ImportError("Cannot Find IPython Environment")

    import IPython
    # IPython 4.0+ changes the position of files in the profile
    # directory
    if V(IPython.__version__) >= V('4.0.0'):
        from jupyter_core.paths import jupyter_data_dir
        return os.path.join(
            jupyter_data_dir(),
            IPYTHON_V4_BASE.strip("/"))
    else:
        if not profile:
            profile = get_profile_name()
        return os.path.join(
            IPython.utils.path.locate_profile(
                profile),
            IPYTHON_V3_BASE.strip("/")) 
Example #10
Source File: ipython_view.py    From ns3-802.11ad with GNU General Public License v2.0 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    """!
    Generate prompt depending on is_continuation value

    @param is_continuation
    @return: The prompt string representation

    """

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #11
Source File: ipython_view.py    From ns3-ecn-sharp with GNU General Public License v2.0 6 votes vote down vote up
def generatePrompt(self, is_continuation):
    '''
    Generate prompt depending on is_continuation value

    @param is_continuation
    @type is_continuation: boolean 

    @return: The prompt string representation
    @rtype: string

    '''

    # Backwards compatibility with ipyton-0.11
    #
    ver = IPython.__version__
    if '0.11' in ver:
        prompt = self.IP.hooks.generate_prompt(is_continuation)
    else:
        if is_continuation:
            prompt = self.IP.prompt_manager.render('in2')
        else:
            prompt = self.IP.prompt_manager.render('in')

    return prompt 
Example #12
Source File: flask_shell_ipython.py    From flask-shell-ipython with MIT License 5 votes vote down vote up
def shell(ipython_args):
    """Runs a shell in the app context.

    Runs an interactive Python shell in the context of a given
    Flask application. The application will populate the default
    namespace of this shell according to it's configuration.
    This is useful for executing small snippets of management code
    without having to manually configuring the application.
    """
    import IPython
    from IPython.terminal.ipapp import load_default_config
    from traitlets.config.loader import Config
    from flask.globals import _app_ctx_stack

    app = _app_ctx_stack.top.app

    if 'IPYTHON_CONFIG' in app.config:
        config = Config(app.config['IPYTHON_CONFIG'])
    else:
        config = load_default_config()

    config.TerminalInteractiveShell.banner1 = '''Python %s on %s
IPython: %s
App: %s [%s]
Instance: %s''' % (sys.version,
                   sys.platform,
                   IPython.__version__,
                   app.import_name,
                   app.env,
                   app.instance_path)

    IPython.start_ipython(
        argv=ipython_args,
        user_ns=app.make_shell_context(),
        config=config,
    ) 
Example #13
Source File: ipynb.py    From python-highcharts with MIT License 5 votes vote down vote up
def _setup_ipython_formatter(ip):
        ''' Set up the ipython formatter to display HTML formatted output inline'''
        from IPython import __version__ as IPython_version
        from .highcharts.highcharts import Highchart 
        from .highmaps.highmaps import Highmap
        from .highstock.highstock import Highstock

        if IPython_version >= '0.11':
            html_formatter = ip.display_formatter.formatters['text/html']
            
            for chart_type in [Highchart, Highmap, Highstock]:
                html_formatter.for_type(chart_type, _print_html) 
Example #14
Source File: IPythonConf.py    From trappy with Apache License 2.0 5 votes vote down vote up
def add_web_base(path):
    """Add the base of the IPython dependency URLs

    :param path: The path to be augmented with the
        webserver base
    :type path: str
    """

    import IPython
    if V(IPython.__version__) >= V('4.0.0'):
        return os.path.join(IPYTHON_V4_BASE, path)
    else:
        return os.path.join(IPYTHON_V3_BASE, path) 
Example #15
Source File: IPythonConf.py    From trappy with Apache License 2.0 5 votes vote down vote up
def add_web_base(path):
    """Add the base of the IPython dependency URLs

    :param path: The path to be augmented with the
        webserver base
    :type path: str
    """

    import IPython
    if V(IPython.__version__) >= V('4.0.0'):
        return os.path.join(IPYTHON_V4_BASE, path)
    else:
        return os.path.join(IPYTHON_V3_BASE, path) 
Example #16
Source File: conf.py    From oggm with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def write_index():
    """This is to write the docs for the index automatically."""

    here = os.path.dirname(__file__)
    filename = os.path.join(here, '_generated', 'version_text.txt')

    try:
        os.makedirs(os.path.dirname(filename))
    except FileExistsError:
        pass

    text = text_version if '+' not in oggm.__version__ else text_dev

    with open(filename, 'w') as f:
        f.write(text) 
Example #17
Source File: format.py    From Splunking-Crime with GNU Affero General Public License v3.0 4 votes vote down vote up
def write_result(self, buf):
        indent = 0
        frame = self.frame

        _classes = ['dataframe']  # Default class.
        if self.classes is not None:
            if isinstance(self.classes, str):
                self.classes = self.classes.split()
            if not isinstance(self.classes, (list, tuple)):
                raise AssertionError('classes must be list or tuple, not {typ}'
                                     .format(typ=type(self.classes)))
            _classes.extend(self.classes)

        if self.notebook:
            div_style = ''
            try:
                import IPython
                if IPython.__version__ < LooseVersion('3.0.0'):
                    div_style = ' style="max-width:1500px;overflow:auto;"'
            except (ImportError, AttributeError):
                pass

            self.write('<div{style}>'.format(style=div_style))

        self.write_style()
        self.write('<table border="{border}" class="{cls}">'
                   .format(border=self.border, cls=' '.join(_classes)), indent)

        indent += self.indent_delta
        indent = self._write_header(indent)
        indent = self._write_body(indent)

        self.write('</table>', indent)
        if self.should_show_dimensions:
            by = chr(215) if compat.PY3 else unichr(215)  # ×
            self.write(u('<p>{rows} rows {by} {cols} columns</p>')
                       .format(rows=len(frame),
                               by=by,
                               cols=len(frame.columns)))

        if self.notebook:
            self.write('</div>')

        _put_lines(buf, self.elements) 
Example #18
Source File: format.py    From elasticintel with GNU General Public License v3.0 4 votes vote down vote up
def write_result(self, buf):
        indent = 0
        frame = self.frame

        _classes = ['dataframe']  # Default class.
        if self.classes is not None:
            if isinstance(self.classes, str):
                self.classes = self.classes.split()
            if not isinstance(self.classes, (list, tuple)):
                raise AssertionError('classes must be list or tuple, not {typ}'
                                     .format(typ=type(self.classes)))
            _classes.extend(self.classes)

        if self.notebook:
            div_style = ''
            try:
                import IPython
                if IPython.__version__ < LooseVersion('3.0.0'):
                    div_style = ' style="max-width:1500px;overflow:auto;"'
            except (ImportError, AttributeError):
                pass

            self.write('<div{style}>'.format(style=div_style))

        self.write_style()
        self.write('<table border="{border}" class="{cls}">'
                   .format(border=self.border, cls=' '.join(_classes)), indent)

        indent += self.indent_delta
        indent = self._write_header(indent)
        indent = self._write_body(indent)

        self.write('</table>', indent)
        if self.should_show_dimensions:
            by = chr(215) if compat.PY3 else unichr(215)  # ×
            self.write(u('<p>{rows} rows {by} {cols} columns</p>')
                       .format(rows=len(frame),
                               by=by,
                               cols=len(frame.columns)))

        if self.notebook:
            self.write('</div>')

        _put_lines(buf, self.elements) 
Example #19
Source File: test_magics.py    From python-bigquery with Apache License 2.0 4 votes vote down vote up
def test_bigquery_magic_with_bqstorage_from_argument(monkeypatch):
    ip = IPython.get_ipython()
    ip.extension_manager.load_extension("google.cloud.bigquery")
    mock_credentials = mock.create_autospec(
        google.auth.credentials.Credentials, instance=True
    )

    # Set up the context with monkeypatch so that it's reset for subsequent
    # tests.
    monkeypatch.setattr(magics.context, "credentials", mock_credentials)

    # Mock out the BigQuery Storage API.
    bqstorage_mock = mock.create_autospec(bigquery_storage_v1.BigQueryReadClient)
    bqstorage_instance_mock = mock.create_autospec(
        bigquery_storage_v1.BigQueryReadClient, instance=True
    )
    bqstorage_instance_mock.transport = mock.Mock()
    bqstorage_mock.return_value = bqstorage_instance_mock
    bqstorage_client_patch = mock.patch(
        "google.cloud.bigquery_storage_v1.BigQueryReadClient", bqstorage_mock
    )

    sql = "SELECT 17 AS num"
    result = pandas.DataFrame([17], columns=["num"])
    run_query_patch = mock.patch(
        "google.cloud.bigquery.magics._run_query", autospec=True
    )
    query_job_mock = mock.create_autospec(
        google.cloud.bigquery.job.QueryJob, instance=True
    )
    query_job_mock.to_dataframe.return_value = result
    with run_query_patch as run_query_mock, bqstorage_client_patch, warnings.catch_warnings(
        record=True
    ) as warned:
        run_query_mock.return_value = query_job_mock

        return_value = ip.run_cell_magic("bigquery", "--use_bqstorage_api", sql)

    # Deprecation warning should have been issued.
    def warning_match(warning):
        message = str(warning).lower()
        return "deprecated" in message and "use_bqstorage_api" in message

    expected_warnings = list(filter(warning_match, warned))
    assert len(expected_warnings) == 1

    assert len(bqstorage_mock.call_args_list) == 1
    kwargs = bqstorage_mock.call_args_list[0].kwargs
    assert kwargs.get("credentials") is mock_credentials
    client_info = kwargs.get("client_info")
    assert client_info is not None
    assert client_info.user_agent == "ipython-" + IPython.__version__

    query_job_mock.to_dataframe.assert_called_once_with(
        bqstorage_client=bqstorage_instance_mock
    )

    assert isinstance(return_value, pandas.DataFrame) 
Example #20
Source File: base.py    From SimpleCV2 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def system():
    """
    
    **SUMMARY**
    
    Output of this function includes various informations related to system and library.
    
    Main purpose:
    - While submiting a bug, report the output of this function
    - Checking the current version and later upgrading the library based on the output
    
    **RETURNS**
    
    None

    **EXAMPLE**
      
      >>> import SimpleCV
      >>> SimpleCV.system()
      
      
    """
    try :
        import platform
        print "System : ", platform.system()
        print "OS version : ", platform.version()
        print "Python version :", platform.python_version()
        try :
            from cv2 import __version__
            print "Open CV version : " + __version__
        except ImportError :
            print "Open CV2 version : " + "2.1"
        if (PIL_ENABLED) :
            print "PIL version : ", pil.VERSION
        else :
            print "PIL module not installed"
        if (ORANGE_ENABLED) :
            print "Orange Version : " + orange.version
        else :
            print "Orange module not installed"
        try :
            import pygame as pg
            print "PyGame Version : " + pg.__version__
        except ImportError:
            print "PyGame module not installed"
        try :
            import pickle
            print "Pickle Version : " + pickle.__version__
        except :
            print "Pickle module not installed"

    except ImportError :
        print "You need to install Platform to use this function"
        print "to install you can use:"
        print "easy_install platform"
    return 
Example #21
Source File: html.py    From vnpy_crypto with MIT License 4 votes vote down vote up
def write_result(self, buf):
        indent = 0
        id_section = ""
        frame = self.frame

        _classes = ['dataframe']  # Default class.
        use_mathjax = get_option("display.html.use_mathjax")
        if not use_mathjax:
            _classes.append('tex2jax_ignore')
        if self.classes is not None:
            if isinstance(self.classes, str):
                self.classes = self.classes.split()
            if not isinstance(self.classes, (list, tuple)):
                raise AssertionError('classes must be list or tuple, not {typ}'
                                     .format(typ=type(self.classes)))
            _classes.extend(self.classes)

        if self.notebook:
            div_style = ''
            try:
                import IPython
                if IPython.__version__ < LooseVersion('3.0.0'):
                    div_style = ' style="max-width:1500px;overflow:auto;"'
            except (ImportError, AttributeError):
                pass

            self.write('<div{style}>'.format(style=div_style))

        self.write_style()

        if self.table_id is not None:
            id_section = ' id="{table_id}"'.format(table_id=self.table_id)
        self.write('<table border="{border}" class="{cls}"{id_section}>'
                   .format(border=self.border, cls=' '.join(_classes),
                           id_section=id_section), indent)

        indent += self.indent_delta
        indent = self._write_header(indent)
        indent = self._write_body(indent)

        self.write('</table>', indent)
        if self.should_show_dimensions:
            by = chr(215) if compat.PY3 else unichr(215)  # ×
            self.write(u('<p>{rows} rows {by} {cols} columns</p>')
                       .format(rows=len(frame),
                               by=by,
                               cols=len(frame.columns)))

        if self.notebook:
            self.write('</div>')

        buffer_put_lines(buf, self.elements)