New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

php

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

php - pypi Package Compare versions

Comparing version
1.0
to
1.1.2
+1
php.egg-info/dependency_links.txt
Metadata-Version: 1.1
Name: php
Version: 1.1.2
Summary: Handle some of the strange standards in PHP projects
Home-page: https://github.com/danielquinn/python-php
Author: Daniel Quinn
Author-email: code@danielquinn.org
License: AGPLv3
Download-URL: https://github.com/danielquinn/python-php
Description: python-php
==========
Making some of those PHP-only functions available to Python
Sometimes you want to write a Python script for a project written in PHP.
For the most part, this is easy, but for a few key things, PHP breaks with
the standard and does things in a its own way. For these cases, you can use
this module to compensate.
http_build_query()
------------------
This was ripped shamelessly from a `PHP forum`_ and ported to Python:
Essentially, it's a (hopefully perfect) replica of PHP's
`http_build_query()`_ that allows you to pass multi-dimensional arrays to a
PHP-managed URL via POST or GET.
.. _PHP forum: http://www.codingforums.com/showthread.php?t=72179
.. _http_build_query(): http://php.net/manual/en/function.http-build-query.php
parse_ini_file()
----------------
A hacked-together attempt at making an .ini file parser that's compatible with
the "standards" that PHP follows in its parse_ini_file() function. Among the
handy features included are:
* List notation (``varname[] = value``)
* Associative array notation (``varname[key] = value``)
* Removal of wrapping doublequotes (``varname = "stuff"`` becomes ``varname = stuff``)
You can turn off the doublequote removal with ``stripquotes=False``
Example
.......
::
from php import parse_ini_file
config = parse_ini_file("config.ini")
print config["sectionName"]["keyName"]
Platform: UNKNOWN
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: PHP
Classifier: Topic :: Internet :: WWW/HTTP
README.rst
php.py
setup.py
php.egg-info/PKG-INFO
php.egg-info/SOURCES.txt
php.egg-info/dependency_links.txt
php.egg-info/top_level.txt
python-php
==========
Making some of those PHP-only functions available to Python
Sometimes you want to write a Python script for a project written in PHP.
For the most part, this is easy, but for a few key things, PHP breaks with
the standard and does things in a its own way. For these cases, you can use
this module to compensate.
http_build_query()
------------------
This was ripped shamelessly from a `PHP forum`_ and ported to Python:
Essentially, it's a (hopefully perfect) replica of PHP's
`http_build_query()`_ that allows you to pass multi-dimensional arrays to a
PHP-managed URL via POST or GET.
.. _PHP forum: http://www.codingforums.com/showthread.php?t=72179
.. _http_build_query(): http://php.net/manual/en/function.http-build-query.php
parse_ini_file()
----------------
A hacked-together attempt at making an .ini file parser that's compatible with
the "standards" that PHP follows in its parse_ini_file() function. Among the
handy features included are:
* List notation (``varname[] = value``)
* Associative array notation (``varname[key] = value``)
* Removal of wrapping doublequotes (``varname = "stuff"`` becomes ``varname = stuff``)
You can turn off the doublequote removal with ``stripquotes=False``
Example
.......
::
from php import parse_ini_file
config = parse_ini_file("config.ini")
print config["sectionName"]["keyName"]
[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0
+98
-90
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Sometimes you want to write a Python script for a project written in PHP.
# For the most part, this is easy, but for a few key things, PHP breaks with
# the standard and does things in a its own way. For these cases, you can use
# this module to compensate.
#
def http_build_query(params, convention="%s"):
"""
import re
This was ripped shamelessly from a PHP forum and ported to Python:
try: # Python3
from urllib.parse import quote
except ImportError: # Python2
from urllib import quote
http://www.codingforums.com/showthread.php?t=72179
__version__ = "1.1.2"
Essentially, it's a (hopefully perfect) replica of PHP's
http_build_query() that allows you to pass multi-dimensional arrays
to a URL via POST or GET.
"""
class Php(object):
from urllib import quote
INI_REGEX_UNQUOTED_LINE = re.compile(r'^([^ =]+)\s*=\s*"?([^"]*)"?$')
INI_REGEX_QUOTED_LINE = re.compile(r'^([^ =]+)\s*=\s*(.*)$')
INI_REGEX_INDEXED_ARRAY = re.compile(r'^([^\]]+)\[\]$')
INI_REGEX_ASSOCIATIVE_ARRAY = re.compile(r'^([^\]]+)\["?([^\]"]+)"?\]$')
INI_REGEX_HEADER_LINE = re.compile(r'^\[([^\]]+)\]$')
if len(params) == 0:
return ""
else:
output = ""
for key in params.keys():
@classmethod
def http_build_query(cls, params, convention="%s"):
"""
if type(params[key]) is dict:
output = output + http_build_query(params[key], convention % (key) + "[%s]")
This was ripped shamelessly from a PHP forum and ported to Python:
elif type(params[key]) is list:
http://www.codingforums.com/showthread.php?t=72179
i = 0
newparams = {}
for element in params[key]:
newparams[str(i)] = element
i = i + 1
Essentially, it's a (hopefully perfect) replica of PHP's
http_build_query() that allows you to pass multi-dimensional arrays
to a URL via POST or GET.
output = output + http_build_query(newparams, convention % (key) + "[%s]")
"""
else:
key = quote(key)
val = quote(str(params[key]))
output = output + convention % (key) + "=" + val + "&"
if len(params) == 0:
return ""
return output
output = ""
for key in params.keys():
if type(params[key]) is dict:
output = output + cls.http_build_query(params[key], convention % key + "[%s]")
def parse_ini_file(filename, **kwargs):
"""
elif type(params[key]) is list:
A hacked-together attempt at making an .ini file parser that's compatible
with the "standards" that PHP follows in its parse_ini_file() function.
Among the handy features included are:
i = 0
new_params = {}
for element in params[key]:
new_params[str(i)] = element
i += 1
* List notation (varname[] = value)
* Associative array notation (varname[key] = value)
* Removal of wrapping doublequotes (varname = "stuff" -becomes- varname = stuff)
output = output + cls.http_build_query(
new_params,
convention % key + "[%s]"
)
You can turn off the doublequote removal with stripquotes=False
else:
Example:
from php import parse_ini_file
config = parse_ini_file("config.ini")
print config["sectionName"]["keyName"]
key = quote(key)
val = quote(str(params[key]))
output = output + convention % key + "=" + val + "&"
"""
return output
import re
@classmethod
def parse_ini_file(cls, filename, strip_quotes=False):
"""
stripquotes = True
try:
stripquotes = kwargs["stripquotes"]
except KeyError:
pass
A hacked-together attempt at making an .ini file parser that's compatible
with the "standards" that PHP follows in its parse_ini_file() function.
Among the handy features included are:
f = open(filename, "r")
* List notation (varname[] = value)
* Associative array notation (varname[key] = value)
* Removal of wrapping double-quotes (varname = "stuff" -becomes- varname = stuff)
ini = {}
You can turn off the doublequote removal with strip_quotes=False
headerKey = None
while True:
Example:
from php import parse_ini_file
config = parse_ini_file("config.ini")
print config["sectionName"]["keyName"]
line = f.readline()
"""
if not line:
break
ini = {}
header_key = None
with open(filename, "r") as f:
while True:
line = f.readline()
if not line:
break
ini, header_key = cls._parse_ini_loop(
line,
header_key,
ini,
strip_quotes
)
header = re.match(r'^\[([^\]]+)\]$', line)
return ini
keyval = None
if stripquotes:
keyval = re.match(r'^([^ =]+)\s*=\s*"?([^"]*)"?$', line)
else:
keyval = re.match(r'^([^ =]+)\s*=\s*(.*)$', line)
@classmethod
def _parse_ini_loop(cls, line, header_key, ini, strip_quotes):
if header:
header = cls.INI_REGEX_HEADER_LINE.match(line)
ini[header.group(1)] = {}
headerKey = header.group(1)
if strip_quotes:
keyval = cls.INI_REGEX_UNQUOTED_LINE.match(line)
else:
keyval = cls.INI_REGEX_QUOTED_LINE.match(line)
elif keyval:
if header:
indexedArray = re.search('^([^\]]+)\[\]$', keyval.group(1))
assocArray = re.search('^([^\]]+)\["?([^\]"]+)"?\]$', keyval.group(1))
ini[header.group(1)] = {}
header_key = header.group(1)
value = keyval.group(2).rstrip("\n")
if indexedArray:
try:
ini[headerKey][indexedArray.group(1)].append(value)
except KeyError:
ini[headerKey][indexedArray.group(1)] = [value]
elif keyval:
elif assocArray:
try:
ini[headerKey][assocArray.group(1)][assocArray.group(2)] = value
except KeyError:
ini[headerKey][assocArray.group(1)] = {assocArray.group(2): value}
indexed_array = cls.INI_REGEX_INDEXED_ARRAY.match(keyval.group(1))
associative_array = cls.INI_REGEX_ASSOCIATIVE_ARRAY.match(keyval.group(1))
else:
ini[headerKey][keyval.group(1)] = value
value = keyval.group(2).rstrip("\n")
if indexed_array:
try:
ini[header_key][indexed_array.group(1)].append(value)
except KeyError:
ini[header_key][indexed_array.group(1)] = [value]
elif associative_array:
try:
ini[header_key][associative_array.group(1)][associative_array.group(2)] = value
except KeyError:
ini[header_key][associative_array.group(1)] = {associative_array.group(2): value}
else:
ini[header_key][keyval.group(1)] = value
f.close()
return ini
return ini, header_key

@@ -1,10 +0,67 @@

Metadata-Version: 1.0
Metadata-Version: 1.1
Name: php
Version: 1.0
Summary: UNKNOWN
Home-page: http://danielquinn.org/projects/software.html
Version: 1.1.2
Summary: Handle some of the strange standards in PHP projects
Home-page: https://github.com/danielquinn/python-php
Author: Daniel Quinn
Author-email: corporate@danielquinn.org
License: UNKNOWN
Description: UNKNOWN
Author-email: code@danielquinn.org
License: AGPLv3
Download-URL: https://github.com/danielquinn/python-php
Description: python-php
==========
Making some of those PHP-only functions available to Python
Sometimes you want to write a Python script for a project written in PHP.
For the most part, this is easy, but for a few key things, PHP breaks with
the standard and does things in a its own way. For these cases, you can use
this module to compensate.
http_build_query()
------------------
This was ripped shamelessly from a `PHP forum`_ and ported to Python:
Essentially, it's a (hopefully perfect) replica of PHP's
`http_build_query()`_ that allows you to pass multi-dimensional arrays to a
PHP-managed URL via POST or GET.
.. _PHP forum: http://www.codingforums.com/showthread.php?t=72179
.. _http_build_query(): http://php.net/manual/en/function.http-build-query.php
parse_ini_file()
----------------
A hacked-together attempt at making an .ini file parser that's compatible with
the "standards" that PHP follows in its parse_ini_file() function. Among the
handy features included are:
* List notation (``varname[] = value``)
* Associative array notation (``varname[key] = value``)
* Removal of wrapping doublequotes (``varname = "stuff"`` becomes ``varname = stuff``)
You can turn off the doublequote removal with ``stripquotes=False``
Example
.......
::
from php import parse_ini_file
config = parse_ini_file("config.ini")
print config["sectionName"]["keyName"]
Platform: UNKNOWN
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: PHP
Classifier: Topic :: Internet :: WWW/HTTP

@@ -1,11 +0,47 @@

from distutils.core import setup
import os
import re
from setuptools import setup
setup(
name="php",
version="1.0",
py_modules=["php"],
url="http://danielquinn.org/projects/software.html",
author="Daniel Quinn",
author_email="corporate@danielquinn.org"
)
# Grab __version__ from the actual module
__version__ = None
with open("php.py") as module:
version_regex = re.compile(r'^__version__ = "(?P<version>[0-9.]+)"')
for line in module.readlines():
m = re.match(version_regex, line)
if m:
__version__ = m.group("version")
break
# Allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
# Get the long description from README.md
with open(os.path.join(os.path.dirname(__file__), "README.rst")) as description:
setup(
name="php",
version=__version__,
license="AGPLv3",
description="Handle some of the strange standards in PHP projects",
long_description=description.read(),
url="https://github.com/danielquinn/python-php",
download_url="https://github.com/danielquinn/python-php",
author="Daniel Quinn",
author_email="code@danielquinn.org",
maintainer="Daniel Quinn",
maintainer_email="code@danielquinn.org",
tests_require=["nose"],
test_suite="nose.collector",
classifiers=[
"Operating System :: POSIX",
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: PHP",
"Topic :: Internet :: WWW/HTTP",
],
)
Sometimes you want to write a Python script for a project written in PHP.
For the most part, this is easy, but for a few key things, PHP breaks with
the standard and does things in a its own way. For these cases, you can use
this module to compensate.
http_build_query()
This was ripped shamelessly from a PHP forum and ported to Python:
http://www.codingforums.com/showthread.php?t=72179
Essentially, it's a (hopefully perfect) replica of PHP's
http_build_query() that allows you to pass multi-dimensional arrays
to a URL via POST or GET.
parse_ini_file()
A hacked-together attempt at making an .ini file parser that's compatible
with the "standards" that PHP follows in its parse_ini_file() function.
Among the handy features included are:
* List notation (varname[] = value)
* Associative array notation (varname[key] = value)
* Removal of wrapping doublequotes (varname = "stuff" -becomes- varname = stuff)
You can turn off the doublequote removal with stripquotes=False
Example:
from php import parse_ini_file
config = parse_ini_file("config.ini")
print config["sectionName"]["keyName"]