PyLinks 0.0.0.dev56__tar.gz → 0.0.0.dev58__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/PKG-INFO +3 -3
  2. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/pyproject.toml +3 -3
  3. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/PyLinks.egg-info/PKG-INFO +3 -3
  4. pylinks-0.0.0.dev58/src/PyLinks.egg-info/requires.txt +3 -0
  5. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/api/github.py +78 -2
  6. pylinks-0.0.0.dev56/src/PyLinks.egg-info/requires.txt +0 -3
  7. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/README.md +0 -0
  8. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/setup.cfg +0 -0
  9. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/PyLinks.egg-info/SOURCES.txt +0 -0
  10. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/PyLinks.egg-info/dependency_links.txt +0 -0
  11. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/PyLinks.egg-info/not-zip-safe +0 -0
  12. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/PyLinks.egg-info/top_level.txt +0 -0
  13. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/__init__.py +0 -0
  14. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/_settings.py +0 -0
  15. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/api/__init__.py +0 -0
  16. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/api/doi.py +0 -0
  17. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/api/orcid.py +0 -0
  18. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/api/zenodo.py +0 -0
  19. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/exception/__init__.py +0 -0
  20. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/exception/api.py +0 -0
  21. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/exception/base.py +0 -0
  22. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/exception/media_type.py +0 -0
  23. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/exception/uri.py +0 -0
  24. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/http.py +0 -0
  25. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/media_type.py +0 -0
  26. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/site/__init__.py +0 -0
  27. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/site/binder.py +0 -0
  28. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/site/conda.py +0 -0
  29. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/site/github.py +0 -0
  30. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/site/lib_io.py +0 -0
  31. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/site/pypi.py +0 -0
  32. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/site/readthedocs.py +0 -0
  33. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/string.py +0 -0
  34. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/uri/__init__.py +0 -0
  35. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/uri/data.py +0 -0
  36. {pylinks-0.0.0.dev56 → pylinks-0.0.0.dev58}/src/pylinks/url.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyLinks
3
- Version: 0.0.0.dev56
3
+ Version: 0.0.0.dev58
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: requests<3,>=2.31.0
6
- Requires-Dist: ExceptionMan==0.0.0.dev43
7
- Requires-Dist: MDit==0.0.0.dev43
6
+ Requires-Dist: ExceptionMan==0.0.0.dev45
7
+ Requires-Dist: MDit==0.0.0.dev45
@@ -17,12 +17,12 @@ namespaces = true
17
17
  # ----------------------------------------- Project Metadata -------------------------------------
18
18
  #
19
19
  [project]
20
- version = "0.0.0.dev56"
20
+ version = "0.0.0.dev58"
21
21
  name = "PyLinks"
22
22
  dependencies = [
23
23
  "requests >= 2.31.0, < 3",
24
- "ExceptionMan == 0.0.0.dev43",
25
- "MDit == 0.0.0.dev43",
24
+ "ExceptionMan == 0.0.0.dev45",
25
+ "MDit == 0.0.0.dev45",
26
26
  ]
27
27
  requires-python = ">=3.10"
28
28
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyLinks
3
- Version: 0.0.0.dev56
3
+ Version: 0.0.0.dev58
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: requests<3,>=2.31.0
6
- Requires-Dist: ExceptionMan==0.0.0.dev43
7
- Requires-Dist: MDit==0.0.0.dev43
6
+ Requires-Dist: ExceptionMan==0.0.0.dev45
7
+ Requires-Dist: MDit==0.0.0.dev45
@@ -0,0 +1,3 @@
1
+ requests<3,>=2.31.0
2
+ ExceptionMan==0.0.0.dev45
3
+ MDit==0.0.0.dev45
@@ -39,6 +39,83 @@ class GitHub:
39
39
  user_data = self.rest_query(f"user/{user_id}")
40
40
  return User(username=user_data["login"], token=self._token)
