php-var-dump 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 1.0
2
+ Name: php_var_dump
3
+ Version: 0.1
4
+ Summary: a port of the var_dump function of php to python.
5
+ Home-page: http://github.com/jvanasco/php_var_dump
6
+ Author: Jonathan Vanasco
7
+ Author-email: jonathan@findmeon.com
8
+ License: UNKNOWN
9
+ Description: php_var_dump
10
+ ~~~~~~~~~~~~
11
+
12
+ A port of the ``var_dump`` function of php to python.
13
+
14
+ Why on earth would you want this?!?!?
15
+ =====================================
16
+
17
+ Imagine that you have to deploy something in php. You don't have a choice.
18
+ You HAVE to.
19
+
20
+ php_var_dump lets you do all your data processing and management in python.
21
+ You can then convert your native python data structures into php code,
22
+ which can then be saved as include fles for php.
23
+
24
+ Other python modules that can accomplish the general idea:
25
+ phpserialize
26
+ implements the PHP serialize/unserialize functions in python
27
+ allows you to serialize a python data structure to PHP
28
+ allows you to unserialize a php data structure to Python
29
+ simplejson
30
+ there are json parsers in php, which can read code you save
31
+
32
+ The main benefit of using the var_dump method, is that there is no overhead
33
+ in loading/unloading/parsing/etc.
34
+
35
+ This method allows you to build a php include file that simply runs fast,
36
+ and that can use multiple includes within the filesystem as a "database"
37
+ like system. This way you don't have to set up any databases, libraries,
38
+ or whatever - you can just deploy PHP code without coding much in PHP.
39
+
40
+
41
+
42
+
43
+ Usage
44
+ =====
45
+
46
+ >>> from php_var_dump import php_var_dump
47
+ >>> data= "Hello World"
48
+ >>> as_php = php_var_dump( 'var', data )
49
+ >>> print as_php
50
+ $var = 'Hello World';
51
+
52
+ You'd probable then want to save it...
53
+
54
+ data_string= "<?php\n\n%s\n\n?>" % as_php
55
+ open('data.php','w').write(data_string.encode( "utf-8" ))
56
+
57
+ Then just include that file in your php programs.
58
+
59
+ There's also a php_as_block function, which does the trivial encapsulation as above.
60
+
61
+
62
+ Platform: UNKNOWN
63
+ Classifier: License :: OSI Approved :: BSD License
64
+ Classifier: Programming Language :: PHP
65
+ Classifier: Programming Language :: Python
@@ -0,0 +1,5 @@
1
+ a port of the var_dump function of php to python.
2
+
3
+ This module allows you to dump python objects into PHP code.
4
+
5
+ docs are inline
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 1.0
2
+ Name: php-var-dump
3
+ Version: 0.1
4
+ Summary: a port of the var_dump function of php to python.
5
+ Home-page: http://github.com/jvanasco/php_var_dump
6
+ Author: Jonathan Vanasco
7
+ Author-email: jonathan@findmeon.com
8
+ License: UNKNOWN
9
+ Description: php_var_dump
10
+ ~~~~~~~~~~~~
11
+
12
+ A port of the ``var_dump`` function of php to python.
13
+
14
+ Why on earth would you want this?!?!?
15
+ =====================================
16
+
17
+ Imagine that you have to deploy something in php. You don't have a choice.
18
+ You HAVE to.
19
+
20
+ php_var_dump lets you do all your data processing and management in python.
21
+ You can then convert your native python data structures into php code,
22
+ which can then be saved as include fles for php.
23
+
24
+ Other python modules that can accomplish the general idea:
25
+ phpserialize
26
+ implements the PHP serialize/unserialize functions in python
27
+ allows you to serialize a python data structure to PHP
28
+ allows you to unserialize a php data structure to Python
29
+ simplejson
30
+ there are json parsers in php, which can read code you save
31
+
32
+ The main benefit of using the var_dump method, is that there is no overhead
33
+ in loading/unloading/parsing/etc.
34
+
35
+ This method allows you to build a php include file that simply runs fast,
36
+ and that can use multiple includes within the filesystem as a "database"
37
+ like system. This way you don't have to set up any databases, libraries,
38
+ or whatever - you can just deploy PHP code without coding much in PHP.
39
+
40
+
41
+
42
+
43
+ Usage
44
+ =====
45
+
46
+ >>> from php_var_dump import php_var_dump
47
+ >>> data= "Hello World"
48
+ >>> as_php = php_var_dump( 'var', data )
49
+ >>> print as_php
50
+ $var = 'Hello World';
51
+
52
+ You'd probable then want to save it...
53
+
54
+ data_string= "<?php\n\n%s\n\n?>" % as_php
55
+ open('data.php','w').write(data_string.encode( "utf-8" ))
56
+
57
+ Then just include that file in your php programs.
58
+
59
+ There's also a php_as_block function, which does the trivial encapsulation as above.
60
+
61
+
62
+ Platform: UNKNOWN
63
+ Classifier: License :: OSI Approved :: BSD License
64
+ Classifier: Programming Language :: PHP
65
+ Classifier: Programming Language :: Python
@@ -0,0 +1,9 @@
1
+ README
2
+ php_var_dump.py
3
+ setup.cfg
4
+ setup.py
5
+ php_var_dump.egg-info/PKG-INFO
6
+ php_var_dump.egg-info/SOURCES.txt
7
+ php_var_dump.egg-info/dependency_links.txt
8
+ php_var_dump.egg-info/not-zip-safe
9
+ php_var_dump.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ php_var_dump
@@ -0,0 +1,109 @@
1
+ r"""
2
+ php_var_dump
3
+ ~~~~~~~~~~~~
4
+
5
+ A port of the ``var_dump`` function of php to python.
6
+
7
+ Why on earth would you want this?!?!?
8
+ =====================================
9
+
10
+ Imagine that you have to deploy something in php. You don't have a choice.
11
+ You HAVE to.
12
+
13
+ php_var_dump lets you do all your data processing and management in python.
14
+ You can then convert your native python data structures into php code,
15
+ which can then be saved as include fles for php.
16
+
17
+ Other python modules that can accomplish the general idea:
18
+ phpserialize
19
+ implements the PHP serialize/unserialize functions in python
20
+ allows you to serialize a python data structure to PHP
21
+ allows you to unserialize a php data structure to Python
22
+ simplejson
23
+ there are json parsers in php, which can read code you save
24
+
25
+ The main benefit of using the var_dump method, is that there is no overhead
26
+ in loading/unloading/parsing/etc.
27
+
28
+ This method allows you to build a php include file that simply runs fast,
29
+ and that can use multiple includes within the filesystem as a "database"
30
+ like system. This way you don't have to set up any databases, libraries,
31
+ or whatever - you can just deploy PHP code without coding much in PHP.
32
+
33
+
34
+
35
+
36
+ Usage
37
+ =====
38
+
39
+ >>> from php_var_dump import php_var_dump
40
+ >>> data= "Hello World"
41
+ >>> as_php = php_var_dump( 'var', data )
42
+ >>> print as_php
43
+ $var = 'Hello World';
44
+
45
+ You'd probable then want to save it...
46
+
47
+ data_string= "<?php\n\n%s\n\n?>" % as_php
48
+ open('data.php','w').write(data_string.encode( "utf-8" ))
49
+
50
+ Then just include that file in your php programs.
51
+
52
+ There's also a php_as_block function, which does the trivial encapsulation as above.
53
+
54
+
55
+ :copyright: 2012 by Jonathan Vanasco
56
+ license: BSD
57
+ """
58
+
59
+ import types
60
+
61
+ def _php_var_dump(data,depth=0):
62
+ """ utility function; recursively called. depth is used to control the amount of padding.
63
+ This has a limited amount of support for data structures. functions, lambas, etc are not supported
64
+ """
65
+ padding= " "*depth
66
+ keypadding= " "*(depth+1)
67
+ depth+= 1
68
+ if ( type(data) == types.DictType ) or ( type(data) == types.DictionaryType ):
69
+ items = []
70
+ for i in data :
71
+ item = keypadding + "'%s' => %s" % (i,_php_var_dump(data[i],depth=depth))
72
+ items.append(item)
73
+ items = ',\n'.join(items)
74
+ return '%sArray(\n%s\n%s)' % ( padding, items, padding)
75
+ elif ( type(data) == types.ListType ) or ( type(data) == types.TupleType ):
76
+ items = []
77
+ for i in data :
78
+ items.append(_php_var_dump(i,depth=depth))
79
+ items = ',\n'.join(items)
80
+ return '%sArray(\n%s\n%s)' % ( padding, items, padding)
81
+ elif type(data) == types.StringType :
82
+ return padding + "'%s'" % data
83
+ elif type(data) == types.UnicodeType :
84
+ return padding + "'%s'" % data
85
+ elif type(data) == types.IntType :
86
+ return padding + "%s" % data
87
+ elif type(data) == types.BooleanType :
88
+ return padding + "%s" % data
89
+ elif type(data) == types.NoneType :
90
+ return padding + "null"
91
+ elif type(data) == types.LongType :
92
+ return padding + "%s" % data
93
+ elif type(data) == types.FloatType :
94
+ return padding + "%s" % data
95
+ else:
96
+ raise ValueError("Unsupported data type (%s) for data : '%s'" % ( type(data) , data ))
97
+
98
+
99
+ def php_var_dump(name,data):
100
+ """ php_var_dump """
101
+ depth=0
102
+ if type(data) == types.DictType:
103
+ depth= 1
104
+ return "$%s = %s;" % ( name , _php_var_dump(data,depth=depth) )
105
+
106
+
107
+ def php_as_block(stringed_var):
108
+ return "<?php\n\n%s\n\n?>" % stringed_var
109
+
@@ -0,0 +1,5 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+ tag_svn_revision = 0
5
+
@@ -0,0 +1,36 @@
1
+ import os
2
+ from setuptools import setup
3
+
4
+ def get_docs():
5
+ result = []
6
+ in_docs = False
7
+ f = open(os.path.join(os.path.dirname(__file__), 'php_var_dump.py'))
8
+ try:
9
+ for line in f:
10
+ if in_docs:
11
+ if line.lstrip().startswith(':copyright:'):
12
+ break
13
+ result.append(line[4:].rstrip())
14
+ elif line.strip() == 'r"""':
15
+ in_docs = True
16
+ finally:
17
+ f.close()
18
+ return '\n'.join(result)
19
+
20
+ setup(
21
+ name='php_var_dump',
22
+ author='Jonathan Vanasco',
23
+ author_email='jonathan@findmeon.com',
24
+ version='0.1',
25
+ url='http://github.com/jvanasco/php_var_dump',
26
+ py_modules=['php_var_dump'],
27
+ description='a port of the var_dump function of php to python.',
28
+ long_description=get_docs(),
29
+ zip_safe=False,
30
+ test_suite='tests',
31
+ classifiers=[
32
+ 'License :: OSI Approved :: BSD License',
33
+ 'Programming Language :: PHP',
34
+ 'Programming Language :: Python',
35
+ ]
36
+ )