decorator

Now.sh build breaking due to: Support for the experimental syntax 'decorators-legacy' isn't currently enabled

大城市里の小女人 提交于 2019-12-13 03:55:56
问题 Expected: After adding decko (Support for decorators) as well as adding support for experimetalDecoractors in my tsconfig.js and using @babel/plugin-proposal-decorators in package.json . My now.sh build should build and deploy fine after creating a PR, also since the app is running perfectly locally. Results: The build actually breaks with the following error: Support for the experimental syntax 'decorators-legacy' isn't currently enabled PR: https://github.com/Futuratum/moonholdings.io/pull

Design pattern appropriate for a modular feature matching application?

本小妞迷上赌 提交于 2019-12-13 03:48:30
问题 Since I got some negative comments on my system design on this question (concerning the implementation of such system), I hope that if I present the problem I could get some better suggestions. I am trying to design a modular application to be used for feature matching in video frames (e.g. matching on very close frames of a movie or a video, like "the product" in this article by Sivic, Zisserman). The idea is to allow for an easy switch between different feature detection algorithms as well

what does decorators in angular2 do in components?

南楼画角 提交于 2019-12-13 02:49:43
问题 What is the use of the decorators in angular2 ? What does it do? like to annotate and modify classes and properties at design time. This sounds pretty much like what annotations do right? Could you explain this ? Thanks in advance. 回答1: It provides meta information for components, directives, pipes, and for dependency injection. They can be used by tools for linting and auto-completion and other design tools. Build tools will generate code (or HTML/CSS) from them. See also How are decorators

Generic type parameter inference priority in TypeScript

若如初见. 提交于 2019-12-13 01:56:12
问题 I have the following class decorator factory accepting an initializer function as its argument. In this initializer function I would like to return an instance corresponding to the involved class type (or that of a derived one): function JsonObject<T>(initializer: (json: any) => T) { return function (target: { new (...args: any[]): T }) { // ... } } @JsonObject(function (json) { return new Animal(); }) class Animal { name: string; } Returning an instance of the exact class (as above) works

Change HTML output of Zend_Form

血红的双手。 提交于 2019-12-13 01:38:08
问题 I'm trying to change the html outputted by Zend_Form using decorators. I want the outputted HTML to look like this: <form> <fieldset> <legend>Your Details</legend> <dl> <dt>label etc</dt> <dd>input etc</dd> <dt>label etc</dt> <dd>input etc</dd> </dl> </fieldset> <fieldset> <legend>Address Details</legend> <dl> <dt>label etc</dt> <dd>input etc</dd> <dt>label etc</dt> <dd>input etc</dd> ... etc ... </dl> </fieldset> </form> I've already broken the sections down i want within specific fieldsets

Get decorated function object by string name

浪尽此生 提交于 2019-12-13 00:55:25
问题 def log(func): def wraper(*a, **kw): return func(*a, **kw) return wraper @log def f(): print 'f' print locals()['f'] # - prints <function wraper at 0x00CBF3F0>. How do you get the real f object (not decorator wrap)? 回答1: You don't. 1 Store it if you need to access it later. def log(func): def wrapper(*a, **kw): return func(*a, **kw) wrapper.func = func return wrapper @log def f(): print 'f' print f.func 1 You could mess with the closure, but I can't recommend it. 回答2: The functools module

Python - Accessing parent class decorators inside class declaration

我与影子孤独终老i 提交于 2019-12-12 21:03:24
问题 Let's say I have this class: class Foo: @classmethod def some_decorator(cls, ...): ... And then I create a subclass which uses the parent class decorator: class Bar(Foo): @Foo.some_decorator(...) def some_function(...) ... How do I remove the need for Foo. before the decorator name? The below code doesn't work: class Bar(Foo): @some_decorator(...) def some_function(...) ... I believe this is possible, because the sly library does this. See their example: from sly import Lexer, Parser class

Conditionally apply login_required decorator in Django

纵饮孤独 提交于 2019-12-12 19:05:25
问题 I have a set of function in views.py which are currently only user-accessible. I'm asked to make it publicly accessible and currently I am using the @login_required decorator in my views. Is there a way to apply this decorator conditionally based on the object being served? For example, part of my views.py : @login_required def details(request, object_id): o = get_object_or_404(Model, pk=object_id) if o.user_id == request.user.pk: return render(request, 'app/details.html') else: return

How to unit test open generic decorator chains in SimpleInjector 2.6.1+

此生再无相见时 提交于 2019-12-12 15:28:16
问题 Given the following open generic deocrator chain using SimpleInjector: container.RegisterManyForOpenGeneric(typeof(IHandleQuery<,>), assemblies); container.RegisterDecorator( typeof(IHandleQuery<,>), typeof(ValidateQueryDecorator<,>) ); container.RegisterSingleDecorator( typeof(IHandleQuery<,>), typeof(QueryLifetimeScopeDecorator<,>) ); container.RegisterSingleDecorator( typeof(IHandleQuery<,>), typeof(QueryNotNullDecorator<,>) ); With SimpleInjector 2.4.0, I was able to unit test this to

Simple ES7 decorator with babel

人盡茶涼 提交于 2019-12-12 14:21:39
问题 I can not run this code: https://www.npmjs.com/package/core-decorators#readonly I use gulp and babel. I have package.json { "name": "my-first-decorator", "version": "0.0.1", "dependencies": { "core-decorators": "^0.8.1" }, "devDependencies": { "babel-plugin-transform-class-properties": "^6.0.14", "babel-plugin-transform-decorators": "^6.0.14", "babel-preset-es2015": "^6.1.2", "babelify": "^7.2.0", "browserify": "^12.0.1", "gulp": "^3.9.0", "vinyl-source-stream": "^1.1.0" } } and I have