Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

CSVStorage and Lineendings #298

Closed
wants to merge 15 commits into from
Closed
3 changes: 3 additions & 0 deletions cmake/ElektraCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ set (PLUGINS_LIST_COMPILE
set (PLUGINS_LIST_NODEP
ccode
fstab
csvstorage
lineendings
hexcode
hidden
ni
Expand All @@ -71,6 +73,7 @@ set (PLUGINS_LIST_POSIX
iconv
network
path
enum
keytometa
rename
syslog
Expand Down
55 changes: 55 additions & 0 deletions src/liberror/specification
Original file line number Diff line number Diff line change
Expand Up @@ -660,3 +660,58 @@ description:python warning
severity:warning
ingroup:plugin
module:python

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for storage plugins, we already have the errors 109, 110, 9, 75 and the macros ELEKTRA_SET_ERROR_GET ELEKTRA_SET_ERROR_SET to have consistent error reporting

number:113
description:couldnt open file.
severity:error
ingroup:plugin
module:lineendings

number:114
description:invalid line ending.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please no dot at end (also in 116, 118, 119,..)

severity:error
ingroup:plugin
module:lineendings

number:115
description:inconsistent line endings
severity:error
ingroup:plugin
module:lineendings

number:116
description: couldn't open file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above about could not open file error

severity:error
ingroup:plugin
module:csvstorage

number:117
description:invalid number of columns
severity:error
ingroup:plugin
module:csvstorage

number:118
description:see Reason.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats a bit too generic. Maybe rename to problem during parsing of csvfile (see reason).

severity:warning
ingroup:plugin
module:csvstorage

number:119
description:out of memory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that ELEKTRA_SET_ERROR won't work in a out of memory situation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in an out of memory situation just cleanup and returning -1 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not against an error for out of memory. But the error should be not specific to this plugin and should be used consistently (for every allocation) in the plugins which are out-of-memory safe.

severity:error
ingroup:plugin
module:csvstorage

number:120
description: Couldn't compile regex.
severity: error
ingroup:plugin
module:enum

number:121
description:Validation failed.
severity:error
ingroup:plugin
module:enum

5 changes: 3 additions & 2 deletions src/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ productive use:
- [fstab](fstab) reads fstab files.
- [regexstore](regexstore)
- [simpleini](simpleini) is ini without sections

- [csvstorage](csvstorage) uses csv files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for csv files
(uses -> for)


## System Information ##

Expand Down Expand Up @@ -126,7 +126,7 @@ copied by another plugin just before):
- [network](network) by using network APIs
- [path](path) by checking files on filesystem
- [type](type) using runtime type checking (CORBA types)

- [enum](enum) compares the keyvalue against a list of valid values

## Interpreter ##

Expand All @@ -142,6 +142,7 @@ These plugins start an interpreter and allow you to use a bindings.
- [doc](doc) contains the documentation of the plugin interface
- [error](error) yields errors as described in metadata
- [template](template) to be copied for new plugins
- [lineendings](lineendings) tests file for consistent line endings

To add a new plugin you can copy the template plugin. Please make sure
to add your plugin:
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/csvstorage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include (LibAddMacros)

add_plugin(csvstorage
SOURCES
csvstorage.h
csvstorage.c
)

install(DIRECTORY csvstorage DESTINATION ${TARGET_TEST_DATA_FOLDER})

add_plugintest(csvstorage)
30 changes: 30 additions & 0 deletions src/plugins/csvstorage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
- infos = Information about the csvstorage plugin is in keys below
- infos/author = Thomas Waser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide some e-mail adr? You can also have a @libelektra.org forwarded to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer the latter if possible

- infos/licence = BSD
- infos/needs =
- infos/provides = storage
- infos/placements = getstorage setstorage
- infos/description = parses csv files

## Introduction ##

This plugin allowes Elektra to read and write CSV files.

## Configuration ##

`config/delimiter`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave out the config/ because neither the user (kdb mount) nor the plugin need to care about the details in system/elektra/mountpoints

Tells the plugin what delimiter is used in the file.
The default delimiter is ; and will be used if config/delimiter is not set.

`config/useheader = 1`
Tells the plugin to use the first line as a header. The columns will get the
coresponding names.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the default? What means the = 1. Should be consistent with delimiter description.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; if nothing else is specified.
Is there a guideline for using keys as flags ? it be acceptable to assume TRUE if the key exists and FALSE otherwise ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

tom-wa wrote:

so, {} for all oneliners ?

Its preferable. Exception: if there is no doubt how it is meant and its highly
unlikely someone would add a line there.

Is there a guideline for using keys as flags ? it be acceptable to assume
TRUE if the key exists and FALSE otherwise ?

No guideline, but there should be. I opened #308. For now go with strict "1"
is true.


`config/outputdelim`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistent name: delimiter was fully written, delim only short.

Is the other one a parsing (input) delimiter only or does delimiter also changes the output? Then this should be described, too.

I think only one delimiter should suffice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the second delimiter was just for changing the delimiter when writing the file. gonna remove that because it's basically useless.

Tells the plugin what delimiter should be used for output.
If not set, ; will be used

## Example ##

`kdb mount test.csv /csv csvstorage delimiter=";" useheader=1`

Loading