summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/classutils.py15
-rw-r--r--meta/lib/oe/distro_check.py4
-rw-r--r--meta/lib/oe/maketype.py9
-rw-r--r--meta/lib/oe/manifest.py3
-rw-r--r--meta/lib/oe/package.py2
-rw-r--r--meta/lib/oe/package_manager.py11
-rw-r--r--meta/lib/oe/qa.py28
-rw-r--r--meta/lib/oe/recipeutils.py4
-rw-r--r--meta/lib/oe/rootfs.py3
-rw-r--r--meta/lib/oe/sdk.py4
-rw-r--r--meta/lib/oe/terminal.py6
-rw-r--r--meta/lib/oe/tests/test_path.py2
-rw-r--r--meta/lib/oe/types.py4
-rw-r--r--meta/lib/oe/utils.py6
14 files changed, 47 insertions, 54 deletions
diff --git a/meta/lib/oe/classutils.py b/meta/lib/oe/classutils.py
index 98bb059a71..e7856c86f2 100644
--- a/meta/lib/oe/classutils.py
+++ b/meta/lib/oe/classutils.py
@@ -1,4 +1,11 @@
1class ClassRegistry(type): 1
2class ClassRegistryMeta(type):
3 """Give each ClassRegistry their own registry"""
4 def __init__(cls, name, bases, attrs):
5 cls.registry = {}
6 type.__init__(cls, name, bases, attrs)
7
8class ClassRegistry(type, metaclass=ClassRegistryMeta):
2 """Maintain a registry of classes, indexed by name. 9 """Maintain a registry of classes, indexed by name.
3 10
4Note that this implementation requires that the names be unique, as it uses 11Note that this implementation requires that the names be unique, as it uses
@@ -12,12 +19,6 @@ Subclasses of ClassRegistry may define an 'implemented' property to exert
12control over whether the class will be added to the registry (e.g. to keep 19control over whether the class will be added to the registry (e.g. to keep
13abstract base classes out of the registry).""" 20abstract base classes out of the registry)."""
14 priority = 0 21 priority = 0
15 class __metaclass__(type):
16 """Give each ClassRegistry their own registry"""
17 def __init__(cls, name, bases, attrs):
18 cls.registry = {}
19 type.__init__(cls, name, bases, attrs)
20
21 def __init__(cls, name, bases, attrs): 22 def __init__(cls, name, bases, attrs):
22 super(ClassRegistry, cls).__init__(name, bases, attrs) 23 super(ClassRegistry, cls).__init__(name, bases, attrs)
23 try: 24 try:
diff --git a/meta/lib/oe/distro_check.py b/meta/lib/oe/distro_check.py
index ba1bba678d..746e242f5d 100644
--- a/meta/lib/oe/distro_check.py
+++ b/meta/lib/oe/distro_check.py
@@ -1,8 +1,8 @@
1from contextlib import contextmanager 1from contextlib import contextmanager
2@contextmanager 2@contextmanager
3def create_socket(url, d): 3def create_socket(url, d):
4 import urllib 4 import urllib.request, urllib.parse, urllib.error
5 socket = urllib.urlopen(url, proxies=get_proxies(d)) 5 socket = urllib.request.urlopen(url, proxies=get_proxies(d))
6 try: 6 try:
7 yield socket 7 yield socket
8 finally: 8 finally:
diff --git a/meta/lib/oe/maketype.py b/meta/lib/oe/maketype.py
index 139f333691..f88981dd90 100644
--- a/meta/lib/oe/maketype.py
+++ b/meta/lib/oe/maketype.py
@@ -6,7 +6,8 @@ the arguments of the type's factory for details.
6""" 6"""
7 7
8import inspect 8import inspect
9import types 9import oe.types as types
10import collections
10 11
11available_types = {} 12available_types = {}
12 13
@@ -53,7 +54,9 @@ def get_callable_args(obj):
53 if type(obj) is type: 54 if type(obj) is type:
54 obj = obj.__init__ 55 obj = obj.__init__
55 56
56 args, varargs, keywords, defaults = inspect.getargspec(obj) 57 sig = inspect.signature(obj)
58 args = list(sig.parameters.keys())
59 defaults = list(s for s in sig.parameters.keys() if sig.parameters[s].default != inspect.Parameter.empty)
57 flaglist = [] 60 flaglist = []
58 if args: 61 if args:
59 if len(args) > 1 and args[0] == 'self': 62 if len(args) > 1 and args[0] == 'self':
@@ -93,7 +96,7 @@ for name in dir(types):
93 continue 96 continue
94 97
95 obj = getattr(types, name) 98 obj = getattr(types, name)
96 if not callable(obj): 99 if not isinstance(obj, collections.Callable):
97 continue 100 continue
98 101
99 register(name, obj) 102 register(name, obj)
diff --git a/meta/lib/oe/manifest.py b/meta/lib/oe/manifest.py
index ec2ef500b2..95f8eb2df3 100644
--- a/meta/lib/oe/manifest.py
+++ b/meta/lib/oe/manifest.py
@@ -4,11 +4,10 @@ import re
4import bb 4import bb
5 5
6 6
7class Manifest(object): 7class Manifest(object, metaclass=ABCMeta):
8 """ 8 """
9 This is an abstract class. Do not instantiate this directly. 9 This is an abstract class. Do not instantiate this directly.
10 """ 10 """
11 __metaclass__ = ABCMeta
12 11
13 PKG_TYPE_MUST_INSTALL = "mip" 12 PKG_TYPE_MUST_INSTALL = "mip"
14 PKG_TYPE_MULTILIB = "mlp" 13 PKG_TYPE_MULTILIB = "mlp"
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 5bb15bbc09..faa0ab2edb 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -8,7 +8,7 @@ def runstrip(arg):
8 # 8 - shared library 8 # 8 - shared library
9 # 16 - kernel module 9 # 16 - kernel module
10 10
11 import commands, stat, subprocess 11 import stat, subprocess
12 12
13 (file, elftype, strip) = arg 13 (file, elftype, strip) = arg
14 14
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 54e6970298..71e5b502e7 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -89,9 +89,7 @@ def opkg_query(cmd_output):
89 return output 89 return output
90 90
91 91
92class Indexer(object): 92class Indexer(object, metaclass=ABCMeta):
93 __metaclass__ = ABCMeta
94
95 def __init__(self, d, deploy_dir): 93 def __init__(self, d, deploy_dir):
96 self.d = d 94 self.d = d
97 self.deploy_dir = deploy_dir 95 self.deploy_dir = deploy_dir
@@ -342,9 +340,7 @@ class DpkgIndexer(Indexer):
342 340
343 341
344 342
345class PkgsList(object): 343class PkgsList(object, metaclass=ABCMeta):
346 __metaclass__ = ABCMeta
347
348 def __init__(self, d, rootfs_dir): 344 def __init__(self, d, rootfs_dir):
349 self.d = d 345 self.d = d
350 self.rootfs_dir = rootfs_dir 346 self.rootfs_dir = rootfs_dir
@@ -512,11 +508,10 @@ class DpkgPkgsList(PkgsList):
512 return opkg_query(cmd_output) 508 return opkg_query(cmd_output)
513 509
514 510
515class PackageManager(object): 511class PackageManager(object, metaclass=ABCMeta):
516 """ 512 """
517 This is an abstract class. Do not instantiate this directly. 513 This is an abstract class. Do not instantiate this directly.
518 """ 514 """
519 __metaclass__ = ABCMeta
520 515
521 def __init__(self, d): 516 def __init__(self, d):
522 self.d = d 517 self.d = d
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py
index 2c301419b0..75e7df8546 100644
--- a/meta/lib/oe/qa.py
+++ b/meta/lib/oe/qa.py
@@ -50,41 +50,41 @@ class ELFFile:
50 if len(self.data) < ELFFile.EI_NIDENT + 4: 50 if len(self.data) < ELFFile.EI_NIDENT + 4:
51 raise NotELFFileError("%s is not an ELF" % self.name) 51 raise NotELFFileError("%s is not an ELF" % self.name)
52 52
53 self.my_assert(self.data[0], chr(0x7f) ) 53 self.my_assert(self.data[0], 0x7f)
54 self.my_assert(self.data[1], 'E') 54 self.my_assert(self.data[1], ord('E'))
55 self.my_assert(self.data[2], 'L') 55 self.my_assert(self.data[2], ord('L'))
56 self.my_assert(self.data[3], 'F') 56 self.my_assert(self.data[3], ord('F'))
57 if self.bits == 0: 57 if self.bits == 0:
58 if self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS32): 58 if self.data[ELFFile.EI_CLASS] == ELFFile.ELFCLASS32:
59 self.bits = 32 59 self.bits = 32
60 elif self.data[ELFFile.EI_CLASS] == chr(ELFFile.ELFCLASS64): 60 elif self.data[ELFFile.EI_CLASS] == ELFFile.ELFCLASS64:
61 self.bits = 64 61 self.bits = 64
62 else: 62 else:
63 # Not 32-bit or 64.. lets assert 63 # Not 32-bit or 64.. lets assert
64 raise NotELFFileError("ELF but not 32 or 64 bit.") 64 raise NotELFFileError("ELF but not 32 or 64 bit.")
65 elif self.bits == 32: 65 elif self.bits == 32:
66 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS32)) 66 self.my_assert(self.data[ELFFile.EI_CLASS], ELFFile.ELFCLASS32)
67 elif self.bits == 64: 67 elif self.bits == 64:
68 self.my_assert(self.data[ELFFile.EI_CLASS], chr(ELFFile.ELFCLASS64)) 68 self.my_assert(self.data[ELFFile.EI_CLASS], ELFFile.ELFCLASS64)
69 else: 69 else:
70 raise NotELFFileError("Must specify unknown, 32 or 64 bit size.") 70 raise NotELFFileError("Must specify unknown, 32 or 64 bit size.")
71 self.my_assert(self.data[ELFFile.EI_VERSION], chr(ELFFile.EV_CURRENT) ) 71 self.my_assert(self.data[ELFFile.EI_VERSION], ELFFile.EV_CURRENT)
72 72
73 self.sex = self.data[ELFFile.EI_DATA] 73 self.sex = self.data[ELFFile.EI_DATA]
74 if self.sex == chr(ELFFile.ELFDATANONE): 74 if self.sex == ELFFile.ELFDATANONE:
75 raise NotELFFileError("self.sex == ELFDATANONE") 75 raise NotELFFileError("self.sex == ELFDATANONE")
76 elif self.sex == chr(ELFFile.ELFDATA2LSB): 76 elif self.sex == ELFFile.ELFDATA2LSB:
77 self.sex = "<" 77 self.sex = "<"
78 elif self.sex == chr(ELFFile.ELFDATA2MSB): 78 elif self.sex == ELFFile.ELFDATA2MSB:
79 self.sex = ">" 79 self.sex = ">"
80 else: 80 else:
81 raise NotELFFileError("Unknown self.sex") 81 raise NotELFFileError("Unknown self.sex")
82 82
83 def osAbi(self): 83 def osAbi(self):
84 return ord(self.data[ELFFile.EI_OSABI]) 84 return self.data[ELFFile.EI_OSABI]
85 85
86 def abiVersion(self): 86 def abiVersion(self):
87 return ord(self.data[ELFFile.EI_ABIVERSION]) 87 return self.data[ELFFile.EI_ABIVERSION]
88 88
89 def abiSize(self): 89 def abiSize(self):
90 return self.bits 90 return self.bits
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py
index 1b8538785c..e3c4b8a759 100644
--- a/meta/lib/oe/recipeutils.py
+++ b/meta/lib/oe/recipeutils.py
@@ -11,7 +11,7 @@ import os.path
11import tempfile 11import tempfile
12import textwrap 12import textwrap
13import difflib 13import difflib
14import utils 14from . import utils
15import shutil 15import shutil
16import re 16import re
17import fnmatch 17import fnmatch
@@ -662,7 +662,7 @@ def bbappend_recipe(rd, destlayerdir, srcfiles, install=None, wildcardver=False,
662 662
663 if removevar in removevalues: 663 if removevar in removevalues:
664 remove = removevalues[removevar] 664 remove = removevalues[removevar]
665 if isinstance(remove, basestring): 665 if isinstance(remove, str):
666 if remove in splitval: 666 if remove in splitval:
667 splitval.remove(remove) 667 splitval.remove(remove)
668 changed = True 668 changed = True
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index d93485819a..1fc35bdc78 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -10,11 +10,10 @@ import subprocess
10import re 10import re
11 11
12 12
13class Rootfs(object): 13class Rootfs(object, metaclass=ABCMeta):
14 """ 14 """
15 This is an abstract class. Do not instantiate this directly. 15 This is an abstract class. Do not instantiate this directly.
16 """ 16 """
17 __metaclass__ = ABCMeta
18 17
19 def __init__(self, d): 18 def __init__(self, d):
20 self.d = d 19 self.d = d
diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py
index 4786cc5aac..c74525f929 100644
--- a/meta/lib/oe/sdk.py
+++ b/meta/lib/oe/sdk.py
@@ -8,9 +8,7 @@ import glob
8import traceback 8import traceback
9 9
10 10
11class Sdk(object): 11class Sdk(object, metaclass=ABCMeta):
12 __metaclass__ = ABCMeta
13
14 def __init__(self, d, manifest_dir): 12 def __init__(self, d, manifest_dir):
15 self.d = d 13 self.d = d
16 self.sdk_output = self.d.getVar('SDK_OUTPUT', True) 14 self.sdk_output = self.d.getVar('SDK_OUTPUT', True)
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 634daa9033..dc25d14ff6 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -25,9 +25,7 @@ class Registry(oe.classutils.ClassRegistry):
25 return bool(cls.command) 25 return bool(cls.command)
26 26
27 27
28class Terminal(Popen): 28class Terminal(Popen, metaclass=Registry):
29 __metaclass__ = Registry
30
31 def __init__(self, sh_cmd, title=None, env=None, d=None): 29 def __init__(self, sh_cmd, title=None, env=None, d=None):
32 fmt_sh_cmd = self.format_command(sh_cmd, title) 30 fmt_sh_cmd = self.format_command(sh_cmd, title)
33 try: 31 try:
@@ -41,7 +39,7 @@ class Terminal(Popen):
41 39
42 def format_command(self, sh_cmd, title): 40 def format_command(self, sh_cmd, title):
43 fmt = {'title': title or 'Terminal', 'command': sh_cmd} 41 fmt = {'title': title or 'Terminal', 'command': sh_cmd}
44 if isinstance(self.command, basestring): 42 if isinstance(self.command, str):
45 return shlex.split(self.command.format(**fmt)) 43 return shlex.split(self.command.format(**fmt))
46 else: 44 else:
47 return [element.format(**fmt) for element in self.command] 45 return [element.format(**fmt) for element in self.command]
diff --git a/meta/lib/oe/tests/test_path.py b/meta/lib/oe/tests/test_path.py
index 5fa24483d1..44d068143e 100644
--- a/meta/lib/oe/tests/test_path.py
+++ b/meta/lib/oe/tests/test_path.py
@@ -85,5 +85,5 @@ class TestRealPath(unittest.TestCase):
85 85
86 def test_loop(self): 86 def test_loop(self):
87 for e in self.EXCEPTIONS: 87 for e in self.EXCEPTIONS:
88 self.assertRaisesRegexp(OSError, r'\[Errno %u\]' % e[1], 88 self.assertRaisesRegex(OSError, r'\[Errno %u\]' % e[1],
89 self.__realpath, e[0], False, False) 89 self.__realpath, e[0], False, False)
diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py
index 7f47c17d0e..4ae58acfac 100644
--- a/meta/lib/oe/types.py
+++ b/meta/lib/oe/types.py
@@ -33,7 +33,7 @@ def choice(value, choices):
33 Acts as a multiple choice for the user. To use this, set the variable 33 Acts as a multiple choice for the user. To use this, set the variable
34 type flag to 'choice', and set the 'choices' flag to a space separated 34 type flag to 'choice', and set the 'choices' flag to a space separated
35 list of valid values.""" 35 list of valid values."""
36 if not isinstance(value, basestring): 36 if not isinstance(value, str):
37 raise TypeError("choice accepts a string, not '%s'" % type(value)) 37 raise TypeError("choice accepts a string, not '%s'" % type(value))
38 38
39 value = value.lower() 39 value = value.lower()
@@ -106,7 +106,7 @@ def boolean(value):
106 Valid values for false: 'no', 'n', 'false', 'f', '0' 106 Valid values for false: 'no', 'n', 'false', 'f', '0'
107 """ 107 """
108 108
109 if not isinstance(value, basestring): 109 if not isinstance(value, str):
110 raise TypeError("boolean accepts a string, not '%s'" % type(value)) 110 raise TypeError("boolean accepts a string, not '%s'" % type(value))
111 111
112 value = value.lower() 112 value = value.lower()
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index 1bbdbb4bd5..cecddc657f 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -46,7 +46,7 @@ def both_contain(variable1, variable2, checkvalue, d):
46 val2 = d.getVar(variable2, True) 46 val2 = d.getVar(variable2, True)
47 val1 = set(val1.split()) 47 val1 = set(val1.split())
48 val2 = set(val2.split()) 48 val2 = set(val2.split())
49 if isinstance(checkvalue, basestring): 49 if isinstance(checkvalue, str):
50 checkvalue = set(checkvalue.split()) 50 checkvalue = set(checkvalue.split())
51 else: 51 else:
52 checkvalue = set(checkvalue) 52 checkvalue = set(checkvalue)
@@ -235,7 +235,7 @@ def format_pkg_list(pkg_dict, ret_format=None):
235# so implement a version here 235# so implement a version here
236# 236#
237 237
238from Queue import Queue 238from queue import Queue
239from threading import Thread 239from threading import Thread
240 240
241class ThreadedWorker(Thread): 241class ThreadedWorker(Thread):
@@ -249,7 +249,7 @@ class ThreadedWorker(Thread):
249 self.worker_end = worker_end 249 self.worker_end = worker_end
250 250
251 def run(self): 251 def run(self):
252 from Queue import Empty 252 from queue import Empty
253 253
254 if self.worker_init is not None: 254 if self.worker_init is not None:
255 self.worker_init(self) 255 self.worker_init(self)