Better example and comments.
[rox-lib.git] / python / rox / Pyrex / Mac / FileMarking.py
blobf4947c82803b5cd575341a075d80169f3b11d55e
1 import macfs, os, sys
3 no_colour = 0
4 passed_colour = 2
5 failed_colour = 6
7 def colour_item(path, colour):
8 if os.path.isdir(path):
9 colour_directory(path, colour)
10 else:
11 colour_file(path, colour)
13 def colour_directory(path, colour):
14 import findertools
15 findertools.label(path, (8 - colour) & 7)
17 def colour_file(path, colour):
18 fsspec = macfs.FSSpec(path)
19 finfo = fsspec.GetFInfo()
20 finfo.Flags = (finfo.Flags & 0xfff1) | (colour << 1)
21 fsspec.SetFInfo(finfo)
23 def get_item_colour(path):
24 import findertools
25 #print "Getting colour of", path ###
26 result = (8 - findertools.label(path)) & 7
27 #print "...result =", result ###
28 return result
30 def mark_path_untested(path):
31 #print "Marking untested:", path ###
32 colour_item(path, no_colour)
34 def mark_untested(item):
35 if os.path.isdir(item):
36 colour_directory(item, no_colour)
37 for name in os.listdir(item):
38 if name <> "Reference":
39 mark_untested(os.path.join(item, name))
40 elif item.endswith(".pyx"):
41 colour_file(item, no_colour)
43 def mark_args_untested():
44 for item in sys.argv[1:]:
45 mark_untested(item)