master_parse/__init__.py
def _do_process_notebooks(params: Params) -> NoReturn:
    """
    Main entry point for notebook processing. This function can be used to
    process notebook from within another Python program.

    :param params: parameters
    :return: Nothing.
    """
    global _output_dir, _file_encoding_in, _file_encoding_out
    _output_dir = params.output_dir
    _file_encoding_in = params.encoding_in
    _file_encoding_out = params.encoding_out

    if (params.course_type is None) or (params.course_type == CourseType.NONE):
        raise UsageError("course_type must be set.")
    if not (params.databricks or params.ipython):
        raise UsageError("Specify at least one of databricks or ipython")
    if not (params.scala or params.python or params.r or params.sql):
        raise UsageError("Specify at least one of Scala, Python, R or SQL")
    if not (params.instructor or params.answers or params.exercises):
        raise UsageError("Specify at least one of: instructor, answers, exercises")

    if os.path.isdir(params.path):
        files = []
        for p in ["*.py", "*.scala", "*.r", "*.sql"]:
            files.extend(glob.glob(os.path.join(params.path, p)))
    else:
        files = [params.path]

    if not files:
        raise UsageError(f"No acceptable files found for {params.path}")

    notebook_kinds = []
    if params.databricks:
        notebook_kinds.append(NotebookKind.DATABRICKS)
    if params.ipython:
        notebook_kinds.append(NotebookKind.IPYTHON)

    notebook_users = []
    if params.instructor:
        notebook_users.append(NotebookUser.INSTRUCTOR)
    if params.exercises:
        notebook_users.append(NotebookUser.EXERCISES)
    if params.answers:
        notebook_users.append(NotebookUser.ANSWERS)

    notebook_languages = []
    if params.scala:
        notebook_languages.append(CommandCode.SCALA)
    if params.python:
        notebook_languages.append(CommandCode.PYTHON)
    if params.r:
        notebook_languages.append(CommandCode.R)
    if params.sql:
        notebook_languages.append(CommandCode.SQL)

    if params.ipython and CommandCode.PYTHON not in notebook_languages:
        langs = []
        for x in notebook_languages:
            langs.append(Parser.code_to_extension[x])
        lang_str = ", ".join(langs)
        raise UsageError(
            "IPython target can only be used when generating Python. "
            + f"Languages found: {lang_str}"
        )

    notebooks = []
    for kind in notebook_kinds:
        for user in notebook_users:
            for lang in notebook_languages:
                if (kind != NotebookKind.IPYTHON) or (
                    kind == NotebookKind.IPYTHON and lang == CommandCode.PYTHON
                ):
                    notebooks.append(NotebookGenerator(kind, user, lang, params))

    parser = Parser()
    for db_src in files:
        header, commands = parser.generate_commands(db_src, params)
        for notebook in notebooks:
            notebook.generate(header, commands, db_src, params)

    Main entry point for notebook processing. This function can be used to
    process notebook from within another Python program.

    :param params: parameters
    :return: Nothing.
    
