def transcrypt_sketch(sketch_name): """ Transcrypt the sketch python code to javascript. :param sketch_name: name for new sketch :type sketch_name: string :return: file names :rtype: list of strings """ sketch_files = SketchFiles(sketch_name) sketch_files.validate_name() if not sketch_files.sketch_exists: raise PythonSketchDoesNotExist(sketch_files.sketch_py.resolve()) compile_sketch_js(sketch_files) return sketch_files
def monitor_sketch(sketch_name): """ Monitor for any change in any .py inside the sketch dir. For every new change, runs the transcrypt to update the js files. :param sketch_name: name for new sketch :type sketch_name: string :return: file names :rtype: list of strings """ sketch_files = SketchFiles(sketch_name) sketch_files.validate_name() if not sketch_files.sketch_exists: raise PythonSketchDoesNotExist(sketch_files.sketch_py.resolve()) cprint(f"Monitoring for changes in {sketch_files.sketch_dir.resolve()}...") try: monitor_sketch_service(sketch_files) except KeyboardInterrupt: cprint.info("Exiting monitor...")
def test_raise_exception_when_name_starts_with_numbers(self): files = SketchFiles('123name') with pytest.raises(InvalidName): files.validate_name()
def test_raise_exception_when_name_contains_non_alphanumeric_chars(self): files = SketchFiles('name&') with pytest.raises(InvalidName): files.validate_name()