DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
snbmodules
python
snbmodules
raw_file_check.py
Go to the documentation of this file.
1
import
os.path
2
3
def
compare_raw_name
(file1, file2):
4
"""Compare the name of two files from their path"""
5
return
os.path.basename(file1) == os.path.basename(file2)
6
7
def
compare_raw_size
(file1, file2):
8
"""Compare the size of two files from their path"""
9
return
os.path.getsize(file1) == os.path.getsize(file2)
10
11
def
compare_raw_content
(file1, file2, buffer_size=1024):
12
"""Compare the content of two files from their path"""
13
buffer_count = 0
14
with
open(file1,
'rb'
)
as
f1, open(file2,
'rb'
)
as
f2:
15
while
True
:
16
data1 = f1.read(buffer_size)
17
data2 = f2.read(buffer_size)
18
19
if
not
data1
and
not
data2:
20
return
True
21
if
not
data1
or
not
data2:
22
return
False
23
if
data1 != data2:
24
print(
"Files are differents at bytes "
+ str(buffer_size * buffer_count) +
" to "
+ str(buffer_size * (buffer_count + 1)))
25
print(data1)
26
print(data2)
27
return
False
28
buffer_count += 1
raw_file_check.compare_raw_name
compare_raw_name(file1, file2)
Definition
raw_file_check.py:3
raw_file_check.compare_raw_content
compare_raw_content(file1, file2, buffer_size=1024)
Definition
raw_file_check.py:11
raw_file_check.compare_raw_size
compare_raw_size(file1, file2)
Definition
raw_file_check.py:7
Generated on
for DUNE-DAQ by
1.17.0