Skip to content

Instantly share code, notes, and snippets.

@icoxfog417
Created March 29, 2019 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icoxfog417/3a7b47f8f4b3dc3c0a0332c7ab970c3e to your computer and use it in GitHub Desktop.
Save icoxfog417/3a7b47f8f4b3dc3c0a0332c7ab970c3e to your computer and use it in GitHub Desktop.
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