Why "error: invalid escape sequence?" - datetime

According to the valadoc
var now = new DateTime.now(new TimeZone.local());
var timestamp = now.format("\%F.\%T");
should set timestamp to "2012-08-28.09:51:06." Why "error: invalid escape sequence" on "F" and "T?" Other formats from the valadoc cause the same error and now.to_string() is in fact "2012-08-28T09:51:06+0000"
Edit: Perhaps embedded-linux target is missing something?
Edit: The test code here prints "(null)" in this project which uses glib 2.26.1.

As NullUserException mentioned, you shouldn't be including the backslashes--that is what is causing the invalid escape sequence error.
The reason it still doesn't work after removing the backslashes is that the %T format specifier wasn't added until the 2.30 cycle. The relevant commit is 414c8ce532c19fe65deb8dfb80222d0164be5cbe
You can work around it by doing something like this instead:
var timestamp = now.format ("%F.%H:%M:%S");

Related

CallFailed error on parse

I am a intern trying to write my first Syntax using Rascal.
While programming i ran into an error that my tutor, Riemer van Rozen, had never seen before. At the moment i am still trying to see if the problem is my code or a Rascal bug but i felt like i should report the error here.
The syntax used to parse normally and even after putting the code back the way it was before I added new stuff it still gives the same error.
My Syntax file
module Syntax
lexical Natural = [0-9]+ !>> [0-9] ;
lexical ID = [a-zA-Z][a-z0-9A-Z]* !>> [a-z0-9A-Z];
lexical String = "\"" ![\"]* "\"";
lexical Sym = [a-zA-Z.!##$%^&*];
lexical Mp = Sym*;
layout WhiteSpace = [\t-\n \r]* ;
start syntax CreatorData
= title: "title " ID title
| author: "author " ID author
| homepage: "homepage " ID homepage;
Parser
module Parser
import Syntax;
import AST;
import ParseTree;
public CreatorData load(str txt) = parse(#CreatorData, txt);
The Error
I hope someone can tell me where i am breaking my program or that i pointed out an unknown Rascal bug.
Call failed means that the call of parse failed, since the arguments you supplied, did not match any of the possible overloads of parse.
For your code, it looks like you also have an ADT called CreatorData. This is overlapping with the CreatorData syntax definition. There is a pattern documented in the tutor how to work around this challenge.
Not sure about your case, but often you can skip the ADT form, and just work on the concrete trees, but that might be something to explore in the future.

What does moment(testDate, "x") do?

I have the following piece of code before me:
var testDate = 1481103000000;
var enterTime = moment(testDate, "x");
console.log(enterTime);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.js"></script>
The variable enterTime results in a momentjs object with an additional _f property set to "x" and a _pf property of type object (see the console log) compared to a normal moment(testDate) object.
I couldn't find information on the _f or _pf properties anywhere.
Can anyone tell me what the "x" stands for and for what reason it is being used?
Thanks in advance.
With moment(testDate, "x"); you are creating a moment object using moment(String, String); function specifying x as format (Unix ms timestamp).
When you do moment(testDate), you are creating a moment object using moment(Number);.
All moment properties starting with _ are for internal use, _f stands for format, while _pf stand for Parsing Flags.
You can have a look to moment code to get more details about _f and _pf.
x denotes Unix ms timestamp
Please note that this parameter is case-sensitive:
X Output: 1410715640.579 Unix timestamp
x Output: 1410715640579 Unix ms timestamp
Refer here for all the options.

How to check if a substring exists inside a 'Result' object with Robot Framework?

I am running the following test inside Robot Framework:
*** Settings ***
Documentation This initializes testrun.robot
Library Process
Library OperatingSystem
Library XML
Library Collections
Output Is A Valid XML File Against JATS format
Start Process xmllint --dtdvalid http://jats.nlm.nih.gov/archiving/1.1d3/JATS-archivearticle1.dtd ./output/nlm/out.xml shell=True
${result}= Wait For Process timeout=45 secs
Log ${result.stdout}
Log ${result.stderr}
Run Keyword Unless '${result.stderr} == ${EMPTY}' Should Contain ${result.stderr} element xref: validity error : IDREFS attribute rid references an unknown
The variable ${result.stderr} is a string that contains the substring 'element xref: validity error : IDREFS attribute rid references an unknown'. As far as I know, I'm not dealing with any whitespace errors or quotation problems, although I could be wrong. (I've been fiddling around with that for a while now.)
Thanks for the help!
Edit: The log that Robot Framework generates tells me that the process has finished (that's how I know what result.stderr contains.)
Consider this statement:
Run Keyword Unless '${result.stderr} == ${EMPTY}' ...
The keyword will never run because you aren't comparing two variables, you are simply checking whether the string literal string '${result.stderr} == ${EMPTY}' is not empty (and it's not, because it has 28 characters).
It is the same as if you did this in python:
if len('${result.stderr} == ${EMPTY}') > 0:
...
You need to put the single quotes around each variable separately so that you are passing a valid expression to the if statement, rather than a string that looks like a valid expression:
Run Keyword Unless '${result.stderr}' == '${EMPTY}' ...

Warning whitelist doesn't work in Google closure compiler

The manual says I can use:
--warnings_whitelist_file VAL : A file containing warnings to
suppress. Each line should be of the
form
<file-name>:<line-number>? <warning-d
escription>
This is what my whitelist looks like:
ef-utils.js:1 Redeclared variable: ef
ef-utils.js:1 Variable ef first declared in externs-ko.js
ef-validation.js:1 Redeclared variable: ef
ef-validation.js:1 Variable ef first declared in externs-ko.js
And I am still getting warnings while compiling:
ef-utils.js:1: WARNING - Redeclared variable: ef
?var ef = (function (ns, ko) {
^
ef-utils.js:1: WARNING - Variable ef first declared in externs-ko.js
?var ef = (function (ns, ko) {
^
ef-validation.js:1: WARNING - Redeclared variable: ef
?var ef = (function (ns, ko) {
^
ef-validation.js:1: WARNING - Variable ef first declared in externs-ko.js
?var ef = (function (ns, ko) {
^
I just toyed around with the current WhitelistWarningsGuard. I found out that
Line numbers are completely ignored: they are stripped both from the input file and the encountered warnings.
File names are formatted as they are for output, i.e. as they occur on the command line.
There is a colon after the file name, followed by two spaces, followed by the message text without indicator of the severity (WARNING, ERROR).
The main effect of the whitelist appears to be turning errors into warnings. So when applied to warnings, there will be no effect at all.
The WhitelistBuilder mentioned by Tibos is there in the code, but I see no way to use it from the command line.
As it is, that feature appears to be mostly useless for my use cases…
You should use the WhitelistBuilder to build the whitelist file. From the looks of it, you need absolute paths to the files, not relative.
As MvG correctly stated as this flag is implemented it's useless. Though, with pretty light changes to the compiler's code it can be turned to what we all expect from it: suppressing errors and warnings we don't want to see.
See details here: Suppressing or resolving compiler errors in goog.base

Retrieving MS Access filename when using RODBC

Typing in my connection name I see a line like DBQ=Path\to\DB. How do I retrieve this value? I have tried
conn$DBQ
conn[DBQ]
conn['DBQ']
conn[,'DBQ']
None return the value. I tried typeof(conn) and got "integer", class(conn) -> "RODBC", mode(conn) -> "numeric".
I think there is no simple way. You could get connection string by attr(conn, "connection.string") and then try to parse it (e.g.: sub("^DBQ=([^=]*);.*", "\\1", attr(a,"connection.string")) or strsplit(attr(a,"connection.string"),";")[[1]][1]).

Resources