Esempio n. 1
0
def display_get_zipcode_attributes(parms):
    """
    * ---------------------------------------------------------
    * function : display the calculate distance form 
    * 
    * parms :
    *  pytype  - address or coords
    *
    * returns : 
    *  N/A 
    * --------------------------------------------------------
    """

    zip_attr_form = InputForm(
        zipcode_atributes_input_id, zipcode_atributes_input_idList,
        zipcode_atributes_input_labelList, zipcode_atributes_input_typeList,
        zipcode_atributes_input_placeholderList,
        zipcode_atributes_input_jsList, zipcode_atributes_input_reqList)

    zip_attr_form.set_gridwidth(720)
    zip_attr_form.set_custombwidth(100)

    zip_attr_form.set_fullparms(True)

    zip_attr_input_html = ""
    zip_attr_input_html = zip_attr_form.get_html()

    zip_attr_heading_html = "<div>Get Zipcode Attributes</div>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"]
    gridhtmls = [zip_attr_heading_html, zip_attr_input_html]

    print("\n")
    display_generic_grid("geocode-utility-wrapper", gridclasses, gridhtmls)
Esempio n. 2
0
def display_get_cities_for_state(parms):

    state_cities_form = InputForm(
        state_cities_input_id, state_cities_input_idList,
        state_cities_input_labelList, state_cities_input_typeList,
        state_cities_input_placeholderList, state_cities_input_jsList,
        state_cities_input_reqList)

    selectDicts = []

    from dfcleanser.sw_utilities.sw_utility_model import get_Dict
    states_dict = get_Dict("US_States_and_Territories")

    state_keys = list(states_dict.keys())
    state_keys.sort()

    states_list = []

    for i in range(len(state_keys)):
        states_list.append(
            str(state_keys[i]) + " : " + str(states_dict.get(state_keys[i])))

    state_sel = {"default": states_list[0], "list": states_list}
    selectDicts.append(state_sel)

    get_select_defaults(state_cities_form, state_cities_input_id,
                        state_cities_input_idList, state_cities_input_typeList,
                        selectDicts)

    state_cities_form.set_gridwidth(720)
    state_cities_form.set_custombwidth(100)

    state_cities_form.set_fullparms(True)

    state_cities_input_html = ""
    state_cities_input_html = state_cities_form.get_html()

    state_cities_heading_html = "<div>Get State Cities</div>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"]
    gridhtmls = [state_cities_heading_html, state_cities_input_html]

    print("\n")
    display_generic_grid("geocode-utility-wrapper", gridclasses, gridhtmls)
Esempio n. 3
0
def display_get_cities_for_county(parms):

    if (parms is None):

        fparms = cfg.get_config_value(county_cities_input_id + "Parms")
        if (not (fparms is None)):
            stateid = fparms[0]
        else:
            stateid = None

    else:

        fparms = get_parms_for_input(parms, county_cities_input_idList)
        stateid = fparms[0]
        cfg.set_config_value(county_cities_input_id + "Parms", fparms)

    county_cities_form = InputForm(
        county_cities_input_id, county_cities_input_idList,
        county_cities_input_labelList, county_cities_input_typeList,
        county_cities_input_placeholderList, county_cities_input_jsList,
        county_cities_input_reqList)

    selectDicts = []

    from dfcleanser.sw_utilities.sw_utility_model import get_Dict
    states_dict = get_Dict("US_States_and_Territories")

    state_keys = list(states_dict.keys())
    state_keys.sort()

    states_list = []

    for i in range(len(state_keys)):
        states_list.append(
            str(state_keys[i]) + " : " + str(states_dict.get(state_keys[i])))

    if (stateid is None):
        state_def = states_list[0]
    else:
        state_def = stateid

    state_sel = {
        "default": state_def,
        "list": states_list,
        "callback": "change_state_for_counties"
    }
    selectDicts.append(state_sel)

    state_id = state_def[:2]

    counties_list = suzm.get_counties_for_state(state_id)
    county_sel = {"default": counties_list[0], "list": counties_list}
    selectDicts.append(county_sel)

    get_select_defaults(county_cities_form, county_cities_input_id,
                        county_cities_input_idList,
                        county_cities_input_typeList, selectDicts)

    county_cities_form.set_gridwidth(720)
    county_cities_form.set_custombwidth(100)

    county_cities_form.set_fullparms(True)

    county_cities_input_html = ""
    county_cities_input_html = county_cities_form.get_html()

    county_cities_heading_html = "<div>Get County Cities</div>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"]
    gridhtmls = [county_cities_heading_html, county_cities_input_html]

    print("\n")
    display_generic_grid("geocode-utility-wrapper", gridclasses, gridhtmls)
def display_next_criteria(df_title, df, criteria, output_df_title):
    """
    * -------------------------------------------------------------------------- 
    * function : display current df subset form
    * 
    * parms :
    *  df      -   dataframe to subset from
    *  filters -   filters form 
    *  colname -   filters column name 
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    col_stats_table = get_column_stats_table(df_title, df)

    from dfcleanser.common.html_widgets import InputForm
    subset_input_form = InputForm(
        get_next_criteria_input_id, get_next_criteria_input_idList,
        get_next_criteria_input_labelList, get_subset_criteria_input_typeList,
        get_subset_criteria_input_placeholderList,
        get_next_criteria_input_jsList, get_subset_criteria_input_reqList)

    subset_input_form.set_label_note({
        2: [
            dfchelp.SUBSET_CRITERIA, "dataframe subset criteria",
            "subsetcriteriaimageid"
        ]
    })

    subset_input_form.set_textarea_resize_flag(1, False)
    subset_input_form.set_textarea_resize_flag(3, False)

    subset_input_form.set_shortForm(False)
    subset_input_form.set_gridwidth(620)
    subset_input_form.set_custombwidth(110)
    subset_input_form.set_fullparms(True)
    subset_input_form.set_custom_font_size("gsnextselectstring", 14)

    cfg.set_config_value(get_next_criteria_input_id + "Parms", [
        output_df_title, swsm.starting_criteria_preamble, criteria,
        swsm.starting_criteria_postamble
    ])
    cfg.set_config_value(get_next_criteria_input_id + "ParmsProtect",
                         [False, True, False, True])

    get_subset_input_html = subset_input_form.get_html()

    get_subset_heading_html = "<div>Get Dataframe Subset</div><br></br>"

    gridclasses = ["dfc-top", "dfcleanser-common-grid-header", "dfc-bottom"]
    gridhtmls = [
        col_stats_table, get_subset_heading_html, get_subset_input_html
    ]

    print("\n")
    display_generic_grid("sw-utils-subset-wrapper", gridclasses, gridhtmls)
def display_manual_df_subset_setup(sequence_title, input_df_title,
                                   colnames_list, cols_action, stepid):
    """
    * -------------------------------------------------------------------------- 
    * function : display current manual df subset form
    * 
    * parms :
    *  df      -   dataframe to subset from
    *  filters -   filters form 
    *  colname -   filters column name 
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    df = swsm.get_current_subset_df()
    col_stats_table = get_column_stats_table(input_df_title, df)

    from dfcleanser.common.html_widgets import InputForm
    subset_input_form = InputForm(get_manual_input_id, get_manual_input_idList,
                                  get_manual_input_labelList,
                                  get_manual_input_typeList,
                                  get_manual_input_placeholderList,
                                  get_manual_input_jsList,
                                  get_manual_input_reqList)

    selectDicts = []

    dataframes = {
        "default": input_df_title,
        "list": [input_df_title]
    }  #cfg.get_dfc_dataframes_select_list(cfg.SWDFSubsetUtility_ID)

    selectDicts.append(dataframes)

    current_df = df  #cfg.get_dfc_dataframe_df(input_df_title)
    colnames = current_df.columns.tolist()
    cols_name_list = [" "]
    for i in range(len(colnames)):
        cols_name_list.append(colnames[i])

    cnames = {
        "default": cols_name_list[0],
        "list": cols_name_list,
        "callback": "change_subset_cols"
    }
    selectDicts.append(cnames)

    if (cols_action == "Keep"):
        subssel = {"default": "Keep", "list": ["Keep", "Drop"]}
    else:
        subssel = {"default": "Drop", "list": ["Keep", "Drop"]}
    selectDicts.append(subssel)

    get_select_defaults(subset_input_form, get_manual_input_form[0],
                        get_manual_input_form[1], get_manual_input_form[3],
                        selectDicts)

    if (len(colnames_list) > 0):
        cnames = str(colnames_list)
    else:
        cnames = ""

    cfg.set_config_value(get_manual_input_id + "Parms",
                         ["", cnames, "", cols_action])
    cfg.set_config_value(get_manual_input_id + "ParmsProtect",
                         [True, False, False, False])

    subset_input_form.set_shortForm(False)
    subset_input_form.set_gridwidth(680)
    subset_input_form.set_custombwidth(140)
    subset_input_form.set_fullparms(True)

    get_subset_input_html = subset_input_form.get_html()

    get_subset_heading_html = "<div>Run Subset Sequence '" + str(
        sequence_title) + "' Step " + str(stepid) + "</div><br></br>"

    gridclasses = ["dfc-top", "dfcleanser-common-grid-header", "dfc-bottom"]
    gridhtmls = [
        col_stats_table, get_subset_heading_html, get_subset_input_html
    ]

    print("\n")
    display_generic_grid("sw-utils-subset-wrapper", gridclasses, gridhtmls)
