om4r932 commited on
Commit
894fb85
·
1 Parent(s): f4051a0

Update app - change spec search_documents

Browse files
Files changed (1) hide show
  1. app.py +5 -34
app.py CHANGED
@@ -410,40 +410,11 @@ class SpecDocFinder:
410
  output = {"specs": self.indexer_specs, "scopes": self.indexer_scopes, "last_indexed_date": self.last_indexer_date}
411
  json.dump(output, f, indent=4, ensure_ascii=False)
412
 
413
- def search_document(self, doc_id, release = None):
414
- for key in self.indexer_specs.keys():
415
- if str(doc_id) in key:
416
- return self.indexer_specs[key]['url']
417
- series = doc_id.split(".")[0]
418
- while len(series) < 2:
419
- series = "0" + series
420
-
421
- url = f"https://www.3gpp.org/ftp/Specs/archive/{series}_series/{doc_id}"
422
-
423
- response = requests.get(url, verify=False)
424
- soup = BeautifulSoup(response.text, 'html.parser')
425
- items = soup.find_all("tr")[1:]
426
- version_found = None
427
- if release is None:
428
- try:
429
- item = items[-1].find("a")
430
- except Exception as e:
431
- print(e)
432
- return f"Unable to find specification {doc_id}"
433
- a, b, c = [_ for _ in item.get_text().split("-")[-1].replace(".zip", "")]
434
- version = f"{self.chars.index(a)}.{self.chars.index(b)}.{self.chars.index(c)}"
435
- version_found = (version, item.get("href"))
436
- _, spec_url = version_found
437
- return spec_url if version_found is not None else f"Specification {doc_id} not found"
438
- else:
439
- for item in items:
440
- x = item.find("a")
441
- if f"{doc_id.replace('.', '')}-{self.chars[int(release)]}" in x.get_text():
442
- a, b, c = [_ for _ in x.get_text().split("-")[-1].replace(".zip", "")]
443
- version = f"{self.chars.index(a)}.{self.chars.index(b)}.{self.chars.index(c)}"
444
- version_found = (version, x.get("href"))
445
- _, spec_url = version_found
446
- return spec_url if version_found is not None else f"Specification {doc_id} not found"
447
 
448
  finder_tsg = TsgDocFinder()
449
  finder_spec = SpecDocFinder()
 
410
  output = {"specs": self.indexer_specs, "scopes": self.indexer_scopes, "last_indexed_date": self.last_indexer_date}
411
  json.dump(output, f, indent=4, ensure_ascii=False)
412
 
413
+ def search_document(self, document):
414
+ series = document.split(".")[0].zfill(2)
415
+ url = f"https://www.3gpp.org/ftp/Specs/archive/{series}_series/{document}"
416
+ versions = self.get_docs_from_url(url)
417
+ return url + "/" + versions[-1] if versions != [] else f"Specification {document} not found"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
 
419
  finder_tsg = TsgDocFinder()
420
  finder_spec = SpecDocFinder()