Coverage for pass_import/managers/zoho.py: 100%
39 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) 2017-2024 Alexandre PUJOL <alexandre@pujol.io>.
4#
6import os
8from pass_import.core import register_managers
9from pass_import.formats.csv import CSV
12class ZohoCSV(CSV):
13 """Importer for Zoho in CSV format."""
14 name = 'zoho'
15 url = 'https://www.zoho.com/vault'
16 hexport = 'Tools > Export Secrets: Zoho Vault Format CSV'
17 himport = 'pass import zoho file.csv'
18 only = True
19 encoding = 'utf-8-sig'
20 keys = {
21 'title': 'Secret Name',
22 'url': 'Secret URL',
23 'comments': 'Notes'
24 }
26 def parse(self):
27 """Parse Zoho CSV file."""
28 super().parse()
29 for entry in self.data:
30 secret = entry.pop(None, ['', ''])
31 entry['login'] = secret[0]
32 entry['password'] = secret[1]
35class ZohoCSVVault(CSV):
36 """Importer for Zoho Vault in CSV format."""
37 name = 'zoho'
38 default = False
39 url = 'https://www.zoho.com/vault'
40 hexport = 'Tools > Export Secrets: Zoho Vault Format CSV'
41 himport = 'pass import zoho file.csv'
42 encoding = 'utf-8-sig'
43 keys = {
44 'title': 'Secret Name',
45 'description': 'Description',
46 'url': 'Secret URL',
47 'comments': 'Notes',
48 'group': 'ChamberName',
49 'tags': 'Tags',
50 '_data': 'SecretData',
51 '_custom': 'CustomData',
52 }
54 def parse(self):
55 """Parse Zoho CSV Vault file."""
56 super().parse()
57 keys = {
58 'SecretType': 'type',
59 'Password': 'password',
60 'User Name': 'login'
61 }
62 for entry in self.data:
63 entry.pop(None, None)
64 entry['group'] = entry.get('group', '').replace('\n', os.sep)
66 items = []
67 items.extend(entry.pop('_data', '\n').split('\n'))
68 items.extend(entry.pop('_custom', '\n').split('\n'))
69 for item in items:
70 if ':' in item:
71 key, value = item.split(':', 1)
72 entry[keys.get(key, key)] = value
75register_managers(ZohoCSV, ZohoCSVVault)