Escaping module names with hyphen ceylon module descriptors - ceylon

How can I escape the hyphen in a ceylon module descriptor?
import com.fasterxml.jackson-core "2.8.4";
Edit:
In this case the jar are downloaded and included in the correct file hierarchy of the local ceylon repository ./repo . So, I expect that I can handle it like any other .car . Then, the only remaining problem is to escape the hyphen in the module name.

You can use quotes. Specifying the explicit maven: namespace is also recommended:
import maven:"com.fasterxml.jackson.core:jackson-core" "2.8.4";
See section 9.3.10. “Module descriptors” of the Ceylon language spec:
Note: quoted module names enable interoperation with Maven and other module repository systems whose module identifiers do not comply with the format specified for Ceylon module names.

As of Ceylon 1.3.2, the preferred syntax for this is to quote:
only the maven artifact id, since that is the bit that often has a dash in it, and
not the maven group id, since that is almost always a legal Ceylon module name.
So you would write:
import maven:com.fasterxml.jackson.core:"jackson-core" "2.8.8";
I'm assuming that this is the module you're trying to import.

Related

maven jaxb plugin, java packages generated has mis-match with XSD namespace

Background: I am trying to convert WSDL/XSD to Java classes
Issue: package names generated is mismatching with the namespace. Last part of number namespace is missing, below 02 is missing from package
XSD has - xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.02"
Java class generated - package iso.std.iso._20022.tech.xsd.pain_001_001;
Steps Taken:
I tried with 2 maven plugin, both gave me same results.
org.jvnet.jaxb2.maven2
maven-jaxb2-plugin
org.codehaus.mojo
jaxb2-maven-plugin
This works as designed. See Section D.5.2 of the JAXB Specification.
Step 2 says:
Remove the trailing file type, one of .?? or .??? or .html.
Apparently, .02 is considered to be the "trailing file type" here and is removed.
Consider using bindings to specify the target package.

How to use ceylon js (also with google closure compiler)

Calling a file resulting from the concatenation (bash: cat ... >> app.js) of the following three files:
/usr/share/ceylon/1.2.0/repo/ceylon/language/1.2.0/ceylon.language-1.2.0.js
modules/com/example/helloworld/1.0.0/com.example.helloworld-1.0.0-model.js
modules/com/example/helloworld/1.0.0/com.example.helloworld-1.0.0.js
with the command nodejs app.js does nothing. The same when used in a web page. How do have I to call that javascript program so that it runs without using require.js ?
Please give the rules how ceylon modules and the run function and other functions contained within translate to javascript and are to be called.
How can I get one javascript file from compilation of several ceylon modules without concatenating them manually or with require.js?
The above is without using google closure compiler.
Given the size of 1.6 MB of the language module, it makes no sense to run ceylon-js without using google closure compiler.
Compiling "ceylon.language-1.2.0.js" alone with google closure compiler results in a lot of warnings.
java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js /usr/share/ceylon/1.2.0/repo/ceylon/language/1.2.0/ceylon.language-1.2.0.js --js_output_file lib-compiled.js
How can I get rid of those warnings?
In what order do I have to chain together files resulting from ceylon-js with the model file and the language file to compile them in advanced mode with google closure compiler for dead code elimination.
These are 3 questions, really.
A Ceylon module is compiled to a CommonJS module. Concatenating the resulting files won't work because each file is on CommonJS format, which is a big function that returns an object with the exported declarations.
You can compile the modules with the --no-module option to get just the generated code, without it being wrapped in CommonJS format. For the language module, you can copy the file and just delete the first line and the last 5 lines.
I do not yet know how to get rid of the warnings you mention in the second question.
And as for the third question, I would recommend putting the language module first, then the rest of the files. If you have any toplevel declarations with the same name in different modules, you'll have conflicts (only the last declaration will remain), even if they're not shared, since they're all in the same module/unit.
Well, I think require.js can run the compilation of the modules to one file and then run the google-closure-compiler, see: http://www.requirejs.org/docs/optimization.html

Plone/SQLAlchemy(?) - How can I import a python package (i.e. sqlalchemy) in a module in a subpackage?

