Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

A library of classes for HAR data using pyserde.

The library is focused on providing a F-Algebra for HAR data and associated morphisms but also contains canonical types for basic usages.

F-Algebra classes

There is one generic-ish class for every HAR type and are affixed with F. All nested HAR types have been replaced with type parameters. Some types have no nested HAR types and so have no generic parameters but are included for completeness.

There is one edge case for post data. Since some of the parameters defined in the spec are mutually exclusive there are two classes for post data. PostDataParamF for ParamF based post data, and PostDataTextF for text based post data. There is a union type PostDataF combining the two for type hints but it cannot be constructed.

All of these types are Functory, by providing a nmap function that takes a function for each of the generic parameters. For example, see the ResponseF class below.

class ResponseF(Generic[A, B, C]):
   ...
   statusText: str
   httpVersion: str
   cookies: List[A]
   headers: List[B]
   content: C
   ...

   def nmap(
       self: "ResponseF[A, B, C]",
       f: Func[A, W],
       g: Func[B, X],
       h: Func[C, Y],
   ) -> "ResponseF[W, X, Y]":
       return replace(
           self,  # type: ignore[arg-type]
           cookies=list(map(f, self.cookies)),
           headers=list(map(g, self.headers)),
           content=h(self.content),
       )

Morphisms

Currently there are just 2 helper morphisms. harf_cata is a general catamorphsim, and harf which helps you build an algebra for harf_cata by taking explicit functions for each HAR type.

For example, if you wanted to count the number of times the string "key" is in headers you could do the following

harf(
    default=0,
    header=lambda h: h.count("key"),
    request=lambda r: sum(r.headers),
    response=lambda r: sum(r.headers),
    entry=lambda e: e.request + e.response,
    log=lambda l: sum(l.entries),
)(har_data)

Canonical/Basic types

For simple usages there are also type aliases for the canonical HAR structure. I.E. Response = ResponseF[Cookie, Header, Content]

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

harf-serde-1.2a2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

harf_serde-1.2a2-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file harf-serde-1.2a2.tar.gz.

File metadata

  • Download URL: harf-serde-1.2a2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.11

File hashes

Hashes for harf-serde-1.2a2.tar.gz
Algorithm Hash digest
SHA256 26cecafdf3ec8cdda3bf71d92cf77995cb5464edecf22a0282255ff02da5b513
MD5 c7f63d7d00cd3dff63b7dad442d3d0c9
BLAKE2b-256 d1458895a2c8260af132f7114716218105fa7daee471108a79687f58307aac5e

See more details on using hashes here.

File details

Details for the file harf_serde-1.2a2-py3-none-any.whl.

File metadata

  • Download URL: harf_serde-1.2a2-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.11

File hashes

Hashes for harf_serde-1.2a2-py3-none-any.whl
Algorithm Hash digest
SHA256 363d8d3886f266d55fb9b66edbb13982c3cf3d1aa7d60be8c0c9ff9fd64f175f
MD5 776989b0009986dffd81a3852558bec6
BLAKE2b-256 ea169f1460d396eca7953feb408ecbb2d73b4ff11d502af187fe5eaebb5f2e33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page