-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |