# -*- coding: utf-8 -*-
"""
Created on Wed Nov 24 11:32:43 2021

@author: russ
"""
import pprint
import clip_utils



import sys
sys.path.append( r"D:\Russ\0000\python00\python3\_examples"  )
import ex_helpers

# ----------------------------------------
def ex_template():
    ex_name  = "ex_template"
    print( f"""{ex_helpers.begin_example( ex_name )} template showing use of begin_example, end-example  ===============
    """ )

    print( "thats all folks" )

    ex_helpers.end_example( ex_name )

#ex_template()

# ------------------------------------------
def test_allign_eq_signs(   ):
    """
    what it says, read


    """

    a_test_string  =  \
"""        s          = 1 + 7
        ssss           =  1 + 7
        aaaaa = "a long walk in the woods"
        bbb = "a long walk in the woods"  # with comment
        another   = 333      # with comment
        two equal =  and =
        equal sign hidden    # = sign after comment
      different = 22
      no equal sign here
      or here either
"""
    print( a_test_string )
    ret      = clip_utils.allign_eq_signs( a_test_string )

    print( "================= allign returns =>" )
    pprint.pprint( ret )

    a_string   = clip_utils.list_to_string_lines( ret )
    print( a_string )

test_allign_eq_signs()



# ------------------------------------------
def test_list_to_string_lines(  ):
    ex_name  = "test_list_to_string_lines"
    print( f"""{ex_helpers.begin_example( ex_name )}    ===============
    """ )
    a_list     = [ "aaa", "vvv", "ccc", "d", "what the heck", "was blank", ]
    a_string   = clip_utils.list_to_string_lines( a_list )
    print( a_string )

    ex_helpers.end_example( ex_name )

#test_list_to_string_lines()


# ----------------------------------------
def test_clean_string_to_list(  ):
    """
    in_text,
    delete_tailing_spaces  = True,
    delete_comments        = False,
    delete_blank_lines     = False,
    """

    in_text    = """
    for ix, i_line in enumerate(lines1):

        # alternate odd even
        if odd:
            part_b = i_line    # trail comment
            odd    = False   # trail comment  # trail comment
        else:
            # if first line does not start with http or https
            # we will return False
            if ix == 1:  # 2 in a way fix this?
                #  add www,  use in to find a beinning
                #  https://snippets.readthedocs.org/en/latest/
                #  012345
                #  !! need to check for both http and htts
                # !! find and use is_url function
                prefix = i_line[0:4]
                if prefix != "http":
                    prefix = i_line[0:5]
                    if prefix != "https":
                        self.logger.info("prefix " + prefix)
                        return (False, "not http or https", "")




    """

    clean_string, cnt_deleted   = clean_string_to_list(in_text)
    #pprint.pprint( f">>>>{clean_string_to_list(in_text)}<<<<")

    pprint.pprint( clean_string )

    clean_string, cnt_deleted   = clean_string_to_list(in_text, delete_comments = True, )
    pprint.pprint( clean_string )

    clean_string, cnt_deleted   = clean_string_to_list(in_text,
                                                       delete_comments     = True,
                                                       delete_blank_lines  = True,)
    print( f"cnt_deleted cnt_deleted")
    pprint.pprint( clean_string )


# ----------------------------------------
#test_clean_string_to_list(  )



# # ------------------- fix !!
# def test_trans_search_replace():  now name_to_literal
#     """
#     new april 2021


#     """

#     import parameters
#     parms   = parameters.Parameters()
#     test_object       = CmdProcessor(   )

#     input_list   = ["abc", "what", "tab", "newline", "space"]
#     for a_string in input_list:

#         ret      = test_object.trans_search_replace( a_string )
#         print( f"input >{a_string}< ->{ret}<" )



