I want to create an import to my CodeQL query.
I want that this import will be named Utils and I will created inside it a predicate named isNumber.
How can I creat such import?
This how I want my code to look like:
import cpp
import Utils
where
if exists(...)
then isNumber(size.(VariableAccess).getTarget())
else ...
select ...
I don't know how I create the Utils import, it writes:
Could not resolve module Utils
I tried to create a folder named Utils near my code query (code.ql) but it didn't work.
I found how to do it.
Need to create a file named Utils.qll in the same folder of your CodeQL query.
This is its code:
import cpp
predicate isNumber(Variable v){
v.getUnspecifiedType() instanceof IntegralType
}
Related
I need to import an existing order to terraform state.
For example:
Consider I need to pass ID and Environment values to import the script.
if we have to pass only one argument say ID, we can use the below script
terraform import hashicups_order.sample {id}
In my case I need to pass two arguments, we can say it id and environmentValue. So how can we do that?
terraform import hashicups_order.sample {id} {one more argument???}
TF import has the following form
terraform import [options] ADDRESS ID
ADDRESS ID is a single value (not multiple values) uniquely identifying the resource to be imported.
If you wish to pass any other values to import you have to use -var in [options] as explained in the docs.
In my Graphene-Django project, I have this structure:
Project level:
schema.py
App level:
schema.py
queries.py
mutations.py
This works well but the queries file has grown quite large. Is there a way to split class Query into multiple classes and/or multiple files?
Robert
From the perspective of the project schema file, you can use inheritance in your Query class to pull in each of your separate Query classes. You can use the same technique to split your Mutation. For example:
from django.conf import settings
import graphene
from graphene_django.debug import DjangoDebug
from app1.schema import App1Query, App1Mutation
from app2.schema import App2Query, App2Mutation
class Query(App1Query, App2Query, graphene.ObjectType):
if settings.DEBUG:
# Debug output - see
# http://docs.graphene-python.org/projects/django/en/latest/debug/
debug = graphene.Field(DjangoDebug, name='__debug')
class Mutation(App1Mutation, App2Mutation, graphene.ObjectType):
pass
schema = graphene.Schema(query=Query, mutation=Mutation)
(Note that I'm also dynamically adding the debug class if DEBUG is True -- this has nothing to do with your question, but it's handy.)
You should able to use the same inheritance technique to further split your query if you need to, for example breaking apart App1Query.
Using python 2.7, I'm building a package as follows:
mypackage/
__init__.py
somemodule.py
In __init__.py I have this:
from . import somemodule
In somemodule.py I have The following:
class SomeClass:
pass
When I try and access SomeClass, it prepends the filename to the class, so it's accessible by this:
import mypackage
mypackage.somemodule.SomeClass
How can I get it so that it's accessible as follows:
mypackage.SomeClass
Without putting the class directly in __init__.py?
I'm sure this has been answered before, but I'm not sure how to phrase the question.
If you really want to import your class like
mymodlue.myClass
you have to import the class in your __init__.py-file first, for instance like this:
from someclass import myClass
You could even do this (just to get your head around the concept - it's actually really ugly):
import someclass
myClass = someclass.myClass
Works just as well.
I have the following code
List<Double> array = new ArrayList<Double>();
This won't compile however because I'm getting an error on List which says "The type list is not generic; it cannot be parameterised with arguments.
I am using Java 7 update 45 and my complile path in eclipse to is JavaSE-1.7 so I thought this should be possible after JDK 5 , does anyone have any suggestions what might be going wrong? My imports are as follows...
import java.awt.List;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.io.File;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Arrays;
You should add import java.util.List; instead of import java.awt.List;. The former one is generic list, the latter one is display element.
java.awt.List - The List component presents the user with a scrolling list of text items.
java.util.List - An ordered collection (also known as a sequence).
I'm trying to get a Hudson job to get built in a custom workspace path that is automatically generated using yyyyMMdd-HHmm. I can get the $BUILD_ID variable expanded as mentioned in bug 3997, and that seems to work fine. However, the workspace path is incorrect as it is of the format yyyy-MM-dd_HH-mm-ss. I've tried using the ZenTimestamp plugin v2.0.1, which changes the $BUILD_ID, but this only seems to take effect after the workspace is created.
Is there a method of defining a custom workspace in the manner that I want it?
You can use a groovy script to achieve that.
import hudson.model.*;
import hudson.util.*;
import java.util.*;
import java.text.*;
import java.io.*;
//Part 1 : Recover build parameter
AbstractBuild currentBuild = (AbstractBuild) Thread.currentThread().executable;
def envVars= currentBuild.properties.get("envVars");
def branchName = envVars["BRANCH_NAME"];
//Part 2 : Define new workspace Path
def newWorkspace = "C:\\Build\\"+branchName;
//Part 3 : Change current build workspace
def newWorspaceFilePath = new FilePath(new File(newWorkspace));
currentBuild.setWorkspace(newWorspaceFilePath);