WPT Parser
Getting Started
-
Prerequisites
- Python >= 3.6.x
- pip
-
Installation
$ pip install wpt-parser -
Examples
- Using the JSON Parser
# import the class from WPTParser.Fetch import Fetch from WPTParser.JSONParser import JSONParser test_json = Fetch().json() keys = ['data.median.firstView.loadTime',] # returns a new dict with specified keys JSONParser(test_json).pick(keys=keys).exec() -
Key Types:
-
key_name
- Works like simple JSON extraction. Provide the name of the key and boom!.
- For extraction from beyond first level, append keys with a separator and provide
key_delimiterfor the program to recognize the start of next level. - Example:
""" { keylevel11: { keylevel21: value, keylevel22: { keylevel31: value } } } """ # key to extract first level # keylevel11 # returns {keylevel21: ...} # key to extract second level, first key # keylevel11.keylevel21 # returns value -
[list_index]
- When you have a list as value and you want to extract a specific index value/object.
- For extraction from beyond first level, append keys with a separator and provide
key_delimiterfor the program to recognize the start of next level. - Example:
""" { keylevel11: { keylevel21: [ 1, 2, 3 ], keylevel22: { keylevel31: value } } } """ # key to extract second level, third index # keylevel11.keylevel21.[2] # returns 3 -
[{key=value}]
- When you have a unordered list of object and you want extract a specific object from the list based on the key and value inside the object
- For extraction from beyond first level, append keys with a separator and provide
key_delimiterfor the program to recognize the start of next level. - Example:
""" { keylevel11: { keylevel21: [ 1, 2, 3 ], keylevel22: { keylevel31: value }, keylevel23: [ { name: Awesome, }, { name: Package } ] } } """ # key to extract second level, and from that extarct the object with name = Awesome # keylevel11.keylevel23.[{name=Awesome}] # return {name: Awesome} -
[{key~regex}]
- When you have a unordered list of object and you want extract a specific object from the list based on the key and a regex of value inside the object
- For extraction from beyond first level, append keys with a separator and provide
key_delimiterfor the program to recognize the start of next level. - The regex search is case sensitive. You do not need to add
//orr''to write your regex. - The search will find all the matches and return a list
- Example:
""" { keylevel11: { keylevel21: [ 1, 2, 3 ], keylevel22: { keylevel31: value }, keylevel23: [ { name: Awesome123, }, { name: Package } ] } } """ # key to extract second level, and from that extarct the object with name matching Awesome # keylevel11.keylevel23.[{name~Awesome}] # return [{name: Awesome}]
-
Available Methods
- JSONParser
| Method | Params | type | default | Description |
|---|---|---|---|---|
| pick | key | str | None | selects a key to be returned |
| pick | keys | list | [] | selects a list key to be returned |
| pick | key_delimiter | str | "." | Separator used to identify multi level JSON |
| pick | key_mapping | dict | {} | Mapping of keys for picking with custom key name. |
- Fetch
| Method | Params | type | default | Description |
|---|---|---|---|---|
| json | test_id | str | None | test_id for a wpt or a speed curve test |
| json | WPT_URI | str | 'https://webpagetest.org' | URI for your WPT instance |
Note:
- The package is under development and will be prone to more frequent updates
Metadata
Release files for wpt-parser 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wpt-parser-0.0.6.tar.gz | 5.3 kB | Without provenance | Details for wpt-parser-0.0.6.tar.gz |
Release files / wpt-parser-0.0.6.tar.gz
| Download URL | wpt-parser-0.0.6.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1fbfc310a122f9f3e5a36433cd2ccfe7f4137ee894a61b3ae69c5e0d8c5dac2c
|
|
BLAKE2b-256 checksum How to use checksums |
421aa4b3b23945651dc57d4e0c5168796b60fa3890e36e78187d16fa45c15ba0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6
|
Security for wpt-parser 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.