Coverage for pass_import/managers/nordpass.py: 100%
16 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-02-26 12:11 +0000
« 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) 2022 Shashwat Pragya <shashwat183@gmail.com>.
4#
6from pass_import.formats.csv import CSV
7from pass_import.core import register_managers
10class NordPassCSV(CSV):
11 """Importer for Nord Pass in CSV format."""
12 name = 'nordpass'
13 url = 'https://nordpass.com/'
14 hexport = 'Settings > Export Items'
15 himport = 'pass import nordpass file.csv'
16 keys = {
17 'title': 'name',
18 'password': 'password',
19 'login': 'username',
20 'url': 'url',
21 'comments': 'note',
22 'group': 'folder'
23 }
25 def parse(self):
26 """Parse NordPass CSV file."""
27 super().parse()
28 # NordPass exports individual folders as their own
29 # empty rows. This code removes the extra folder entries
30 # from the parsed data.
31 groups = []
32 for entry in self.data:
33 if entry['group']:
34 groups.append(entry['group'])
36 self.data = list(filter(
37 lambda x: not (x['title'] in groups and not x['group']),
38 self.data))
41register_managers(NordPassCSV)