Exemple #1
0
    def determine_version(self, bundle, env, hunk=None):
        if not hunk:
            if not has_placeholder(bundle.output):
                hunk = FileHunk(bundle.resolve_output(env))
            else:
                # Can cannot determine the version of placeholder files.
                raise VersionIndeterminableError(
                    'output target has a placeholder')

        hasher = self.hasher()
        hasher.update(hunk.data())
        return hasher.hexdigest()[:self.length]
Exemple #2
0
    def determine_version(self, bundle, env, hunk=None):
        if not hunk:
            if not has_placeholder(bundle.output):
                hunk = FileHunk(bundle.resolve_output(env))
            else:
                # Can cannot determine the version of placeholder files.
                raise VersionIndeterminableError(
                    'output target has a placeholder')

        hasher = self.hasher()
        hasher.update(hunk.data())
        return hasher.hexdigest()[:self.length]
Exemple #3
0
    def determine_version(self, bundle, ctx, hunk=None):
        if not hunk:
            from webassets.bundle import has_placeholder
            if not has_placeholder(bundle.output):
                hunk = FileHunk(bundle.resolve_output(ctx))
            else:
                # Can cannot determine the version of placeholder files.
                raise VersionIndeterminableError(
                    'output target has a placeholder')

        hasher = self.hasher()
        hasher.update(hunk.data().encode('utf-8'))
        return hasher.hexdigest()[:self.length]
Exemple #4
0
    def determine_version(self, bundle, ctx, hunk=None):
        if not hunk:
            from webassets.bundle import has_placeholder
            if not has_placeholder(bundle.output):
                hunk = FileHunk(bundle.resolve_output(ctx))
            else:
                # Can cannot determine the version of placeholder files.
                raise VersionIndeterminableError(
                    'output target has a placeholder')

        hasher = self.hasher()
        hasher.update(hunk.data().encode('utf-8'))
        return hasher.hexdigest()[:self.length]
css_assets = Bundle(
    "normalize.css",
    "skeleton.css",
    "custom.css",
    filters="cssmin",
    output="packed.min.%(version)s.css",
)

assets = Environment(app)
assets.manifest = "json"
assets.register("css_all", css_assets)

if not app.config["ASSETS_DEBUG"]:
    css = FileHunk(css_assets.resolve_output())
    app.jinja_env.globals["css_assets_built"] = css.data()

db_client = DynamoDBClient(app.config.get("DYNAMODB_TABLE"))


def initialise_sentry():
    global sentry_initialised
    if os.environ.get("SENTRY_DSN", "") and not sentry_initialised:
        sentry_sdk.init(
            os.environ.get("SENTRY_DSN"),
            integrations=[
                AwsLambdaIntegration(),
                FlaskIntegration(),
                AioHttpIntegration(),
            ],
            traces_sample_rate=0.01,
Exemple #6
0
 def test_read_binary_file_hunk(self):
     h = FileHunk(self.path(self.name))
     d = h.data() 
     assert isinstance(d, str)
     assert d == self.BINARY_DATA