-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhgcrawler.py
More file actions
26 lines (20 loc) · 901 Bytes
/
hgcrawler.py
File metadata and controls
26 lines (20 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import subprocess
from pathlib import Path
import os
from crawlerscommon import Crawler, SimpleFormatter, TemplateFormatter, MECFormatter
class HGCrawler(Crawler):
def __init__(self, outputformatter=SimpleFormatter()):
super().__init__(outputformatter)
def revertFilesInList(self, listfile, sourcedir):
path = Path(sourcedir)
with open(listfile, 'r') as f:
lines = [l.lower().strip().split('.')[0] for l in f.readlines()]
to_revert = [p for p in path.glob('*.*') if os.path.basename(p).lower().strip().split('.')[0] in lines]
print(to_revert)
os.chdir(sourcedir)
for p in to_revert:
pipe = subprocess.Popen(["hg", "revert", p.name])
pipe.wait()
if __name__ == '__main__':
crawler = HGCrawler()
crawler.revertFilesInList('D:/Work/modules_not.txt', 'D:/Work/Test')