Python Forum
Text conversion to lowercase is not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text conversion to lowercase is not working
#4
Much thanks for your replies. It was my lack Python of coding practice that was the error. I corrected the Autokey script pasted below and is working fine.

I must apply Title Case to the text to be displayed as Small Caps in Wikisource/wikipedia, but the connecting words must be reverted to lowercase.

# [ alt + s ] title and small case selected text
# 240115_2129 - *alt-s-title-with-small-caps.py - /home/ineuw/.config/autokey/data/english - Geany

# clear clipboard
clipboard.fill_clipboard('')
time.sleep(0.05)

# small caps wiki template set
open_ = '{{sc|'
close_ = '}}'
copy_ = '<ctrl>+<insert>'
paste_ = '<shift>+<insert>'
time.sleep(0.05)

try:
	keyboard.send_keys(copy_)
	time.sleep(0.05)

	text_ = clipboard.get_clipboard()

except:
	time.sleep(0.05)

else:
	text_ = text_.title()
	time.sleep(0.05)

	text_=text_=text_.replace(" A "," a ")
	time.sleep(0.05)
	text_=text_.replace(" An "," an ")
	time.sleep(0.05)
	text_=text_.replace(" And "," and ")
	time.sleep(0.05)
	text_=text_.replace(" As "," as ")
	time.sleep(0.05)
	text_=text_.replace(" At "," at ")
	time.sleep(0.05)
	text_=text_.replace(" De "," de ")
	time.sleep(0.05)
	text_=text_.replace(" Du "," du ")
	time.sleep(0.05)
	text_=text_.replace(" For "," for ")
	time.sleep(0.05)
	text_=text_.replace(" In "," in ")
	time.sleep(0.05)
	text_=text_.replace(" Is "," is ")
	time.sleep(0.05)
	text_=text_.replace(" It "," it ")
	time.sleep(0.05)
	text_=text_.replace(" Not "," not ")
	time.sleep(0.05)
	text_=text_.replace(" Of "," of ")
	time.sleep(0.05)
	text_=text_.replace(" On "," on ")
	time.sleep(0.05)
	text_=text_.replace(" The ", " the ")
	time.sleep(0.05)
	text_=text_.replace(" To "," to ")
	time.sleep(0.05)

	combined_ = open_ + text_ + close_
	time.sleep(0.8)

clipboard.fill_clipboard(combined_)
time.sleep(0.05)

keyboard.send_keys(paste_)
Linux Mint Cinnamon 21.3 - Python 3.10.12 - Autokey-gtk 0.96.0 as of 2024-01-13.
Reply


Messages In This Thread
RE: Text conversion to lowercase is not working - by ineuw - Jan-16-2024, 02:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Decryption not working if key has same symbol like text Paragoon2 0 396 Nov-11-2023, 09:32 PM
Last Post: Paragoon2
  while loop not working-I am using sublime text editor mma_python 4 1,259 Feb-05-2023, 06:26 PM
Last Post: deanhystad
  ANSI not working for change of text colors BliepMonster 10 3,687 Nov-10-2022, 09:28 AM
Last Post: BliepMonster
  How to properly scale text in postscript conversion to pdf? philipbergwerf 3 1,257 Nov-07-2022, 01:30 PM
Last Post: philipbergwerf
  python-docx- change lowercase to bold, italic Tmagpy 0 1,513 Jul-01-2022, 07:25 AM
Last Post: Tmagpy
  Replace changing string including uppercase character with lowercase character silfer 11 6,401 Mar-25-2019, 12:54 PM
Last Post: silfer
  Printing from a text file not working as I thought it would PythonZenon 10 6,321 Jun-02-2018, 09:19 PM
Last Post: snippsat
  Ending loop with string (capital & lowercase) MattWilk97 3 3,528 Oct-22-2017, 09:13 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020