Created
March 29, 2019 06:11
-
-
Save icoxfog417/3a7b47f8f4b3dc3c0a0332c7ab970c3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EDINETGetDocumentsOperator(BaseOperator): | |
@apply_defaults | |
def __init__(self, filter_func=None, *args, **kwargs): | |
self.filter_func = filter_func | |
super().__init__(*args, **kwargs) | |
def execute(self, context): | |
self.log.info("Retreave list of documents from EDINET @ {}.".format( | |
self.start_date.strftime("%Y/%m/%d"))) | |
client = api.DocumentListClient() | |
documents = client.get(self.start_date) | |
total_count = len(documents) | |
if self.filter_func: | |
documents = [d for i, d in enumerate(documents) | |
if self.filter_func(i, d)] | |
self.log.info("Dealing {}/{} documents.".format( | |
len(documents), total_count)) | |
document_ids = [d.document_id for d in documents] | |
return document_ids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment