imio.pyutils 1.0.2__tar.gz → 1.0.4__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.
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/CHANGES.rst +14 -0
- {imio_pyutils-1.0.2/imio.pyutils.egg-info → imio.pyutils-1.0.4}/PKG-INFO +18 -4
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio/__init__.py +2 -1
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio/pyutils/bs.py +2 -2
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio/pyutils/postgres.py +23 -16
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio/pyutils/system.py +128 -79
- imio.pyutils-1.0.4/imio/pyutils/tests.py +244 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio/pyutils/utils.py +36 -34
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4/imio.pyutils.egg-info}/PKG-INFO +18 -4
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio.pyutils.egg-info/SOURCES.txt +1 -0
- imio.pyutils-1.0.4/imio.pyutils.egg-info/entry_points.txt +3 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio.pyutils.egg-info/requires.txt +2 -1
- imio.pyutils-1.0.4/setup.py +48 -0
- imio_pyutils-1.0.2/imio/pyutils/tests.py +0 -241
- imio_pyutils-1.0.2/setup.py +0 -44
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/MANIFEST.in +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/Makefile +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/README.rst +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio/pyutils/__init__.py +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio.pyutils.egg-info/dependency_links.txt +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio.pyutils.egg-info/namespace_packages.txt +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio.pyutils.egg-info/not-zip-safe +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/imio.pyutils.egg-info/top_level.txt +0 -0
- {imio_pyutils-1.0.2 → imio.pyutils-1.0.4}/setup.cfg +0 -0
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
1.0.4 (2024-06-11)
|
|
5
|
+
------------------
|
|
6
|
+
|
|
7
|
+
- Blacked files.
|
|
8
|
+
[sgeulette]
|
|
9
|
+
- Added `system.post_request` to send a POST request.
|
|
10
|
+
[sgeulette]
|
|
11
|
+
|
|
12
|
+
1.0.3 (2024-05-24)
|
|
13
|
+
------------------
|
|
14
|
+
|
|
15
|
+
- Fix bad release for python2.
|
|
16
|
+
[aduchene]
|
|
17
|
+
|
|
4
18
|
1.0.2 (2024-05-15)
|
|
5
19
|
------------------
|
|
6
20
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: imio.pyutils
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: Some python useful methods
|
|
5
5
|
Home-page: https://github.com/imio/imio.pyutils/
|
|
6
6
|
Author: IMIO
|
|
@@ -9,15 +9,13 @@ License: GPL
|
|
|
9
9
|
Project-URL: PyPI, https://pypi.python.org/pypi/imio.pyutils
|
|
10
10
|
Project-URL: Source, https://github.com/imio/imio.pyutils
|
|
11
11
|
Keywords: Python IMIO
|
|
12
|
+
Platform: UNKNOWN
|
|
12
13
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
14
|
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
|
|
14
15
|
Classifier: Operating System :: OS Independent
|
|
15
16
|
Classifier: Programming Language :: Python
|
|
16
17
|
Classifier: Programming Language :: Python :: 2.7
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Requires-Dist: setuptools
|
|
19
|
-
Requires-Dist: future
|
|
20
|
-
Requires-Dist: six>=1.16.0
|
|
21
19
|
|
|
22
20
|
.. image:: https://github.com/IMIO/imio.pyutils/actions/workflows/main.yml/badge.svg?branch=master
|
|
23
21
|
:target: https://github.com/IMIO/imio.pyutils/actions/workflows/main.yml
|
|
@@ -82,6 +80,20 @@ Can be run with: `bin/python -m unittest discover`
|
|
|
82
80
|
Changelog
|
|
83
81
|
=========
|
|
84
82
|
|
|
83
|
+
1.0.4 (2024-06-11)
|
|
84
|
+
------------------
|
|
85
|
+
|
|
86
|
+
- Blacked files.
|
|
87
|
+
[sgeulette]
|
|
88
|
+
- Added `system.post_request` to send a POST request.
|
|
89
|
+
[sgeulette]
|
|
90
|
+
|
|
91
|
+
1.0.3 (2024-05-24)
|
|
92
|
+
------------------
|
|
93
|
+
|
|
94
|
+
- Fix bad release for python2.
|
|
95
|
+
[aduchene]
|
|
96
|
+
|
|
85
97
|
1.0.2 (2024-05-15)
|
|
86
98
|
------------------
|
|
87
99
|
|
|
@@ -345,3 +357,5 @@ Changelog
|
|
|
345
357
|
|
|
346
358
|
- Initial release.
|
|
347
359
|
[sgeulette]
|
|
360
|
+
|
|
361
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
|
|
2
2
|
try:
|
|
3
|
-
__import__(
|
|
3
|
+
__import__("pkg_resources").declare_namespace(__name__)
|
|
4
4
|
except ImportError:
|
|
5
5
|
from pkgutil import extend_path
|
|
6
|
+
|
|
6
7
|
__path__ = extend_path(__path__, __name__)
|
|
@@ -68,13 +68,13 @@ def remove_comments(element):
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
def remove_elements(element, to_remove=[]):
|
|
71
|
-
"""Removes sub tags and all their content
|
|
71
|
+
"""Removes sub tags and all their content"""
|
|
72
72
|
for tagtr in to_remove:
|
|
73
73
|
for tag in element.find_all(tagtr):
|
|
74
74
|
tag.decompose()
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def replace_entire_strings(element, replace=
|
|
77
|
+
def replace_entire_strings(element, replace="\n", by=""):
|
|
78
78
|
"""Replaces an entire string by another value. With default params, removes newlines.
|
|
79
79
|
|
|
80
80
|
:param element: bs item
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
import psycopg2
|
|
9
|
-
from system import error, trace
|
|
9
|
+
from .system import error, trace
|
|
10
10
|
|
|
11
11
|
# ------------------------------------------------------------------------------
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
# dsn="host=localhost port=5432 dbname= user= password="
|
|
15
15
|
def openConnection(dsn):
|
|
16
|
-
"""
|
|
16
|
+
"""open a postgres connection"""
|
|
17
17
|
conn = None
|
|
18
18
|
try:
|
|
19
19
|
conn = psycopg2.connect(dsn)
|
|
@@ -23,11 +23,12 @@ def openConnection(dsn):
|
|
|
23
23
|
raise Exception(msg)
|
|
24
24
|
return conn
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
# ------------------------------------------------------------------------------
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
def insertInTable(dsn, table, columns, vals, TRACE=False):
|
|
30
|
-
"""
|
|
31
|
+
"""insert values in a table"""
|
|
31
32
|
conn = openConnection(dsn)
|
|
32
33
|
cursor = conn.cursor()
|
|
33
34
|
req = "insert into %s(%s) values(%s)" % (table, columns, vals)
|
|
@@ -45,16 +46,17 @@ def insertInTable(dsn, table, columns, vals, TRACE=False):
|
|
|
45
46
|
conn.close()
|
|
46
47
|
return True
|
|
47
48
|
|
|
49
|
+
|
|
48
50
|
# ------------------------------------------------------------------------------
|
|
49
51
|
|
|
50
52
|
|
|
51
|
-
def updateTable(dsn, table, updates, condition=
|
|
52
|
-
"""
|
|
53
|
+
def updateTable(dsn, table, updates, condition="", TRACE=False):
|
|
54
|
+
"""update columns in a table"""
|
|
53
55
|
conn = openConnection(dsn)
|
|
54
56
|
cursor = conn.cursor()
|
|
55
57
|
req = "update %s set %s" % (table, updates)
|
|
56
58
|
if condition:
|
|
57
|
-
req +=
|
|
59
|
+
req += " where %s" % condition
|
|
58
60
|
trace(TRACE, "Update: %s" % req)
|
|
59
61
|
try:
|
|
60
62
|
cursor.execute(req)
|
|
@@ -69,11 +71,12 @@ def updateTable(dsn, table, updates, condition='', TRACE=False):
|
|
|
69
71
|
conn.close()
|
|
70
72
|
return True
|
|
71
73
|
|
|
74
|
+
|
|
72
75
|
# ------------------------------------------------------------------------------
|
|
73
76
|
|
|
74
77
|
|
|
75
78
|
def selectWithSQLRequest(dsn, sql, TRACE=False):
|
|
76
|
-
"""
|
|
79
|
+
"""select multiple lines in a table with a complete sql"""
|
|
77
80
|
conn = openConnection(dsn)
|
|
78
81
|
cursor = conn.cursor()
|
|
79
82
|
req = sql
|
|
@@ -90,16 +93,17 @@ def selectWithSQLRequest(dsn, sql, TRACE=False):
|
|
|
90
93
|
conn.close()
|
|
91
94
|
return data
|
|
92
95
|
|
|
96
|
+
|
|
93
97
|
# ------------------------------------------------------------------------------
|
|
94
98
|
|
|
95
99
|
|
|
96
|
-
def selectAllInTable(dsn, table, selection, condition=
|
|
97
|
-
"""
|
|
100
|
+
def selectAllInTable(dsn, table, selection, condition="", TRACE=False):
|
|
101
|
+
"""select multiple lines in a table"""
|
|
98
102
|
conn = openConnection(dsn)
|
|
99
103
|
cursor = conn.cursor()
|
|
100
104
|
req = "select %s from %s" % (selection, table)
|
|
101
105
|
if condition:
|
|
102
|
-
req +=
|
|
106
|
+
req += " where %s" % condition
|
|
103
107
|
trace(TRACE, "Selection: %s" % req)
|
|
104
108
|
try:
|
|
105
109
|
cursor.execute(req)
|
|
@@ -113,16 +117,17 @@ def selectAllInTable(dsn, table, selection, condition='', TRACE=False):
|
|
|
113
117
|
conn.close()
|
|
114
118
|
return data
|
|
115
119
|
|
|
120
|
+
|
|
116
121
|
# ------------------------------------------------------------------------------
|
|
117
122
|
|
|
118
123
|
|
|
119
|
-
def selectOneInTable(dsn, table, selection, condition=
|
|
120
|
-
"""
|
|
124
|
+
def selectOneInTable(dsn, table, selection, condition="", TRACE=False):
|
|
125
|
+
"""select a single line in a table"""
|
|
121
126
|
conn = openConnection(dsn)
|
|
122
127
|
cursor = conn.cursor()
|
|
123
128
|
req = "select %s from %s" % (selection, table)
|
|
124
129
|
if condition:
|
|
125
|
-
req +=
|
|
130
|
+
req += " where %s" % condition
|
|
126
131
|
trace(TRACE, "Selection: %s" % req)
|
|
127
132
|
try:
|
|
128
133
|
cursor.execute(req)
|
|
@@ -136,16 +141,17 @@ def selectOneInTable(dsn, table, selection, condition='', TRACE=False):
|
|
|
136
141
|
conn.close()
|
|
137
142
|
return data
|
|
138
143
|
|
|
144
|
+
|
|
139
145
|
# ------------------------------------------------------------------------------
|
|
140
146
|
|
|
141
147
|
|
|
142
|
-
def deleteTable(dsn, table, condition=
|
|
143
|
-
"""
|
|
148
|
+
def deleteTable(dsn, table, condition="", TRACE=False):
|
|
149
|
+
"""delete a table"""
|
|
144
150
|
conn = openConnection(dsn)
|
|
145
151
|
cursor = conn.cursor()
|
|
146
152
|
req = "delete from %s" % table
|
|
147
153
|
if condition:
|
|
148
|
-
req +=
|
|
154
|
+
req += " where %s" % condition
|
|
149
155
|
trace(TRACE, "Deletion : %s" % req)
|
|
150
156
|
try:
|
|
151
157
|
cursor.execute(req)
|
|
@@ -160,4 +166,5 @@ def deleteTable(dsn, table, condition='', TRACE=False):
|
|
|
160
166
|
conn.close()
|
|
161
167
|
return True
|
|
162
168
|
|
|
169
|
+
|
|
163
170
|
# ------------------------------------------------------------------------------
|