Browse Source

added two new arguments --all for entire pad content, --pad for specific pad

master
crunk 3 years ago
parent
commit
0740ba4789
  1. 40
      palanggana.py
  2. 28
      pyproject.toml

40
palanggana.py

@ -13,6 +13,7 @@ parser.add_argument(
required=True,
help="Add your magic word here",
)
parser.add_argument(
"-k",
"--keep",
@ -20,11 +21,27 @@ parser.add_argument(
action="store_true",
)
parser.add_argument(
"-p",
"--pad",
help="specify a pad name, get only that pad",
)
parser.add_argument(
"-a",
"--all",
help="get all content from pad not just the lines containing the magic",
action="store_true",
)
# just a few variables that we will need
thepump = "https://etherpump.vvvvvvaria.org/"
args = parser.parse_args()
magicword = "__{0}__".format(f"{args.magic}".upper())
padname = f"{args.pad}"
keep = args.keep
wholepad = args.all
def extractlinks(thewell):
@ -43,8 +60,20 @@ def extracttext(thegoods):
"""extract the texts from the plain text links"""
plaintexts = []
for link in thegoods:
res = req.get(link)
plaintexts.append(res.text.splitlines())
if padname and padname != "None":
strippedlink = (
link.replace(thepump, "")
.replace(".raw.txt", "")
.replace("p/", "")
)
if padname.lower() == strippedlink.lower():
res = req.get(link)
# print("pad found {0} with link {1}".format(padname, link))
plaintexts.append(res.text.splitlines())
return plaintexts
else:
res = req.get(link)
plaintexts.append(res.text.splitlines())
return plaintexts
@ -53,7 +82,12 @@ def extractmagic(plaintexts):
magiclines = []
# print(magicword)
for line in plaintexts:
if magicword in line:
if not wholepad:
if magicword in line:
if not keep:
line = line.replace(magicword, "")
magiclines.append(line)
else:
if not keep:
line = line.replace(magicword, "")
magiclines.append(line)

28
pyproject.toml

@ -0,0 +1,28 @@
# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.
[tool.black]
line-length = 79
target-version = ['py37', 'py38', 'py39']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
# The following are specific to Black, you probably don't want those.
| blib2to3
| tests/data
| profiling
)/
'''
Loading…
Cancel
Save