pywaybackup 1.2.5__tar.gz → 1.3.0__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 (30) hide show
  1. pywaybackup-1.3.0/.github/ISSUE_TEMPLATE/bug.md +25 -0
  2. pywaybackup-1.3.0/.gitignore +164 -0
  3. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/PKG-INFO +7 -2
  4. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/README.md +4 -0
  5. pywaybackup-1.3.0/dev/pip_build.sh +16 -0
  6. pywaybackup-1.3.0/dev/venv_create.sh +17 -0
  7. pywaybackup-1.3.0/pywaybackup/__version__.py +1 -0
  8. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/archive.py +20 -12
  9. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/arguments.py +3 -0
  10. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/main.py +12 -5
  11. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup.egg-info/PKG-INFO +7 -2
  12. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup.egg-info/SOURCES.txt +9 -1
  13. pywaybackup-1.3.0/pywaybackup.egg-info/requires.txt +8 -0
  14. pywaybackup-1.3.0/requirements.txt +4 -0
  15. pywaybackup-1.3.0/test/cdx.example.com.200 +2851 -0
  16. pywaybackup-1.3.0/test/cdx.example.com.404 +9163 -0
  17. pywaybackup-1.3.0/test/cdx.example.com.small.200 +46 -0
  18. pywaybackup-1.2.5/pywaybackup/__version__.py +0 -1
  19. pywaybackup-1.2.5/pywaybackup.egg-info/requires.txt +0 -3
  20. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/LICENSE +0 -0
  21. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/Exception.py +0 -0
  22. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/SnapshotCollection.py +0 -0
  23. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/Verbosity.py +0 -0
  24. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/__init__.py +0 -0
  25. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup/helper.py +0 -0
  26. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup.egg-info/dependency_links.txt +0 -0
  27. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup.egg-info/entry_points.txt +0 -0
  28. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/pywaybackup.egg-info/top_level.txt +0 -0
  29. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/setup.cfg +0 -0
  30. {pywaybackup-1.2.5 → pywaybackup-1.3.0}/setup.py +0 -0
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: Bug
3
+ about: Describe a faulty behavior
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe**
11
+ Describe the bug / unexpected event
12
+
13
+ **Snapshot to reproduce**
14
+ <a href="https://example.com">If possible add a link to the snapshot which caused the error.</a>
15
+
16
+ **Command to reproduce**
17
+ `Add the used command`
18
+
19
+ **Terminal output**
20
+ ```
21
+ Insert exception / output if possible - remove private folders / files
22
+ ```
23
+
24
+ **Additional context**
25
+ Add any other context about the problem here.
@@ -0,0 +1,164 @@
1
+ waybackup_snapshots/
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ build/
14
+ develop-eggs/
15
+ dist/
16
+ downloads/
17
+ eggs/
18
+ .eggs/
19
+ lib/
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py,cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # poetry
100
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104
+ #poetry.lock
105
+
106
+ # pdm
107
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108
+ #pdm.lock
109
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110
+ # in version control.
111
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
112
+ .pdm.toml
113
+ .pdm-python
114
+ .pdm-build/
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
152
+
153
+ # pytype static type analyzer
154
+ .pytype/
155
+
156
+ # Cython debug symbols
157
+ cython_debug/
158
+
159
+ # PyCharm
160
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
163
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
+ #.idea/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pywaybackup
3
- Version: 1.2.5
3
+ Version: 1.3.0
4
4
  Summary: Download snapshots from the Wayback Machine
5
5
  Home-page: https://github.com/bitdruid/python-wayback-machine-downloader
6
6
  Author: bitdruid
@@ -11,7 +11,8 @@ Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: requests==2.31.0
13
13
  Requires-Dist: tqdm==4.66.2
14
- Requires-Dist: python-magic==0.4.27
14
+ Requires-Dist: python-magic==0.4.27; sys_platform == "linux"
15
+ Requires-Dist: python-magic-bin==0.4.14; sys_platform == "win32"
15
16
 
