Exemplo n.º 1
0
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Tables"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\Tables"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            if os.path.isfile(file_name):
                fh.file_str_replace(file_name, 'GO', '')
                fh.file_str_replace(file_name, 'go', '')
                pattern = re.compile(
                    r"(?<=dbo.).+?(?=.table.sql)")  # 取两个字符串中间的字符
                table_name = pattern.findall(f)[0]
                header = '''IF NOT EXISTS(SELECT TOP 1 1 FROM sys.tables t WITH(NOLOCK)
WHERE SCHEMA_NAME(schema_id) = 'DBO' AND OBJECT_NAME(object_id) =\'''' + table_name + '''\' AND type = 'U')
BEGIN
    '''

                encoding_name = fh.get_file_encoding(file_name)
                context = fh.get_file_context(file_name, encoding_name)
                # print(context)
                tail = '''            
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Table ''' + table_name + '''...')            
END
    GO'''
                new_context = header + context + tail
                new_file_name = os.path.join(tgt_dir, f)
                fh.write_file(new_file_name, new_context, encoding='utf-8')
Exemplo n.º 2
0
def merge_scripts_in_order(script_list, parent_folder, w_file):
    for h_file in script_list:
        file_path = search_file_in_folder(h_file, parent_folder)
        if file_path is not None and os.path.isfile(file_path):
            context = fh.read_file(file_path)
            context = "\r\n" + context
            fh.write_file(w_file, context, 'utf-8', 'a')
Exemplo n.º 3
0
def merge_views(script_list, folder, w_file):
    merge_scripts_in_order(script_list, folder, w_file)  # merged first
    files = os.listdir(folder)
    for file in files:
        if file in script_list:
            continue  # this kind of file has been merged
        f = os.path.join(folder, file)
        if os.path.isfile(f):
            context = fh.read_file(f)
            context = "\r\n" + context
            fh.write_file(w_file, context, 'utf-8', 'a')
Exemplo n.º 4
0
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Tables\Keys"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\ForeignKeys"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            # only read pkey files
            if os.path.isfile(file_name) and re.search(r'fkey', f) is not None:
                try:
                    fh.file_str_replace(file_name, 'GO', '')
                    fh.file_str_replace(file_name, 'go', '')
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name,encoding_name)
                    ex_table = re.compile(r"\[.*?\]+")
                    l = ex_table.findall(context)
                    if l[0].replace('[','').replace(']','') != 'dbo':
                        print(1/0)
                    table_name = l[1].replace('[','').replace(']','')
                    fk_name = l[2].replace('[','').replace(']','')
                    # if re.search('FK_' , fk_name) is None:
                    #     fh.check_obj_name(fk_name, f)
                    header = '''IF NOT EXISTS
(
    SELECT TOP 1 1
    FROM sys.foreign_keys fk
    WHERE OBJECT_ID = OBJECT_ID(N\'''' + fk_name + '''\')
          AND fk.parent_object_id = OBJECT_ID(N\'''' + table_name + '''\')
)
BEGIN
'''
                    tail = '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Foreign Key '''+ fk_name+'''...')                      
END;
GO
'''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')

                    # print('{} {} {}'.format(f,table_name,pk_name))
                except:
                    print(f)
