SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. import widlparser
  3.  
  4. browser = 'firefox'
  5.  
  6. if browser == 'firefox':
  7.     webidl_path = "/Users/vinyldarkscratch/Developer/git/gecko-dev"
  8. elif browser == 'chrome':
  9.     webidl_path = "/Users/vinyldarkscratch/Developer/git/chromium/src"
  10. elif browser == 'safari':
  11.     webidl_path = "/Users/vinyldarkscratch/Developer/WebKit"
  12.  
  13. data = ""
  14. with open("/Users/vinyldarkscratch/Desktop/%s_null.txt" %browser) as f:
  15.     entries_to_check = [l.replace("\n", "") for l in f.readlines() if l.startswith("api.")]
  16.  
  17. def dir_walk(path):
  18.     response = []
  19.     for root, subdirs, files in os.walk(path):
  20.         response += [os.path.join(root, f) for f in files if (f.endswith('.idl') or f.endswith('.webidl'))]
  21.         for s in subdirs:
  22.             response += dir_walk(s)
  23.     return response
  24.  
  25. def check_entry(entry):
  26.     e = entry.split(".")
  27.     for w in widl:
  28.         if w.name == e[1]:
  29.             if len(e) == 2:
  30.                 return "true"
  31.             else:
  32.                 if hasattr(w, 'members'):
  33.                     for m in w.members:
  34.                         if m.name == e[2] and len(e) == 3:
  35.                             return "true"
  36.  
  37.     return "null"
  38.  
  39. files = sorted(dir_walk(webidl_path))
  40. for fn in files:
  41.     with open(os.path.join(webidl_path, fn), 'r') as f:
  42.         new_data = f.read()
  43.         data += new_data
  44.  
  45. widl = widlparser.parser.Parser(data)
  46.  
  47. for entry in entries_to_check:
  48.     c = check_entry(entry)
  49.     print("%s - %s" %(entry, c))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top