ucsschool.importer.writer package

Submodules

ucsschool.importer.writer.base_writer module

Base class for output writers.

class ucsschool.importer.writer.base_writer.BaseWriter(*arg, **kwargs)[source]

Bases: object

Abstraction of a data dump mechanism like CSV, JSON, XML, sockets etc.

Create a writer.

Parameters
  • arg (tuple) – arguments for implementing class

  • kwargs (dict) – arguments for implementing class

open(filename, mode='wb')[source]

Get a handle on the output file or something similar to be used as a context manager. IMPLEMENTME with the method appropriate for the output type.

Parameters
  • filename (str) – filename to write data to

  • mode (str) – passed to used open() method

Returns

a context manager

write_header(header)[source]

Write an optional header (line) before the main data. IMPLEMENTME if you wish to write a header line.

Parameters

header – object to write as header

Returns

None

Write a optional footer (line) after the main data. IMPLEMENTME if you wish to write a footer.

Parameters

footer – object to write as footer

Returns

None

write_obj(obj)[source]

Write object to output. IMPLEMENTME if it’s not just outfile.write(obj).

Parameters

obj – object or error to write

Returns

result of write operation, if any

ucsschool.importer.writer.csv_writer module

Write the result of a user import job to a CSV file.

class ucsschool.importer.writer.csv_writer.CsvWriter(field_names, dialect=None)[source]

Bases: ucsschool.importer.writer.base_writer.BaseWriter

Create a CSV file writer.

Parameters
  • field_names (list(str)) – names of the columns

  • dialect (csv.Dialect) – If unset will try to detect dialect of input file or fall back to “excel”.

open(filename, mode='w')[source]

Open the output file.

Parameters
  • filename (str) – filename to write data to

  • mode (str) – passed to builtin open() method

Returns

DictWriter instance

Return type

csv.DictWriter

write_header(header)[source]

Write a header line before the main data.

Parameters

header – object to write as header (ignored)

Returns

None

write_obj(obj)[source]

Write object to output.

Parameters

obj (dict) – data to write

Returns

None

ucsschool.importer.writer.new_user_password_csv_exporter module

ucsschool.importer.writer.result_exporter module

ucsschool.importer.writer.test_user_csv_exporter module

ucsschool.importer.writer.user_import_csv_result_exporter module