Giter Club home page Giter Club logo

losses's Introduction

losses.py Stand With Ukraine

losses.py is a Python script that allows to watch an actual data of the russian army losses in the Russo-Ukrainian War.

You can watch the data in the console or generate an image with this. For this you'll need file with a background and file with a font in .ttf format.

For the image making part, you'll have a file config.json created when you use script for creating image for the first time. Detailed description of the file and usage can be found down bellow.

The data comes from the Ministry of Finance website. Script parses, strips and prepares it to be printed as table or written on image.

This script was made as a final project of CS50’s Introduction to Programming with Python.

Demo

Here you can see how the script prints data to the console: demo

If you run the script with image generation mode you'll get something like this: result

How to run

Console stats output:

  1. Install Python 3.
  2. Run pip install -r requirements.txt to install dependencies.
  3. Run python losses.py

Generating image:

  1. Install Python 3.
  2. Run pip install -r requirements.txt to install dependencies.
  3. Run python losses.py -i. This will generate config file.
  4. Edit config.json, specifying resource files and font sizes.
  5. Run python losses.py -i again. This will produce result.jpg file.

Config file example:

{
    "background_path": "./resources/image.jpg",
    "font_path": "./resources/font.ttf",
    "font_size": 24,
    "text_color": "white",
    "header_font_size": 34,
    "header_text": "Протягом 24.02-%s\n орієнтовані втрати противника склали:",
    "header_color": "yellow",
    "tint_amount": 0.35
}

NOTE: header_text must contain %s for the current date.

Also, you can run tests for the script. For this:

  1. Install pytest: pip install pytest
  2. Run pytest test_project.py

Stand With Ukraine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.