Coverage for src/ptf_tools/indexingChecker.py: 28%

43 statements  

« prev     ^ index     » next       coverage.py v7.7.0, created at 2025-04-03 12:11 +0000

1from ptf import model_helpers 

2from ptf.models import Article 

3from ptf.external.ads import AdsQuery, AdsArticle 

4 

5 

6class ReferencingChecker: 

7 _journals = {} 

8 

9 def __init__(self): 

10 self._journals['CRPHYS'] = Journal("comptes rendus physique", "CRPHYS") 

11 self._journals['CRGEOS'] = Journal("comptes rendus geoscience", "CRGEOS") 

12 self._journals['CRMECA'] = Journal("comptes rendus mecanique", "CRMECA") 

13 

14 def check_references(self, collect_id): 

15 collection = model_helpers.get_collection(collect_id) 

16 print(collection) 

17 query = AdsQuery() 

18 present = query.query_referencing(collection.issn) 

19 volumes_collections = model_helpers.get_volumes_in_collection(collection) 

20 print(volumes_collections) 

21 sorted_issues = volumes_collections["sorted_issues"] 

22 volumes = sorted_issues[0]['volumes'] 

23 journal = self._journals.get(collect_id) 

24 for volume in volumes: 

25 for issue in volume['issues']: 

26 articles = issue.article_set.all().order_by("doi") 

27 for article in articles: 

28 if article.doi[:7] == '10.5802': 

29 found_article = present.get(article.doi, None) 

30 if not found_article: 

31 print(article.doi) 

32 journal.articles().append(article) 

33 return journal 

34 

35 

36class Journal: 

37 _title: str 

38 _collection_pid: str 

39 _articles: [Article] 

40 

41 def __init__(self, title, collection_pid): 

42 self._title = title 

43 self._collection_pid = collection_pid 

44 self._articles = [] 

45 

46 def collection_pid(self) -> str: 

47 return self._collection_pid 

48 

49 def title(self) -> str: 

50 return self._title 

51 

52 def articles(self) -> [Article]: 

53 return self._articles 

54