Replace these uses of glob with winglob.

This commit is contained in:
voussoir 2020-01-15 22:47:26 -08:00
parent 8eeb22d0b0
commit 2d5ef0c7cf
7 changed files with 12 additions and 14 deletions

View file

@ -1,10 +1,11 @@
import argparse import argparse
import codecs import codecs
import glob
import pyperclip import pyperclip
import re import re
import sys import sys
from voussoirkit import winglob
def contentreplace(filename, replace_from, replace_to, autoyes=False, do_regex=False): def contentreplace(filename, replace_from, replace_to, autoyes=False, do_regex=False):
f = open(filename, 'r', encoding='utf-8') f = open(filename, 'r', encoding='utf-8')
@ -34,7 +35,7 @@ def contentreplace(filename, replace_from, replace_to, autoyes=False, do_regex=F
f.write(content) f.write(content)
def contentreplace_argparse(args): def contentreplace_argparse(args):
filenames = glob.glob(args.filename_glob) filenames = winglob.glob(args.filename_glob)
if args.clip_prompt: if args.clip_prompt:
replace_from = input('Ready from') replace_from = input('Ready from')

View file

@ -1,12 +1,10 @@
''' '''
Convert LF line endings to CRLF. Convert LF line endings to CRLF.
''' '''
import glob
import sys import sys
from voussoirkit import pipeable from voussoirkit import pipeable
from voussoirkit import winglob
CR = b'\x0D' CR = b'\x0D'
LF = b'\x0A' LF = b'\x0A'
@ -22,7 +20,7 @@ def crlf(filename):
def main(args): def main(args):
for line in pipeable.go(args, strip=True, skip_blank=True): for line in pipeable.go(args, strip=True, skip_blank=True):
for filename in glob.glob(line): for filename in winglob.glob(line):
pipeable.output(filename) pipeable.output(filename)
crlf(filename) crlf(filename)

View file

@ -1,7 +1,6 @@
import argparse import argparse
import re import re
import subprocess import subprocess
import glob
import sys import sys
from voussoirkit import pathclass from voussoirkit import pathclass

View file

@ -4,7 +4,6 @@ Not a replacement for real version control but could be applicable in very simpl
cases where e.g. git is not. cases where e.g. git is not.
''' '''
import argparse import argparse
import glob
import hashlib import hashlib
import os import os
import shutil import shutil
@ -13,6 +12,7 @@ import time
from voussoirkit import bytestring from voussoirkit import bytestring
from voussoirkit import pathclass from voussoirkit import pathclass
from voussoirkit import winglob
def hash_file(filepath, hasher): def hash_file(filepath, hasher):
bytestream = read_filebytes(filepath) bytestream = read_filebytes(filepath)
@ -44,7 +44,7 @@ def filetimelapse(filepath, rate):
(noext, extension) = os.path.splitext(filepath) (noext, extension) = os.path.splitext(filepath)
last_hash = None last_hash = None
existing_timelapses = glob.glob(f'{noext}-*.filetimelapse{extension}') existing_timelapses = winglob.glob(f'{noext}-*.filetimelapse{extension}')
if existing_timelapses: if existing_timelapses:
last_hash = hash_file_md5(existing_timelapses[-1]) last_hash = hash_file_md5(existing_timelapses[-1])
print(f'Starting with previous {existing_timelapses[-1]} {last_hash}') print(f'Starting with previous {existing_timelapses[-1]} {last_hash}')

View file

@ -1,4 +1,3 @@
import glob
import sys import sys
from voussoirkit import pipeable from voussoirkit import pipeable

View file

@ -1,8 +1,9 @@
import glob
import os import os
from PIL import Image from PIL import Image
import sys import sys
from voussoirkit import winglob
def fit_into_bounds(image_width, image_height, frame_width, frame_height): def fit_into_bounds(image_width, image_height, frame_width, frame_height):
''' '''
Given the w+h of the image and the w+h of the frame, Given the w+h of the image and the w+h of the frame,
@ -22,7 +23,7 @@ def fit_into_bounds(image_width, image_height, frame_width, frame_height):
filenames = sys.argv[1] filenames = sys.argv[1]
filenames = glob.glob(filenames) filenames = winglob.glob(filenames)
for filename in filenames: for filename in filenames:
i = Image.open(filename) i = Image.open(filename)
if all(x.isdigit() for x in sys.argv[2:3]): if all(x.isdigit() for x in sys.argv[2:3]):

View file

@ -1,15 +1,15 @@
''' '''
Create the file, or update the last modified timestamp. Create the file, or update the last modified timestamp.
''' '''
import glob
import os import os
import sys import sys
from voussoirkit import clipext from voussoirkit import clipext
from voussoirkit import safeprint from voussoirkit import safeprint
from voussoirkit import winglob
def touch(glob_pattern): def touch(glob_pattern):
filenames = glob.glob(glob_pattern) filenames = winglob.glob(glob_pattern)
if len(filenames) == 0: if len(filenames) == 0:
safeprint.safeprint(glob_pattern) safeprint.safeprint(glob_pattern)
open(glob_pattern, 'a').close() open(glob_pattern, 'a').close()