Added pyquotes

This commit is contained in:
rakete 2022-10-13 01:18:33 +02:00
parent ffc2b2f6fc
commit e7e340e1b3
38 changed files with 252 additions and 0 deletions

122
.local/bin/pyquotes Executable file
View File

@ -0,0 +1,122 @@
#!/usr/bin/python3
"""
Copyright (C) 2021 Jenny Rakete
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import argparse
import os.path
import random
from os import environ, scandir
VERSION = "1.1"
BANNER = f"""\
pyquotes {VERSION} - Copyright (C) 2021 Jenny Rakete
This is free software; see the beginning of this file for copying conditions.
There is NO warranty;
not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."""
QUOTEPATH = (
environ["QUOTEPATH"] if "QUOTEPATH" in environ else "/usr/share/pyquotes"
)
def get_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("quotedirs", action="extend", nargs="*",
help="list of quotedirs to select quotes from")
parser.add_argument("-l", "--list", action="store_true",
help="list all known quotedirs")
parser.add_argument("-V", "--version", action="store_true",
help="print version information")
options = parser.parse_args()
return options
def parse_arguments(options: argparse.Namespace):
if options.version:
print(BANNER)
exit()
if len(options.quotedirs) == 0:
options.quotedirs = [quotedir.name for quotedir in get_quotedirs()]
if options.list:
list_quotedirs(options.quotedirs)
exit()
def get_quotedirs():
try:
return [quote_dir for quote_dir
in scandir(QUOTEPATH)
if quote_dir.is_dir()]
except FileNotFoundError:
print(f"quotepath `{QUOTEPATH}` does not exist. "
"Is $QUOTEPATH set correctly?")
exit(1)
def list_quotedirs(quote_dirs: list):
output = {}
total_quotes = 0
for quote_dir in quote_dirs:
output[quote_dir] = len(
[_ for _ in scandir(QUOTEPATH + os.path.sep + quote_dir)])
total_quotes += output[quote_dir]
print("\n".join(
["{percentage:.2f}%\t {name} ({amount})".format(
percentage=(output[name] / total_quotes * 100),
name=name,
amount=output[name],
) for name in output]
))
def get_quote(quotedirs: list):
quote_files = []
for quotedir in quotedirs:
try:
new_quote_files = [file for file
in scandir(QUOTEPATH + os.path.sep + quotedir)
if file.is_file()]
except FileNotFoundError:
print(f"quotedir `{quotedir}` not found in `{QUOTEPATH}`. ")
exit(1)
quote_files += [quote_file for quote_file
in new_quote_files
if quote_file.name.endswith(".quote")]
quote_file = random.choice(quote_files)
with open(quote_file.path) as quote_file:
return "".join(quote_file.readlines())
def main():
options = get_arguments()
parse_arguments(options)
quote = get_quote(options.quotedirs)
print(quote, end="\n" * (quote[-1] != "\n"))
if __name__ == "__main__":
main()

View File

@ -0,0 +1,3 @@
If consumers even know there's a DRM, what it is,
and how it works, we've already failed.
-- Peter Lee

View File

@ -0,0 +1,4 @@
It's certainly easier to implement bad security
and make it illegal for anyone to notice
than it is to implement good security.
-- Bruce Schneier

View File

@ -0,0 +1,3 @@
...trying to make digital files uncopyable
is like trying to make water not wet.
-- Bruce Schneier

View File

@ -0,0 +1,4 @@
Writing non-free software is not an ethically legitimate activity, so if people
who do this run into trouble, that's good! All businesses based on non-free
software ought to fail, and the sooner the better.
-- Dr. Richard M. Stallman

View File

@ -0,0 +1,4 @@
The idea of free software is that users of computing deserve freedom.
They deserve in particular to have control over their computing. And
proprietary software does not allow users to have control of their computing.
-- Dr. Richard M. Stallman

View File

@ -0,0 +1,4 @@
Free software is software that respects your freedom and
the social solidarity of your community.
So it's free as in freedom.
-- Dr. Richard M. Stallman

View File

@ -0,0 +1,6 @@
Many users of the GNU/Linux system will
not have heard the ideas of free software.
They will not be aware that we have ideas,
that a system exists because of ethical ideals,
which were omitted from ideas associated with the term 'open source'.
-- Dr. Richard M. Stallman

View File

@ -0,0 +1,4 @@
Shareware tends to combine
the worst of commercial software with
the worst of free software.
-- Linus Torvalds

View File

@ -0,0 +1,3 @@
The strongest bulwark of authority is uniformity;
the least divergence from it is the greatest crime.
-- Emma Goldman

View File

@ -0,0 +1,4 @@
Ask for work.
If they don't give you work, ask for bread.
If they do not give you work or bread, then take bread.
-- Emma Goldman

View File

@ -0,0 +1,5 @@
Religion, the dominion of the human mind;
Property, the dominion of human needs; and
Government, the dominion of human conduct,
represent the stronghold of man's enslavement and all the horrors it entails.
-- Emma Goldman

View File

@ -0,0 +1,4 @@
Give us what belongs to us in peace,
and if you don't give it to us in peace,
we will take it by force.
-- Emma Goldman

View File

@ -0,0 +1,5 @@
No great idea in its beginning can ever be within the law.
How can it be within the law?
The law is stationary. The law is fixed. The law is a chariot wheel
which binds us all regardless of conditions or place or time.
-- Emma Goldman

View File

@ -0,0 +1,5 @@
Anarchism stands for the liberation of the human mind from the dominion
of religion and liberation of the human body from the coercion of property;
liberation from the shackles and restraint of government.
It stands for a social order based on the free grouping of individuals...
-- Emma Goldman

View File

@ -0,0 +1,3 @@
People have only as much liberty as they have
the intelligence to want and the courage to take.
-- Emma Goldman

View File

@ -0,0 +1,6 @@
No real social change has ever been brought about without a revolution -
Revolution is but thought carried into action.
Every effort for progress, for enlightenment, for science,
for religious, political, and economic liberty,
emanates from the minority, and not from the mass.
-- Emma Goldman

View File

@ -0,0 +1,2 @@
If voting changed anything, they'd make it illegal.
-- Emma Goldman

View File

@ -0,0 +1,3 @@
Freiheit ist immer die Freiheit des Andersdenkenden.
Aber was ist, wenn der andere denkt, dass alle das gleiche denken sollen?
-- Rosa Luxemburg

View File

@ -0,0 +1,2 @@
Who doesn't have two thirds of his day for himself, is a slave.
-- Friedrich Nietzsche

View File

@ -0,0 +1,3 @@
All the papers that matter live off their advertisements,
and the advertisers exercise an indirect censorship over news.
-- George Orwell

View File

@ -0,0 +1,3 @@
Who controls the past controls the future.
Who controls the present controls the past.
-- George Orwell

View File

@ -0,0 +1,2 @@
Freedom is the right to tell people what they do not want to hear.
-- George Orwell

View File

@ -0,0 +1,2 @@
Some ideas are so stupid that only intellectuals believe them.
-- George Orwell

View File

@ -0,0 +1,2 @@
We know that no one ever seizes power with the intention of relinquishing it.
-- George Orwell

View File

@ -0,0 +1,2 @@
The revolution will be complete when the language is perfect.
-- George Orwell

View File

@ -0,0 +1,3 @@
All of law is but a symptomatic remedy for the
issues in society -- and a snake oil at that.
-- rakete

View File

@ -0,0 +1,3 @@
In matters of truth and justice, there is no difference between large and
small problems, for issues concerning the treatment of people are all the same.
-- Albert Einstein

View File

@ -0,0 +1,3 @@
Justice consists not in being neutral between right and wrong, but in
finding out the right and upholding it, wherever found, against the wrong.
-- Theodore Roosevelt

View File

@ -0,0 +1,7 @@
Unjust laws exist;
shall we be content to obey them,
or shall we endeavor to amend them, and obey them until we have succeeded,
or shall we transgress them at once?
-- Henry David Thoreau

View File

@ -0,0 +1,3 @@
Die Verwertungsindustrie ist einer der groessten Feinde
origineller Kreativitaet.
-- rakete

View File

@ -0,0 +1,2 @@
Everybody has plans until they get punched for the first time.
-- Mike Tyson

View File

@ -0,0 +1,3 @@
Three things cannot be long hidden:
the sun, the moon, and the truth.
-- Gautama Buddha

View File

@ -0,0 +1,3 @@
Whoever is careless with the truth in small matters
cannot be trusted with important matters.
-- Albert Einstein

View File

@ -0,0 +1,4 @@
I am a firm believer in the people.
If given the truth, they can be depended upon to meet a national crisis.
The great point is to bring them the real facts.
-- Abraham Lincoln

View File

@ -0,0 +1,3 @@
Acknowleding that there is no definitive stage of wisdom
is a necessary step on the path leading to it.
-- rakete

View File

@ -0,0 +1,6 @@
If you come across any special trait of meanness or stupidity ... you must be
careful not to let it annoy or distress you, but to look upon it merely as an
addition to your knowledge -- a new fact to be considered in studying the
character of humanity. Your attitude towards it will be that of the
mineralogist who stumbles upon very characteristic specimen of a mineral.
-- Arthur Schopenhauer

View File

@ -0,0 +1,2 @@
It's easier to fool people than to convince them that they have been fooled.
-- Mark Twain