def display_dc_export_forms(exid, detid=0, notes=False):
    """
    * -------------------------------------------------------------------------- 
    * function : display pandas export input forms
    * 
    * parms :
    *   exid    -   export type
    *   detid   -   detail id
    *   notes   -   notes flag
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    clear_output()

    # add the main import task bar
    if (exid == dem.EXPORT_TB_ONLY):

        display_export_main_taskbar()
        cfg.display_data_select_df(cfg.DataExport_ID)

    else:

        if (cfg.is_a_dfc_dataframe_loaded()):

            # add the pandas import task bar or pandas details form
            if ((exid == dem.EXPORT_PANDAS_TB_ONLY)
                    or (exid == dem.EXPORT_PANDAS_TB_PLUS_DETAILS)):

                # add the pandas export details form
                if (exid == dem.EXPORT_PANDAS_TB_PLUS_DETAILS):

                    if (detid == dem.SQLTABLE_EXPORT):

                        import dfcleanser.common.db_utils as dbutils

                        cfg.drop_config_value(pandas_export_sqltable_id +
                                              "Parms")

                        dbid = cfg.get_config_value(cfg.CURRENT_DB_ID_KEY)

                        if (dbid == None):
                            cfg.set_config_value(cfg.CURRENT_DB_ID_KEY,
                                                 dbutils.MySql)
                            conparms = cfg.get_config_value(
                                dbutils.MYSQL_DBCON_PARMS)
                            if (conparms == None):
                                conparms = [
                                    "", "", "", "", dbutils.pymysql_library
                                ]

                        elif (dbid == dbutils.MySql):
                            conparms = cfg.get_config_value(
                                dbutils.MYSQL_DBCON_PARMS)
                            if (conparms == None):
                                conparms = [
                                    "", "", "", "", dbutils.pymysql_library
                                ]

                        elif (dbid == dbutils.MS_SQL_Server):
                            conparms = cfg.get_config_value(
                                dbutils.MSSQL_DBCON_PARMS)
                            if (conparms == None):
                                conparms = [
                                    "", "", "", "", dbutils.pyodbc_library
                                ]

                        elif (dbid == dbutils.SQLite):
                            conparms = cfg.get_config_value(
                                dbutils.SQLITE_DBCON_PARMS)
                            if (conparms == None):
                                conparms = ["", dbutils.sqlite3_library]

                        elif (dbid == dbutils.Postgresql):
                            conparms = cfg.get_config_value(
                                dbutils.POSTGRESQL_DBCON_PARMS)
                            if (conparms == None):
                                conparms = [
                                    "", "", "", "", dbutils.psycopg2_library
                                ]

                        elif (dbid == dbutils.Oracle):
                            conparms = cfg.get_config_value(
                                dbutils.ORACLE_DBCON_PARMS)
                            if (conparms == None):
                                conparms = [
                                    "", "", "", dbutils.cx_oracle_library
                                ]

                        elif (dbid == dbutils.Custom):
                            conparms = cfg.get_config_value(
                                dbutils.CUSTOM_DBCON_PARMS)
                            if (conparms == None): conparms = [""]

                        dbutils.display_db_connector_inputs(
                            cfg.get_config_value(cfg.CURRENT_DB_ID_KEY),
                            conparms, dbutils.SQL_EXPORT)

                    else:

                        display_export_main_taskbar()

                        pandas_export_form = get_pandas_export_input_form(
                            detid)

                        if (cfg.get_dfc_mode() == cfg.INLINE_MODE):
                            pandas_export_form.set_shortForm(True)
                            pandas_export_form.set_gridwidth(640)
                            pandas_export_form.set_custombwidth(110)
                        else:
                            pandas_export_form.set_gridwidth(480)
                            pandas_export_form.set_custombwidth(100)

                        pandas_input_html = ""
                        pandas_input_html = pandas_export_form.get_html()

                        pandas_input_heading_html = "<div>" + get_pandas_export_input_title(
                            detid) + "</div>"

                        gridclasses = [
                            "dfcleanser-common-grid-header", "dfc-footer"
                        ]
                        gridhtmls = [
                            pandas_input_heading_html, pandas_input_html
                        ]

                        if (cfg.get_dfc_mode() == cfg.INLINE_MODE):
                            display_generic_grid("data-import-wrapper",
                                                 gridclasses, gridhtmls)
                        else:
                            display_generic_grid("data-import-pop-up-wrapper",
                                                 gridclasses, gridhtmls)

                else:
                    display_pandas_export_taskbar()

            elif (exid == dem.EXPORT_CUSTOM_ONLY):

                print("dem.EXPORT_PANDAS_TB_ONLY")

                # add the custom import form
                exportCustomDetailsForm = InputForm(
                    custom_export_id, custom_export_idList,
                    custom_export_labelList, custom_export_typeList,
                    custom_export_placeholderList, custom_export_jsList,
                    custom_export_reqList)

                if (notes):
                    customNotes = [
                        "To create custom export code in the code cell below hit 'New Custom Export'",
                        "&nbsp;&nbsp;&nbsp;&nbsp;(enter and test export in the code cell below)",
                        "&nbsp;&nbsp;&nbsp;&nbsp;(leave the '# custom export' comment line in the code cell",
                        "&nbsp;&nbsp;&nbsp;&nbsp;(call dfcleanser.common.cfg.get_dfc_dataframe_df() to get the current dataframe)",
                        "To run the export code in the Custom Export Code box hit 'Run Custom Export' button",
                        "&nbsp;&nbsp;&nbsp;&nbsp;(only the code in the Custom Export Code box is run and stored for scripting)",
                        "Once import successful hit 'Save Custom Import' button to store import code for future retrieval",
                        "To drop the custom export code and clear the Custom Export Code box hit 'Drop Custom Export' button"
                    ]

                    print("\n")
                    display_inline_help(customNotes, 92)

                selectDicts = []

                df_list = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID)
                selectDicts.append(df_list)

                flags = {"default": "False", "list": ["True", "False"]}
                selectDicts.append(flags)

                get_select_defaults(exportCustomDetailsForm, custom_export_id,
                                    custom_export_idList,
                                    custom_export_typeList, selectDicts)

                if (cfg.get_dfc_mode() == cfg.INLINE_MODE):
                    exportCustomDetailsForm.set_shortForm(True)
                    exportCustomDetailsForm.set_gridwidth(640)
                    exportCustomDetailsForm.set_custombwidth(110)
                else:
                    exportCustomDetailsForm.set_gridwidth(480)
                    exportCustomDetailsForm.set_custombwidth(100)

                exportCustomDetailsForm.set_fullparms(True)

                from dfcleanser.common.html_widgets import new_line
                custom_code = "# add USER CODE to export the df" + new_line + new_line
                custom_code = (
                    custom_code +
                    "from dfcleanser.common.cfg import get_dfc_dataframe" +
                    new_line)
                custom_code = (custom_code +
                               "df = get_dfc_dataframe_df(dataframe_title)" +
                               new_line + new_line)
                custom_code = (custom_code + "# USER CODE" + new_line)

                cfg.set_config_value(custom_export_id + "Parms",
                                     ["", custom_code, ""])

                custom_export_html = ""
                custom_export_html = exportCustomDetailsForm.get_html()

                custom_export_heading_html = "<div>Custom Export</div><br>"

                gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"]
                gridhtmls = [custom_export_heading_html, custom_export_html]

                if (cfg.get_dfc_mode() == cfg.INLINE_MODE):
                    display_generic_grid("data-import-wrapper", gridclasses,
                                         gridhtmls)
                else:
                    display_generic_grid("data-import-pop-up-wrapper",
                                         gridclasses, gridhtmls)

        else:

            display_export_main_taskbar()
            cfg.display_data_select_df(cfg.DataExport_ID)
            cfg.display_no_dfs(cfg.DataExport_ID)
Esempio n. 7
0
def display_dict_maint(keyValue=None, loadfile=None):
    """
    * ------------------------------------------------------------------------
    * function : display the user dicts maintenance form
    * 
    * parms :
    *  keyValue   - dict name
    *
    * -------------------------------------------------------------------------
    """
    #print("display_dict_maint",keyValue,loadfile)

    opstat = opStatus()

    if (loadfile is None):

        dict_maint_input_form = InputForm(
            maint_dict_utility_input_id, maint_dict_utility_input_idList,
            maint_dict_utility_input_labelList,
            maint_dict_utility_input_typeList,
            maint_dict_utility_input_placeholderList,
            maint_dict_utility_input_jsList, maint_dict_utility_input_reqList)

    else:

        dict_maint_input_form = InputForm(
            maint_dict_file_utility_input_id,
            maint_dict_file_utility_input_idList,
            maint_dict_file_utility_input_labelList,
            maint_dict_file_utility_input_typeList,
            maint_dict_file_utility_input_placeholderList,
            maint_dict_file_utility_input_jsList,
            maint_dict_file_utility_input_reqList)

    selectDicts = []

    from dfcleanser.sw_utilities.sw_utility_model import get_dicts_names, USER_CREATED
    dict_names = get_dicts_names(USER_CREATED)

    #print("dict_names",dict_names)
    if (not (dict_names is None)):

        if (keyValue is None):
            def_dict = dict_names[0]
        else:
            def_dict = keyValue

        seldict = swum.get_Dict(def_dict, USER_CREATED)

        keys = list(seldict.keys())
        if ((def_dict == "Country_Codes") or (def_dict == "Language_Codes")):
            keys.sort()

        seldict = swum.get_pretty_dict(seldict, keys)

    else:
        dict_names = ["No User dicts defined"]
        def_dict = "No User dicts defined"

        seldict = "User defined dict"

    dictssel = {
        "default": def_dict,
        "list": dict_names,
        "callback": "select_dict"
    }
    selectDicts.append(dictssel)

    from dfcleanser.common.common_utils import get_select_defaults

    get_select_defaults(dict_maint_input_form, maint_dict_utility_input_id,
                        maint_dict_utility_input_idList,
                        maint_dict_utility_input_typeList, selectDicts)

    dict_maint_input_form.set_gridwidth(700)
    #dict_maint_input_form.set_custombwidth(110)
    if (loadfile is None):
        dict_maint_input_form.set_buttonstyle({
            "font-size": 13,
            "height": 75,
            "width": 90,
            "left-margin": 20
        })
    else:
        dict_maint_input_form.set_buttonstyle({
            "font-size": 13,
            "height": 75,
            "width": 90,
            "left-margin": 205
        })

    dict_maint_input_form.set_fullparms(True)

    cfg.drop_config_value(maint_dict_utility_input_id + "Parms")
    cfg.drop_config_value(maint_dict_utility_input_id + "ParmsProtect")

    if (not (loadfile is None)):

        import json

        #from dfcleanser.common.common_utils import does_file_exist
        #print("does_file_exist",does_file_exist(loadfile))

        try:
            with open(loadfile, 'r') as ds_file:
                ds = json.load(ds_file)
                ds_file.close()

                keys = list(ds.keys())
                seldict = swum.get_pretty_dict(ds, keys)

                #print(seldict)

        except Exception as e:
            opstat.set_errorMsg("invalid user file to load " + loadfile)
            opstat.set_exception(e)

    if (opstat.get_status()):

        if (loadfile is None):
            cfg.set_config_value(maint_dict_utility_input_id + "Parms",
                                 [def_dict, "", seldict, ""])
        else:
            cfg.set_config_value(maint_dict_utility_input_id + "Parms",
                                 [def_dict, "", seldict, loadfile])
            cfg.set_config_value(maint_dict_utility_input_id + "ParmsProtect",
                                 [True, False, True, True])

        help_note = "To add a user dict enter parms and values above and click on 'Add User Dict'.</br>To update the current dict change values and click on 'Update User Dict'"

        from dfcleanser.common.common_utils import get_help_note_html
        dict_maint_notes_html = get_help_note_html(help_note, 80, 75, None)

        dict_maint_html = "Fill in new user dict parms or update currently displayed user dict."
        dict_maint_html = dict_maint_input_form.get_html()

        dict_maint_title_html = "<div>User Dicts</div><br></br>"

        gridclasses = [
            "dfcleanser-common-grid-header", "dfc-bottom", "dfc-footer"
        ]
        gridhtmls = [
            dict_maint_title_html, dict_maint_html, dict_maint_notes_html
        ]

        #print(dict_maint_html)
        #print(dict_maint_notes_html)
        print("\n")
        display_generic_grid("sw-utils-listdict-wrapper", gridclasses,
                             gridhtmls)

    else:

        display_exception(opstat)
        add_error_to_log("[Get User Dict from File] " + loadfile +
                         str(sys.exc_info()[0].__name__))
Esempio n. 8
0
def display_list_dict(stype, keyValue=None):
    """
    * ------------------------------------------------------------------------
    * function : display the dict or list start form
    * 
    * parms :
    *  id         - list or dict
    *  keyValue   - dict or list name
    *
    * -------------------------------------------------------------------------
    """

    #print("display_list_dict",stype,keyValue)

    if (stype == swum.DICT_ID):
        list_dict_form = build_dict_utility_input_form

    else:
        list_dict_form = build_list_utility_input_form

    list_dict_input_form = InputForm(list_dict_form[0], list_dict_form[1],
                                     list_dict_form[2], list_dict_form[3],
                                     list_dict_form[4], list_dict_form[5],
                                     list_dict_form[6])

    selectDicts = []

    if (stype == swum.DICT_ID):

        from dfcleanser.sw_utilities.sw_utility_model import get_dicts_names, DFC_CREATED
        dict_names = get_dicts_names(DFC_CREATED)

        if (keyValue is None):
            def_dict = dict_names[0]
        else:
            def_dict = keyValue
        #print("def_dict",def_dict,keyValue)

        dictssel = {
            "default": def_dict,
            "list": dict_names,
            "callback": "select_dict"
        }
        seldict = swum.get_Dict(def_dict, DFC_CREATED)

        keys = list(seldict.keys())
        if ((def_dict == "Country_Codes") or (def_dict == "Language_Codes")):
            keys.sort()

        seldict = swum.get_pretty_dict(seldict, keys)

    else:

        from dfcleanser.sw_utilities.sw_utility_model import get_lists_names, DFC_CREATED
        list_names = get_lists_names(DFC_CREATED)

        if (keyValue is None):
            def_list = list_names[0]
        else:
            def_list = keyValue

        dictssel = {
            "default": def_list,
            "list": list_names,
            "callback": "select_list"
        }
        sellist = str(swum.get_List(def_list, DFC_CREATED))

    selectDicts.append(dictssel)

    from dfcleanser.common.common_utils import get_select_defaults

    get_select_defaults(list_dict_input_form, list_dict_form[0],
                        list_dict_form[1], list_dict_form[3], selectDicts)

    list_dict_input_form.set_gridwidth(700)
    list_dict_input_form.set_custombwidth(120)
    list_dict_input_form.set_fullparms(True)

    if (stype == swum.DICT_ID):

        selparms = [def_dict, seldict]
        cfg.set_config_value(build_dict_utility_input_id + "Parms", selparms)
        cfg.set_config_value(build_dict_utility_input_id + "ParmsProtect",
                             [False, True])

        help_note = "To retrieve a dict in python from dfcleanser.sw_utiliities.sw_utility.model call 'get_Dict(dictname)'.</br>To add a dict in python from dfcleanser.sw_utiliities.sw_utility.model call 'add_Dict(dictname,newdict)'"

    else:

        selparms = [def_list, sellist]
        cfg.set_config_value(build_list_utility_input_id + "Parms", selparms)
        cfg.set_config_value(build_list_utility_input_id + "ParmsProtect",
                             [False, True])

        help_note = "To retrieve a list in python from dfcleanser.sw_utiliities.sw_utility.model call 'get_List(listname)'.</br>To add a list in python from dfcleanser.sw_utiliities.sw_utility.model call 'add_List(listtname,newlist)'"

    from dfcleanser.common.common_utils import get_help_note_html
    listdict_notes_html = get_help_note_html(help_note, 100, None, None)

    list_dictcustom_html = ""
    list_dictcustom_html = list_dict_input_form.get_html()

    if (stype == swum.DICT_ID):
        list_title_html = "<div>dfc Dicts</div><br></br>"
        cfg.drop_config_value(build_dict_utility_input_id + "Parms")

    else:
        list_title_html = "<div>dfc Lists</div><br></br>"
        cfg.drop_config_value(build_list_utility_input_id + "Parms")

    gridclasses = ["dfcleanser-common-grid-header", "dfc-bottom", "dfc-footer"]
    gridhtmls = [list_title_html, list_dictcustom_html, listdict_notes_html]

    print("\n")
    display_generic_grid("sw-utils-listdict-wrapper", gridclasses, gridhtmls)
def display_df_subset_setup():
    """
    * -------------------------------------------------------------------------- 
    * function : display current df subset form
    * 
    * parms :
    *  df      -   dataframe to subset from
    *  filters -   filters form 
    *  colname -   filters column name 
    *
    * returns : N/A
    * --------------------------------------------------------
    """
    df_title = cfg.get_config_value(cfg.CURRENT_SUBSET_DF)
    df = cfg.get_dfc_dataframe_df(df_title)

    col_stats_table = get_column_stats_table(df_title, df)

    from dfcleanser.common.html_widgets import InputForm
    subset_input_form = InputForm(get_subset_input_id, get_subset_input_idList,
                                  get_subset_input_labelList,
                                  get_subset_input_typeList,
                                  get_subset_input_placeholderList,
                                  get_subset_input_jsList,
                                  get_subset_input_reqList)

    selectDicts = []

    dataframes = cfg.get_dfc_dataframes_select_list(cfg.SWDFSubsetUtility_ID)
    selectDicts.append(dataframes)

    current_df = cfg.get_current_chapter_df(cfg.SWDFSubsetUtility_ID)
    colnames = current_df.columns.tolist()
    cols_name_list = [" "]
    for i in range(len(colnames)):
        cols_name_list.append(colnames[i])

    cnames = {
        "default": cols_name_list[0],
        "list": cols_name_list,
        "callback": "change_subset_cols"
    }
    selectDicts.append(cnames)

    subssel = {"default": "Keep", "list": ["Keep", "Drop"]}
    selectDicts.append(subssel)

    get_select_defaults(subset_input_form, get_subset_input_form[0],
                        get_subset_input_form[1], get_subset_input_form[3],
                        selectDicts)

    subset_input_form.set_shortForm(False)
    subset_input_form.set_gridwidth(680)
    subset_input_form.set_custombwidth(140)
    subset_input_form.set_fullparms(True)

    get_subset_input_html = subset_input_form.get_html()

    get_subset_heading_html = "<div>Get Dataframe Subset</div><br></br>"

    gridclasses = ["dfc-top", "dfcleanser-common-grid-header", "dfc-bottom"]
    gridhtmls = [
        col_stats_table, get_subset_heading_html, get_subset_input_html
    ]

    print("\n")
    display_generic_grid("sw-utils-subset-wrapper", gridclasses, gridhtmls)
def display_dc_data_scripting(optionId, parms=None):

    from IPython.display import clear_output
    clear_output()

    from dfcleanser.common.cfg import check_if_dc_init
    if (not check_if_dc_init()):

        from dfcleanser.common.display_utils import display_dfcleanser_taskbar
        display_dfcleanser_taskbar(
            ButtonGroupForm(dc_script_tb_id, dc_script_tb_keyTitleList,
                            dc_script_tb_jsList, dc_script_tb_centered), False)

        from dfcleanser.scripting.data_scripting_control import clear_data_scripting_data
        clear_data_scripting_data()

        return

    from dfcleanser.common.display_utils import display_dfcleanser_taskbar
    display_dfcleanser_taskbar(
        ButtonGroupForm(dc_script_tb_id, dc_script_tb_keyTitleList,
                        dc_script_tb_jsList, dc_script_tb_centered), False)

    if (parms == None):
        from dfcleanser.scripting.data_scripting_control import clear_data_scripting_data
        clear_data_scripting_data()

    else:

        funcid = int(parms[0])

        if (funcid == dsm.TURN_ON_SCRIPTING):
            from dfcleanser.scripting.data_scripting_control import set_scripting_status
            set_scripting_status(True)
            from dfcleanser.common.common_utils import display_status_note
            display_status_note("Scripting is turned on")

        elif (funcid == dsm.TURN_OFF_SCRIPTING):
            from dfcleanser.scripting.data_scripting_control import set_scripting_status
            set_scripting_status(False)
            from dfcleanser.common.common_utils import display_status_note
            display_status_note("Scripting is turned off")

        elif (funcid == dsm.SHOW_CURRENT_SCRIPT):
            display_scripting_forms()

        elif (funcid == dsm.ADD_TO_CURRENT_SCRIPT):
            script_form = InputForm(
                dc_add_code_input_id, dc_add_code_input_idList,
                dc_add_code_input_labelList, dc_add_code_input_typeList,
                dc_add_code_input_placeholderList, dc_add_code_input_jsList,
                dc_add_code_input_reqList)

            script_form.set_shortForm(True)
            script_form.set_buttonstyle({
                "font-size": 12,
                "height": 75,
                "width": 140,
                "left-margin": 70
            })
            script_form.set_gridwidth(880)
            script_form.set_fullparms(True)

            script_form_html = script_form.get_html()
            script_title_html = "<div>Scripting</div><br>"

            gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"]
            gridhtmls = [script_title_html, script_form_html]

            from dfcleanser.common.common_utils import display_generic_grid
            display_generic_grid("data-scripting-wrapper", gridclasses,
                                 gridhtmls)

        elif (funcid == dsm.ADD_CODE_SCRIPT):
            from dfcleanser.scripting.data_scripting_control import add_code_to_script
            add_code_to_script(parms)
            display_status("Code added to Current Script succesfully ")

        elif (funcid == dsm.DELETE_CURRENT_SCRIPT):
            from dfcleanser.scripting.data_scripting_control import drop_current_script
            drop_current_script()
            display_status("Current Script Cleared succesfully ")

        elif (funcid == dsm.LOAD_BACKUP_SCRIPT):
            from dfcleanser.scripting.data_scripting_control import load_backup_scriptlog_to_current
            load_backup_scriptlog_to_current()
            display_scripting_forms()

            display_status("Current Script Loaded from Backup ")

        elif (funcid == dsm.SAVE_BACKUP_SCRIPT):

            codeparms = get_parms_for_input(parms[1], dc_script_input_idList)
            save_code = get_code_from_form(codeparms)

            from dfcleanser.scripting.data_scripting_control import (
                set_current_scriptlog, save_current_scriptlog_to_backup)
            set_current_scriptlog(save_code)
            save_current_scriptlog_to_backup(save_code)
            display_scripting_forms()

            display_status("Current Script Backed up successfully ")

        elif (funcid == dsm.RUN_CURRENT_SCRIPT):

            opstat = opStatus()
            from dfcleanser.scripting.data_scripting_control import run_scriptlog
            run_scriptlog(parms, opstat)

            if (opstat.get_status()):
                display_status("Current Script Run successfully ")
            else:
                display_exception(opstat)
def display_scripting_forms():

    from dfcleanser.scripting.data_scripting_control import get_current_scriptlog
    if (not (get_current_scriptlog() == None)):
        cfg.set_config_value(dc_script_input_id + "Parms",
                             [get_current_scriptlog()])

    print("\n")

    notes = []
    notes.append("You can manually edit the script log as desired")
    notes.append(
        "The step numbers are cmmentary only and order is insignificant")
    display_notes(notes)

    script_form = InputForm(dc_script_input_id, dc_script_input_idList,
                            dc_script_input_labelList,
                            dc_script_input_typeList,
                            dc_script_input_placeholderList,
                            dc_script_input_jsList, dc_script_input_reqList)

    script_form.set_shortForm(True)
    script_form.set_buttonstyle({
        "font-size": 12,
        "height": 75,
        "width": 140,
        "left-margin": 70
    })
    script_form.set_gridwidth(880)
    script_form.set_fullparms(True)

    script_form_html = script_form.get_html()
    script_title_html = "<div>Scripting</div><br>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-footer"]
    gridhtmls = [script_title_html, script_form_html]

    from dfcleanser.common.common_utils import display_generic_grid
    display_generic_grid("data-scripting-wrapper", gridclasses, gridhtmls)

    cfg.drop_config_value(dc_script_input_id + "Parms")

    print("\n")
Esempio n. 12
0
def display_offline():
    """
    * -------------------------------------------------------------------------- 
    * function : display offline toggle mode
    * 
    * parms :
    *  N/A
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    from dfcleanser.common.html_widgets import InputForm
    dfmanager_input_form = InputForm(
        dfmgr_offline_input_id, dfmgr_offline_input_idList,
        dfmgr_offline_input_labelList, dfmgr_offline_input_typeList,
        dfmgr_offline_input_placeholderList, dfmgr_offline_input_jsList,
        dfmgr_offline_input_reqList)

    selectDicts = []

    if (sysm.get_dfc_run_offline_status()):
        stat = "True"
    else:
        stat = "False"
    offline_mode = {"default": stat, "list": ["False", "True"]}
    selectDicts.append(offline_mode)

    get_select_defaults(dfmanager_input_form, dfmgr_offline_input_id,
                        dfmgr_offline_input_idList,
                        dfmgr_offline_input_typeList, selectDicts)

    dfmanager_input_form.set_shortForm(True)
    dfmanager_input_form.set_gridwidth(480)
    dfmanager_input_form.set_custombwidth(100)
    dfmanager_input_form.set_fullparms(True)

    dfmgr_input_html = dfmanager_input_form.get_html()

    dfmgr_heading_html = "<div>Run dfc Offline Manager</div>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-main"]
    gridhtmls = [dfmgr_heading_html, dfmgr_input_html]

    print("\n")
    if (cfg.get_dfc_mode() == cfg.INLINE_MODE):
        display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses,
                             gridhtmls)
    else:
        display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses,
                             gridhtmls, True)

    from dfcleanser.common.display_utils import display_pop_up_buffer
    display_pop_up_buffer()
