nix #11

Manually merged
geoffrey merged 113 commits from nix into main 2023-12-09 21:43:01 +01:00
18 changed files with 47 additions and 42 deletions
Showing only changes of commit 33945f865f - Show all commits

View file

@ -1,11 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
import coloredlogs
import logging import logging
import os import os
import sys import sys
import coloredlogs
coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")
log = logging.getLogger() log = logging.getLogger()
@ -155,7 +156,6 @@ def archive(docdir):
# If the directory doesn't exist, create the directories under it and move all the folder # If the directory doesn't exist, create the directories under it and move all the folder
else: else:
if args.dry: if args.dry:
print("mkdir -p", parentArcdir) print("mkdir -p", parentArcdir)
else: else:
@ -177,7 +177,6 @@ def unarchive(arcdir):
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Place a folder in ~/Documents in ~/Documents/Archives and symlink it" description="Place a folder in ~/Documents in ~/Documents/Archives and symlink it"
) )

View file

@ -1,18 +1,19 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import datetime
import hashlib
import json
import logging
import os import os
import shutil import shutil
import statistics
import subprocess import subprocess
import sys import sys
import logging import tempfile
import time
import coloredlogs import coloredlogs
import progressbar import progressbar
import time
import hashlib
import tempfile
import json
import statistics
import datetime
coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")
log = logging.getLogger() log = logging.getLogger()
@ -161,6 +162,7 @@ log.info(
) )
) )
# From https://stackoverflow.com/a/3431838 # From https://stackoverflow.com/a/3431838
def sha256(fname): def sha256(fname):
hash_sha256 = hashlib.sha256() hash_sha256 = hashlib.sha256()

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import random import random
import sys
for line in sys.stdin: for line in sys.stdin:
nl = "" nl = ""

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import random import random
import sys
for line in sys.stdin: for line in sys.stdin:
nl = "" nl = ""

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os
import sys
import subprocess
import logging import logging
import os
import subprocess
import sys
import coloredlogs import coloredlogs

View file

@ -1,9 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import logging
import os import os
import shutil import shutil
import logging import sys
import coloredlogs import coloredlogs
coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")

View file

@ -1,14 +1,15 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import argparse
import ovh
import xdg.BaseDirectory
import urllib.request
from pprint import pprint
import json import json
import logging import logging
import os
import urllib.request
from pprint import pprint
import coloredlogs import coloredlogs
import argparse import ovh
import xdg.BaseDirectory
coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s") coloredlogs.install(level="DEBUG", fmt="%(levelname)s %(message)s")
log = logging.getLogger() log = logging.getLogger()

View file

@ -39,7 +39,7 @@ def main(args: argparse.Namespace) -> None:
log.warning("Processing files...") log.warning("Processing files...")
for full_path in get_pictures(**kwargs): for full_path in get_pictures(**kwargs):
# Find date # Find date
with open(full_path, 'rb') as fd: with open(full_path, "rb") as fd:
exif_data = exifread.process_file(fd) exif_data = exifread.process_file(fd)
if not exif_data: if not exif_data:
log.warning(f"{full_path} does not have EXIF data") log.warning(f"{full_path} does not have EXIF data")
@ -54,8 +54,8 @@ def main(args: argparse.Namespace) -> None:
# Determine new filename # Determine new filename
ext = os.path.splitext(full_path)[1].lower() ext = os.path.splitext(full_path)[1].lower()
if ext == '.jpeg': if ext == ".jpeg":
ext = '.jpg' ext = ".jpg"
new_name = date.isoformat().replace(":", "-").replace("T", "_") + args.suffix new_name = date.isoformat().replace(":", "-").replace("T", "_") + args.suffix
# First substitution is to allow images being sent to a NTFS filesystem # First substitution is to allow images being sent to a NTFS filesystem
# Second substitution is for esthetics # Second substitution is for esthetics

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import sys
import pulsectl
from Xlib import X, XK, display import pulsectl
from Xlib import XK, X, display
from Xlib.ext import record from Xlib.ext import record
from Xlib.protocol import rq from Xlib.protocol import rq

View file

@ -3,14 +3,15 @@
# Handles sync-conflict files # Handles sync-conflict files
import argparse import argparse
import logging
import os import os
import pickle import pickle
import re import re
import sys import sys
import zlib import zlib
import coloredlogs import coloredlogs
import progressbar import progressbar
import logging
progressbar.streams.wrap_stderr() progressbar.streams.wrap_stderr()
coloredlogs.install(level="INFO", fmt="%(levelname)s %(message)s") coloredlogs.install(level="INFO", fmt="%(levelname)s %(message)s")
@ -425,7 +426,6 @@ class DatabaseFile:
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Handle Syncthing's .sync-conflict files " description="Handle Syncthing's .sync-conflict files "
) )

View file

@ -9,21 +9,21 @@ with the unread items (non-video links are ignored).
""" """
import datetime import datetime
import filelock
import functools import functools
import logging import logging
import os import os
import pickle import pickle
import random import random
import requests
import re import re
import subprocess import subprocess
import sys
import time import time
import typing import typing
import sys
import coloredlogs import coloredlogs
import configargparse import configargparse
import filelock
import requests
import yt_dlp import yt_dlp
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,8 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import base64 import base64
import colorama
import configargparse
import datetime import datetime
import email.utils import email.utils
import io import io
@ -10,6 +8,8 @@ import pprint
import subprocess import subprocess
import sys import sys
import colorama
import configargparse
if __name__ == "__main__": if __name__ == "__main__":
parser = configargparse.ArgParser( parser = configargparse.ArgParser(

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import random import random
import sys
# maj = True # maj = True

View file

@ -1,7 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import os import os
import sys
import piexif import piexif
assert len(sys.argv) >= 3, "Usage {} CREATOR FILENAMES...".format(sys.argv[0]) assert len(sys.argv) >= 3, "Usage {} CREATOR FILENAMES...".format(sys.argv[0])

View file

@ -1,12 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import logging
import os import os
import subprocess import subprocess
import sys import sys
import logging
import magic
import typing import typing
import coloredlogs import coloredlogs
import magic
# TODO Able to ignore extensions everywhere # TODO Able to ignore extensions everywhere

View file

@ -3,9 +3,9 @@
import logging import logging
import os import os
import re
import subprocess import subprocess
import typing import typing
import re
import coloredlogs import coloredlogs
import progressbar import progressbar

View file

@ -4,8 +4,8 @@
# FFMPEG's reasonable default settings # FFMPEG's reasonable default settings
import os import os
import sys
import subprocess import subprocess
import sys
files = sys.argv[1:] files = sys.argv[1:]

View file

@ -8,8 +8,8 @@
# Example: videoQuota 20971520 source.mov dest.mp4 # Example: videoQuota 20971520 source.mov dest.mp4
# To make a ~20 MiB MP4 of a MOV video # To make a ~20 MiB MP4 of a MOV video
import sys
import subprocess import subprocess
import sys
def duration_file(path: str) -> float: def duration_file(path: str) -> float: