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
f1d7e053
Commit
f1d7e053
authored
Jul 25, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Partially improve the Module code: focus on Module.py
parent
ff83acf6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
157 additions
and
96 deletions
+157
-96
content.py
hdlmake/module/content.py
+4
-4
core.py
hdlmake/module/core.py
+45
-0
module.py
hdlmake/module/module.py
+95
-89
plugin.py
hdlmake/module/plugin.py
+10
-0
simulation.py
hdlmake/module/simulation.py
+1
-1
module_pool.py
hdlmake/module_pool.py
+2
-2
No files found.
hdlmake/module/content.py
View file @
f1d7e053
...
...
@@ -29,7 +29,7 @@ class ModuleContent(ModulePlugin):
except
AttributeError
:
pass
else
:
self
.
manifest_dict
[
"files"
]
=
self
.
_
flatten_list
(
self
.
manifest_dict
[
"files"
])
self
.
manifest_dict
[
"files"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"files"
])
logging
.
debug
(
"Files in
%
s:
%
s"
%
(
self
.
path
,
str
(
self
.
manifest_dict
[
"files"
])))
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"files"
])
self
.
files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
...
...
@@ -52,7 +52,7 @@ class ModuleContent(ModulePlugin):
# Process required modules
if
"local"
in
self
.
manifest_dict
[
"modules"
]:
local_paths
=
self
.
_
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"local"
])
local_paths
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"local"
])
local_mods
=
[]
for
path
in
local_paths
:
if
path_mod
.
is_abs_path
(
path
):
...
...
@@ -69,7 +69,7 @@ class ModuleContent(ModulePlugin):
self
.
local
=
[]
if
"svn"
in
self
.
manifest_dict
[
"modules"
]:
self
.
manifest_dict
[
"modules"
][
"svn"
]
=
self
.
_
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"svn"
])
self
.
manifest_dict
[
"modules"
][
"svn"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"svn"
])
svn_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"svn"
]:
svn_mods
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
...
...
@@ -81,7 +81,7 @@ class ModuleContent(ModulePlugin):
self
.
svn
=
[]
if
"git"
in
self
.
manifest_dict
[
"modules"
]:
self
.
manifest_dict
[
"modules"
][
"git"
]
=
self
.
_
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"git"
])
self
.
manifest_dict
[
"modules"
][
"git"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"modules"
][
"git"
])
git_mods
=
[]
for
url
in
self
.
manifest_dict
[
"modules"
][
"git"
]:
git_mods
.
append
(
self
.
pool
.
new_module
(
parent
=
self
,
...
...
hdlmake/module/core.py
View file @
f1d7e053
import
os
import
logging
from
.plugin
import
ModulePlugin
from
hdlmake.util
import
path
as
path_mod
from
hdlmake
import
fetch
class
ModuleCore
(
ModulePlugin
):
def
__init__
(
self
):
...
...
@@ -33,3 +38,43 @@ class ModuleCore(ModulePlugin):
self
.
target
=
self
.
manifest_dict
[
"target"
]
.
lower
()
self
.
action
=
self
.
manifest_dict
[
"action"
]
.
lower
()
def
_set_origin
(
self
,
parent
,
url
,
source
,
fetchto
):
"""Calculate and initialize the origin attributes: path, source..."""
self
.
source
=
source
self
.
parent
=
parent
self
.
fetchto
=
fetchto
self
.
raw_url
=
url
if
source
!=
fetch
.
LOCAL
:
self
.
url
,
self
.
branch
,
self
.
revision
=
path_mod
.
url_parse
(
url
)
if
(
os
.
path
.
exists
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
)
)
)
and
os
.
listdir
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
)
):
self
.
path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
self
.
basename
))
self
.
isfetched
=
True
logging
.
debug
(
"Module
%
s (parent:
%
s) is fetched."
,
url
,
parent
.
path
)
else
:
self
.
path
=
None
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
,
url
,
parent
.
path
)
else
:
self
.
url
,
self
.
branch
,
self
.
revision
=
url
,
None
,
None
if
not
os
.
path
.
exists
(
url
):
logging
.
error
(
"Path to the local module doesn't exist:
\n
"
+
url
+
"
\n
This module was instantiated in: "
+
str
(
parent
))
quit
()
self
.
path
=
url
self
.
isfetched
=
True
hdlmake/module/module.py
View file @
f1d7e053
This diff is collapsed.
Click to expand it.
hdlmake/module/plugin.py
View file @
f1d7e053
...
...
@@ -3,4 +3,14 @@ class ModulePlugin(object):
def
process_manifest
(
self
):
pass
@
staticmethod
def
flatten_list
(
sth
):
"""Convert the argument in a list, being an empty list if none"""
if
sth
is
not
None
:
if
not
isinstance
(
sth
,
(
list
,
tuple
)):
sth
=
[
sth
]
else
:
sth
=
[]
return
sth
hdlmake/module/simulation.py
View file @
f1d7e053
...
...
@@ -40,7 +40,7 @@ class ModuleSimulation(ModulePlugin):
if
len
(
self
.
manifest_dict
[
"sim_only_files"
])
==
0
:
self
.
sim_only_files
=
SourceFileSet
()
else
:
self
.
manifest_dict
[
"sim_only_files"
]
=
self
.
_
flatten_list
(
self
.
manifest_dict
[
"sim_only_files"
])
self
.
manifest_dict
[
"sim_only_files"
]
=
ModulePlugin
.
flatten_list
(
self
.
manifest_dict
[
"sim_only_files"
])
paths
=
self
.
_make_list_of_paths
(
self
.
manifest_dict
[
"sim_only_files"
])
self
.
sim_only_files
=
self
.
_create_file_list_from_paths
(
paths
=
paths
)
...
...
hdlmake/module_pool.py
View file @
f1d7e053
...
...
@@ -97,8 +97,8 @@ class ModulePool(list):
new_module
=
Module
(
parent
=
parent
,
url
=
url
,
source
=
source
,
fetchto
=
fetchto
,
pool
=
self
)
fetchto
=
fetchto
)
new_module
.
set_pool
(
self
)
self
.
_add
(
new_module
)
if
not
self
.
top_module
:
self
.
top_module
=
new_module
...
...
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