Esempio n. 13
0
def get_df_list_html(title):
    """
    * -------------------------------------------------------------------------- 
    * function : get the html for list of dfc dataframes
    * 
    * parms :
    *  N/A
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    fparms = []

    if (title is None):

        if (cfg.is_a_dfc_dataframe_loaded()):
            df_titles = cfg.get_dfc_dataframes_titles_list()
            fparms = [
                df_titles[0],
                str(len(cfg.get_dfc_dataframe_df(df_titles[0]))),
                str(len(cfg.get_dfc_dataframe_df(df_titles[0]).columns)),
                cfg.get_dfc_dataframe_notes(df_titles[0])
            ]
        else:
            fparms = ["", "", "", ""]

    else:

        if (cfg.is_a_dfc_dataframe_loaded()):
            dfc_df = cfg.get_dfc_dataframe(title)

            if (dfc_df is None):
                fparms = ["", "", "", ""]
            else:
                fparms = [
                    title,
                    str(len(cfg.get_dfc_dataframe_df(title))),
                    str(len(cfg.get_dfc_dataframe_df(title).columns)),
                    cfg.get_dfc_dataframe_notes(title)
                ]
        else:
            fparms = ["", "", "", ""]

    parmsProtect = [False, True, True, False]

    cfg.set_config_value(dfmgr_input_id + "Parms", fparms)
    cfg.set_config_value(dfmgr_input_id + "ParmsProtect", parmsProtect)

    dfmanager_input_form = InputForm(dfmgr_input_id, dfmgr_input_idList,
                                     dfmgr_input_labelList,
                                     dfmgr_input_typeList,
                                     dfmgr_input_placeholderList,
                                     dfmgr_input_jsList, dfmgr_input_reqList)

    selectDicts = []
    df_titles = cfg.get_dfc_dataframes_titles_list()

    #if(df_titles is None) :
    if (not (cfg.is_a_dfc_dataframe_loaded())):
        dfs = {"default": " ", "list": [" "]}
    else:
        dfs = {
            "default": str(fparms[0]),
            "list": df_titles,
            "callback": "select_new_df"
        }
    selectDicts.append(dfs)

    get_select_defaults(dfmanager_input_form, dfmgr_input_id,
                        dfmgr_input_idList, dfmgr_input_typeList, selectDicts)

    dfmanager_input_form.set_shortForm(True)
    dfmanager_input_form.set_gridwidth(480)
    dfmanager_input_form.set_custombwidth(90)
    dfmanager_input_form.set_fullparms(True)

    dfmgr_input_html = dfmanager_input_form.get_html()

    return (dfmgr_input_html)
Esempio n. 14
0
def display_add_df_input():
    """
    * -------------------------------------------------------------------------- 
    * function : add a dataframe to the dfc list 
    * 
    * parms :
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    from dfcleanser.common.html_widgets import InputForm
    dfmanager_input_form = InputForm(
        dfmgr_add_input_id, dfmgr_add_input_idList, dfmgr_add_input_labelList,
        dfmgr_add_input_typeList, dfmgr_add_input_placeholderList,
        dfmgr_add_input_jsList, dfmgr_add_input_reqList)

    dfmanager_input_form.set_shortForm(True)
    dfmanager_input_form.set_gridwidth(480)
    dfmanager_input_form.set_custombwidth(70)
    dfmanager_input_form.set_fullparms(True)

    dfmgr_input_html = dfmanager_input_form.get_html()

    dfmgr_heading_html = "<div>Add df to dfc dataframe Manager</div>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-main"]
    gridhtmls = [dfmgr_heading_html, dfmgr_input_html]

    print("\n")
    if (cfg.get_dfc_mode() == cfg.INLINE_MODE):
        display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses,
                             gridhtmls)
    else:
        display_generic_grid("dfc-common-480px-2-vert-wrapper", gridclasses,
                             gridhtmls, True)

    from dfcleanser.common.display_utils import display_pop_up_buffer
    display_pop_up_buffer()
