9
9
"strings"
10
10
"strconv"
11
11
"os/exec"
12
+ "regexp"
12
13
)
13
14
14
15
type node struct {
@@ -42,6 +43,8 @@ func main() {
42
43
verbose := flag .Bool ("verbose" , false , "log iteration through file tree" )
43
44
flag .Parse ()
44
45
46
+ reStr := regexp .MustCompile (`\W` )
47
+
45
48
err := filepath .Walk ("." , func (path string , info os.FileInfo , err error ) error {
46
49
if err != nil {
47
50
return err
@@ -79,7 +82,7 @@ func main() {
79
82
pre := "a_"
80
83
id := strings .Replace (element , "." , "_" , - 1 )
81
84
id = pre + id
82
- id = strings . Replace (id , "-" , "_" , - 1 )
85
+ id = reStr . ReplaceAllString (id , "$1" )
83
86
id += strconv .Itoa (i )
84
87
if (info .IsDir () == false ) {
85
88
groups := strings .Split (element , "." )
@@ -92,7 +95,7 @@ func main() {
92
95
93
96
ParentId := strings .Replace (pathSegments [parentIndex ], "." , "_" , - 1 )
94
97
ParentId = pre + ParentId
95
- ParentId = strings . Replace (ParentId , "-" , "_" , - 1 )
98
+ ParentId = reStr . ReplaceAllString (ParentId , "$1" )
96
99
ParentId += strconv .Itoa (parentIndex )
97
100
98
101
if (ext != "DS_Store" ) {
@@ -150,6 +153,7 @@ func main() {
150
153
for _ , c := range currentFile .Contributers {
151
154
if (len (c ) > 3 ) {
152
155
contributerId := "c_" + strings .Replace (c , " " , "" , - 1 )
156
+ contributerId = reStr .ReplaceAllString (contributerId , "$1" )
153
157
if (! Contains (processedContributers , c )) {
154
158
fmt .Println ("CREATE (" + contributerId + ":" + "person" + " { name: '" + c + "' })" )
155
159
processedContributers = append (processedContributers , c )
0 commit comments