41
41
 
42
+ def search_code(self, query: str, max_results: int = 0):
43
+ results = {
44
+ "total_count": 0,
45
+ "incomplete_results": False,
46
+ "items": []
47
+ }
48
+ page = 1
49
+ while True:
50
+ response = self.rest_query(f"search/code?q={query}&per_page=100&page={page}")
51
+ results["total_count"] = response["total_count"]
52
+ results["incomplete_results"] = results["incomplete_results"] or response["incomplete_results"]
53
+ results["items"].extend(response["items"])
54
+ page += 1
55
+ if len(response["items"]) < 100 or (max_results and len(results["items"]) >= max_results):
56
+ break
57
+ return results
58
+
59
+ def search_code_graphql(
60
+ self,
61
+ query: str,
62
+ search_type: Literal["discussion", "issue", "repository", "user"],
63
+ payload: str,
64
+ count: int = 0,
65
+ cursor_before: str | None = None,
66
+ cursor_after: str | None = None,
67
+ sort: Literal["first", "last"] = "first",
68
+ ) -> list[dict]:
69
+ """
70
+ Get a list of commits for a pull request.
71
+
72
+ Parameters
73
+ ----------
74
+ number : int
75
+ Pull request number.
76
+
77
+ Returns
78
+ -------
79
+ list[dict]
80
+ A list of commits as dictionaries.
81
+ Commits are ordered by ascending commit date.
82
+
83
+ References
84
+ ----------
85
+ - [GitHub API Docs](https://docs.github.com/en/rest/pulls/commits?apiVersion=2022-11-28#list-commits-on-a-pull-request)
86
+ """
87
+
88
+ def make_query():
89
+ response = self.graphql_query(
90
+ query=f'{search_sig} {{{page_info_fields} {payload}}}',
91
+ variables=variables,
92
+ )["search"]
93
+ page_info = response.pop("pageInfo")
94
+ return page_info, response
95
+
96
+ search_args = [f'query: "{query}"', f"type: {search_type.upper()}", "after: $after", "before: $before", f"{sort}: {100 if count <= 0 else min(count, 100)}"]
97
+ page_info_fields = "pageInfo {startCursor, endCursor, hasNextPage, hasPreviousPage}"
98
+ search_sig = f"search({", ".join(search_args)})"
99
+ variables = {
100
+ "after": (cursor_after, "String", False),
101
+ "before": (cursor_before, "String", False),
102
+ }
103
+ page_info, data = make_query()
104
+ out = [data]
105
+ total_downloaded = 100
106
+ while True:
107
+ if count <= 0:
108
+ must_continue = page_info["hasNextPage" if sort == "first" else "hasPreviousPage"]
109
+ if not must_continue:
110
+ return out
111
+ elif total_downloaded >= count:
112
+ return out
113
+ else:
114
+ variables["after" if sort == "first" else "before"] = (page_info["endCursor" if sort == "first" else "startCursor"], "String", False)
115
+ page_info, data = make_query()
116
+ out.append(data)
117
+ total_downloaded += 100
118
+
42
119
  def graphql_query(
43
120
  self,
44
121
  query: str,
@@ -690,10 +767,9 @@ class Repo:
690
767
  elif total_downloaded >= count:
691
768
  return post_process()
692
769
  else:
693
- variables[sort] = page_info["endCursor" if sort == "first" else "startCursor"]
770
+ variables["after" if sort == "first" else "before"] = (page_info["endCursor" if sort == "first" else "startCursor"], "String", False)
694
771
  data.append(self._graphql_query(payload, variables))
695
772
  total_downloaded += 100
696
-
697
773
  # commits = []
698
774
  # page = 1
699
775
  # while True:
@@ -1,3 +0,0 @@
1
- requests<3,>=2.31.0
2
- ExceptionMan==0.0.0.dev43
3
- MDit==0.0.0.dev43
File without changes
File without changes