Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hshetl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tools
hshetl
Commits
c4275e90
Commit
c4275e90
authored
11 years ago
by
Philipp Schiffmann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Started writing a JSON dumper for the YAML editor.
parent
7f70a215
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hshetl/editor.py
+56
-0
56 additions, 0 deletions
hshetl/editor.py
with
56 additions
and
0 deletions
hshetl/editor.py
0 → 100644
+
56
−
0
View file @
c4275e90
from
__future__
import
print_function
import
hshetl
import
yaml
import
json
def
find_subclasses
(
cls
):
result
=
[]
for
subcls
in
cls
.
__subclasses__
():
if
not
subcls
.
__module__
.
startswith
(
"
hshetl
"
):
continue
result
.
append
(
subcls
)
result
+=
find_subclasses
(
subcls
)
return
result
def
json_encode_class
(
cls
):
arg_resolver
=
hshetl
.
ConfigurationArgumentMatcher
()
props
,
required
=
arg_resolver
.
get_constructor_arguments
(
cls
)
cfg
=
{
"
yaml_tag
"
:
cls
.
yaml_tag
,
"
verbose_name
"
:
cls
.
__name__
,
"
properties
"
:
{}}
for
prop
in
props
:
cfg
[
"
properties
"
][
prop
]
=
{
"
type
"
:
"
!!str
"
,
"
form
"
:
{
"
display
"
:
"
textfield
"
}}
if
prop
in
required
:
cfg
[
"
properties
"
][
prop
][
"
defaults
"
]
=
"
foo
"
def
dump_schema
():
yaml_subclasses
=
{}
for
cls
in
find_subclasses
(
yaml
.
YAMLObject
):
name
=
cls
.
__module__
+
"
.
"
+
cls
.
__name__
yaml_subclasses
.
setdefault
(
name
,
cls
)
docs
=
{
"
order
"
:
[
"
connectors
"
,
"
entities
"
,
"
jobs
"
],
"
children
"
:
{
"
connectors
"
:
[],
"
entities
"
:
[
"
!entity
"
],
"
jobs
"
:
[]}}
classes
=
[]
for
cls
in
sorted
(
yaml_subclasses
):
print
(
yaml_subclasses
[
cls
])
continue
return
if
True
:
if
"
job
"
in
cls
.
__name__
.
lower
():
docs
[
"
children
"
][
"
jobs
"
].
append
(
cls
.
yaml_tag
)
elif
"
connector
"
in
cls
.
__name__
.
lower
():
docs
[
"
children
"
][
"
connectors
"
].
append
(
cls
.
yaml_tag
)
classes
.
append
(
json_encode_class
(
cls
))
with
open
(
'
editor_data.js
'
,
'
w
'
)
as
f
:
print
(
"
\"
use strict
\"
;
\n\n
var hshetl_editor_data =
"
+
json
.
dumps
({
"
documents
"
:
docs
,
"
classes
"
:
classes
},
indent
=
4
,
separators
=
(
'
,
'
,
'
:
'
)),
file
=
f
)
if
__name__
==
'
__main__
'
:
dump_schema
()
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