Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90383020
arclint.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 1, 03:59
Size
1 KB
Mime Type
text/x-python
Expires
Sun, Nov 3, 03:59 (2 d)
Engine
blob
Format
Raw Data
Handle
22064300
Attached To
rAKA akantu
arclint.py
View Options
import
json
from
.results
import
Results
from
.
import
export
@export
class
ARCLintJson
:
STATUS
=
{
'passed'
:
Results
.
PASS
,
'failed'
:
Results
.
FAIL
}
def
__init__
(
self
,
filename
):
self
.
_file
=
open
(
filename
,
"r"
)
self
.
_json
=
json
.
load
(
self
.
_file
)
def
__iter__
(
self
):
self
.
_last_path_lints
=
[]
self
.
_lints
=
iter
(
self
.
_json
)
return
self
def
__next__
(
self
):
class
Lint
:
def
__init__
(
self
,
path
,
json
):
self
.
json
=
json
self
.
json
[
'path'
]
=
path
if
'name'
in
json
and
'code'
in
json
and
\
json
[
'name'
]
==
json
[
'code'
]:
self
.
json
[
'name'
]
=
json
[
'description'
]
del
self
.
json
[
'description'
]
def
__getattr__
(
self
,
name
):
if
name
==
'json'
:
return
self
.
json
elif
name
in
self
.
json
:
return
self
.
json
[
name
]
else
:
return
None
def
__str__
(
self
):
return
f
'{self.path} => {self.name}'
lint
=
None
while
not
lint
:
if
len
(
self
.
_last_path_lints
)
>
0
:
lint
=
Lint
(
self
.
_last_path
,
self
.
_last_path_lints
.
pop
(
0
))
break
json
=
next
(
self
.
_lints
)
if
type
(
json
)
!=
dict
:
raise
RuntimeError
(
"Wrong input type for the linter processor"
)
self
.
_last_path
=
list
(
json
.
keys
())[
0
]
self
.
_last_path_lints
=
json
[
self
.
_last_path
]
return
lint
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
self
.
_file
.
close
()
def
__enter__
(
self
):
return
self
Event Timeline
Log In to Comment