def __init__(self, domain, neo4j_conn, kafka_server, conf): self.worker = Worker(neo4j_conn, domain=domain) self.domain = domain self.topic = conf['doc']['type'] self.producer = self.connect_kafka(kafka_server) for config in conf: self.kafka_handler(config)
def __init__(self, domain, neo4j_conn, output_path, conf): self.worker = Worker(neo4j_conn, domain=domain) self.xls_handler = XlsHanler( os.path.join(output_path, 'DOMAIN_{0}.xlsx'.format(domain))) self.domain = domain self.output_path = output_path for tab_config in conf: self.tab_handler(tab_config)
def __init__(self, email_address, neo4j_conn, output_path, conf): self.worker = Worker(neo4j_conn, email_address=email_address) self.xls_handler = XlsHanler( os.path.join(output_path, 'EMAIL_{0}.xlsx'.format(email_address))) self.email_address = email_address self.output_path = output_path for tab_config in conf: self.tab_handler(tab_config)
def __init__(self, message_id, neo4j_conn, output_path, conf): self.worker = Worker(neo4j_conn, message_id=message_id) self.xls_handler = XlsHanler(os.path.join( output_path, 'HEADER_{0}.xlsx'.format(message_id))) self.message_id = message_id self.output_path = output_path for tab_config in conf: self.tab_handler(tab_config)
class Domain_to_XLSX(): def __init__(self, domain, neo4j_conn, output_path, conf): self.worker = Worker(neo4j_conn, domain=domain) self.xls_handler = XlsHanler( os.path.join(output_path, 'DOMAIN_{0}.xlsx'.format(domain))) self.domain = domain self.output_path = output_path for tab_config in conf: self.tab_handler(tab_config) def tab_handler(self, tab_config): row = 0 col = 0 gap = tab_config['gap'] if tab_config['orientation'] == 'vertical': vt = True else: vt = False for query in tab_config['queries']: data = self.worker.get_result(query['query']) title = query['title'] if not data: continue row, col = self.xls_handler.save_data_to_tab( tab_config['name'], title, data, row, col, vt, tab_config['autofit']) if vt: col += gap row = 0 else: row += gap col = 0
class Domain_to_Kafka(): def __init__(self, domain, neo4j_conn, kafka_server, conf): self.worker = Worker(neo4j_conn, domain=domain) self.domain = domain self.topic = conf['doc']['type'] self.producer = self.connect_kafka(kafka_server) for config in conf: self.kafka_handler(config) def connect_kafka(self, server): return KafkaProducer(bootstrap_servers=server) def kafka_handler(self, config): for query in config['queries']: data = self.worker.get_result(query['query']) if data: keys = data[0].keys() for v in data: for k in keys: self.producer.send(self.topic, k, v[k])