mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-23 13:20:41 +00:00
60 lines
1.4 KiB
Python
60 lines
1.4 KiB
Python
#
|
|
# Copyright (C) 2018 Satoru SATOH <ssato @ redhat.com>
|
|
# License: MIT
|
|
#
|
|
r"""Abstract processor module.
|
|
|
|
.. versionadded:: 0.9.5
|
|
|
|
- Add to abstract processors such like Parsers (loaders and dumpers).
|
|
"""
|
|
from __future__ import absolute_import
|
|
|
|
|
|
class Processor(object):
|
|
"""
|
|
Abstract processor class to provide basic implementation of some methods,
|
|
interfaces and members.
|
|
|
|
- _type: type indicates data types it can process
|
|
- _priority: Priority to select it if there are others of same type
|
|
- _extensions: File extensions of data type it can process
|
|
|
|
.. note::
|
|
This class ifself is not a singleton but its children classes should so
|
|
in most cases, I think.
|
|
"""
|
|
_cid = None
|
|
_type = None
|
|
_priority = 0 # 0 (lowest priority) .. 99 (highest priority)
|
|
_extensions = []
|
|
|
|
@classmethod
|
|
def cid(cls):
|
|
"""Processor class ID
|
|
"""
|
|
return repr(cls) if cls._cid is None else cls._cid
|
|
|
|
@classmethod
|
|
def type(cls):
|
|
"""Processors' type
|
|
"""
|
|
return cls._type
|
|
|
|
@classmethod
|
|
def priority(cls):
|
|
"""Processors's priority
|
|
"""
|
|
return cls._priority
|
|
|
|
@classmethod
|
|
def extensions(cls):
|
|
"""A list of file extensions of files which this process can process.
|
|
"""
|
|
return cls._extensions
|
|
|
|
def __eq__(self, other):
|
|
return self.cid() == other.cid()
|
|
|
|
# vim:sw=4:ts=4:et:
|