Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98cb4a5

Browse files
committed
Pass all tests
1 parent e81a75a commit 98cb4a5

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

05_howler/FOX.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.

05_howler/howler.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ def get_args():
2121
help='A positional argument')
2222

2323
parser.add_argument('-o',
24-
'--on',
25-
help='A boolean flag',
26-
action='store_true')
24+
'--outfile',
25+
help='Output filename',
26+
metavar='str',
27+
type=str,
28+
default='')
2729

2830
return parser.parse_args()
2931

@@ -33,21 +35,22 @@ def main():
3335
"""Make a jazz noise here"""
3436

3537
args = get_args()
36-
flag_arg = args.on
38+
out_arg = args.outfile
3739
pos_arg = args.positional
3840

3941
str = ''
4042

41-
if flag_arg:
42-
if os.path.isfile(pos_arg):
43-
str = open(pos_arg).read().rstrip().upper()
44-
else:
45-
#ERROR PATH
46-
print('This is not working')
43+
if os.path.isfile(pos_arg):
44+
str = open(pos_arg).read().rstrip().upper()
4745
else:
4846
str = pos_arg.upper()
4947

50-
print(str)
48+
if out_arg:
49+
out_fh = open(out_arg,'wt')
50+
print(str, file=out_fh)
51+
out_fh.close()
52+
else:
53+
print(str)
5154

5255

5356
# --------------------------------------------------

README_fleide.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,21 @@ os.path.basename(file)
176176

177177
os.getcwd() # Current directory
178178

179+
# Reading
180+
179181
file_handler = open(file)
180182
file_handler.read() # Empties the file handler
181183
file_handler.seek(0) # To return to start and be able to read again
182184

183185
str = open(file).read().rstrip() # Better (plus option to trim right)
184186

187+
# Writing
188+
189+
out_fh = open('new.txt','wt') # Modes : r/w/append, and text/bytes
190+
191+
out_fh.write('Some text plus a return feed because else its missing \n')
192+
print('or via print and then no need for the return', file=out_fh)
193+
194+
out_fh.close()
195+
185196
```

0 commit comments

Comments
 (0)