Skip to content

Commit

Permalink
Execution control for Table.write and various widget tweaks... (#6835)
Browse files Browse the repository at this point in the history
- Adds execution control to `Table.write`.
- Refactored the `Text.write` to make part reusable.
- Tidied up some legacy mess in tests.
- Add easier flow to go from `Text` to an `URI` to fetching data.
- Add decode functions to `Response` and `Response_Body`.
- Fix issue with 0 length regex matches (using same as Python and .Net approach).
- Add various ALIAS entries to make function discovery easier.
- Sort a lot of drop down and vector editors out (including switch to fully qualified names).
  • Loading branch information
jdunkerley authored Jun 1, 2023
1 parent 0337180 commit 343b5fb
Show file tree
Hide file tree
Showing 45 changed files with 485 additions and 265 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
- [Implemented the `cast` operation for `Table` and `Column`.][6711]
- [Added `.round` and `.int` to `Integer` and `Decimal`.][6743]
- [Added `.round`, `.truncate`, `.ceil`, and `.floor` to `Column`.][6817]
- [Added execution control to `Table.write` and various bug fixes.][6835]

[debug-shortcuts]:
https://github.com/enso-org/enso/blob/develop/app/gui/docs/product/shortcuts.md#debug
Expand Down Expand Up @@ -684,6 +685,7 @@
[6711]: https://github.com/enso-org/enso/pull/6711
[6743]: https://github.com/enso-org/enso/pull/6743
[6817]: https://github.com/enso-org/enso/pull/6817
[6835]: https://github.com/enso-org/enso/pull/6835

#### Enso Compiler

Expand Down
10 changes: 2 additions & 8 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ type Any
to_display_text : Text
to_display_text self = @Builtin_Method "Any.to_display_text"

## ALIAS Equality

## ALIAS Equals
Checks if `self` is equal to `that`.

Arguments:
Expand Down Expand Up @@ -110,8 +109,7 @@ type Any
== : Any -> Boolean
== self that = @Builtin_Method "Any.=="

## ALIAS Inequality

## ALIAS Not Equals
Checks if `self` is not equal to `that`.

Arguments:
Expand All @@ -134,7 +132,6 @@ type Any
!= self that = (self == that).not

## ALIAS Greater Than

Checks if `self` is greater than `that`.

Arguments:
Expand Down Expand Up @@ -162,7 +159,6 @@ type Any
_ -> False

## ALIAS Greater Than or Equal

Checks if `self` is greater than or equal to `that`.

Arguments:
Expand Down Expand Up @@ -192,7 +188,6 @@ type Any
_ -> False

## ALIAS Less Than

Checks if `self` is less than `that`.

Arguments:
Expand Down Expand Up @@ -220,7 +215,6 @@ type Any
_ -> False

## ALIAS Less Than or Equal

Checks if `self` is less than or equal to `that`.

Arguments:
Expand Down
30 changes: 20 additions & 10 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data.enso
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ list_directory : (File | Text) -> Text -> Boolean -> Vector File
list_directory directory name_filter=Nothing recursive=False =
File.new directory . list name_filter=name_filter recursive=recursive

## Fetches from the provided URL and returns the response body.
Will error if the status code does not represent a successful response.
## ALIAS Download, HTTP Get
Fetches from the provided URI and returns the response, parsing the body if
the content-type is recognised. Returns an error if the status code does not
represent a successful response.

Arguments:
- url: The URL to fetch.
- uri: The URI to fetch.
- method: The HTTP method to use. Defaults to `GET`.
- headers: The headers to send with the request. Defaults to an empty vector.
- parse: If successful should the body be parsed to an Enso native object.
Expand All @@ -159,10 +161,18 @@ fetch uri method=HTTP_Method.Get headers=[] parse=True =
request = Request.new method uri parsed_headers
response = HTTP.new.request request

if response.code.is_success.not then Error.throw (Request_Error.Error "Status Code" ("Request failed with status code: " + response.code.to_text + ". " + response.body.to_text)) else
response_headers = response.headers
content_type = response_headers.find if_missing=Nothing h-> "Content-Type".equals_ignore_case h.name
if (parse == False) || (content_type == Nothing) then response else
format = Auto_Detect.get_web_parser content_type.value uri
if format == Nothing then response else
format.read_web response
if response.code.is_success.not then Error.throw (Request_Error.Error "Status Code" ("Request failed with status code: " + response.code.to_text + ". " + response.body.decode_as_text)) else
if parse then response.decode if_unsupported=response else response

## ALIAS Download, HTTP Get
Fetches from the URI and returns the response, parsing the body if the
content-type is recognised. Returns an error if the status code does not
represent a successful response.

Arguments:
- method: The HTTP method to use. Defaults to `GET`.
- headers: The headers to send with the request. Defaults to an empty vector.
- parse: If successful should the body be parsed to an Enso native object.
URI.fetch : HTTP_Method -> Vector (Header | Pair Text Text) -> Boolean -> Any
URI.fetch self method=HTTP_Method.Get headers=[] parse=True =
Data.fetch self method headers parse
3 changes: 2 additions & 1 deletion distribution/lib/Standard/Base/0.0.0-dev/src/Data/Array.enso
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,8 @@ type Array
each_with_index : (Integer -> Any -> Any) -> Nothing
each_with_index self f = Vector.each_with_index self f

## Concatenates two arrays, resulting in a new `Vector`, containing all the
## ALIAS Concatenate
Concatenates two arrays, resulting in a new `Vector`, containing all the
elements of `self`, followed by all the elements of `that`.

Arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type Boolean
True
False

## Computes the logical and (conjunction) of two booleans.
## ALIAS And
Computes the logical and (conjunction) of two booleans.

Arguments:
- that: The boolean to compute the conjunction of this with.
Expand All @@ -31,7 +32,8 @@ type Boolean
&& : Boolean -> Boolean
&& self ~that = @Builtin_Method "Boolean.&&"

## Computes the logical or (disjunction) of two booleans.
## ALIAS Or
Computes the logical or (disjunction) of two booleans.

Arguments:
- that: The boolean to compute the disjunction of this with.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,6 @@ type Filter_Condition
Not_In values -> "is not in " + values.to_display_text
"Filter Condition: " + condition

## PRIVATE
Gets a widget set up for a Filter_Condition.
default_widget : Widget
default_widget =
names = ["Equal", "Not Equal", "Is In", "Not In", "Is True", "Is False", "Is Nothing", "Not Nothing", "Is Empty", "Not Empty", "Less", "Equal Or Less", "Greater", "Equal Or Greater", "Between", "Starts With", "Ends With", "Contains", "Not Contains", "Like", "Not Like"]
values = ["(Filter_Condition.Equal)", "(Filter_Condition.Not_Equal)", "(Filter_Condition.Is_In)", "(Filter_Condition.Not_In)", "Filter_Condition.Is_True", "Filter_Condition.Is_False", "Filter_Condition.Is_Nothing", "Filter_Condition.Not_Nothing", "Filter_Condition.Is_Empty", "Filter_Condition.Not_Empty", "(Filter_Condition.Less)", "(Filter_Condition.Equal_Or_Less)", "(Filter_Condition.Greater)", "(Filter_Condition.Equal_Or_Greater)", "(Filter_Condition.Between)", "(Filter_Condition.Starts_With)", "(Filter_Condition.Ends_With)", "(Filter_Condition.Contains)", "(Filter_Condition.Not_Contains)", "(Filter_Condition.Like)", "(Filter_Condition.Not_Like)"]
options = names.zip values . map p-> Option p.first p.second
Single_Choice values=options display=Display.Always

## PRIVATE
sql_like_to_regex sql_pattern =
regex_pattern = Regex_Utils.sql_like_pattern_to_regex sql_pattern
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,5 +445,6 @@ type Locale
widget_options : Vector Option
widget_options = Locale.predefined_locale_fields.map field_name->
display_string = field_name.replace '_' ' ' . to_case (if field_name.length == 2 then Case.Upper else Case.Title)
code_string = "Locale." + field_name
fqn = Meta.get_qualified_type_name Locale
code_string = fqn + "." + field_name
Option display_string code_string
Loading

0 comments on commit 343b5fb

Please sign in to comment.