Skip to content

Commit 479da00

Browse files
committed
Restructure project
1 parent 1e9c983 commit 479da00

File tree

16 files changed

+66
-27
lines changed

16 files changed

+66
-27
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ dmypy.json
131131
obj
132132
bin
133133
build
134+
135+
.idea/

Build.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ open Helpers
66
initializeContext()
77

88
let buildPath = Path.getFullName "build"
9-
let srcPath = Path.getFullName "stdlib"
9+
let srcPath = Path.getFullName "src"
1010
let deployPath = Path.getFullName "deploy"
1111
let testsPath = Path.getFullName "test"
1212

@@ -21,7 +21,7 @@ Target.create "Clean" (fun _ ->
2121

2222
Target.create "Build" (fun _ ->
2323
Shell.mkdir buildPath
24-
run dotnet $"run -c Release -p {cliPath} -- --lang Python --exclude Fable.Core --outDir {buildPath}/stdlib" srcPath
24+
run dotnet $"run -c Release -p {cliPath} -- --lang Python --exclude Fable.Core --outDir {buildPath}" srcPath
2525
)
2626

2727
Target.create "Run" (fun _ ->
@@ -34,8 +34,6 @@ Target.create "Test" (fun _ ->
3434
"python", dotnet $"run -c Release -p {cliPath} -- --lang Python --exclude Fable.Core --outDir {buildPath}/tests" testsPath
3535
]
3636
|> runParallel
37-
Shell.Exec("touch", $"{buildPath}/tests/__init__.py") |> ignore
38-
Shell.Exec("touch", $"{buildPath}/tests/stdlib/__init__.py") |> ignore
3937
run pytest $"{buildPath}/tests" ""
4038
)
4139

examples/flask/App.fs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ module Safe
33
open Fable.Python.Builtins
44
open Flask
55

6-
let app = Flask.Create(__name__)
6+
let app = Flask(__name__)
77
let index = app.route("/")
88

9+
let a = builtins.len
10+
911
let hello_world () =
1012
"<p>Hello, World!</p>"
1113
//flask.render_template()
1214

13-
hello_world |> index |> ignore
15+
hello_world |> index |> ignore
16+
17+
[<EntryPoint>]
18+
let main args =
19+
1

examples/flask/Flask.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
55
<GenerateProgramFile>false</GenerateProgramFile>
66
<Author>Dag Brattli</Author>
77
<Copyright>Dag Brattli</Copyright>
8+
<OutputType>Exe</OutputType>
89
</PropertyGroup>
910
<ItemGroup>
1011
<Compile Include="App.fs" />
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project Sdk="Microsoft.NET.Sdk">
33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Author>Dag Brattli</Author>
77
<Copyright>Dag Brattli</Copyright>
88
<PackageLicenseFile>LICENSE</PackageLicenseFile>
9+
<Version>0.3.0</Version>
910
<WarnOn>3390;$(WarnOn)</WarnOn>
1011
</PropertyGroup>
1112
<ItemGroup>
12-
<Compile Include="Ast.fs" />
13-
<Compile Include="Builtins.fs" />
14-
<Compile Include="Json.fs" />
15-
<Compile Include="Os.fs" />
13+
<Compile Include="stdlib/Ast.fs" />
14+
<Compile Include="stdlib/Builtins.fs" />
15+
<Compile Include="stdlib/Json.fs" />
16+
<Compile Include="stdlib/Os.fs" />
17+
<Compile Include="stdlib/TkInter.fs" />
18+
19+
<Compile Include="flask/Flask.fs" />
20+
21+
<Compile Include="cognite-sdk/CogniteSdk.fs" />
1622
</ItemGroup>
1723
<ItemGroup>
1824
<ProjectReference Include="../../Fable/src/Fable.Core/Fable.Core.fsproj" />
@@ -21,7 +27,7 @@
2127
<Content Include="pyproject.toml; *.fsproj; **\*.fs; **\*.fsi" PackagePath="fable\" />
2228
</ItemGroup>
2329
<ItemGroup>
24-
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath=""/>
30+
<None Include="..\LICENSE" Pack="true" Visible="false" PackagePath="" />
2531
</ItemGroup>
2632
<Import Project="..\.paket\Paket.Restore.targets" />
2733
</Project>

src/cognite-sdk/CogniteSdk.fs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Fable.Python.CogniteSdk
2+
3+
open Fable.Core
4+
5+
type ITimeSeries =
6+
abstract plot: start: string * ``end``: string * aggregates: string array * granularity: string -> unit
7+
8+
type ITimeSeriesApi =
9+
abstract retrieve: id: int64 -> ITimeSeries
10+
abstract list: unit -> ITimeSeries list
11+
12+
[<Import("CogniteClient", from="cognite.client")>]
13+
type CogniteClient (?apiKey: string, ?api_subversion: string, ?project: string, ?clientName: string) =
14+
abstract member time_series: ITimeSeriesApi with get
15+
default this.time_series with get () = nativeOnly
16+
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Flask
1+
module Fable.Python.Flask
22

33
open Fable.Core
44

@@ -9,22 +9,16 @@ type RequestBase =
99
type Request =
1010
inherit RequestBase
1111

12-
type Flask =
13-
abstract route : rule: string -> ((unit -> string) -> Flask)
14-
abstract route : rule: string * methods: string array -> ((unit -> string) -> Flask)
15-
16-
17-
type FlaskStatic =
18-
[<Emit("$0(import_name=$1)")>]
19-
abstract Create : string -> Flask
20-
2112
[<Import("Flask", "flask")>]
22-
let Flask: FlaskStatic = nativeOnly
13+
type Flask (name: string) =
14+
member _.route(rule: string) : ((unit -> string) -> Flask) = nativeOnly
15+
member _.route(rule: string, methods: string array) : ((unit -> string) -> Flask) = nativeOnly
16+
2317

2418
type IExports =
2519
abstract render_template : template_name_or_list: string -> string
2620
abstract render_template : template_name_or_list: string seq -> string
2721
abstract request : Request
2822

2923
[<ImportAll("flask")>]
30-
let flask : IExports = nativeOnly
24+
let flask: IExports = nativeOnly
File renamed without changes.

0 commit comments

Comments
 (0)