Exemplo n.º 5
0
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Programmability\Stored Procedures"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\StoredProcedures"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            if f == "dbo.UserStory59.proc.sql": # except this script
                continue
            file_name = os.path.join(src_dir, f)
            # only read trigger files
            if os.path.isfile(file_name):
                try:
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name,encoding_name)
                    ex = re.compile(r"\[.*?\]+")
                    l = ex.findall(context)
                    sp_name = l[1].replace('[', '').replace(']', '')
                    """debug code below 3 rows"""
                    # fh.check_obj_name(sp_name, f)
                    header = '''IF EXISTS(SELECT TOP 1 1 FROM sys.procedures i with(nolock) 
              WHERE i.name = \'''' + sp_name + '''\')
BEGIN
DROP PROCEDURE ''' + sp_name + '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Dropped Stored Procedure '''+sp_name+'''...')
END;
GO
    '''
                    tail = '''
GO
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Stored Procedure '''+sp_name+'''...')               
GO
    '''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')
                    # print('{} {}'.format(f,trigger_name))
                except:
                    print(f)
                    pass
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Programmability\Functions"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\\UserFunctions"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            # only read trigger files
            if os.path.isfile(file_name):
                try:
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name,encoding_name)
                    ex = re.compile(r"\[.*?\]+")
                    l = ex.findall(context)
                    function_name = l[1].replace('[', '').replace(']', '')
                    """debug code below 3 rows"""
                    fh.check_obj_name(function_name, f)
                    header = '''
IF OBJECT_ID(\'''' + function_name + '''\') IS NOT NULL
BEGIN
DROP FUNCTION ''' + function_name + '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Dropped Function '''+ function_name+'''...')
END;
GO
    '''
                    tail = '''
GO
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Function '''+ function_name+'''...')               
GO
    '''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')
                    # print('{} {}'.format(f,trigger_name))
                except:
                    print(f)
                    pass
Exemplo n.º 7
0
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Tables\Indexes"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\Indexes"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            # only read ukey files
            if re.search(r'index', f) is not None:
                try:
                    fh.file_str_replace(file_name, 'GO', '')
                    fh.file_str_replace(file_name, 'go', '')
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name, encoding_name)
                    ex = re.compile(r"\[.*?\]+")
                    l = ex.findall(context)
                    idx_name = l[0].replace('[', '').replace(']', '')
                    if idx_name == 'dbo':
                        print(f)
                    fh.check_obj_name(idx_name, f)
                    header = '''IF NOT EXISTS(SELECT TOP 1 1 FROM sys.indexes i with(nolock) 
                  WHERE i.name = \'''' + idx_name + '''\')
BEGIN
'''
                    tail = '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Index ''' + idx_name + '''...')                               
END
GO
'''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')

                    # print('{} {} {}'.format(f,table_name,pk_name))
                except:
                    print(f)
Exemplo n.º 8
0
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Tables\Keys"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\PrimaryKeys"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            # only read pkey files
            if os.path.isfile(file_name) and re.search(r'pkey', f) is not None:
                try:
                    fh.file_str_replace(file_name, 'GO', '')
                    fh.file_str_replace(file_name, 'go', '')
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name, encoding_name)
                    ex_table = re.compile(r"\[.*?\]+")
                    l = ex_table.findall(context)
                    table_name = l[1].replace('[', '').replace(']', '')
                    pk_name = l[2].replace('[', '').replace(']', '')
                    fh.check_obj_name(pk_name, f)
                    header = '''IF NOT EXISTS(SELECT TOP 1 1 FROM sys.tables t WITH(NOLOCK) 
JOIN sys.indexes i ON t.object_id = i.object_id AND i.is_primary_key = 1
 WHERE SCHEMA_NAME(t.schema_id) = 'DBO' AND OBJECT_NAME(t.object_id) =\'''' + table_name + '''\' AND t.type = 'U')
BEGIN
    '''
                    tail = '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Primary Key ''' + pk_name + '''\',' ON Table ''' + table_name + '''...')
END
GO
    '''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')

                    # print('{} {} {}'.format(f,table_name,pk_name))
                except:
                    print(f)
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Tables\Triggers"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\Triggers"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            # only read trigger files
            if os.path.isfile(file_name) and re.search(r'trigger',
                                                       f) is not None:
                try:
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name, encoding_name)
                    ex = re.compile(r"\[.*?\]+")
                    l = ex.findall(context)
                    trigger_name = l[1].replace('[', '').replace(']', '')
                    fh.check_obj_name(trigger_name, f)
                    header = '''IF EXISTS(SELECT * FROM sys.triggers WHERE name =\'''' + trigger_name + '''\')
BEGIN
DROP TRIGGER ''' + trigger_name + '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Dropped Trigger ''' + trigger_name + '''...')
END;
GO
    '''
                    tail = '''
GO                    
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Trigger ''' + trigger_name + '''...')
GO
    '''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')
                    # print('{} {}'.format(f,trigger_name))
                except:
                    print(f)
