mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
Merge pull request #198 from vbanos/subdir-prefix
New option --subdir-prefix
This commit is contained in:
commit
f7d4286b54
@ -91,6 +91,8 @@ def _build_arg_parser(prog='warcprox', show_hidden=False):
|
|||||||
help='where to store and load generated certificates')
|
help='where to store and load generated certificates')
|
||||||
arg_parser.add_argument('-d', '--dir', dest='directory',
|
arg_parser.add_argument('-d', '--dir', dest='directory',
|
||||||
default='./warcs', help='where to write warcs')
|
default='./warcs', help='where to write warcs')
|
||||||
|
arg_parser.add_argument('--subdir-prefix', dest='subdir_prefix', action='store_true',
|
||||||
|
help='write warcs to --dir subdir equal to the current warc-prefix'),
|
||||||
arg_parser.add_argument('--warc-filename', dest='warc_filename',
|
arg_parser.add_argument('--warc-filename', dest='warc_filename',
|
||||||
default='{prefix}-{timestamp17}-{serialno}-{randomtoken}',
|
default='{prefix}-{timestamp17}-{serialno}-{randomtoken}',
|
||||||
help='define custom WARC filename with variables {prefix}, {timestamp14}, {timestamp17}, {serialno}, {randomtoken}, {hostname}, {shorthostname}, {port}')
|
help='define custom WARC filename with variables {prefix}, {timestamp14}, {timestamp17}, {serialno}, {randomtoken}, {hostname}, {shorthostname}, {port}')
|
||||||
|
@ -55,7 +55,10 @@ class WarcWriter:
|
|||||||
self.open_suffix = '' if options.no_warc_open_suffix else '.open'
|
self.open_suffix = '' if options.no_warc_open_suffix else '.open'
|
||||||
self.rollover_size = options.rollover_size or 1000000000
|
self.rollover_size = options.rollover_size or 1000000000
|
||||||
self.rollover_idle_time = options.rollover_idle_time or None
|
self.rollover_idle_time = options.rollover_idle_time or None
|
||||||
self.directory = options.directory or './warcs'
|
if options.subdir_prefix and options.prefix:
|
||||||
|
self.directory = os.path.sep.join([options.directory, options.prefix]) or './warcs'
|
||||||
|
else:
|
||||||
|
self.directory = options.directory or './warcs'
|
||||||
self.filename_template = options.warc_filename or \
|
self.filename_template = options.warc_filename or \
|
||||||
'{prefix}-{timestamp17}-{randomtoken}-{serialno}'
|
'{prefix}-{timestamp17}-{randomtoken}-{serialno}'
|
||||||
self.last_activity = time.time()
|
self.last_activity = time.time()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user