Coverage for pass_import/managers/dashlane.py: 100%

28 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-02-26 12:11 +0000

1# -*- encoding: utf-8 -*- 

2# pass import - Passwords importer swiss army knife 

3# Copyright (C) 2017-2024 Alexandre PUJOL <alexandre@pujol.io>. 

4# 

5 

6import json 

7 

8from pass_import.core import register_managers 

9from pass_import.formats.csv import CSV 

10from pass_import.formats.json import JSON 

11 

12 

13class DashlaneCSV(CSV): 

14 """Importer for Dashlane in CSV format.""" 

15 name = 'dashlane' 

16 url = 'https://www.dashlane.com' 

17 hexport = 'File > Export > Unsecured Archive in CSV' 

18 himport = 'pass import dashlane file.csv' 

19 fieldnames = ['title', 'url', 'login', 'password', 'comments'] 

20 keys = { 

21 'title': 'title', 

22 'password': 'password', 

23 'login': 'login', 

24 'url': 'url', 

25 'comments': 'comments' 

26 } 

27 

28 

29class DashlaneJSON(JSON): 

30 """Importer for Dashlane in JSON format.""" 

31 name = 'dashlane' 

32 default = False 

33 url = 'https://www.dashlane.com' 

34 hexport = 'File > Export > Unsecured Archive in JSON' 

35 himport = 'pass import dashlane file.json' 

36 keys = { 

37 'title': 'title', 

38 'password': 'password', 

39 'email': 'email', 

40 'login': 'login', 

41 'url': 'domain', 

42 'comments': 'note', 

43 } 

44 json_header = { 

45 'AUTHENTIFIANT': list, 

46 'EMAIL': list 

47 } 

48 

49 def parse(self): 

50 """Parse Dashlane JSON file.""" 

51 jsons = json.loads(self.file.read()) 

52 keys = self.invkeys() 

53 for item in jsons.get('AUTHENTIFIANT', {}): 

54 entry = {} 

55 for key, value in item.items(): 

56 entry[keys.get(key, key)] = value 

57 

58 self.data.append(entry) 

59 

60 

61register_managers(DashlaneCSV, DashlaneJSON)