I am trying to import sqlalchemy in a module in a subpackage.
Here is my folder layout
PloneInstance
my.package
my
package
subpackage
In the buildout.cfg file of the root folder, I add "sqlalchemy" to the eggs.
In my.package, in configure.zcml, I add:
In the subpackage, I have a blank __init__.py file, a configure.zcml file, and a file called mymodule.py
In mymodule.py I have a line for importing sqlalchemy
import sqlalchemy
Unfortunately, I am getting an error when I try to run an instance:
ImportError: No module named sqlalchemy
I'm assuming I am missing a step. How do I properly import python packages?
Thank you in advance. I apologize if my terminology is off.
Edit:
The module in question I am importing from turned out to be zope.sqlalchemy.
I accidentally overlooked this because prior to moving files to a subpackage, the import statement for zope.sqlalchemy was working without adding zope.sqlalchemy to the eggs section of the buildout.
Look in the setup.py file at the top directory of your package. You'll find a section like:
install_requires=['setuptools',
# -*- Extra requirements: -*-
],
In place of the "Extra requirements' comment, put a comma-separated list of strings specifying your package's requirements. You may even specify versions.
Do not add standard Plone packages to the list. They're taken for granted.
Re-run buildout after specifying your requirements. The result is that the new install requires will be added to your Python environment when you start Plone.

Error when importing java class in jruby script

I want to use HermiT reasoner in my jruby script as described here http://hermit-reasoner.com/java.html. As described there I have to have HermiT.jar in my classpath. So I did require for jar file and also I want to import Reasoner class. My script looks like this:
require "java"
require "HermiT.jar"
java_import org.semanticweb.HermiT.Reasoner
But I get an error: Missig class or uppercase package name ('org.semanticweb.HermiT'). But 'org.semanticweb.HermiT' should be icluded in HermiT.jar... Is there any way how to find out what is really included in jar file and can you reproduce this problem? Thank you very much.
The problem is probably the name of package (because of capital letters?).
Everything is ok when I write package name with quotes:
java_import 'org.semanticweb.HermiT.Reasoner'

tcl - how to find the path of package loaded?

In tcl how does one find out the path of the package loaded?
% tclsh
% package require csv
I want to find out the path from which csv was loaded.
In python, one can find the path of a module using
>>> import os
>>> print os.__file__
'/a/b/python2.2.1/linux26_x86_64/lib/python2.2/os.pyc'
I am looking for a similar command in tcl
It's not that simple: a package in Tcl appears to be a more abstract thing than that in Python.
First, there are two kinds of packages: "classic" and "modules" which have different underlying mechanisms for finding what to load in response to the package require ... command.
Next, both kinds of packages are able to do whatever they wish to provide their functionality. It means they can be (but not limited to):
Pure Tcl packages, source'ing just one Tcl file or any number of files.
Packages implemented in C or another compiled language, which are in the form of dynamic library which gets loaded when the package is required.
A combination of the above, when there's a C library and a layer of Tcl code around it (usually providing helper/convenience commands).
Hence the question per se has little sense as only modules are represented by exactly one self-contained file but "classic" packages are free to implement themselves as they see fit.
On the other hand, each package normally provides (using one way or another) certain information to the package subsystem which can be retreived (and parsed) using the package ifneeded command. For instance, on my Windows system with ActiveState Tcl 8.5.x, I have:
% package require csv
0.7.2
% package ifneeded csv 0.7.2
package provide csv 0.7.2;source -encoding utf-8 {C:/Program Files/Tcl/lib/teapot/package/tcl/teapot/tcl8/8.3/csv-0.7.2.tm}
Note that what package ifneeded returns is just a Tcl script which is meant to be evaluated to get the package loaded, so parsing of this information is bound to be inherently ad-hoc and fragile.
For Tcl packages you can view list of all loadedable path dirs by command:
join $::auto_path \n
This manual addresses auto_path and other loadable library variables: https://www.systutorials.com/docs/linux/man/n-auto_path/
New or missing loadable package search directory can be added within tclsh:
lappend auto_path /new_directoty