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

20 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 

10 

11 

12class Passpack(CSV): 

13 """Importer for Passpack in CSV format.""" 

14 name = 'passpack' 

15 url = 'https://www.passpack.com' 

16 hexport = 'Settings > Export > Save to CSV' 

17 keys = { 

18 'title': 'Entry Name', 

19 'password': 'Password', 

20 'login': 'User ID', 

21 'url': 'URL', 

22 'email': 'Email', 

23 'comments': 'Notes', 

24 'group': 'Tags' 

25 } 

26 

27 def parse(self): 

28 """Parse Passpack CSV file.""" 

29 super().parse() 

30 for entry in self.data: 

31 groups = json.loads(entry.pop('group', '')).get('tags', []) 

32 for item in groups: 

33 field = json.loads(item) 

34 entry['group'] = field.get('tag', '') 

35 

36 extra = json.loads(entry.pop('Extra Fields', 

37 '')).get('extraFields', []) 

38 for item in extra: 

39 field = json.loads(item) 

40 entry[field.get('name', '')] = field.get('data', '') 

41 

42 

43register_managers(Passpack)