-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
2c77ae2
commit 5e9af5c
Showing
1 changed file
with
6 additions
and
5 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 |
---|---|---|
@@ -1,23 +1,24 @@ | ||
import argparse | ||
import os | ||
|
||
def check_sql_files(file): | ||
found_staging = False | ||
if file.endswith(".sql"): | ||
if os.path.exists(file) and file.endswith(".sql"): | ||
with open(file, "r") as f: | ||
lines = f.readlines() | ||
for line in lines: | ||
if "basedosdados-dev" in line: | ||
if "basedosdados-staging" in line: | ||
found_staging = True | ||
print(f"Found 'basedosdados-dev' in {file}") | ||
print(f"Found 'basedosdados-staging' in {file}") | ||
break | ||
return found_staging | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Check for 'basedosdados-dev' occurrences in SQL files.") | ||
parser = argparse.ArgumentParser(description="Check for 'basedosdados-staging' occurrences in SQL files.") | ||
parser.add_argument("file", help="Path to the SQL file to check") | ||
args = parser.parse_args() | ||
|
||
if check_sql_files(args.file): | ||
exit(1) | ||
else: | ||
print("No occurrences of 'basedosdados-dev' found in SQL files.") | ||
print("No occurrences of 'basedosdados-staging' found in SQL files.") |