コード例 #1
0
class BaseParser:
    """Abstract base parser for data pipeline parsers.

    Attributes:
        extractor (:obj:`parsing.library.extractor.Extractor`)
        ingestor (:obj:`parsing.library.ingestor.Ingestor`)
        requester (:obj:`parsing.library.requester.Requester`)
        school (:obj:`str`): School that parser is for.
    """

    __metaclass__ = ABCMeta

    def __init__(self,
                 school,
                 config=None,
                 output_path=None,
                 output_error_path=None,
                 break_on_error=True,
                 break_on_warning=False,
                 skip_duplicates=True,
                 display_progress_bar=False,
                 validate=True,
                 tracker=None):
        """Create base parser instance.

        Args:
            school (str): The subject school.
            config (None, dict, optional): Configuration dictionary.
            output_path (None, str, optional)
            output_error_path (None, str, optional)
            break_on_error (bool, optional)
            break_on_warning (bool, optional)
            skip_duplicates (bool, optional): TODO
            display_progress_bar (bool, optional)
            validate (bool, optional): Flag to validate or not.
            tracker (None, Tracker, optional): Tracker to track parse.
        """
        self.school = school
        self.requester = Requester()
        self.tracker = tracker
        self.ingestor = Ingestor(config,
                                 output_path,
                                 break_on_error=break_on_error,
                                 break_on_warning=break_on_warning,
                                 skip_duplicates=skip_duplicates,
                                 display_progress_bar=display_progress_bar,
                                 validate=validate,
                                 tracker=self.tracker)

    @abstractmethod
    def start(self, **kwargs):
        """Start the parse.

        Args:
            **kwargs: expanded in child parser.
        """

    def end(self):
        """Finish the parse."""
        self.ingestor.end()
コード例 #2
0
ファイル: base_parser.py プロジェクト: majidaziz/semesterly
class BaseParser:
    """Abstract base parser for data pipeline parsers.

    Attributes:
        extractor (:obj:`parsing.library.extractor.Extractor`)
        ingestor (:obj:`parsing.library.ingestor.Ingestor`)
        requester (:obj:`parsing.library.requester.Requester`)
        school (:obj:`str`): School that parser is for.
    """

    __metaclass__ = ABCMeta

    def __init__(self, school,
                 config=None,
                 output_path=None,
                 output_error_path=None,
                 break_on_error=True,
                 break_on_warning=False,
                 skip_duplicates=True,
                 display_progress_bar=False,
                 validate=True,
                 tracker=None):
        """Create base parser instance.

        Args:
            school (str): The subject school.
            config (None, dict, optional): Configuration dictionary.
            output_path (None, str, optional)
            output_error_path (None, str, optional)
            break_on_error (bool, optional)
            break_on_warning (bool, optional)
            skip_duplicates (bool, optional): TODO
            display_progress_bar (bool, optional)
            validate (bool, optional): Flag to validate or not.
            tracker (None, Tracker, optional): Tracker to track parse.
        """
        self.school = school
        self.requester = Requester()
        self.tracker = tracker
        self.ingestor = Ingestor(config,
                                 output_path,
                                 break_on_error=break_on_error,
                                 break_on_warning=break_on_warning,
                                 skip_duplicates=skip_duplicates,
                                 display_progress_bar=display_progress_bar,
                                 validate=validate,
                                 tracker=self.tracker)

    @abstractmethod
    def start(self, **kwargs):
        """Start the parse.

        Args:
            **kwargs: expanded in child parser.
        """

    def end(self):
        """Finish the parse."""
        self.ingestor.end()
コード例 #3
0
ファイル: base_parser.py プロジェクト: majidaziz/semesterly
    def __init__(self, school,
                 config=None,
                 output_path=None,
                 output_error_path=None,
                 break_on_error=True,
                 break_on_warning=False,
                 skip_duplicates=True,
                 display_progress_bar=False,
                 validate=True,
                 tracker=None):
        """Create base parser instance.

        Args:
            school (str): The subject school.
            config (None, dict, optional): Configuration dictionary.
            output_path (None, str, optional)
            output_error_path (None, str, optional)
            break_on_error (bool, optional)
            break_on_warning (bool, optional)
            skip_duplicates (bool, optional): TODO
            display_progress_bar (bool, optional)
            validate (bool, optional): Flag to validate or not.
            tracker (None, Tracker, optional): Tracker to track parse.
        """
        self.school = school
        self.requester = Requester()
        self.tracker = tracker
        self.ingestor = Ingestor(config,
                                 output_path,
                                 break_on_error=break_on_error,
                                 break_on_warning=break_on_warning,
                                 skip_duplicates=skip_duplicates,
                                 display_progress_bar=display_progress_bar,
                                 validate=validate,
                                 tracker=self.tracker)
