[python-debian/master 06/36] Use absolute imports.

Colin Watson cjwatson at canonical.com
Mon Oct 8 07:41:23 UTC 2012


---
 lib/debian/changelog.py      |    4 +++-
 lib/debian/deb822.py         |    4 ++--
 lib/debian/debfile.py        |    8 ++++----
 lib/debian/debian_support.py |    4 ++--
 lib/debian/debtags.py        |    4 ++--
 lib/debian/doc-debtags       |    8 ++++++--
 tests/test_changelog.py      |    6 ++++--
 tests/test_deb822.py         |    6 ++++--
 tests/test_debfile.py        |    8 +++++---
 tests/test_debian_support.py |    8 +++++---
 tests/test_debtags.py        |    6 ++++--
 11 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/lib/debian/changelog.py b/lib/debian/changelog.py
index 93c348f..a30ee0c 100644
--- a/lib/debian/changelog.py
+++ b/lib/debian/changelog.py
@@ -23,13 +23,15 @@
 
 """This module implements facilities to deal with Debian changelogs."""
 
+from __future__ import absolute_import
+
 import os
 import pwd
 import re
 import socket
 import warnings
 
-import debian_support
+from debian import debian_support
 
 class ChangelogParseError(StandardError):
     """Indicates that the changelog could not be parsed"""
diff --git a/lib/debian/deb822.py b/lib/debian/deb822.py
index 742527c..4ba6ef3 100644
--- a/lib/debian/deb822.py
+++ b/lib/debian/deb822.py
@@ -22,9 +22,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 
-from deprecation import function_deprecated_by
+from debian.deprecation import function_deprecated_by
 
 try:
     import apt_pkg
diff --git a/lib/debian/debfile.py b/lib/debian/debfile.py
index a43af5e..e764ce8 100644
--- a/lib/debian/debfile.py
+++ b/lib/debian/debfile.py
@@ -15,14 +15,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 
 import gzip
 import tarfile
 
-from arfile import ArFile, ArError
-from changelog import Changelog
-from deb822 import Deb822
+from debian.arfile import ArFile, ArError
+from debian.changelog import Changelog
+from debian.deb822 import Deb822
 
 DATA_PART = 'data.tar'      # w/o extension
 CTRL_PART = 'control.tar'
diff --git a/lib/debian/debian_support.py b/lib/debian/debian_support.py
index b761094..a5af828 100644
--- a/lib/debian/debian_support.py
+++ b/lib/debian/debian_support.py
@@ -18,14 +18,14 @@
 
 """This module implements facilities to deal with Debian-specific metadata."""
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 
 import os
 import re
 import hashlib
 import types
 
-from deprecation import function_deprecated_by
+from debian.deprecation import function_deprecated_by
 
 try:
     import apt_pkg
diff --git a/lib/debian/debtags.py b/lib/debian/debtags.py
index 2e9379e..fd1b82f 100644
--- a/lib/debian/debtags.py
+++ b/lib/debian/debtags.py
@@ -15,11 +15,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 
 import re, cPickle
 
-from deprecation import function_deprecated_by
+from debian.deprecation import function_deprecated_by
 
 def parse_tags(input):
 	lre = re.compile(r"^(.+?)(?::?\s*|:\s+(.+?)\s*)$")
diff --git a/lib/debian/doc-debtags b/lib/debian/doc-debtags
index 37a1178..366f1bf 100755
--- a/lib/debian/doc-debtags
+++ b/lib/debian/doc-debtags
@@ -1,11 +1,15 @@
 #!/usr/bin/python
 
-from __future__ import print_function
+from __future__ import absolute_import, print_function
 
-import debtags
 import sys
+import os
 import inspect
 
+sys.path.insert(0, os.path.join(sys.path[0], os.pardir))
+
+from debian import debtags
+
 def print_indented (spaces, string):
 	for line in string.split("\n"):
 		for i in range(1,spaces):
diff --git a/tests/test_changelog.py b/tests/test_changelog.py
index 65e7d66..99681e5 100755
--- a/tests/test_changelog.py
+++ b/tests/test_changelog.py
@@ -24,12 +24,14 @@
 # Copyright 2005 Frank Lichtenheld <frank at lichtenheld.de>
 # and licensed under the same license as above.
 
+from __future__ import absolute_import
+
 import sys
 import unittest
 
-sys.path.insert(0, '../lib/debian/')
+sys.path.insert(0, '../lib/')
 
-import changelog
+from debian import changelog
 
 class ChangelogTests(unittest.TestCase):
 
diff --git a/tests/test_deb822.py b/tests/test_deb822.py
index c99e985..93d6af3 100755
--- a/tests/test_deb822.py
+++ b/tests/test_deb822.py
@@ -17,6 +17,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+from __future__ import absolute_import
+
 import os
 import re
 import sys
@@ -25,9 +27,9 @@ import unittest
 import warnings
 from StringIO import StringIO
 
-sys.path.insert(0, '../lib/debian/')
+sys.path.insert(0, '../lib/')
 
-import deb822
+from debian import deb822
 
 
 UNPARSED_PACKAGE = '''\
diff --git a/tests/test_debfile.py b/tests/test_debfile.py
index b37dfd7..96fff89 100755
--- a/tests/test_debfile.py
+++ b/tests/test_debfile.py
@@ -17,6 +17,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import absolute_import
+
 import unittest
 import os
 import re
@@ -25,10 +27,10 @@ import sys
 import tempfile
 import uu
 
-sys.path.insert(0, '../lib/debian/')
+sys.path.insert(0, '../lib/')
 
-import arfile
-import debfile
+from debian import arfile
+from debian import debfile
 
 class TestArFile(unittest.TestCase):
 
diff --git a/tests/test_debian_support.py b/tests/test_debian_support.py
index d29fb1a..867466d 100755
--- a/tests/test_debian_support.py
+++ b/tests/test_debian_support.py
@@ -18,13 +18,15 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
+from __future__ import absolute_import
+
 import sys
 import unittest
 
-sys.path.insert(0, '../lib/debian/')
+sys.path.insert(0, '../lib/')
 
-import debian_support
-from debian_support import *
+from debian import debian_support
+from debian.debian_support import *
 
 
 class VersionTests(unittest.TestCase):
diff --git a/tests/test_debtags.py b/tests/test_debtags.py
index cbe6674..63b254a 100755
--- a/tests/test_debtags.py
+++ b/tests/test_debtags.py
@@ -17,11 +17,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+from __future__ import absolute_import
+
 import sys
 import unittest
 
-sys.path.insert(0, '../lib/debian/')
-import debtags
+sys.path.insert(0, '../lib/')
+from debian import debtags
 
 class TestDebtags(unittest.TestCase):
     def mkdb(self):
-- 
1.7.2.5





More information about the pkg-python-debian-commits mailing list