File: loop.py

package info (click to toggle)
kopanocore 8.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,400 kB
  • sloc: cpp: 175,422; python: 24,623; perl: 7,319; php: 6,056; sh: 2,172; makefile: 1,294; xml: 45; ansic: 1
file content (40 lines) | stat: -rwxr-xr-x 1,201 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python3
# SPDX-License-Identifier: AGPL-3.0-only

# basic looping examples (users, items, properties, folders, attachments, companies..)

# usage: ./loop.py (change USER to username)

import kopano

USER = 'user1'

server = kopano.Server()

for prop in server.admin_store.props():
    print(prop.idname if not prop.named else prop.name, hex(prop.proptag), repr(prop.value))

for company in server.companies():
	print('company:', company.name)

for user in server.users():
	print('local user:', user.name)

print(server.guid, [user.store.guid for user in server.users()])

for user in server.users():
    if user.name == USER:
        print([folder.name for folder in user.store.folders()])

for user in server.users():
    if user.name == USER:
        print(list(user.store.props()))
        for folder in user.store.folders():
            if folder.name == 'Sent Items':
                for item in folder:
                    print('item:', item.subject, list(item.props()), [(att.filename, att.mimetype, len(att.data)) for att in item.attachments()])

for user in server.users():
    for folder in user.store.folders():
        for item in folder:
            print(user, folder, item)