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"""
|
"""Return directories which potentially contain junk"""
|
||||||
|
|
||||||
for d in ['~/tmp', '~/.local/share/Trash', '~/rpmbuild', '~/RPM',
|
for d in ['~/tmp', '~/.local/share/Trash', '~/rpmbuild', '~/RPM',
|
||||||
'~/.cache/tracker']:
|
'~/.cache/tracker', '~/.local/share/apt-dater/history']:
|
||||||
d = os.path.expanduser(d)
|
d = os.path.expanduser(d)
|
||||||
if os.path.exists(d):
|
if os.path.exists(d):
|
||||||
yield d
|
yield d
|
||||||
|
|
|
@ -4,13 +4,14 @@
|
||||||
from __future__ import division, print_function
|
from __future__ import division, print_function
|
||||||
|
|
||||||
from colorama import Fore
|
from colorama import Fore
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def git_directories(startdir):
|
def git_directories(startdir) -> Path:
|
||||||
for dirpath, dirnames, _ in os.walk(startdir):
|
for dirpath, dirnames, _ in os.walk(startdir):
|
||||||
if '.sync' in dirpath:
|
if '.sync' in dirpath:
|
||||||
continue
|
continue
|
||||||
|
@ -18,11 +19,11 @@ def git_directories(startdir):
|
||||||
# FIXME
|
# FIXME
|
||||||
continue
|
continue
|
||||||
if set(['info', 'objects', 'refs']).issubset(set(dirnames)):
|
if set(['info', 'objects', 'refs']).issubset(set(dirnames)):
|
||||||
yield dirpath
|
yield Path(dirpath)
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def working_directory(directory):
|
def working_directory(directory: Path):
|
||||||
saved_cwd = os.getcwd()
|
saved_cwd = os.getcwd()
|
||||||
os.chdir(directory)
|
os.chdir(directory)
|
||||||
yield
|
yield
|
||||||
|
@ -30,7 +31,12 @@ def working_directory(directory):
|
||||||
|
|
||||||
|
|
||||||
for git_directory in git_directories('.'):
|
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):
|
with working_directory(work_tree_directory):
|
||||||
try:
|
try:
|
||||||
out = subprocess.check_output(['git', 'status', '-s'], stderr=subprocess.STDOUT)
|
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
|
#!/bin/sh
|
||||||
# check for common problems + junk
|
# check for common problems + junk
|
||||||
|
# https://github.com/neingeist/dirty-helpers
|
||||||
|
|
||||||
|
|
||||||
is_debian() {
|
is_debian() {
|
||||||
|
@ -12,7 +13,7 @@ is_fedora() {
|
||||||
|
|
||||||
|
|
||||||
echo "== Dangling symlinks in /etc"
|
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"
|
echo "== Trashes"
|
||||||
for t in /home/*/.local/share/Trash; do
|
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
|
# Find duplicate keys in ~/.ssh/known_hosts
|
||||||
#
|
#
|
||||||
# Of course, we should have been more careful in the first place :)
|
# 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