Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyperclip, time, sys, re
- # Every second, checks to make sure the contents of the clipboard are in
- # alphabetical order. I'm using this to check if the index I'm writing is in
- # alphabetical order, which is tricky since it has sub-entries which are out
- # of order relative to the main entries.
- while True:
- entries = [x.strip().lower() for x in pyperclip.paste().split('\n') if x.strip() != '']
- entries = [re.sub('[^a-z ]', '', x) for x in entries] # remove non-letter
- sortedEntries = sorted(entries)
- if entries == sortedEntries:
- print('Ok')
- else:
- print('Out of order:\n', '\n'.join(entries))
- print()
- print('Should be:\n', '\n'.join(sortedEntries))
- sys.exit()
- time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement