From 50484c9603d048ff46b868be984a8a19a462df0f Mon Sep 17 00:00:00 2001 From: Christian Duarte <97495088+cduarte3@users.noreply.github.com> Date: Thu, 31 Oct 2024 11:56:54 -0400 Subject: [PATCH 1/2] added kotlin io operations --- web/thesauruses/kotlin/1.5/io.json | 270 +++++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 web/thesauruses/kotlin/1.5/io.json diff --git a/web/thesauruses/kotlin/1.5/io.json b/web/thesauruses/kotlin/1.5/io.json new file mode 100644 index 000000000..1f9333918 --- /dev/null +++ b/web/thesauruses/kotlin/1.5/io.json @@ -0,0 +1,270 @@ +{ + "meta": { + "language": "kotlin", + "language_name": "Kotlin", + "structure": "io", + "language_version": "1.5" + }, + "concepts": { + "write_line": { + "code": [ + "print(\"...\")" + ] + }, + "write_line_with_new_line": { + "code": [ + "println(\"...\")" + ] + }, + "read_line": { + "code": [ + "val variable_name = readln()" + ] + }, + "read_char": { + "code": [ + "val variable_name = readln()", + "val first_char = variable_name[0]" + ], + "comment": [ + "First character can be read by accessing the first element of the string" + ] + }, + "clear_console_output": { + "not-implemented": true + }, + "change_console_background_color": { + "not-implemented": true + }, + "change_console_text_color": { + "not-implemented": true + }, + "file_functions_lib": { + "code": [ + "java.io.File" + ] + }, + "list_directory": { + "code": [ + "val dir = File(\".\")", + "val files = dir.listFiles()", + "file?.forEach { println(it.name) }" + ] + }, + "read_directory_info": { + "code": [ + "val dir = File(\".\")", + "val files = dir.listFiles()", + "println(\"Number of items: ${files.size}\")", + "println(\"Total size: ${files.sumOf { it.length() }}\")" + ], + "comment": [ + "There are no in built stats functions in Kotlin, so we have to calculate them manually" + ] + }, + "create_directory": { + "code": [ + "File(\"location\").mkdir()" + ], + "comment": [ + "Successful creation can be checked with conditional statements" + ] + }, + "delete_directory": { + "code": [ + "File(\"location\").delete()" + ] + }, + "rename_directory": { + "code": [ + "File(\"oldDirectoryName\").renameTo(File(\"newDirectoryName\"))" + ] + }, + "move_directory": { + "code": [ + "File(\"oldDirectoryName\").renameTo(File(\"newDirectoryName\"))" + ] + }, + "update_directory_permissions": { + "code": [ + "File(\"location\").setReadable(true, true).setWritable(true, true)" + ], + "comment": [ + "First parameter: specifies if permission is granted (true) or revoked (false)\n\n Second parameter: specifies if permission is granted to all users (true) or only the owner (false)" + ] + }, + "read_line_of_file": { + "code": [ + "val line = File(\"filePath\").bufferedReader().readLine()" + ] + }, + "read_lines_of_file": { + "code": [ + "val lines = File(\"filePath\").readLines()" + ] + }, + "read_file_stream": { + "code": [ + "val inputStream = File(\"filePath\").inputStream()", + "// OR", + "File(\"filePath\").inputStream().use { inputStream ->", + "// Code to alter stream", + "}" + ], + "comment": [ + "The second example ensures the stream is closed after use" + ] + }, + "create_file": { + "code": [ + "val fileCreated = File(\"filePath\").createNewFile()" + ] + }, + "delete_file": { + "code": [ + "val fileDeleted = File(\"filePath\").delete()" + ] + }, + "update_file": { + "code": [ + "val lines = File(\"filePath\").readLines().toMutableList()", + "lines.add(\"Example text\")", + "File(filePath).writeText(lines.joinToString(\"\\n\"))" + ], + "comment": [ + "This example appends a line to the end of the file, there is no explicit update method present in this language" + ] + }, + "move_file": { + "code": [ + "val moved = File(\"sourceFilePath\").renameTo(File(\"targetFilePath\"))" + ] + }, + "network_functions_lib": { + "not-implemented": true + }, + "send_a_http_request": { + "not-implemented": true + }, + "send_a_get_request": { + "not-implemented": true + }, + "send_a_post_request": { + "not-implemented": true + }, + "send_a_put_request": { + "not-implemented": true + }, + "send_a_patch_request": { + "not-implemented": true + }, + "send_a_delete_request": { + "not-implemented": true + }, + "send_a_head_request": { + "not-implemented": true + }, + "send_a_options_request": { + "not-implemented": true + }, + "send_a_connect_request": { + "not-implemented": true + }, + "send_a_trace_request": { + "not-implemented": true + }, + "add_headers": { + "not-implemented": true + }, + "add_query_params": { + "not-implemented": true + }, + "inbuilt_url_class": { + "not-implemented": true + }, + "open_a_socket": { + "not-implemented": true + }, + "close_a_socket": { + "not-implemented": true + }, + "add_authorization_headers": { + "not-implemented": true + }, + "add_cookies": { + "not-implemented": true + }, + "read_cookies": { + "not-implemented": true + }, + "read_headers": { + "not-implemented": true + }, + "database_functions_lib": { + "not-implemented": true + }, + "open_connection": { + "not-implemented": true + }, + "close_connection": { + "not-implemented": true + }, + "execute_query_single_result_set": { + "not-implemented": true + }, + "execute_query_multiple_result_sets": { + "not-implemented": true + }, + "execute_non_query": { + "not-implemented": true + }, + "json_function_lib": { + "not-implemented": true + }, + "serialize_json": { + "not-implemented": true + }, + "deserialize_json": { + "not-implemented": true + }, + "serialize_json_with_options": { + "not-implemented": true + }, + "deserialize_json_with_options": { + "not-implemented": true + }, + "xml_function_lib": { + "not-implemented": true + }, + "serialize_xml": { + "not-implemented": true + }, + "deserialize_xml": { + "not-implemented": true + }, + "serialize_xml_with_options": { + "not-implemented": true + }, + "deserialize_xml_with_options": { + "not-implemented": true + }, + "csv_function_lib": { + "not-implemented": true + }, + "read_csv_file": { + "not-implemented": true + }, + "read_csv_to_type": { + "not-implemented": true + }, + "write_csv_file": { + "not-implemented": true + }, + "append_csv_file": { + "not-implemented": true + }, + "set_csv_delimiter": { + "not-implemented": true + } + } +} \ No newline at end of file From 22f4d72f4be235f6c2556a2895c409434e843627 Mon Sep 17 00:00:00 2001 From: Christian Duarte <97495088+cduarte3@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:24:46 -0400 Subject: [PATCH 2/2] Fixing kotlin io structure --- web/thesauruses/kotlin/1.5/io.json | 31 ++++-------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/web/thesauruses/kotlin/1.5/io.json b/web/thesauruses/kotlin/1.5/io.json index 1f9333918..6f17885dd 100644 --- a/web/thesauruses/kotlin/1.5/io.json +++ b/web/thesauruses/kotlin/1.5/io.json @@ -22,13 +22,7 @@ ] }, "read_char": { - "code": [ - "val variable_name = readln()", - "val first_char = variable_name[0]" - ], - "comment": [ - "First character can be read by accessing the first element of the string" - ] + "not-implemented": true }, "clear_console_output": { "not-implemented": true @@ -46,21 +40,11 @@ }, "list_directory": { "code": [ - "val dir = File(\".\")", - "val files = dir.listFiles()", - "file?.forEach { println(it.name) }" + "val files = File(\".\").listFiles()" ] }, "read_directory_info": { - "code": [ - "val dir = File(\".\")", - "val files = dir.listFiles()", - "println(\"Number of items: ${files.size}\")", - "println(\"Total size: ${files.sumOf { it.length() }}\")" - ], - "comment": [ - "There are no in built stats functions in Kotlin, so we have to calculate them manually" - ] + "not-implemented": true }, "create_directory": { "code": [ @@ -126,14 +110,7 @@ ] }, "update_file": { - "code": [ - "val lines = File(\"filePath\").readLines().toMutableList()", - "lines.add(\"Example text\")", - "File(filePath).writeText(lines.joinToString(\"\\n\"))" - ], - "comment": [ - "This example appends a line to the end of the file, there is no explicit update method present in this language" - ] + "not-implemented": true }, "move_file": { "code": [