9#include <boost/python/class.hpp>
10#include <boost/python/copy_const_reference.hpp>
12#include <framework/dataobjects/FileMetaData.h>
13#include <framework/utilities/HTML.h>
14#include <framework/utilities/KeyValuePrinter.h>
16#include <boost/algorithm/string.hpp>
18#include <nlohmann/json.hpp>
24using namespace boost::python;
27 m_lfn(
""), m_nEvents(0), m_nFullEvents(0), m_experimentLow(0), m_runLow(0), m_eventLow(0),
28 m_experimentHigh(0), m_runHigh(0), m_eventHigh(0), m_date(
""), m_site(
""), m_user(
""), m_release(
""),
29 m_steering(
""), m_isMC(true), m_mcEvents(0)
51 class_<FileMetaData>(
"FileMetaData")
79 if (option && (option == std::string(
"steering"))) {
82 }
else if (option && (option == std::string(
"json"))) {
86 const bool all = (option && option == std::string(
"all"));
105 std::cout <<
"=== FileMetaData ===\n";
106 std::cout << printer.
string();
111 physicalFileName =
"";
112 if (input.eof())
return false;
115 std::getline(input, line);
116 boost::algorithm::trim(line);
117 if (line.compare(
"<File>") != 0)
return false;
119 while (!input.eof()) {
120 std::getline(input, line);
121 boost::algorithm::trim(line);
122 if (line.compare(
"</File>") == 0)
return true;
124 int pos = line.find(
'>') + 1;
125 std::string tag = line.substr(0, pos);
126 std::string value = line.substr(pos, line.rfind(
'<') - pos);
127 if (tag.compare(
"<LFN>") == 0) {
129 }
else if (tag.compare(
"<PFN>") == 0) {
131 }
else if (tag.compare(
"<ExperimentLow>") == 0) {
133 }
else if (tag.compare(
"<RunLow>") == 0) {
135 }
else if (tag.compare(
"<EventLow>") == 0) {
137 }
else if (tag.compare(
"<ExperimentHigh>") == 0) {
139 }
else if (tag.compare(
"<RunHigh>") == 0) {
141 }
else if (tag.compare(
"<EventHigh>") == 0) {
143 }
else if (tag.compare(
"<Parents>") == 0) {
144 pos = value.find(
',');
147 value.erase(0, pos + 1);
148 pos = value.find(
',');
159 output <<
" <File>\n";
161 if (!physicalFileName.empty()) {
162 output <<
" <PFN>" <<
HTML::escape(physicalFileName) <<
"</PFN>\n";
164 output <<
" <ExperimentLow>" <<
m_experimentLow <<
"</ExperimentLow>\n";
165 output <<
" <RunLow>" <<
m_runLow <<
"</RunLow>\n";
166 output <<
" <EventLow>" <<
m_eventLow <<
"</EventLow>\n";
168 output <<
" <RunHigh>" <<
m_runHigh <<
"</RunHigh>\n";
169 output <<
" <EventHigh>" <<
m_eventHigh <<
"</EventHigh>\n";
172 for (
unsigned int parent = 1; parent <
m_parentLfns.size(); parent++) {
175 output <<
"</Parents>\n";
177 output <<
" </File>\n";
184 nlohmann::json metadata = {
206 return metadata.dump(2);
create human-readable or JSON output for key value pairs.
void put(const std::string &key, const T &value)
Add one key-value pair.
std::string string() const
Return completed string.
std::string escape(const std::string &str)
Convert &, <, > etc.
std::string unescape(const std::string &str)
inverse of escape()
Abstract base class for different kinds of events.