Exemplo n.º 10
0
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Tables\Keys"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\\UniqueKeys"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            # only read ukey files
            if os.path.isfile(file_name) and re.search(r'ukey', f) is not None:
                try:
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name, encoding_name)
                    ex_table = re.compile(r"\[.*?\]+")
                    l = ex_table.findall(context)
                    if l[0].replace('[', '').replace(']', '') != 'dbo':
                        print(1 / 0)
                    table_name = l[1].replace('[', '').replace(']', '')
                    uk_name = l[2].replace('[', '').replace(']', '')
                    fh.check_obj_name(uk_name, f)
                    header = '''IF NOT EXISTS(SELECT * FROM sys.indexes i WHERE i.name =\'''' + uk_name + '''\')
BEGIN 
    '''
                    tail = '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Unique Key ''' + uk_name + '''...')                
END;
GO
    '''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')

                    # print('{} {} {}'.format(f,table_name,uk_name))
                except:
                    print(f)
def run():
    # source script location
    src_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\AspiraFocusDatabaseCodes\Databases\CA\Schema Objects\Tables\Constraints"
    # target script location
    tgt_dir = "E:\Work-RAOutdoors\CA\AspiraFocusDB\\UniversalDatabasesCodes\Databases\Constraints"

    if os.path.exists(src_dir) and os.path.exists(tgt_dir):
        files = os.listdir(src_dir)
        for f in files:
            file_name = os.path.join(src_dir, f)
            # only read trigger files
            if os.path.isfile(file_name):
                try:
                    fh.file_str_replace(file_name, 'GO', '')
                    fh.file_str_replace(file_name, 'go', '')
                    encoding_name = fh.get_file_encoding(file_name)
                    context = fh.get_file_context(file_name, encoding_name)
                    ex = re.compile(r"\[.*?\]+")
                    l = ex.findall(context)
                    constraint_name = l[2].replace('[', '').replace(']', '')
                    # fh.check_obj_name(constraint_name, f)
                    header = '''IF (OBJECT_ID(\'''' + constraint_name + '''\')) IS NULL
BEGIN
'''
                    tail = '''
PRINT concat('[INFO] ', convert(varchar,getdate(),120), ' - Created Constraint ''' + constraint_name + '''...')                             
END;
GO
'''
                    new_context = header + context + tail

                    new_file_name = os.path.join(tgt_dir, f)
                    fh.write_file(new_file_name, new_context, 'utf-8')
                    # print('{} {}'.format(f, constraint_name))
                except:
                    print(f)
Exemplo n.º 12
0
def kill(task_id):
    todos = [todo for todo in read_file() if todo['status'] == 0]
    todos[int(task_id) - 1]['status'] = 1
    write_file(todos)
    print 'cool!\nTasks left:'
    show(todos)
Exemplo n.º 13
0
def add(task_detail):
    todos = read_file()
    todos.append({'task_detail': task_detail, 'status': 0})
    write_file(todos)
    print 'got it.'
Exemplo n.º 14
0
def kill(task_id):
    todos = not_completed_todos()
    todos[int(task_id) - 1]['status'] = 1
    write_file(todos + completed_todos())
    print 'cool!\nTasks left:'
    show()