def display_dc_pandas_export_sql_inputs(fId,
                                        dbId,
                                        dbconparms,
                                        exportparms=None):
    """
    * -------------------------------------------------------------------------- 
    * function : display pandas sql export form
    * 
    * parms :
    *   fid             -   export type
    *   dbid            -   database id
    *   dbconparms      -   db connector parms
    *   exportparms     -   export parms
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    opstat = opStatus()
    opstatStatus = True
    listHtml = ""
    dbid = int(dbId)
    fid = int(fId)
    fparms = None

    if (fid == 0):

        dbid = cfg.get_config_value(cfg.CURRENT_DB_ID_KEY)
        from dfcleanser.data_import.data_import_widgets import (
            get_table_names, TABLE_NAMES, get_rows_html)
        tablelist = get_table_names(dbid, opstat)
        listHtml = get_rows_html(tablelist, TABLE_NAMES, True)

    elif (fid == 1):

        fparms = get_parms_for_input(exportparms,
                                     pandas_export_sqltable_idList)
        dbid = cfg.get_config_value(cfg.CURRENT_DB_ID_KEY)
        cfg.set_config_value(pandas_export_sqltable_id + "Parms", fparms)

        if (len(fparms[0]) > 0):
            from dfcleanser.data_import.data_import_widgets import (
                get_column_names, get_rows_html)
            from dfcleanser.data_import.data_import_model import COLUMN_NAMES
            columnlist = get_column_names(dbid, fparms[1], opstat)
            listHtml = get_rows_html(columnlist, COLUMN_NAMES, True)
        else:
            opstat.set_status(False)
            opstat.set_errorMsg("No Table Selected")

    elif (fid == 2):

        cfg.set_config_value(cfg.CURRENT_DB_ID_KEY, dbid)

        dbcondict = {}
        if (not (dbconparms == None)):
            parse_connector_parms(dbconparms, dbid, dbcondict)
        else:
            conparms = get_stored_con_Parms(dbid)
            parse_connector_parms(conparms, dbid, dbcondict)

        listHtml = get_db_connector_list(dbid, dbcondict)

    if (not (opstat.get_status())):
        dbcondict = {}
        conparms = get_stored_con_Parms(dbid)
        parse_connector_parms(conparms, dbid, dbcondict)

        listHtml = get_db_connector_list(dbid, dbcondict)

        opstatStatus = opstat.get_status()
        opstatErrormsg = opstat.get_errorMsg()
        opstat.set_status(True)

    if (opstat.get_status()):

        export_sql_input_form = InputForm(
            pandas_export_sqltable_id, pandas_export_sqltable_idList,
            pandas_export_sqltable_labelList, pandas_export_sqltable_typeList,
            pandas_export_sqltable_placeholderList,
            pandas_export_sqltable_jsList, pandas_export_sqltable_reqList)

        selectDicts = []
        df_list = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID)
        selectDicts.append(df_list)

        exists = {"default": "fail", "list": ["fail", "replace", "append"]}
        selectDicts.append(exists)
        index = {"default": "True", "list": ["True", "False"]}
        selectDicts.append(index)

        get_select_defaults(export_sql_input_form, pandas_export_sqltable_id,
                            pandas_export_sqltable_idList,
                            pandas_export_sqltable_typeList, selectDicts)

        export_sql_input_form.set_shortForm(False)
        export_sql_input_form.set_gridwidth(680)
        export_sql_input_form.set_custombwidth(125)
        export_sql_input_form.set_fullparms(True)

        export_sql_input_html = ""
        export_sql_input_html = export_sql_input_form.get_html()

        export_sql_heading_html = "<div>" + get_pandas_export_input_title(
            dem.SQLTABLE_EXPORT, dbid) + "</div><br>"

        if (not (exportparms == None)):
            cfg.set_config_value(pandas_export_sqltable_id + "Parms", fparms)

        gridclasses = [
            "dfcleanser-common-grid-header", "dfc-left", "dfc-right"
        ]
        gridhtmls = [export_sql_heading_html, listHtml, export_sql_input_html]

        display_generic_grid("data-import-sql-table-wrapper", gridclasses,
                             gridhtmls)

    if (not (opstatStatus)):
        opstat.set_status(opstatStatus)
        opstat.set_errorMsg(opstatErrormsg)
        display_exception(opstat)
def display_process_subset():
    """
    * -------------------------------------------------------------------------- 
    * function : display current df subset form
    * 
    * parms :
    *  df      -   dataframe to subset from
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    current_step = swsm.get_current_subset_step()
    dftitle = current_step.get_output_subset_df_title()

    subset_df = swsm.get_current_subset_df()

    df_stats_table = get_df_stats_table(dftitle, subset_df)
    df_cols_table = get_column_stats_table(dftitle, subset_df)

    from dfcleanser.common.html_widgets import InputForm
    subset_input_form = InputForm(
        get_subset_run_input_id, get_subset_run_input_idList,
        get_subset_run_input_labelList, get_subset_run_input_typeList,
        get_subset_run_input_placeholderList, get_subset_run_input_jsList,
        get_subset_run_input_reqList)

    selectDicts = []

    colnames = subset_df.columns.tolist()
    cols_name_list = [" "]
    for i in range(len(colnames)):
        cols_name_list.append(colnames[i])

    cnames = {
        "default": cols_name_list[0],
        "list": cols_name_list,
        "callback": "change_run_subset_cols"
    }
    selectDicts.append(cnames)

    subssel = {"default": "Keep", "list": ["Keep", "Drop"]}
    selectDicts.append(subssel)

    savesel = {"default": "True", "list": ["True", "False"]}
    selectDicts.append(savesel)

    get_select_defaults(subset_input_form, get_subset_run_input_form[0],
                        get_subset_run_input_form[1],
                        get_subset_run_input_form[3], selectDicts)

    subset_input_form.set_shortForm(False)
    subset_input_form.set_gridwidth(680)
    subset_input_form.set_custombwidth(90)
    subset_input_form.set_fullparms(True)

    cfg.set_config_value(get_subset_run_input_id + "Parms",
                         [dftitle, "", "", ""])
    cfg.set_config_value(get_subset_run_input_id + "ParmsProtect",
                         [True, False, False, False])

    get_subset_input_html = subset_input_form.get_html()

    get_subset_heading_html = "<div>Process Dataframe Subset</div><br>"

    gridclasses = [
        "dfc-top", "dfc-main", "dfcleanser-common-grid-header", "dfc-bottom"
    ]
    gridhtmls = [
        df_stats_table, df_cols_table, get_subset_heading_html,
        get_subset_input_html
    ]

    print("\n")
    display_generic_grid("sw-utils-subset-run-wrapper", gridclasses, gridhtmls)
