Rushabh Mehta | ab7021c | 2015-12-03 17:52:46 +0530 | [diff] [blame^] | 1 | from __future__ import unicode_literals |
| 2 | |
| 3 | import os |
| 4 | |
| 5 | for basepath, folders, files in os.walk("user"): |
| 6 | if "index.txt" in files: |
| 7 | with open(os.path.join(basepath, "index.txt"), "r") as i: |
| 8 | in_index = i.read().splitlines() |
| 9 | |
| 10 | missing = [] |
| 11 | |
| 12 | for f in files: |
| 13 | name = f.rsplit(".", 1)[0] |
| 14 | if name not in in_index and name != "index": |
| 15 | missing.append(f) |
| 16 | |
| 17 | if missing: |
| 18 | print missing |
| 19 | with open(os.path.join(basepath, "index.txt"), "w") as i: |
| 20 | i.write("\n".join(in_index + missing)) |
| 21 | |