Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b121b7

Browse files
committed
Python: Autoformat values.
1 parent 51f1cf0 commit 5b121b7

12 files changed

Lines changed: 642 additions & 1068 deletions

File tree

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import python
22

33
class Builtin extends @py_cobject {
4-
54
Builtin() {
65
not (
76
/* @py_cobjects for modules which have a corresponding Python module */
8-
exists(@py_cobject mod_type | py_special_objects(mod_type, "ModuleType") and py_cobjecttypes(this, mod_type)) and
7+
exists(@py_cobject mod_type |
8+
py_special_objects(mod_type, "ModuleType") and py_cobjecttypes(this, mod_type)
9+
) and
910
exists(Module m | py_cobjectnames(this, m.getName()))
10-
)
11-
and (
11+
) and
12+
(
1213
/* Exclude unmatched builtin objects in the library trap files */
1314
py_cobjectnames(this, _) or
1415
py_cobjecttypes(this, _) or
@@ -17,9 +18,11 @@ class Builtin extends @py_cobject {
1718
}
1819

1920
string toString() {
20-
not this = undefinedVariable().asBuiltin() and not this = Builtin::unknown() and
21+
not this = undefinedVariable().asBuiltin() and
22+
not this = Builtin::unknown() and
2123
exists(Builtin type, string typename, string objname |
22-
py_cobjecttypes(this, type) and py_cobjectnames(this, objname) and typename = type.getName() |
24+
py_cobjecttypes(this, type) and py_cobjectnames(this, objname) and typename = type.getName()
25+
|
2326
result = typename + " " + objname
2427
)
2528
}
@@ -35,9 +38,7 @@ class Builtin extends @py_cobject {
3538
py_cmembers_versioned(this, name, result, major_version().toString())
3639
}
3740

38-
Builtin getItem(int index) {
39-
py_citems(this, index, result)
40-
}
41+
Builtin getItem(int index) { py_citems(this, index, result) }
4142

4243
Builtin getBaseClass() {
4344
/* The extractor uses the special name ".super." to indicate the super class of a builtin class */
@@ -50,12 +51,7 @@ class Builtin extends @py_cobject {
5051
this.getBaseClass().inheritsFromType()
5152
}
5253

53-
string getName() {
54-
if this.isStr() then
55-
result = "str"
56-
else
57-
py_cobjectnames(this, result)
58-
}
54+
string getName() { if this.isStr() then result = "str" else py_cobjectnames(this, result) }
5955

6056
private predicate isStr() {
6157
major_version() = 2 and this = Builtin::special("bytes")
@@ -64,8 +60,10 @@ class Builtin extends @py_cobject {
6460
}
6561

6662
predicate isClass() {
67-
py_cobjecttypes(_, this) or
68-
this = Builtin::unknownType() or
63+
py_cobjecttypes(_, this)
64+
or
65+
this = Builtin::unknownType()
66+
or
6967
exists(Builtin meta | meta.inheritsFromType() and py_cobjecttypes(this, meta))
7068
}
7169

@@ -77,9 +75,7 @@ class Builtin extends @py_cobject {
7775
)
7876
}
7977

80-
predicate isModule() {
81-
this.getClass() = Builtin::special("ModuleType")
82-
}
78+
predicate isModule() { this.getClass() = Builtin::special("ModuleType") }
8379

8480
predicate isMethod() {
8581
this.getClass() = Builtin::special("MethodDescriptorType")
@@ -88,50 +84,42 @@ class Builtin extends @py_cobject {
8884
}
8985

9086
int intValue() {
91-
(this.getClass() = Builtin::special("int") or
92-
this.getClass() = Builtin::special("long")) and
87+
(
88+
this.getClass() = Builtin::special("int") or
89+
this.getClass() = Builtin::special("long")
90+
) and
9391
result = this.getName().toInt()
9492
}
9593

9694
float floatValue() {
97-
(this.getClass() = Builtin::special("float")) and
95+
this.getClass() = Builtin::special("float") and
9896
result = this.getName().toFloat()
9997
}
10098

10199
string strValue() {
102-
(this.getClass() = Builtin::special("unicode") or
103-
this.getClass() = Builtin::special("bytes")) and
100+
(
101+
this.getClass() = Builtin::special("unicode") or
102+
this.getClass() = Builtin::special("bytes")
103+
) and
104104
exists(string quoted_string |
105-
quoted_string = this.getName()
106-
and
105+
quoted_string = this.getName() and
107106
result = quoted_string.regexpCapture("[bu]'([\\s\\S]*)'", 1)
108107
)
109108
}
110-
111109
}
112110

113111
module Builtin {
114-
115112
Builtin builtinModule() {
116113
py_special_objects(result, "builtin_module_2") and major_version() = 2
117114
or
118115
py_special_objects(result, "builtin_module_3") and major_version() = 3
119116
}
120117

121-
Builtin builtin(string name) {
122-
result = builtinModule().getMember(name)
123-
}
118+
Builtin builtin(string name) { result = builtinModule().getMember(name) }
124119

125-
Builtin special(string name) {
126-
py_special_objects(result, name)
127-
}
120+
Builtin special(string name) { py_special_objects(result, name) }
128121

129-
Builtin unknown() {
130-
py_special_objects(result, "_1")
131-
}
122+
Builtin unknown() { py_special_objects(result, "_1") }
132123

133-
Builtin unknownType() {
134-
py_special_objects(result, "_semmle_unknown_type")
135-
}
136-
137-
}
124+
Builtin unknownType() { py_special_objects(result, "_semmle_unknown_type") }
125+
}

0 commit comments

Comments
 (0)