11# xocto - utilities for Python services
22
3- This repo houses various shared utilities for Python services at Octopus Energy.
3+ This repo houses various shared utilities for Python services at Kraken
4+ Technologies.
5+
6+ This library works with Python 3.8 and above.
47
58CI status:
69
710[ ![ CircleCI] ( https://circleci.com/gh/octoenergy/xocto/tree/master.svg?style=svg )] ( https://circleci.com/gh/octoenergy/xocto/tree/master )
811
9- PyPI detail page: https://pypi.python.org/pypi/xocto
12+ PyPI detail page: < https://pypi.python.org/pypi/xocto >
1013
1114## Functionality
1215
1316### Event publishing
1417
1518Use ` events.publish ` to publish application events. These will be logged as JSON
16- to a logger named "events".
19+ to a logger named "events".
1720
1821Sample usage:
1922
2023``` python
2124from xocto import events
2225
2326events.publish(
24- event = " ACCOUNT.CREATED" ,
27+ event = " ACCOUNT.CREATED" ,
2528 params = {
26- ' name' : ' Barry Chuckle' ,
29+ ' name' : ' Barry Chuckle' ,
2730 ' quote_id' : ' xyz123' ,
2831 },
2932 meta = {
@@ -47,7 +50,7 @@ with events.Timer() as t:
4750events.publish(
4851 event = " SOMETHING.HAPPENED" ,
4952 meta = {
50- " duration_in_ms" : t.duration_in_ms
53+ " duration_in_ms" : t.duration_in_ms
5154 }
5255)
5356```
@@ -75,13 +78,15 @@ from xocto.ranges import Range, RangeBoundaries
7578[< Range: [3 ,4 )> , < Range: [4 ,5 )> ]
7679```
7780
78- See [xocto.ranges](xocto/ ranges.py) for more details, including examples and in depth technical details.
81+ See [`xocto.ranges` ](xocto/ ranges.py) for more details, including examples and in
82+ depth technical details.
7983
8084# ## Numbers
8185
8286The `numbers` module is intended as your one- stop shop for all things numbers.
8387
8488An example of rounding a number to an arbitrary integer base:
89+
8590```python
8691from xocto.numbers import quantise
8792
@@ -93,11 +98,14 @@ See [xocto.numbers](xocto/numbers.py) for more details, including examples and i
9398
9499# ## The localtime module
95100
96- This module is a battle tested and well reviewed module for working with dates, times and timezones.
101+ This module is a battle tested and well reviewed module for working with dates,
102+ times and timezones.
97103
98- It' s been over the years internally in Kraken Technologies, and is used heavily internally.
104+ It' s been over the years internally in Kraken Technologies, and is used heavily
105+ internally.
99106
100- The main API it presents is composed of a series of functions which accept a date/ datetime object , and manipulate it in one form or another.
107+ The main API it presents is composed of a series of functions which accept a
108+ date/ datetime object , and manipulate it in one form or another.
101109
102110Examples of a few of those:
103111
@@ -114,43 +122,67 @@ from xocto import localtime
114122
115123See [xocto.localtime](xocto/ localtime.py) for more details, including examples and in depth technical details.
116124
125+ # # Development
126+
127+ # ## Installation
128+
129+ Create and activate a Python 3.8 virtualenv then run:
130+
131+ ```sh
132+ make install
133+ ```
117134
118- # # Contributing
135+ to install the package including development and testing dependencies
119136
120- Create and activate a virtualenv then:
137+ # ## Running tests
121138
122- $ make
139+ Run the test suite with :
123140
124- Test package locally with :
141+ ```sh
142+ make test
143+ ```
125144
126- $ make test
145+ # ## Running static analysis
127146
128- and :
147+ Use these make commands
129148
130- $ make lint
149+ ```sh
150+ make lint
151+ make black
152+ make isort
153+ ```
131154
132- Development docker images can be built with :
155+ Docker images for these jobs can be built with :
133156
134- $ make docker_images
157+ ```sh
158+ make docker_images
159+ ```
135160
136- which creates separate images for pytest, isort and black. Each can be run like so:
161+ This creates separate images for pytest, isort and black. Each can be run like
162+ so:
137163
138- $ docker run - v `pwd` :/ opt/ app xocto/ pytest
139- $ docker run - v `pwd` :/ opt/ app xocto/ isort
140- $ docker run - v `pwd` :/ opt/ app xocto/ black
164+ ```sh
165+ docker run - v `pwd` :/ opt/ app xocto/ pytest
166+ docker run - v `pwd` :/ opt/ app xocto/ isort
167+ docker run - v `pwd` :/ opt/ app xocto/ black
168+ ```
141169
142- # # Release new version
170+ # ## Publishing
143171
144172Release to PyPI by:
145173
1461741 . Bumping the version in `setup.py`
147175
1481762 . Updating `CHANGELOG .md`
149177
150- 3 . Committing
178+ 3 . Committing:
151179
152- $ git commit - am " Bump version to v..."
180+ ```sh
181+ git commit - am " Bump version to v..."
182+ ```
153183
154- 4 . Running:
184+ 4 . Running:
155185
156- $ make publish
186+ ```sh
187+ make publish
188+ ```
0 commit comments