github-backup 0.46.0__py3-none-any.whl → 0.48.0__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.
github_backup/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.46.0"
1
+ __version__ = "0.48.0"
@@ -15,15 +15,16 @@ import platform
15
15
  import re
16
16
  import select
17
17
  import socket
18
+ import ssl
18
19
  import subprocess
19
20
  import sys
20
21
  import time
22
+ from datetime import datetime
21
23
  from http.client import IncompleteRead
22
24
  from urllib.error import HTTPError, URLError
23
25
  from urllib.parse import quote as urlquote
24
26
  from urllib.parse import urlencode, urlparse
25
27
  from urllib.request import HTTPRedirectHandler, Request, build_opener, urlopen
26
- from datetime import datetime
27
28
 
28
29
  try:
29
30
  from . import __version__
@@ -36,6 +37,23 @@ FNULL = open(os.devnull, "w")
36
37
  FILE_URI_PREFIX = "file://"
37
38
  logger = logging.getLogger(__name__)
38
39
 
40
+ https_ctx = ssl.create_default_context()
41
+ if not https_ctx.get_ca_certs():
42
+ import warnings
43
+
44
+ warnings.warn(
45
+ "\n\nYOUR DEFAULT CA CERTS ARE EMPTY.\n"
46
+ + "PLEASE POPULATE ANY OF:"
47
+ + "".join(
48
+ ["\n - " + x for x in ssl.get_default_verify_paths() if type(x) is str]
49
+ )
50
+ + "\n",
51
+ stacklevel=2,
52
+ )
53
+ import certifi
54
+
55
+ https_ctx = ssl.create_default_context(cafile=certifi.where())
56
+
39
57
 
40
58
  def logging_subprocess(
41
59
  popenargs, stdout_log_level=logging.DEBUG, stderr_log_level=logging.ERROR, **kwargs
@@ -511,7 +529,7 @@ def get_github_host(args):
511
529
 
512
530
 
513
531
  def read_file_contents(file_uri):
514
- return open(file_uri[len(FILE_URI_PREFIX):], "rt").readline().strip()
532
+ return open(file_uri[len(FILE_URI_PREFIX) :], "rt").readline().strip()
515
533
 
516
534
 
517
535
  def get_github_repo_url(args, repository):
@@ -666,7 +684,7 @@ def _get_response(request, auth, template):
666
684
  while True:
667
685
  should_continue = False
668
686
  try:
669
- r = urlopen(request)
687
+ r = urlopen(request, context=https_ctx)
670
688
  except HTTPError as exc:
671
689
  errors, should_continue = _request_http_error(exc, auth, errors) # noqa
672
690
  r = exc
@@ -782,13 +800,15 @@ def download_file(url, path, auth, as_app=False, fine=False):
782
800
  if os.path.exists(path):
783
801
  return
784
802
 
785
- request = _construct_request(per_page=100,
786
- page=1,
787
- query_args={},
788
- template=url,
789
- auth=auth,
790
- as_app=as_app,
791
- fine=fine)
803
+ request = _construct_request(
804
+ per_page=100,
805
+ page=1,
806
+ query_args={},
807
+ template=url,
808
+ auth=auth,
809
+ as_app=as_app,
810
+ fine=fine,
811
+ )
792
812
  request.add_header("Accept", "application/octet-stream")
793
813
  opener = build_opener(S3HTTPRedirectHandler)
794
814
 
@@ -931,11 +951,15 @@ def filter_repositories(args, unfiltered_repositories):
931
951
  if r.get("language") and r.get("language").lower() in languages
932
952
  ] # noqa
933
953
  if name_regex:
934
- repositories = [r for r in repositories if name_regex.match(r["name"])]
954
+ repositories = [
955
+ r for r in repositories if "name" not in r or name_regex.match(r["name"])
956
+ ]
935
957
  if args.skip_archived:
936
958
  repositories = [r for r in repositories if not r.get("archived")]
937
959
  if args.exclude:
938
- repositories = [r for r in repositories if r["name"] not in args.exclude]
960
+ repositories = [
961
+ r for r in repositories if "name" not in r or r["name"] not in args.exclude
962
+ ]
939
963
 
940
964
  return repositories
941
965
 
