Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wow, very word density #67

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
wow, very word density
  • Loading branch information
Heath123 committed Sep 4, 2020
commit fc3aa9b25254ea735a256fc703d5f9bb79825438
24 changes: 22 additions & 2 deletions doge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ def setup(self):
doge = []
max_doge = 15

if self.ns.density > 3.5:
sys.stderr.write('wow, density such over 3.5, too high\n')
sys.exit(1)

if self.ns.density < 0:
sys.stderr.write('wow, density such negative, too low\n')
sys.exit(1)

if self.tty.width < max_doge:
# Shibe won't fit, so abort.
sys.stderr.write('wow, such small terminal\n')
Expand Down Expand Up @@ -122,7 +130,11 @@ def apply_text(self):
# Calculate a random sampling of lines that are to have text applied
# onto them. Return value is a sorted list of line index integers.
linelen = len(self.lines)
affected = sorted(random.sample(range(linelen), int(linelen / 3.5)))

if self.ns.density == 0:
return

affected = sorted(random.sample(range(linelen), int(linelen / (3.5 / self.ns.density))))

for i, target in enumerate(affected, start=1):
line = self.lines[target]
Expand Down Expand Up @@ -474,6 +486,13 @@ def setup_arguments():
help='such max width',
type=int,
)

parser.add_argument(
'-d', '--density',
help='such word density, max is 3.5, default is 1, wow',
type=float,
default=1,
)
return parser


Expand Down Expand Up @@ -521,6 +540,7 @@ def main():
return 1


# wow very main
wow very main
if __name__ == "__main__":
sys.exit(main())
main()