Exemplo n.º 15
0
def merge_all_scripts():
    # absolute path
    trunk_dir = root_dir + '\\UniversalDatabasesCodes\\Databases'
    child_folders = ('Databases', 'Tables', 'PrimaryKeys', 'ForeignKeys',
                     'Indexes', 'Enums', r"UserDefinedDataTypes",
                     'SpecialScripts', r'UserFunctions', 'Views',
                     'StoredProcedures', 'Triggers', 'Constraints',
                     r'UniqueKeys')
    script_name = 'DB_Deployment_v1.0.0.sql'

    view_list = [
        "dbo.adhoc_Phone.view.sql", "dbo.adhoc_Address.view.sql",
        "dbo.adhoc_Customer.view.sql",
        "dbo.vw_AnnualIssuance_CustomerMailing.view.sql"
    ]
    moved_files = [
        trunk_dir + '\\UserFunctions\\dbo.udf_GetCustomerName.function.sql',
        trunk_dir +
        '\\Views\\dbo.vw_ControlledInventory_OutletStatusCount.view.sql',
        trunk_dir + '\\Views\\dbo.vw_ConfigValueComplete_Effective.view.sql',
        trunk_dir + '\\Views\\dbo.adhoc_license.view.sql',
        trunk_dir + '\\Views\\dbo.vw_CurrentCustomerVesselName.view.sql',
        trunk_dir + '\\Views\\dbo.vw_CustomerVesselAllOwnership.view.sql',
        trunk_dir + '\\Views\\dbo.vw_CustomerAddress.view.sql',
        trunk_dir + '\\Views\\dbo.vw_StockOnHand.view.sql',
        trunk_dir + '\\Views\\dbo.vw_CustomerVesselCurrentOwnership.view.sql',
        trunk_dir + '\\Views\\dbo.vw_LEPermitRelatedCustomer.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_LifetimeAnnualIssuanceCustomerSearch_Live.view.sql',
        trunk_dir + '\\Views\\dbo.Diag_ItemFeeDist_CompleteTotals.view.sql',
        trunk_dir + '\\Views\\dbo.vw_ActiveAddress.view.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_GetCustomerIdentity.function.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_CustomerBusiness.view.sql',
        trunk_dir + '\\Views\\dbo.vw_AnnualIssuance_CustomerPurchase.view.sql',
        trunk_dir + '\\Views\\dbo.vw_Item_LifetimeEnablingItem.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_AnnualIssuance_CustomerHasEnablingItem.view.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_Search_LicenseReportAnswerGroup_ForDataExtracts.function.sql',
        trunk_dir + '\\UserFunctions\\dbo.udf_Renewal_Customers.function.sql',
        trunk_dir +
        '\\Views\\dbo.vw_rpt_CustomerVesselOwnershipCurrent.view.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_Search_Renewal_Customers.function.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_GetHighestPriorityDocumentTitleByDocumentID.function.sql',
        trunk_dir + '\\UserFunctions\\dbo.udf_Renewal_Items.function.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_Search_CustomerSimple.function.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_PreviouslyReportedCount.function.sql',
        trunk_dir + '\\UserFunctions\\dbo.udf_RoundToTheNearest.function.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_GetGlobalDistribution.function.sql',
        trunk_dir + '\\UserFunctions\\dbo.udf_CatalogAllFees.function.sql',
        trunk_dir + '\\Views\\dbo.vw_ItemSalesFee_All.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_CustomerVesselHomePortVesselPortCurrent.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_AnnualIssuance_PurchaseTotalByPackage.view.sql',
        trunk_dir + '\\Views\\dbo.vw_HuntDrawGroup.view.sql',
        trunk_dir + '\\Views\\dbo.vw_MasterHuntType_Complete.view.sql',
        trunk_dir + '\\Views\\dbo.vw_DrawConfig_Complete.view.sql',
        trunk_dir + '\\Views\\dbo.vw_HuntTypeLicenseYear_Complete.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_FulfillmentMostRecentDocumentFulfillmentAction.view.sql',
        trunk_dir + '\\Views\\dbo.vw_transactiondetail.view.sql',
        trunk_dir + '\\Views\\dbo.vw_LEPermitTypeEx.view.sql',
        trunk_dir + '\\Views\\dbo.vw_LEPermitEx.view.sql',
        trunk_dir + '\\Views\\dbo.vw_LEPermitAnnualDesignationEx.view.sql',
        trunk_dir + '\\Views\\dbo.vw_LEPermitHerringPlatoonSpecial.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_LEPermitHerringPlatoonDesignationInfo.view.sql',
        trunk_dir + '\\Views\\dbo.vw_LEPermitTemporaryTransferEx.view.sql',
        trunk_dir + '\\Views\\dbo.vw_LEPermitHerringSquareView.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_LifetimeAnnualIssuanceSummary_LivePackageCustomerList.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_rpt_CustomerActiveAddressReturnPreferred.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_VesselCustomersOnly.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_CustomerVesselOwnership.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_rpt_CustomerVesselHomePortVesselPortCurrent.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_HerringAreaPlatoon.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_LEPermitAnnualDesignation.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_rpt_LEPermitLEPermitAnnualDesignationCurrent.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_LEPermitTemporaryTransfer.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_LEPermitType.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_rpt_CustomerVesselDocumentationCurrent.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_rpt_CustomerVesselCurrentOwnershipDocumentationHomePort.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_AnnualIssuance_JobResultSubTotals.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_AnnualIssuance_JobResultTotalByMailing.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_HuntApplicationParticipants.view.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_CustomerVesselDocumentation.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_LifetimeAnnualIssuanceCustomerSearch_PostIssuance.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_CustomerUnifiedNameAndIdentities.view.sql',
        trunk_dir + '\\Views\\dbo.vw_SLMSParticipantInfo.view.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_Search_SPFalconDispositionHistory.function.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_Config_GetValueByKey_Effective.function.sql',
        trunk_dir + '\\Views\\dbo.vw_SLMSLettersConfigurationValues.view.sql',
        trunk_dir + '\\Views\\dbo.Diag_ItemFeeDist_FixedTotals.view.sql',
        trunk_dir +
        '\\Views\\dbo.vw_rpt_CustomerVesselHomePortVesselPort.view.sql',
        trunk_dir + '\\Views\\dbo.vw_CustomerOfficalDocument.view.sql',
        trunk_dir + '\\UserFunctions\\dbo.udf_ConvertHeight.function.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_GetCustomerIdentityForLicense.function.sql',
        trunk_dir +
        '\\UserFunctions\\dbo.udf_GetCustomerDisability.function.sql',
        trunk_dir + '\\Views\\dbo.vw_rpt_CustomerIndividual.view.sql',
        trunk_dir + '\\Views\\dbo.Diag_ItemFeeDist_PercentageTotals.view.sql',
        trunk_dir + '\\Views\\dbo.vw_CustomerActiveID.view.sql',
        trunk_dir + '\\Views\\dbo.Diag_ItemFeeDist_UnallocatedTotals.view.sql',
    ]
    enum_list = get_enums(trunk_dir + '\\Views')
    file_loc = trunk_dir + '\\Enums'
    fh.clear_folder(file_loc)
    fh.move_files(enum_list, file_loc)
    if os.path.exists(trunk_dir):
        script_file = os.path.join(trunk_dir, script_name)
        fh.write_file(script_file, '')
        for folder in child_folders:
            abs_path = os.path.join(trunk_dir, folder)
            if folder == 'SpecialScripts':
                merge_special_scripts(moved_files, script_file)
                file_loc = trunk_dir + '\\SpecialScripts'
                fh.clear_folder(file_loc)
                fh.move_files(moved_files, file_loc)
                continue
            if folder == 'Views':
                merge_views(view_list, abs_path, script_file)
                continue
            if os.path.exists(abs_path):
                files = os.listdir(abs_path)
                for file in files:
                    f = os.path.join(abs_path, file)
                    if os.path.isfile(f):
                        context = fh.read_file(f)
                        context = "\r\n" + context
                        fh.write_file(script_file, context, 'utf-8', 'a')
Exemplo n.º 16
0
def merge_special_scripts(script_list, w_file):
    for f in script_list:
        if os.path.isfile(f):
            context = fh.read_file(f)
            context = "\r\n" + context
            fh.write_file(w_file, context, 'utf-8', 'a')