Skip to content

Commit

Permalink
refactor: tidy codes
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Apr 12, 2024
1 parent 8fb0ce6 commit 8af7ccb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions plugin/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import sublime

assert __package__

PACKAGE_NAME = __package__.partition(".")[0]

DB_FILE_IN_PACKAGE = f"Packages/{PACKAGE_NAME}/data/emoji-test.txt"
Expand Down
11 changes: 6 additions & 5 deletions plugin/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def from_dict(cls, db: dict[str, Any]) -> EmojiDatabase:
def from_lines(cls, lines: Iterable[str]) -> EmojiDatabase:
collection = cls()
for line in lines:
if e := Emoji.from_line(line):
collection.emojis.append(e)
if emoji := Emoji.from_line(line):
collection.emojis.append(emoji)
continue
if m := cls._re_version.fullmatch(line):
collection.version = m.group("version").strip()
Expand All @@ -179,11 +179,12 @@ def from_lines(cls, lines: Iterable[str]) -> EmojiDatabase:
continue
return collection

def to_json(self, *, pretty: bool = False) -> str:
def to_json(self, *, pretty: bool = False, **kwargs: Any) -> str:
kwargs = kwargs.copy()
if pretty:
kwargs: dict[str, Any] = {"indent": "\t"}
kwargs["indent"] = "\t"
else:
kwargs = {"separators": (",", ":")}
kwargs["separators"] = (",", ":")
return json.dumps(
dict(asdict(self), generator_revision=DB_GENERATOR_REVISION),
ensure_ascii=False,
Expand Down

0 comments on commit 8af7ccb

Please sign in to comment.