Skip to content

Commit

Permalink
moved the 'as_' functions into common
Browse files Browse the repository at this point in the history
  • Loading branch information
ndenny committed Sep 4, 2024
1 parent 75ed3ca commit 2e77325
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/Bastion/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import operator
import random
import pathlib
import logging

import yaml

Expand Down Expand Up @@ -295,3 +296,16 @@ def Boggle(*args):
#-- If somehow I got here without, then nothing matched the invocation.
#-- This is an error.
raise ValueError

def asLogLevel(x):
if isinstance(x, int):
return x
elif isinstance(x, str):
x = x.upper()
if x in ['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']:
return getattr(logging, x)
raise ValueError("asLogLevel - cannot interpret '{}' as a log level.".format(x))


def asPath(x):
return pathlib.Path(x)

0 comments on commit 2e77325

Please sign in to comment.