Skip to content

Commit

Permalink
fixing lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jspreddy committed Nov 28, 2020
1 parent f16ede7 commit 5fefcac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dql/cli.py
Expand Up @@ -10,8 +10,8 @@
from collections import OrderedDict
from contextlib import contextmanager
from fnmatch import fnmatch
from typing import Any, Callable, ContextManager, Dict, Optional, Tuple
from pathlib import Path
from typing import Any, Callable, ContextManager, Dict, Optional, Tuple

import botocore
from pyparsing import ParseException
Expand Down Expand Up @@ -168,17 +168,20 @@ def get_enum_key(key, choices):
if len(keys) == 1:
return keys[0]


def create_dir_if_not_exists(path):
if not os.path.exists(path):
os.makedirs(path)


def get_history_dir_and_file():
home = str(Path.home())
history_dir = os.path.join(home, '.dql')
history_dir = os.path.join(home, ".dql")
create_dir_if_not_exists(history_dir)
history_file = os.path.join(history_dir, 'history')
history_file = os.path.join(history_dir, "history")
return (history_dir, history_file)


def try_to_write_history():
(history_dir, history_file) = get_history_dir_and_file()
try:
Expand All @@ -190,6 +193,7 @@ def try_to_write_history():
readline.write_history_file(history_file)
print("History written to file: " + history_file)


def try_to_load_history():
(history_dir, history_file) = get_history_dir_and_file()
if os.path.exists(history_file):
Expand All @@ -202,6 +206,7 @@ def try_to_load_history():
else:
readline.read_history_file(history_file)


@contextmanager
def exception_handler(engine):
""" It is a context manager which can handle exceptions and deal with them. """
Expand Down

0 comments on commit 5fefcac

Please sign in to comment.