- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmemory_chunk_module.py
More file actions
Latest commit
26 lines (20 loc) · 653 Bytes
/
Copy pathmemory_chunk_module.py
File metadata and controls
26 lines (20 loc) · 653 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
26
importmath
importos
defget_parsed_memory(memory):
# kilobyte
ifmemory[-1].upper() =='K':
returnint(memory[:-1]) *1024
# megabyte
elifmemory[-1].upper() =='M':
returnint(memory[:-1]) *1024*1024
# gigabyte
elifmemory[-1].upper() =='G':
returnint(memory[:-1]) *1024*1024*1024
# byte
else:
returnint(memory)
defget_total_chunk(filename, chunk_memory):
returnint(math.ceil((os.path.getsize(filename) /chunk_memory)))
defcleanup_chunk_file(chunk_filenames):
forfileinchunk_filenames:
os.remove(file)