Skip to content

Commit 430c580

Browse files
author
Corne Bester
committed
feat: package for pypi
1 parent cd83d41 commit 430c580

9 files changed

Lines changed: 63 additions & 35 deletions

File tree

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"snyk.advanced.organization": "4d30615c-6bb3-4e73-9c86-2fce0ad942d2",
3+
"snyk.advanced.autoSelectOrganization": true
4+
}

README.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ example
44

55
```
66
from datetime import datetime, timezone
7-
from modules.time_functions import get_timestamp_unix_millis
8-
# OR
97
from time_functions import get_timestamp_unix_millis
108
# OR
119
import time_functions
@@ -17,30 +15,16 @@ unix_millis = get_timestamp_unix_millis(timestamp) # create unix timestamp from
1715

1816
## local dev
1917

20-
pip install pytest build
18+
pip install -r requirements.txt
19+
2120

2221
## test
2322

2423
pytest
2524

26-
## build ( create dist artifacts )
27-
28-
python -m build
29-
30-
## install from location
31-
32-
python -m pip install "C:\Users\corne\Documents\GitHub\python_time_functions\dist\pythom_time_functions-2.1.0-py3-none-any.whl"
33-
3425

3526
### other
3627

3728
pip3 freeze > requirements.txt
3829

39-
## bad formats I dreamed up for iot/psql. fix with sanitizer fx
4030

41-
>>> time_functions.timestamp_sanitizer_psql(1729755232184)
42-
1729755232.184
43-
>>> time_functions.timestamp_sanitizer_psql(1729765227856.3)
44-
1729765227.856
45-
>>> time_functions.timestamp_sanitizer_psql(1729765228327.051)
46-
1729765228.327

test.py renamed to example_conversions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22

33
from datetime import datetime, timezone
4-
import time_functions
4+
import src.python_time_fuctions.time_functions as time_functions
55

66
logger = logging.getLogger(__name__)
77

@@ -41,7 +41,7 @@
4141
print(f"unix_micros: {unix_micros}")
4242
print(f"unix_with_subseconds: {unix_with_subseconds}")
4343

44-
print("--- convertions ---")
44+
print("--- conversions ---")
4545
print(f"obj_from_iso: {obj_from_iso}", )
4646
print(f"obj_from_iso_millis: {obj_from_iso_millis}")
4747
print(f"obj_from_iso_micros: {obj_from_iso_micros}")
@@ -59,4 +59,4 @@
5959
dtstmp = (
6060
obj.strftime("%Y%m%d-%H%M%S.%f")[:-3] + " UTC,"
6161
) # Chris format for psql
62-
print(f"CSIRO: {dtstmp}")
62+
print(f"custom: {dtstmp}")

pyproject.toml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ requires = ["setuptools>=65.5.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "pythom_time_functions"
7-
version = "2.1.1"
6+
name = "python_time_functions"
7+
version = "2.1.2"
88
description = "Common Python functions for time handling"
9+
readme = "README.md"
910
authors = [{name = "Corne Bester", email = "corne.bester@gmail.com"}]
1011
dependencies = [
12+
"datetime",
13+
"timezone"
1114
]
12-
1315
license = "MIT"
14-
license-files = ["LICEN[CS]E*"]
16+
license-files = ["LICEN[CS]E*"]
17+
18+
[project.urls]
19+
Homepage = "https://example.com"
20+
Documentation = "https://readthedocs.org"
21+
Repository = "https://github.com/cornebester/python_time_functions"
22+
Issues = "https://github.com/cornebester/python_time_functions/issues"
23+
Changelog = "https://github.com/cornebester/python_time_functions/blob/master/CHANGELOG.md"
24+

requirements.txt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
1-
build==1.3.0
1+
backports.tarfile==1.2.0
2+
build==1.4.0
3+
certifi==2026.2.25
4+
charset-normalizer==3.4.5
25
colorama==0.4.6
3-
exceptiongroup==1.3.0
6+
docutils==0.22.4
7+
exceptiongroup==1.3.1
8+
id==1.6.1
9+
idna==3.11
10+
importlib_metadata==8.7.1
411
iniconfig==2.3.0
5-
packaging==25.0
12+
jaraco.classes==3.4.0
13+
jaraco.context==6.1.1
14+
jaraco.functools==4.4.0
15+
keyring==25.7.0
16+
markdown-it-py==4.0.0
17+
mdurl==0.1.2
18+
more-itertools==10.8.0
19+
nh3==0.3.3
20+
packaging==26.0
621
pluggy==1.6.0
722
Pygments==2.19.2
823
pyproject_hooks==1.2.0
9-
pytest==8.4.2
10-
tomli==2.3.0
11-
typing_extensions==4.15.0
24+
pytest==9.0.2
25+
pywin32-ctypes==0.2.3
26+
readme_renderer==44.0
27+
requests==2.32.5
28+
requests-toolbelt==1.0.0
29+
rfc3986==2.0.0
30+
rich==14.3.3
31+
tomli==2.4.0
32+
twine==6.2.0
33+
typing_extensions==4.15.0
34+
urllib3==2.6.3
35+
zipp==3.23.0

src/python_time_fuctions/__init__.py

Whitespace-only changes.

time_functions.py renamed to src/python_time_fuctions/time_functions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,14 @@ def timestamp_parser_psql_millis(timestamp):
241241
def timestamp_sanitizer_psql(input):
242242
'''
243243
Normalize unix timestamps to postgresl friendly float with millisecond decimals. 14 digits
244-
Attemps to fix/sanitize bad timestamps
245-
handle timestamnp as:
244+
Attemps to fix/sanitize bad timestamp format I dreamed up like
245+
>>> time_functions.timestamp_sanitizer_psql(1729755232184)
246+
1729755232.184
247+
>>> time_functions.timestamp_sanitizer_psql(1729765227856.3)
248+
1729765227.856
249+
>>> time_functions.timestamp_sanitizer_psql(1729765228327.051)
250+
1729765228.327
251+
handle timestamp as:
246252
unix micros or millis in decimal format
247253
unix millis or micros in unix format
248254
iso8601

tests/test_time_function_sanitizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import time_functions
1+
import src.python_time_fuctions.time_functions as time_functions
22

33
def test_convertions_from_sample23():
44
assert float(time_functions.timestamp_sanitizer_psql(1742758997)) == 1742758997

tests/test_time_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from datetime import datetime, timezone
3-
import time_functions
3+
import src.python_time_fuctions.time_functions as time_functions
44

55

66
new_obj = datetime.now(timezone.utc)

0 commit comments

Comments
 (0)