MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / Record

Class Record

keepercommander/record.py:66–429  ·  view source on GitHub ↗

Defines a user-friendly Keeper Record for display purposes

Source from the content-addressed store, hash-verified

64
65
66class Record:
67 """Defines a user-friendly Keeper Record for display purposes"""
68
69 @staticmethod
70 def xstr(s):
71 return str(s or '')
72
73 def __init__(self, record_uid='', folder='', title='', login='', password='', login_url='', notes='',
74 custom_fields=None, revision=''):
75 self.record_uid = record_uid
76 self.record_type = ''
77 self.folder = Record.xstr(folder)
78 self.title = Record.xstr(title)
79 self.login = Record.xstr(login)
80 self.password = Record.xstr(password)
81 self.login_url = Record.xstr(login_url)
82 self.notes = Record.xstr(notes)
83 self.custom_fields = custom_fields or [] # type: list
84 self.attachments = None
85 self.revision = revision
86 self.unmasked_password = None
87 self.totp = None
88 self.version = 2
89 self.password_label = '' # custom label on the v3 password field (e.g. "Passphrase")
90 self.login_label = '' # custom label on the v3 login field
91 self.url_label = '' # custom label on the v3 url field
92 self.totp_label = '' # custom label on the v3 oneTimeCode field
93
94 def load(self, data, **kwargs):
95 self.version = kwargs.get('version', 2)
96 if 'title' in data:
97 self.title = Record.xstr(data['title']).strip()
98 if 'notes' in data:
99 self.notes = Record.xstr(data['notes'])
100
101 if self.version in (1, 2):
102 self.record_type = 'general'
103 if 'secret1' in data:
104 self.login = Record.xstr(data['secret1'])
105 if 'secret2' in data:
106 self.password = Record.xstr(data['secret2'])
107 if 'link' in data:
108 self.login_url = Record.xstr(data['link'])
109 if 'custom' in data:
110 self.custom_fields = data['custom'] or []
111 if 'extra' in kwargs and kwargs['extra']:
112 extra = kwargs['extra']
113 self.attachments = extra.get('files')
114 if 'fields' in extra:
115 for field in extra['fields']:
116 if field['field_type'] == 'totp':
117 self.totp = field['data']
118 elif self.version in (3, 5, 6):
119 self.record_type = data.get('type', 'login')
120 for field in itertools.chain(data['fields'], data.get('custom') or []):
121 field_label = field.get('label', '')
122 field_type = field.get('type', '')
123 field_value = field.get('value', '')

Callers 3

_v2_recordMethod · 0.90
get_recordFunction · 0.70

Calls

no outgoing calls

Tested by 2

_v2_recordMethod · 0.72