Skip to content

Commit

Permalink
Use StashLogHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
stg-annon committed Aug 6, 2024
1 parent 9086cda commit 7e65adf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions plugins/performerBodyCalculator/example_config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from stashapi.log import StashLogLevel
from body_tags import *

# Log level will skip logging lower levels
log_level = StashLogLevel.INFO
log_level = 'INFO'

# Comment out tags you dont want in Stash
TAGS_TO_USE = (
Expand Down
6 changes: 3 additions & 3 deletions plugins/performerBodyCalculator/performer_body_calculator.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import sys, json
import logging as log
from collections import defaultdict

import config
from performer_calculator import *
from body_tags import *

try:
from stashapi.log import StashLogger
from stashapi.log import StashLogHandler
from stashapi.stashapp import StashInterface
from stashapi.stash_types import OnMultipleMatch
except ModuleNotFoundError:
print("You need to install stashapp-tools. (https://pypi.org/project/stashapp-tools/)", file=sys.stderr)
print("If you have pip (normally installed with python), run this command in a terminal (cmd): 'pip install stashapp-tools'", file=sys.stderr)
sys.exit()

log = StashLogger(config.log_level)
log.basicConfig(format="%(message)s", handlers=[StashLogHandler()], level=config.log_level)

def main(stash_in=None, mode_in=None):
global stash
Expand Down
9 changes: 5 additions & 4 deletions plugins/performerBodyCalculator/performer_calculator.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import re, sys
import logging as log

import config
from body_tags import *

try:
from stashapi.log import StashLogger
from stashapi.log import StashLogHandler
except ModuleNotFoundError:
print("You need to install stashapp-tools. (https://pypi.org/project/stashapp-tools/)", file=sys.stderr)
print("If you have pip (normally installed with python), run this command in a terminal (cmd): 'pip install stashapp-tools'", file=sys.stderr)
sys.exit()
log = StashLogger(config.log_level)
log.basicConfig(format="%(message)s", handlers=[StashLogHandler()], level=config.log_level)

class DebugException(Exception):
pass
Expand Down Expand Up @@ -76,15 +77,15 @@ def parse_measurements(self):
raise DebugException(f"No measurements found for {str(self)}")

# Full Measurements | Band, Cup Size, Waist, Hips | Example: "32D-28-34"
if band_cup_waist_hips := re.match(r'^(?P<band>\d+)(?P<cupsize>[a-zA-Z]+)\-(?P<waist>\d+)\-(?P<hips>\d+)$', self.measurements):
if band_cup_waist_hips := re.match(r'^(?P<band>\d+)(?P<cupsize>[a-zA-Z]+)\-(?P<waist>\d+)\-(?P<hips>\d+)$', self.measurements):
m = band_cup_waist_hips.groupdict()

# Fashion Measurements | Bust, Waist, Hips | Example: "36-28-34"
elif bust_waist_hips := re.match(r'^(?P<bust>\d+)\-(?P<waist>\d+)\-(?P<hips>\d+)$', self.measurements):
m = bust_waist_hips.groupdict()

# Bra Measurements | Band, Cup Size | Example: "32D", "32D (81D)", "32D-??-??"
elif band_cup := re.match(r'^(?P<band>\d+)(?P<cupsize>[a-zA-Z]+)', self.measurements):
elif band_cup := re.match(r'^(?P<band>\d+)(?P<cupsize>[a-zA-Z]+)', self.measurements):
m = band_cup.groupdict()

# Error cant parse given measurements
Expand Down

0 comments on commit 7e65adf

Please sign in to comment.