-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
``` 3730 - OpenStudioCLI.execute_ruby_script.forward_flags.forward_help (Failed) 3731 - OpenStudioCLI.execute_python_script.forward_flags.forward_help (Failed) ```
- Loading branch information
Showing
3 changed files
with
45 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,21 @@ | ||
import argparse | ||
from pathlib import Path | ||
|
||
|
||
def validate_file(arg): | ||
if (filepath := Path(arg)).is_file(): | ||
return filepath | ||
else: | ||
raise FileNotFoundError(arg) | ||
|
||
def validate_xml_file(arg): | ||
filepath = validate_file(arg) | ||
if (filepath.suffix != '.xml'): | ||
raise FileNotFoundError(f"{arg} is not a .xml file") | ||
return filepath | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="The Python help description.") | ||
parser.add_argument("-x,--xml", metavar='FILE', required=True, type=validate_xml_file, help="HPXML file") | ||
args = parser.parse_args() | ||
print(args) |
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