Skip to content

Commit 9a68f32

Browse files
committed
Initial version, need some cleaning
1 parent 7ff888c commit 9a68f32

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

pwc.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!python3
2+
3+
# read file and interpret it as yaml
4+
def read_yaml(file):
5+
6+
with open(file) as f:
7+
data = yaml.safe_load(f)
8+
return data
9+
10+
import sys
11+
import yaml
12+
#import pprint
13+
from wcmatch import glob
14+
15+
# read filename from command line as first argument
16+
spellcheck_configuration_file = sys.argv[1]
17+
18+
data = read_yaml(spellcheck_configuration_file)
19+
20+
# fetch the sources from the YAML data
21+
sources = data.get('matrix')[0].get('sources')
22+
23+
# print the sources from the YAML data
24+
#pprint.pprint(sources)
25+
26+
for changed_file in sys.stdin:
27+
if 'q' == changed_file.rstrip():
28+
break
29+
changed_file = changed_file.rstrip()
30+
#print(f'Input : {changed_file}')
31+
32+
matched = glob.globmatch(changed_file, sources, flags=glob.NEGATE | glob.GLOBSTAR | glob.SPLIT)
33+
34+
if matched:
35+
#print("Matched file:", changed_file)
36+
exit(0)
37+
else:
38+
#print("No match for file:", changed_file)
39+
exit(1)
40+
41+
#pprint.pprint(files)

0 commit comments

Comments
 (0)