|
13 | 13 | import time
|
14 | 14 |
|
15 | 15 | import strfile
|
| 16 | +import rot13 |
16 | 17 |
|
17 | 18 | # Version string used by the what(1) and ident(1) commands:
|
18 |
| -ID = "@(#) $Id: fortune - print a random, hopefully interesting, adage v1.0.0 (August 11, 2021) by Hubert Tournier $" |
| 19 | +ID = "@(#) $Id: fortune - print a random, hopefully interesting, adage v1.0.2 (August 13, 2021) by Hubert Tournier $" |
19 | 20 |
|
20 | 21 | # Default parameters. Can be overcome by environment variables, then command line options
|
21 | 22 | parameters = {
|
@@ -555,7 +556,7 @@ def search_for_pattern(fortune_files):
|
555 | 556 | continue
|
556 | 557 |
|
557 | 558 | if file["Header"]["rotated flag"]:
|
558 |
| - fortune = rot13(fortune) |
| 559 | + fortune = rot13.rot(fortune) |
559 | 560 |
|
560 | 561 | if parameters["Ignore case"]:
|
561 | 562 | results = re.search(parameters["Pattern"], fortune, flags=re.IGNORECASE)
|
@@ -592,24 +593,6 @@ def select_fortune_file(fortune_files):
|
592 | 593 | return None
|
593 | 594 |
|
594 | 595 |
|
595 |
| -################################################################################ |
596 |
| -def rot13(fortune): |
597 |
| - """Return the ROT13 version of the given fortune""" |
598 |
| - # TODO: |
599 |
| - # To be moved one day in a future rot13 command/library |
600 |
| - rotated_fortune = "" |
601 |
| - for character in fortune: |
602 |
| - if character.isalpha(): |
603 |
| - if character.isupper(): |
604 |
| - rotated_fortune += chr(ord('A') + (ord(character) - ord('A') + 13) % 26) |
605 |
| - else: |
606 |
| - rotated_fortune += chr(ord('a') + (ord(character) - ord('a') + 13) % 26) |
607 |
| - else: |
608 |
| - rotated_fortune += character |
609 |
| - |
610 |
| - return rotated_fortune |
611 |
| - |
612 |
| - |
613 | 596 | ################################################################################
|
614 | 597 | def select_fortune(file):
|
615 | 598 | """Randomly choose a fortune from a fortune file"""
|
@@ -643,7 +626,7 @@ def select_fortune(file):
|
643 | 626 | continue
|
644 | 627 |
|
645 | 628 | if file["Header"]["rotated flag"]:
|
646 |
| - return rot13(fortune) |
| 629 | + return rot13.rot(fortune) |
647 | 630 |
|
648 | 631 | return fortune
|
649 | 632 |
|
|
0 commit comments