Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
 def textdiff_parser():
     """
     defines the way to parse the magic command ``%textdiff``
     """
     parser = MagicCommandParser(prog="textdiff",
                                 description='show the differences between two files, two text')
     parser.add_argument('f1', type=str, help='first file or text or url')
     parser.add_argument('f2', type=str, help='second file or text or url')
     parser.add_argument(
         '-c',
         '--context',
         default="",
         help='context view, empty to see everything, > 0 to see only a couple of lines around the changes')
     parser.add_argument(
         '-i',
         '--inline',
         action="store_true",
         default=False,
         help='True=one column (inline) or False=two columns')
     parser.add_argument(
         '-e',
         '--encoding',
         default="utf8",
         help='file encoding')
     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
Esempio n. 6
0
 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 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
Esempio n. 8
0
 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
Esempio n. 10
0
 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
Esempio n. 11
0
 def dfs_ls_parser():
     """
     defines the way to parse the magic command ``%dfs_ls``
     """
     parser = MagicCommandParser(prog="dfs_ls",
                                 description='returns the content of a folder from the cluster as a dataframe')
     parser.add_argument(
         'path',
         type=str,
         help='path to look into')
     return parser
Esempio n. 12
0
 def hd_job_kill_parser():
     """
     defines the way to parse the magic command ``%hd_job_kill``
     """
     parser = MagicCommandParser(prog="hd_job_kill",
                                 description='kill a job')
     parser.add_argument(
         'jobid',
         type=str,
         help='job id')
     return parser
Esempio n. 13
0
 def hd_job_status_parser():
     """
     defines the way to parse the magic command ``%hd_job_status``
     """
     parser = MagicCommandParser(prog="hd_job_status",
                                 description='get the status of the job')
     parser.add_argument(
         'jobid',
         type=str,
         help='job id')
     return parser
Esempio n. 14
0
 def blob_rmr_parser():
     """
     defines the way to parse the magic command ``%blob_rmr``
     """
     parser = MagicCommandParser(prog="blob_rmr",
                                 description='remove a remote folder')
     parser.add_argument(
         'remotepath',
         type=str,
         help='remote path to remove')
     return parser
Esempio n. 15
0
 def blob_lsl_parser():
     """
     defines the way to parse the magic command ``%blob_lsl``
     """
     parser = MagicCommandParser(prog="blob_lsl",
                                 description='describes the content of folder in a blob storage + metadata')
     parser.add_argument(
         'path',
         type=str,
         help='path to look into, </path> or <container>/<path>')
     return parser
Esempio n. 16
0
 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')
     return parser
Esempio n. 17
0
 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
Esempio n. 18
0
 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
Esempio n. 19
0
 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
Esempio n. 20
0
 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
Esempio n. 21
0
 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
Esempio n. 22
0
 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
Esempio n. 23
0
 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
Esempio n. 24
0
 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 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 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
Esempio n. 28
0
 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 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
Esempio n. 30
0
 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
Esempio n. 31
0
 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
Esempio n. 32
0
 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
Esempio n. 33
0
 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
Esempio n. 34
0
 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
Esempio n. 35
0
 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
Esempio n. 36
0
 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
Esempio n. 37
0
 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
Esempio n. 38
0
 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
Esempio n. 39
0
 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
Esempio n. 40
0
 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
Esempio n. 41
0
 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
Esempio n. 42
0
 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
Esempio n. 43
0
 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
Esempio n. 44
0
 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
Esempio n. 45
0
 def grep_parser():
     """
     defines the way to parse the magic command ``%grep``
     """
     parser = MagicCommandParser(
         prog="grep", description='display the first lines of a text file')
     parser.add_argument('f', type=str, help='filename')
     parser.add_argument('regex', type=str, help='regular expression')
     parser.add_argument('-n',
                         '--n',
                         type=int,
                         default=-1,
                         help='number of lines to display, -1 for all')
     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')
     return parser
 def remote_py_parser():
     """
     defines the way to parse the magic command ``%remote_py``
     """
     parser = MagicCommandParser(
         prog="remote_py", description='run a python script on the bridge')
     parser.add_argument('file', type=str, help='file name')
     parser.add_argument('args',
                         nargs='*',
                         type=str,
                         help='list of options for the job')
     parser.add_argument('-i',
                         '--interpreter',
                         type=str,
                         default='python',
                         help='change the interpreter, python by default')
     parser.add_argument('--raw-output',
                         default=False,
                         action='store_true',
                         help='display raw text instead of HTML')
     return parser
Esempio n. 47
0
 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')
     return parser
Esempio n. 48
0
 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 remote_down_cluster_parser():
     """
     defines the way to parse the magic command ``%remote_down_cluster``
     """
     parser = MagicCommandParser(
         prog="remote_down_cluster",
         description=
         'download a file from the cluster to the remote machine and then to your local machine'
     )
     parser.add_argument('remotepath',
                         type=str,
                         help='remote path (HDFS) 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')
     parser.add_argument('-m',
                         '--merge',
                         action='store_true',
                         default=False,
                         help='merges files in folder in a single file')
     return parser