diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 939a132..5e8c486 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -64,7 +64,6 @@ from IPython.core.prefilter import PrefilterManager, ESC_MAGIC from IPython.core.profiledir import ProfileDir from IPython.core.pylabtools import pylab_activate from IPython.core.prompts import PromptManager -from IPython.external.Itpl import ItplNS from IPython.utils import PyColorize from IPython.utils import io from IPython.utils import py3compat diff --git a/IPython/core/tests/test_application.py b/IPython/core/tests/test_application.py index a1d0474..5af7f06 100644 --- a/IPython/core/tests/test_application.py +++ b/IPython/core/tests/test_application.py @@ -5,10 +5,10 @@ import os import tempfile from IPython.core.application import BaseIPythonApplication -from IPython.testing import decorators as testdec +from IPython.testing import decorators as dec from IPython.utils import py3compat -@testdec.onlyif_unicode_paths +@dec.onlyif_unicode_paths def test_unicode_cwd(): """Check that IPython starts with non-ascii characters in the path.""" wd = tempfile.mkdtemp(suffix=u"€") @@ -25,7 +25,7 @@ def test_unicode_cwd(): finally: os.chdir(old_wd) -@testdec.onlyif_unicode_paths +@dec.onlyif_unicode_paths def test_unicode_ipdir(): """Check that IPython starts with non-ascii characters in the IP dir.""" ipdir = tempfile.mkdtemp(suffix=u"€") diff --git a/IPython/core/tests/test_completerlib.py b/IPython/core/tests/test_completerlib.py index 2404b80..d50c122 100644 --- a/IPython/core/tests/test_completerlib.py +++ b/IPython/core/tests/test_completerlib.py @@ -19,8 +19,6 @@ import nose.tools as nt from nose import SkipTest from IPython.core.completerlib import magic_run_completer -from IPython.testing import decorators as dec -from IPython.testing import tools as tt from IPython.utils import py3compat diff --git a/IPython/core/tests/test_handlers.py b/IPython/core/tests/test_handlers.py index c6dd8eb..099abd9 100644 --- a/IPython/core/tests/test_handlers.py +++ b/IPython/core/tests/test_handlers.py @@ -9,7 +9,6 @@ import nose.tools as nt # our own packages from IPython.core import autocall -from IPython.testing import decorators as dec from IPython.testing import tools as tt from IPython.testing.globalipapp import get_ipython from IPython.utils import py3compat diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index d57cd51..581d5c5 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -28,7 +28,6 @@ from os.path import join import sys from StringIO import StringIO -from IPython.testing import decorators as dec from IPython.utils import io #----------------------------------------------------------------------------- diff --git a/IPython/core/tests/test_iplib.py b/IPython/core/tests/test_iplib.py index 7afc585..cbfe78c 100644 --- a/IPython/core/tests/test_iplib.py +++ b/IPython/core/tests/test_iplib.py @@ -13,7 +13,6 @@ import tempfile import nose.tools as nt # our own packages -from IPython.testing import decorators as dec from IPython.testing.globalipapp import get_ipython from IPython.utils import py3compat diff --git a/IPython/core/tests/test_magic_terminal.py b/IPython/core/tests/test_magic_terminal.py index 6b58075..6a4d01b 100644 --- a/IPython/core/tests/test_magic_terminal.py +++ b/IPython/core/tests/test_magic_terminal.py @@ -13,7 +13,6 @@ from StringIO import StringIO import nose.tools as nt -from IPython.testing import decorators as dec from IPython.testing import tools as tt #----------------------------------------------------------------------------- diff --git a/IPython/deathrow/oldfrontend/asyncfrontendbase.py b/IPython/deathrow/oldfrontend/asyncfrontendbase.py index 649ff21..ba912aa 100644 --- a/IPython/deathrow/oldfrontend/asyncfrontendbase.py +++ b/IPython/deathrow/oldfrontend/asyncfrontendbase.py @@ -22,13 +22,13 @@ from twisted.python.failure import Failure from zope.interface import implements, classProvides # From IPython -from IPython.external import guid - from IPython.frontend.frontendbase import (FrontEndBase, IFrontEnd, IFrontEndFactory) from IPython.kernel.core.history import FrontEndHistory from IPython.kernel.engineservice import IEngineCore +import uuid + #----------------------------------------------------------------------------- # Classes and functions #----------------------------------------------------------------------------- @@ -67,7 +67,7 @@ class AsyncFrontEndBase(FrontEndBase): return Failure(Exception("Block is not compilable")) if(blockID == None): - blockID = guid.generate() + blockID = uuid.uuid4() d = self.engine.execute(block) d.addCallback(self._add_history, block=block) diff --git a/IPython/deathrow/oldfrontend/cocoa/cocoa_frontend.py b/IPython/deathrow/oldfrontend/cocoa/cocoa_frontend.py index ca1e058..a7ee199 100644 --- a/IPython/deathrow/oldfrontend/cocoa/cocoa_frontend.py +++ b/IPython/deathrow/oldfrontend/cocoa/cocoa_frontend.py @@ -26,7 +26,7 @@ __docformat__ = "restructuredtext en" import sys import objc -from IPython.external import guid +import uuid from Foundation import NSObject, NSMutableArray, NSMutableDictionary,\ NSLog, NSNotificationCenter, NSMakeRange,\ @@ -361,7 +361,7 @@ class IPythonCocoaController(NSObject, AsyncFrontEndBase): def next_block_ID(self): - return guid.generate() + return uuid.uuid4() def new_cell_block(self): """A new CellBlock at the end of self.textView.textStorage()""" diff --git a/IPython/deathrow/oldfrontend/frontendbase.py b/IPython/deathrow/oldfrontend/frontendbase.py index 3dc9f40..da02949 100644 --- a/IPython/deathrow/oldfrontend/frontendbase.py +++ b/IPython/deathrow/oldfrontend/frontendbase.py @@ -22,7 +22,7 @@ __docformat__ = "restructuredtext en" #------------------------------------------------------------------------------- import string import codeop -from IPython.external import guid +import uuid from IPython.frontend.zopeinterface import ( @@ -242,7 +242,7 @@ class FrontEndBase(object): raise Exception("Block is not compilable") if(blockID == None): - blockID = guid.generate() + blockID = uuid.uuid4() try: result = self.shell.execute(block) diff --git a/IPython/deathrow/oldfrontend/tests/test_process.py b/IPython/deathrow/oldfrontend/tests/test_process.py index df96626..9e43487 100644 --- a/IPython/deathrow/oldfrontend/tests/test_process.py +++ b/IPython/deathrow/oldfrontend/tests/test_process.py @@ -17,7 +17,7 @@ from time import sleep import sys from IPython.frontend.process import PipedProcess -from IPython.testing import decorators as testdec +from IPython.testing import decorators as dec def test_capture_out(): @@ -47,7 +47,7 @@ def test_io(): assert result == test_string -@testdec.skip_win32 +@dec.skip_win32 def test_kill(): """ Check that we can kill a process, and its subprocess. """ diff --git a/IPython/external/guid/__init__.py b/IPython/external/guid/__init__.py deleted file mode 100644 index bb40c41..0000000 --- a/IPython/external/guid/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -try: - from guid import * -except ImportError: - from _guid import * diff --git a/IPython/external/guid/_guid.py b/IPython/external/guid/_guid.py deleted file mode 100644 index c5a73d0..0000000 --- a/IPython/external/guid/_guid.py +++ /dev/null @@ -1,169 +0,0 @@ -# encoding: utf-8 - -# GUID.py -# Version 2.6 -# -# Copyright (c) 2006 Conan C. Albrecht -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is furnished -# to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - - - -################################################################################################## -### A globally-unique identifier made up of time and ip and 8 digits for a counter: -### each GUID is 40 characters wide -### -### A globally unique identifier that combines ip, time, and a counter. Since the -### time is listed first, you can sort records by guid. You can also extract the time -### and ip if needed. -### -### Since the counter has eight hex characters, you can create up to -### 0xffffffff (4294967295) GUIDs every millisecond. If your processor -### is somehow fast enough to create more than that in a millisecond (looking -### toward the future, of course), the function will wait until the next -### millisecond to return. -### -### GUIDs make wonderful database keys. They require no access to the -### database (to get the max index number), they are extremely unique, and they sort -### automatically by time. GUIDs prevent key clashes when merging -### two databases together, combining data, or generating keys in distributed -### systems. -### -### There is an Internet Draft for UUIDs, but this module does not implement it. -### If the draft catches on, perhaps I'll conform the module to it. -### - - -# Changelog -# Sometime, 1997 Created the Java version of GUID -# Went through many versions in Java -# Sometime, 2002 Created the Python version of GUID, mirroring the Java version -# November 24, 2003 Changed Python version to be more pythonic, took out object and made just a module -# December 2, 2003 Fixed duplicating GUIDs. Sometimes they duplicate if multiples are created -# in the same millisecond (it checks the last 100 GUIDs now and has a larger random part) -# December 9, 2003 Fixed MAX_RANDOM, which was going over sys.maxint -# June 12, 2004 Allowed a custom IP address to be sent in rather than always using the -# local IP address. -# November 4, 2005 Changed the random part to a counter variable. Now GUIDs are totally -# unique and more efficient, as long as they are created by only -# on runtime on a given machine. The counter part is after the time -# part so it sorts correctly. -# November 8, 2005 The counter variable now starts at a random long now and cycles -# around. This is in case two guids are created on the same -# machine at the same millisecond (by different processes). Even though -# it is possible the GUID can be created, this makes it highly unlikely -# since the counter will likely be different. -# November 11, 2005 Fixed a bug in the new IP getting algorithm. Also, use IPv6 range -# for IP when we make it up (when it's no accessible) -# November 21, 2005 Added better IP-finding code. It finds IP address better now. -# January 5, 2006 Fixed a small bug caused in old versions of python (random module use) - -import math -import socket -import random -import sys -import time -import threading - - - -############################# -### global module variables - -#Makes a hex IP from a decimal dot-separated ip (eg: 127.0.0.1) -make_hexip = lambda ip: ''.join(["%04x" % long(i) for i in ip.split('.')]) # leave space for ip v6 (65K in each sub) - -MAX_COUNTER = 0xfffffffe -counter = 0L -firstcounter = MAX_COUNTER -lasttime = 0 -ip = '' -lock = threading.RLock() -try: # only need to get the IP addresss once - ip = socket.getaddrinfo(socket.gethostname(),0)[-1][-1][0] - hexip = make_hexip(ip) -except: # if we don't have an ip, default to someting in the 10.x.x.x private range - ip = '10' - rand = random.Random() - for i in range(3): - ip += '.' + str(rand.randrange(1, 0xffff)) # might as well use IPv6 range if we're making it up - hexip = make_hexip(ip) - - -################################# -### Public module functions - -def generate(ip=None): - '''Generates a new guid. A guid is unique in space and time because it combines - the machine IP with the current time in milliseconds. Be careful about sending in - a specified IP address because the ip makes it unique in space. You could send in - the same IP address that is created on another machine. - ''' - global counter, firstcounter, lasttime - lock.acquire() # can't generate two guids at the same time - try: - parts = [] - - # do we need to wait for the next millisecond (are we out of counters?) - now = long(time.time() * 1000) - while lasttime == now and counter == firstcounter: - time.sleep(.01) - now = long(time.time() * 1000) - - # time part - parts.append("%016x" % now) - - # counter part - if lasttime != now: # time to start counter over since we have a different millisecond - firstcounter = long(random.uniform(1, MAX_COUNTER)) # start at random position - counter = firstcounter - counter += 1 - if counter > MAX_COUNTER: - counter = 0 - lasttime = now - parts.append("%08x" % (counter)) - - # ip part - parts.append(hexip) - - # put them all together - return ''.join(parts) - finally: - lock.release() - - -def extract_time(guid): - '''Extracts the time portion out of the guid and returns the - number of seconds since the epoch as a float''' - return float(long(guid[0:16], 16)) / 1000.0 - - -def extract_counter(guid): - '''Extracts the counter from the guid (returns the bits in decimal)''' - return int(guid[16:24], 16) - - -def extract_ip(guid): - '''Extracts the ip portion out of the guid and returns it - as a string like 10.10.10.10''' - # there's probably a more elegant way to do this - thisip = [] - for index in range(24, 40, 4): - thisip.append(str(int(guid[index: index + 4], 16))) - return '.'.join(thisip) -