Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
force-bdss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adham Hashibon
force-bdss
Merge requests
!158
Introduces base class and interface for the factories
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Introduces base class and interface for the factories
49-base-class-for-factory
into
master
Overview
1
Commits
6
Pipelines
0
Changes
13
Merged
Adham Hashibon
requested to merge
49-base-class-for-factory
into
master
6 years ago
Overview
1
Commits
6
Pipelines
0
Changes
13
Expand
Created by: stefanoborini
Introduces a base class for the factories.
Fixes
#49 (closed)
0
0
Merge request reports
Viewing commit
857f5a5d
Prev
Next
Show latest version
13 files
+
150
−
257
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
13
Search (e.g. *.vue) (Ctrl+P)
857f5a5d
Introduces base class and interface for the factories
· 857f5a5d
Stefano Borini
authored
6 years ago
force_bdss/core/base_factory.py
0 → 100644
+
55
−
0
Options
from
envisage.plugin
import
Plugin
from
traits.api
import
HasStrictTraits
,
Str
,
Instance
from
force_bdss.ids
import
factory_id
class
BaseFactory
(
HasStrictTraits
):
#: Unique identifier that identifies the factory uniquely in the
#: universe of factories. Create one with the function factory_id()
id
=
Str
()
#: A human readable name of the factory. Spaces allowed
name
=
Str
()
#: Reference to the plugin that carries this factory
#: This is automatically set by the system. you should not define it
#: in your subclass.
plugin
=
Instance
(
Plugin
,
allow_none
=
False
)
def
__init__
(
self
,
plugin
):
super
(
BaseFactory
,
self
).
__init__
(
plugin
=
plugin
)
self
.
name
=
self
.
get_name
()
identifier
=
self
.
get_identifier
()
try
:
id
=
self
.
_global_id
(
identifier
)
except
ValueError
:
raise
ValueError
(
"
Invalid identifier {} returned by
"
"
{}.get_identifier()
"
.
format
(
identifier
,
self
.
__class__
.
__name__
)
)
self
.
id
=
id
def
get_name
(
self
):
"""
Must be reimplemented to return a user-visible name of the
data source.
"""
raise
NotImplementedError
(
"
get_name was not implemented in factory {}
"
.
format
(
self
.
__class__
))
def
get_identifier
(
self
):
"""
Must be reimplemented to return a unique string identifying
the factory. The provider is responsible to guarantee this identifier
to be unique across the plugin data sources.
"""
raise
NotImplementedError
(
"
get_identifier was not implemented in factory {}
"
.
format
(
self
.
__class__
))
def
_global_id
(
self
,
identifier
):
return
factory_id
(
self
.
plugin
.
id
,
identifier
)
Loading