Skip to content

Commit a8b358c

Browse files
committed
Print error messages to stderr, not stdout
- print(..., file=sys.stderr) for error messages - Provides better error handling if the output is being directed to a file - Review: general check
1 parent 4996b43 commit a8b358c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

yaml2ics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ def event_from_yaml(event_yaml: dict) -> ics.Event:
4343
interval = repeat['interval']
4444

4545
if not len(interval) == 1:
46-
print('Error: interval must specify seconds, minutes, hours, days, weeks, months, or years only')
46+
print('Error: interval must specify seconds, minutes, hours, days, weeks, months, or years only', file=sys.stderr)
4747
sys.exit(-1)
4848

4949
interval_measure = list(interval.keys())[0]
5050
if interval_measure not in interval_type:
51-
print('Error: expected interval to be specified in seconds, minutes, hours, days, weeks, months, or years only')
51+
print('Error: expected interval to be specified in seconds, minutes, hours, days, weeks, months, or years only', file=sys.stderr)
5252
sys.exit(-1)
5353

5454
if 'until' not in repeat:
55-
print('Error: must specify end date for repeating events')
55+
print('Error: must specify end date for repeating events', file=sys.stderr)
5656
sys.exit(-1)
5757

5858
event.end = d.get('end', None)
@@ -102,7 +102,7 @@ def files_to_calendar(files: list) -> ics.Calendar:
102102
files = sys.argv[1:]
103103
for f in files:
104104
if not os.path.isfile(f):
105-
print(f'Error: {f} is not a file')
105+
print(f'Error: {f} is not a file', file=sys.stderr)
106106
sys.exit(-1)
107107

108108
calendar = files_to_calendar(files)

0 commit comments

Comments
 (0)