Esempio n. 17
0
def display_inspect_cols(parms):
    """
    * -------------------------------------------------------------------------- 
    * function : display the inspect cols option
    * 
    * parms :
    *
    * returns : 
    *  N/A
    * --------------------------------------------------------
    """

    opstat = opStatus()

    clock = RunningClock()
    clock.start()

    try:

        df = cfg.get_current_chapter_df(cfg.DataInspection_ID)
        colnames = df.columns.tolist()

        if (not (parms is None)):
            colname = parms
        else:
            colname = colnames[0]

        cnames = {
            'default': colname,
            'list': colnames,
            "callback": "change_inspect_cols_col",
            "size": 10
        }

        if (is_numeric_col(df, colname)):

            coldetails_form = InputForm(diw.inspect_col_input_id,
                                        diw.inspect_col_input_idList,
                                        diw.inspect_col_input_labelList,
                                        diw.inspect_col_input_typeList,
                                        diw.inspect_col_input_placeholderList,
                                        diw.inspect_col_input_jsList,
                                        diw.inspect_col_input_reqList)
        else:

            coldetails_form = InputForm(
                diw.inspect_nn_col_input_id, diw.inspect_nn_col_input_idList,
                diw.inspect_nn_col_input_labelList,
                diw.inspect_nn_col_input_typeList,
                diw.inspect_nn_col_input_placeholderList,
                diw.inspect_nn_col_input_jsList,
                diw.inspect_nn_col_input_reqList)

        selectDicts = []
        selectDicts.append(cnames)

        get_select_defaults(coldetails_form, diw.inspect_col_input_id,
                            diw.inspect_col_input_idList,
                            diw.inspect_col_input_typeList, selectDicts)

        coldetails_form.set_shortForm(True)
        coldetails_form.set_fullparms(True)

        if (cfg.get_dfc_mode() == cfg.INLINE_MODE):

            coldetails_form.set_gridwidth(360)
            if (is_numeric_col(df, colname)):
                coldetails_form.set_buttonstyle({
                    "font-size": 12,
                    "height": 75,
                    "width": 85,
                    "left-margin": 2
                })
            else:
                coldetails_form.set_buttonstyle({
                    "font-size": 12,
                    "height": 75,
                    "width": 85,
                    "left-margin": 75
                })

        else:

            coldetails_form.set_gridwidth(480)
            if (is_numeric_col(df, colname)):
                coldetails_form.set_buttonstyle({
                    "font-size": 12,
                    "height": 75,
                    "width": 110,
                    "left-margin": 2
                })
            else:
                coldetails_form.set_buttonstyle({
                    "font-size": 12,
                    "height": 75,
                    "width": 110,
                    "left-margin": 110
                })

        coldetails_html = coldetails_form.get_html()

        from dfcleanser.data_cleansing.data_cleansing_widgets import display_col_stats
        col_stats_html = display_col_stats(df, colname, False, True)

        gridclasses = ["dfc-left", "dfc-right"]
        gridhtmls = [col_stats_html, coldetails_html]

        if (cfg.get_dfc_mode() == cfg.INLINE_MODE):
            display_generic_grid("df-inspection-column-data-wrapper",
                                 gridclasses, gridhtmls)
        else:
            display_generic_grid("df-inspection-pop-up-column-data-wrapper",
                                 gridclasses, gridhtmls)

    except Exception as e:
        opstat.store_exception("Error displaying column data\n ", e)

    clock.stop()

    if (not (opstat.get_status())):
        display_exception(opstat)
