mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-09-01 19:02:31 +01:00
pluginloader: Replaced extension loader with WA3 plugin loader
In the process removed modules and boot_strap.py. Also Renamed extensions Plugins. Louie is now monkey patched rather than containing a modified version in external
This commit is contained in:
@@ -30,7 +30,7 @@ BULLET_CHARS = '-*'
|
||||
|
||||
def get_summary(aclass):
|
||||
"""
|
||||
Returns the summary description for an extension class. The summary is the
|
||||
Returns the summary description for an plugin class. The summary is the
|
||||
first paragraph (separated by blank line) of the description taken either from
|
||||
the ``descripton`` attribute of the class, or if that is not present, from the
|
||||
class' docstring.
|
||||
@@ -41,7 +41,7 @@ def get_summary(aclass):
|
||||
|
||||
def get_description(aclass):
|
||||
"""
|
||||
Return the description of the specified extension class. The description is taken
|
||||
Return the description of the specified plugin class. The description is taken
|
||||
either from ``description`` attribute of the class or its docstring.
|
||||
|
||||
"""
|
||||
@@ -291,7 +291,7 @@ def underline(text, symbol='='):
|
||||
return '{}\n{}\n\n'.format(text, symbol * len(text))
|
||||
|
||||
|
||||
def get_rst_from_extension(ext):
|
||||
def get_rst_from_plugin(ext):
|
||||
text = underline(ext.name, '-')
|
||||
if hasattr(ext, 'description'):
|
||||
desc = strip_inlined_text(ext.description or '')
|
||||
|
@@ -21,7 +21,7 @@ import threading
|
||||
|
||||
import colorama
|
||||
|
||||
from wlauto.core.bootstrap import settings
|
||||
from wlauto.core.config.core import settings
|
||||
import wlauto.core.signal as signal
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ def init_logging(verbosity):
|
||||
console_handler = logging.StreamHandler()
|
||||
if verbosity == 1:
|
||||
console_handler.setLevel(logging.DEBUG)
|
||||
if 'colour_enabled' in settings.logging and not settings.logging['colour_enabled']:
|
||||
if 'colour' in settings.logging and not settings.logging['colour']:
|
||||
console_handler.setFormatter(LineFormatter(settings.logging['verbose_format']))
|
||||
else:
|
||||
console_handler.setFormatter(ColorFormatter(settings.logging['verbose_format']))
|
||||
else:
|
||||
console_handler.setLevel(logging.INFO)
|
||||
if 'colour_enabled' in settings.logging and not settings.logging['colour_enabled']:
|
||||
if 'colour' in settings.logging and not settings.logging['colour']:
|
||||
console_handler.setFormatter(LineFormatter(settings.logging['regular_format']))
|
||||
else:
|
||||
console_handler.setFormatter(ColorFormatter(settings.logging['regular_format']))
|
||||
|
@@ -35,7 +35,7 @@ It's also possible to use the serializer directly::
|
||||
This can also be used to ``dump()`` POD structures. By default,
|
||||
``dump()`` will produce JSON, but ``fmt`` parameter may be used to
|
||||
specify an alternative format (``yaml`` or ``python``). ``load()`` will
|
||||
use the file extension to guess the format, but ``fmt`` may also be used
|
||||
use the file plugin to guess the format, but ``fmt`` may also be used
|
||||
to specify it explicitly.
|
||||
|
||||
"""
|
||||
|
@@ -29,6 +29,7 @@ import os
|
||||
import re
|
||||
import math
|
||||
import shlex
|
||||
from bisect import insort
|
||||
from collections import defaultdict
|
||||
|
||||
from wlauto.utils.misc import isiterable, to_identifier
|
||||
@@ -300,3 +301,112 @@ class arguments(list):
|
||||
def __str__(self):
|
||||
return ' '.join(self)
|
||||
|
||||
|
||||
class prioritylist(object):
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Returns an OrderedReceivers object that externaly behaves
|
||||
like a list but it maintains the order of its elements
|
||||
according to their priority.
|
||||
"""
|
||||
self.elements = defaultdict(list)
|
||||
self.is_ordered = True
|
||||
self.priorities = []
|
||||
self.size = 0
|
||||
self._cached_elements = None
|
||||
|
||||
def add(self, new_element, priority=0):
|
||||
"""
|
||||
adds a new item in the list.
|
||||
|
||||
- ``new_element`` the element to be inserted in the prioritylist
|
||||
- ``priority`` is the priority of the element which specifies its
|
||||
order withing the List
|
||||
"""
|
||||
self._add_element(new_element, priority)
|
||||
|
||||
def add_before(self, new_element, element):
|
||||
priority, index = self._priority_index(element)
|
||||
self._add_element(new_element, priority, index)
|
||||
|
||||
def add_after(self, new_element, element):
|
||||
priority, index = self._priority_index(element)
|
||||
self._add_element(new_element, priority, index + 1)
|
||||
|
||||
def index(self, element):
|
||||
return self._to_list().index(element)
|
||||
|
||||
def remove(self, element):
|
||||
index = self.index(element)
|
||||
self.__delitem__(index)
|
||||
|
||||
def _priority_index(self, element):
|
||||
for priority, elements in self.elements.iteritems():
|
||||
if element in elements:
|
||||
return (priority, elements.index(element))
|
||||
raise IndexError(element)
|
||||
|
||||
def _to_list(self):
|
||||
if self._cached_elements is None:
|
||||
self._cached_elements = []
|
||||
for priority in self.priorities:
|
||||
self._cached_elements += self.elements[priority]
|
||||
return self._cached_elements
|
||||
|
||||
def _add_element(self, element, priority, index=None):
|
||||
if index is None:
|
||||
self.elements[priority].append(element)
|
||||
else:
|
||||
self.elements[priority].insert(index, element)
|
||||
self.size += 1
|
||||
self._cached_elements = None
|
||||
if priority not in self.priorities:
|
||||
insort(self.priorities, priority)
|
||||
|
||||
def _delete(self, priority, priority_index):
|
||||
del self.elements[priority][priority_index]
|
||||
self.size -= 1
|
||||
if len(self.elements[priority]) == 0:
|
||||
self.priorities.remove(priority)
|
||||
self._cached_elements = None
|
||||
|
||||
def __iter__(self):
|
||||
for priority in reversed(self.priorities): # highest priority first
|
||||
for element in self.elements[priority]:
|
||||
yield element
|
||||
|
||||
def __getitem__(self, index):
|
||||
return self._to_list()[index]
|
||||
|
||||
def __delitem__(self, index):
|
||||
if isinstance(index, numbers.Integral):
|
||||
index = int(index)
|
||||
if index < 0:
|
||||
index_range = [len(self) + index]
|
||||
else:
|
||||
index_range = [index]
|
||||
elif isinstance(index, slice):
|
||||
index_range = range(index.start or 0, index.stop, index.step or 1)
|
||||
else:
|
||||
raise ValueError('Invalid index {}'.format(index))
|
||||
current_global_offset = 0
|
||||
priority_counts = {priority: count for (priority, count) in
|
||||
zip(self.priorities, [len(self.elements[p]) for p in self.priorities])}
|
||||
for priority in self.priorities:
|
||||
if not index_range:
|
||||
break
|
||||
priority_offset = 0
|
||||
while index_range:
|
||||
del_index = index_range[0]
|
||||
if priority_counts[priority] + current_global_offset <= del_index:
|
||||
current_global_offset += priority_counts[priority]
|
||||
break
|
||||
within_priority_index = del_index - \
|
||||
(current_global_offset + priority_offset)
|
||||
self._delete(priority, within_priority_index)
|
||||
priority_offset += 1
|
||||
index_range.pop(0)
|
||||
|
||||
def __len__(self):
|
||||
return self.size
|
||||
|
Reference in New Issue
Block a user