Ejemplo n.º 1
0
class IncomeStatementPipeline(StateMachine):
    def __init__(self, memento_path='./stockcat/data/memento/income_statement.json'):
        self.helper = EntryListHelper()
        memento_param = {
            'path' : memento_path, 
            'default_value' : self.__get_default_value(),
            'filter_key_list' : [ 'state', 'all_entry_list', 'todo_entry_list', 'last_updated_date' ],
        }
        param = {
            'memento' : memento_param,
            'spider' : IncomeStatementSpider(), 
            'assembler' : IncomeStatementAssembler(), 
            'feed_builder' : IncomeStatementFeedBuilder(),
        }
        StateMachine.__init__(self, param)

    def __get_default_value(self):
        all_entry_list = self.helper.get_all_financial_statement_entry_list()
        todo_entry_list = self.helper.get_legacy_financial_statement_entry_list()
        # !!! DEBUG ONLY !!!
        all_entry_list = all_entry_list[67:68]
        todo_entry_list = todo_entry_list[67:68]
        return {
            'state' : 'spider',
            'all_entry_list' : list(all_entry_list),
            'todo_entry_list' : list(todo_entry_list),
            'last_updated_date' : datetime.date(1949, 12, 7) 
        }
Ejemplo n.º 2
0
 def __init__(self, memento_path='./stockcat/data/memento/cash_flow.json'):
     self.helper = EntryListHelper()
     memento_param = {
         'path' : memento_path, 
         'default_value' : self.__get_default_value(),
         'filter_key_list' : [ 'state', 'all_entry_list', 'todo_entry_list', 'last_updated_date' ],
     }
     transition_table = [
         ('InitialState', 'LoadState', ''),
         ('LoadState', 'SpiderState', 'spider'),
         ('LoadState', 'AssemblerState', 'assembler'),
         ('LoadState', 'AssemblerState', 'database'),
         ('LoadState', 'FinalState', 'final'),
         ('SpiderState', 'AssemblerState', ''), 
         ('AssemblerState', 'DatabaseState', ''), 
         ('DatabaseState', 'FinalState', ''), 
     ]
     param = {
         'memento' : memento_param,
         'transition_table' : transition_table,
         'spider' : CashFlowSpider(), 
         'assembler' : CashFlowAssembler(), 
         'feed_builder' : CashFlowFeedBuilder(),
     }
     StateMachine.__init__(self, param)
class OperatingRevenuePipeline(StateMachine):
    def __init__(self, memento_path='./stockcat/data/memento/operating_revenue.json'):
        self.helper = EntryListHelper()
        memento_param = {
            'path' : memento_path, 
            'default_value' : self.__get_default_value(),
            'filter_key_list' : [ 'state', 'all_entry_list', 'todo_entry_list', 'last_updated_date' ],
        }
        param = {
            'memento' : memento_param,
            'spider' : OperatingRevenueSummarySpider(), 
            'assembler' : OperatingRevenueSummaryAssembler(), 
            'feed_builder' : OperatingRevenueSummaryFeedBuilder(),
        }
        StateMachine.__init__(self, param)

    def __get_default_value(self):
        entry_list = self.helper.get_operating_revenue_entry_list()
        # !!! DEBUG ONLY !!!
        entry_list = entry_list[:2]
        return {
            'state' : 'spider',
            'all_entry_list' : list(entry_list),
            'todo_entry_list' : list(entry_list),
            'last_updated_date' : datetime.date(1949, 12, 7) 
        }
Ejemplo n.º 4
0
class CashFlowPipeline(StateMachine):
    def __init__(self, memento_path='./stockcat/data/memento/cash_flow.json'):
        self.helper = EntryListHelper()
        memento_param = {
            'path' : memento_path, 
            'default_value' : self.__get_default_value(),
            'filter_key_list' : [ 'state', 'all_entry_list', 'todo_entry_list', 'last_updated_date' ],
        }
        transition_table = [
            ('InitialState', 'LoadState', ''),
            ('LoadState', 'SpiderState', 'spider'),
            ('LoadState', 'AssemblerState', 'assembler'),
            ('LoadState', 'AssemblerState', 'database'),
            ('LoadState', 'FinalState', 'final'),
            ('SpiderState', 'AssemblerState', ''), 
            ('AssemblerState', 'DatabaseState', ''), 
            ('DatabaseState', 'FinalState', ''), 
        ]
        param = {
            'memento' : memento_param,
            'transition_table' : transition_table,
            'spider' : CashFlowSpider(), 
            'assembler' : CashFlowAssembler(), 
            'feed_builder' : CashFlowFeedBuilder(),
        }
        StateMachine.__init__(self, param)

    def __get_default_value(self):
        all_entry_list = self.helper.get_all_financial_statement_entry_list()
        todo_entry_list = self.helper.get_legacy_financial_statement_entry_list()
        # !!! DEBUG ONLY !!!
        #all_entry_list = all_entry_list[67:68]
        #todo_entry_list = todo_entry_list[67:68]
        return {
            'state' : 'spider',
            'all_entry_list' : list(all_entry_list),
            'todo_entry_list' : list(todo_entry_list),
            'last_updated_date' : datetime.date(1949, 12, 7) 
        }
Ejemplo n.º 5
0
 def __init__(self, memento_path='./stockcat/data/memento/income_statement.json'):
     self.helper = EntryListHelper()
     memento_param = {
         'path' : memento_path, 
         'default_value' : self.__get_default_value(),
         'filter_key_list' : [ 'state', 'all_entry_list', 'todo_entry_list', 'last_updated_date' ],
     }
     param = {
         'memento' : memento_param,
         'spider' : IncomeStatementSpider(), 
         'assembler' : IncomeStatementAssembler(), 
         'feed_builder' : IncomeStatementFeedBuilder(),
     }
     StateMachine.__init__(self, param)
 def __init__(self, memento_path='./stockcat/data/memento/operating_revenue.json'):
     self.helper = EntryListHelper()
     memento_param = {
         'path' : memento_path, 
         'default_value' : self.__get_default_value(),
         'filter_key_list' : [ 'state', 'all_entry_list', 'todo_entry_list', 'last_updated_date' ],
     }
     param = {
         'memento' : memento_param,
         'spider' : OperatingRevenueSummarySpider(), 
         'assembler' : OperatingRevenueSummaryAssembler(), 
         'feed_builder' : OperatingRevenueSummaryFeedBuilder(),
     }
     StateMachine.__init__(self, param)