summaryrefslogtreecommitdiff
path: root/crocoite/behavior.py
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2019-07-02 09:14:55 +0200
committerLars-Dominik Braun <lars@6xq.net>2019-07-02 09:16:55 +0200
commit9ff793e96139ed40090ab9d8c3cae99b284858e5 (patch)
treee1b568fc77c0600a767fea1f541de1d5e85d87a5 /crocoite/behavior.py
parent9d8d48358bf44d7a3e4918bcdac3f4ef1348541b (diff)
downloadcrocoite-9ff793e96139ed40090ab9d8c3cae99b284858e5.tar.gz
crocoite-9ff793e96139ed40090ab9d8c3cae99b284858e5.tar.bz2
crocoite-9ff793e96139ed40090ab9d8c3cae99b284858e5.zip
Stabilize WARC headers
In preparation for 1.0 release: - Correct mime types - Add X-Crocoite-Type, so logs, scripts, dom-snapshots and screenshots can be identified easily - Remove random WARC headers like X-Chrome-Initiator. We don’t want to maintain those. - Remove non-standard urn-based package URLs. Can’t use them without a urn-registration
Diffstat (limited to 'crocoite/behavior.py')
-rw-r--r--crocoite/behavior.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/crocoite/behavior.py b/crocoite/behavior.py
index fd4d066..efb2ced 100644
--- a/crocoite/behavior.py
+++ b/crocoite/behavior.py
@@ -52,11 +52,12 @@ class Script:
""" A JavaScript resource """
__slots__ = ('path', 'data')
+ datadir = 'data'
def __init__ (self, path=None, encoding='utf-8'):
self.path = path
if path:
- self.data = pkg_resources.resource_string (__name__, os.path.join ('data', path)).decode (encoding)
+ self.data = pkg_resources.resource_string (__name__, os.path.join (self.datadir, path)).decode (encoding)
def __repr__ (self):
return f'<Script {self.path}>'
@@ -64,6 +65,11 @@ class Script:
def __str__ (self):
return self.data
+ @property
+ def abspath (self):
+ return pkg_resources.resource_filename (__name__,
+ os.path.join (self.datadir, self.path))
+
@classmethod
def fromStr (cls, data, path=None):
s = Script ()
@@ -140,7 +146,7 @@ class JsOnload (Behavior):
constructor = result['objectId']
if self.options:
- yield Script.fromStr (json.dumps (self.options, indent=2), f'{self.script.path}/options')
+ yield Script.fromStr (json.dumps (self.options, indent=2), f'{self.script.path}#options')
result = await tab.Runtime.callFunctionOn (
functionDeclaration='function(options){return new this(options);}',
objectId=constructor,