def display_save_subset(df_title, df, auto=False):
    """
    * -------------------------------------------------------------------------- 
    * function : display current df subset form
    * 
    * parms :
    *  df      -   dataframe to subset from
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    df_stats_table = get_df_stats_table(df_title, df)
    df_cols_table = get_column_stats_table(df_title, df)

    from dfcleanser.common.html_widgets import InputForm
    subset_input_form = InputForm(
        get_subset_save_input_id, get_subset_save_input_idList,
        get_subset_save_input_labelList, get_subset_save_input_typeList,
        get_subset_save_input_placeholderList, get_subset_save_input_jsList,
        get_subset_save_input_reqList)

    subset_input_form.set_shortForm(False)
    subset_input_form.set_gridwidth(680)
    subset_input_form.set_custombwidth(140)
    subset_input_form.set_fullparms(True)

    cfg.set_config_value(get_subset_save_input_id + "Parms",
                         [df_title, "./" + df_title + ".csv", df_title])

    if (auto):
        cfg.set_config_value(get_subset_save_input_id + "ParmsProtect",
                             [False, False, True])
    else:
        cfg.drop_config_value(get_subset_save_input_id + "ParmsProtect")

    get_subset_input_html = subset_input_form.get_html()

    get_subset_heading_html = "<div>Save Dataframe Subset</div><br>"

    gridclasses = [
        "dfc-top", "dfc-main", "dfcleanser-common-grid-header", "dfc-bottom"
    ]
    gridhtmls = [
        df_stats_table, df_cols_table, get_subset_heading_html,
        get_subset_input_html
    ]

    print("\n")
    display_generic_grid("sw-utils-subset-run-wrapper", gridclasses, gridhtmls)
Esempio n. 19
0
def display_funcs():
    """
    * ------------------------------------------------------------------------
    * function : display the dfc funcs start form
    * 
    * parms :
    *
    * -------------------------------------------------------------------------
    """

    list_funcs_input_form = InputForm(
        build_funcs_utility_input_id, build_funcs_utility_input_idList,
        build_funcs_utility_input_labelList,
        build_funcs_utility_input_typeList,
        build_funcs_utility_input_placeholderList,
        build_funcs_utility_input_jsList, build_funcs_utility_input_reqList)

    selectDicts = []

    from dfcleanser.sw_utilities.sw_utility_genfunc_model import get_genfunc_list
    gen_funcs = get_genfunc_list()
    default_func = gen_funcs[0]

    funcssel = {
        "default": default_func,
        "list": gen_funcs,
        "callback": "select_gen_func"
    }
    selectDicts.append(funcssel)

    from dfcleanser.common.common_utils import get_select_defaults

    get_select_defaults(list_funcs_input_form, build_funcs_utility_input_id,
                        build_funcs_utility_input_idList,
                        build_funcs_utility_input_typeList, selectDicts)

    list_funcs_input_form.set_gridwidth(700)
    list_funcs_input_form.set_custombwidth(120)
    list_funcs_input_form.set_fullparms(True)

    from dfcleanser.sw_utilities.sw_utility_genfunc_model import reservedfunctionsmodule

    from dfcleanser.sw_utilities.sw_utility_genfunc_functions import get_generic_function_code
    func_code = get_generic_function_code(default_func)

    cfg.set_config_value(build_funcs_utility_input_id + "Parms",
                         [default_func, reservedfunctionsmodule, func_code])
    cfg.set_config_value(build_funcs_utility_input_id + "ParmsProtect",
                         [False, True, True])

    help_note = "Generic functions help note'"

    from dfcleanser.common.common_utils import get_help_note_html
    list_funcs_notes_html = get_help_note_html(help_note, 100, None, None)

    list_funcs_html = ""
    list_funcs_html = list_funcs_input_form.get_html()

    list_funcs_title_html = "<div>Generic dfc Functions</div><br></br>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-bottom", "dfc-footer"]
    gridhtmls = [list_funcs_title_html, list_funcs_html, list_funcs_notes_html]

    print("\n")
    display_generic_grid("sw-utils-listdict-wrapper", gridclasses, gridhtmls)
def display_saved_subset_sequences():
    """
    * -------------------------------------------------------------------------- 
    * function : display current saved sequences
    * 
    * parms :
    *  df      -   dataframe to subset from
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    from dfcleanser.common.html_widgets import InputForm
    subset_input_form = InputForm(get_subset_sequences_input_id,
                                  get_subset_sequences_input_idList,
                                  get_subset_sequences_input_labelList,
                                  get_subset_sequences_input_typeList,
                                  get_subset_sequences_input_placeholderList,
                                  get_subset_sequences_input_jsList,
                                  get_subset_sequences_input_reqList)

    selectDicts = []

    sequences = swsm.get_sequences_list()

    if (len(sequences) > 0):
        seqdict = {"default": sequences[0], "list": sequences}
    else:
        seqdict = {
            "default": "no saved sequences",
            "list": ["no saved sequences"]
        }

    selectDicts.append(seqdict)

    subsetact = {"default": "Auto Run", "list": ["Auto Run", "Manual Run"]}
    selectDicts.append(subsetact)

    get_select_defaults(subset_input_form, get_subset_sequences_input_form[0],
                        get_subset_sequences_input_form[1],
                        get_subset_sequences_input_form[3], selectDicts)

    subset_input_form.set_shortForm(False)
    subset_input_form.set_gridwidth(680)
    subset_input_form.set_custombwidth(140)
    subset_input_form.set_fullparms(True)

    get_subset_input_html = subset_input_form.get_html()

    get_subset_heading_html = "<div>Run Saved Subset Sequence</div><br>"

    gridclasses = ["dfcleanser-common-grid-header", "dfc-main"]
    gridhtmls = [get_subset_heading_html, get_subset_input_html]

    print("\n")
    display_generic_grid("sw-utils-subset-main-wrapper", gridclasses,
                         gridhtmls)
