Coverage for src/api/indexapi_v1.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.10.0, created at 2026-11-03 10:27 +0000

1#!/usr/bin/python 

2# -*- coding: utf-8 -*- 

3# Copyright (c) 2018, Silvio Peroni <essepuntato@gmail.com> 

4# 

5# Permission to use, copy, modify, and/or distribute this software for any purpose 

6# with or without fee is hereby granted, provided that the above copyright notice 

7# and this permission notice appear in all copies. 

8# 

9# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 

10# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 

11# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, 

12# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 

13# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 

14# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 

15# SOFTWARE. 

16 

17__author__ = "Arcangelo Massari & Ivan Heibi" 

18 

19from indexapi_common import ( 

20 lower, # noqa: F401 - used by ramose via getattr 

21 count_unique_cits, # noqa: F401 - used by ramose via getattr 

22 count_groups, # noqa: F401 - used by ramose via getattr 

23 oci_search, # noqa: F401 - used by ramose via getattr 

24 literal_search, 

25 unique_citations, 

26 citation_row, 

27) 

28 

29 

30def cited_search(doi): 

31 return (literal_search(doi, "cited_br"),) 

32 

33 

34def citing_search(doi): 

35 return (literal_search(doi, "citing_br"),) 

36 

37 

38def citations_info(res): 

39 f_res = [ 

40 ["oci", "citing", "cited", "creation", "timespan", "journal_sc", "author_sc"] 

41 ] 

42 for citation in unique_citations(res): 

43 f_res.append( 

44 citation_row( 

45 citation, 

46 __get_doi(citation["citing_ids"]), 

47 __get_doi(citation["cited_ids"]), 

48 ) 

49 ) 

50 return f_res, True 

51 

52 

53def __get_doi(ids): 

54 return " ".join( 

55 id.removeprefix("doi:") for id in ids.split(" __ ") if id.startswith("doi:") 

56 )