Example #1
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author:
#      Mateusz Kruszynski <*****@*****.**>
#
"""Module provides a simple class that is able to read tags xml file and 
give on demand subsequential tags."""

import xml.dom.minidom
from Queue import Queue
import tag_utils
import tags_logging as logger
LOGGER = logger.get_logger('tags_file_reader')


class TagsFileReader(object):
    """A simple class that is able to read tags xml file and 
    give on demand subsequential tags."""
    def __init__(self, p_tags_file_name):
        """Init tags file path."""
        self._tags_file_name = p_tags_file_name
        self._tags = []
        self.start_tags_reading()

    def start_tags_reading(self):
        """Read tags file, store data in memory."""
        try:
            l_tags_file = open(self._tags_file_name, 'rt')
Example #2
0
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author:
#      Mateusz Kruszynski <*****@*****.**>
#

"""Module provides a simple class that is able to read tags xml file and 
give on demand subsequential tags."""

import xml.dom.minidom
from Queue import Queue
import tag_utils
import tags_logging as logger
LOGGER = logger.get_logger('tags_file_reader')


class TagsFileReader(object):
    """A simple class that is able to read tags xml file and 
    give on demand subsequential tags."""

    def __init__(self, p_tags_file_name):
        """Init tags file path."""
        self._tags_file_name = p_tags_file_name
        self._tags = []
        self.start_tags_reading()

    def start_tags_reading(self):
        """Read tags file, store data in memory."""
        try:
Example #3
0
# -*- coding: utf-8 -*-
#!/usr/bin/env python
#
# Author:
#     Mateusz Kruszyński <*****@*****.**>
#
import copy
import tags_file_reader
import tags_logging as logger
LOGGER = logger.get_logger("smart_tags_source", "info")


class TagsSource(object):
    def get_tags(self):
        LOGGER.error("The method must be subclassed")

    def _filter_tags(self,
                     p_tags,
                     p_tag_type=None,
                     p_from=None,
                     p_len=None,
                     p_func=None):
        l_tags = p_tags
        if not (p_tag_type is None):
            l_tags = [i_tag for i_tag in l_tags if p_tag_type == i_tag['name']]

        if not (p_from is None):
            l_start = p_from
            l_end = p_from + p_len
            l_tags = [
                i_tag for i_tag in l_tags
Example #4
0
# -*- coding: utf-8 -*-
#!/usr/bin/env python
#
# Author:
#     Mateusz Kruszyński <*****@*****.**>
#
import copy
import tags_file_reader
import tags_logging as logger
LOGGER = logger.get_logger("smart_tags_source", "info")


class TagsSource(object):
    def get_tags(self):
        LOGGER.error("The method must be subclassed")

    def _filter_tags(self, p_tags, p_tag_type=None, p_from=None, p_len=None, p_func=None):
        l_tags = p_tags
        if not (p_tag_type is None):
            l_tags = [i_tag for i_tag in l_tags if p_tag_type == i_tag['name']]

        if not (p_from is None):
            l_start = p_from
            l_end = p_from + p_len
            l_tags = [i_tag for i_tag in l_tags if 
                      (l_start <= i_tag['start_timestamp'] and i_tag['start_timestamp'] <= l_end)]

        if not (p_func is None):
            l_tags = [i_tag for i_tag in l_tags if p_func(i_tag)]

        return l_tags