File size: 533 Bytes
089cd7d
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import re

def reference(value, fallback):
    text = ' '.join(str(value or '').split())
    if not text or re.fullmatch('(?:s[123]_.+|R\\d+|L\\d+-\\d+|H1-\\d+)', text):
        return fallback
    text = re.sub('#\\d+\\s*', '', text).strip()
    if not text:
        return fallback
    return text if text.lower().startswith(('the ', 'this ', 'that ', 'your ')) else 'the ' + text

def rejection(item=None, target=None):
    return 'You cannot use ' + reference(item, 'this item') + ' on ' + reference(target, 'this object') + '.'