def mlnet_parser(): """ Defines the way to parse the magic command ``%%mlnet``. """ parser = MagicCommandParser( prog="mlnet", description= 'Compiles and wrap a C# function into a Python function.\n' 'Automatically adds ML.net dependencies.') parser.add_argument('name', type=str, help='function name') parser.add_argument( '-i', '--idep', nargs='*', action='append', help='internal dependencies (like System, System.Linq)') parser.add_argument( '-d', '--dep', nargs='*', action='append', help='dependencies (assembly name without extension)') parser.add_argument('-c', '--catch', action='store', default=False, help='catch exception') return parser
def jsdf_parser(): """ defines the way to parse the magic command ``%jsdf`` """ parser = MagicCommandParser( description='display a pandas DataFrame based on module qgrid', prog="jsdf") parser.add_argument( 'df', help='dataframe to display') parser.add_argument( '--defaultColumnWidth', type=int, default=80, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--enableColumnReorder', type=bool, default=True, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--multiColumnSort', type=bool, default=False, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--rowHeight', type=int, default=25, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--showHeaderRow', type=bool, default=False, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--forceFitColumns', type=bool, default=False, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--autoHeight', type=bool, default=False, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--enableCellNavigation', type=bool, default=True, help='see https://github.com/mleibman/SlickGrid/wiki/Grid-Options') parser.add_argument( '--precision', type=int, default=4, help='see function qgrid.set_defaults') parser.add_argument( '--editable', type=bool, default=True, help='make the output editable') return parser
def snap_parser(): """ defines the way to parse the magic command ``%snap`` """ parser = MagicCommandParser(prog="snap", description='insert a snap window inside a notebook') parser.add_argument( '-f', '--file', type=str, default="", help='scratch or snap file to display') parser.add_argument( '-d', '--div', type=str, default="scratch_div_id", help='id for the HTML div') parser.add_argument( '-W', '--width', type=int, default=1000, help='window width') parser.add_argument( '-H', '--height', type=int, default=600, help='window height') return parser
def SQL_import_tsv_parser(): """ defines the way to parse the magic command ``%SQL_import_tsv`` """ parser = MagicCommandParser( prog="SQL_import_tsv", description='import a tsv file into the database') parser.add_argument('filename', type=str, help='tsv file name', eval_type=str) parser.add_argument('-t', '--table', type=str, help='table name', default="-", eval_type=str) parser.add_argument('--verbose', help='print progress', action="store_true") parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def head_parser(): """ defines the way to parse the magic command ``%head`` """ parser = MagicCommandParser( prog="head", description='display the first lines of a text file') parser.add_argument('f', type=str, help='filename') parser.add_argument('-n', '--n', type=int, default=10, help='number of lines to display') parser.add_argument('-r', '--raw', default=False, action='store_true', help='display raw text instead of HTML') parser.add_argument('-e', '--encoding', default="utf8", help='file encoding') parser.add_argument( '-s', '--errors', default="", help='What about errors: "", strict, replace, surrogateescape, ' 'xmlcharrefreplace, backslashreplace, namereplace') return parser
def SQL_parser(): """ defines the way to parse the magic command ``%%SQL`` """ parser = MagicCommandParser(prog="SQL", description='query the database') parser.add_argument('--df', type=str, help='output dataframe', default="temp_view", no_eval=True) parser.add_argument('-n', '--n', type=int, help='number of first lines to display', default=10, eval_type=int) parser.add_argument( '-q', '--query', type=str, help= 'when used in a single line (no cell), query is the SQL query, the command ' + 'returns the full dataframe', default="", eval_type=str) parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def dfs_mkdir_parser(): """ defines the way to parse the magic command ``%dfs_mkdir`` """ parser = MagicCommandParser(prog="dfs_mkdir", description='create a folder') parser.add_argument('path', type=str, help='path to remove') return parser
def remote_ls_parser(): """ defines the way to parse the magic command ``%remote_ls`` """ parser = MagicCommandParser( prog="remote_ls", description='returns the content of a folder as a dataframe') parser.add_argument('path', type=str, help='path to look into') return parser
def PYTHON_parser(): """ Defines the way to parse the magic command ``%%PYTHON``. """ parser = MagicCommandParser( prog="PYTHON", description= 'the command stores the content of the cell as a local file.') parser.add_argument('file', type=str, help='filename') return parser
def HIVE_parser(): """ defines the way to parse the magic command ``%%HIVE`` """ parser = MagicCommandParser( prog="HIVE", description= 'The command store the content of the cell as a local file.') parser.add_argument('file', type=str, help='file name') return parser
def mpl_style_parser(): """ defines the way to parse the magic command ``%mpl_style`` """ parser = MagicCommandParser(description='changes matplotlib style', prog="mpl_style") parser.add_argument('style', type=str, help='style, ggplot for exemple', default="ggplot") return parser
def remote_up_parser(): """ defines the way to parse the magic command ``%remote_up`` """ parser = MagicCommandParser( prog="remote_up", description='upload a file to the remote machine') parser.add_argument('localfile', type=str, help='local file to upload') parser.add_argument('remotepath', type=str, help='remote path of the uploaded file') return parser
def job_syntax_parser(): """ defines the way to parse the magic command ``%job_syntax`` """ parser = MagicCommandParser(prog="remote_py", description='check syntax of a pig job') parser.add_argument('file', type=str, help='file name') parser.add_argument('--raw-output', default=False, action='store_true', help='display raw text instead of HTML') return parser
def SQL_tables_parser(): """ defines the way to parse the magic command ``%SQL_tables`` """ parser = MagicCommandParser( prog="SQL_tables", description='list the tables of a database') parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def maml_parser(): """ Defines the way to parse the magic command ``%%maml``. """ parser = MagicCommandParser(prog="maml", description='Runs a maml script.') parser.add_argument('-q', '--quiet', action='store_true', default=False, help='hide output') return parser
def lsrepo_parser(): """ defines the way to parse the magic command ``%lsrepo`` """ parser = MagicCommandParser( prog="lsrepo", description='display the content of a repository (GIT or SVN)') parser.add_argument('path', type=str, nargs="?", help='path', default=".") return parser
def SQL_drop_table_parser(): """ defines the way to parse the magic command ``%SQL_drop_table`` """ parser = MagicCommandParser(prog="SQL_drop_table", description='drop a table from a database') parser.add_argument('table', type=str, help='table', eval_type=str) parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def SQL_close_parser(): """ defines the way to parse the magic command ``%SQL_close`` """ parser = MagicCommandParser(prog="SQL_close", description='connect to a SQL database') parser.add_argument( '-v', '--variable', default="DB", help= 'variable name used to store the database object (and to close)') return parser
def open_remote_shell_parser(): """ defines the way to parse the magic command ``%open_remote_shell`` """ parser = MagicCommandParser( prog="open_remote_shell", description='command will execute as if they were in a shell') parser.add_argument('-f', '--format', type=str, default='html', help='formart of this output, html or plain') return parser
def dfs_rm_parser(): """ defines the way to parse the magic command ``%dfs_rm`` """ parser = MagicCommandParser(prog="dfs_rm", description='remove a file on the cluster') parser.add_argument('path', type=str, help='path to remove') parser.add_argument('-r', '--recursive', action='store_true', default=False, help='to remove subfolders too') return parser
def SQL_refresh_completion_parser(): """ defines the way to parse the magic command ``%SQL_refresh_completion`` """ parser = MagicCommandParser( prog="SQL_refresh_completion", description='refresh completion (tables names, ...)') parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def SQL_add_function_parser(): """ defines the way to parse the magic command ``%SQL_add_function`` """ parser = MagicCommandParser( prog="SQL_add_function", description='add a custom function to the database') parser.add_argument('funct', type=str, help='function name') parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def encoding_parser(): """ defines the way to parse the magic command ``%encoding`` """ parser = MagicCommandParser(prog="encoding", description='guess the encoding of a file') parser.add_argument('f', type=str, help='filename') parser.add_argument( '-n', '--n', type=int, default=2**20, help='maximum number of lines to use to guess the encoding') return parser
def runpy_parser(): """ Defines the way to parse the magic command ``%%runpy``. """ parser = MagicCommandParser( prog="runpy", description='run a python script which accepts standards input and ' + 'produces standard outputs, a timeout is set up at 10s') parser.add_argument('file', type=str, help='python file') parser.add_argument('args', type=str, nargs="*", help='arguments for the scripts', default=".") return parser
def SQL_schema_parser(): """ defines the way to parse the magic command ``%SQL_schema`` """ parser = MagicCommandParser(prog="SQL_schema", description='schema of a table') parser.add_argument('table', type=str, help='table', eval_type=str) parser.add_argument('--as_list', help='as a dictionary (False) or as a list (True)', action="store_true") parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def SQL_connect_parser(): """ defines the way to parse the magic command ``%SQL_connect`` """ parser = MagicCommandParser(prog="SQL_connect", description='connect to a SQL database') parser.add_argument('filename', type=str, help='database filename', eval_type=str) parser.add_argument( '-v', '--variable', default="DB", help='variable name used to store the database object') return parser
def remote_down_parser(): """ defines the way to parse the magic command ``%remote_down`` """ parser = MagicCommandParser( prog="remote_down", description='download a file from the remote machine') parser.add_argument('remotepath', type=str, help='remote path of the uploaded file') parser.add_argument('localfile', type=str, help='local file to upload') parser.add_argument('-o', '--overwrite', action='store_true', default=False, help='overwrite the local file') return parser
def lsr_parser(): """ defines the way to parse the magic command ``%lsr`` """ parser = MagicCommandParser( prog="lsr", description='display the content of a folder as a dataframe') parser.add_argument('path', type=str, nargs="?", help='path', default=".") parser.add_argument('-f', '--filter', type=str, default=".*", help='filter, same syntax as a regular expression') return parser
def nb_menu_parser(): """ defines the way to parse the magic command ``%nb_menu`` """ parser = MagicCommandParser( description='display a menu in the notebook based on javascript', prog="nb_menu") parser.add_argument( '-t', '--title', type=str, default="Plan", help='title before the menu') parser.add_argument( '-i', '--menu-id', type=str, default="my_menu_id", help='menu id used to locate the corresponding HTML tag div') parser.add_argument( '-f', '--format', type=str, default="html", help='format to consider, html or rst') parser.add_argument( '-l1', '--level1', type=int, default=2, help='first level to consider in the menu') parser.add_argument( '-l2', '--level2', type=int, default=4, help='last level to consider in the menu') parser.add_argument( '-r', '--raw', type=bool, default=False, help='if true, displays the javascript, otherwise the html') return parser
def pig_submit_parser(): """ defines the way to parse the magic command ``%pig_submit`` """ parser = MagicCommandParser( prog="pig_submit", description= 'Submits a job to the cluster, the job is local, the job ' + 'is first uploaded to the cluster. The magic command populates the local variable last_job with the submitted job id.' ) parser.add_argument('file', type=str, help='file name') parser.add_argument('-d', '--dependency', nargs="*", type=str, help='dependency of the job, the python script') parser.add_argument( '-l', '--local', action='store_true', default=False, help='run locally on the bridge or on the cluster (default)') parser.add_argument('-r', '--redirection', type=str, default="redirection.pig", help='list of options for the job') parser.add_argument('--raw-output', default=False, action='store_true', help='display raw text instead of HTML') parser.add_argument( '-s', '--stop_on_failure', action='store_true', default=False, help='if true, the job stops on failure right away') parser.add_argument('-o', '--option', nargs='*', type=str, help='list of options for the job') return parser