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

Function encode_file

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

Executes decoding subsection. Shows the heading of this area. Gets the source file for encoding. Gets the destination file. Handles errors. Gets a key. Executes the main encoding system. Prints a confirmation.

()

Source from the content-addressed store, hash-verified

126 return key
127
128def encode_file():
129 '''Executes decoding subsection.
130
131 Shows the heading of this area.
132 Gets the source file for encoding.
133 Gets the destination file.
134 Handles errors.
135 Gets a key.
136 Executes the main encoding system.
137 Prints a confirmation.'''
138 show_heading('ENCODE FILE')
139 source = get_source('What is the name of the source file?')
140 destination = get_destination('What will be the name of the destination file?')
141 bad_key = True
142 while bad_key:
143 try:
144 key = get_key()
145 work_encode(source, destination, key)
146 bad_key = False
147 except:
148 print 'Please enter a different filename.'
149 print 'The encoded file has been created at the location specified.'
150 print
151
152def get_source(prompt):
153 '''Gets a source file.

Callers 1

mainFunction · 0.70

Calls 5

show_headingFunction · 0.85
get_destinationFunction · 0.85
work_encodeFunction · 0.85
get_sourceFunction · 0.70
get_keyFunction · 0.70

Tested by

no test coverage detected