Merge branch 'master' of cvs.moegen-wir.net:neingeist/dirty-helpers
This commit is contained in:
commit
011f5f8a90
6 changed files with 58 additions and 7 deletions
|
@ -15,7 +15,7 @@ def junk_dirs():
|
|||
"""Return directories which potentially contain junk"""
|
||||
|
||||
for d in ['~/tmp', '~/.local/share/Trash', '~/rpmbuild', '~/RPM',
|
||||
'~/.cache/tracker']:
|
||||
'~/.cache/tracker', '~/.local/share/apt-dater/history']:
|
||||
d = os.path.expanduser(d)
|
||||
if os.path.exists(d):
|
||||
yield d
|
||||
|
|
|
@ -4,13 +4,14 @@
|
|||
from __future__ import division, print_function
|
||||
|
||||
from colorama import Fore
|
||||
from pathlib import Path
|
||||
|
||||
import contextlib
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
def git_directories(startdir):
|
||||
def git_directories(startdir) -> Path:
|
||||
for dirpath, dirnames, _ in os.walk(startdir):
|
||||
if '.sync' in dirpath:
|
||||
continue
|
||||
|
@ -18,11 +19,11 @@ def git_directories(startdir):
|
|||
# FIXME
|
||||
continue
|
||||
if set(['info', 'objects', 'refs']).issubset(set(dirnames)):
|
||||
yield dirpath
|
||||
yield Path(dirpath)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def working_directory(directory):
|
||||
def working_directory(directory: Path):
|
||||
saved_cwd = os.getcwd()
|
||||
os.chdir(directory)
|
||||
yield
|
||||
|
@ -30,7 +31,12 @@ def working_directory(directory):
|
|||
|
||||
|
||||
for git_directory in git_directories('.'):
|
||||
work_tree_directory = git_directory[:-4]
|
||||
# technically,we could have a different GIT_DIR than ".git", but this script
|
||||
# assumes ".git".
|
||||
if git_directory.parts[-1] != ".git":
|
||||
continue
|
||||
work_tree_directory = git_directory.parent
|
||||
|
||||
with working_directory(work_tree_directory):
|
||||
try:
|
||||
out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT)
|
||||
|
|
15
rmdir-empty
Executable file
15
rmdir-empty
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
# recursively delete empty directories
|
||||
|
||||
rmdir_empty() {
|
||||
# make default . explicit
|
||||
if [ -z "$1" ]; then
|
||||
set -- .
|
||||
fi
|
||||
|
||||
find "$@" -depth \
|
||||
-path "." -prune -or \
|
||||
-type d -empty -exec rmdir -v {} \;
|
||||
}
|
||||
|
||||
rmdir_empty "$@"
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/sh
|
||||
# check for common problems + junk
|
||||
# https://github.com/neingeist/dirty-helpers
|
||||
|
||||
|
||||
is_debian() {
|
||||
|
@ -12,7 +13,7 @@ is_fedora() {
|
|||
|
||||
|
||||
echo "== Dangling symlinks in /etc"
|
||||
find /etc -type l -and -xtype l | egrep -v 'blkid.tab|/var/log/dropbear'
|
||||
find /etc -type l -and -xtype l | egrep -v 'blkid.tab|/var/log/dropbear|/etc/sv/ssh'
|
||||
|
||||
echo "== Trashes"
|
||||
for t in /home/*/.local/share/Trash; do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# Find duplicate keys in ~/.ssh/known_hosts
|
||||
#
|
||||
# Of course, we should have been more careful in the first place :)
|
||||
|
|
29
wiewardertatort
Executable file
29
wiewardertatort
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import requests
|
||||
import re
|
||||
import click
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.argument('search_title')
|
||||
def search(search_title):
|
||||
q = requests.utils.quote(search_title)
|
||||
url = f"https://www.wiewardertatort.de/search?q={q}"
|
||||
|
||||
soup = BeautifulSoup(requests.get(url).text, features="lxml")
|
||||
|
||||
for post_outer in soup.select("div.post-outer"):
|
||||
title = post_outer.select_one("h3.post-title").a.text
|
||||
print(title)
|
||||
|
||||
if m := re.search(r"Bewertung: (\d+)/", post_outer.text):
|
||||
bewertung = int(m.group(1))
|
||||
print(bewertung)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
search()
|
||||
|
||||
# vim:ft=python:tw=120:
|
Loading…
Add table
Add a link
Reference in a new issue