Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
0d2c5746
Commit
0d2c5746
authored
Oct 04, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring.
parent
4258554e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
58 deletions
+57
-58
action.py
hdlmake/action/action.py
+24
-26
configparser.py
hdlmake/manifest_parser/configparser.py
+3
-2
content.py
hdlmake/module/content.py
+0
-18
core.py
hdlmake/module/core.py
+28
-11
module.py
hdlmake/module/module.py
+2
-1
No files found.
hdlmake/action/action.py
View file @
0d2c5746
...
...
@@ -47,6 +47,29 @@ class Action(object):
self
.
_deps_solved
=
False
self
.
options
=
options
def
_add
(
self
,
new_module
):
"""Add the given new module if this is not already in the pool"""
assert
isinstance
(
new_module
,
Module
),
"Expect a Module instance"
if
self
.
__contains
(
new_module
):
return
if
new_module
.
isfetched
:
for
mod
in
new_module
.
submodules
():
self
.
_add
(
mod
)
self
.
manifests
.
append
(
new_module
)
def
new_module
(
self
,
parent
,
url
,
source
,
fetchto
):
"""Add new module to the pool.
This is the only way to add new modules to the pool
Thanks to it the pool can easily control its content
"""
self
.
_deps_solved
=
False
args
=
ModuleArgs
()
args
.
set_args
(
parent
,
url
,
source
,
fetchto
)
new_module
=
Module
(
args
,
self
)
self
.
_add
(
new_module
)
return
new_module
def
load_top_manifest
(
self
):
# Top level module.
assert
self
.
top_manifest
is
None
...
...
@@ -82,20 +105,6 @@ class Action(object):
else
:
raise
Exception
(
"Unknown requested action: {}"
.
format
(
action
))
def
new_module
(
self
,
parent
,
url
,
source
,
fetchto
):
"""Add new module to the pool.
This is the only way to add new modules to the pool
Thanks to it the pool can easily control its content
"""
self
.
_deps_solved
=
False
new_module_args
=
ModuleArgs
()
new_module_args
.
set_args
(
parent
,
url
,
source
,
fetchto
)
new_module
=
Module
(
new_module_args
,
self
)
if
not
self
.
__contains
(
new_module
):
self
.
_add
(
new_module
)
return
new_module
def
build_complete_file_set
(
self
):
"""Build file set with all the files listed in the complete pool"""
logging
.
debug
(
"Begin build complete file set"
)
...
...
@@ -158,7 +167,7 @@ class Action(object):
config_dict
=
{}
for
mod
in
self
.
manifests
:
manifest_dict_tmp
=
mod
.
manifest_dict
if
not
manifest_dict_tmp
==
None
:
if
manifest_dict_tmp
is
not
None
:
if
'fetchto'
in
manifest_dict_tmp
:
manifest_dict_tmp
[
'fetchto'
]
=
os
.
path
.
relpath
(
os
.
path
.
join
(
mod
.
path
,
...
...
@@ -167,17 +176,6 @@ class Action(object):
config_dict
=
manifest_dict_tmp
return
config_dict
def
_add
(
self
,
new_module
):
"""Add the given new module if this is not already in the pool"""
assert
isinstance
(
new_module
,
Module
),
"Expect a Module instance"
if
self
.
__contains
(
new_module
):
return
False
if
new_module
.
isfetched
:
for
mod
in
new_module
.
submodules
():
self
.
_add
(
mod
)
self
.
manifests
.
append
(
new_module
)
return
True
def
__contains
(
self
,
module
):
"""Check if the pool contains the given module by checking the URL"""
for
mod
in
self
.
manifests
:
...
...
hdlmake/manifest_parser/configparser.py
View file @
0d2c5746
...
...
@@ -246,7 +246,7 @@ types:[<type 'int'>]
return
[
o
.
name
for
o
in
self
.
options
if
o
is
not
None
]
def
__parser_runner
(
self
,
content
,
extra_context
):
"""method that acts as an 'exec' wraper to run the Python code"""
"""method that acts as an 'exec' wraper to run the Python code
. Return the locals
"""
options
=
{}
try
:
with
capture_stdout
()
as
stdout_aux
:
...
...
@@ -283,7 +283,8 @@ types:[<type 'int'>]
return
open
(
self
.
config_file
,
"r"
)
.
read
()
def
parse
(
self
,
extra_context
=
None
):
"""Parse the stored manifest plus arbitrary code"""
"""Parse the stored manifest plus arbitrary code. Return a dictionnary
of variables defined in the manifest."""
assert
isinstance
(
extra_context
,
dict
)
or
extra_context
is
None
# These HDLMake keys must not be inherited from parent module
...
...
hdlmake/module/content.py
View file @
0d2c5746
...
...
@@ -10,24 +10,6 @@ import six
import
os
class
ModuleArgs
(
object
):
"""This class is just a container for the main Module args"""
def
__init__
(
self
):
self
.
parent
=
None
self
.
url
=
None
self
.
source
=
'local'
self
.
fetchto
=
None
def
set_args
(
self
,
parent
,
url
,
source
,
fetchto
):
"""Set the module arguments"""
self
.
parent
=
parent
self
.
url
=
url
self
.
source
=
source
or
'local'
self
.
fetchto
=
fetchto
class
ModuleContent
(
ModuleCore
):
"""Class providing the HDLMake module content"""
...
...
hdlmake/module/core.py
View file @
0d2c5746
...
...
@@ -9,6 +9,23 @@ from hdlmake import fetch
from
hdlmake.util
import
path
as
path_mod
class
ModuleArgs
(
object
):
"""This class is just a container for the main Module args"""
def
__init__
(
self
):
self
.
parent
=
None
self
.
url
=
None
self
.
source
=
'local'
self
.
fetchto
=
None
def
set_args
(
self
,
parent
,
url
,
source
,
fetchto
):
"""Set the module arguments"""
self
.
parent
=
parent
self
.
url
=
url
self
.
source
=
source
or
'local'
self
.
fetchto
=
fetchto
class
ModuleConfig
(
object
):
"""This class containt the base properties and methods that
...
...
@@ -49,7 +66,16 @@ class ModuleConfig(object):
self
.
source
=
source
self
.
parent
=
parent
if
self
.
source
!=
'local'
:
if
self
.
source
==
'local'
:
self
.
url
,
self
.
branch
,
self
.
revision
=
url
,
None
,
None
if
not
os
.
path
.
exists
(
url
):
raise
Exception
(
"Path to the local module doesn't exist:
\n
"
+
url
+
"
\n
This module was instantiated in: "
+
str
(
self
.
parent
))
self
.
path
=
path_mod
.
relpath
(
url
)
self
.
isfetched
=
True
else
:
if
self
.
source
==
'svn'
:
self
.
url
,
self
.
revision
=
path_mod
.
svn_parse
(
url
)
else
:
...
...
@@ -69,15 +95,6 @@ class ModuleConfig(object):
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
,
url
,
self
.
parent
.
path
)
else
:
self
.
url
,
self
.
branch
,
self
.
revision
=
url
,
None
,
None
if
not
os
.
path
.
exists
(
url
):
raise
Exception
(
"Path to the local module doesn't exist:
\n
"
+
url
+
"
\n
This module was instantiated in: "
+
str
(
self
.
parent
))
self
.
path
=
path_mod
.
relpath
(
url
)
self
.
isfetched
=
True
def
_check_filepath
(
self
,
filepath
):
"""Check the provided filepath against several conditions"""
...
...
@@ -119,7 +136,7 @@ class ModuleCore(ModuleConfig):
self
.
action
=
None
self
.
pool
=
None
self
.
top_manifest
=
None
self
.
manifest_dict
=
None
self
.
manifest_dict
=
{}
super
(
ModuleCore
,
self
)
.
__init__
()
def
set_pool
(
self
,
pool
):
...
...
hdlmake/module/module.py
View file @
0d2c5746
...
...
@@ -35,7 +35,8 @@ import logging
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
from
hdlmake.manifest_parser.variables
import
ManifestParser
from
.content
import
ModuleContent
,
ModuleArgs
from
.content
import
ModuleContent
from
.core
import
ModuleArgs
import
six
...
...
Write
Preview
Markdown
is supported
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