-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGenerateIndexPy.fs
49 lines (41 loc) · 1.69 KB
/
GenerateIndexPy.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module GenerateIndexPy
open System
open System.IO
open System.Text.RegularExpressions
open System.Text
let createImportStatement path (classes : string []) =
let classes = classes |> Array.reduce (fun acc x -> acc + ", " + x)
sprintf "from %s import %s" path classes
let writePyIndexfile (path: string) (content: string) =
let filePath = Path.Combine(path, "arctrl.py")
File.WriteAllText(filePath, content)
let generateIndexFileContent (classes : (string*string) []) =
classes
|> Array.groupBy fst
|> Array.map (fun (p,a) -> createImportStatement p (a |> Array.map snd))
let classes =
[|
"__future__", "annotations"
"collections.abc", "Callable"
"typing", "Any"
".ISA.ISA.JsonTypes.comment", "Comment"
".ISA.ISA.JsonTypes.ontology_annotation","OntologyAnnotation";
".ISA.ISA.JsonTypes.person", "Person";
".ISA.ISA.JsonTypes.publication", "Publication";
".ISA.ISA.ArcTypes.composite_header", "IOType"
".ISA.ISA.ArcTypes.composite_header", "CompositeHeader";
".ISA.ISA.ArcTypes.composite_cell", "CompositeCell"
".ISA.ISA.ArcTypes.composite_column", "CompositeColumn"
".ISA.ISA.ArcTypes.arc_table", "ArcTable"
".ISA.ISA.ArcTypes.arc_types", "ArcAssay";
".ISA.ISA.ArcTypes.arc_types", "ArcStudy";
".ISA.ISA.ArcTypes.arc_types", "ArcInvestigation";
".Templates.template", "Template"
".Templates.templates", "Templates"
".Templates.template", "Organisation"
".arc","ARC"
|]
let ARCtrl_generate (rootPath: string) =
generateIndexFileContent classes
|> Array.reduce (fun a b -> a + "\n" + b)
|> writePyIndexfile rootPath