abstract compensator string manipulation

This commit is contained in:
brmnjsh 2023-09-15 19:37:47 +00:00
parent 64a1011604
commit ae4ed690f7
2 changed files with 5 additions and 3 deletions

View File

@ -12,3 +12,6 @@ def is_float(element: str) -> bool:
return True return True
except ValueError: except ValueError:
return False return False
def camel_to_snake(camel_string: str) -> str:
return re.sub(r'(?<!^)(?=[A-Z])', '_', camel_string).lower()

View File

@ -1,6 +1,6 @@
import logging, json, re import logging, json, re
from helpers import aws_helper, tar_helper from helpers import aws_helper, tar_helper, common_helper
class Base: class Base:
@ -19,9 +19,8 @@ class Base:
self.tar = tar_helper.raw_to_tar(s3_object) self.tar = tar_helper.raw_to_tar(s3_object)
# get attributes file and convert to dict # get attributes file and convert to dict
action_snake = re.sub(r'(?<!^)(?=[A-Z])', '_', self.ACTION).lower()
attributes = json.loads( attributes = json.loads(
tar_helper.extract_file_from_tar( tar_helper.extract_file_from_tar(
self.tar, f'{action_snake}_attributes.json').read()) self.tar, f'{camel_to_snake(self.ACTION)}_attributes.json').read())
return attributes return attributes