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

Method __init__

recipes/Python/492215_diskdemopy/recipe-492215.py:277–305  ·  view source on GitHub ↗
(self, context, path)

Source from the content-addressed store, hash-verified

275
276 # Create A File
277 def __init__(self, context, path):
278 assert context.__class__ is Context
279 assert type(path) is str
280 while True:
281 try:
282 option = raw_input('write OR append? ')
283 assert option == 'write' or option == 'append'
284 break
285 except:
286 pass
287 if option[0] == 'a':
288 if context.exists(path):
289 if context.isfile(path):
290 self.__menu(context, path, 'a')
291 else:
292 print 'PATH IN NOT A FILE'
293 else:
294 print 'FILE DOES NOT EXIST AND WILL NOT BE CREATED'
295 else:
296 try:
297 if context.exists(path):
298 if context.isfile(path):
299 self.__menu(context, path, 'w')
300 else:
301 print 'PATH IS NOT A FILE'
302 else:
303 self.__menu(context, path, 'w')
304 except:
305 print 'FILE COULD NOT BE CREATED'
306
307 # Display A Menu
308 def __menu(self, context, path, mode):

Callers

nothing calls this directly

Calls 3

__menuMethod · 0.95
isfileMethod · 0.80
existsMethod · 0.45

Tested by

no test coverage detected