Added a function as utility in /src/Config/Config.py that only reads text files, throws error otherwise
def is_text_file(self, file_name):
try:
with open(file_name, 'tr') as check_file:
check_file.read()
return True
except:
return False
Used this function as a check for text files and updated set_temp function in /src/Cli/config.py for the same
@click.command()
@click.argument('path', type=str)
def set_temp(path):
try:
config = Config()
if config.is_text_file(path):
config.set_template(path)
click.echo(click.style('Template path set', fg='green'))
else:
click.echo(click.style('Template must be a text file', fg='red'))
except Exception as e:
click.echo(e)
Added a function as utility in /src/Config/Config.py that only reads text files, throws error otherwise
Used this function as a check for text files and updated set_temp function in /src/Cli/config.py for the same