@@ -1231,10 +1255,16 @@ def backup_releases(args, repo_cwd, repository, repos_template, include_assets=F
1231
1255
  if args.skip_prerelease:
1232
1256
  releases = [r for r in releases if not r["prerelease"] and not r["draft"]]
1233
1257
 
1234
- if args.number_of_latest_releases and args.number_of_latest_releases < len(releases):
1235
- releases.sort(key=lambda item: datetime.strptime(item["created_at"], "%Y-%m-%dT%H:%M:%SZ"),
1236
- reverse=True)
1237
- releases = releases[:args.number_of_latest_releases]
1258
+ if args.number_of_latest_releases and args.number_of_latest_releases < len(
1259
+ releases
1260
+ ):
1261
+ releases.sort(
1262
+ key=lambda item: datetime.strptime(
1263
+ item["created_at"], "%Y-%m-%dT%H:%M:%SZ"
1264
+ ),
1265
+ reverse=True,
1266
+ )
1267
+ releases = releases[: args.number_of_latest_releases]
1238
1268
  logger.info("Saving the latest {0} releases to disk".format(len(releases)))
1239
1269
  else:
1240
1270
  logger.info("Saving {0} releases to disk".format(len(releases)))
@@ -1261,7 +1291,7 @@ def backup_releases(args, repo_cwd, repository, repos_template, include_assets=F
1261
1291
  os.path.join(release_assets_cwd, asset["name"]),
1262
1292
  get_auth(args, encode=not args.as_app),
1263
1293
  as_app=args.as_app,
1264
- fine=True if args.token_fine is not None else False
1294
+ fine=True if args.token_fine is not None else False,
1265
1295
  )
1266
1296
 
1267
1297
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: github-backup
3
- Version: 0.46.0
3
+ Version: 0.48.0
4
4
  Summary: backup a github user or organization
5
5
  Home-page: http://github.com/josegonzalez/python-github-backup
6
6
  Author: Jose Diaz-Gonzalez
@@ -186,7 +186,7 @@ Customise the permissions for your use case, but for a personal account full bac
186
186
 
187
187
  **User permissions**: Read access to followers, starring, and watching.
188
188
 
189
- **Repository permissions**: Read access to code, commit statuses, issues, metadata, pages, pull requests, and repository hooks.
189
+ **Repository permissions**: Read access to contents, issues, metadata, pull requests, and webhooks.
190
190
 
191
191
 
192
192
  Prefer SSH
@@ -244,7 +244,7 @@ Gotchas / Known-issues
244
244
  All is not everything
245
245
  ---------------------
246
246
 
247
- The ``--all`` argument does not include; cloning private repos (``-P, --private``), cloning forks (``-F, --fork``) cloning starred repositories (``--all-starred``), ``--pull-details``, cloning LFS repositories (``--lfs``), cloning gists (``--starred-gists``) or cloning starred gist repos (``--starred-gists``). See examples for more.
247
+ The ``--all`` argument does not include: cloning private repos (``-P, --private``), cloning forks (``-F, --fork``), cloning starred repositories (``--all-starred``), ``--pull-details``, cloning LFS repositories (``--lfs``), cloning gists (``--gists``) or cloning starred gist repos (``--starred-gists``). See examples for more.
248
248
 
249
249
  Cloning all starred size
250
250
  ------------------------
@@ -273,12 +273,6 @@ It's therefore recommended to only use the incremental argument if the output/re
273
273
 
274
274
  This is due to needing the correct permission for ``--hooks`` on public repos.
275
275
 
276
- 2. **Releases blocking**
277
-
278
- A known ``--releases`` (required for ``--assets``) error will sometimes block the backup.
279
-
280
- If you're backing up a lot of repositories with releases e.g. an organisation or ``--all-starred``. You may need to remove ``--releases`` (and therefore ``--assets``) to complete a backup. Documented in `issue 209 <https://github.com/josegonzalez/python-github-backup/issues/209>`_.
281
-
282
276
 
283
277
  "bare" is actually "mirror"
284
278
  ---------------------------
@@ -0,0 +1,9 @@
1
+ github_backup/__init__.py,sha256=bkYe4lEQZCEmFm0XRZaZkxTV1niMqR_lbp-tzKL6s6c,23
2
+ github_backup/github_backup.py,sha256=ELVxSHe9i0UzDqaPx3tC7sdDnEClI_nnkJUm51qPPWE,48657
3
+ github_backup-0.48.0.data/scripts/github-backup,sha256=I79TNA67phytRmI9nm_LlD9h2zauXFOsOn9tYyAy9pU,1546
4
+ github_backup-0.48.0.dist-info/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
5
+ github_backup-0.48.0.dist-info/METADATA,sha256=sMZG88IfiXq7Zg_ae6M4DIWYezMrw_BJJQSTHQXOifA,18847
6
+ github_backup-0.48.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
7
+ github_backup-0.48.0.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
8
+ github_backup-0.48.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
+ github_backup-0.48.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,9 +0,0 @@
1
- github_backup/__init__.py,sha256=VTDTPpzZ6KwzjCPZhHgalFxPlpuy4ZGRkHB_n3WGwYs,23
2
- github_backup/github_backup.py,sha256=EVF5gspuh6HZ7DIN4exIBZ4HO4lzBvLyAavlP1luWN4,48176
3
- github_backup-0.46.0.data/scripts/github-backup,sha256=I79TNA67phytRmI9nm_LlD9h2zauXFOsOn9tYyAy9pU,1546
4
- github_backup-0.46.0.dist-info/LICENSE.txt,sha256=ML-pLyn1qtAKo_DHMcQ8-p7k3f8cp-IR-mf5B49R2rk,1085
5
- github_backup-0.46.0.dist-info/METADATA,sha256=2ZUxBjhvUTKFFfjzbtw-ugrUKaMNoWyx28HtcVveymA,19290
6
- github_backup-0.46.0.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
7
- github_backup-0.46.0.dist-info/top_level.txt,sha256=Za6fKRAlxZ0b3ZBH_osPqklLe14LetdNAkvAQANT2AA,14
8
- github_backup-0.46.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
- github_backup-0.46.0.dist-info/RECORD,,