16
17
  # python wayback machine downloader
17
18
 
@@ -101,6 +102,10 @@ Path defaults to output-dir. Saves the result of CDX query as a file. Useful for
101
102
  - **`--cdxinject`** `<filepath>`:<br>
102
103
  Injects a CDX query file to download snapshots. Ensure the query matches the previous `--url` for correct folder structure.
103
104
 
105
+ **Auto:**
106
+ - **`--auto`**:<br>
107
+ If set, csv, skip and cdxbackup/cdxinject are handled automatically. Keep the files and folders as they are. Otherwise they will not be recognized when restarting a download.
108
+
104
109
  ### Debug
105
110
 
106
111
  - `--debug`: If set, full traceback will be printed in case of an error. The full exception will be written into `waybackup_error.log`.
@@ -86,6 +86,10 @@ Path defaults to output-dir. Saves the result of CDX query as a file. Useful for
86
86
  - **`--cdxinject`** `<filepath>`:<br>
87
87
  Injects a CDX query file to download snapshots. Ensure the query matches the previous `--url` for correct folder structure.
88
88
 
89
+ **Auto:**
90
+ - **`--auto`**:<br>
91
+ If set, csv, skip and cdxbackup/cdxinject are handled automatically. Keep the files and folders as they are. Otherwise they will not be recognized when restarting a download.
92
+
89
93
  ### Debug
90
94
 
91
95
  - `--debug`: If set, full traceback will be printed in case of an error. The full exception will be written into `waybackup_error.log`.
@@ -0,0 +1,16 @@
1
+ #!bin/bash
2
+
3
+ # path of the script
4
+ SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5
+ TARGET_PATH="$SCRIPT_PATH/.."
6
+
7
+ # install dependencies
8
+ pip install twine wheel setuptools
9
+
10
+ # build
11
+ python $TARGET_PATH/setup.py sdist bdist_wheel --verbose
12
+ python -m twine upload dist/*
13
+ #pip install -e $TARGET_PATH
14
+
15
+ # clean up
16
+ rm -rf $TARGET_PATH/build $TARGET_PATH/dist # $TARGET_PATH/*.egg-info
@@ -0,0 +1,17 @@
1
+ #!bin/bash
2
+
3
+ # path of the script
4
+ SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5
+ TARGET_PATH="$SCRIPT_PATH/.."
6
+ echo "Preparing virtual environment in $TARGET_PATH"
7
+ # Create a virtual environment
8
+ if [ ! -d "..$SCRIPT_PATH/.venv" ]; then
9
+ python3 -m venv "$TARGET_PATH/.venv"
10
+ fi
11
+
12
+ # update pip
13
+ "$TARGET_PATH/.venv/bin/python" -m pip install --upgrade pip
14
+ "$TARGET_PATH/.venv/bin/python" -m pip install twine wheel setuptools
15
+
16
+ # install requirements
17
+ "$TARGET_PATH/.venv/bin/python" -m pip install -r "$TARGET_PATH/requirements.txt"
@@ -0,0 +1 @@
1
+ __version__ = "1.3.0"
@@ -97,26 +97,28 @@ def print_list():
97
97
  # create filelist
98
98
  # timestamp format yyyyMMddhhmmss
99
99
  def query_list(url: str, range: int, start: int, end: int, explicit: bool, mode: str, cdxbackup: str, cdxinject: str):
100
- if cdxinject:
101
- try:
100
+
101
+ def inject(cdxinject):
102
+ if os.path.isfile(cdxinject):
102
103
  vb.write("\nInjecting CDX data...")
103
104
  cdxResult = open(cdxinject, "r")
104
105
  cdxResult = cdxResult.read()
105
- vb.write(f"\n-----> {len(cdxResult)} snapshots injected")
106
- except FileNotFoundError as e:
107
- vb.write("\nFILE NOT FOUND -> could not inject CDX data")
108
- os._exit(1)
109
- else:
106
+ linecount = cdxResult.count("\n") - 1
107
+ vb.write(f"\n-----> {linecount} snapshots injected")
108
+ return cdxResult
109
+ else:
110
+ vb.write("\nNo CDX file found to inject - querying snapshots...")
111
+ return False
112
+
113
+ def query(url, range, start, end, explicit):
110
114
  vb.write("\nQuerying snapshots...")
111
115
  query_range = ""
112
-
113
116
  if not range:
114
117
  if start: query_range = query_range + f"&from={start}"
115
118
  if end: query_range = query_range + f"&to={end}"
116
119
  else:
117
120
  query_range = "&from=" + str(datetime.now().year - range)
118
121
 
119
- # parse user input url and create according cdx url
120
122
  domain, subdir, filename = url_split(url)
121
123
  if domain and not subdir and not filename:
122
124
  cdx_url = f"*.{domain}/*" if not explicit else f"{domain}"
@@ -142,6 +144,12 @@ def query_list(url: str, range: int, start: int, end: int, explicit: bool, mode:
142
144
  file.write(cdxResult)
143
145
  vb.write("\n-----> CDX backup generated")
144
146
 
147
+ return cdxResult
148
+
149
+ if cdxinject:
150
+ cdxResult = inject(cdxinject)
151
+ if not cdxResult:
152
+ cdxResult = query(url, range, start, end, explicit)
145
153
  cdxResult = json.loads(cdxResult)
146
154
  sc.create_list(cdxResult, mode)
147
155
  vb.write(f"\n-----> {sc.count(collection=True)} snapshots to utilize")
@@ -382,15 +390,15 @@ def csv_close(csv_path: str, url: str):
382
390
  if sc.count(collection=True) > 0:
383
391
  if os.path.exists(csv_path): # append to existing file
384
392
  existing_rows = set()
385
- with open(csv_path, mode='r') as file: # read existing rows
393
+ with open(csv_path, mode='r', newline='') as file: # read existing rows
386
394
  existing_rows = set(csv_read(file))
387
- with open(csv_path, mode='a') as file: # append new rows
395
+ with open(csv_path, mode='a', newline='') as file: # append new rows
388
396
  row = csv.DictWriter(file, sc.SNAPSHOT_COLLECTION[0].keys())
389
397
  for snapshot in sc.SNAPSHOT_COLLECTION:
390
398
  if snapshot["response"] is not False and snapshot["url_archive"] not in existing_rows: # only append handled snapshots
391
399
  row.writerow(snapshot)
392
400
  else: # create new file
393
- with open(csv_path, mode='w') as file:
401
+ with open(csv_path, mode='w', newline='') as file:
394
402
  row = csv.DictWriter(file, sc.SNAPSHOT_COLLECTION[0].keys())
395
403
  row.writeheader()
396
404
  for snapshot in sc.SNAPSHOT_COLLECTION:
@@ -36,6 +36,9 @@ def parse():
36
36
  exclusive_cdx.add_argument('--cdxbackup', type=str, nargs='?', const=True, metavar='path', help='Save the cdx query-result to a file for recurent use - defaults to output folder')
37
37
  exclusive_cdx.add_argument('--cdxinject', type=str, nargs='?', const=True, metavar='path', help='Inject a cdx backup-file to download according to the given url')
38
38
 
39
+ auto = parser.add_argument_group('auto')
40
+ auto.add_argument('--auto', action='store_true', help='includes automatic csv, skip and cdxbackup/cdxinject to resume a stopped download')
41
+
39
42
  args = parser.parse_args(args=None if sys.argv[1:] else ['--help']) # if no arguments are given, print help
40
43
  command = ' '.join(sys.argv[1:])
41
44
 
@@ -2,6 +2,7 @@ import os
2
2
 
3
3
  import signal
4
4
 
5
+ import pywaybackup.helper as helper
5
6
  import pywaybackup.archive as archive
6
7
 
7
8
  from pywaybackup.arguments import parse
@@ -25,14 +26,20 @@ def main():
25
26
  if args.current:
26
27
  mode = "current"
27
28
 
28
- if args.skip is True:
29
+ if args.auto:
29
30
  args.skip = args.output
30
- if args.csv is True:
31
31
  args.csv = args.output
32
- if args.cdxbackup is True:
33
32
  args.cdxbackup = args.output
34
- if args.cdxinject is True:
35
- args.cdxinject = args.output
33
+ args.cdxinject = os.path.join(args.output, f"waybackup_{helper.sanitize_filename(args.url)}.cdx")
34
+ else:
35
+ if args.skip is True:
36
+ args.skip = args.output
37
+ if args.csv is True:
38
+ args.csv = args.output
39
+ if args.cdxbackup is True:
40
+ args.cdxbackup = args.output
41
+ if args.cdxinject is True:
42
+ args.cdxinject = args.output
36
43
 
37
44
  if args.save:
38
45
  archive.save_page(args.url)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pywaybackup
3
- Version: 1.2.5
3
+ Version: 1.3.0
4
4
  Summary: Download snapshots from the Wayback Machine
5
5
  Home-page: https://github.com/bitdruid/python-wayback-machine-downloader
6
6
  Author: bitdruid
@@ -11,7 +11,8 @@ Description-Content-Type: text/markdown
11
11
  License-File: LICENSE
12
12
  Requires-Dist: requests==2.31.0
13
13
  Requires-Dist: tqdm==4.66.2
14
- Requires-Dist: python-magic==0.4.27
14
+ Requires-Dist: python-magic==0.4.27; sys_platform == "linux"
15
+ Requires-Dist: python-magic-bin==0.4.14; sys_platform == "win32"
15
16
 
16
17
  # python wayback machine downloader
17
18
 
@@ -101,6 +102,10 @@ Path defaults to output-dir. Saves the result of CDX query as a file. Useful for
101
102
  - **`--cdxinject`** `<filepath>`:<br>
102
103
  Injects a CDX query file to download snapshots. Ensure the query matches the previous `--url` for correct folder structure.
103
104
 
105
+ **Auto:**
106
+ - **`--auto`**:<br>
107
+ If set, csv, skip and cdxbackup/cdxinject are handled automatically. Keep the files and folders as they are. Otherwise they will not be recognized when restarting a download.
108
+
104
109
  ### Debug
105
110
 
106
111
  - `--debug`: If set, full traceback will be printed in case of an error. The full exception will be written into `waybackup_error.log`.
@@ -1,6 +1,11 @@
1
+ .gitignore
1
2
  LICENSE
2
3
  README.md
4
+ requirements.txt
3
5
  setup.py
6
+ .github/ISSUE_TEMPLATE/bug.md
7
+ dev/pip_build.sh
8
+ dev/venv_create.sh
4
9
  pywaybackup/Exception.py
5
10
  pywaybackup/SnapshotCollection.py
6
11
  pywaybackup/Verbosity.py
@@ -15,4 +20,7 @@ pywaybackup.egg-info/SOURCES.txt
15
20
  pywaybackup.egg-info/dependency_links.txt
16
21
  pywaybackup.egg-info/entry_points.txt
17
22
  pywaybackup.egg-info/requires.txt
18
- pywaybackup.egg-info/top_level.txt
23
+ pywaybackup.egg-info/top_level.txt
24
+ test/cdx.example.com.200
25
+ test/cdx.example.com.404
26
+ test/cdx.example.com.small.200
@@ -0,0 +1,8 @@
1
+ requests==2.31.0
2
+ tqdm==4.66.2
3
+
4
+ [:sys_platform == "linux"]
5
+ python-magic==0.4.27
6
+
7
+ [:sys_platform == "win32"]
8
+ python-magic-bin==0.4.14
@@ -0,0 +1,4 @@
1
+ requests==2.31.0
2
+ tqdm==4.66.2
3
+ python-magic==0.4.27; sys_platform == 'linux'
4
+ python-magic-bin==0.4.14; sys_platform == 'win32'