Skip to content

Commit

Permalink
Revert "feat: remove custom operators"
Browse files Browse the repository at this point in the history
Merge pull request #40 from datagouv/revert-39-remove-custom-operators
  • Loading branch information
Pierlou authored Mar 12, 2024
2 parents 3c15aca + 3f217ab commit c8753be
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/operators/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
__pycache__/
32 changes: 32 additions & 0 deletions plugins/operators/clean_folder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import os
import shutil
from typing import Optional

from airflow.models import BaseOperator


class CleanFolderOperator(BaseOperator):
"""
Clean tmp folder
:param folder_path: path of folder to clean
:type folder_path: str
"""

supports_lineage = True

template_fields = ("folder_path",)

def __init__(
self,
*,
folder_path: Optional[str] = None,
**kwargs,
) -> None:
super().__init__(**kwargs)

self.folder_path = folder_path

def execute(self, context):
if os.path.exists(self.folder_path) and os.path.isdir(self.folder_path):
shutil.rmtree(self.folder_path)

0 comments on commit c8753be

Please sign in to comment.