Skip to main content

Python wrappers for PHP functions, when you just can't shake it.

Project description

PyPi Status PyPi Python Version PyPi Downloads GitHub Issues GitHub Commit Activity PyPi License PyPi Version

wraphper

Python wrappers for PHP functions, when you just can't shake it.

Why?

If you're coming from PHP, you'll take a bit of time getting used to the new names or methods in Python. You could look up something like "python str_replace" everytime you want to do so, or you could just save time and use php.str_replace('Hello', 'Goodbye', 'Hello, world!').

Why not?

Installation

Pip it.

$ pip install wraphper

Usage

Import the module and then fulfil your PHP fantasies in Python:

import wraphper as php

a = [1, 2, 3]
php.count(a)
# outputs: 3

Supported functions

This module is a work in progress. Not all functions are supported yet. The current list includes:

PRs with more functions are welcome!

Performance and Security

wraphper doesn't internally call PHP to run these functions, it simply provides you a PHP-like function name that runs the Python equivalent. As such, performance is unaffected because only Python is running.

Similarly, there are no implications of this on security.

Contributing

Follow these rules with contributed functions:

  • The function must be an native PHP function, not from a third-party library.
  • The name of the function must match the original exactly. Otherwise, the purpose of this module is defeated.
  • The function should take the exact same number of arguments as the original.
  • The argument types must match the PHP types as closely as possible, so string is str, int is int, array is list or dict, etc.
  • The function must throw an appropriate exception with the exact same error message from the PHP function.
  • The function should avoid any pre- or post-processing of the argument or return value. The goal is not to match PHP functions' inputs and outputs, but to provide a PHP-familiar syntax for Python developers.

Testing

Tests can be run by the following command:

$ python tests.py

Compatibility

wraphper has been checked with Python 2.7 and 3.6, but there's no reason why it shouldn't work with older versions.

Changelog

0.0.2 - 2019-01-29

  • Added str_replace

0.0.1.post2 - 2019-01-28

  • BREAKING Removed class to make it easier to import and use
  • Added tuple support
  • Added more tests
  • Added changelog

0.0.1.post1 - 2019-01-26

  • Added tests

0.0.1 - 2019-01-26

  • Initial release with count function

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wraphper-0.0.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wraphper-0.0.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file wraphper-0.0.2.tar.gz.

File metadata

  • Download URL: wraphper-0.0.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for wraphper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 25eb399f170241ba44546babd5f4d0a7d75a31c39f8d6f3d3f1abaed38c5f88c
MD5 0b8defac5ec182179d4410e8f8bef2d6
BLAKE2b-256 c418e9d3125b98e34c975f034891d81d9805ab9fc4634f199ef8bad52ce77e6f

See more details on using hashes here.

File details

Details for the file wraphper-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: wraphper-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for wraphper-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 746cb6f4432f5b0485ae731f47e68916a13b1c5c13420bb215f933dc72288ba9
MD5 2c0d327cac40acaa499c20365e5b87e6
BLAKE2b-256 0e27f39b5504cbe9c8072ec1620b26952b5a7c1da291310c1f654615b48eecca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page