Skip to content

Commit

Permalink
Update parser
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminfisk committed Dec 2, 2023
1 parent 730485c commit fb8f06e
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions KubeSec-master/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
import os
import logging

def createLoggerObj():
fileName = '2023-12-1.log'
formatStr = '%(asctime)s %(message)s'
logging.basicConfig(format=formatStr, filename=fileName, level=logging.INFO)
myLogObj = logging.getLogger('sqa2023-logger')
return myLogObj

#update basepath
base_path = r" "

Expand Down Expand Up @@ -141,11 +134,9 @@ def checkIfValidHelm(path_script):
return val_ret

def readYAMLAsStr( path_script ):
logger = createLoggerObj()
yaml_as_str = constants.YAML_SKIPPING_TEXT
with open( path_script , constants.FILE_READ_FLAG) as file_:
yaml_as_str = file_.read()
logger.info(f'Results of opening yaml file{yaml_as_str}')
return yaml_as_str

# This function checks whether our parser throws an exception for reading the YAML file.
Expand All @@ -168,7 +159,6 @@ def checkParseError( path_script ):
return flag

def loadMultiYAML( script_ ):
logger = createLoggerObj()
dicts2ret = []
with open(script_, constants.FILE_READ_FLAG ) as yml_content :
yaml = ruamel.yaml.YAML()
Expand All @@ -179,13 +169,10 @@ def loadMultiYAML( script_ ):
# print(d_)
dicts2ret.append( d_ )
except ruamel.yaml.parser.ParserError as parse_error:
logger.info(f'Error in parsing yaml file {parse_error}')
print(constants.YAML_SKIPPING_TEXT)
except ruamel.yaml.error.YAMLError as exc:
logger.info(f'Error in parsing yaml file {exc}')
print( constants.YAML_SKIPPING_TEXT )
except UnicodeDecodeError as err_:
logger.info(f'Error in parsing yaml file {err_}')
print( constants.YAML_SKIPPING_TEXT )

path = find_json_path_keys(dicts2ret)
Expand Down

0 comments on commit fb8f06e

Please sign in to comment.