cub-sdt-104-2024 / tasks

This repository hosts a task tracker for all projects.
1 stars 0 forks source link

Encoding and decoding web site log records to/from string #6

Open dbarashev-jetbrains opened 2 months ago

dbarashev-jetbrains commented 2 months ago

When users access a web site page, their visits are logged by a web server and the logs are written to a text file. One row in the file corresponds to one HTTP request. There are a few commonly used log formats, however, we will use a very simple comma-delimited format with just a few fields:

<IP ADDRESS>,<QUOTED_PAGE_URL>,<TIMESTAMP>

An example: 195.19.255.253, "/download", 1725640644

This record can be represented in memory as a tuple with three elements: tuple[str,str,long]. Your task is to write two functions that encode and decode such tuples to/from strings:

encodeLogRecord(item: tuple[str,str,long]) -> str decodeLogRecord(textRow: str) -> tuple[str,str,long]


Please don't forget to write unit tests for these functions.