Skip to content

Commit

Permalink
Remove typing
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Jan 29, 2024
1 parent de8fac2 commit e916813
Showing 1 changed file with 2 additions and 35 deletions.
37 changes: 2 additions & 35 deletions import_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import sys
import threading
import time
import typing
import urllib.request, urllib.parse, urllib.error
import urllib.request, urllib.error, urllib.parse
import urllib.parse
Expand Down Expand Up @@ -279,38 +278,6 @@ def remove_ignored_groups(self, groups):
for group in groups:
del self.json[group]

if typing.TYPE_CHECKING:
class CaddyTLS(typing.TypedDict):
resumed: bool
version: int
cipher_suite: int
proto: str
server_name: str

class CaddyRequest(typing.TypedDict):
remote_ip: str
remote_port: int
client_ip: str
proto: str
method: str
host: str
uri: str
headers: typing.Dict[str, typing.List[str]]
tls: CaddyTLS

class CaddyLogElement(typing.TypedDict):
level: str
ts: float
logger: str
msg: str
request: CaddyRequest
bytes_read: int
user_id: str
duration: float
size: int
status: int
resp_headers: typing.Dict[str, typing.List[str]]

class CaddyJsonFormat(BaseFormat):
def __init__(self, name):
super(CaddyJsonFormat, self).__init__(name)
Expand All @@ -319,14 +286,14 @@ def __init__(self, name):

def check_format_line(self, line):
try:
self.json: "CaddyLogElement" = json.loads(line)
self.json = json.loads(line)
return "request" in self.json and "user_id" in self.json and "resp_headers" in self.json
except:
return False

def match(self, line):
try:
self.json: "CaddyLogElement" = json.loads(line)
self.json = json.loads(line)
return self
except:
self.json = None
Expand Down

0 comments on commit e916813

Please sign in to comment.