BOM.csv Coding task: BOM checker We perform mechanical design of our devices using...

80.2K

Verified Solution

Question

Accounting

imageimage

BOM.csv

image

Coding task: BOM checker We perform mechanical design of our devices using a 3D CAD (SolidWorks). Such a mechanical design is a collection of part files (. .sldprt ) organized in subdirectories and typically contains a few thousand files. In addition to the CAD part files, we write down all part files in a "part list" file called a bill of materials (BOM). The 3D CAD part files are easy to change (e.g., simply by moving the view angle and accidentally hitting (trl-S) and this poses a problem because it is difficult to tell those innocuous changes (e.g., view angle changes) from potentially critical errors (e.g., accidentally dragging and changing an important dimension). To mitigate the chance of breaking the design, this BOM contains a SHA256 hash of each part file (*.sldprt file) so that we can detect unintentional file changes by calculating the SHA256 hash of actual files and comparing them to the BOM. Task Your task is to implement a small Python tool that checks if the CAD part files (*.sldprt) are accidentally modified or otherwise inconsistent with the BOM. This tool will compare the actual part files (*.sldprt files) in the folder to the BOM and detects following types of errors. - Modification of part files (SHA256 hash inconsistent to what is recorded in the BOM) - Missing part part files (*.sldprt file specified in the BOM but missing from the folder) - Unidentified part files (*.sldprt file present in the folder but missing from the BOM) - Duplication of part files (multiple *.sldprt files with the same name in different folders) To perform this task, Python standard library packages hashlib and csv will likely be relevant. Requirements - The code will be executed from command line as python bonchecker.py "path/to/root" . "path/to/root . Python 3.8 will be used. - path/to/root is the top-level folder that contains only check contents of this folder. - The code shall anly use the Python Standard Library. - If a part file is specified in the BOM but not present under path/to/root, its filename If none of those errors are detected, print ok to stdout. shall be printed in stdout. - If a part file is present under path/to/root but is missing from the BOM, its path shall be printed to stdout. - If SHA256 is specified in the BOM and it does not match SHA256 calculated from the - If SHA256 is specified in the BOM and it does - If multiple part files with the same name (case-insensitive) are present under path/ta/rost folder, their paths shall be printed to stdout. If none of the problems above is detected, output or to stdout. Any files that do not have the extension of , sldprt shall be ignored. Evaluation criteria - A BOM csv file ( ban. csv) is present at path/to/raat/bom.csv. - Correctness of the program - Code organization and cleanliness - You can assume the BOM csv file is properly formatted: Example " The first row is a header row. - Following the header row, it contains 1 to 10000 rows. - Each row contains a unique and valid part file name. - Each row contains a blank or valid SHA256 hash. Some files may be contain a blank SHA256, indicating no file hash check for that file. "The BOM csv file contains only ASCII characters. - The BOM csv file does not contain any double quotes ("), commas (, ), and new lines ( ) within a cell. Output format The detected errors shall be printed to stdout in the following format. \begin{tabular}{l|l} \hline \multicolumn{1}{|l|}{ CAD file name } & SHA256 \\ \hline part top level A.sldprt & a0cdb460e98ebb13dfbdd820d646f9088b472367bea6bf4f8b4f596deb12b8c7 \\ \hline part second level B.sidprt & 2aae6681a3ccf7c08abb280b110a9394553629798701d1ae13abf804c7c90395 \\ \hline part A.sldprt & 3761f755aff9f41844f4acdf53c322ab7fb9731175ab64a426e83aaa4f959f5e \\ \hline part D.sldprt & 6e257e2808a67c0c1c3d8232122c1f247c0a2b57a5cee280cb46433bedfa551f \\ \hline part second level C.sidprt & \\ \hline part B.sidprt & 180f25053358d52994f127a14281108437632d17190029044752c4bbc046d79a \\ \hline part C.sidprt & 16cabab2c4b16cfbc0fcba77e8b16264c836b4e7aa37e371c61f8c8b9d75b6dd \\ \hline part second level A.sidprt & f85e3d6146e761c4f14724d1d52a523c746f1f2c5160be30c2ae30c5d4f2b778 \\ \hline \end{tabular} Coding task: BOM checker We perform mechanical design of our devices using a 3D CAD (SolidWorks). Such a mechanical design is a collection of part files (. .sldprt ) organized in subdirectories and typically contains a few thousand files. In addition to the CAD part files, we write down all part files in a "part list" file called a bill of materials (BOM). The 3D CAD part files are easy to change (e.g., simply by moving the view angle and accidentally hitting (trl-S) and this poses a problem because it is difficult to tell those innocuous changes (e.g., view angle changes) from potentially critical errors (e.g., accidentally dragging and changing an important dimension). To mitigate the chance of breaking the design, this BOM contains a SHA256 hash of each part file (*.sldprt file) so that we can detect unintentional file changes by calculating the SHA256 hash of actual files and comparing them to the BOM. Task Your task is to implement a small Python tool that checks if the CAD part files (*.sldprt) are accidentally modified or otherwise inconsistent with the BOM. This tool will compare the actual part files (*.sldprt files) in the folder to the BOM and detects following types of errors. - Modification of part files (SHA256 hash inconsistent to what is recorded in the BOM) - Missing part part files (*.sldprt file specified in the BOM but missing from the folder) - Unidentified part files (*.sldprt file present in the folder but missing from the BOM) - Duplication of part files (multiple *.sldprt files with the same name in different folders) To perform this task, Python standard library packages hashlib and csv will likely be relevant. Requirements - The code will be executed from command line as python bonchecker.py "path/to/root" . "path/to/root . Python 3.8 will be used. - path/to/root is the top-level folder that contains only check contents of this folder. - The code shall anly use the Python Standard Library. - If a part file is specified in the BOM but not present under path/to/root, its filename If none of those errors are detected, print ok to stdout. shall be printed in stdout. - If a part file is present under path/to/root but is missing from the BOM, its path shall be printed to stdout. - If SHA256 is specified in the BOM and it does not match SHA256 calculated from the - If SHA256 is specified in the BOM and it does - If multiple part files with the same name (case-insensitive) are present under path/ta/rost folder, their paths shall be printed to stdout. If none of the problems above is detected, output or to stdout. Any files that do not have the extension of , sldprt shall be ignored. Evaluation criteria - A BOM csv file ( ban. csv) is present at path/to/raat/bom.csv. - Correctness of the program - Code organization and cleanliness - You can assume the BOM csv file is properly formatted: Example " The first row is a header row. - Following the header row, it contains 1 to 10000 rows. - Each row contains a unique and valid part file name. - Each row contains a blank or valid SHA256 hash. Some files may be contain a blank SHA256, indicating no file hash check for that file. "The BOM csv file contains only ASCII characters. - The BOM csv file does not contain any double quotes ("), commas (, ), and new lines ( ) within a cell. Output format The detected errors shall be printed to stdout in the following format. \begin{tabular}{l|l} \hline \multicolumn{1}{|l|}{ CAD file name } & SHA256 \\ \hline part top level A.sldprt & a0cdb460e98ebb13dfbdd820d646f9088b472367bea6bf4f8b4f596deb12b8c7 \\ \hline part second level B.sidprt & 2aae6681a3ccf7c08abb280b110a9394553629798701d1ae13abf804c7c90395 \\ \hline part A.sldprt & 3761f755aff9f41844f4acdf53c322ab7fb9731175ab64a426e83aaa4f959f5e \\ \hline part D.sldprt & 6e257e2808a67c0c1c3d8232122c1f247c0a2b57a5cee280cb46433bedfa551f \\ \hline part second level C.sidprt & \\ \hline part B.sidprt & 180f25053358d52994f127a14281108437632d17190029044752c4bbc046d79a \\ \hline part C.sidprt & 16cabab2c4b16cfbc0fcba77e8b16264c836b4e7aa37e371c61f8c8b9d75b6dd \\ \hline part second level A.sidprt & f85e3d6146e761c4f14724d1d52a523c746f1f2c5160be30c2ae30c5d4f2b778 \\ \hline \end{tabular}

Answer & Explanation Solved by verified expert
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students