-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtar.py
executable file
·47 lines (31 loc) · 1.26 KB
/
tar.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
import tarfile
from workthief2 import WorkThief as Base
otar = None
################################################################################
class TarFiles(Base):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self):
self.otar = None
Base.__init__(self)
return
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def process_directory(self, dirname, statinfo=None):
Base.process_directory(self,dirname,statinfo)
#print(dirname)
return
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def process_file(self, filename, statinfo=None):
# base class processing
Base.process_file(self,filename,statinfo)
# open output tar file if necessary
if not self.otar:
self.otar = tarfile.open("/ephemeral/benkirk/test_tar_output/output-{:05d}.tar".format(self.rank), "w")
print("[{:3d}] {}".format(self.rank,filename))
self.otar.add(filename, recursive=False)
return
################################################################################
if __name__ == "__main__":
t = TarFiles()
t.run()
t.summary()