def generate(spec, common, details, should_check_encoding): """Create a compiled decoder for a specification in the test directory. Doesn't attempt to compile the specification. spec -- The specification to compile. common -- The common entries from the specification. details -- Object containing information on how and where to compile this specification. """ if os.path.exists(details.TEST_DIR): # For some reason on Windows it takes some time for the executable # to be freed by the system; we keep on getting # # WindowsError: [Error 145] The directory is not empty: '...' # # We just wait for a bit, and retry. i = 0 while 1: try: shutil.rmtree(details.TEST_DIR) break except OSError: if i > 10: raise i += 1 time.sleep(0.01) os.mkdir(details.TEST_DIR) options = { 'generate_encoder':should_check_encoding, } comp.generate_code(spec, _load_templates_from_cache(details.LANGUAGE), details.TEST_DIR, common, options)
def generate(spec, common, details, should_check_encoding): """Create a compiled decoder for a specification in the test directory. Doesn't attempt to compile the specification. spec -- The specification to compile. common -- The common entries from the specification. details -- Object containing information on how and where to compile this specification. """ if os.path.exists(details.TEST_DIR): shutil.rmtree(details.TEST_DIR) os.mkdir(details.TEST_DIR) options = { 'generate_encoder':should_check_encoding, } comp.generate_code(spec, _load_templates_from_cache(details.LANGUAGE), details.TEST_DIR, common, options)