The Playrix test task implementation. Includes a CLI utility generating and parsing random archives with information about game objects.
The following modules are included:
playrix/generate.py- utilities to generate random XML files and archives;playrix/parse.py- parsing generated XML archives;playrix/utils.py- additional helpers;cli.py- command-line interface to invoke generating and parsing commands.
To test the implementation of main project's classes, one could use
tox automation tool. Using tox, you
only need to navigate into project's folder and run:
$ cd playrix
$ toxTo generate a bunch of archives with XML files, use:
(venv) $ python cli.py generate 100 archivesTo parse a directory with generated archives:
(venv) $ python cli.py parse archives outputThe core library used in the project is lxml. The library allows to generate
XML trees in object-oriented fashion and save them into text files.
The click library allows to build sophisticated hierarchical command-line
interfaces. It is not really required in our case of a simple project with only
two commands, and a couple of available options but in general, the library is
very powerful and convenient tool.
The Pandas library (and its dependencies) is only used to save information
into CSV format. We could use built-in csv library instead because our data
processing code is quite simple.
Finally, the pytest library is used to run test suits.
To gain a computation speed-up, one could write critical fragments of the code
with Cython, or use numpy arrays and random
distributions to make the generation process a bit faster.