MCPcopy Create free account
hub / github.com/comaps/comaps / FindPageAndFill

Method FindPageAndFill

generator/descriptions_section_builder.cpp:154–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154size_t DescriptionsCollector::FindPageAndFill(std::string const & path, descriptions::LangMeta & meta)
155{
156 size_t size = 0;
157 if (path.empty() || !IsValidDir(path))
158 return size;
159
160 Platform::FilesList filelist;
161 Platform::GetFilesByExt(path, ".html", filelist);
162 for (auto const & filename : filelist)
163 {
164 auto const lang = base::FilenameWithoutExt(filename);
165 localisation::LanguageIndex const languageIndex = localisation::ConvertLanguageCodeToLanguageIndex(lang);
166 if (languageIndex == localisation::kUnsupportedLanguageIndex)
167 {
168 LOG(LWARNING, (languageIndex, "is an unsupported language."));
169 continue;
170 }
171
172 auto res = m_path2Index.try_emplace(base::JoinPath(path, filename), 0);
173 if (res.second)
174 {
175 auto const & filePath = res.first->first;
176 auto content = FillStringFromFile(filePath);
177 size_t const sz = content.size();
178 if (sz == 0)
179 {
180 LOG(LWARNING, ("Empty descriptions file:", filePath));
181 m_path2Index.erase(res.first);
182 continue;
183 }
184
185 auto & strings = m_collection.m_strings;
186 res.first->second = strings.size();
187 strings.push_back(std::move(content));
188
189 size += sz;
190 }
191
192 m_stat.IncCode(languageIndex);
193 meta.emplace_back(languageIndex, res.first->second);
194 }
195
196 return size;
197}
198
199// static
200void DescriptionsSectionBuilder::CollectAndBuild(std::string const & wikipediaDir, std::string const & mwmFile,

Callers

nothing calls this directly

Calls 10

IsValidDirFunction · 0.85
FilenameWithoutExtFunction · 0.85
JoinPathFunction · 0.85
IncCodeMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
push_backMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected