Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a script to check for warnings
Signed-off-by: sarfaraz siddiqui <sarfarazsiddiqui199@gmail.com>
- Loading branch information
1 parent
3f55494
commit e614d0c
Showing
2 changed files
with
48 additions
and
1 deletion.
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
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,45 @@ | ||
#!/usr/bin/env python3 | ||
# ===----------------------------------------------------------------------=== # | ||
# Copyright (c) 2024, Modular Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions: | ||
# https://llvm.org/LICENSE.txt | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ===----------------------------------------------------------------------=== # | ||
|
||
import argparse | ||
import os | ||
import sys | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
description=( | ||
"Exits successfully if the file at the given path is empty or does" | ||
" not exist. Otherwise, prints the file's contents, then exits" | ||
" unsuccessfully." | ||
) | ||
) | ||
parser.add_argument("path") | ||
args = parser.parse_args() | ||
|
||
if not os.path.exists(args.path): | ||
return | ||
|
||
with open(args.path, "r") as f: | ||
content = f.read().strip() | ||
if content: | ||
print( | ||
f"error: '{args.path}' is not empty:\n{content}", | ||
file=sys.stderr, | ||
) | ||
exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |