How to use multiple tags in custom_filter? - osmnx

I am trying to add a union of tags in the custom_filter parameter, however, OSMNX seems to not recognize the union syntax as described in the Overpass QL Wiki. How can I add several tags to filter on inside the custom_filter parameter?
My goal is to use a filter like:
customBikeFilter = '(["bike"~"designated"]; ["highway"~"cycleway"];)'
I expect to get all the roads tagged as ["bike"~"designated"] OR ["highway"~"cycleway"]. Any tips?

Related

Using tags to exclude group of features [duplicate]

This question already has an answer here:
Can you use wildcard characters with tags to get all matching tags
(1 answer)
Closed 1 year ago.
We are using tags to be able to group features and senarios. For example, we have something like:
#jira=123
Scenario: test scenario 1
...
#jira=456
Scenario: test scenario 2, known failure
...
Scenario: test scenario 3, new feature
Now, we are hoping to run test that are not tagged with #jira=123 or #jira=456. Because we have many features and scenarios tagged with the #jira=somevalue, it is impractical to add them all. So I am looking for a way to be able to exclude anything tagged with #jira. I tried ~#jira and "~#jira=" but no luck.
Looking at the following junit case:
TagTest.java#testToString()
Which is using "#foo=" as a tag, but was not able to find an example. Is there a way to exclude a group of scenarios tagged by #jira, regardless of the tag value ?
The tag value is the whole string, even if it contains a = and you may assume there is key and a value.
But you could consider to use multiple tags, they are allowed.
So, in your case, I would use something like:
#jira=123
#jira
Scenario: test scenario 1
...
#jira=456
#jira
Scenario: test scenario 2, known failure
And the you can use the ~#jira to exclude all the #jira scenarios.
This will allow you to still reference the single #jira=123 when needed.
Yes, we haven't documented this well but this question here can be a start. Karate actually supports a mini expression language for tags.
Have a look at this test for some options: TagsTest.java
And this should work for your requirement, do confirm in the comments ! Yes just use the string below where you would normally put #jira etc.
!valuesFor('#jira').isPresent
One more important point. When you use the special expression language, any AND or OR complexity has to be managed within the single expression that you pass into the tags option. Only one expression is needed and the use of comma-separated values or multiple values for the tag parameter is not applicable.
For example:
To select scenarios that have values for either the #fail tag or the #bad tag (note the use of the JS || (OR) operator):
valuesFor('#fail').isPresent || valuesFor('#bad').isPresent
And to select any scenario that has values for the #fail tag and where the #smoke tag is present (without values, just the plain tag and no = part):
valuesFor('#fail').isPresent && anyOf('#smoke')
And yes, you can use the "expression language" on the command-line i.e. within the karate.options or as the --tags or -t option to the stand-alone JAR: https://stackoverflow.com/a/72054253/143475

Search repos with GitHub API using date query

If I make the following GET request to the GitHub API, I get about 58 entries:
https://api.github.com/search/repositories?&per_page=250&sort=updated&order=asc&q=%22github-octocat%22
However, the following with any date parameters return 0 entries:
Created since date: ( created:>=2010-09-01 )
https://api.github.com/search/repositories?&per_page=250&sort=updated&order=asc&q=%22github-octocat+created:>=2010-09-01%22
Date range: ( created:2012-08-13..2020-08-14 )
https://api.github.com/search/repositories?&per_page=250&sort=updated&order=asc&q=%22github-octocat+created:2012-08-13..2020-08-14%22
In the GitHub docs, under the section Constructing a search query, the syntax is outlined as such:
SEARCH_KEYWORD_1 SEARCH_KEYWORD_N QUALIFIER_1 QUALIFIER_N
Thei GitHub docs at Search by when a repository was created or last updated outlines date formats like the two above, and Query for values between a range outlines valid combinations of them. I suspect these examples are not meant for this use, as the examples use URLs intended for browsers, such as https://github.com/search?q=case+pushed%3A%3E%3D2013-03-06+fork%3Aonly&type=Repositories, instead of api.github.com, which is confusing too.
I'm trying to apply the patterns shown in the following resources in order to get a range of dates filter:
Github API call: filter by committer-date, answer by Poonacha
Get issues on a date range from Github enterprise API, answer by Al Neill
Any pointers greatly appreciated.
Even though the GitHub docs outlines the syntax as such:
SEARCH_KEYWORD_1 SEARCH_KEYWORD_N QUALIFIER_1 QUALIFIER_N
the parameters for date or similar, are not valid unless placed outside the q parameter. Instead of including date qualifier inside of the double quotes (shown as %22 below):
q=%22mysearch+pushed%3A2017-09-01..2020-10-01+sort:updated%22
Pull them out, and add them after the closing quote of the q parameter:
q=%22mystring%22+pushed%3A2017-09-01..2020-10-01+sort:updated

Apache Zeppelin: passing parameters between different interpreters

Here's a problem.
I'm building a dashboard in Apache Zeppelin using org.postgresql.Driver to connect to Greenplum database. Usually I use something like:
where country_title like '${country=UK,UK|USA|Canada|%}'
to pass parameters into my query. But I have a long list of other parameters (like "towns") which I also need to pass to my query. And they are different for different country_title values. I can use something like:
select towns from towns_by_country where country_title like '${country=UK,UK|USA|Canada|%}'
to get a list of towns. How can I use it as a parameter in drop-down menu (WITH '%', of course).
I can use z.angularBind or z.put & z.get , of course. But they work in %spark interpreters, not in custom interpreters.
I would be very grateful for an answer or any other constructive feedback.

How can I get page id, wikidata id of some title along with multiple languages in a single API call?

I have been trying to call Wikipedia API to retrieve page id and wikidata item id using below call and it works fine.
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&ppprop=wikibase_item&redirects=1&format=xml&titles=Cat
but I need to retrieve the same information from other languages of my choice for example if I mention German and French languages in my call, it should look for their translation of word Cat and retrieve their page info. There is langlink property in Wikipedia API but somehow it doesn't work with query action along with pageprop.
So ideally, I want something like this:
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&ppprop=wikibase_item&prop=langlinks&lllang=de&lllang=fr&titles=Cat
Any help would be appreciated.
Using lllang twice will just result in the second value overwriting the first one. You'll have to omit the paramter and then you get all the links:
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops|langlinks&ppprop=wikibase_item&titles=Cat

Combining separate tags in beautiful soup for find methods

I have some html tags that I've selected in Beautiful Soup based on some criteria. I'd like to be able to do further queries (e.g. find() or find_all()) on these tags however I haven't been able to find a method that would allow this since they are all separate entities.
I would combine the tags from the beginning. Combine the initial queries into one by using the ability to pass in a list to the find_all() method, and then search on that result. Here is an example that will return all the links in a table cell, table header, or div:
soup.find_all(["td","th","div"]).find_all("a")
Link to the documentation about lists: http://www.crummy.com/software/BeautifulSoup/bs4/doc/#a-list
If your initial query is complicated you can bundle it in a function: http://www.crummy.com/software/BeautifulSoup/bs4/doc/#a-function
rather than combining everything in a line, i would prefer to separate them. For example, i would first using find_all() to capture them into a list then use find() to narrow down my search.
container = soup.find_all("tag",{"tag class":"tag class name"})
what_i_want = container.find("another tag")
hope this helps