Skip to content

Commit

Permalink
Fix: trim and lost long litterals in documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Aug 31, 2024
1 parent 1df7d7e commit 94c155e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bddrest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .exceptions import InvalidUrlParametersError, CallVerifyError


__version__ = '6.1.0'
__version__ = '6.1.1'
3 changes: 2 additions & 1 deletion bddrest/documentary/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json

from ..helpers import querystring_encode
from .helpers import loststr


class CURL:
Expand Down Expand Up @@ -120,7 +121,7 @@ def from_call(cls, call):
verb=call.verb,
content_type=call.content_type,
authorization=call.authorization,
headers=[f'{k}: {v}' for k, v in call.headers or []],
headers=[f'{k}: {loststr(v)}' for k, v in call.headers or []],
multipart=call.multipart,
json=call.json,
)
Expand Down
3 changes: 2 additions & 1 deletion bddrest/documentary/documenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .curl import CURL
from .formatters import create as createformatter
from .helpers import loststr


class Documenter:
Expand Down Expand Up @@ -138,7 +139,7 @@ def write_call(self, basecall, call, formatter):
if call.headers \
and (basecall is None or call.headers != basecall.headers):
formatter.write_header('Request Headers', 3)
formatter.write_list(f'{k}: {v}' for k, v in call.headers)
formatter.write_list(f'{k}: {loststr(v)}' for k, v in call.headers)

self.write_curl(formatter, CURL.from_call(call))

Expand Down
8 changes: 8 additions & 0 deletions bddrest/documentary/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MAX_LITERAL_LEN = 40


def loststr(s, maxlen=MAX_LITERAL_LEN):
if len(s) > maxlen:
return f'{s[:maxlen // 3]}...{s[-(maxlen // 3):]}'

return s

0 comments on commit 94c155e

Please sign in to comment.