how to use regex with vega - vega-lite

I am new to vega lite / vega.
I'm trying to write a regex query for a java log error as following with vega tree layout.
A field 'message' contains :
[Poolthread] com.xxxx.content.core-bundle com.xxxxx.content.model.impl.RegisterTypeInternal(3179)] The activate method has thrown an exception (com.xxxxx.content.model.exception.ModelException: ModelException: {Code}-LCC-REP-FCT-002, {Message}-Access denied)
com.xxxx.content.model.exception.ModelException: ModelException: {Code}-LCC-REP-FCT-002, {Message}-Access denied
at com.xxxxx.content.repository.utils.ExceptionUtil.getException(ExceptionUtil.java:52)
at com.xxxxx.content.repository.utils.ExceptionUtil.getException(ExceptionUtil.java:171)
i'm use this regex which gets an exception word before the character : (like as ModelException ) but i don't how use this regex in vega . i tested this regex on the site regex101.com and it works fine.
([a-zA-Z0-9_]+)(?=:)
Thank for your help

Related

Was there a change from PrimeFaces 10.0.0 to 11.0.0 that made TreeNode into a Raw Type?

Now, when I define a TreeNode List such as:
List node = otherNode.getChildren();
I get two warnings.
For the left side: "TreeNode is a raw type. References to generic type TreeNode should be parameterized"
For the right side: "Type safety: The expression of type List needs unchecked conversion to conform to List"
This also creates a code breaking issue when trying to use a for loop to iterate though the list like this:
for(TreeNode loopingNode : node.getChildren())
{
...
}
I receive an actual error: "Type mismatch: cannot convert from element type Object to TreeNode"
These issues were only raised when upgrading from PrimeFaces 10.0.0 to PrimeFaces 11.0.0. Why would this be? I have looked through the migration guide (https://primefaces.github.io/primefaces/11_0_0/#/../migrationguide/11_0_0), but I do not think I see anything about this.
Yes. See:
https://github.com/primefaces/primefaces/pull/7525/files#diff-76612635b2ee16c50bf86c76f7b8400e887e790e9ba89e18fb4e79694f4454d1
https://github.com/primefaces/primefaces/issues/7523
This was added in 11.0.0 RC 1. I'll add a note to the migration guide.

Robot framework: Retrieving keys that contain dashes from a dict

I am new to Robot Framework and am trying to validate the contents of some JSON that is returned from a web service. The problem is that some attributes of the json objects have dashes in them and Robot doesn't seem to like this. I have something like the following
&{deployment} = list deployment ${deployment_name}
&{changeSets} = Set Variable ${deployment.ChangeSets}
&{myChangeSet} = Set Variable ${changeSets.my-change-set}
Should Be True ${myChangeSet.UseLocal}
Should Be Equal As Strings ${myChangeSet.Version} ${update_version}
But Robot fails on the 3rd line with the following error:
Resolving variable '${changeSets.my-change-set}' failed: AttributeError: my
I tried to escape the dashes but that still doesn't seem to work:
Resolving variable '${changeSets.my\-change\-set}' failed: SyntaxError: unexpected character after line continuation character (<string>, line 1)
I can't seem to find any information in the Robot docs with other ways to retrieve dict keys outside of the dot-notation. Any suggestions?
The use of dot notation is just a convenience. You can still access them the normal way (documented in the dictionary variables section of the user guide as &{NAME}[key]):
&{changeSets}[my-change-set]
Or, with extended variable syntax, which treats everything inside {} as a python expression:
${changeSets['my-change-set']}
Here is a working example illustrating these two methods:
*** Variables ***
&{changeSets} my-change-set=foo
*** Test Cases ***
Test 1
should be equal ${changeSets['my-change-set']} foo
Test 2
should be equal &{changeSets}[my-change-set] foo

Why doesn't atom package linter-eslint recognize template literals?

The documentation on template literals for ES6 has the following syntax example:
`string text ${expression} string text`
Following this, my function is:
function madLib (verb, adjective, noun) {
return `We shall ${verb} the ${adjective} ${noun}.`;
}
In console, this outputs as expected:
We shall fly the iridescent zoo.
However, the eslinter package complains of a fatal parsing error at the first back tick, citing
Unexpected character '`'
Why is this?
(This SO post on literals is about a syntax error--couldn't find any other related eslinter posts.)
ESLint by default is configured to only lint ES5 code. Template literals are part of ES6 spec. Because of that, parser will fail to parse your JavaScript code with fatal error. You need to create an .eslintrc file in the root of your project and set ecmaVersion to 6. For more information about configuring ESLint see http://eslint.org/docs/user-guide/configuring#specifying-parser-options
this is the way you can. in the .eslintrc.js change the values of "quotes" (for me is single) like this:
"quotes": ["error", "single", {
avoidEscape: true,
allowTemplateLiterals: true
}],
you can use back-tick and avoid escaping!

Badly Formed hexadecimal uuid string error in Django fixture; json uuid conversion fails issue

File "/home/malikarumi/Projects/cannon/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 2390, in get_db_prep_value
value = uuid.UUID(value)
File "/usr/lib/python2.7/uuid.py", line 134, in __init__
raise ValueError('badly formed hexadecimal UUID string')
ValueError: Problem installing fixture '/home/malikarumi/Projects/cannon/jamf/essell/fixtures/test22byhand.json': badly formed hexadecimal UUID string
I've found the following links so far:
https://github.com/dcramer/django-uuidfield/issues/40
https://github.com/dcramer/django-uuidfield/commit/caae1bc4e45445a06dd11bb22da6a9f07395f78a
Django UUIDField modelfield causes error in Django admin: badly formed hexadecimal UUID string
Django Primary Key: badly formed hexadecimal UUID string
I counted my uuidfield value. It is len=36, because it has dashes in it. At least the string representation I can see is that way. So I replaced it with the same alphanumeric without dashes, as suggested as a test by the bugfix, but I still got the same result.
I checked the model, but there is no max length on any uuid field, nor on the fk link back to the uuid. There's nothing on the fk to suggest it is, or should be limited to, chars, ints, uuids, etc.
Then I found this: http://arthurpemberton.com/2015/04/fixing-uuid-is-not-json-serializable which I hacked into /python2.7/site-packages/django/core/serializers/python.py. The blogger had put it into models.py. But I got the same error, before realizing it was NOT coming from serializers/python.py, as it was yesterday, but from /usr/lib/python2.7/uuid.py, line 134, in init. the relevant portions of that code are:
if hex is not None:
hex = hex.replace('urn:', '').replace('uuid:', '')
hex = hex.strip('{}').replace('-', '')
if len(hex) != 32:
raise ValueError('badly formed hexadecimal UUID string')
int = long(hex, 16)
Rather than try to hack more core code, given that the indication is the problem is json, not Python, I left this alone for now.
Finally, I looked at this:
https://code.djangoproject.com/ticket/24012
It is stated a couple of times here that Django's "UUIDField generates UUIDs in Python". Now here is some history. I created one row, a single instance of Model A into Django with a fixture that had no uuid and no datefield and had no issues. (The uuidfield is on an abstract model, so it is created when the object is created). I did that because I needed the uuid of that Model A instance for a fk field in Model B, which is the one I am struggling with now. I did that by copy pasting the Model A uuid into the fk field on Model B in a csv file which I then converted to json in order to use it as a fixture.
Is it possible that the uuid ran into problems in this copy paste maneuver, before the conversion to json?
If not, that means even though it was an acceptable Python object when it was created, going thru the json conversion messed it up, correct?
If that's the case, what is a workaround?
Can the Arthur Pemberton code be made to work somewhere else in this process?
If I leave the uuid off, I can probably make this work, but then I have to go back and put the all the fk uuid's in manually. Is there a better solution? Maybe a bulk insert of that field alone?
This may be a recurring issue for me, because I am also using Scrapy, which supports but does not require json. None of my scraped items will come with uuid, but how do I automate adding their fk's into my process in order to get them into Django?
Or is all of this a good reason to forget uuids altogether?
Thanks.
EDIT/UPDATE per #rolf:
Since I just discovered that the django shell differs more than I realized (the shell can find settings, the regular interpreter can't) I decided to run this once in each one, but the results were the same.
(cannon)malikarumi#Tetuoan2:~/Projects/cannon/jamf$ python manage.py shell
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
IPython 4.0.3 -- An enhanced Interactive Python.
In [1]: uuid.UUID(a82857b6-e336-4c6c-8499-47601770b39d)
File "<ipython-input-1-e282858da374>", line 1
uuid.UUID(a82857b6-e336-4c6c-8499-47601770b39d)
^
SyntaxError: invalid syntax
In [2]: uuid.UUID(a0a69415-6627-43db-8c7a-b57d0c4cefe2)
File "<ipython-input-2-befebf1573ba>", line 1
uuid.UUID(a0a69415-6627-43db-8c7a-b57d0c4cefe2)
^
SyntaxError: invalid syntax
In [3]: uuid.UUID(e6e11b06-ea3b-4e98-a31f-9a83447ad884)
File "<ipython-input-3-a59ea095e61a>", line 1
uuid.UUID(e6e11b06-ea3b-4e98-a31f-9a83447ad884)
^
SyntaxError: invalid syntax
In [4]: uuid.UUID(bd116432-65d7-4612-abfe-9a99dcaf5cad)
File "<ipython-input-4-c4a04434aa3c>", line 1
uuid.UUID(bd116432-65d7-4612-abfe-9a99dcaf5cad)
^
SyntaxError: invalid syntax
Now that I have posted this, I notice that even Stack Overflow treats these uuid differently, i.e., the way they are colored, if that's relevant and meaningful here.
But now that we know this, what do we do with / about it?
2nd Update
This morning I thought, what about a uuid that had never been anywhere but in Django? So here's what I did:
In [5]: e.uuid
Out[5]: UUID('61877565-5fe5-4175-9f2b-d24704df0b74')
In [6]: uuid.UUID(61877565-5fe5-4175-9f2b-d24704df0b74)
File "<ipython-input-6-56137f5f4eb6>", line 1
uuid.UUID(61877565-5fe5-4175-9f2b-d24704df0b74)
^
SyntaxError: invalid syntax
In [7]: uuid.UUID('61877565-5fe5-4175-9f2b-d24704df0b74')
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-7-3b4d3e5bd156> in <module>()
----> 1 uuid.UUID('61877565-5fe5-4175-9f2b-d24704df0b74')
NameError: name 'uuid' is not defined
This is apparently because I left the quote around the alphanumeric, but why that would generate a uuid not defined error, instead of 'string type' or some such error is beyond me.
In [8]: uuid.UUID(61877565-5fe5-4175-9f2b-d24704df0b74)
File "<ipython-input-8-56137f5f4eb6>", line 1
uuid.UUID(61877565-5fe5-4175-9f2b-d24704df0b74)
^
SyntaxError: invalid syntax
The first time I keyed in the characters by hand. I decided to repeat the test by copying and pasting, but as you can see, it made no difference. If there was something weird about the way only the 5 that the caret is pointing to was generated, we might be on to something, but if so, why do I get the same error in the same place when I typed it in by hand myself?
This no longer seems like a json issue to me, since – as far as I know – json has never touched this uuid, unless it did somehow in the internal workings of Django.
Instead, there is either
1. something wrong with the way uuid.UUID generates uuids, or
2. the way it generates them on my system, (Ubuntu 15.10, Django 1.9.1, Python 2.7.10) or
3. the way it reads and evaluates them when they come back, like in uuid.UUID() or being input outside the internal, automatic uuid generation process.
But that also means people using uuid.UUID() to generate uuids will never know there is an issue unless they do what I did, which is try to bring them in from outside. I remember reading somewhere that all uuids are supposed to be compatible. So, unless someone here has a better insight, I think we might be up for a bug report. But is it a Python bug, a Django bug, or both?
Your syntax is wrong:
uuid.UUID('61877565-5fe5-4175-9f2b-d24704df0b74') # note the quotes

Extract a html tag that contains a string in openrefine?

There is not much to add to the title. It's what i'm trying to do. Any suggestions?
I reviewed the docs at github and googled extensively.
The best i got is:
value.parseHtml().select('p[contains('xyz')]')
It results in a syntax error.
The 'select' syntax is based on the select syntax in Beautiful Soup (http://jsoup.org/cookbook/extracting-data/selector-syntax)
In this case I believe the syntax you need is:
value.parseHtml().select("p:contains(xyz)")
Owen
Perhaps you missed my writeup (and WARNING) on the wiki :) here ?
https://github.com/OpenRefine/OpenRefine/wiki/StrippingHTML#extract-html-attributes-text-links-with-integrated-grel-jsoup-commands
WARNING: Make sure to use .toString() suffixes when needed to output strings into Refine cells while working with the built-in HTML GREL commands (the default output is org.jsoup.nodes objects). Otherwise you'll get a preview just fine in the Expression Editor, BUT no data shown in the Refine cells when you apply it!
BTW, How could we make the docs better and where, so that someone doesn't miss this in the future ?
I even gave folks a nice example in our docs that shows using .toString() :
https://github.com/OpenRefine/OpenRefine/wiki/GREL-Other-Functions#selectelement-e-string-s