Skip to content

Commit

Permalink
Initial version, need some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbn committed Oct 13, 2024
1 parent 7ff888c commit 9a68f32
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions pwc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!python3

# read file and interpret it as yaml
def read_yaml(file):

with open(file) as f:
data = yaml.safe_load(f)
return data

import sys
import yaml
#import pprint
from wcmatch import glob

# read filename from command line as first argument
spellcheck_configuration_file = sys.argv[1]

data = read_yaml(spellcheck_configuration_file)

# fetch the sources from the YAML data
sources = data.get('matrix')[0].get('sources')

# print the sources from the YAML data
#pprint.pprint(sources)

for changed_file in sys.stdin:
if 'q' == changed_file.rstrip():
break
changed_file = changed_file.rstrip()
#print(f'Input : {changed_file}')

matched = glob.globmatch(changed_file, sources, flags=glob.NEGATE | glob.GLOBSTAR | glob.SPLIT)

if matched:
#print("Matched file:", changed_file)
exit(0)
else:
#print("No match for file:", changed_file)
exit(1)

#pprint.pprint(files)

0 comments on commit 9a68f32

Please sign in to comment.