summaryrefslogtreecommitdiffstats
path: root/examplescript.py
blob: 290d3a50ec379fe6917ed3c5cdcb04505e05fbfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# This is an example script that can be used as
# pwman -p examplescript.py
# pwman --call-pymod examplescript.py
# See pwman --help for more information.
#

def run(db):
	# Print all category names.
	categories = db.getCategoryNames()
	print("Categories:", categories)

	# Print all titles in a category.
	titles = db.getEntryTitles("testcat1")
	print("Titles in testcat1:", titles)

	# Move all titles from a category to another one and change the title.
	for title in titles:
		entry = db.getEntry("testcat1", title)
		print("Moving entry:", entry)
		db.moveEntry(entry, "othercat", "foobar_" + title)

	# Permanently write the changes to the database file.
	db.commit()
bues.ch cgit interface