Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
akuny committed Jan 24, 2024
1 parent f7ba17d commit 33d2c47
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
19 changes: 13 additions & 6 deletions nad_ch/application_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,29 @@ def __init__(self):

def create_provider_repository(self):
return SqlAlchemyDataProviderRepository(
create_session_factory(config.DATABASE_URL))
create_session_factory(config.DATABASE_URL)
)

def create_submission_repository(self):
return SqlAlchemyDataSubmissionRepository(
create_session_factory(config.DATABASE_URL))
create_session_factory(config.DATABASE_URL)
)

def create_logger(self):
return Logger(__name__)

def create_storage(self):
return S3Storage(config.S3_ACCESS_KEY, config.S3_SECRET_ACCESS_KEY,
config.S3_REGION, config.S3_BUCKET_NAME)
return S3Storage(
config.S3_ACCESS_KEY,
config.S3_SECRET_ACCESS_KEY,
config.S3_REGION,
config.S3_BUCKET_NAME,
)

def create_task_queue(self):
return RedisTaskQueue("task-queue", config.QUEUE_PASSWORD,
config.QUEUE_HOST, config.QUEUE_PORT)
return RedisTaskQueue(
"task-queue", config.QUEUE_PASSWORD, config.QUEUE_HOST, config.QUEUE_PORT
)

@property
def providers(self):
Expand Down
4 changes: 2 additions & 2 deletions nad_ch/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .base import APP_ENV


if APP_ENV == 'dev_local' or APP_ENV == 'test':
if APP_ENV == "dev_local" or APP_ENV == "test":
from .development_local import *
elif APP_ENV == 'dev_remote':
elif APP_ENV == "dev_remote":
from .development_remote import *
6 changes: 3 additions & 3 deletions nad_ch/domain/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def __repr__(self):

@staticmethod
def generate_filename(file_path: str, provider: DataProvider) -> str:
s = re.sub(r'\W+', '_', provider.name)
s = re.sub(r"\W+", "_", provider.name)
s = s.lower()
s = s.strip('_')
formatted_provider_name = re.sub(r'_+', '_', s)
s = s.strip("_")
formatted_provider_name = re.sub(r"_+", "_", s)
datetime_str = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
_, file_extension = os.path.splitext(file_path)
filename = f"{formatted_provider_name}_{datetime_str}{file_extension}"
Expand Down
5 changes: 3 additions & 2 deletions nad_ch/infrastructure/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@


class S3Storage:
def __init__(self, access_key_id: str, secret_access_key: str, region: str,
bucket: str):
def __init__(
self, access_key_id: str, secret_access_key: str, region: str, bucket: str
):
self.s3client = boto3.client(
"s3",
aws_access_key_id=access_key_id,
Expand Down
2 changes: 1 addition & 1 deletion nad_ch/use_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def ingest_data_submission(
return

_, file_extension = os.path.splitext(file_path)
if file_extension.lower() not in ['.zip', '.csv']:
if file_extension.lower() not in [".zip", ".csv"]:
ctx.logger.error("Invalid file format. Only ZIP or CSV files are accepted.")
return

Expand Down

0 comments on commit 33d2c47

Please sign in to comment.