From 1c95b340a7c955bce42b83c280c6bea3be5b6cc7 Mon Sep 17 00:00:00 2001 From: Roman Dolgiy Date: Thu, 13 Jan 2011 00:18:01 +0200 Subject: [PATCH] Removed `other_packages` from global sys.path It may cause errors when using twill as a library with other libraries --- tests/test-broken-html.py | 2 +- tests/test-checkbox.py | 2 +- tests/test-encoding.py | 2 +- tests/test-form.py | 2 +- twill/__init__.py | 7 +------ twill/_browser.py | 4 ++-- twill/browser.py | 4 ++-- twill/commands.py | 6 +++--- twill/parse.py | 2 +- twill/utils.py | 10 +++++----- 10 files changed, 18 insertions(+), 23 deletions(-) diff --git a/tests/test-broken-html.py b/tests/test-broken-html.py index 42fff56..3704ad0 100644 --- a/tests/test-broken-html.py +++ b/tests/test-broken-html.py @@ -3,7 +3,7 @@ parser) can parse. """ -from _mechanize_dist import ClientForm +from twill.other_packages._mechanize_dist import ClientForm import twilltestlib from twill import commands diff --git a/tests/test-checkbox.py b/tests/test-checkbox.py index a31bae4..85ce396 100644 --- a/tests/test-checkbox.py +++ b/tests/test-checkbox.py @@ -2,7 +2,7 @@ import twill from twill import namespaces, commands from twill.errors import TwillAssertionError -from _mechanize_dist import BrowserStateError, ClientForm +from twill.other_packages._mechanize_dist import BrowserStateError, ClientForm def setup_module(): global url diff --git a/tests/test-encoding.py b/tests/test-encoding.py index e7c0530..06a919b 100644 --- a/tests/test-encoding.py +++ b/tests/test-encoding.py @@ -1,5 +1,5 @@ import twilltestlib -from _mechanize_dist import ClientForm +from twill.other_packages._mechanize_dist import ClientForm from cStringIO import StringIO def test_form_parse(): diff --git a/tests/test-form.py b/tests/test-form.py index e523a22..2400cc2 100644 --- a/tests/test-form.py +++ b/tests/test-form.py @@ -2,7 +2,7 @@ import twill from twill import namespaces, commands from twill.errors import TwillAssertionError -from _mechanize_dist import BrowserStateError, ClientForm +from twill.other_packages._mechanize_dist import BrowserStateError, ClientForm def test(): url = twilltestlib.get_url() diff --git a/twill/__init__.py b/twill/__init__.py index a0f09fa..347f8d9 100644 --- a/twill/__init__.py +++ b/twill/__init__.py @@ -31,7 +31,7 @@ "set_errout"] # -# add extensions (twill/extensions) and the the wwwsearch & pyparsing +# add extensions (twill/extensions) # stuff from twill/included-packages/. NOTE: this works with eggs! hooray! # @@ -43,11 +43,6 @@ extensions = os.path.join(thisdir, 'extensions') sys.path.append(extensions) -# add other_packages in at the *beginning*, so that the correct -# (patched) versions of pyparsing and mechanize get imported. -wwwsearchlib = os.path.join(thisdir, 'other_packages') -sys.path.insert(0, wwwsearchlib) - # the two core components of twill: from shell import TwillCommandLoop from parse import execute_file, execute_string diff --git a/twill/_browser.py b/twill/_browser.py index 5326e69..b83bdde 100644 --- a/twill/_browser.py +++ b/twill/_browser.py @@ -3,13 +3,13 @@ """ # wwwsearch imports -from _mechanize_dist import Browser as MechanizeBrowser +from other_packages._mechanize_dist import Browser as MechanizeBrowser import wsgi_intercept from utils import FixedHTTPBasicAuthHandler, FunctioningHTTPRefreshProcessor def build_http_handler(): - from _mechanize_dist._urllib2 import HTTPHandler + from other_packages._mechanize_dist._urllib2 import HTTPHandler class MyHTTPHandler(HTTPHandler): def http_open(self, req): diff --git a/twill/browser.py b/twill/browser.py index 80e7562..94ed0a1 100644 --- a/twill/browser.py +++ b/twill/browser.py @@ -10,8 +10,8 @@ import re # wwwsearch imports -import _mechanize_dist as mechanize -from _mechanize_dist import BrowserStateError, LinkNotFoundError, ClientForm +import other_packages._mechanize_dist as mechanize +from other_packages._mechanize_dist import BrowserStateError, LinkNotFoundError, ClientForm # twill package imports from _browser import PatchedMechanizeBrowser diff --git a/twill/commands.py b/twill/commands.py index 4130e59..5f03fdc 100644 --- a/twill/commands.py +++ b/twill/commands.py @@ -4,9 +4,9 @@ """ import sys -import _mechanize_dist as mechanize -from _mechanize_dist import ClientForm -from _mechanize_dist._headersutil import is_html +import other_packages._mechanize_dist as mechanize +from other_packages._mechanize_dist import ClientForm +from other_packages._mechanize_dist._headersutil import is_html OUT=None ERR=sys.stderr diff --git a/twill/parse.py b/twill/parse.py index 2db9a3c..5c3a4bc 100644 --- a/twill/parse.py +++ b/twill/parse.py @@ -6,7 +6,7 @@ from cStringIO import StringIO from errors import TwillAssertionError, TwillNameError -from pyparsing import OneOrMore, Word, printables, quotedString, Optional, \ +from other_packages.pyparsing import OneOrMore, Word, printables, quotedString, Optional, \ alphas, alphanums, ParseException, ZeroOrMore, restOfLine, Combine, \ Literal, Group, removeQuotes, CharsNotIn diff --git a/twill/utils.py b/twill/utils.py index f25eb1f..e87dae9 100644 --- a/twill/utils.py +++ b/twill/utils.py @@ -8,12 +8,12 @@ import os import base64 -import subprocess +from other_packages import subprocess -import _mechanize_dist as mechanize -from _mechanize_dist import ClientForm -from _mechanize_dist._util import time -from _mechanize_dist._http import HTTPRefreshProcessor +import other_packages._mechanize_dist as mechanize +from other_packages._mechanize_dist import ClientForm +from other_packages._mechanize_dist._util import time +from other_packages._mechanize_dist._http import HTTPRefreshProcessor from errors import TwillException