Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.core
Commits
b7042604
Commit
b7042604
authored
May 29, 2018
by
Samuel GAIST
Browse files
[toolchain] Fixed documentation related warnings
Also unused import cleanup
parent
1b6a49a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/core/toolchain.py
View file @
b7042604
...
...
@@ -36,7 +36,6 @@ Validation for toolchains
import
collections
import
six
import
simplejson
from
.
import
schema
...
...
@@ -53,7 +52,6 @@ class Storage(utils.Storage):
name (str): The name of the toolchain object in the format
``<user>/<name>/<version>``.
"""
def
__init__
(
self
,
prefix
,
name
):
...
...
@@ -97,11 +95,11 @@ class Toolchain(object):
storage (object): A simple object that provides information about file
paths for this toolchain
errors (list): A list containing errors found while loading this toolchain.
errors (list): A list containing errors found while loading this
toolchain.
data (dict): The original data for this toolchain, as loaded by our JSON
decoder.
"""
def
__init__
(
self
,
prefix
,
data
):
...
...
@@ -118,14 +116,14 @@ class Toolchain(object):
self
.
_name
=
None
self
.
storage
=
None
if
data
is
None
:
#
loads prototype and validates it
if
data
is
None
:
#
loads prototype and validates it
self
.
data
,
self
.
errors
=
prototypes
.
load
(
'toolchain'
)
assert
not
self
.
errors
,
"
\n
* %s"
%
"
\n
*"
.
join
(
self
.
errors
)
else
:
if
not
isinstance
(
data
,
dict
):
#
user has a file pointer
if
not
isinstance
(
data
,
dict
):
#
user has a file pointer
self
.
_name
=
data
self
.
storage
=
Storage
(
self
.
prefix
,
self
.
_name
)
if
not
self
.
storage
.
exists
():
...
...
@@ -137,7 +135,7 @@ class Toolchain(object):
# this runs basic validation, including JSON loading if required
self
.
data
,
self
.
errors
=
schema
.
validate
(
'toolchain'
,
data
)
if
self
.
errors
:
return
#
don't proceed with the rest of validation
if
self
.
errors
:
return
#
don't proceed with the rest of validation
# these will be filled by the following methods
channels
=
[]
...
...
@@ -285,8 +283,8 @@ class Toolchain(object):
@
property
def
name
(
self
):
"""Returns the name of this object
"""
"""Returns the name of this object
"""
return
self
.
_name
or
'__unnamed_toolchain__'
@
name
.
setter
...
...
@@ -343,18 +341,20 @@ class Toolchain(object):
def
execution_order
(
self
):
"""Returns the execution order in an ordered dictionary with block deps."""
"""Returns the execution order in an ordered dictionary with block
deps.
"""
items
=
[
k
[
'name'
]
for
k
in
self
.
data
[
'blocks'
]
+
self
.
data
[
'analyzers'
]]
deps
=
dict
(
zip
(
items
,
[
self
.
dependencies
(
k
)
for
k
in
items
]))
queue
=
collections
.
OrderedDict
()
while
len
(
items
)
!=
len
(
queue
):
# while there are blocks/analyzers to treat
while
len
(
items
)
!=
len
(
queue
):
# while there are blocks/analyzers to treat
insert
=
collections
.
OrderedDict
()
for
k
in
items
:
#if block has no executed deps
if
k
not
in
queue
and
deps
[
k
].
issubset
(
queue
.
keys
()):
insert
[
k
]
=
deps
[
k
]
#
insert into queue
insert
[
k
]
=
deps
[
k
]
#
insert into queue
queue
.
update
(
insert
)
return
queue
...
...
@@ -498,11 +498,13 @@ class Toolchain(object):
@
property
def
description
(
self
):
"""The short description for this object"""
return
self
.
data
.
get
(
'description'
,
None
)
@
description
.
setter
def
description
(
self
,
value
):
"""Sets the short description for this object"""
self
.
data
[
'description'
]
=
value
...
...
@@ -545,13 +547,13 @@ class Toolchain(object):
Parameters:
indent (int): The number of indentation spaces at every indentation level
indent (int): The number of indentation spaces at every indentation
level
Returns:
str: The JSON representation for this object
"""
return
simplejson
.
dumps
(
self
.
data
,
indent
=
indent
,
...
...
@@ -571,12 +573,11 @@ class Toolchain(object):
storage (:py:class:`.Storage`, Optional): If you pass a new storage,
then this object will be written to that storage point rather than
its default.
"""
if
storage
is
None
:
if
not
self
.
_name
:
raise
RuntimeError
(
"toolchain has no name"
)
storage
=
self
.
storage
#
overwrite
storage
=
self
.
storage
#
overwrite
storage
.
save
(
str
(
self
),
self
.
description
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment