Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sams-hub-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
coding-at-fu
sams-hub-creator
Commits
09669027
Commit
09669027
authored
7 years ago
by
Sebastian Lobinger
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parents
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
__init__.py
+40
-0
40 additions, 0 deletions
__init__.py
with
40 additions
and
0 deletions
__init__.py
0 → 100644
+
40
−
0
View file @
09669027
import
yaml
,
os
,
glob
from
sams_classes
import
SAMSHub
,
SAMSApp
from
flask
import
Flask
def
create_hub
(
conf_part_hub
,
conf_part_apps
=
'
apps
'
,
config_file_path
=
'
config/config.yaml
'
,
dir_apps
=
'
.
'
):
with
open
(
config_file_path
,
'
r
'
)
as
f
:
hubConf
=
yaml
.
load
(
f
.
read
())
hub
=
SAMSHub
(
name
=
__name__
,
config
=
hubConf
[
hub_conf_key
])
hub
.
flaskApp
.
config
.
update
(
hubConf
.
get
(
'
flask
'
,
{}))
for
appEntry
in
hubConf
[
'
apps
'
]:
appName
=
appEntry
[
'
name
'
]
appAlias
=
appEntry
.
get
(
'
alias
'
)
with
open
(
os
.
path
.
join
(
dir_apps
,
appName
.
replace
(
'
.
'
,
'
/
'
)
,
'
manifest.yaml
'
))
as
f
:
manifest
=
yaml
.
load
(
f
.
read
())
langDict
=
{
'
en
'
:
{}}
for
yaml_file
in
search_yaml_files
(
os
.
path
.
join
(
dir_apps
,
appName
.
replace
(
'
.
'
,
'
/
'
),
'
lang/
'
)):
with
open
(
yaml_file
)
as
f
:
singleLang
=
yaml
.
load
(
f
.
read
())
langDict
.
update
(
{
os
.
path
.
splitext
(
os
.
path
.
basename
(
yaml_file
))[
0
]:
singleLang
})
hub
.
addApp
(
SAMSApp
(
name
=
appName
,
manifest
=
manifest
,
langDict
=
langDict
),
alias
=
appAlias
)
return
hub
def
search_yaml_files
(
path
,
exts
=
[
'
.yaml
'
,
'
.yml
'
]):
matchingFiles
=
[]
for
ext
in
exts
:
for
path
in
glob
.
glob
(
path
+
'
*
'
+
ext
):
if
os
.
path
.
isfile
(
path
):
matchingFiles
.
append
(
path
)
return
matchingFiles
if
__name__
==
'
__main__
'
:
create_hub
()
else
:
hub
=
create_hub
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment