Skip to content

Commit 16a0a1c

Browse files
Merge pull request #16 from bmeg/feature/update-grip-structse
Feature/update grip structs
2 parents e5729fa + b88905d commit 16a0a1c

File tree

9 files changed

+246
-109
lines changed

9 files changed

+246
-109
lines changed

.gitignore

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
.DS_Store# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
131+
# IDE
132+
.idea/
133+
134+
# scratch
135+
tmp/
136+
.DS_Store
137+
gencli

cmd/gen_dir/main.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"strings"
99

10+
"github.com/bmeg/grip/gripql"
1011
"github.com/bmeg/jsonschemagraph/graph"
1112
"github.com/bmeg/jsonschemagraph/util"
1213
"github.com/spf13/cobra"
@@ -124,19 +125,21 @@ var Cmd = &cobra.Command{
124125
}
125126

126127
var IedgeInit, VertexInit, OedegeInit = true, true, true
128+
jum := gripql.NewFlattenMarshaler()
127129
for line := range procChan {
128130
if result, err := out.Generate(ClassName, line, false, mapstringArgs); err == nil {
129131
for _, lin := range result {
130-
if b, err := json.Marshal(lin.Edge); err == nil {
131-
IedgeInit = util.Write_line(IedgeInit, b, InEdge_file, InEdge_gzWriter)
132-
}
133-
if b, err := json.Marshal(lin.Edge); err == nil {
134-
OedegeInit = util.Write_line(OedegeInit, b, OutEdege_file, OutEdge_gzWriter)
135-
136-
}
137-
if b, err := json.Marshal(lin.Vertex); err == nil {
138-
VertexInit = util.Write_line(VertexInit, b, vertex_file, Vertex_gzwriter)
139-
132+
if lin.Edge != nil {
133+
if b, err := jum.Marshal(lin.Edge); err == nil {
134+
IedgeInit = util.Write_line(IedgeInit, b, InEdge_file, InEdge_gzWriter)
135+
}
136+
if b, err := jum.Marshal(lin.Edge); err == nil {
137+
OedegeInit = util.Write_line(OedegeInit, b, OutEdege_file, OutEdge_gzWriter)
138+
}
139+
} else if lin.Vertex != nil {
140+
if b, err := jum.Marshal(lin.Vertex); err == nil {
141+
VertexInit = util.Write_line(VertexInit, b, vertex_file, Vertex_gzwriter)
142+
}
140143
}
141144
}
142145
} else if err != nil {

cmd/gen_graph/main.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"strings"
99

10+
"github.com/bmeg/grip/gripql"
1011
"github.com/bmeg/jsonschemagraph/graph"
1112
"github.com/bmeg/jsonschemagraph/util"
1213

@@ -119,18 +120,21 @@ var Cmd = &cobra.Command{
119120
}
120121

121122
var IedgeInit, VertexInit, OedegeInit = true, true, true
122-
123+
jum := gripql.NewFlattenMarshaler()
123124
for line := range procChan {
124125
if result, err := out.Generate(args[3], line, false, mapstringArgs); err == nil {
125126
for _, lin := range result {
126-
if b, err := json.Marshal(lin.Edge); err == nil {
127-
IedgeInit = util.Write_line(IedgeInit, b, InEdge_file, InEdge_gzWriter)
128-
}
129-
if b, err := json.Marshal(lin.Edge); err == nil {
130-
OedegeInit = util.Write_line(OedegeInit, b, OutEdege_file, OutEdge_gzWriter)
131-
}
132-
if b, err := json.Marshal(lin.Vertex); err == nil {
133-
VertexInit = util.Write_line(VertexInit, b, vertex_file, Vertex_gzwriter)
127+
if lin.Edge != nil {
128+
if b, err := jum.Marshal(lin.Edge); err == nil {
129+
IedgeInit = util.Write_line(IedgeInit, b, InEdge_file, InEdge_gzWriter)
130+
}
131+
if b, err := jum.Marshal(lin.Edge); err == nil {
132+
OedegeInit = util.Write_line(OedegeInit, b, OutEdege_file, OutEdge_gzWriter)
133+
}
134+
} else if lin.Vertex != nil {
135+
if b, err := jum.Marshal(lin.Vertex); err == nil {
136+
VertexInit = util.Write_line(VertexInit, b, vertex_file, Vertex_gzwriter)
137+
}
134138
}
135139
}
136140
} else if err != nil {

cmd/gen_graphql/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package gen_graphql
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"log"
6+
"os"
77

88
schema "github.com/bmeg/jsonschemagraph/graphql"
99
"github.com/spf13/cobra"
@@ -32,7 +32,7 @@ var Cmd = &cobra.Command{
3232

3333
config := Config{DependencyOrder: []string{}}
3434
if configPath != "" {
35-
data, err := ioutil.ReadFile(configPath)
35+
data, err := os.ReadFile(configPath)
3636
if err != nil {
3737
log.Fatalf("Failed to read YAML file: %v", err)
3838
}

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.24.0
66

77
require (
88
github.com/bmeg/golib v0.0.0-20200725232156-e799a31439fc
9-
github.com/bmeg/grip v0.0.0-20250328235822-525777e2873c
9+
github.com/bmeg/grip v0.0.0-20250421161012-b9b392fc8721
1010
github.com/bmeg/jsonschema/v5 v5.3.4-0.20241111204732-55db82022a92
1111
github.com/google/uuid v1.6.0
1212
github.com/spf13/cobra v1.8.1
@@ -31,6 +31,6 @@ require (
3131
golang.org/x/net v0.35.0 // indirect
3232
golang.org/x/sys v0.30.0 // indirect
3333
golang.org/x/term v0.29.0 // indirect
34-
google.golang.org/genproto v0.0.0-20230303212802-e74f57abe488 // indirect
34+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
3535
google.golang.org/grpc v1.70.0 // indirect
3636
)

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/bmeg/golib v0.0.0-20200725232156-e799a31439fc h1:/0v/ZcXYjGs44InmjECrls31onIbVKVu1Q/E2cmnCEU=
22
github.com/bmeg/golib v0.0.0-20200725232156-e799a31439fc/go.mod h1:hoSeuZtqe58ANXHuWpeODx4bDHGV36QXlCs1yrUvK6M=
3-
github.com/bmeg/grip v0.0.0-20250328235822-525777e2873c h1:QN0mMO3fEBfwskX3VMimiVQ9OWV2UNlf9zU4VNarwIQ=
4-
github.com/bmeg/grip v0.0.0-20250328235822-525777e2873c/go.mod h1:QSP37ElaIjyvmMZf+F1z3ZkfGWcVuFjoaujZiqhMyts=
3+
github.com/bmeg/grip v0.0.0-20250421161012-b9b392fc8721 h1:roEYW8/n2JHUWgIvF0d/o4N8xpK01FKLenVSwret5po=
4+
github.com/bmeg/grip v0.0.0-20250421161012-b9b392fc8721/go.mod h1:HZ9XI515z+VZe2YbBocZZHIswWLAJKj5mPDW7r38vyM=
55
github.com/bmeg/jsonschema/v5 v5.3.4-0.20241111204732-55db82022a92 h1:Myx/j+WxfEg+P3nDaizR1hBpjKSLgvr4ydzgp1/1pAU=
66
github.com/bmeg/jsonschema/v5 v5.3.4-0.20241111204732-55db82022a92/go.mod h1:6v27bSBKXyIDFqlKQbUSnHlekE1y6bDkgWCuVEaDPng=
77
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
@@ -75,8 +75,8 @@ golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
7575
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
7676
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
7777
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
78-
google.golang.org/genproto v0.0.0-20230303212802-e74f57abe488 h1:QQF+HdiI4iocoxUjjpLgvTYDHKm99C/VtTBFnfiCJos=
79-
google.golang.org/genproto v0.0.0-20230303212802-e74f57abe488/go.mod h1:TvhZT5f700eVlTNwND1xoEZQeWTB2RY/65kplwl/bFA=
78+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A=
79+
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU=
8080
google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ=
8181
google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw=
8282
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=

0 commit comments

Comments
 (0)