semvec/pypi-packages huggingface dataset:
instacart-log-generator 0.1.6
Generate fake log based on instacart dataset
License: MIT
Requires Python: >=3.8

# Instacart Log Generator

## install

`pip install instacart-log-generator`

## Code

```python
from instacart_log_generator.my_gen_log import InstacartLogGenerator

LOGGING_FILE_PATH = 'file_path_where_you_want.log'
LOG_PER_SECOND = 1

InstacartLogGenerator().logging(LOGGING_FILE_PATH, LOG_PER_SECOND)
```

## Result

```shell
162.232.228.1 - - [17/Jan/2022:17:11:16 +0900] "POST /order HTTP/1.1" 400 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) GSA/7.0.55539 Mobile/12H143 Safari/600.1.4"
162.232.228.1 - - [17/Jan/2022:17:11:16 +0900] {"order_id": 3375775, "product_id": 21903, "add_to_cart_order": 2, "reordered": 1, "aisle_id": 123, "department_id": 4, "order_number": 4, "order_dow": 4, "order_hour_of_day": 11, "days_since_prior_order": 17}
51.117.186.246 - - [17/Jan/2022:17:11:17 +0900] "GET /order HTTP/1.1" 200 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36"
```

## What's New

### Jan 19, 2022

- Add department category. It can generate more various url
- Add request_type and url to body log. It looks more real on now
- Log the body value only when the order url and response code is 200.
- Logs are generally chronological, but there are logs that are not chronological to implement log out of the same ip user.
etag-cache 0.2
Python package for caching HTTP response based on etag
License: MIT

# etag-response-cache
Etag cache implementation for HTTP requests, to save request bandwidth for a non-modified response. Returns
high-speed accessed dictionary data as cache.

## Concept
Store Etag value(as hash key:value pair) in the user's home directory `os.path.join(os.getenv("HOME"), ".pyapp")` into `etag` and successful response data into `cache` DBM files.<br>
Add `If-None-Match` header for all `GET` request.</br> 
Update `etag` and `cache` for required request url, when none 304 http status is received i.e if response is modified.</br>
Return `cache` data as dictionary for non-modified response.</br>

Sample `GET` request header with `If-None-Match`:
```
{'X-Kite-Version': '3', 'User-Agent': 'Kiteconnect-python/3.9.4', 
'If-None-Match': 'W/"i51p01GqP6TRPWsM"', 
'Authorization': 'token api_key:access_token'}
```

## Installation
```
To-do: Release it as pypi package
```

## Usage
```python
import requests
from etag_package import EtagCache


cache_object = EtagCache()
url = "https://api.kite.trade/portfolio/holdings"

payload = ""
headers = {
    'x-kite-version': "3",
    'authorization': "token api_key:access_token"
    }
# Add etag to request header
headers = cache_object.add_etag("GET", headers, url)

response = requests.request("GET", url, data=payload, headers=headers)
# Store etag from response header
cache_object.save_etag(response)
# Store response data as cache
response_dict = cache_object.add_read_cache(response)
print(response_dict)
```
## Response
```
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /portfolio/holdings HTTP/1.1" 304 0

{'tradingsymbol': 'APOLLOPIPE', 'exchange': 'NSE', 'instrument_token': 3676417, 'isin': 'INE126J01016',
 'product': 'CNC', 'price': 0, 'quantity': 3, 'used_quantity': 0, 't1_quantity': 0, 'realised_quantity': 3,
 'authorised_quantity': 0, 'authorised_date': '2021-12-28 00:00:00', 'opening_quantity': 3, 'short_quantity': 
 0, 'collateral_quantity': 0, 'collateral_type': '', 'discrepancy': False, 'average_price': 582.666667, 
 'last_price': 539.8, 'close_price': 539.65, 'pnl': -128.60000100000002, 'day_change': 0.14999999999997726, 
 'day_change_percentage': 0.027795793569902208} .....
```