Esempio n. 21
0
def display_list_maint(keyValue=None, loadfile=None):
    """
    * ------------------------------------------------------------------------
    * function : display the user lists maintenance form
    * 
    * parms :
    *  keyValue   - list name
    *
    * -------------------------------------------------------------------------
    """
    opstat = opStatus()

    if (loadfile is None):

        list_maint_input_form = InputForm(
            maint_list_utility_input_id, maint_list_utility_input_idList,
            maint_list_utility_input_labelList,
            maint_list_utility_input_typeList,
            maint_list_utility_input_placeholderList,
            maint_list_utility_input_jsList, maint_list_utility_input_reqList)

    else:

        list_maint_input_form = InputForm(
            maint_list_file_utility_input_id,
            maint_list_file_utility_input_idList,
            maint_list_file_utility_input_labelList,
            maint_list_file_utility_input_typeList,
            maint_list_file_utility_input_placeholderList,
            maint_list_file_utility_input_jsList,
            maint_list_file_utility_input_reqList)

    selectDicts = []

    from dfcleanser.sw_utilities.sw_utility_model import get_lists_names, USER_CREATED
    list_names = get_lists_names(USER_CREATED)

    #print("list_names",list_names)
    if (not (list_names is None)):

        if (keyValue is None):
            def_list = list_names[0]
        else:
            def_list = keyValue

        sellist = swum.get_List(def_list, USER_CREATED)

        dsstr = "["
        for i in range(len(sellist)):
            dsstr = dsstr + str(sellist[i])
            if (i == (len(sellist) - 1)):
                dsstr = dsstr + "]"
            else:
                dsstr = dsstr + ","

    else:
        list_names = ["No User lists defined"]
        def_list = "No User lists defined"

        sellist = "User defined list"

    listssel = {
        "default": def_list,
        "list": list_names,
        "callback": "select_list"
    }
    selectDicts.append(listssel)

    from dfcleanser.common.common_utils import get_select_defaults

    get_select_defaults(list_maint_input_form, maint_list_utility_input_id,
                        maint_list_utility_input_idList,
                        maint_list_utility_input_typeList, selectDicts)

    list_maint_input_form.set_gridwidth(700)

    if (loadfile is None):
        list_maint_input_form.set_buttonstyle({
            "font-size": 13,
            "height": 75,
            "width": 90,
            "left-margin": 20
        })
    else:
        list_maint_input_form.set_buttonstyle({
            "font-size": 13,
            "height": 75,
            "width": 90,
            "left-margin": 205
        })

    list_maint_input_form.set_fullparms(True)

    cfg.drop_config_value(maint_list_utility_input_id + "Parms")
    cfg.drop_config_value(maint_list_utility_input_id + "ParmsProtect")

    if (not (loadfile is None)):

        import json

        from dfcleanser.common.common_utils import does_file_exist
        if (does_file_exist(loadfile)):

            try:
                with open(loadfile, 'r') as ds_file:
                    ds = json.load(ds_file)
                    ds_file.close()

                dsstr = "["
                for i in range(len(ds)):
                    dsstr = dsstr + str(ds[i])
                    if (i == (len(ds) - 1)):
                        dsstr = dsstr + "]"
                    else:
                        dsstr = dsstr + ","

            except Exception as e:
                opstat.set_status(False)
                opstat.set_errorMsg("Error processing user file to load" +
                                    loadfile)
                opstat.set_exception(e)

        else:
            opstat.set_status(False)
            opstat.set_errorMsg("invalid user file to load" + loadfile)

    if (opstat.get_status()):

        if (loadfile is None):
            cfg.set_config_value(maint_list_utility_input_id + "Parms",
                                 [def_list, "", dsstr, ""])
        else:
            cfg.set_config_value(maint_list_utility_input_id + "Parms",
                                 [def_list, "", dsstr, loadfile])
            cfg.set_config_value(maint_list_utility_input_id + "ParmsProtect",
                                 [True, False, True, True])

        help_note = "To add a user list enter parms and values above and click on 'Add User List'.</br>To update the current list change values and click on 'Update User List'"

        from dfcleanser.common.common_utils import get_help_note_html
        list_maint_notes_html = get_help_note_html(help_note, 80, 75, None)

        list_maint_html = ""
        list_maint_html = list_maint_input_form.get_html()

        list_maint_title_html = "<div>User Lists</div><br></br>"

        gridclasses = [
            "dfcleanser-common-grid-header", "dfc-bottom", "dfc-footer"
        ]
        gridhtmls = [
            list_maint_title_html, list_maint_html, list_maint_notes_html
        ]
        #print(list_maint_html)
        #print(list_maint_notes_html)

        print("\n")
        display_generic_grid("sw-utils-listdict-wrapper", gridclasses,
                             gridhtmls)

    else:

        display_exception(opstat)
        add_error_to_log("[Get User Dict from File] " + loadfile +
                         str(sys.exc_info()[0].__name__))
