You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.go 1.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package ops
  2. import (
  3. "fmt"
  4. "gitlink.org.cn/cloudream/common/pkgs/ioswitch/dag"
  5. )
  6. func formatStreamIO(node *dag.Node) string {
  7. is := ""
  8. for i, in := range node.InputStreams {
  9. if i > 0 {
  10. is += ","
  11. }
  12. if in == nil {
  13. is += "."
  14. } else {
  15. is += fmt.Sprintf("%v", in.ID)
  16. }
  17. }
  18. os := ""
  19. for i, out := range node.OutputStreams {
  20. if i > 0 {
  21. os += ","
  22. }
  23. if out == nil {
  24. os += "."
  25. } else {
  26. os += fmt.Sprintf("%v", out.ID)
  27. }
  28. }
  29. if is == "" && os == "" {
  30. return ""
  31. }
  32. return fmt.Sprintf("S{%s>%s}", is, os)
  33. }
  34. func formatValueIO(node *dag.Node) string {
  35. is := ""
  36. for i, in := range node.InputValues {
  37. if i > 0 {
  38. is += ","
  39. }
  40. if in == nil {
  41. is += "."
  42. } else {
  43. is += fmt.Sprintf("%v", in.ID)
  44. }
  45. }
  46. os := ""
  47. for i, out := range node.OutputValues {
  48. if i > 0 {
  49. os += ","
  50. }
  51. if out == nil {
  52. os += "."
  53. } else {
  54. os += fmt.Sprintf("%v", out.ID)
  55. }
  56. }
  57. if is == "" && os == "" {
  58. return ""
  59. }
  60. return fmt.Sprintf("V{%s>%s}", is, os)
  61. }