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
ca7cdc4b
Commit
ca7cdc4b
authored
Aug 18, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A more straighforward way of using the fetcher's backends
parent
f1c0bc62
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
76 deletions
+13
-76
core.py
hdlmake/action/core.py
+11
-3
__init__.py
hdlmake/fetch/__init__.py
+2
-2
backend_factory.py
hdlmake/fetch/backend_factory.py
+0
-57
constants.py
hdlmake/fetch/constants.py
+0
-14
No files found.
hdlmake/action/core.py
View file @
ca7cdc4b
...
...
@@ -34,6 +34,8 @@ import hdlmake.new_dep_solver as dep_solver
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.srcfile
import
VerilogFile
,
VHDLFile
,
NGCFile
from
hdlmake.vlog_parser
import
VerilogPreprocessor
from
hdlmake.fetch
import
Svn
,
Git
,
Local
from
hdlmake.fetch
import
SVN
,
GIT
,
LOCAL
from
.action
import
Action
...
...
@@ -43,6 +45,9 @@ class ActionCore(Action):
def
__init__
(
self
,
*
args
):
super
(
ActionCore
,
self
)
.
__init__
(
*
args
)
self
.
git_backend
=
Git
()
self
.
svn_backend
=
Svn
()
self
.
local_backend
=
Local
()
def
_fetch_all
(
self
):
"""Fetch all the modules declared in the design"""
...
...
@@ -51,9 +56,12 @@ class ActionCore(Action):
"""Fetch the given module from the remote origin"""
new_modules
=
[]
logging
.
debug
(
"Fetching module:
%
s"
,
str
(
module
))
backend
=
fetch
.
FETCH_TYPE_LOOKUP
.
get_backend
(
module
)
fetcher
=
backend
()
result
=
fetcher
.
fetch
(
module
)
if
module
.
source
is
SVN
:
result
=
self
.
svn_backend
.
fetch
(
module
)
elif
module
.
source
is
GIT
:
result
=
self
.
git_backend
.
fetch
(
module
)
elif
module
.
source
is
LOCAL
:
result
=
self
.
local_backend
.
fetch
(
module
)
if
result
is
False
:
logging
.
error
(
"Unable to fetch module
%
s"
,
str
(
module
.
url
))
sys
.
exit
(
"Exiting"
)
...
...
hdlmake/fetch/__init__.py
View file @
ca7cdc4b
...
...
@@ -21,7 +21,7 @@
"""This package provides stuff to handle local and remote repositories"""
from
.constants
import
(
GIT
,
SVN
,
LOCAL
,
FETCH_TYPE_LOOKUP
)
from
.constants
import
(
GIT
,
SVN
,
LOCAL
)
from
.git
import
Git
from
.svn
import
Svn
from
.
backend_factory
import
BackendFactory
from
.
local
import
Local
hdlmake/fetch/backend_factory.py
deleted
100644 → 0
View file @
f1c0bc62
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
"""Module providing the BackendFactory, a mechanism to create fetchers"""
from
__future__
import
absolute_import
import
logging
from
.constants
import
(
LOCAL
)
import
six
class
BackendFactory
(
object
):
"""Class providing instances that can be used to build fetchers
for the required source origin (Local, Git, SVN)"""
def
__init__
(
self
):
self
.
backend_table
=
{}
def
register_backend
(
self
,
backend_id
,
backend
):
"""Add a mapping: backend_id -> backend"""
self
.
backend_table
[
backend_id
]
=
backend
def
get_backend
(
self
,
module
):
"""Get the appropriated source origin backend for the given module"""
try
:
if
module
.
source
!=
LOCAL
:
logging
.
info
(
"Investigating module: "
+
str
(
module
)
+
"[parent: "
+
str
(
module
.
parent
)
+
"]"
)
backend
=
self
.
backend_table
[
module
.
source
]
except
KeyError
:
error_string
=
"No registered backend found for module: "
+
\
str
(
module
)
+
"
\n
"
+
\
"Registered backends are:
\n
"
for
backend_id
in
six
.
iterkeys
(
self
.
backend_table
):
error_string
+=
"
\t
%
d"
%
(
backend_id
)
logging
.
error
(
error_string
)
raise
return
backend
hdlmake/fetch/constants.py
View file @
ca7cdc4b
...
...
@@ -28,17 +28,3 @@
GIT
=
1
SVN
=
2
LOCAL
=
3
from
.svn
import
Svn
from
.git
import
Git
from
.local
import
Local
from
.backend_factory
import
BackendFactory
# Initialize an instance of BackendFactory which will be made publicly
# available
FETCH_TYPE_LOOKUP
=
BackendFactory
()
FETCH_TYPE_LOOKUP
.
register_backend
(
GIT
,
Git
)
FETCH_TYPE_LOOKUP
.
register_backend
(
SVN
,
Svn
)
FETCH_TYPE_LOOKUP
.
register_backend
(
LOCAL
,
Local
)
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