MCPcopy Create free account
hub / github.com/ActiveState/code / decode_file

Function decode_file

recipes/Python/456374_Crypt/recipe-456374.py:198–220  ·  view source on GitHub ↗

Decodes a file. Shows the heading. Gets the source file. Gets the destination file. Handles errors. Gets a key. Does the decoding. Prints a confirmation.

()

Source from the content-addressed store, hash-verified

196 destination.close()
197
198def decode_file():
199 '''Decodes a file.
200
201 Shows the heading.
202 Gets the source file.
203 Gets the destination file.
204 Handles errors.
205 Gets a key.
206 Does the decoding.
207 Prints a confirmation.'''
208 show_heading('DECODE FILE')
209 source = get_source('What is the name of the source file?')
210 destination = get_destination('What will be the name of the destination file?')
211 bad_key = True
212 while bad_key:
213 try:
214 key = get_key()
215 work_decode(source, destination, key)
216 bad_key = False
217 except:
218 print 'Please enter a different filename.'
219 print 'The decoded file has been created at the location specified.'
220 print
221
222def work_decode(source, destination, key):
223 '''Does decoding.

Callers 1

mainFunction · 0.70

Calls 5

show_headingFunction · 0.85
get_destinationFunction · 0.85
work_decodeFunction · 0.85
get_sourceFunction · 0.70
get_keyFunction · 0.70

Tested by

no test coverage detected