diff --git a/src/calibre/gui2/email.py b/src/calibre/gui2/email.py index 516bcb531f..d33e3ae379 100644 --- a/src/calibre/gui2/email.py +++ b/src/calibre/gui2/email.py @@ -170,12 +170,8 @@ def send_mails(jobnames, callback, attachments, to_s, subjects, # file internal metadata so don't nuke the filename. # https://www.mobileread.com/forums/showthread.php?t=349290 aname = f'{uuid4()}.' + aname.rpartition('.')[-1] - import random - - from calibre.utils.random_ua import common_english_words, random_english_text - words = common_english_words() - num_in_subject = random.randrange(3, 9) - subject = ' '.join(random.choice(words) for i in range(num_in_subject)) + from calibre.utils.random_ua import random_english_text + subject = random_english_text(min_words_per_sentence=3, max_words_per_sentence=9, max_num_sentences=1).rstrip('.') text = random_english_text() job = ThreadedJob('email', description, gui_sendmail, (attachment, aname, to, subject, text), {}, callback) diff --git a/src/calibre/utils/random_ua.py b/src/calibre/utils/random_ua.py index 082a548525..d9521ab135 100644 --- a/src/calibre/utils/random_ua.py +++ b/src/calibre/utils/random_ua.py @@ -23,13 +23,13 @@ def common_english_words(): return ans -def random_english_text(): +def random_english_text(max_num_sentences=3, min_words_per_sentence=8, max_words_per_sentence=41): import random - num_sentences = random.randrange(1, 4) + num_sentences = random.randrange(1, max_num_sentences+1) words = common_english_words() def sentence(): - num_words = random.randrange(23, 42) + num_words = random.randrange(min_words_per_sentence, max_words_per_sentence+1) return ' '.join(random.choice(words) for i in range(num_words)).capitalize() + '.' return ' '.join(sentence() for i in range(num_sentences))