Giter VIP home page Giter VIP logo

python's Introduction

Python

Python libraries for MPZinke.

Modules

DownloadIterator

An object that takes a request to download large amounts of data and can run a function for each chunk.

Alternatives & Justification

requests allows for downloading large amounts of data, but when downloading a large amount of data, memory usage can be a factor. As such, writing to a file may be required. The DownloadIterator object wraps the request to allow for iterative download and processing of data.

Additionally, the request timeout specifies the amount of time for the server to respond, not the amount of time spent downloading the response. DownloadIterator provides a way to specify a maximum amount of time downloading a file.

Usage

Usage can be found here Notably, stream must be set to True.

Generic

A class that can be called or inherited to make a function, method or class generic.

Alternatives & Justification

typing.Generic is a built-in class for generics. It however lacks the ability to be inherited from nor to store the generic's type. EG, if MyGenericClass inherits from typing.Generic, there is no way in MyGenericClass[int] to know the type of int once the class is instantiated.

Further more, typing.Generic cannot be applied to functions. As such, the mpzinke.Generic stores the type in a .__args__ attribute like list and Dict.

Usage

Usage can be found here

is_json(string: str) -> bool:

is_json checks when a string is JSON parsable.

Alternatives & Justification

json.loads is the core of the is_json function. However to know if a string can be safely parsed, one must wrap it with a try-catch block. This does that automatically.

Usage

Usage can be found here

Possible Future Enhancements

  1. Add optional function to execute if string is successfully parsed.

Server

Server is a class that wraps a Flask server to provide for easier server setup, error handling, authorization, and route addition. Additionally, it uses the doc strings of functions' passed to routes to document all endpoints.

Alternatives & Justification

Flask servers offer great API's for adding routes, but are limited in that a route only take 1 function for all METHODS.

Usage

Usage can be found here

Possible Future Enhancements

  1. Add optional function to execute if string is successfully parsed.

A Flask server class for simple routing by HTTP method.

Build Commands

FROM: https://packaging.python.org/en/latest/tutorials/packaging-projects/

  • python3 -m pip install --upgrade build
  • python3 -m pip install --upgrade twine
  • python3 -m build
  • python3 -m twine upload --repository testpypi dist/*
    • username: __token__
    • password: <API KEY>

python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps python_server_MPZinke

python's People

Contributors

mpzinke avatar

Watchers

 avatar

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.