Package base :: Package lib :: Package drupy :: Module DrupyPHP
[hide private]

Module DrupyPHP

source code

A PHP abstraction layer for Python
See Also:
Drupy Homepage, Drupal Homepage
Notes:

Author: Brendon Crawford

Copyright: 2008 Brendon Crawford

Contact: message144 at users dot sourceforge dot net

Version: 0.1

Classes [hide private]
  stdClass
Std class
  Reference
Reference class
  __SuperGlobals
Class to handle super globals
  __Output
Handles drupy output functions
Functions [hide private]
 
gzencode()
compress
source code
 
gzdecode(val)
decompress
source code
 
sizeof(item)
Gets array count
source code
 
require_once(filename, scope=None)
Includes file
source code
 
require(filename, scope=None)
Includes file
source code
 
include_once(filename, scope=None)
Includes file
source code
 
substr(items, a1, a2=None)
Array slice
source code
 
preg_replace_callback(pat, rep, subject)
preg_replace wrapper
source code
 
is_writeable(filename)
CHecks file is writeable
source code
 
header(data, replace=True)
Write headers
source code
 
flush()
Flush buffer...
source code
 
__init()
Initiate superglobals and set output buffering
source code
 
session_set_save_handler(open_, close_, read_, write_, destroy_, gc_)
Sets user-level session storage functions
source code
 
session_start()
Initialize session data
source code
 
session_name(name='DrupySession')
Get and/or set the current session name
source code
 
define(name, val=None)
THIS FUNCTION SHOULD BE DEPRECATED EVENTUALLY...
source code
 
base64_encode(data)
Base 64 encode
source code
 
base64_decode(data)
Base 64 encode
source code
 
error_get_last()
Gets error.
source code
 
scandir(path_)
List files and directories inside the specified path
source code
 
uasort(item, func)
Sort on func
source code
 
call_user_func_array(func, args)
Call user func
source code
 
call_user_func(func, *arg)
Call user func
source code
 
array_filter(item, func)
Array filter
source code
 
getimagesize(filename)
GD image size
source code
 
explode(delim, val, limit=None)
Splits string on delim
source code
 
microtime()
Gets microtime
source code
 
is_writable(filename)
CHecks file is writeable
source code
 
is_dir(filename)
Checks file is directory
source code
 
array_merge(a1, a2, inplace=False, empty_source=False)
Merges lists
source code
 
array_keys(item)
Get keys
source code
 
array_key_exists(name, item)
Has key
source code
 
isset(obj, val=None, searchGlobal=False, data={})
Check variable existance
source code
 
time_()
Get time
source code
 
in_array(val, obj)
In array
source code
 
array_fill(start, cnt, val)
Fills array
source code
 
array_shift(item)
Shifts array
source code
 
trigger_error(data, errno)
Triggers error
source code
 
