6 from configparser import ConfigParser
8 config = ConfigParser()
9 config.read('.taguette_gdocs')
11 ## this is project ID from the configuration
12 project_id = int(config['General']['taguette_project_id'])
13 taguette_database_file = config['General']['taguette_database_file']
17 con = sqlite3.connect(taguette_database_file)
20 # Run this if you just want tags and no highlights
21 sql_stmt_get = "SELECT id, path, description FROM tags WHERE project_id = ?"
23 # Run this if you want tags AND highlights
24 #sql_stmt_get = "SELECT tags.id, tags.path, tags.description, highlights.snippet FROM highlight_tags INNER JOIN tags ON highlight_tags.tag_id = tags.id INNER JOIN highlights ON highlight_tags.highlight_id = highlights.id WHERE project_id = ?"
25 cur.execute(sql_stmt_get, (project_id,))
28 print("\t".join(['id', 'axial codes', 'tags', 'category', 'description']))
35 tag_id, path, description = row
37 tag_match = re.match(r'^(.+)\_(.*)$', path)
39 axial = tag_match.group(1)
40 tag = tag_match.group(2)
45 # look for extra category information stored in the description
46 cat_match = re.match('^(.*)\s*(\{(.*)\})$', description)
48 description = cat_match.group(1)
49 category = json.loads(cat_match.group(2))["category"]
53 print("\t".join([str(tag_id), axial, tag, category, description]))