Main entry point for notebook processing. This function can be used to
process notebook from within another Python program.
Main entry point for notebook processing . This function can be used to process notebook from within another Python program .
def _do_process_notebooks(params: Params) -> NoReturn:
    global _output_dir, _file_encoding_in, _file_encoding_out
    _output_dir = params.output_dir
    _file_encoding_in = params.encoding_in
    _file_encoding_out = params.encoding_out
    if (params.course_type is None) or (params.course_type == CourseType.NONE):
        raise UsageError("course_type must be set.")
    if not (params.databricks or params.ipython):
        raise UsageError("Specify at least one of databricks or ipython")
    if not (params.scala or params.python or params.r or params.sql):
        raise UsageError("Specify at least one of Scala, Python, R or SQL")
    if not (params.instructor or params.answers or params.exercises):
        raise UsageError("Specify at least one of: instructor, answers, exercises")
    if os.path.isdir(params.path):
        files = []
        for p in ["*.py", "*.scala", "*.r", "*.sql"]:
            files.extend(glob.glob(os.path.join(params.path, p)))
    else:
        files = [params.path]
    if not files:
        raise UsageError(f"No acceptable files found for {params.path}")
    notebook_kinds = []
    if params.databricks:
        notebook_kinds.append(NotebookKind.DATABRICKS)
    if params.ipython:
        notebook_kinds.append(NotebookKind.IPYTHON)
    notebook_users = []
    if params.instructor:
        notebook_users.append(NotebookUser.INSTRUCTOR)
    if params.exercises:
        notebook_users.append(NotebookUser.EXERCISES)
    if params.answers:
        notebook_users.append(NotebookUser.ANSWERS)
    notebook_languages = []
    if params.scala:
        notebook_languages.append(CommandCode.SCALA)
    if params.python:
        notebook_languages.append(CommandCode.PYTHON)
    if params.r:
        notebook_languages.append(CommandCode.R)
    if params.sql:
        notebook_languages.append(CommandCode.SQL)
    if params.ipython and CommandCode.PYTHON not in notebook_languages:
        langs = []
        for x in notebook_languages:
            langs.append(Parser.code_to_extension[x])
        lang_str = ", ".join(langs)
        raise UsageError(
            "IPython target can only be used when generating Python. "
            + f"Languages found: {lang_str}"
        )
    notebooks = []
    for kind in notebook_kinds:
        for user in notebook_users:
            for lang in notebook_languages:
                if (kind != NotebookKind.IPYTHON) or (
                    kind == NotebookKind.IPYTHON and lang == CommandCode.PYTHON
                ):
                    notebooks.append(NotebookGenerator(kind, user, lang, params))
    parser = Parser()
    for db_src in files:
        header, commands = parser.generate_commands(db_src, params)
        for notebook in notebooks:
            notebook.generate(header, commands, db_src, params)
def _do_process_notebooks ( params : Params ) -> NoReturn : global _output_dir , _file_encoding_in , _file_encoding_out _output_dir = params . output_dir _file_encoding_in = params . encoding_in _file_encoding_out = params . encoding_out if ( params . course_type is None ) or ( params . course_type == CourseType . NONE ) : raise UsageError ( "course_type must be set." ) if not ( params . databricks or params . ipython ) : raise UsageError ( "Specify at least one of databricks or ipython" ) if not ( params . scala or params . python or params . r or params . sql ) : raise UsageError ( "Specify at least one of Scala, Python, R or SQL" ) if not ( params . instructor or params . answers or params . exercises ) : raise UsageError ( "Specify at least one of: instructor, answers, exercises" ) if os . path . isdir ( params . path ) : files = [ ] for p in [ "*.py" , "*.scala" , "*.r" , "*.sql" ] : files . extend ( glob . glob ( os . path . join ( params . path , p ) ) ) else : files = [ params . path ] if not files : raise UsageError ( f"No acceptable files found for {params.path}" ) notebook_kinds = [ ] if params . databricks : notebook_kinds . append ( NotebookKind . DATABRICKS ) if params . ipython : notebook_kinds . append ( NotebookKind . IPYTHON ) notebook_users = [ ] if params . instructor : notebook_users . append ( NotebookUser . INSTRUCTOR ) if params . exercises : notebook_users . append ( NotebookUser . EXERCISES ) if params . answers : notebook_users . append ( NotebookUser . ANSWERS ) notebook_languages = [ ] if params . scala : notebook_languages . append ( CommandCode . SCALA ) if params . python : notebook_languages . append ( CommandCode . PYTHON ) if params . r : notebook_languages . append ( CommandCode . R ) if params . sql : notebook_languages . append ( CommandCode . SQL ) if params . ipython and CommandCode . PYTHON not in notebook_languages : langs = [ ] for x in notebook_languages : langs . append ( Parser . code_to_extension [ x ] ) lang_str = ", " . join ( langs ) raise UsageError ( "IPython target can only be used when generating Python. " + f"Languages found: {lang_str}" ) notebooks = [ ] for kind in notebook_kinds : for user in notebook_users : for lang in notebook_languages : if ( kind != NotebookKind . IPYTHON ) or ( kind == NotebookKind . IPYTHON and lang == CommandCode . PYTHON ) : notebooks . append ( NotebookGenerator ( kind , user , lang , params ) ) parser = Parser ( ) for db_src in files : header , commands = parser . generate_commands ( db_src , params ) for notebook in notebooks : notebook . generate ( header , commands , db_src , params )
Main entry point for notebook processing.
Main entry point for notebook processing .
"""
    Main entry point for notebook processing. This function can be used to
    process notebook from within another Python program.

    :param params: parameters
    :return: Nothing.
    """
None
params
Params
None