summaryrefslogtreecommitdiff
path: root/crocoite/tools.py
diff options
context:
space:
mode:
Diffstat (limited to 'crocoite/tools.py')
-rw-r--r--crocoite/tools.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/crocoite/tools.py b/crocoite/tools.py
index 84c6f44..9c5d836 100644
--- a/crocoite/tools.py
+++ b/crocoite/tools.py
@@ -67,7 +67,7 @@ def mergeWarc (files, output):
'id': rid, 'date': headers.get_header('WARC-Date')}
unique += 1
else:
- logging.debug ('Record {} is duplicate of {}'.format (rid, dup['id']))
+ logging.debug (f'Record {rid} is duplicate of {dup["id"]}')
# Payload may be identical, but HTTP headers are
# (probably) not. Include them.
record = writer.create_revisit_record (
@@ -80,7 +80,7 @@ def mergeWarc (files, output):
else:
unique += 1
writer.write_record (record)
- logging.info ('Wrote {} unique records, {} revisits'.format (unique, revisit))
+ logging.info (f'Wrote {unique} unique records, {revisit} revisits')
def mergeWarcCli():
parser = argparse.ArgumentParser(description='Merge WARCs, reads filenames from stdin.')
@@ -116,12 +116,12 @@ def extractScreenshot ():
urlSanitized = headers.get_header('WARC-Target-URI').replace ('/', '_')
xoff = 0
yoff = int (headers.get_header ('X-Crocoite-Screenshot-Y-Offset'))
- outpath = '{}-{}-{}-{}.png'.format (args.prefix, urlSanitized, xoff, yoff)
+ outpath = f'{args.prefix}-{urlSanitized}-{xoff}-{yoff}.png'
if args.force or not os.path.exists (outpath):
with open (outpath, 'wb') as out:
shutil.copyfileobj (record.raw_stream, out)
else:
- print ('not overwriting {}'.format (outpath))
+ print (f'not overwriting {outputh}')
class Errata:
__slots__ = ('uuid', 'description', 'affects')
@@ -145,8 +145,7 @@ class Errata:
return all (matchedAll)
def __repr__ (self):
- return '{}({!r}, {!r}, {!r})'.format (self.__class__.__name__,
- self.uuid, self.description, self.affects)
+ return f'{self.__class__.__name__}({self.uuid!r}, {self.description!r}, {self.affects!r})'
@property
def fixable (self):
@@ -180,7 +179,7 @@ def makeReport (fd):
pass
def errata ():
- parser = argparse.ArgumentParser(description='Show/fix erratas for WARCs generated by {}.'.format (__package__))
+ parser = argparse.ArgumentParser(description=f'Show/fix erratas for WARCs generated by {__package__}.')
parser.add_argument('input', type=argparse.FileType ('rb'), help='Input WARC')
args = parser.parse_args()