#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0

    Retrieving a specific path from a mapping file


    Hello

    I have a mapping file (named mapping.txt) who's contents are as follows

    dir1\folder1\file1 ws1\fw1\file1.1
    dir2\folder2\file2 ws2\fw2\file2.1
    dir3\folder3\file3 ws3\fw3\file3.1
    dir4\folder4\file4 ws4\fw4\file4.1

    According to the arguments passed via CLI, say for example

    python main.py file3.1

    the script should open this mapping.txt file check if the file is available as file3.1 and retrieve the output as (path and the filename) dir3\folder3\file3 in order to perform an operation on dir3\folder3\file3.

    Please do help me as this is eating my head a lot and is kinda complicated (may be for me).

    Thanks
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    Code:
    '''
    This file is named p.py.
    
    The examples run with file mapping.txt containing:
    dir1\folder1\file1 ws1\fw1\file1.1
    dir2\folder2\file2 ws2\fw2\file2.1
    dir3\folder3\file3 ws3\fw3\file3.1
    dir4\folder4\file4 ws4\fw4\file4.1
    
    
    Unix command
    $ python p.py 3.1 1.1
    {'1.1': 'dir1\\folder1\\file1', '3.1': 'dir3\\folder3\\file3'}
    
    
    $ python p.py 1
    raises an error
    '''
    
    import sys
    import pprint
    
    
    # examine the command line arguments
    print('The command line argument array is %s\n'%str(sys.argv))
    
    
    # read the map file
    MAP_FILE_NAME = 'mapping.txt'
    
    with open(MAP_FILE_NAME,'r') as inf:
        MAP = inf.readlines()
    
    
    # convert the map file to a python mapping type.  A dictionary.
    MAP_DICT = dict()
    for LINE in MAP:
        FIELDS = LINE.strip().split()
        MAP_DICT[FIELDS[1]] = FIELDS[0]
    
    
    # examine the map
    print('The mapping dictionary:')
    pprint.pprint(MAP_DICT)
    print('')
    
    
    # construct a dictionary with matching files based on the command line
    RESULT = dict()
    for NAME in sys.argv[1:]:
        for KEY in MAP_DICT:
            if KEY.endswith(NAME):
                if NAME in RESULT:
                    raise ValueError('Confilicting entries match %s.'%NAME)
                RESULT[NAME] = MAP_DICT[KEY]
    
    
    # display the result
    print('The correspondence:')
    pprint.pprint(RESULT)
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Thanks a lot.

    It does work for the example you have provided.

    But it doesn't seem to be working with the mapping file I actually have.

    If i could attach a file over here i could send you the mapping file.

    The error I'm getting is

    Traceback (most recent call last):
    File "p.py", line 36, in <module>
    raise ValueError('Confilicting entries match %s.'%NAME)
    ValueError: Confilicting entries match AnalysisWnd.h.


    below are few of my entries from my mapping file.

    epcominterfaces/AnalysisWnd.h DELE5Interfaces/ProtectedInterfaces/AnalysisWnd.h
    epcominterfaces/BaseDataObj.h DELE5Interfaces/ProtectedInterfaces/BaseDataObj.h
    epcominterfaces/BrowserCompAccessBase.h DELE5Interfaces/ProtectedInterfaces/BrowserCompAccessBase.h
    epcominterfaces/DPEStreamFile.h DELE5Interfaces/ProtectedInterfaces/DPEStreamFile.h
    epcominterfaces/DPFFrame.h DELE5Interfaces/ProtectedInterfaces/DPFFrame.h
    epcominterfaces/DPFPrintData.h DELE5Interfaces/ProtectedInterfaces/DPFPrintData.h
    epcominterfaces/DataUpdate.h DELE5Interfaces/ProtectedInterfaces/DataUpdate.h
    epcominterfaces/EPCSObjectCache.h DELE5Interfaces/ProtectedInterfaces/EPCSObjectCache.h
    epcominterfaces/EPClientUpdate.h DELE5Interfaces/ProtectedInterfaces/EPClientUpdate.h
    epcominterfaces/EPFetchAttributes.h DELE5Interfaces/ProtectedInterfaces/EPFetchAttributes.h
    epcominterfaces/EPGenericAccess.h DELE5Interfaces/ProtectedInterfaces/EPGenericAccess.h
    epcominterfaces/EPGenericAccessStructures.h DELE5Interfaces/ProtectedInterfaces/EPGenericAccessStructures.h
    epcominterfaces/EPGenericServices.h DELE5Interfaces/ProtectedInterfaces/EPGenericServices.h
    epcominterfaces/EPObjectEditor.h DELE5Interfaces/ProtectedInterfaces/EPObjectEditor.h
    epcominterfaces/EPPLMConfiguration.h DELE5Interfaces/ProtectedInterfaces/EPPLMConfiguration.h
    epcominterfaces/EPResourceAgent.h DELE5Interfaces/ProtectedInterfaces/EPResourceAgent.h
    epcominterfaces/Graphicdata.h DELE5Interfaces/ProtectedInterfaces/Graphicdata.h
    epcominterfaces/IAutomationErgoExplorerManager.h DELE5Interfaces/ProtectedInterfaces/IAutomationErgoExplorerManager.h
    epcominterfaces/IAutomationExplorerView.h DELE5Interfaces/ProtectedInterfaces/IAutomationExplorerView.h
    epcominterfaces/IEPBrowserTreeExpanderStarter.h DELE5Interfaces/ProtectedInterfaces/IEPBrowserTreeExpanderStarter.h
    epcominterfaces/IEPVBAProcess.h DELE5Interfaces/ProtectedInterfaces/IEPVBAProcess.h
    epcominterfaces/IScriptingHostTimeAnalysisCheck.h DELE5Interfaces/ProtectedInterfaces/IScriptingHostTimeAnalysisCheck.h
    epcominterfaces/ObjectQuery.h DELE5Interfaces/ProtectedInterfaces/ObjectQuery.h
    epcominterfaces/ResourceAgent.h DELE5Interfaces/ProtectedInterfaces/ResourceAgent.h
    epcominterfaces/SupportScriptActions.h DELE5Interfaces/ProtectedInterfaces/SupportScriptActions.h
    epcominterfaces/Transaction.h DELE5Interfaces/ProtectedInterfaces/Transaction.h
    epcominterfaces/blob.h DELE5Interfaces/ProtectedInterfaces/blob.h
    epcominterfaces/callback.h DELE5Interfaces/ProtectedInterfaces/callback.h
    epcominterfaces/configfactory.h DELE5Interfaces/ProtectedInterfaces/configfactory.h
    epcominterfaces/customizationenums.h DELE5Interfaces/ProtectedInterfaces/customizationenums.h
    epcominterfaces/datalock.h DELE5Interfaces/ProtectedInterfaces/datalock.h
    epcominterfaces/dataupdatedefines.h DELE5Interfaces/ProtectedInterfaces/dataupdatedefines.h
    epcominterfaces/dbeditor.h DELE5Interfaces/ProtectedInterfaces/dbeditor.h
    epcominterfaces/dpeconfiguration.h DELE5Interfaces/ProtectedInterfaces/dpeconfiguration.h
    epcominterfaces/emergencyagentprovider.h DELE5Interfaces/ProtectedInterfaces/emergencyagentprovider.h
    epcominterfaces/epfilter2.h DELE5Interfaces/ProtectedInterfaces/epfilter2.h
    epcominterfaces/epgridtable.h DELE5Interfaces/ProtectedInterfaces/epgridtable.h
    epcominterfaces/epipdserver.h DELE5Interfaces/ProtectedInterfaces/epipdserver.h
    epcominterfaces/eplogger.h DELE5Interfaces/ProtectedInterfaces/eplogger.h
    epcominterfaces/epmultiuser.h DELE5Interfaces/ProtectedInterfaces/epmultiuser.h
    epcominterfaces/epplmconfigcomponenttypes.h DELE5Interfaces/ProtectedInterfaces/epplmconfigcomponenttypes.h
    epcominterfaces/eppoolingserver.h DELE5Interfaces/ProtectedInterfaces/eppoolingserver.h
    epcominterfaces/eprights.h DELE5Interfaces/ProtectedInterfaces/eprights.h
    epcominterfaces/epservertools.h DELE5Interfaces/ProtectedInterfaces/epservertools.h
    epcominterfaces/epsessiondata.h DELE5Interfaces/ProtectedInterfaces/epsessiondata.h
    epcominterfaces/epssoservice.h DELE5Interfaces/ProtectedInterfaces/epssoservice.h
    epcominterfaces/eptransactionmng.h DELE5Interfaces/ProtectedInterfaces/eptransactionmng.h
    epcominterfaces/epuihandler.h DELE5Interfaces/ProtectedInterfaces/epuihandler.h
    epcominterfaces/epvariantmatrix.h DELE5Interfaces/ProtectedInterfaces/epvariantmatrix.h
    epcominterfaces/epversion.h DELE5Interfaces/ProtectedInterfaces/epversion.h
    epcominterfaces/ergoplandoimpl.h DELE5Interfaces/ProtectedInterfaces/ergoplandoimpl.h
    epcominterfaces/ipdclient.h DELE5Interfaces/ProtectedInterfaces/ipdclient.h
    epcominterfaces/ipdclientcaching.h DELE5Interfaces/ProtectedInterfaces/ipdclientcaching.h


    Thank you once again.
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    The code I wrote assumed that your problem statement is incomplete. Thus, the command line argument

    program.h

    matches

    \path\program.h

    as well as

    \path\my_program.h

    So modify the program, or use a command line argument of
    \AnalysisWnd.h
    if that's the file you intend. I don't know how you present back slashes to your shell. Probably DOS. Probably no trouble.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Hi

    My appologies I am unable to understand what you meant.

    I did try the command line argument with a /AnalysisWnd.h but no luck.

    I still get the same error msg.

    Thanks for your reply.

    I'm still trying to understand the code you have written.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    I seem to have figured out why i was getting that error.

    There were 2 occurances of AnalysisWnd.h and hence the value was already stored in Result and hence was raising the Value error.

    Although i have figured out the issue I'm not sure how to resolve this scenario.

    How could i get round this if there are 2 or more occurnaces of the file.

    The code works fine for a single occurance in the mapping file..

    Thanks a lot my friend.
  12. #7
  13. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    This version interactively resolves conflict.

    Code:
    import sys
    import pprint
    import collections
    
    
    # examine the command line arguments
    print('The command line argument array is %s\n'%str(sys.argv))
    
    
    # read the map file
    MAP_FILE_NAME = 'mapping.txt'
    
    with open(MAP_FILE_NAME,'r') as inf:
        MAP = inf.readlines()
    
    
    # convert the map file to a python mapping type.  A dictionary.
    MAP_DICT = dict()
    for LINE in MAP:
        FIELDS = LINE.strip().split()
        MAP_DICT[FIELDS[1]] = FIELDS[0]
    
    
    # examine the map
    print('The mapping dictionary:')
    pprint.pprint(MAP_DICT)
    print('')
    
    
    # construct a dictionary with matching files based on the command line
    RESULT = collections.defaultdict(list)
    for NAME in sys.argv[1:]:
        for KEY in MAP_DICT:
            if KEY.endswith(NAME):
                RESULT[NAME].append(MAP_DICT[KEY])
    
    
    # interactively resolve conflict
    for (KEY,VALUE,) in RESULT.items():
        K = 0
        if 1 < len(VALUE):
            print('\nFound multiple matches for arg %s.  Choose by number:'%KEY)
            for T in enumerate(VALUE):
                print('%4d %s'%T)
            while True:
                try:
                    K = int(sys.stdin.readline())
                except ValueError:
                    print('enter one of those numbers!')
                else:
                    try:
                        VALUE[K]
                    except IndexError:
                        print('Choose wisely, young turnip.')
                    else:
                        break
        RESULT[KEY] = VALUE[K]
    
    
    
    # display the result
    print('The correspondence:')
    pprint.pprint(RESULT)
    [code]Code tags[/code] are essential for python code and Makefiles!
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    Thanks a lot..

    It works perfectly fine.

    You are really damn good.

    Thank you once again.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0

    Another complex scenario


    Hi

    I have another complex scenario which i require your help with.

    I have a log file generated with the following content



    # RWC-INFO: no warning, no error
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEGINFCXR23/GlobalResults.htm

    Promoting the workspace revision "DEIPrjCXR23.DEIAPPCXR23.93" to "DEIIntCXR23".
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\FEUILLET.catvba has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Built_In has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Built_In\BUILT-IN_Table_PREPA.xls has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Rapport has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Rapport\Design_Unit_043.csv has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5 has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET\PWC_AR ETE.CATPart has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET\PWC_DE VELOPPE.CATPart has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET\PWC_FE UILLET.catalog has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DEFAULT_A3.CATDrawin g has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\FOND_DE_PLAN_PREPA.C ATDrawing has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\ProfileFabricationSk etch_2DSymbols.CATDrawing has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Xml has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Xml\Endcut.xml has been created
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrEdgePrepItemDlg.cpp has been modified
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrProfileEdgePrepDlg.cpp has been modified

    Checking that the files to promote are in compliance with CAA rules
    ## ---> Start of CAA Compatibility Check
    ## ---> End of CAA Compatibility Check (0)
    ## ---> Start of QuickReviews Check
    # RWC-INFO: no warning, no error
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIAPPCXR23/GlobalResults.htm

    Promoting the workspace revision "DEIPrjCXR23.DEIDPECXR23.256" to "DEIIntCXR23".
    DELE5Base\xconvert.m\src\epcombstr.cpp has been modified
    DELE5BridgeVPMV4\epvpmloaderexe.m\src\epcomploadermain.cpp has been modified
    DELE5BridgeVPMV4\epvpmloaderexe.m\src\epcomploaderxmlhandler.cpp has been modified
    DELE5PoetGen\CNext.internal_Windows\reffiles\PPRServer\dmp\BBF_Projekte_ohneEnglisch\BBF_Projekte_oh neEnglisch.dmp has been modified
    DELE5PoetGen\CNext.internal_Windows\reffiles\PPRServer\dmp\pe523_e\e5_database.dmp has been modified
    DELE5PoetGen\CNext.internal_Windows\reffiles\PPRServer\dmp\pe523_motorx35\motorx35.dmp has been modified
    DELE5Server\filters.m\src\xepattributefilter.cpp has been modified


    Promoting the workspace revision "DEIPrjCXR23.DEIINFCXR23.106" to "DEIIntCXR23".
    DNBD5DataImport\DNBD5Feat.m\Imakefile.mk has been modified
    DNBD5DataImport\DNBD5Feat.m\src\DNBD5FeatureMain.cpp has been modified
    DNBD5DataImport.tst\FunctionTests\TestCases\DNBD5IFeat.sh has been deleted
    DNBStrMfgModeler\DNBStrMfgFeatures.m\src\CATEStrMfgFeatureFactoryExt.cpp has been modified

    Checking that the files to promote are in compliance with CAA rules
    ## ---> Start of CAA Compatibility Check
    ## ---> End of CAA Compatibility Check (0)
    ## ---> Start of QuickReviews Check
    # RWC-INFO: NON BLOCKING MODE : 1 errors changed into warnings
    # RWC-WARNING: 1 warning detected
    # RWC-INFO: see //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIINFCXR23/RWC/main.html
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIINFCXR23/GlobalResults.htm

    --- Simulation end ---

    What i require from the above file is as follows

    - I require the path of the files that have been modified, created, deleted or moved, for example lets take the line

    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\FEUILLET.catvba has been created

    In the above line i need to retrieve 3 things viz.,
    1. path - DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing
    2. file name- FEUILLET.catvba and
    3. the keyword- created

    Another example, lets take the line
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrProfileEdgePrepDlg.cpp has been modified

    From the above line i need to retrieve 3 things
    1. path - DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\
    2. filename- DNBDpmStrProfileEdgePrepDlg.cpp
    3. keyword- modified

    I also require to check if the folder is created as well as you can see in the file above which states
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing has been created

    In this case i need to retrieve again 3 things
    1. path
    2. folder name
    3. keyword created

    Please do help me with the code.

    Thanks a lot
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0

    Another complex scenario


    Hi

    I have another complex scenario which i require your help with.

    I have a log file generated with the following content



    # RWC-INFO: no warning, no error
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEGINFCXR23/GlobalResults.htm

    Promoting the workspace revision "DEIPrjCXR23.DEIAPPCXR23.93" to "DEIIntCXR23".
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\FEUILLET.catvba has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Built_In has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Built_In\BUILT-IN_Table_PREPA.xls has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Rapport has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Rapport\Design_Unit_043.csv has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5 has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET\PWC_AR ETE.CATPart has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET\PWC_DE VELOPPE.CATPart has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DATA_FEUILLET\PWC_FE UILLET.catalog has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\DEFAULT_A3.CATDrawin g has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\FOND_DE_PLAN_PREPA.C ATDrawing has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Template_V5\ProfileFabricationSk etch_2DSymbols.CATDrawing has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Xml has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources\Xml\Endcut.xml has been created
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrEdgePrepItemDlg.cpp has been modified
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrProfileEdgePrepDlg.cpp has been modified

    Checking that the files to promote are in compliance with CAA rules
    ## ---> Start of CAA Compatibility Check
    ## ---> End of CAA Compatibility Check (0)
    ## ---> Start of QuickReviews Check
    # RWC-INFO: no warning, no error
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIAPPCXR23/GlobalResults.htm

    Promoting the workspace revision "DEIPrjCXR23.DEIDPECXR23.256" to "DEIIntCXR23".
    DELE5Base\xconvert.m\src\epcombstr.cpp has been modified
    DELE5BridgeVPMV4\epvpmloaderexe.m\src\epcomploadermain.cpp has been modified
    DELE5BridgeVPMV4\epvpmloaderexe.m\src\epcomploaderxmlhandler.cpp has been modified
    DELE5PoetGen\CNext.internal_Windows\reffiles\PPRServer\dmp\BBF_Projekte_ohneEnglisch\BBF_Projekte_oh neEnglisch.dmp has been modified
    DELE5PoetGen\CNext.internal_Windows\reffiles\PPRServer\dmp\pe523_e\e5_database.dmp has been modified
    DELE5PoetGen\CNext.internal_Windows\reffiles\PPRServer\dmp\pe523_motorx35\motorx35.dmp has been modified
    DELE5Server\filters.m\src\xepattributefilter.cpp has been modified


    Promoting the workspace revision "DEIPrjCXR23.DEIINFCXR23.106" to "DEIIntCXR23".
    DNBD5DataImport\DNBD5Feat.m\Imakefile.mk has been modified
    DNBD5DataImport\DNBD5Feat.m\src\DNBD5FeatureMain.cpp has been modified
    DNBD5DataImport.tst\FunctionTests\TestCases\DNBD5IFeat.sh has been deleted
    DNBStrMfgModeler\DNBStrMfgFeatures.m\src\CATEStrMfgFeatureFactoryExt.cpp has been modified

    Checking that the files to promote are in compliance with CAA rules
    ## ---> Start of CAA Compatibility Check
    ## ---> End of CAA Compatibility Check (0)
    ## ---> Start of QuickReviews Check
    # RWC-INFO: NON BLOCKING MODE : 1 errors changed into warnings
    # RWC-WARNING: 1 warning detected
    # RWC-INFO: see //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIINFCXR23/RWC/main.html
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIINFCXR23/GlobalResults.htm

    --- Simulation end ---

    What i require from the above file is as follows

    - I require the path of the files that have been modified, created, deleted or moved, for example lets take the line

    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\FEUILLET.catvba has been created

    In the above line i need to retrieve 3 things viz.,
    1. path - DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing
    2. file name- FEUILLET.catvba and
    3. the keyword- created

    Another example, lets take the line
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrProfileEdgePrepDlg.cpp has been modified

    From the above line i need to retrieve 3 things
    1. path - DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\
    2. filename- DNBDpmStrProfileEdgePrepDlg.cpp
    3. keyword- modified

    I also require to check if the folder is created as well as you can see in the file above which states
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing has been created

    In this case i need to retrieve again 3 things
    1. path
    2. folder name
    3. keyword created

    Please do help me with the code.

    Thanks a lot
  20. #11
  21. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,931
    Rep Power
    481
    Would this algorithm work?

    1) filter the log file keeping only the useful lines,

    2) then use a modified previous program.
    Code:
    DATA = r'''
    # RWC-INFO: no warning, no error
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEGINFCXR23/GlobalResults.htm
    
    Promoting the workspace revision "DEIPrjCXR23.DEIAPPCXR23.93" to "DEIIntCXR23".
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\FEUILLET.catvba has been created
    DNBDpmStrCommonUI\CNext\VBScript\Structure_Manufacturing\Ressources has been created
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrEdgePrepItemDlg.cpp has been modified
    DNBDpmStrCommonUI\DNBDpmStrJoiningActivity.m\src\DNBDpmStrProfileEdgePrepDlg.cpp has been modified
    
    Checking that the files to promote are in compliance with CAA rules
    ## ---> Start of CAA Compatibility Check
    ## ---> End of CAA Compatibility Check (0)
    ## ---> Start of QuickReviews Check
    # RWC-INFO: no warning, no error
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIAPPCXR23/GlobalResults.htm
    
    Promoting the workspace revision "DEIPrjCXR23.DEIDPECXR23.256" to "DEIIntCXR23".
    DELE5Base\xconvert.m\src\epcombstr.cpp has been modified
    DELE5BridgeVPMV4\epvpmloaderexe.m\src\epcomploadermain.cpp has been modified
    DELE5Server\filters.m\src\xepattributefilter.cpp has been modified
    
    
    Promoting the workspace revision "DEIPrjCXR23.DEIINFCXR23.106" to "DEIIntCXR23".
    DNBD5DataImport\DNBD5Feat.m\Imakefile.mk has been modified
    DNBD5DataImport.tst\FunctionTests\TestCases\DNBD5IFeat.sh has been deleted
    
    Checking that the files to promote are in compliance with CAA rules
    ## ---> Start of CAA Compatibility Check
    ## ---> End of CAA Compatibility Check (0)
    ## ---> Start of QuickReviews Check
    # RWC-INFO: NON BLOCKING MODE : 1 errors changed into warnings
    # RWC-WARNING: 1 warning detected
    # RWC-INFO: see //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIINFCXR23/RWC/main.html
    ## ---> End of QuickReviews Check (0)
    ## ---> Start of Documentation Check
    SEE DETAILS IN: //imp20dei/IMP20DEI-D/Adele/DEIPrjCXR23/ToolsData/CheckSourceResult/DEIINFCXR23/GlobalResults.htm
    
    --- Simulation end ---
    '''
    
    import os
    import pprint
    
    def retain(A):
        B = A.strip()
        keep = True
        keep = keep and ('has been' in B)
        keep = keep and any(B.endswith(w) for w in 'modified created deleted moved'.split())
        keep = keep and ('\\' in B)
        return keep
    
    def process_line(A):
        FIELDS = A.split(' ')
        T = os.path.split(FIELDS[0])
        return T + (FIELDS[-1],)
    
    def group(A):
        result = ([],[],[],)
        for L in A:
            for (B,C,) in enumerate(process_line(L)):
                result[B].append(C)
        return result
    
    
    LINES = [L for L in DATA.split('\n') if retain(L)]
    
    pprint.pprint(group(LINES))
    For further work, please hire a programmer.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo