Skip to content

Commit

Permalink
refactor: Redefine staticmethod as module method #2
Browse files Browse the repository at this point in the history
Change scoping of _generate_field_dict to module level
declaration
rather than @staticmethod tag. Follow project coding style.
  • Loading branch information
ImplyingICheck committed May 16, 2023
1 parent 5714cb3 commit c6fcc90
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ankicard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def _generate_field_names(field_names, n_fields):
return field_names


def _generate_field_dict(field_names, fields):
field_dict = {}
for idx in range(len(field_names)):
field_dict[field_names[idx]] = fields[idx]
return field_dict

class AnkiCard:
"""
Anki Card fields as denoted by Anki documentation
Expand All @@ -26,21 +32,14 @@ def __init__(self, fields, has_html=False, tags_idx=None, field_names=None,
self.has_html = has_html
self.tags_field_idx = tags_idx
self.field_names = _generate_field_names(field_names, len(fields))
self.fields = self.__generate_field_dict(self.field_names, fields)
self.fields = _generate_field_dict(self.field_names, fields)
self.note_type_field = note_type_idx
self.deck_field_idx = deck_idx
self.guid_field_idx = guid_idx

def __repr__(self):
return str(self.fields)

@staticmethod
def __generate_field_dict(field_names, fields):
field_dict = {}
for idx in range(len(field_names)):
field_dict[field_names[idx]] = fields[idx]
return field_dict

def get_field(self, field_name):
return self.fields[field_name]

Expand Down

0 comments on commit c6fcc90

Please sign in to comment.