Skip to content

Commit

Permalink
Merge branch 'hotfix-1.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Milind220 committed Apr 21, 2022
2 parents 7eaa463 + 6f8bd58 commit 0e289df
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ozon3
version = 1.7.0
version = 1.7.1
author = Milind Sharma
author_email = [email protected]
description = A package to get air quality data using the WAQI API
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
description="A package to get air quality data using the WAQI API",
license="GPLv3+",
url="https://github.com/Milind220/Ozone",
version="1.7.0",
download_url="https://github.com/Milind220/Ozone/archive/refs/tags/v1.7.0.tar.gz",
version="1.7.1",
download_url="https://github.com/Milind220/Ozone/archive/refs/tags/v1.7.1.tar.gz",
packages=setuptools.find_packages(),
install_requires=[
"numpy; python_version>='3'",
Expand Down
1 change: 1 addition & 0 deletions src/ozone/historical/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._reverse_engineered import get_data_from_id
14 changes: 8 additions & 6 deletions src/ozone/historical/_reverse_engineered.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import json
from pathlib import Path
from datetime import datetime
from typing import List, Dict, Any
from typing import Any, Dict, List

import js2py
import pandas
import requests
from sseclient import SSEClient

from .relevant_funcs import JS_FUNCS

# NOTE(lahdjirayhan):
# The following variable is a long string, a source JS code that
# The JS_FUNCS variable is a long string, a source JS code that
# is excerpted from one of aqicn.org frontend's scripts.
# See relevant_funcs.js for more information.
_JS_FUNCS = Path(__file__).parent.joinpath("relevant_funcs.js").read_text()
# See relevant_funcs.py for more information.


# Make js context where js code can be executed
_context = js2py.EvalJs()
_context.execute(_JS_FUNCS)
_context.execute(JS_FUNCS)


def get_results_from_backend(city_id: int) -> List[Dict[str, Any]]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/** NOTE(lahdjirayhan):
This long string is excerpted from one of aqicn.org frontend's scripts.
It contains minimal number of relevant functions required to decipher backend-sent data.
A small number of variable names have been manually de-obfuscated.
Several comments has been made during de-obfuscation process to reduce mental workload.
-----
The last function i.e. gatekeep_convert_date_object_to_unix_seconds
is manually written. It's a wrapper that needs to be there to make it
possible to get out Date information out from JavaScript context
into Python context. See the function below for more information.
*/
# NOTE(lahdjirayhan):
# This long string is excerpted from one of aqicn.org frontend's scripts.
# It contains minimal number of relevant functions required to decipher backend-sent data.
# A small number of variable names have been manually de-obfuscated.
# Several comments has been made during de-obfuscation process to reduce mental workload.
# -----
# The last function i.e. gatekeep_convert_date_object_to_unix_seconds
# is manually written. It's a wrapper that needs to be there to make it
# possible to get out Date information out from JavaScript context
# into Python context. See the function below for more information.

JS_FUNCS: str = """
function checkValidDigitNumber(t) {
return !isNaN(t) && parseInt(Number(t)) == t && !isNaN(parseInt(t, 10))
}
Expand Down Expand Up @@ -166,4 +166,5 @@
RES.species[i].values = values
}
return RES
}
}
"""
16 changes: 9 additions & 7 deletions src/ozone/ozone.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
1 second.
"""

import pandas
import numpy
import requests
import json
import itertools
from pathlib import Path
import json
import warnings
from pathlib import Path
from typing import Any, Dict, List, Tuple, Union

import numpy
import pandas
import requests
from ratelimit import limits, sleep_and_retry
from typing import Any, Dict, List, Union, Tuple
from .urls import URLs

from .historical._reverse_engineered import get_data_from_id
from .urls import URLs

# 1000 calls per second is the limit allowed by API
CALLS: int = 1000
Expand Down

0 comments on commit 0e289df

Please sign in to comment.