Belle II Software
development
Toggle main menu visibility
Main Page
Topics
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
w
x
z
Typedefs
a
b
c
d
e
g
i
k
l
m
n
p
r
s
t
u
v
w
Enumerations
a
b
c
e
f
g
n
p
s
v
z
Enumerator
c
d
f
p
t
v
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
z
Related Symbols
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
Typedefs
Macros
▼
Belle II Software
►
Topics
►
Namespaces
►
Classes
▼
Files
▼
File List
►
alignment
►
analysis
►
arich
►
b2bii
►
background
►
beast
►
calibration
►
cdc
►
daq
►
decfiles
►
display
►
dqm
►
ecl
▼
framework
►
core
►
data
►
database
►
dataobjects
►
datastore
►
dbobjects
►
examples
►
gearbox
►
geometry
►
io
►
logging
►
modules
►
particledb
►
pcore
►
pybasf2
►
scripts
▼
tests
angle.cc
b2file-normalize.py
B2Vector3.cc
basf2_args.py
basf2_rootinit.py
BeamParameters.cc
binnedEventT0.cc
CalcMeanCov.cc
chain_input.py
check_globaltag_trim.py
check_payload_metadata.py
check_payload_names.py
checkRandomNumbers.py
conditional_iov.py
conditions.py
conditions_metadataprovider.cc
conditions_process2.py
const.cc
cutNodes.cc
database.cc
datastore.cc
dowhile.py
dry-run.py
emptyrelations.py
eventExtraInfo.cc
eventlimiter.py
eventT0.cc
evtmetadata.py
evtpdl.py
filemetadata.py
FileSystem.cc
findFile.py
foreach.py
formula_parser.cc
framework_cppcheck.py
framework_doxygen_check.py
gearbox.cc
generalCut.cc
hardwareClockSettings.cc
Helix.cc
HTML.cc
include_exclude_branches.py
independent_merge_path.py
independent_path.py
iointercept.cc
ioutils.cc
local_database_file.py
local_metadata_provider.py
logging.cc
logsummary.py
make_root_compatible.cc
mcevent_forwarding.py
merge_files.py
mixed_runs.py
module_paths.py
module_setparameters.py
modulelist.py
mrucache.cc
msghandler.cc
multiple_module_conditions.py
node_factory.cc
numberSequence.cc
parallel_processing.py
partialselect.py
path_serialisation.py
prescale.py
processstatistics.cc
prune_datastore.py
pylogging.py
pyroot_tfile.py
python_datastore.py
python_dbinterface.py
recommend.py
relations_consolidate.cc
relations_internal.cc
relationsobject.cc
root_input.py
root_output.py
root_output_split.py
root_returnvalues.py
ScopeGuards.cc
select_subset.cc
seqroot_input.py
seqroot_output.py
signals.py
sphinx_full_release.py
sphinx_light_release.py
sqlite.cc
stop_on_error.py
stream.cc
streamer_test.py
test_b2conditionsdb_commands.py
test_b2file-mix.py
test_b2help_recommendation.py
test_basf2_utils.py
test_calculation.py
test_calculationList.py
test_calculationProcess.py
test_calculationQueue.py
test_check_basf2_file.py
test_entities.py
test_environmentInformation.py
test_globaltag_forwarding.py
test_iov.py
test_IPythonHandler.py
test_light_dependencies.py
test_module_log_level.py
test_module_log_level_run.py
test_print_module_parameters.py
test_runningupdate.py
test_tag_merge.py
UncertainHelix.cc
unit.cc
utils.cc
►
tools
►
utilities
►
generators
►
geometry
►
hlt
►
ir
►
klm
►
masterclass
►
mdst
►
mva
►
online_book
►
pxd
►
rawdata
►
reconstruction
►
simulation
►
site_scons
►
structure
►
svd
►
top
►
tracking
►
trg
►
validation
►
vxd
Doxygen.h
resource_analyzer.py
►
File Members
findFile.py
1
#!/usr/bin/env python3
2
3
10
11
from
basf2
import
find_file, B2INFO
12
import
os
13
14
# define shortcut for getting symlink-free path
15
rl = os.path.realpath
16
17
18
def
expect_missing(*args):
19
"""Return true if passing the arguments to find_file raises a FileNotFoundError, otherwise False"""
20
# raises a file not found exception if not found (unless suppressed)
21
try
:
22
find_file(*args)
23
except
FileNotFoundError:
24
return
True
25
else
:
26
return
False
27
28
29
assert
expect_missing(
'framework/tests/ThisFileDoesntExist'
)
30
# try to find TEST data file
31
assert
expect_missing(
'findFile.py'
,
'test'
)
32
33
B2INFO(
"No more output from here..."
)
34
assert
''
== find_file(
'framework/tests/ThisFileDoesntExist'
, silent=
True
)
35
36
# find ourselves relative to basf2 dir
37
abspath = rl(find_file(
'framework/tests/findFile.py'
))
38
assert
len(abspath) > 0
39
40
# adding '/' is ok, but optional
41
assert
abspath == rl(find_file(
'/framework/tests/findFile.py'
))
42
43
# absolute paths should be found
44
assert
abspath == rl(find_file(abspath))
45
46
# also works on directories
47
testdir = rl(find_file(
'/framework/tests/'
))
48
assert
len(testdir) > 0
49
50
# paths relative to PWD are also ok (no, prefixing this with / is not allowed)
51
os.chdir(testdir)
52
assert
abspath == rl(find_file(
'findFile.py'
))
53
assert
abspath == rl(find_file(
'./findFile.py'
))
54
55
# try finding relative to basf2 dir again (from different location)
56
os.chdir(
'/'
)
57
assert
abspath == rl(find_file(
'framework/tests/findFile.py'
))
58
assert
abspath == rl(find_file(
'/framework/tests/findFile.py'
))
59
assert
abspath == rl(find_file(
'./framework/tests/findFile.py'
))
60
61
# set BELLe2_TEST_DATA_DIR and try to find data file
62
os.environ[
'BELLE2_TEST_DATA_DIR'
] = os.environ.get(
'BELLE2_RELEASE_DIR'
, os.environ.get(
'BELLE2_LOCAL_DIR'
))
63
assert
abspath == rl(find_file(
'framework/tests/findFile.py'
,
'test'
))
framework
tests
findFile.py
Generated on Sat May 17 2025 02:59:20 for Belle II Software by
1.13.2