PyLinks 0.0.0.dev45__py3-none-any.whl → 0.0.0.dev47__py3-none-any.whl

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.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyLinks
3
- Version: 0.0.0.dev45
3
+ Version: 0.0.0.dev47
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: requests <3,>=2.31.0
6
- Requires-Dist: ExceptionMan ==0.0.0.dev32
7
- Requires-Dist: MDit ==0.0.0.dev32
6
+ Requires-Dist: ExceptionMan ==0.0.0.dev34
7
+ Requires-Dist: MDit ==0.0.0.dev34
8
8
 
@@ -6,7 +6,7 @@ pylinks/string.py,sha256=yoORoiILKAKzzfDw-bwePBTwb3Shr_RvOSB2tdEZuSU,1397
6
6
  pylinks/url.py,sha256=4YzmNn0U1nzWmcdzEW6RKaZd5uu-MZRimHGl5Xi60Cg,7815
7
7
  pylinks/api/__init__.py,sha256=q7hhZabjTajBYxDxzJy44y8Rx_-5sye9VnVnkytIua8,488
8
8
  pylinks/api/doi.py,sha256=7YnMqy4_Ct2sw9Wz4mQC5S4xAahwh6fMUPKAx_qqj-M,5899
9
- pylinks/api/github.py,sha256=d_du2eSkefD-BXTv2cbclY1XFpZNAuVQPcfeyDx4d4U,74896
9
+ pylinks/api/github.py,sha256=l5Fkz-u0Qp6ewW4D11WZkoCCXyFultrjnVH05b3GCMU,75161
10
10
  pylinks/api/orcid.py,sha256=e0DAuziq7HdGJ4BJOI28mo1emB4_7gPsLxR7VsYPYMA,1377
11
11
  pylinks/api/zenodo.py,sha256=LZwpwwb24rSFqIMpSrflnkcMP1_y8Co4apVGD4PGKNU,5150
12
12
  pylinks/exception/__init__.py,sha256=tU-LvaYi4NsLEZeeUN-JjemhefJ6R_DG37fIMoaZ5a4,89
@@ -23,7 +23,7 @@ pylinks/site/pypi.py,sha256=-NSglDo-k55bALi-aN0iF2I6z1WXsjYOIVDyjNUxuuU,1944
23
23
  pylinks/site/readthedocs.py,sha256=_s27ETa3oRoeDdQvFrrtuSh2my6cjWEIEVhwHz0yZ90,1797
24
24
  pylinks/uri/__init__.py,sha256=W38fMHGgV7mg8uPWC8IMWGgmlCQO9VHIqNpInG2NS2I,29
25
25
  pylinks/uri/data.py,sha256=uD1CipMo4oFpxH8liOY24PsxMyuR5kEH2a0XDkO1dgI,6380
26
- PyLinks-0.0.0.dev45.dist-info/METADATA,sha256=lh94zFzz2_GWeu7VHAXXWcjL0h9jvFzAr5rGhiBS7mI,194
27
- PyLinks-0.0.0.dev45.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
28
- PyLinks-0.0.0.dev45.dist-info/top_level.txt,sha256=LlaTHnPw89VppYU3vCciF81IOSzvc16RkdNkOCqhAcs,8
29
- PyLinks-0.0.0.dev45.dist-info/RECORD,,
26
+ PyLinks-0.0.0.dev47.dist-info/METADATA,sha256=BppQLSN_zGcwhg0ujBN_7FVbc-tGAGeY5nAyaY_xDqM,194
27
+ PyLinks-0.0.0.dev47.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
28
+ PyLinks-0.0.0.dev47.dist-info/top_level.txt,sha256=LlaTHnPw89VppYU3vCciF81IOSzvc16RkdNkOCqhAcs,8
29
+ PyLinks-0.0.0.dev47.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
pylinks/api/github.py CHANGED
@@ -166,6 +166,16 @@ class Repo:
166
166
  endpoint=endpoint
167
167
  )
168
168
 
169
+ def _graphql_query(
170
+ self,
171
+ payload: str,
172
+ extra_headers: dict | None = None,
173
+ ) -> dict:
174
+ return self._github.graphql_query(
175
+ query=f'repository(name: "{self._name}", owner: "{self._username}") {{{payload}}}',
176
+ extra_headers=extra_headers,
177
+ )["repository"]
178
+
169
179
  @property
170
180
  def username(self) -> str:
171
181
  return self._username
@@ -412,13 +422,9 @@ class Repo:
412
422
  - [GitHub Docs](https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions)
413
423
  -
414
424
  """
415
- payload = "{discussionCategories(first: 100) {edges {node {name, slug, id}}}}"
416
- query = f'repository(name: "{self._name}", owner: "{self._username}") {payload}'
417
- data = self._github.graphql_query(query)
418
- discussions = [
419
- entry["node"]
420
- for entry in data["repository"]["discussionCategories"]["edges"]
421
- ]
425
+ payload = "discussionCategories(first: 100) {edges {node {name, slug, id}}}"
426
+ data = self._graphql_query(payload)
427
+ discussions = [entry["node"] for entry in data["discussionCategories"]["edges"]]
422
428
  return discussions
423
429
 
424
430
  def issue(self, number: int) -> dict:
@@ -610,7 +616,12 @@ class Repo:
610
616
  """
611
617
  return self._rest_query(f"pulls/{number}")
612
618
 
613
- def pull_commits(self, number: int) -> list[dict]:
619
+ def pull_commits(
620
+ self,
621
+ number: int,
622
+ count: int = 0,
623
+ sort: Literal["first", "last"] = "last",
624
+ ) -> list[dict]:
614
625
  """
615
626
  Get a list of commits for a pull request.
616
627
 
@@ -629,6 +640,9 @@ class Repo:
629
640
  ----------
630
641
  - [GitHub API Docs](https://docs.github.com/en/rest/pulls/commits?apiVersion=2022-11-28#list-commits-on-a-pull-request)
631
642
  """
643
+ payload = f"pullRequest(number: {number})"
644
+ commits = "{{commits()"
645
+
632
646
  commits = []
633
647
  page = 1
634
648
  while True:
@@ -639,6 +653,8 @@ class Repo:
639
653
  break
640
654
  return commits
641
655
 
656
+
657
+
642
658
  def pull_create(
643
659
  self,
644
660
  head: str,
@@ -1683,9 +1699,8 @@ class Repo:
1683
1699
  ----------
1684
1700
  - [GitHub API Docs](https://docs.github.com/en/graphql/reference/objects#branchprotectionruleconnection)
1685
1701
  """
1686
- payload = "{branchProtectionRules(first: 100) {nodes {id, pattern}}}"
1687
- query = f'repository(name: "{self._name}", owner: "{self._username}") {payload}'
1688
- data = self._github.graphql_query(query)
1702
+ payload = "branchProtectionRules(first: 100) {nodes {id, pattern}}"
1703
+ data = self._graphql_query(payload)
1689
1704
  return data["repository"]["branchProtectionRules"]["nodes"]
1690
1705
 
1691
1706
  def branch_protection_rule_create(