コード例 #4
0
ファイル: base_parser.py プロジェクト: Boccca2014/semesterly
    def __init__(
        self,
        school,
        config=None,
        output_path=None,
        output_error_path=None,
        break_on_error=True,
        break_on_warning=False,
        skip_duplicates=True,
        display_progress_bar=False,
        validate=True,
        tracker=None,
    ):
        """Create base parser instance.

        Args:
            school (str): The subject school.
            config (None, dict, optional): Configuration dictionary.
            output_path (None, str, optional)
            output_error_path (None, str, optional)
            break_on_error (bool, optional)
            break_on_warning (bool, optional)
            skip_duplicates (bool, optional): TODO
            display_progress_bar (bool, optional)
            validate (bool, optional): Flag to validate or not.
            tracker (None, Tracker, optional): Tracker to track parse.
        """
        self.school = school
        self.requester = Requester()
        self.tracker = tracker
        self.ingestor = Ingestor(
            config,
            output_path,
            break_on_error=break_on_error,
            break_on_warning=break_on_warning,
            skip_duplicates=skip_duplicates,
            display_progress_bar=display_progress_bar,
            validate=validate,
            tracker=self.tracker,
        )
コード例 #5
0
    def __init__(self,
                 school,
                 config_path=None,
                 output_path=None,
                 output_error_path=None,
                 break_on_error=True,
                 break_on_warning=False,
                 skip_duplicates=True,
                 display_progress_bar=False,
                 validate=True,
                 tracker=None):
        """Create base parser instance.

        Args:
            school (str): Description
            config_path (None, str, optional): Description
            output_path (None, str, optional): Description
            output_error_path (None, str, optional): Description
            break_on_error (bool, optional): Description
            break_on_warning (bool, optional): Description
            skip_duplicates (bool, optional): Description
            display_progress_bar (bool, optional): Description
            validate (bool, optional): Description
            tracker (None, optional): Description
        """
        self.school = school
        self.requester = Requester()
        self.extractor = Extractor()
        self.ingestor = Ingestor(school,
                                 config_path,
                                 output_path,
                                 output_error_path,
                                 break_on_error=break_on_error,
                                 break_on_warning=break_on_warning,
                                 skip_duplicates=skip_duplicates,
                                 display_progress_bar=display_progress_bar,
                                 validate=validate,
                                 tracker=tracker)
コード例 #6
0
class BaseParser:
    """Abstract base parser for data pipeline parsers.

    Attributes:
        extractor (:obj:`parsing.library.extractor.Extractor`)
        ingestor (:obj:`parsing.library.ingestor.Ingestor`)
        requester (:obj:`parsing.library.requester.Requester`)
        school (:obj:`str`): School that parser is for.
    """

    __metaclass__ = ABCMeta

    def __init__(self,
                 school,
                 config_path=None,
                 output_path=None,
                 output_error_path=None,
                 break_on_error=True,
                 break_on_warning=False,
                 skip_duplicates=True,
                 display_progress_bar=False,
                 validate=True,
                 tracker=None):
        """Create base parser instance.

        Args:
            school (str): Description
            config_path (None, str, optional): Description
            output_path (None, str, optional): Description
            output_error_path (None, str, optional): Description
            break_on_error (bool, optional): Description
            break_on_warning (bool, optional): Description
            skip_duplicates (bool, optional): Description
            display_progress_bar (bool, optional): Description
            validate (bool, optional): Description
            tracker (None, optional): Description
        """
        self.school = school
        self.requester = Requester()
        self.extractor = Extractor()
        self.ingestor = Ingestor(school,
                                 config_path,
                                 output_path,
                                 output_error_path,
                                 break_on_error=break_on_error,
                                 break_on_warning=break_on_warning,
                                 skip_duplicates=skip_duplicates,
                                 display_progress_bar=display_progress_bar,
                                 validate=validate,
                                 tracker=tracker)

    @abstractmethod
    def start(self, **kwargs):
        """Start the parse.

        Args:
            **kwargs: pass-through to child parser.
        """

    def end(self):
        """Finish the parse."""
        self.ingestor.end()