igraph for python - igraph

I'm thoroughly confused about how to read/write into igraph's Python module. What I'm trying right now is:
g = igraph.read("football.gml")
g.write_svg("football.svg", g.layout_circle() )
I have a football.gml file, and this code runs and writes a file called football.svg. But when I try to open it using InkScape, I get an error message saying the file cannot be loaded. Is this the correct way to write the code? What could be going wrong?

The write_svg function is sort of deprecated; it was meant only as a quick hack to allow SVG exports from igraph even if you don't have the Cairo module for Python. It has not been maintained for a while so it could be the case that you hit a bug.
If you have the Cairo module for Python (on most Linux systems, you can simply install it from an appropriate package), you can simply do this:
igraph.plot(g, "football.svg", layout="circle")
This would use Cairo's SVG renderer, which is likely to generate the correct result. If you cannot install the Cairo module for Python for some reason, please file a bug report on https://bugs.launchpad.net/igraph so we can look into this.
(Even better, please file a bug report even if you managed to make it work using igraph.plot).

Couple years late, but maybe this will be helpful to somebody.
The write_svg function seems not to escape ampersands correctly. Texas A&M has an ampersand in its label -- InkScape is probably confused because it sees & rather than &. Just open football.svg in a text editor to fix that, and you should be golden!

Related

Simple html to pdf conversion commandline tool for automated file creation

I have a system that automatically creates and saves documents as html. For further storage they ought to be pdfs though.
I want to avoid having to do it manually so my preferred solution would be a small executable that I can call via command line, feed it with a source and output path (and ideally further parameters) and then let it do its magic. Something in concept like this:
exampleConverter.exe "C:\source\document1.html" "C:\convertedPDFs\document1.pdf"
No UI whatsoever, no human input, no popping up and closing console.
I looked through several options, but common problems I encountered were
the software not being free for commercial use
It just being a library of code, not a ready-to-go executable / code-base you just need to compile into one
The tool needing to get installed instead of being 'portable'
I'd like to avoid having to implement any modern libraries myself, partially for simple time concearns, partially because internally our code runs in a less than modern IE & VBS context so I for see compatibility problems.
Simply triggering a precompiled executable through a generic command line inerface that I can trigger from vbs seems like the perfect solution here.
Your Windows OS program code is almost there, why not reverse input and output (makes the task easier later), with a switch or two. you can embellish that with your for /? loop to run through the current working folder, just like any other program.
Your pseudo code
exampleConverter.exe --print-to-pdf="C:\convertedPDFs\document1.pdf" --headless "C:\source\document1.html"
Working Windows native code
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --print-to-pdf="%CD%\out\document1.pdf" --headless "%CD%\in\document1.html"
Other options are available
learn.microsoft.com suggest this working snippet to run edge with parameters
wscript vbsEdge.vbs
Dim shell
Set shell = WScript.CreateObject("WScript.Shell")
shell.Run "msedge https://www.google.com --hide-scrollbars --content-shell-hide-toolbar"
So just combine the program methods. However, you need to sort out your own arguments.
For greater control then you need to step-up to heavier custom isations https://blogs.windows.com/msedgedev/2015/07/23/bringing-automated-testing-to-microsoft-edge-through-webdriver/ etc.

Fatal error (13): No program entry point with XDS Modula-2?

I'm using the current bundled binaries from https://github.com/excelsior-oss/xds (as of 12/6/2020) with just the most basic Hello World MOD file:
MODULE HelloWorld;
FROM STextIO IMPORT WriteLn, WriteString;
BEGIN
WriteString("Hello, World!");
WriteLn;
END HelloWorld.
xc HelloWorld.mod works fine for compiling it to object. However, I'm not clear on the exact syntax for xlink on a standalone MOD file. xlink HelloWorld.obj will at least get it to try with my object file, but as the error shows, it doesn't know the entrypoint. I've tried setting the entry point with the /ENTRY switch, but no luck doing it by module name. I've also tried setting the /SYS to console, but again, no luck there.
I feel there's some trivial linker option or program directive needed, but I'm just not finding it via Google...
To build a binary, use: xc =a =make HelloWorld.mod
The above is found in https://github.com/excelsior-oss/xds/blob/master/Sources/Doc/Comp/src/usage.tex .
It is unfortunate that XDS did not put PDFs of their documentation on github. I suggest building the documentation from their LaTeX files.
Edit: I since learnt that the Wayback Machine has archived the XDS documentation here: https://web.archive.org/web/20060705213825/http://www.excelsior-usa.com/xdsdoc.html

'refactor' move files in VSCode - es6

If I move ComponentFoo.js from folder X to folder Y, than a bunch of import statements break. Looking into this it seems there are many solutions for typescript, but what about js / es6? If I move a file in the editor, it should find all the import statements and update them to the new location. Is this possible?
Old post, but this might help some Googlers. This feature can be enabled and disabled in User Settings. For Javascript and Typescript, it's called "Updated Imports On File Move".
I had apparently disabled it and just figured the feature was broken :X
VS Code has built-in support for this for both javascript and typescript since VS Code 1.24.
For JavaScript specifically, you need to make sure VS code's language support can find all the references to the file so that imports referring symbols in that can be updated properly. Definitely create a jsconfig.json for your project, and also consider enabling semantic checking for JavaScript so that VS Code shows when imports are not being properly resolved
If your project is configured properly but files are not being updated, make sure you are running the latest VS Code insiders build and report an issue if it still doesn't work
for flutter developers you should move files one by one. vscode doesn't support multi file moving with refactor yet.
Just use IntelliJ. It handles all kinds of refactoring perfectly. I'm a huge fan of VS Code, but refacotoring is definetly not one of it's stengths. Some imports don't get detected, and the imports can get modified in a weird way. For example, I had an import like this:
import { myStore} from 'src/common/stores/myStore';
When moving the file of myStore.ts to a different folder, VS Code constructed this bull**it:
import { myStore} from 'src/common/composables/myStoreStore';
The line above is no typo!
Btw I'm using vetur, maybe thats causing it, I don't know ...

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)