Skip to main content

A python script to convert simple php code to python

Project description


A python script to convert simple php code to python,
It just converts the basic syntax
It is the one i use in the conversion mpg25/Instagram-API in PHP to danleyb2/Instagram-API in PYTHON

## usage
$ python -h

usage: [-h] -s SCRIPT [-o]

PHP to PYTHON syntax converter.

optional arguments:
-h, --help show this help message and exit
-s SCRIPT, --script SCRIPT
Path to PHP script
-o, --overwrite Overwrite Python script if exists


$ python -s test_scripts/Caption.php

Converting: test_scripts/Caption.php. Output file will be: test_scripts/
# Remove opening and closing <?php
# convert $this-> to self.
# convert :: to .
# delete all }
# delete namespace|require_once|include_once
# convert protected $var to self.var = None then move into __init__
# convert public|protected function to def
# add `self` to function signatures
# classes not children to extend `object`
# convert $ to ''
# convert ; to ''
# convert new to ''
Converted: test_scripts/Caption.php. to: test_scripts/ { Go on, Proof Check :) }


$ python -s test_scripts/Caption.php
Sorry, A python Script test_scripts/ already exist, use -o to overwrite.


Project details

Download files

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

Files for convert2php, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size convert2php-0.0.1.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page