def get_pandas_export_input_form(exid):
    """
    * -------------------------------------------------------------------------- 
    * function : get pandas export input form
    * 
    * parms :
    *   exid    -   export type
    *
    * returns : N/A
    * --------------------------------------------------------
    """

    selectDicts = []

    if (exid == dem.CSV_EXPORT):
        export_form = InputForm(pandas_export_csv_id, pandas_export_csv_idList,
                                pandas_export_csv_labelList,
                                pandas_export_csv_typeList,
                                pandas_export_csv_placeholderList,
                                pandas_export_csv_jsList,
                                pandas_export_csv_reqList)

        dataframes = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID)
        selectDicts.append(dataframes)

        boolFlag = {"default": "True", "list": ["True", "False"]}
        selectDicts.append(boolFlag)
        selectDicts.append(boolFlag)

        get_select_defaults(export_form, pandas_export_csv_id,
                            pandas_export_csv_idList,
                            pandas_export_csv_typeList, selectDicts)

    elif (exid == dem.EXCEL_EXPORT):
        export_form = InputForm(
            pandas_export_excel_id, pandas_export_excel_idList,
            pandas_export_excel_labelList, pandas_export_excel_typeList,
            pandas_export_excel_placeholderList, pandas_export_excel_jsList,
            pandas_export_excel_reqList)

        dataframes = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID)
        selectDicts.append(dataframes)

        boolFlag = {"default": "True", "list": ["True", "False"]}
        selectDicts.append(boolFlag)
        selectDicts.append(boolFlag)

        get_select_defaults(export_form, pandas_export_excel_id,
                            pandas_export_excel_idList,
                            pandas_export_excel_typeList, selectDicts)

    elif (exid == dem.JSON_EXPORT):
        export_form = InputForm(
            pandas_export_json_id, pandas_export_json_idList,
            pandas_export_json_labelList, pandas_export_json_typeList,
            pandas_export_json_placeholderList, pandas_export_json_jsList,
            pandas_export_json_reqList)

        dataframes = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID)
        selectDicts.append(dataframes)

        get_select_defaults(export_form, pandas_export_json_id,
                            pandas_export_json_idList,
                            pandas_export_json_typeList, selectDicts)

    elif (exid == dem.HTML_EXPORT):
        export_form = InputForm(
            pandas_export_html_id, pandas_export_html_idList,
            pandas_export_html_labelList, pandas_export_html_typeList,
            pandas_export_html_placeholderList, pandas_export_html_jsList,
            pandas_export_html_reqList)

        dataframes = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID)
        selectDicts.append(dataframes)

        boolFlag = {"default": "True", "list": ["True", "False"]}
        selectDicts.append(boolFlag)
        selectDicts.append(boolFlag)

        get_select_defaults(export_form, pandas_export_html_id,
                            pandas_export_html_idList,
                            pandas_export_html_typeList, selectDicts)

    elif (exid == dem.SQLTABLE_EXPORT):
        export_form = InputForm(
            pandas_export_sqltable_id, pandas_export_sqltable_idList,
            pandas_export_sqltable_labelList, pandas_export_sqltable_typeList,
            pandas_export_sqltable_placeholderList,
            pandas_export_sqltable_jsList, pandas_export_sqltable_reqList)

        dataframes = cfg.get_dfc_dataframes_select_list(cfg.DataExport_ID)
        selectDicts.append(dataframes)

        ifexists = {"default": "fail", "list": ["fail", "replace", "append"]}
        selectDicts.append(ifexists)

        index = {"default": "True", "list": ["True", "False"]}
        selectDicts.append(index)

        get_select_defaults(export_form, pandas_export_sqltable_id,
                            pandas_export_sqltable_idList,
                            pandas_export_sqltable_typeList, selectDicts)

    return (export_form)