Compare commits

...

4 Commits

Author SHA1 Message Date
Dandaedre c3294c82e0 Rebase of the hack
Quick and dirty hack to add a --stdout to allow for file modification in stdout
2025-01-10 04:57:45 -06:00
Dandaedre 497f7caaaf Fixes stderr being muted and add a --no-failure 2025-01-10 04:57:45 -06:00
Dandaedre fe849c5f1b Fix a silly mistake due to None in the filenames 2025-01-10 04:57:45 -06:00
Dandaedre 829e2ff8ac Quick and dirty hack to add a --stdout to allow for file modification in stdout 2025-01-10 04:57:45 -06:00
4 changed files with 40 additions and 8 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ release_notes.txt
# IDE files
.idea/
.vscode/
venv
# Ignore external repos used for tests
tests/external_repos/repos

View File

@ -133,18 +133,22 @@ def main():
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr, bKeepProcessingFiles = f((0, "stdin"))
lReturn.append((fStatus, testCase, dJsonEntry))
if sOutputStd:
print(sOutputStd)
if not commandLineArguments.stdout:
print(sOutputStd)
if sOutputErr:
print(sOutputErr, file=sys.stderr)
if not commandLineArguments.stdout:
print(sOutputErr, file=sys.stderr)
else:
for iIndex, sFileName in enumerate(commandLineArguments.filename):
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr, bKeepProcessingFiles = f((iIndex + int(commandLineArguments.stdin), sFileName))
lReturn.append((fStatus, testCase, dJsonEntry))
if sOutputStd:
print(sOutputStd)
if not commandLineArguments.stdout:
print(sOutputStd)
if sOutputErr:
print(sOutputErr, file=sys.stderr)
if not commandLineArguments.stdout:
print(sOutputErr, file=sys.stderr)
if bKeepProcessingFiles:
break
@ -155,9 +159,11 @@ def main():
fStatus, testCase, dJsonEntry, sOutputStd, sOutputErr, bKeepProcessingFiles = tResult
lReturn.append((fStatus, testCase, dJsonEntry))
if sOutputStd:
print(sOutputStd)
if not commandLineArguments.stdout:
print(sOutputStd)
if sOutputErr:
print(sOutputErr, file=sys.stderr)
if not commandLineArguments.stdout:
print(sOutputErr, file=sys.stderr)
if bKeepProcessingFiles:
break
@ -182,7 +188,10 @@ def main():
if commandLineArguments.quality_report:
quality_report.write(commandLineArguments, dJson)
sys.exit(fExitStatus)
if commandLineArguments.no_failure:
sys.exit(0)
else:
sys.exit(fExitStatus)
def create_json_dictionary():

View File

@ -114,7 +114,10 @@ def apply_rules(commandLineArguments, oConfig, tIndexFileName):
if commandLineArguments.backup:
create_backup_file(sFileName)
oRules.fix(commandLineArguments.fix_phase, commandLineArguments.skip_phase, fix_only)
write_vhdl_file(oVhdlFile, oConfig.dConfig)
if commandLineArguments.stdout:
print("\n".join(oVhdlFile.get_lines()[1:]))
else:
write_vhdl_file(oVhdlFile, oConfig.dConfig)
oRules.clear_violations()
oRules.check_rules(

View File

@ -67,6 +67,12 @@ def parse_command_line_arguments():
default=False,
help="Read VHDL input from stdin, disables all other file selections, disables multiprocessing",
)
parser.add_argument(
"--stdout",
action="store_true",
default=False,
help="Write all file changes stdout instead of writing them in a file, enabling this will disable all diagnostics and just print a file fix",
)
parser.add_argument("--force_fix", action="store_true", default=False, help="ALPHA: Apply fixes if syntax errors are detected.")
add_quality_report_argument(parser)
@ -79,6 +85,7 @@ def parse_command_line_arguments():
help="number of parallel jobs to use, default is the number of cpu cores",
)
parser.add_argument("--debug", default=False, action="store_true", help="Displays verbose debug information")
parser.add_argument("--no-failure", default=False, action="store_true", help="Always exits with exit code 0, usefull for scripting")
parser.add_argument("filename_args", metavar="FILENAME", type=__is_valid_file, nargs="*", default=[], help="File to analyze")
args_ = parser.parse_args()
@ -87,6 +94,7 @@ def parse_command_line_arguments():
validate_ap_argument(args_)
fix_filename_argument(args_)
fix_configuration_argument(args_)
validate_stdout_argument(args_)
if sys.platform == "win32":
# Work around https://bugs.python.org/issue26903
@ -126,6 +134,17 @@ def validate_backup_argument(args_):
print("ERROR: --backup argument requires --fix argument")
sys.exit(1)
def validate_stdout_argument(args_):
"""
The function validates the stdout option is only present when the fix option is also present.
"""
if args_.stdout and not args_.fix:
print("ERROR: --stdout argument requires --fix argument")
sys.exit(1)
if args_.stdout and not args_.stdin and len(args_.filename)>1:
print("ERROR: --stdout argument cannot be used with multiples files")
sys.exit(1)
def validate_ap_argument(args_):
"""