Python black formatting in Foundry Code Repositories - palantir-foundry

Is there any way to automatically format code using the black library within Code Repositories? Is it possible to do so during development?
I have imported the black library, but I am not sure if I have to change the setup.py file in some capacity to enable the formatting.

I don't know about black, but if you want to have PEP8 styling in general you can enable that in your build.gradle file like this:
apply plugin: 'com.palantir.conda.pep8'
Here is a link to the documentation which is a little bit more in depth.

It's currently not possible. I have raised this(*) as a feature request last year to the dev team and hope they will consider to implement this. Please use your internal channels to raise this feature request with Palantir as well.
(*)
black auto formatting on save
pre-commit hook for auto-formatting
check that code is formatted in CI checks.

Related

Quartz Composer - Capture output of composition as input to another patch

I'm looking to see if there is a way to capture the entire output of a quartz composer scene, or it could even be a scene within a macro patch, and use it as the input to another patch that accepts an image. My use case is an image filter that overlays something dynamically generated based on the input image.
Yes, you can do it but not in QuartzComposer.app
To capture a video/audio/images from some QC patches you should use AVCaptureSession and AVCapturePhotoOutput classes from AVFoundation framework in Xcode. Then you can easily pass this data to another QC patches. Of course, you need to have a good knowledge of Swift or Obj-C.

How to setup limeJS in a totally offline workspace

I'm trying to setup limeJS, the issue is the Internet connection is a problem. I had closure library, box2d, closure compiler and closure templates downloaded separately as .rar files, but I can't find a guide anywhere to set it up like this, everyone just uses(and with reason!!!) the python bin/lime.py init command to get it working. I managed to figure out(yay!) how to setup box2d and closure library but what about the other two?
My laptop is running 64 bits Windows 7. Any help appreciated
All I need is an advice on directory structure, like where to drop the compiler.jar and soy templates .js files, so that when I run the update/create command it doesn't try to download the compiler or templates like it does right now.
I got it working, after taking a quick look at the lime.py file it told me everything I needed, for example both the SoyJs templates file and the compiler need to be in the /path/to/lime/bin/external folder and for example, the lime.py file was expecting a compiler file named compiler-dateOfLatestCompiler.jar instead of compiler.jar.
In general, If you have LimeJS built up in one machine using Python and all, you can just copy paste the whole package anywhere you want and use it just as ususal.
You don't need network once you have all the files/codes for Lime is downloaded.
Infact, you dont even need python for normal development tasks(Python is required to build your js file once you complete development though)

Uploading a file using TCL

I'm a newbie working on OpenACS architecture and need to upload a .xml file through TCL. I went through the documentation and tried to work around with the code mentioned here: http://wiki.tcl.tk/13675
However, I'm unable to understand the code and the copy-paste won't work. Could someone please suggest a easier working way to upload a file in TCL? A working code would be of great help.
I need to upload a file through a HTTP form(with input type file parameter) and I'm asking for server-side code.
OpenACS already has file uploading built in (assuming you're using the OpenACS form builder aka ad_form, template::form - it has many names!). The specific widget you need to use is template::widget::file
A worked example is in the General Comments package (see file-ae.adp, file-add.tcl and file-add-2.tcl):
http://cvs.openacs.org/browse/OpenACS/openacs-4/packages/general-comments/www/file-ae.adp?r=1.6
http://cvs.openacs.org/browse/OpenACS/openacs-4/packages/general-comments/www/file-add.tcl?r=1.4
http://cvs.openacs.org/browse/OpenACS/openacs-4/packages/general-comments/www/file-add-2.tcl?r=1.6
Specifically, look out for the 2 ad_page_contract parameters, and follow those variables down through the code:
upload_file:notnull
upload_file.tmpfile:tmpfile
Re-inventing network protocols is not so much worth in most cases, so I'd like to recommend using proven community libs. From my personal experience, I'm pretty glad to deal with libcurl (see http://curl.haxx.se/libcurl/tcl)

How can I over-ride the default code formatting policy in MonoDevelop?

MonoDevelop allows creation and installation of custom policies to control all aspects of code formatting. I have created a policy for our work site, which can be applied via Project > Apply Policy ...
We are using the Unity game engine, which regularly regenerates the MonoDevelop solution, requiring each developer to re-apply the policy -- irritating and error-prone.
How can I make my policy file be the default for new MonoDevelop solutions?
Also, where is the information about the applied policy saved?
In the .sln file I see "$0.CSharpFormattingPolicy = $2", but this is unchanged after applying my custom policy. I have compared all the project files before and after applying the policy, and the only changes are (1) a .userprefs file is generated, but doesn't mention policies, and (2) various .pidb files are different, but this can't be where policy information goes??
I'm using the version of MonoDevelop that is integrated with Unity 3.5.2, which is MonoDevelop version 2.8.2 (on Windows 7). (Yes, 2.8.2 is a little out of date, and it's possible that Unity Technologies has made changes that are causing my issues.)
This is a year after the other answers, but none of the above works for unity, and this was near the top of the google search.
Here are the steps I had to follow to get formatting to work:
MonoDevelop->Tools->Custom Policies->Add Policy->New Policy
Edit the policy inside of the 'Custom Policies' window, making sure your policy is selected.
Project->Apply Policy->Apply Stock or Custom Policy Set (select your policy)->Apply
Goto Tools->Options->KeyBinding
Then goto Edit -> FormatDocument
Then assign your shortcut key and click on apply and use it in your document.
The default policy is applied to new solutions or solutions without policies. It can be edited in the Preferences/Options dialog, where it's mixed in with the user preferences: Tools->Options on Windows, MonoDevelop->Preferences on Mac. You can identify the policies because they have a "Policy" dropdown at the top of the panel that allows you to load from a named policy.
I spent like 30 minutes fixing this and finally figure it out.
In Windows:
Go to Project -> Assembly C-Sharp Options
Then change the Code Formatting from there!
Going to Project -> Solution Options does absolutely nothing
After a year of dealing with this, we wrote a Unity editor script that would watch the project files for changes, and when they changed, check the policy entries in the project (pretty simple XML to parse.) If they had deviated from our desired policy, we'd modify them and write them back out with the correct policy changes.
Another idea (we wanted to enforce a policy) would be do do the same thing, but just remove the policy entries from the project whenever they got updated, and then you'd never have project policies overriding what you set up at the tool level.

How do I disable code generation in my test plugin?

I have a couple of test files written in my DSL in my tests plugin/project. Most of the tests use inline multi-line strings and Xtend but in four cases, I need to test code which does some magic with URLs and the classpath, so I really need resources in the classpath for that.
Since loading the resources only works when the extension is correct, I can't give the files a fake extension.
Now my problem: My DSL also has a code generator. This means that eventually, I end up with a couple of generated files in places where I can't have them (they don't compile, for example, and one even contains an error to test error handling when information is split across several files).
I can't disable the Xtext nature because the tests project uses Xtend so for these files, I do need code generation.
Since the generator runs inside Eclipse (I have the DSL plugins installed for other projects), there is no way to override the code generator in Guice.
How can I disable the code generator in this case?
There is a simple way to achieve this:
Open the properties of your project
Expand the entry for your DSL
Select "Compiler"
Select "Enable project specific settings"
Disable/deselect "Compiler is activated" under "General"
If you don't have a properties entry for your DSL:
Add this fragment to your .mwe2 workflow file:
fragment = generator.GeneratorFragment {}
Regenerate your projects
Merge the new code from plugin.xml_gen into plugin.xml both in the base and the UI plugins.
The interesting parts are the two extension points org.eclipse.ui.preferencePages and org.eclipse.ui.propertyPages