Some logging and comments
This commit is contained in:
@ -10,7 +10,7 @@ import numexpr
|
||||
|
||||
from . import errors
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||
|
||||
VALID_OPERATORS = 'k|rr|ro|mi|ma|ra|e|p'
|
||||
VALID_OPERATORS_ARRAY = VALID_OPERATORS.split('|')
|
||||
@ -41,10 +41,10 @@ def get_roll_comment(rollStr):
|
||||
no_comment = ''
|
||||
dice_set = re.split('([-+*/().=])', rollStr)
|
||||
dice_set = [d for d in dice_set if not d in (None, '')]
|
||||
log.debug("Found dice set: " + str(dice_set))
|
||||
logging.debug("Found dice set: " + str(dice_set))
|
||||
for index, dice in enumerate(dice_set):
|
||||
match = DICE_PATTERN.match(dice)
|
||||
log.debug("Found dice group: " + str(match.groups()))
|
||||
logging.debug("Found dice group: " + str(match.groups()))
|
||||
no_comment += dice.replace(match.group(5), '')
|
||||
if match.group(5):
|
||||
comment = match.group(5) + ''.join(dice_set[index + 1:])
|
||||
@ -85,10 +85,10 @@ class Roll(object):
|
||||
# parse each, returning a SingleDiceResult
|
||||
dice_set = re.split('([-+*/().=])', rollStr)
|
||||
dice_set = [d for d in dice_set if not d in (None, '')]
|
||||
log.debug("Found dice set: " + str(dice_set))
|
||||
logging.debug("Found dice set: " + str(dice_set))
|
||||
for index, dice in enumerate(dice_set):
|
||||
match = DICE_PATTERN.match(dice)
|
||||
log.debug("Found dice group: " + str(match.groups()))
|
||||
logging.debug("Found dice group: " + str(match.groups()))
|
||||
# check if it's dice
|
||||
if match.group(1):
|
||||
roll = self.roll_one(dice.replace(match.group(5), ''), adv)
|
||||
@ -157,7 +157,7 @@ class Roll(object):
|
||||
skeleton=skeletonReply, raw_dice=self)
|
||||
except Exception as ex:
|
||||
if not isinstance(ex, (SyntaxError, KeyError, errors.AvraeException)):
|
||||
log.error('Error in roll() caused by roll {}:'.format(rollStr))
|
||||
logging.error('Error in roll() caused by roll {}:'.format(rollStr))
|
||||
traceback.print_exc()
|
||||
return DiceResult(verbose_result="Invalid input: {}".format(ex))
|
||||
|
||||
|
Reference in New Issue
Block a user