Bug 48189 - add pre-read-hook that modifies the header of a CSV file to ucs-school-import
add pre-read-hook that modifies the header of a CSV file to ucs-school-import
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Import scripts
UCS@school 4.3
Other Linux
: P5 normal (vote)
: UCS@school 4.3 v8
Assigned To: Daniel Tröder
Ole Schwiegert
:
Depends on: 48188
Blocks: 48958 49048 49268
  Show dependency treegraph
 
Reported: 2018-11-21 15:15 CET by Daniel Tröder
Modified: 2019-04-09 14:23 CEST (History)
4 users (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2018-11-21 15:15:35 CET
Create a hook that modifies the header of a CSV file.

A mapping is read from the configuration object.

Add the hook to the UCS@school product in /usr/share/ucs-school-import/pyhooks-available/ so that customers can activate it, if required.
Comment 1 Daniel Tröder univentionstaff 2019-03-07 16:23:05 CET
WIP in dtroeder/48188_pre-read-hook
Comment 2 Daniel Tröder univentionstaff 2019-03-11 18:37:08 CET
PyHook is in /usr/share/ucs-school-import/pyhooks-available/pre_read_modify_csv_header.py. Users can copy it to /usr/share/ucs-school-import/pyhooks/ to active it.

"""
A pre-read hooks that changes the header of a input CSV file.

A mapping is read from the configuration file (csv:header_swap), the original
CSV file is backuped and the header is changed.

If a mapping key is not found in the input file, it is ignored.

Example::
	{
		"csv": {
			"header_swap": {
				"Schulen Ost": "Schulen",
				"Schulname": "Schulen",
				"Familienname": "Nachname"
			}
		}
	}

	header 1 before: "ID","Vorname","Nachname","Email","Schulen Ost"
	header 1 after : "ID","Vorname","Nachname","Email","Schulen"
	header 2 before: "ID","Familienname,"Vorname","Schulname"
	header 2 after : "ID","Nachname,"Vorname","Schulen"
"""


[dtroeder/48188_pre-read-hook] 73abaedbd Bug #48189: WIP: pre-read hook that modifies the header of a CSV file
[dtroeder/48188_pre-read-hook] 1652ce831 Bug #48189: modify CSV header

Please reopen, when starting QA (missing merge, changelog and package build).
Comment 3 Daniel Tröder univentionstaff 2019-03-12 16:01:40 CET
Merged to 4.4 as part of work on Bug #48958.
Comment 4 Ole Schwiegert univentionstaff 2019-03-13 14:05:14 CET
Package installs: OK
Test passes: OK
Hook function working: OK

Please merge and create changelog and advisory
Comment 5 Daniel Tröder univentionstaff 2019-03-13 17:19:19 CET
Merge to 4.3:

[4.3] 4c4ead2d2 Bug #48189: WIP: pre-read hook that modifies the header of a CSV file
[4.3] 0356ef28d Bug #48189: modify CSV header
[4.3] 34d23f52f Bug #48189: add test for pre-read hook
[4.3] 22efeef6f Bug #48189: changelog
[4.3] 1d42a6f85 Bug #48188, Bug #48189: advisory

ucs-school-import (16.0.3-6)

Merge to 4.4:

[4.4] ea4b83060 Bug #48189: WIP: pre-read hook that modifies the header of a CSV file
[4.4] d58db2bf9 Bug #48189: modify CSV header
[4.4] 85f2305c8 Bug #48189: add test for pre-read hook
[4.4] 244b3568a Bug #48189: adapt to UCS@school 4.4
[4.4] 7cb9efbe7 Bug #48189: adapt tests to check_for_non_empty_pyhooks
Comment 6 Ole Schwiegert univentionstaff 2019-03-18 09:18:00 CET
4.4:
Changelog: Bug not mentioned
Advisories: missing
hook present and works: OK

4.3:
Changelog&Advisory: OK
hook present and works: OK
Comment 7 Daniel Tröder univentionstaff 2019-03-18 10:28:41 CET
(In reply to Ole Schwiegert from comment #6)
> 4.4:
> Changelog: Bug not mentioned
4.4 has been released. The 4.3→4.4-changelog won't be changed now. But a new changelog will (almost) automatically be created from the advisory for the next errata-release.

> Advisories: missing
[4.4 43f5e910a] Bug #48189: advisory
Comment 8 Ole Schwiegert univentionstaff 2019-03-18 11:04:53 CET
OK.
Comment 9 Sönke Schwardt-Krummrich univentionstaff 2019-04-01 00:44:22 CEST
UCS@school 4.3 v8 has been released.

https://docs.software-univention.de/changelog-ucsschool-4.3v8-de.html

If this error occurs again, please clone this bug.