nativeUts 1.0.0__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,6 @@
1
+ Change Log
2
+ ==========
3
+
4
+ 1.0.0 (2025-12-02)
5
+ ------------------
6
+ - First Release
@@ -0,0 +1,8 @@
1
+
2
+ Copyright 2021 Melque Lima
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ global-include *.txt *.py *.md
2
+ recursive-exclude venv *
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.1
2
+ Name: nativeUts
3
+ Version: 1.0.0
4
+ Summary: A Python package for native utilities.
5
+ Home-page:
6
+ Author: Melque Lima
7
+ Author-email: melque_ex@yahoo.com.br
8
+ License: MIT
9
+ Keywords: nativeUts
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Education
12
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENCE.txt
17
+ Requires-Dist: forbiddenfruit==0.1.4
18
+
19
+ # NativeUts
20
+ #
21
+ ### Installation
22
+
23
+ ```sh
24
+ pip install nativeUts
25
+ ```
26
+
27
+ ## GitHub
28
+ https://github.com/ZdekPyPi/NativeUts
29
+
30
+
31
+ ## Usage
32
+ #
33
+
34
+ # LIST — Exemplo de Uso
35
+
36
+ ## `list.group`
37
+
38
+ ```python
39
+ from nativeUts.list import *
40
+
41
+ a = [1, 2, 3, 4, 5, 6, 7]
42
+ print(a.group(3))
43
+ #[[1, 2, 3], [4, 5, 6], [7]]
44
+ ```
45
+
46
+
47
+
48
+ # NUMBER — Exemplo de Uso
49
+
50
+ ## `float.numberToBr`
51
+
52
+ ```python
53
+ from nativeUts.number import *
54
+
55
+ valor = 12345.678
56
+ print(valor.numberToBr())
57
+ #12.345,68
58
+ ```
59
+
60
+ # STRING — Exemplo de Uso
61
+
62
+ ## `str.only_numbers`
63
+
64
+ ```python
65
+ from nativeUts.string import *
66
+
67
+ print("abc123d4".only_numbers())
68
+ #1234
69
+ ```
70
+
71
+ ## `str.only_numbers`
72
+ ```python
73
+
74
+ ```
75
+
76
+ ## `str.usToNumber`
77
+ ```python
78
+ from nativeUts.string import *
79
+
80
+ print("12,345.67".usToNumber())
81
+ #12345.67
82
+ ```
83
+
84
+ ## `str.brToNumber`
85
+ ```python
86
+ from nativeUts.string import *
87
+
88
+ print("R$ 12.345,67".brToNumber())
89
+ #12345.67
90
+ ```
91
+
92
+ ## `str.joinPath`
93
+ ```python
94
+ from nativeUts.string import *
95
+
96
+ print("home/user".joinPath("docs", "file.txt"))
97
+ #home/user/docs/file.txt
98
+ ```
99
+
100
+ ## `str.joinUrl`
101
+ ```python
102
+ from nativeUts.string import *
103
+
104
+ print("https://site.com".joinUrl("api", "v1"))
105
+ #https://site.com/api/v1
106
+ ```
107
+
108
+ ## `str.fileName`
109
+ ```python
110
+ from nativeUts.string import *
111
+
112
+ print("/home/user/file.txt".fileName())
113
+ #file.txt
114
+ ```
115
+ ## `str.isEmail`
116
+ ```python
117
+ from nativeUts.string import *
118
+
119
+ print("user@mail.com".isEmail())
120
+ #True
121
+ ```
122
+ ## `str.isLike`
123
+ ```python
124
+ from nativeUts.string import *
125
+
126
+ print("AB123".isLike(r"[A-Z]{2}[0-9]{3}"))
127
+ #True
128
+ ```
129
+ ## `str.regx`
130
+ ```python
131
+ from nativeUts.string import *
132
+
133
+ print("abc123xyz456".regx(r"\d+"))
134
+ #['123', '456']
135
+ ```
136
+
137
+
138
+ Change Log
139
+ ==========
140
+
141
+ 1.0.0 (2025-12-02)
142
+ ------------------
143
+ - First Release
@@ -0,0 +1,117 @@
1
+ # NativeUts
2
+ #
3
+ ### Installation
4
+
5
+ ```sh
6
+ pip install nativeUts
7
+ ```
8
+
9
+ ## GitHub
10
+ https://github.com/ZdekPyPi/NativeUts
11
+
12
+
13
+ ## Usage
14
+ #
15
+
16
+ # LIST — Exemplo de Uso
17
+
18
+ ## `list.group`
19
+
20
+ ```python
21
+ from nativeUts.list import *
22
+
23
+ a = [1, 2, 3, 4, 5, 6, 7]
24
+ print(a.group(3))
25
+ #[[1, 2, 3], [4, 5, 6], [7]]
26
+ ```
27
+
28
+
29
+
30
+ # NUMBER — Exemplo de Uso
31
+
32
+ ## `float.numberToBr`
33
+
34
+ ```python
35
+ from nativeUts.number import *
36
+
37
+ valor = 12345.678
38
+ print(valor.numberToBr())
39
+ #12.345,68
40
+ ```
41
+
42
+ # STRING — Exemplo de Uso
43
+
44
+ ## `str.only_numbers`
45
+
46
+ ```python
47
+ from nativeUts.string import *
48
+
49
+ print("abc123d4".only_numbers())
50
+ #1234
51
+ ```
52
+
53
+ ## `str.only_numbers`
54
+ ```python
55
+
56
+ ```
57
+
58
+ ## `str.usToNumber`
59
+ ```python
60
+ from nativeUts.string import *
61
+
62
+ print("12,345.67".usToNumber())
63
+ #12345.67
64
+ ```
65
+
66
+ ## `str.brToNumber`
67
+ ```python
68
+ from nativeUts.string import *
69
+
70
+ print("R$ 12.345,67".brToNumber())
71
+ #12345.67
72
+ ```
73
+
74
+ ## `str.joinPath`
75
+ ```python
76
+ from nativeUts.string import *
77
+
78
+ print("home/user".joinPath("docs", "file.txt"))
79
+ #home/user/docs/file.txt
80
+ ```
81
+
82
+ ## `str.joinUrl`
83
+ ```python
84
+ from nativeUts.string import *
85
+
86
+ print("https://site.com".joinUrl("api", "v1"))
87
+ #https://site.com/api/v1
88
+ ```
89
+
90
+ ## `str.fileName`
91
+ ```python
92
+ from nativeUts.string import *
93
+
94
+ print("/home/user/file.txt".fileName())
95
+ #file.txt
96
+ ```
97
+ ## `str.isEmail`
98
+ ```python
99
+ from nativeUts.string import *
100
+
101
+ print("user@mail.com".isEmail())
102
+ #True
103
+ ```
104
+ ## `str.isLike`
105
+ ```python
106
+ from nativeUts.string import *
107
+
108
+ print("AB123".isLike(r"[A-Z]{2}[0-9]{3}"))
109
+ #True
110
+ ```
111
+ ## `str.regx`
112
+ ```python
113
+ from nativeUts.string import *
114
+
115
+ print("abc123xyz456".regx(r"\d+"))
116
+ #['123', '456']
117
+ ```
@@ -0,0 +1,4 @@
1
+ pip3 install setuptools twine
2
+ python setup.py sdist
3
+ twine upload --config-file .\.pypirc --repository-url https://upload.pypi.org/legacy/ dist/*
4
+ twine upload --config-file .\.pypirc .\dist\iniUts-1.1.
@@ -0,0 +1,5 @@
1
+ from .dict import *
2
+ from .list import *
3
+ from .number import *
4
+ from .string import *
5
+ from .pandas import *
@@ -0,0 +1,39 @@
1
+ from forbiddenfruit import curse
2
+
3
+ def explodeDict(dic:dict,key=None):
4
+ adjust = {}
5
+ for k,v in dic.items():
6
+ if isinstance(v,dict):
7
+ v = explodeDict(v,key=k)
8
+ adjust = {**adjust,**v}
9
+ else:
10
+ kk = k if not key else f"{key}_{k}"
11
+ adjust[kk]=v
12
+ return adjust
13
+
14
+ def explodeListDict(dic): #[{},{}]
15
+ adjust = []
16
+ for r in dic:
17
+ if isinstance(r,dict):
18
+ adjust.append(explodeDict(r))
19
+ return adjust
20
+
21
+ def keys_to_lower(dic:dict):
22
+ new = {}
23
+ for k,v in dic.items():
24
+ new[k.lower()] = v
25
+ return new
26
+
27
+ def rename_key(key,new_key,dic:dict):
28
+ v = dic.pop(key)
29
+ dic[new_key] = v
30
+ return dic
31
+
32
+ def filter_keys(dic:dict,keys):
33
+ return {k:y for k,y in dic.items() if k in keys}
34
+
35
+
36
+ curse(dict, "explodeDict", explodeDict)
37
+ curse(dict, "keys_to_lower", keys_to_lower)
38
+ curse(dict, "rename_key", rename_key)
39
+ curse(dict, "filter_keys", filter_keys)
@@ -0,0 +1,9 @@
1
+ from forbiddenfruit import curse
2
+
3
+
4
+
5
+ #============================ LIST
6
+ def group(self,n):
7
+ return [self[x:x+n] for x in range(0, len(self), n)]
8
+
9
+ curse(list, "group", group)
@@ -0,0 +1,10 @@
1
+ from forbiddenfruit import curse
2
+
3
+
4
+
5
+ def numberToBr(self):
6
+ return f"{self:,.2f}".replace(",", "X").replace(".", ",").replace("X", ".")
7
+
8
+
9
+
10
+ curse(float, "numberToBr", numberToBr)
@@ -0,0 +1,49 @@
1
+ from forbiddenfruit import curse
2
+ import pandas as pd
3
+ import unicodedata
4
+
5
+
6
+ #============================ DATAFRAME
7
+ def trim_all(self):
8
+ return self.map(lambda x: x.strip() if isinstance(x, str) else x)
9
+
10
+ def table_query(self,table_name,varchar=255,force_string=False,query_type="postgres"):
11
+ tipos = { "O":f"VARCHAR({varchar})","int64": "BIGINT","q": "BIGINT", "float64": "FLOAT","d": "FLOAT", "object": f"VARCHAR({varchar})", "bool": "BOOLEAN","?": f"VARCHAR({varchar})", "datetime64[ns]": "TIMESTAMP", "timedelta[ns]": "INTERVAL", "category": f"VARCHAR({varchar})", "int32": "INT", "float32": "REAL", "string": "TEXT", "UInt8": "TINYINT", "UInt16": "SMALLINT", "UInt32": "INT", "UInt64": "BIGINT", "Int8": "TINYINT", "Int16": "SMALLINT", "Int32": "INT", "Int64": "BIGINT" }
12
+
13
+ column_name_format = lambda x:f'[{x}]' if query_type != 'postgres' else f'"{x}"'
14
+
15
+ if force_string:
16
+ return f"create table {table_name} (\n" + "\n".join([f"{column_name_format(x)} VARCHAR({varchar})," for x in self.columns])[0:-1] + "\n)"
17
+ else:
18
+ return f"create table {table_name} (\n" + "\n".join([f"{column_name_format(x)} {tipos[self.dtypes[x].char]}," for x in self.columns])[0:-1] + "\n)"
19
+
20
+
21
+ def headers_snake_case(self):
22
+ '''
23
+ Essa função faz:
24
+ espaços para _
25
+ retira espaços extras
26
+ retira acentuacao
27
+ '''
28
+ df_loc = self.copy()
29
+
30
+ retira_acentuacao = lambda titulo:unicodedata.normalize("NFKD", titulo).encode("ascii", "ignore").decode("ascii")
31
+ retira_caracteres = lambda titulo: "".join([x for x in titulo if x not in "-()/\\'"])
32
+ para_minusculas = lambda titulo:titulo.lower()
33
+ retira_espacos_ext = lambda titulo: titulo.replace(" "," ")
34
+ retira_laterais = lambda titulo: titulo.strip()
35
+ retira_espacos = lambda titulo: titulo.replace(" ","_")
36
+
37
+ df_loc.columns = df_loc.columns.map(retira_acentuacao)
38
+ df_loc.columns = df_loc.columns.map(retira_caracteres)
39
+ df_loc.columns = df_loc.columns.map(para_minusculas)
40
+ df_loc.columns = df_loc.columns.map(retira_espacos_ext)
41
+ df_loc.columns = df_loc.columns.map(retira_laterais)
42
+ df_loc.columns = df_loc.columns.map(retira_espacos)
43
+
44
+ return df_loc
45
+
46
+
47
+ curse(pd.DataFrame, "trim_all", trim_all)
48
+ curse(pd.DataFrame, "table_query", table_query)
49
+ curse(pd.DataFrame, "headers_snake_case", headers_snake_case)
@@ -0,0 +1,52 @@
1
+ from forbiddenfruit import curse
2
+ import os
3
+ from pathlib import Path
4
+ import re
5
+ import posixpath
6
+
7
+
8
+ #============================ STRING
9
+ def only_numbers(self):
10
+ return "".join([x for x in self if x in "0123456789"])
11
+
12
+ def usToNumber(self):
13
+ return float(self.replace(",",""))
14
+
15
+ def brToNumber(self):
16
+ num = re.sub(r"R|r|\$", "", self)
17
+ num = num.replace(".","")
18
+ num = num.replace(",",".")
19
+ return float(num.strip() or '0')
20
+
21
+ def joinPath(self,*paths):
22
+ return os.path.join(self, *paths)
23
+
24
+ def joinUrl(self,*paths):
25
+ return posixpath.join(self, *paths)
26
+
27
+ def fileName(self,extension=True):
28
+ if extension:
29
+ return os.path.basename(self)
30
+ return Path(self).stem
31
+
32
+ def isEmail(self):
33
+ r = re.compile(r'^[\w-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$')
34
+ return bool(r.match(self))
35
+
36
+ def isLike(self,pattern):
37
+ r = re.compile(f"^{pattern}$")
38
+ return bool(r.match(self))
39
+
40
+ def regx(self,pattern):
41
+ return re.findall(pattern,self)
42
+
43
+
44
+ curse(str, "only_numbers", only_numbers)
45
+ curse(str, "usToNumber", usToNumber)
46
+ curse(str, "brToNumber", brToNumber)
47
+ curse(str, "isEmail", isEmail)
48
+ curse(str, "joinPath", joinPath)
49
+ curse(str, "joinUrl", joinUrl)
50
+ curse(str, "fileName", fileName)
51
+ curse(str, "isLike", isLike)
52
+ curse(str, "regx", regx)
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.1
2
+ Name: nativeUts
3
+ Version: 1.0.0
4
+ Summary: A Python package for native utilities.
5
+ Home-page:
6
+ Author: Melque Lima
7
+ Author-email: melque_ex@yahoo.com.br
8
+ License: MIT
9
+ Keywords: nativeUts
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Education
12
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENCE.txt
17
+ Requires-Dist: forbiddenfruit==0.1.4
18
+
19
+ # NativeUts
20
+ #
21
+ ### Installation
22
+
23
+ ```sh
24
+ pip install nativeUts
25
+ ```
26
+
27
+ ## GitHub
28
+ https://github.com/ZdekPyPi/NativeUts
29
+
30
+
31
+ ## Usage
32
+ #
33
+
34
+ # LIST — Exemplo de Uso
35
+
36
+ ## `list.group`
37
+
38
+ ```python
39
+ from nativeUts.list import *
40
+
41
+ a = [1, 2, 3, 4, 5, 6, 7]
42
+ print(a.group(3))
43
+ #[[1, 2, 3], [4, 5, 6], [7]]
44
+ ```
45
+
46
+
47
+
48
+ # NUMBER — Exemplo de Uso
49
+
50
+ ## `float.numberToBr`
51
+
52
+ ```python
53
+ from nativeUts.number import *
54
+
55
+ valor = 12345.678
56
+ print(valor.numberToBr())
57
+ #12.345,68
58
+ ```
59
+
60
+ # STRING — Exemplo de Uso
61
+
62
+ ## `str.only_numbers`
63
+
64
+ ```python
65
+ from nativeUts.string import *
66
+
67
+ print("abc123d4".only_numbers())
68
+ #1234
69
+ ```
70
+
71
+ ## `str.only_numbers`
72
+ ```python
73
+
74
+ ```
75
+
76
+ ## `str.usToNumber`
77
+ ```python
78
+ from nativeUts.string import *
79
+
80
+ print("12,345.67".usToNumber())
81
+ #12345.67
82
+ ```
83
+
84
+ ## `str.brToNumber`
85
+ ```python
86
+ from nativeUts.string import *
87
+
88
+ print("R$ 12.345,67".brToNumber())
89
+ #12345.67
90
+ ```
91
+
92
+ ## `str.joinPath`
93
+ ```python
94
+ from nativeUts.string import *
95
+
96
+ print("home/user".joinPath("docs", "file.txt"))
97
+ #home/user/docs/file.txt
98
+ ```
99
+
100
+ ## `str.joinUrl`
101
+ ```python
102
+ from nativeUts.string import *
103
+
104
+ print("https://site.com".joinUrl("api", "v1"))
105
+ #https://site.com/api/v1
106
+ ```
107
+
108
+ ## `str.fileName`
109
+ ```python
110
+ from nativeUts.string import *
111
+
112
+ print("/home/user/file.txt".fileName())
113
+ #file.txt
114
+ ```
115
+ ## `str.isEmail`
116
+ ```python
117
+ from nativeUts.string import *
118
+
119
+ print("user@mail.com".isEmail())
120
+ #True
121
+ ```
122
+ ## `str.isLike`
123
+ ```python
124
+ from nativeUts.string import *
125
+
126
+ print("AB123".isLike(r"[A-Z]{2}[0-9]{3}"))
127
+ #True
128
+ ```
129
+ ## `str.regx`
130
+ ```python
131
+ from nativeUts.string import *
132
+
133
+ print("abc123xyz456".regx(r"\d+"))
134
+ #['123', '456']
135
+ ```
136
+
137
+
138
+ Change Log
139
+ ==========
140
+
141
+ 1.0.0 (2025-12-02)
142
+ ------------------
143
+ - First Release
@@ -0,0 +1,18 @@
1
+ CHANGELOG.txt
2
+ LICENCE.txt
3
+ MANIFEST.in
4
+ README.md
5
+ commands.txt
6
+ run.py
7
+ setup.py
8
+ nativeUts/__init__.py
9
+ nativeUts/dict.py
10
+ nativeUts/list.py
11
+ nativeUts/number.py
12
+ nativeUts/pandas.py
13
+ nativeUts/string.py
14
+ nativeUts.egg-info/PKG-INFO
15
+ nativeUts.egg-info/SOURCES.txt
16
+ nativeUts.egg-info/dependency_links.txt
17
+ nativeUts.egg-info/requires.txt
18
+ nativeUts.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ forbiddenfruit==0.1.4
@@ -0,0 +1 @@
1
+ nativeUts
nativeuts-1.0.0/run.py ADDED
@@ -0,0 +1,6 @@
1
+ #TEST FILE
2
+ from dotenv import load_dotenv
3
+ import sys
4
+ import os
5
+ sys.path.append("./nativeUts")
6
+ from nativeUts import *
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ from setuptools import setup, find_packages, Extension
2
+
3
+ classifiers = [
4
+ 'Development Status :: 5 - Production/Stable',
5
+ 'Intended Audience :: Education',
6
+ 'Operating System :: Microsoft :: Windows :: Windows 10',
7
+ 'License :: OSI Approved :: MIT License',
8
+ 'Programming Language :: Python :: 3'
9
+ ]
10
+
11
+ setup(
12
+ name='nativeUts',
13
+ version='1.0.0',
14
+ description='A Python package for native utilities.',
15
+ long_description=open('README.md').read() + '\n\n' + open('CHANGELOG.txt').read(),
16
+ long_description_content_type='text/markdown',
17
+ url='',
18
+ author='Melque Lima',
19
+ author_email='melque_ex@yahoo.com.br',
20
+ license='MIT',
21
+ classifiers=classifiers,
22
+ keywords='nativeUts',
23
+ packages=find_packages(),
24
+ install_requires=[
25
+ 'forbiddenfruit==0.1.4',
26
+ ]
27
+ )