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
cb5ecb5c
Commit
cb5ecb5c
authored
Oct 28, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge module/core.py into module/content.py
parent
d65d88c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
111 deletions
+91
-111
content.py
hdlmake/module/content.py
+90
-3
core.py
hdlmake/module/core.py
+0
-106
module.py
hdlmake/module/module.py
+1
-2
No files found.
hdlmake/module/content.py
View file @
cb5ecb5c
...
...
@@ -5,12 +5,27 @@ from __future__ import absolute_import
import
logging
from
..fetch.git
import
Git
from
..util
import
path
as
path_mod
from
.core
import
ModuleConfig
import
six
import
os
class
ModuleArgs
(
object
):
"""This class is just a container for the main Module args"""
class
ModuleContent
(
ModuleConfig
):
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
(
object
):
"""Class providing the HDLMake module content"""
...
...
@@ -24,7 +39,79 @@ class ModuleContent(ModuleConfig):
self
.
pool
=
None
self
.
top_manifest
=
None
self
.
manifest_dict
=
{}
super
(
ModuleContent
,
self
)
.
__init__
()
self
.
source
=
None
self
.
parent
=
None
self
.
url
=
None
self
.
branch
=
None
self
.
revision
=
None
self
.
path
=
None
self
.
isfetched
=
False
def
init_config
(
self
,
module_args
):
"""This initializes the module configuration.
The function is executed by Module constructor"""
self
.
parent
=
module_args
.
parent
url
=
module_args
.
url
self
.
source
=
module_args
.
source
fetchto
=
module_args
.
fetchto
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
)
basename
=
path_mod
.
svn_basename
(
self
.
url
)
else
:
self
.
url
,
self
.
branch
,
self
.
revision
=
path_mod
.
url_parse
(
url
)
basename
=
path_mod
.
url_basename
(
self
.
url
)
self
.
path
=
path_mod
.
relpath
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
basename
)))
# Check if the module dir exists and is not empty
if
os
.
path
.
exists
(
self
.
path
)
and
os
.
listdir
(
self
.
path
):
self
.
isfetched
=
True
logging
.
debug
(
"Module
%
s (parent:
%
s) is fetched."
,
url
,
self
.
parent
.
path
)
else
:
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
,
url
,
self
.
parent
.
path
)
def
_check_filepath
(
self
,
filepath
):
"""Check the provided filepath against several conditions"""
if
filepath
:
if
path_mod
.
is_abs_path
(
filepath
):
logging
.
warning
(
"Specified path seems to be an absolute path: "
+
filepath
+
"
\n
Omitting."
)
return
False
filepath
=
os
.
path
.
join
(
self
.
path
,
filepath
)
if
not
os
.
path
.
exists
(
filepath
):
raise
Exception
(
"Path specified in manifest {} doesn't exist: {}"
.
format
(
self
.
path
,
filepath
))
filepath
=
path_mod
.
rel2abs
(
filepath
,
self
.
path
)
if
os
.
path
.
isdir
(
filepath
):
logging
.
warning
(
"Path specified in manifest
%
s is a directory:
%
s"
,
self
.
path
,
filepath
)
return
True
def
_make_list_of_paths
(
self
,
list_of_paths
):
"""Get a list with only the valid absolute paths from the provided"""
paths
=
[]
for
filepath
in
list_of_paths
:
if
self
.
_check_filepath
(
filepath
):
paths
.
append
(
path_mod
.
rel2abs
(
filepath
,
self
.
path
))
return
paths
def
process_manifest
(
self
):
"""Process the content section of the manifest_dict"""
...
...
hdlmake/module/core.py
deleted
100644 → 0
View file @
d65d88c8
"""Provides the core functionality for the HDLMake module"""
from
__future__
import
absolute_import
import
os
import
sys
import
logging
from
..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
need to be initialized for a proper behavior"""
def
__init__
(
self
):
self
.
source
=
None
self
.
parent
=
None
self
.
url
=
None
self
.
branch
=
None
self
.
revision
=
None
self
.
path
=
None
self
.
isfetched
=
False
def
init_config
(
self
,
module_args
):
"""This initializes the module configuration.
The function is executed by Module constructor"""
self
.
parent
=
module_args
.
parent
url
=
module_args
.
url
self
.
source
=
module_args
.
source
fetchto
=
module_args
.
fetchto
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
)
basename
=
path_mod
.
svn_basename
(
self
.
url
)
else
:
self
.
url
,
self
.
branch
,
self
.
revision
=
path_mod
.
url_parse
(
url
)
basename
=
path_mod
.
url_basename
(
self
.
url
)
self
.
path
=
path_mod
.
relpath
(
os
.
path
.
abspath
(
os
.
path
.
join
(
fetchto
,
basename
)))
# Check if the module dir exists and is not empty
if
os
.
path
.
exists
(
self
.
path
)
and
os
.
listdir
(
self
.
path
):
self
.
isfetched
=
True
logging
.
debug
(
"Module
%
s (parent:
%
s) is fetched."
,
url
,
self
.
parent
.
path
)
else
:
self
.
isfetched
=
False
logging
.
debug
(
"Module
%
s (parent:
%
s) is NOT fetched."
,
url
,
self
.
parent
.
path
)
def
_check_filepath
(
self
,
filepath
):
"""Check the provided filepath against several conditions"""
if
filepath
:
if
path_mod
.
is_abs_path
(
filepath
):
logging
.
warning
(
"Specified path seems to be an absolute path: "
+
filepath
+
"
\n
Omitting."
)
return
False
filepath
=
os
.
path
.
join
(
self
.
path
,
filepath
)
if
not
os
.
path
.
exists
(
filepath
):
raise
Exception
(
"Path specified in manifest {} doesn't exist: {}"
.
format
(
self
.
path
,
filepath
))
filepath
=
path_mod
.
rel2abs
(
filepath
,
self
.
path
)
if
os
.
path
.
isdir
(
filepath
):
logging
.
warning
(
"Path specified in manifest
%
s is a directory:
%
s"
,
self
.
path
,
filepath
)
return
True
def
_make_list_of_paths
(
self
,
list_of_paths
):
"""Get a list with only the valid absolute paths from the provided"""
paths
=
[]
for
filepath
in
list_of_paths
:
if
self
.
_check_filepath
(
filepath
):
paths
.
append
(
path_mod
.
rel2abs
(
filepath
,
self
.
path
))
return
paths
hdlmake/module/module.py
View file @
cb5ecb5c
...
...
@@ -35,8 +35,7 @@ import logging
from
..util
import
path
as
path_mod
from
..util
import
shell
from
..manifest_parser.manifestparser
import
ManifestParser
from
.content
import
ModuleContent
from
.core
import
ModuleArgs
from
.content
import
ModuleContent
,
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