Download indexers.py from OrganizedProgrammers/DocIndexer-v2: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/spaces/OrganizedProgrammers/DocIndexer-v2/resolve/main/indexers.py
- Command line
-
hf download hf://spaces/OrganizedProgrammers/DocIndexer-v2/indexers.py
-
curl -L -o indexers.py https://huggingface.co/spaces/OrganizedProgrammers/DocIndexer-v2/resolve/main/indexers.py
2.53 kB
| """Shared indexer singletons, locks, and 3GPP working-group/meeting-folder helpers. | |
| Extracted from v0's app.py so that both the REST endpoints (used by the web | |
| dashboard) and the MCP indexing server share the same indexer instances and | |
| locks, preventing an indexing job started from one surface from racing with | |
| one started from the other. | |
| """ | |
| import re | |
| import threading | |
| from classes import TDocIndexer, Spec3GPPIndexer, SpecETSIIndexer | |
| meetings_mapping = { | |
| "SA": [ | |
| "TSG_SA", | |
| "WG1_Serv", | |
| "WG2_Arch", | |
| "WG3_Security", | |
| "WG4_CODEC", | |
| "WG5_TM", | |
| "WG6_MissionCritical" | |
| ], | |
| "CT": [ | |
| "TSG_CT", | |
| "WG1_mm-cc-sm_ex-CN1", | |
| "WG2_capability_ex-T2", | |
| "WG3_interworking_ex-CN3", | |
| "WG4_protocollars_ex-CN4", | |
| "WG5_osa_ex-CN5", | |
| "WG6_Smartcard_Ex-T3" | |
| ], | |
| "RAN": [ | |
| "TSG_RAN", | |
| "WG1_RL1", | |
| "WG2_RL2", | |
| "WG3_Iu", | |
| "WG4_Radio", | |
| "WG5_Test_ex-T1", | |
| "WG6_legacyRAN" | |
| ] | |
| } | |
| def get_folder_name(working_group: str): | |
| if working_group.endswith("P"): | |
| if working_group.startswith("S"): | |
| return ("SA", 0) | |
| if working_group.startswith("C"): | |
| return ("CT", 0) | |
| if working_group.startswith("R"): | |
| return ("RAN", 0) | |
| m = re.match(r"([A-Z]+)(\d+)", working_group) | |
| if m: | |
| code, num = m.groups() | |
| return (code, int(num)) | |
| else: | |
| raise ValueError("Unattended format") | |
| _tdoc_indexer = None | |
| _spec_3gpp_indexer = None | |
| _spec_etsi_indexer = None | |
| _init_locks = { | |
| "tdoc": threading.Lock(), | |
| "3gpp": threading.Lock(), | |
| "etsi": threading.Lock(), | |
| } | |
| indexing_locks = { | |
| "tdoc": threading.Lock(), | |
| "3gpp": threading.Lock(), | |
| "etsi": threading.Lock(), | |
| } | |
| def get_tdoc_indexer(): | |
| global _tdoc_indexer | |
| if _tdoc_indexer is None: | |
| with _init_locks["tdoc"]: | |
| if _tdoc_indexer is None: | |
| _tdoc_indexer = TDocIndexer() | |
| return _tdoc_indexer | |
| def get_spec_3gpp_indexer(): | |
| global _spec_3gpp_indexer | |
| if _spec_3gpp_indexer is None: | |
| with _init_locks["3gpp"]: | |
| if _spec_3gpp_indexer is None: | |
| _spec_3gpp_indexer = Spec3GPPIndexer() | |
| return _spec_3gpp_indexer | |
| def get_spec_etsi_indexer(): | |
| global _spec_etsi_indexer | |
| if _spec_etsi_indexer is None: | |
| with _init_locks["etsi"]: | |
| if _spec_etsi_indexer is None: | |
| _spec_etsi_indexer = SpecETSIIndexer() | |
| return _spec_etsi_indexer | |