function_exists(val, scope={'CRLF': '\r\n', 'ENT_QUOTES': 1, 'E_ALL': 6143, 'E_USER_WARNI...)
Function exists
source code
 
htmlspecialchars(val, flags=None)
html special chars
source code
 
empty(val)
Checks for empty
source code
 
strtr(text, items)
Translate characters...
source code
 
is_uploaded_file(filename)
Check if uploaded file
source code
 
implode(delim, items)
Implodes
source code
 
array_slice(items, a1, a2=None)
Array slice
source code
 
rtrim(val, chars=None)
R Trim
source code
 
ltrim(val, chars=None)
L trim
source code
 
is_file(filename)
Check regular file
source code
 
file_exists(filename)
Check file exists
source code
 
include(filename, scope=None)
Includes file
source code
 
urldecode(val)
Url decoder
source code
 
parse_url(url, port=80)
Parse url Urlparse doesnt support 'mysql' or 'mysqli' schemes so, we need to add a fix for this.
source code
 
print_r(data, ret=False)
Recursive pretty printer
source code
 
object_(dic)
Cast to object
source code
 
array_(obj)
Cast to array
source code
 
strlen(val)
Get strlen
source code
 
array_reverse(items)
Reverses list
source code
 
preg_quote(val, delim=None)
Escapes regular expression
source code
 
preg_match(pat, subject, match=None)
Convert PHP preg_match to Python matcher
source code
 
preg_match_all(pat, subject, matches=None)
Preg Match all
source code
 
uniqid(prefix=None, more_entropy=False)
Returns unique id
source code
 
mt_rand(min=0, max=2147483647)
Random
source code
 
str_replace(pat, rep, subject) source code
 
preg_replace(pat, rep, subject)
preg_replace wrapper
source code
 
dirname(path)
dir name
source code
 
trim(val, chars=None)
trim whitespace
source code
 
count(item)
Gets array count
source code
 
static(func, prop, val=None)
Sets a static var
source code
 
is_numeric(val)
Determines whether or not is numeric
source code
 
is_string(val)
Determines if string
source code
 
is_array(val)
Determines if "array"
source code
 
is_object(val)
Determnes if object
source code
 
is_null(val)
Is null
source code
 
strpos(haystack, needle)
Gets str pos
source code
 
ini_set(name, val)
Pretends to set an ini...
source code
 
serialize(obj)
serializer
source code
 
unserialize(val)
unserializer
source code
 
defined(val, scope={'CRLF': '\r\n', 'ENT_QUOTES': 1, 'E_ALL': 6143, 'E_USER_WARNI...)
Checks for defined var
source code
 
gmdate(format, stamp=None)
GMT date
source code
 
stripslashes(val)
Strip slashes
source code
 
addslashes(val)
Add slashes
source code
 
md5(val)
md5
source code
 
gzinflate(val)
decompress
source code
 
gzdeflate()
compress
source code
 
array_pop(item)
Pops item
source code
 
__preg_setup(pat)
prepares pattern for python regex
source code
 
__str_replace_str(pat, rep, subject)
str replace real
source code
 
__preg_replace_str(pat, rep, subject)
Real preg replace
source code
Variables [hide private]
  __version__ = '$Revision: 1 $'
  SERVER = {'Apple_PubSub_Socket_Render': '/tmp/launch-d5roMI/Re...
  GET = {}
  POST = {}
  REQUEST = {}
  SESSION = None
  ENT_QUOTES = 1
  E_USER_WARNING = 512
  E_ALL = 6143
  CRLF = '\r\n'
Function Details [hide private]

gzencode()

source code 
compress
Parameters:
  • val - Str
Returns:
Str

gzdecode(val)

source code 
decompress
Parameters:
  • val - Str
Returns:
Str

sizeof(item)

source code 
Gets array count
Parameters:
  • item - List,Dict
Returns:
Int

require_once(filename, scope=None)

source code 
Includes file
Parameters:
  • filename - Str
  • scope - Dict
Returns:
Bool

require(filename, scope=None)

source code 
Includes file
Parameters:
  • filename - Str
  • scope - Dict
Returns:
Bool

include_once(filename, scope=None)

source code 
Includes file
Parameters:
  • filename - Str
  • scope - Dict
Returns:
Bool

substr(items, a1, a2=None)

source code 
Array slice
Parameters:
  • items - List,Dict
  • a1 - Int
  • a2 - Int
Returns:
Mixed

preg_replace_callback(pat, rep, subject)

source code 
preg_replace wrapper
Parameters:
  • pat - Str
  • replace - Str
  • subject - Str
Returns:
Str

is_writeable(filename)

source code 
CHecks file is writeable
Parameters:
  • filename - Str
Returns:
Bool

header(data, replace=True)

source code 
Write headers
Parameters:
  • data - Str

flush()

source code 
Flush buffer For now this is only constructed to work with CGI Eventually this will need to be modified to work with WSGI

session_set_save_handler(open_, close_, read_, write_, destroy_, gc_)

source code 
Sets user-level session storage functions
Parameters:
  • open_ - Func
  • close_ - Func
  • read_ - Func
  • write_ - Func
  • destroy_ - Func
  • gc_ - Func
Returns:
Bool

session_start()

source code 
Initialize session data
Returns:
Bool

session_name(name='DrupySession')

source code 
Get and/or set the current session name
Parameters:
  • name - Str
Returns:
Str

define(name, val=None)

source code 
THIS FUNCTION SHOULD BE DEPRECATED EVENTUALLY Sets globals variable
Parameters:
  • name - Str
  • val - Number,Str
Returns:
Bool

error_get_last()

source code 
Gets error. This does not mimic the exact behaviour of the corresponding PHP function
Returns:
Tuple

scandir(path_)

source code 
List files and directories inside the specified path
Parameters:
  • path_ - Str
Returns:
Tuple

uasort(item, func)

source code 
Sort on func
Parameters:
  • item - Iterable
  • func - Function
Returns:
Iterable

call_user_func_array(func, args)

source code 
Call user func
Parameters:
  • func - Function
  • args - Tuple,List
Returns:
Unknown

call_user_func(func, *arg)

source code 
Call user func
Parameters:
  • func - Function
  • arg - Mixed
Returns:
Unknown

array_filter(item, func)

source code 
Array filter
Parameters:
  • item - Iterable
  • func - Function
Returns:
Iterable

getimagesize(filename)

source code 
GD image size
Parameters:
  • filename - Str

explode(delim, val, limit=None)

source code 
Splits string on delim
Parameters:
  • delim - Str
  • val - Str
Returns:
Str

microtime()

source code 
Gets microtime
Returns:
Str

is_writable(filename)

source code 
CHecks file is writeable
Parameters:
  • filename - Str
Returns:
Bool

is_dir(filename)

source code 
Checks file is directory
Parameters:
  • filename - Str
  • inplace - Bool
  • empty_source - Bool
Returns:
Bool

array_merge(a1, a2, inplace=False, empty_source=False)

source code 
Merges lists
Parameters:
  • a1 - Dict,List
  • a2 - Dict,List
Returns:
Dict,List

array_keys(item)

source code 
Get keys
Parameters:
  • item - Dict
Returns:
List

array_key_exists(name, item)

source code 
Has key
Parameters:
  • item - Str
  • item - Dict
Returns:
Bool

isset(obj, val=None, searchGlobal=False, data={})

source code 
Check variable existance
Parameters:
  • obj - Dict,List,Object
  • val - Str,Int
  • searchGlobal - Bool

time_()

source code 
Get time
Returns:
Int

in_array(val, obj)

source code 
In array
Parameters:
  • val - Str,Int
  • obj - List,Dict,Object
Returns:
Bool

array_fill(start, cnt, val)

source code 
Fills array
Parameters:
  • start - Int
  • cnt - Int
  • val - Str
Returns:
Dict

array_shift(item)

source code 
Shifts array
Parameters:
  • item - List,Dict,Tuple
Returns:
Mixed

trigger_error(data, errno)

source code 
Triggers error
Parameters:
  • data - Str

function_exists(val, scope={'CRLF': '\r\n', 'ENT_QUOTES': 1, 'E_ALL': 6143, 'E_USER_WARNI...)

source code 
Function exists
Parameters:
  • obj - Dict,List,Object
  • val - Str
Returns:
Bool

htmlspecialchars(val, flags=None)

source code 
html special chars
Parameters:
  • val - Str
Returns:
Str

empty(val)

source code 
Checks for empty
Parameters:
  • obj - Any
Returns:
Bool

strtr(text, items)

source code 
Translate characters Inspired by snippet from Xavier Defrang

See Also:  

is_uploaded_file(filename)

source code 
Check if uploaded file
Parameters:
  • filename - Str
Returns:
Bool

implode(delim, items)

source code 
Implodes
Parameters:
  • delim - Str
  • items - List
Returns:
Str

array_slice(items, a1, a2=None)

source code 
Array slice
Parameters:
  • items - List,Dict
  • a1 - Int
  • a2 - Int
Returns:
Mixed

rtrim(val, chars=None)

source code 
R Trim
Parameters:
  • val - Str
Returns:
Str

ltrim(val, chars=None)

source code 
L trim
Parameters:
  • val - Str
Returns:
Str

is_file(filename)

source code 
Check regular file
Parameters:
  • filename - String
Returns:
Bool

file_exists(filename)

source code 
Check file exists
Parameters:
  • filename - Str
Returns:
Bool

include(filename, scope=None)

source code 
Includes file
Parameters:
  • filename - Str
  • scope - Dict
Returns:
Bool

urldecode(val)

source code 
Url decoder
Parameters:
  • val - Str
Returns:
Str

parse_url(url, port=80)

source code 
Parse url Urlparse doesnt support 'mysql' or 'mysqli' schemes so, we need to add a fix for this.
Parameters:
  • url
Returns:
Dict

print_r(data, ret=False)

source code 
Recursive pretty printer
Parameters:
  • data - Any
  • ret - Bool
Returns:
Bool,Str

object_(dic)

source code 
Cast to object
Parameters:
  • dic - Dict
Returns:
Object

array_(obj)

source code 
Cast to array
Parameters:
  • obj - Object
Returns:
Dict

strlen(val)

source code 
Get strlen
Parameters:
  • val - Str
Returns:
Int

array_reverse(items)

source code 
Reverses list
Parameters:
  • items - List
Returns:
List

preg_quote(val, delim=None)

source code 
Escapes regular expression
Parameters:
  • val - Str
  • delim - Any Not used
Returns:
Str

preg_match(pat, subject, match=None)

source code 
Convert PHP preg_match to Python matcher
Parameters:
  • pat - Str
  • subject - Str
  • match - Dict
Returns:
Dict

preg_match_all(pat, subject, matches=None)

source code 
Preg Match all
Parameters:
  • pat - Str
  • subject - Str
  • &matches - Reference
Returns:
Int

uniqid(prefix=None, more_entropy=False)

source code 
Returns unique id
Parameters:
  • prefix - Str
  • more_entropy - Bool
Returns:
Str

mt_rand(min=0, max=2147483647)

source code 
Random
Parameters:
  • min - Int
  • max - Int
Returns:
Int

preg_replace(pat, rep, subject)

source code 
preg_replace wrapper
Parameters:
  • pat - Str
  • replace - Str
  • subject - Str
Returns:
Str

dirname(path)

source code 
dir name
Parameters:
  • path - Str
Returns:
Str

trim(val, chars=None)

source code 
trim whitespace
Parameters:
  • val - Str
Returns:
Str

count(item)

source code 
Gets array count
Parameters:
  • item - List,Dict
Returns:
Int

is_numeric(val)

source code 
Determines whether or not is numeric
Parameters:
  • val - Any
Returns:
Bool

is_string(val)

source code 
Determines if string
Parameters:
  • Any
Returns:
Bool

is_array(val)

source code 
Determines if "array"
Parameters:
  • Any
Returns:
Bool

is_null(val)

source code 
Is null
Parameters:
  • val - Any

strpos(haystack, needle)

source code 
Gets str pos
Parameters:
  • haystack - Str
  • needle - Str
Returns:
Int,Bool

ini_set(name, val)

source code 
Pretends to set an ini Actually just sets a global
Parameters:
  • name - Str
  • val - Str,Number,None,Bool
Returns:
Bool

serialize(obj)

source code 
serializer
Parameters:
  • obj - Any
Returns:
Str

unserialize(val)

source code 
unserializer
Parameters:
  • val - Str
Returns:
Obj

gmdate(format, stamp=None)

source code 
GMT date
Parameters:
  • format - Str
  • stamp - Int
Returns:
Str

stripslashes(val)

source code 
Strip slashes
Parameters:
  • val - Str

addslashes(val)

source code 
Add slashes
Parameters:
  • val - Str
Returns:
Str

md5(val)

source code 
md5
Parameters:
  • val - Str
Returns:
Str

gzinflate(val)

source code 
decompress
Parameters:
  • val - Str
Returns:
Str

gzdeflate()

source code 
compress
Parameters:
  • val - Str
Returns:
Str

array_pop(item)

source code 
Pops item
Parameters:
  • item
Returns:
Mixed

__preg_setup(pat)

source code 
prepares pattern for python regex
Parameters:
  • pat - Str
Returns:
_sre.SRE_Pattern Regular Expression object

__str_replace_str(pat, rep, subject)

source code 
str replace real
Parameters:
  • pat - Str
  • rep - Str
  • subject - Str
Returns:
Str

__preg_replace_str(pat, rep, subject)

source code 
Real preg replace
Parameters:
  • pat - Str
  • replace - Str
  • subject - Str
Returns:
Str

Variables Details [hide private]

SERVER

Value:
{'Apple_PubSub_Socket_Render': '/tmp/launch-d5roMI/Render',
 'COMMAND_MODE': 'unix2003',
 'CVS_RSH': 'ssh',
 'DISPLAY': ':0.0',
 'DOCUMENT_ROOT': '/Users/brendon/work/projects/PythonDrupal/drupy/bas\
e',
 'EDITOR': '/usr/bin/emacs',
 'GATEWAY_INTERFACE': 'CGI/1.1',
...