Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. import sys
  2. import os
  3. #from beets import ui
  4. #from beets.ui import human_bytes
  5.  
  6. # Full script plan:
  7. # Read file (populate array) -> Parse file -> Sent to driver, calls functions from parse
  8. # -> Output to report function -> Html
  9.  
  10. def main():
  11. # todo: import 5 beets functions or all of beets if necessary
  12. # todo: write 4 helper functions: open file, run the method, compare results, write to html output
  13.  
  14. # walk the testCase file tree
  15. readFiles()
  16.  
  17. def readFiles():
  18.  
  19. rootDir = '../testCases/'
  20.  
  21. for filename in os.listdir(rootDir):
  22.  
  23. with open(os.path.join(rootDir, filename), "r") as f:
  24. #infoLines is an array populated by the first six lines of the testCase file
  25. infoLines = f.readlines()[0:6]
  26. infoLines = list(map(str.strip,infoLines))
  27.  
  28. driver(parseFiles(infoLines))
  29.  
  30. def parseFiles(infoLineArray):
  31. #1. test number or ID
  32. #2. requirement being tested
  33. #3. component being tested
  34. #4. method being tested
  35. #5. test input(s) including command-line argument(s)
  36. #6. expected outcome(s)
  37.  
  38. paren = '('
  39. comm = '#'
  40.  
  41. head, mid, tail = infoLineArray[3].partition(paren)
  42. funcName = head
  43.  
  44. print(infoLineArray[4])
  45. if '#' in infoLineArray[4]:
  46. head, mid, tail = infoLineArray[4].partition(comm)
  47. else:
  48. head = infoLineArray[4]
  49.  
  50. try:
  51. inputVal = float(head.strip())
  52. except:
  53. print(head)
  54. inputVal = 1.0
  55.  
  56. returnVal = [funcName, inputVal]
  57. return returnVal
  58.  
  59.  
  60. def driver(info):
  61. inFuncName = info[0]
  62. inInputVal = info[1]
  63.  
  64. output = getattr(ui, inFuncName)(inInputVal)
  65. print(output)
  66.  
  67. if __name__ == "__main__":
  68. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement