Skip to content

Commit 5ba2cab

Browse files
committed
+custom-csv-path
1 parent cff8c6d commit 5ba2cab

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pywaybackup/archive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,15 @@ def parse_response_code(response_code: int):
256256
return RESPONSE_CODE_DICT[response_code]
257257
return "Unknown response code"
258258

259-
def save_csv(output: str):
259+
def save_csv(csv_path: str):
260260
"""
261261
Write a CSV file with the list of snapshots.
262262
"""
263263
import csv
264264
if sc.count_list() > 0:
265265
v.write("\nSaving CSV file...")
266-
os.makedirs(os.path.abspath(output), exist_ok=True)
267-
with open(os.path.join(output, "waybackup.csv"), mode='w') as file:
266+
os.makedirs(os.path.abspath(csv_path), exist_ok=True)
267+
with open(os.path.join(csv_path, "waybackup.csv"), mode='w') as file:
268268
row = csv.DictWriter(file, sc.SNAPSHOT_COLLECTION[0].keys())
269269
row.writeheader()
270270
for snapshot in sc.SNAPSHOT_COLLECTION:

pywaybackup/arguments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ def parse():
1616
optional = parser.add_argument_group('optional')
1717
optional.add_argument('-l', '--list', action='store_true', help='Only print snapshots (opt range in y)')
1818
optional.add_argument('-e', '--explicit', action='store_true', help='Search only for the explicit given url')
19-
optional.add_argument('-o', '--output', type=str, help='Output folder')
19+
optional.add_argument('-o', '--output', type=str, help='Output folder defaults to current directory')
2020
optional.add_argument('-r', '--range', type=int, help='Range in years to search')
2121
optional.add_argument('--start', type=int, help='Start timestamp format: YYYYMMDDhhmmss')
2222
optional.add_argument('--end', type=int, help='End timestamp format: YYYYMMDDhhmmss')
2323

2424
special = parser.add_argument_group('special')
25-
special.add_argument('--csv', action='store_true', help='Save a csv file with the list of snapshots inside the output folder')
25+
special.add_argument('--csv', type=str, nargs='?', const=True, help='Save a csv file on a given path or defaults to the output folder')
2626
special.add_argument('--no-redirect', action='store_true', help='Do not follow redirects by archive.org')
2727
special.add_argument('--verbosity', type=str, default="standard", choices=["standard", "progress", "json"], help='Verbosity level')
2828
special.add_argument('--retry', type=int, default=0, metavar="X-TIMES", help='Retry failed downloads (opt tries as int, else infinite)')

pywaybackup/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ def main():
1515

1616
if args.output is None:
1717
args.output = os.path.join(os.getcwd(), "waybackup_snapshots")
18+
if args.csv is True:
19+
args.csv = args.output
1820

1921
if args.save:
2022
archive.save_page(args.url)
@@ -25,7 +27,7 @@ def main():
2527
else:
2628
archive.download_list(args.output, args.retry, args.no_redirect, args.worker)
2729
if args.csv:
28-
archive.save_csv(args.output)
30+
archive.save_csv(args.csv)
2931
v.close()
3032

3133
if __name__ == "__main__":

0 commit comments

Comments
 (0)