| 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): |