├── VERSION ├── etc ├── demo │ ├── tags │ │ └── .deleteme │ ├── events │ │ ├── 2009-07-29 - no tags │ │ │ └── emptydir │ │ ├── 2008-12-25 - holiday india │ │ │ ├── .tag │ │ │ └── cimg1029.jpg │ │ └── 2008-03-29 - holiday south korea │ │ │ ├── .tag │ │ │ └── 00_IMG008.jpg │ └── README ├── test │ └── events │ │ ├── 2009-07-29 - no tags │ │ └── emptydir │ │ ├── .tagfs │ │ └── tagfs.conf │ │ ├── 2008-11-11 - airport underground railway │ │ ├── .tag │ │ └── airport.jpg │ │ ├── 2008-12-25 - holiday india │ │ ├── .tag │ │ └── cimg1029.jpg │ │ └── 2008-03-29 - holiday south korea │ │ ├── .tag │ │ └── 00_IMG008.jpg └── rdf │ └── example-rdf.xml ├── .gitignore ├── src ├── modules │ └── tagfs │ │ ├── __init__.py │ │ ├── sysIO.py │ │ ├── node_file.py │ │ ├── node_filter_value.py │ │ ├── node_root.py │ │ ├── node_untagged_items.py │ │ ├── log.py │ │ ├── log_config.py │ │ ├── node_export.py │ │ ├── node.py │ │ ├── config.py │ │ ├── node_export_chart.py │ │ ├── node_export_csv.py │ │ ├── transient_dict.py │ │ ├── node_filter_any_context.py │ │ ├── cache.py │ │ ├── node_filter.py │ │ ├── freebase_support.py │ │ ├── node_filter_context.py │ │ ├── view.py │ │ ├── main.py │ │ └── item_access.py ├── test │ ├── tagfs_test │ │ ├── __init__.py │ │ ├── item_access_mock.py │ │ ├── item_mock.py │ │ └── node_asserter.py │ └── tagfs_test_small │ │ ├── __init__.py │ │ ├── test_freebase_support_query.py │ │ ├── systemMocks.py │ │ ├── test_item_access_tag.py │ │ ├── test_freebase_support_queryFileParser.py │ │ ├── test_transient_dict.py │ │ ├── test_filter_context_value_list_directory_node.py │ │ ├── test_freebase_support_genericQueryFactory.py │ │ ├── test_item_access_parseTagsFromFile.py │ │ ├── test_untagged_items_directory_node.py │ │ ├── test_item_access_item.py │ │ ├── test_root_directory_node.py │ │ └── test_filter_context_value_filter_directory_node.py └── bin │ └── tagfs ├── test └── e2e │ ├── .gitignore │ ├── emptyExport │ ├── items │ │ ├── empty_dir │ │ └── .tagfs │ │ │ └── tagfs.conf │ ├── export.csv │ └── assert │ ├── contextValueFilter │ ├── items │ │ ├── car │ │ │ └── .tag │ │ ├── banana │ │ │ └── .tag │ │ ├── carrot │ │ │ └── .tag │ │ └── .tagfs │ │ │ └── tagfs.conf │ └── assert │ ├── umlauteItems │ ├── items │ │ ├── äöü │ │ │ └── .tag │ │ ├── aou │ │ │ └── .tag │ │ └── .tagfs │ │ │ └── tagfs.conf │ └── assert │ ├── untaggedItems │ ├── items │ │ ├── dir without tags │ │ │ └── empty_dir │ │ └── .tagfs │ │ │ └── tagfs.conf │ └── assert │ ├── anyContextValueFilter │ ├── items │ │ ├── banana │ │ │ └── .tag │ │ ├── carrot │ │ │ └── .tag │ │ └── .tagfs │ │ │ └── tagfs.conf │ └── assert │ └── contextValueRecursion_i7 │ ├── items │ ├── Ted │ │ └── .tag │ ├── banana │ │ └── .tag │ └── .tagfs │ │ └── tagfs.conf │ └── assert ├── AUTHORS ├── .project ├── .pydevproject ├── backlog ├── bin ├── runEndToEndTest.sh └── e2eAssertSandbox.sh ├── reports ├── 2011-05-31_19_05_56 │ ├── coverage.txt │ └── tests.txt ├── 2011-06-06_05_28_41 │ ├── coverage.txt │ └── tests.txt ├── 2011-02-07_08_53_03 │ └── coverage.txt └── 2011-02-07_10_10_40 │ ├── coverage.txt │ └── tests.txt ├── Makefile ├── README.dev ├── util └── trace_logfiles.py ├── README ├── setup.py └── COPYING /VERSION: -------------------------------------------------------------------------------- 1 | 0.1 2 | -------------------------------------------------------------------------------- /etc/demo/tags/.deleteme: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | build 3 | -------------------------------------------------------------------------------- /src/modules/tagfs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/test/tagfs_test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/e2e/.gitignore: -------------------------------------------------------------------------------- 1 | assert.log 2 | -------------------------------------------------------------------------------- /test/e2e/emptyExport/items/empty_dir: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/e2e/contextValueFilter/items/car/.tag: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/e2e/emptyExport/export.csv: -------------------------------------------------------------------------------- 1 | "name" 2 | -------------------------------------------------------------------------------- /etc/demo/events/2009-07-29 - no tags/emptydir: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /etc/test/events/2009-07-29 - no tags/emptydir: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/e2e/umlauteItems/items/äöü/.tag: -------------------------------------------------------------------------------- 1 | umlaut 2 | -------------------------------------------------------------------------------- /test/e2e/umlauteItems/items/aou/.tag: -------------------------------------------------------------------------------- 1 | noumlaut 2 | -------------------------------------------------------------------------------- /test/e2e/untaggedItems/items/dir without tags/empty_dir: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/e2e/anyContextValueFilter/items/banana/.tag: -------------------------------------------------------------------------------- 1 | category: fruit 2 | -------------------------------------------------------------------------------- /test/e2e/contextValueFilter/items/banana/.tag: -------------------------------------------------------------------------------- 1 | category: fruit 2 | -------------------------------------------------------------------------------- /test/e2e/anyContextValueFilter/items/carrot/.tag: -------------------------------------------------------------------------------- 1 | category: vegetable 2 | -------------------------------------------------------------------------------- /test/e2e/contextValueFilter/items/carrot/.tag: -------------------------------------------------------------------------------- 1 | category: vegetable 2 | -------------------------------------------------------------------------------- /test/e2e/contextValueRecursion_i7/items/Ted/.tag: -------------------------------------------------------------------------------- 1 | movie 2 | genre: comedy 3 | -------------------------------------------------------------------------------- /test/e2e/contextValueRecursion_i7/items/banana/.tag: -------------------------------------------------------------------------------- 1 | fruit 2 | genre: delicious 3 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Markus Peröbner 2 | Peter Prohaska 3 | -------------------------------------------------------------------------------- /etc/demo/events/2008-12-25 - holiday india/.tag: -------------------------------------------------------------------------------- 1 | holiday 2 | airport 3 | location: india 4 | -------------------------------------------------------------------------------- /etc/demo/events/2008-03-29 - holiday south korea/.tag: -------------------------------------------------------------------------------- 1 | holiday 2 | airport 3 | location: korea 4 | -------------------------------------------------------------------------------- /etc/test/events/.tagfs/tagfs.conf: -------------------------------------------------------------------------------- 1 | 2 | [global] 3 | 4 | enableValueFilters = true 5 | enableRootItemLinks = true 6 | -------------------------------------------------------------------------------- /test/e2e/emptyExport/assert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | assertEqualContent "$TEST_MOUNT_DIR/.export/export.csv" "export.csv" 4 | -------------------------------------------------------------------------------- /etc/test/events/2008-11-11 - airport underground railway/.tag: -------------------------------------------------------------------------------- 1 | airport 2 | creator: Tama Yuri 3 | source: flickr 4 | object: tube 5 | -------------------------------------------------------------------------------- /etc/test/events/2008-12-25 - holiday india/.tag: -------------------------------------------------------------------------------- 1 | holiday 2 | airport 3 | 4 | india 5 | creator: Markus Pielmeier 6 | empty test: 7 | -------------------------------------------------------------------------------- /etc/test/events/2008-03-29 - holiday south korea/.tag: -------------------------------------------------------------------------------- 1 | holiday 2 | airport 3 | korea 4 | creator: Markus Pielmeier 5 | object: tube 6 | -------------------------------------------------------------------------------- /test/e2e/emptyExport/items/.tagfs/tagfs.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | tagFileName = .tag 3 | enableValueFilters = false 4 | enableRootItemLinks = false 5 | -------------------------------------------------------------------------------- /test/e2e/umlauteItems/items/.tagfs/tagfs.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | tagFileName = .tag 3 | enableValueFilters = false 4 | enableRootItemLinks = false 5 | -------------------------------------------------------------------------------- /test/e2e/untaggedItems/items/.tagfs/tagfs.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | tagFileName = .tag 3 | enableValueFilters = false 4 | enableRootItemLinks = false 5 | -------------------------------------------------------------------------------- /test/e2e/anyContextValueFilter/items/.tagfs/tagfs.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | tagFileName = .tag 3 | enableValueFilters = false 4 | enableRootItemLinks = false 5 | -------------------------------------------------------------------------------- /test/e2e/contextValueFilter/items/.tagfs/tagfs.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | tagFileName = .tag 3 | enableValueFilters = false 4 | enableRootItemLinks = false 5 | -------------------------------------------------------------------------------- /etc/demo/events/2008-12-25 - holiday india/cimg1029.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marook/tagfs/HEAD/etc/demo/events/2008-12-25 - holiday india/cimg1029.jpg -------------------------------------------------------------------------------- /etc/test/events/2008-12-25 - holiday india/cimg1029.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marook/tagfs/HEAD/etc/test/events/2008-12-25 - holiday india/cimg1029.jpg -------------------------------------------------------------------------------- /test/e2e/contextValueRecursion_i7/items/.tagfs/tagfs.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | tagFileName = .tag 3 | enableValueFilters = false 4 | enableRootItemLinks = false 5 | -------------------------------------------------------------------------------- /etc/demo/events/2008-03-29 - holiday south korea/00_IMG008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marook/tagfs/HEAD/etc/demo/events/2008-03-29 - holiday south korea/00_IMG008.jpg -------------------------------------------------------------------------------- /etc/test/events/2008-03-29 - holiday south korea/00_IMG008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marook/tagfs/HEAD/etc/test/events/2008-03-29 - holiday south korea/00_IMG008.jpg -------------------------------------------------------------------------------- /etc/test/events/2008-11-11 - airport underground railway/airport.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marook/tagfs/HEAD/etc/test/events/2008-11-11 - airport underground railway/airport.jpg -------------------------------------------------------------------------------- /test/e2e/anyContextValueFilter/assert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | assertLink "$TEST_MOUNT_DIR/.any_context/fruit/banana" 4 | 5 | assertLink "$TEST_MOUNT_DIR/.any_context/vegetable/carrot" 6 | -------------------------------------------------------------------------------- /test/e2e/umlauteItems/assert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | assertDir "$TEST_MOUNT_DIR/.any_context/umlaut" 4 | assertDir "$TEST_MOUNT_DIR/.any_context/umlaut/äöü" 5 | 6 | ls "$TEST_MOUNT_DIR/.any_context/umlaut" 7 | -------------------------------------------------------------------------------- /test/e2e/untaggedItems/assert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This makes sure that items without .tag file are linked within 4 | # untagged items. 5 | # 6 | 7 | assertLink "$TEST_MOUNT_DIR/.untagged/dir without tags" 8 | -------------------------------------------------------------------------------- /test/e2e/contextValueFilter/assert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | assertLink "$TEST_MOUNT_DIR/category/fruit/banana" 4 | 5 | assertLink "$TEST_MOUNT_DIR/category/vegetable/carrot" 6 | 7 | assertLink "$TEST_MOUNT_DIR/category/.unset/car" 8 | -------------------------------------------------------------------------------- /test/e2e/contextValueRecursion_i7/assert: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This test makes sure that recursions without extra information are not 4 | # visible. See issue https://github.com/marook/tagfs/issues/7 5 | assertNotExists "$TEST_MOUNT_DIR/genre/comedy/genre" 6 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | tagfs 4 | 5 | 6 | 7 | 8 | 9 | org.python.pydev.PyDevBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.python.pydev.pythonNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.pydevproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /tagfs/src 7 | /tagfs/test 8 | 9 | python 2.5 10 | Default 11 | 12 | -------------------------------------------------------------------------------- /backlog: -------------------------------------------------------------------------------- 1 | * umlaute in taggings are not handled correctly :bug: 2 | currently tagfs kicks umlaute from tag directory names. but removing umlaute 3 | is only done when listing directories. 4 | 5 | this also applies for anything which is not ascii. 6 | * modifications in .tag files should be applied live :feature: 7 | currently you have to remount tagfs in order to apply modifications in .tag 8 | files. tagfs should watch the .tag files for modifications and apply the 9 | changes immediately. 10 | 11 | -------------------------------------------------------------------------------- /src/test/tagfs_test/item_access_mock.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from tagfs_test.item_mock import ItemMock 21 | 22 | class ItemAccessMock(object): 23 | 24 | def __init__(self): 25 | self.parseTime = 42 26 | self.taggedItems = [] 27 | self.untaggedItems = [] 28 | -------------------------------------------------------------------------------- /src/test/tagfs_test/item_mock.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | class ItemMock(object): 21 | 22 | def __init__(self, name, tags = []): 23 | self.name = name 24 | self.tags = tags 25 | 26 | def createItemMocks(itemNames): 27 | return [ItemMock(name, []) for name in itemNames] 28 | -------------------------------------------------------------------------------- /bin/runEndToEndTest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | TEST_DIR=$1 6 | 7 | fail() { 8 | echo "$1" >&2 9 | exit 1 10 | } 11 | 12 | cleanupTagFS(){ 13 | fusermount -u $TEST_MOUNT_DIR 14 | rmdir $TEST_MOUNT_DIR 15 | } 16 | 17 | if [ ! -d "$TEST_DIR" ] 18 | then 19 | fail "TEST_DIR is not a directory: $TEST_DIR" 20 | fi 21 | 22 | TEST_NAME=`basename $TEST_DIR` 23 | 24 | echo '' 25 | echo '======================================================' 26 | echo " Executing end-to-end test $TEST_NAME" 27 | 28 | PYTHON=python 29 | 30 | BIN_DIR=`dirname "$0"` 31 | PROJECT_DIR=$BIN_DIR/.. 32 | PYMODDIR=$PROJECT_DIR/src/modules 33 | export PYTHONPATH=$PYMODDIR:$PYTHONPATH 34 | 35 | export TEST_MOUNT_DIR=`mktemp -d --tmpdir tagfs_e2e.$TEST_NAME.XXXXXXXXXX` 36 | 37 | echo "Using mount $TEST_MOUNT_DIR" 38 | 39 | $PYTHON $PROJECT_DIR/src/bin/tagfs -i $TEST_DIR/items $TEST_MOUNT_DIR 40 | 41 | trap cleanupTagFS EXIT 42 | 43 | echo 'Asserting mount' 44 | 45 | $BIN_DIR/e2eAssertSandbox.sh $TEST_DIR/assert 46 | 47 | echo "Success" 48 | -------------------------------------------------------------------------------- /bin/e2eAssertSandbox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | ASSERT_BIN=$1 6 | 7 | fail() { 8 | echo "TEST FAILED: $1" >&2 9 | exit 1 10 | } 11 | 12 | assertExists(){ 13 | local path="$1" 14 | 15 | if [ ! -e "${path}" ] 16 | then 17 | fail "Expected path to exist: ${path}" 18 | fi 19 | } 20 | 21 | assertNotExists(){ 22 | local path="$1" 23 | 24 | if [ -e "${path}" ] 25 | then 26 | fail "Expected path to not exist: ${path}" 27 | fi 28 | } 29 | 30 | assertLink(){ 31 | local path="$1" 32 | 33 | assertExists "${path}" 34 | 35 | if [ ! -L "${path}" ] 36 | then 37 | fail "Expected path to be link: ${path}" 38 | fi 39 | } 40 | 41 | assertDir(){ 42 | local path="$1" 43 | 44 | assertExists "${path}" 45 | 46 | if [ ! -d "${path}" ] 47 | then 48 | fail "Expected path to be a directory: ${path}" 49 | fi 50 | } 51 | 52 | assertEqualContent(){ 53 | cmp "$1" "$2" > /dev/null || fail "File content is not equal: $1 and $2 ($DIFF)" 54 | } 55 | 56 | cd `dirname "$ASSERT_BIN"` 57 | . $ASSERT_BIN > "$ASSERT_BIN.log" 58 | -------------------------------------------------------------------------------- /src/modules/tagfs/sysIO.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import os.path 20 | 21 | def createSystem(): 22 | return System(open = open, pathExists = os.path.exists) 23 | 24 | class System(object): 25 | '''Abstraction layer for system access. 26 | 27 | This class can be used to mock system access in tests. 28 | ''' 29 | 30 | def __init__(self, open = None, pathExists = None): 31 | self.open = open 32 | self.pathExists = pathExists 33 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_file.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2013 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | import array 21 | import stat 22 | from node import Stat 23 | 24 | class FileNode(object): 25 | 26 | @property 27 | def attr(self): 28 | s = Stat() 29 | 30 | s.st_mode = stat.S_IFREG | 0444 31 | s.st_nlink = 2 32 | 33 | # TODO replace with memory saving size calculation 34 | s.st_size = len(array.array('c', self.content)) 35 | 36 | return s 37 | 38 | def open(self, path, flags): 39 | return 40 | 41 | def read(self, path, size, offset): 42 | return self.content[offset:offset + size] 43 | -------------------------------------------------------------------------------- /src/bin/tagfs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009 Markus Pielmeier 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | 21 | from tagfs.main import main 22 | from tagfs.log_config import setUpLogging 23 | 24 | if __name__ == '__main__': 25 | from os import environ as env 26 | if 'DEBUG' in env: 27 | setUpLogging() 28 | 29 | import logging 30 | import sys 31 | 32 | if 'PROFILE' in env: 33 | logging.info('Enabled tagfs profiling') 34 | 35 | import cProfile 36 | import os 37 | 38 | profileFile = os.path.join(os.getcwd(), 'tagfs.profile') 39 | 40 | sys.exit(cProfile.run('main()', profileFile)) 41 | else: 42 | sys.exit(main()) 43 | 44 | -------------------------------------------------------------------------------- /etc/rdf/example-rdf.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | location 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | holiday 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | airport 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 2008-03-29 - holiday south korea 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_freebase_support_query.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import unittest 20 | import tagfs.freebase_support as freebase_support 21 | 22 | class WhenQueryWithOneFilerAndOneSelector(unittest.TestCase): 23 | 24 | def setUp(self): 25 | super(WhenQueryWithOneFilerAndOneSelector, self).setUp() 26 | 27 | self.query = freebase_support.Query({'filter': 'filterValue', 'selector': None, }) 28 | 29 | def testThenSelectedKeysIsSelector(self): 30 | self.assertEqual(list(self.query.selectedKeys), ['selector',]) 31 | 32 | def testThenQueryStringIs(self): 33 | self.assertEqual(self.query.queryString, '{"filter":"filterValue","selector":[]}') 34 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_filter_value.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from node_filter import FilterDirectoryNode 21 | 22 | class ValueFilterDirectoryNode(FilterDirectoryNode): 23 | 24 | def __init__(self, itemAccess, config, parentNode, value): 25 | super(ValueFilterDirectoryNode, self).__init__(itemAccess, config) 26 | self.parentNode = parentNode 27 | self.value = value 28 | 29 | @property 30 | def name(self): 31 | return self.value 32 | 33 | @property 34 | def items(self): 35 | for item in self.parentNode.items: 36 | if not item.isTaggedWithValue(self.value): 37 | continue 38 | 39 | yield item 40 | 41 | -------------------------------------------------------------------------------- /reports/2011-05-31_19_05_56/coverage.txt: -------------------------------------------------------------------------------- 1 | Name Stmts Exec Cover Missing 2 | --------------------------------------------------------------------- 3 | src/bin/tagfs 15 0 0% 21-42 4 | src/modules/tagfs/__init__ 1 0 0% 1 5 | src/modules/tagfs/cache 33 8 24% 21-35, 38-75, 92 6 | src/modules/tagfs/config 38 0 0% 21-92 7 | src/modules/tagfs/item_access 195 0 0% 19-351 8 | src/modules/tagfs/log 24 0 0% 20-60 9 | src/modules/tagfs/log_config 15 0 0% 21-51 10 | src/modules/tagfs/main 77 0 0% 28-180 11 | src/modules/tagfs/node 40 23 57% 20-27, 39-44, 47, 51, 60-66, 78-79 12 | src/modules/tagfs/node_filter_context 56 9 16% 20-66, 71-75, 89-111 13 | src/modules/tagfs/node_root 32 16 50% 20-27, 30, 44-45, 49, 55-60, 64, 69 14 | src/modules/tagfs/node_untagged_items 16 10 62% 20-25, 29, 43 15 | src/modules/tagfs/transient_dict 51 38 74% 20-24, 27, 30-32, 36, 43, 47, 54, 64, 73, 92 16 | src/modules/tagfs/view 81 0 0% 21-174 17 | --------------------------------------------------------------------- 18 | TOTAL 674 104 15% 19 | -------------------------------------------------------------------------------- /src/test/tagfs_test/node_asserter.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | import stat 21 | 22 | def hasMode(attr, mode): 23 | return (attr.st_mode & mode > 0) 24 | 25 | def validateNodeInterface(test, node): 26 | attr = node.attr 27 | 28 | test.assertTrue(attr.st_atime >= 0) 29 | test.assertTrue(attr.st_mtime >= 0) 30 | test.assertTrue(attr.st_ctime >= 0) 31 | 32 | def validateDirectoryInterface(test, node): 33 | attr = node.attr 34 | 35 | test.assertTrue(hasMode(attr, stat.S_IFDIR)) 36 | 37 | validateNodeInterface(test, node) 38 | 39 | def validateLinkInterface(test, node): 40 | attr = node.attr 41 | 42 | test.assertTrue(hasMode(attr, stat.S_IFLNK)) 43 | 44 | validateNodeInterface(test, node) 45 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/systemMocks.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | class ReadLineFileMock(object): 20 | 21 | def __init__(self, lines): 22 | self.lines = lines 23 | 24 | def __enter__(self, *args, **kwargs): 25 | return self.lines 26 | 27 | def __exit__(self, *args, **kwargs): 28 | pass 29 | 30 | class SystemMock(object): 31 | 32 | def __init__(self, test, readFiles = {}): 33 | self.test = test 34 | self.readFiles = readFiles 35 | 36 | def open(self, fileName, mode): 37 | if(mode == 'r'): 38 | return self.readFiles[fileName] 39 | 40 | self.test.fail('Unknown file mode %s' % mode) 41 | 42 | def pathExists(self, path): 43 | return path in self.readFiles 44 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_root.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from node_filter import FilterDirectoryNode 21 | from node_untagged_items import UntaggedItemsDirectoryNode 22 | 23 | class RootDirectoryNode(FilterDirectoryNode): 24 | 25 | def __init__(self, itemAccess, config): 26 | super(RootDirectoryNode, self).__init__(itemAccess, config) 27 | 28 | @property 29 | def items(self): 30 | return self.itemAccess.taggedItems 31 | 32 | @property 33 | def _enableItemLinks(self): 34 | return self.config.enableRootItemLinks 35 | 36 | @property 37 | def _entries(self): 38 | yield UntaggedItemsDirectoryNode('.untagged', self.itemAccess) 39 | 40 | for e in super(RootDirectoryNode, self)._entries: 41 | yield e 42 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_item_access_tag.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from unittest import TestCase 21 | 22 | import tagfs.item_access as item_access 23 | 24 | class TagTest(TestCase): 25 | 26 | def testTagValueInfluencesHash(self): 27 | self.assertTrue(item_access.Tag('a', None).__hash__() != item_access.Tag('b', None).__hash__()) 28 | 29 | def testTagContextInfluencesHash(self): 30 | self.assertTrue(item_access.Tag('v', None).__hash__() != item_access.Tag('v', 'c').__hash__()) 31 | 32 | def testEqualTagsEqWhenContextNone(self): 33 | self.assertTrue(item_access.Tag('t', None).__eq__(item_access.Tag('t', None))) 34 | 35 | def testEqualTagsEqWhenContextStr(self): 36 | self.assertTrue(item_access.Tag('t', 'c').__eq__(item_access.Tag('t', 'c'))) 37 | -------------------------------------------------------------------------------- /reports/2011-06-06_05_28_41/coverage.txt: -------------------------------------------------------------------------------- 1 | Name Stmts Exec Cover Missing 2 | --------------------------------------------------------------------- 3 | src/bin/tagfs 15 0 0% 21-42 4 | src/modules/tagfs/__init__ 1 0 0% 1 5 | src/modules/tagfs/cache 33 7 21% 21-35, 38-75, 90-92 6 | src/modules/tagfs/config 38 0 0% 21-92 7 | src/modules/tagfs/item_access 195 0 0% 19-351 8 | src/modules/tagfs/log 24 0 0% 20-60 9 | src/modules/tagfs/log_config 15 0 0% 21-51 10 | src/modules/tagfs/main 77 0 0% 28-180 11 | src/modules/tagfs/node 40 23 57% 20-27, 39-44, 47, 51, 60-66, 78-79 12 | src/modules/tagfs/node_export 19 0 0% 20-53 13 | src/modules/tagfs/node_filter 27 19 70% 20-25, 28, 42, 51, 57 14 | src/modules/tagfs/node_filter_context 45 17 37% 20-27, 33-37, 41, 45-47, 52, 56, 70-91 15 | src/modules/tagfs/node_root 14 5 35% 20-28, 31, 35 16 | src/modules/tagfs/node_untagged_items 16 10 62% 20-25, 29, 43 17 | src/modules/tagfs/transient_dict 51 38 74% 20-24, 27, 30-32, 36, 43, 47, 54, 64, 73, 92 18 | src/modules/tagfs/view 81 0 0% 21-174 19 | --------------------------------------------------------------------- 20 | TOTAL 691 119 17% 21 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_untagged_items.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from cache import cache 21 | from node import Stat, ItemLinkNode, DirectoryNode 22 | 23 | class UntaggedItemsDirectoryNode(DirectoryNode): 24 | 25 | def __init__(self, name, itemAccess): 26 | self.name = name 27 | self.itemAccess = itemAccess 28 | 29 | @property 30 | def attr(self): 31 | s = super(UntaggedItemsDirectoryNode, self).attr 32 | 33 | # TODO why nlink == 2? 34 | s.st_nlink = 2 35 | 36 | # TODO write test case which tests st_mtime == itemAccess.parseTime 37 | s.st_mtime = self.itemAccess.parseTime 38 | s.st_ctime = s.st_mtime 39 | s.st_atime = s.st_mtime 40 | 41 | return s 42 | 43 | @property 44 | def _entries(self): 45 | for item in self.itemAccess.untaggedItems: 46 | yield ItemLinkNode(item) 47 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_freebase_support_queryFileParser.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2013 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import unittest 20 | import tagfs.freebase_support as freebase_support 21 | import systemMocks 22 | 23 | class QueryParserMock(object): 24 | 25 | def parse(self, queryString): 26 | return 'rule' 27 | 28 | class WhenFileWithOneLineExists(unittest.TestCase): 29 | 30 | def setUp(self): 31 | super(WhenFileWithOneLineExists, self).setUp() 32 | 33 | self.filePath = '/path/to/my/file' 34 | 35 | self.system = systemMocks.SystemMock(self) 36 | self.system.readFiles[self.filePath] = systemMocks.ReadLineFileMock(['line1',]) 37 | 38 | self.queryParser = QueryParserMock() 39 | self.queryFileParser = freebase_support.QueryFileParser(self.system, self.queryParser) 40 | 41 | def testThenParsesOneLine(self): 42 | self.assertEqual(list(self.queryFileParser.parseFile(self.filePath)), ['rule',]) 43 | -------------------------------------------------------------------------------- /reports/2011-05-31_19_05_56/tests.txt: -------------------------------------------------------------------------------- 1 | testForgettValuesWhenDictSizeExceeded (tagfs_test_small.test_transient_dict.TestTransientDict) ... ok 2 | testGetAndSetValues (tagfs_test_small.test_transient_dict.TestTransientDict) ... ok 3 | testNodeAttrMTimeIsItemAccessParseTime (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 4 | testNodeHasName (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 5 | testNodeIsDirectory (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 6 | testUntaggedItemAccessItemsAreUntaggedItemsDirectoryEntries (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 7 | testItemLinksReplaceUntaggedDirectory (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 8 | testNodeAttrMTimeIsItemAccessParseTime (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 9 | testNodeContainerContainsTaggedNodeLinks (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 10 | testNodeIsDirectory (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 11 | testNodeContainsUntaggedDirectory (tagfs_test_small.test_root_directory_node.TestRootDirectoryNodeUntaggedDirectory) ... ok 12 | testNodeAttrMTimeIsItemAccessParseTime (tagfs_test_small.test_filter_context_value_list_directory_node.TestContextValueListDirectoryNode) ... ok 13 | testNodeIsDirectory (tagfs_test_small.test_filter_context_value_list_directory_node.TestContextValueListDirectoryNode) ... ok 14 | 15 | ---------------------------------------------------------------------- 16 | Ran 13 tests in 0.005s 17 | 18 | OK 19 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_transient_dict.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | import unittest 21 | from tagfs.transient_dict import TransientDict 22 | 23 | class TestTransientDict(unittest.TestCase): 24 | 25 | def testGetAndSetValues(self): 26 | d = TransientDict(10) 27 | 28 | self.assertTrue('1' not in d) 29 | 30 | d['1'] = 'a' 31 | d['2'] = 'b' 32 | 33 | self.assertTrue(d['1'] == 'a') 34 | self.assertTrue(d['2'] == 'b') 35 | 36 | self.assertTrue('1' in d) 37 | self.assertTrue('3' not in d) 38 | self.assertTrue('a' not in d) 39 | 40 | def testForgettValuesWhenDictSizeExceeded(self): 41 | d = TransientDict(2) 42 | 43 | d['1'] = 'a' 44 | d['2'] = 'b' 45 | d['1'] = 'a' 46 | d['3'] = 'c' 47 | d['1'] = 'a' 48 | d['4'] = 'c' 49 | 50 | self.assertTrue('1' in d) 51 | self.assertTrue('2' not in d) 52 | self.assertTrue('4' in d) 53 | -------------------------------------------------------------------------------- /src/modules/tagfs/log.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010, 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | import functools 21 | import logging 22 | 23 | def getLogger(*args): 24 | o = args[0] 25 | 26 | logger = logging.getLogger(o.__class__.__name__) 27 | 28 | return logger 29 | 30 | 31 | def logCall(f): 32 | 33 | @functools.wraps(f) 34 | def logCall(*args, **kwargs): 35 | logger = getLogger(*args) 36 | 37 | if(logger.isEnabledFor(logging.DEBUG)): 38 | logger.debug(f.__name__ + '(' + (', '.join('\'' + str(a) + '\'' for a in args[1:])) + ')') 39 | 40 | return f(*args, **kwargs) 41 | 42 | return logCall 43 | 44 | def logException(f): 45 | 46 | @functools.wraps(f) 47 | def logException(*args, **kwargs): 48 | try: 49 | return f(*args, **kwargs) 50 | except: 51 | logger = getLogger(*args) 52 | 53 | if(logger.isEnabledFor(logging.ERROR)): 54 | import traceback 55 | 56 | logger.warn(traceback.format_exc()) 57 | 58 | raise 59 | 60 | return logException 61 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_filter_context_value_list_directory_node.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from unittest import TestCase 21 | 22 | from tagfs.node_filter_context import ContextValueListDirectoryNode 23 | 24 | from tagfs_test.node_asserter import validateDirectoryInterface, validateLinkInterface 25 | from tagfs_test.item_access_mock import ItemAccessMock 26 | from tagfs_test.item_mock import createItemMocks 27 | 28 | class ParentNodeMock(object): 29 | 30 | pass 31 | 32 | class TestContextValueListDirectoryNode(TestCase): 33 | 34 | def setUp(self): 35 | self.itemAccess = ItemAccessMock() 36 | self.itemAccess.taggedItems = createItemMocks(['item1']) 37 | 38 | self.parentNode = ParentNodeMock() 39 | self.context = 'c1' 40 | self.node = ContextValueListDirectoryNode(self.itemAccess, None, self.parentNode, self.context) 41 | 42 | def testNodeAttrMTimeIsItemAccessParseTime(self): 43 | attr = self.node.attr 44 | 45 | self.assertEqual(self.itemAccess.parseTime, attr.st_mtime) 46 | 47 | def testNodeIsDirectory(self): 48 | validateDirectoryInterface(self, self.node) 49 | -------------------------------------------------------------------------------- /reports/2011-02-07_08_53_03/coverage.txt: -------------------------------------------------------------------------------- 1 | Name Stmts Exec Cover Missing 2 | ---------------------------------------------------------------- 3 | src/modules/tagfs/__init__ 1 0 0% 1 4 | src/modules/tagfs/cache 33 8 24% 21-35, 38-75, 92 5 | src/modules/tagfs/config 38 20 52% 21-33, 38, 56, 63-65, 69, 74, 78, 82, 86, 90 6 | src/modules/tagfs/item_access 182 115 63% 19-27, 38, 43-45, 48, 51-54, 88-90, 96-97, 101-102, 111, 119-120, 127-130, 142-143, 150, 157-158, 162-167, 170, 187-189, 192, 201-205, 208, 212-214, 217-219, 222, 234-238, 248, 259-260, 270-271, 275-276, 288-289, 293-294, 298-301, 308, 317-318, 330-331 7 | src/modules/tagfs/log 9 4 44% 20-25, 34 8 | src/modules/tagfs/log_config 15 0 0% 21-51 9 | src/modules/tagfs/node 346 220 63% 20-30, 42, 45-47, 57-61, 65-66, 70, 74-76, 80-82, 92-93, 100, 108-115, 122, 125, 134-135, 141-142, 152-154, 159, 166, 173-178, 185-186, 193, 196-209, 214, 230, 234-235, 245, 267-268, 272, 279-284, 295-296, 303, 306, 309-311, 316, 326, 330-334, 338, 348-350, 354, 371-373, 379, 383-384, 388, 413-415, 421, 425-426, 430, 450-452, 458, 462-463, 467, 492-494, 499, 503-504, 508, 525-532, 538, 545, 549, 553-554, 558, 573-575, 580, 584, 588, 603-605, 610-611, 615, 649-661 10 | src/modules/tagfs/tagfs 77 0 0% 28-173 11 | src/modules/tagfs/transient_dict 51 38 74% 20-24, 27, 30-32, 36, 43, 47, 54, 64, 73, 92 12 | src/modules/tagfs/view 78 40 51% 21-41, 46, 50, 82, 89, 100, 105-107, 111, 116-118, 122-133, 138-140, 144, 149-151, 155-164 13 | src/tagfs 14 0 0% 21-41 14 | ---------------------------------------------------------------- 15 | TOTAL 844 445 52% 16 | -------------------------------------------------------------------------------- /reports/2011-02-07_10_10_40/coverage.txt: -------------------------------------------------------------------------------- 1 | Name Stmts Exec Cover Missing 2 | ---------------------------------------------------------------- 3 | src/bin/tagfs 14 0 0% 21-41 4 | src/modules/tagfs/__init__ 1 0 0% 1 5 | src/modules/tagfs/cache 33 8 24% 21-35, 38-75, 92 6 | src/modules/tagfs/config 38 20 52% 21-33, 38, 56, 63-65, 69, 74, 78, 82, 86, 90 7 | src/modules/tagfs/item_access 182 115 63% 19-27, 38, 43-45, 48, 51-54, 88-90, 96-97, 101-102, 111, 119-120, 127-130, 142-143, 150, 157-158, 162-167, 170, 187-189, 192, 201-205, 208, 212-214, 217-219, 222, 234-238, 248, 259-260, 270-271, 275-276, 288-289, 293-294, 298-301, 308, 317-318, 330-331 8 | src/modules/tagfs/log 9 4 44% 20-25, 34 9 | src/modules/tagfs/log_config 15 0 0% 21-51 10 | src/modules/tagfs/node 346 220 63% 20-30, 42, 45-47, 57-61, 65-66, 70, 74-76, 80-82, 92-93, 100, 108-115, 122, 125, 134-135, 141-142, 152-154, 159, 166, 173-178, 185-186, 193, 196-209, 214, 230, 234-235, 245, 267-268, 272, 279-284, 295-296, 303, 306, 309-311, 316, 326, 330-334, 338, 348-350, 354, 371-373, 379, 383-384, 388, 413-415, 421, 425-426, 430, 450-452, 458, 462-463, 467, 492-494, 499, 503-504, 508, 525-532, 538, 545, 549, 553-554, 558, 573-575, 580, 584, 588, 603-605, 610-611, 615, 649-661 11 | src/modules/tagfs/tagfs 77 0 0% 28-173 12 | src/modules/tagfs/transient_dict 51 38 74% 20-24, 27, 30-32, 36, 43, 47, 54, 64, 73, 92 13 | src/modules/tagfs/view 78 40 51% 21-41, 46, 50, 82, 89, 100, 105-107, 111, 116-118, 122-133, 138-140, 144, 149-151, 155-164 14 | ---------------------------------------------------------------- 15 | TOTAL 844 445 52% 16 | -------------------------------------------------------------------------------- /src/modules/tagfs/log_config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009, 2010 Markus Pielmeier 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | 21 | import logging 22 | import sys 23 | 24 | def setUpLogging(): 25 | def exceptionCallback(eType, eValue, eTraceBack): 26 | import cgitb 27 | 28 | txt = cgitb.text((eType, eValue, eTraceBack)) 29 | 30 | logging.critical(txt) 31 | 32 | # sys.exit(1) 33 | 34 | # configure file logger 35 | logging.basicConfig(level = logging.DEBUG, 36 | format = '%(asctime)s %(levelname)s %(message)s', 37 | filename = '/tmp/tagfs.log', 38 | filemode = 'a') 39 | 40 | # configure console logger 41 | consoleHandler = logging.StreamHandler(sys.stdout) 42 | consoleHandler.setLevel(logging.DEBUG) 43 | 44 | consoleFormatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') 45 | consoleHandler.setFormatter(consoleFormatter) 46 | logging.getLogger().addHandler(consoleHandler) 47 | 48 | # replace default exception handler 49 | sys.excepthook = exceptionCallback 50 | 51 | logging.debug('Logging and exception handling has been set up') 52 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_freebase_support_genericQueryFactory.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2013 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import unittest 20 | import tagfs.freebase_support as freebase_support 21 | 22 | class WhenGenericQueryFactoryWithVariables(unittest.TestCase): 23 | 24 | def resolveVar(self, name): 25 | return self.variables[name] 26 | 27 | def setUp(self): 28 | super(WhenGenericQueryFactoryWithVariables, self).setUp() 29 | 30 | self.variables = {} 31 | self.factory = freebase_support.GenericQueryFactory(self.resolveVar) 32 | 33 | self.varValue = 'value' 34 | self.variables['var'] = self.varValue 35 | 36 | def testResolveExistingVariable(self): 37 | q = {'key': '$var',} 38 | 39 | self.assertEqual(self.factory.createQuery(q), {'key': self.varValue,}) 40 | 41 | def testCreatedQueryIsNewInstance(self): 42 | q = {} 43 | 44 | self.assertTrue(not q is self.factory.createQuery(q)) 45 | 46 | def testGenericQueryIsUntouched(self): 47 | q = {'key': '$var',} 48 | 49 | self.factory.createQuery(q) 50 | 51 | self.assertEqual(q, {'key': '$var',}) 52 | 53 | def testResolveValueToNone(self): 54 | q = {'key': None,} 55 | 56 | self.assertEqual(self.factory.createQuery(q), q) 57 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_item_access_parseTagsFromFile.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import unittest 20 | import tagfs.item_access as item_access 21 | import systemMocks 22 | 23 | class ParseTagsFromFileTest(unittest.TestCase): 24 | 25 | def setUp(self): 26 | super(ParseTagsFromFileTest, self).setUp() 27 | 28 | self.system = systemMocks.SystemMock(self) 29 | 30 | def setTagFileContent(self, lines): 31 | self.system.readFiles['.tag'] = systemMocks.ReadLineFileMock(lines) 32 | 33 | def assertParseTags(self, expectedTags): 34 | self.assertEqual(list(item_access.parseTagsFromFile(self.system, '.tag')), expectedTags) 35 | 36 | def testParseTagWithoutContext(self): 37 | self.setTagFileContent(['value',]) 38 | 39 | self.assertParseTags([item_access.Tag('value'),]) 40 | 41 | def testParseTagWithContext(self): 42 | self.setTagFileContent(['context: value',]) 43 | 44 | self.assertParseTags([item_access.Tag('value', 'context'),]) 45 | 46 | def testIgnoreEmptyLines(self): 47 | self.setTagFileContent(['',]) 48 | 49 | self.assertParseTags([]) 50 | 51 | def testIgnoreLinesWithJustSpaces(self): 52 | self.setTagFileContent(['\t ',]) 53 | 54 | self.assertParseTags([]) 55 | -------------------------------------------------------------------------------- /reports/2011-06-06_05_28_41/tests.txt: -------------------------------------------------------------------------------- 1 | testForgettValuesWhenDictSizeExceeded (tagfs_test_small.test_transient_dict.TestTransientDict) ... ok 2 | testGetAndSetValues (tagfs_test_small.test_transient_dict.TestTransientDict) ... ok 3 | testNodeAttrMTimeIsItemAccessParseTime (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 4 | testNodeHasName (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 5 | testNodeIsDirectory (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 6 | testUntaggedItemAccessItemsAreUntaggedItemsDirectoryEntries (tagfs_test_small.test_untagged_items_directory_node.TestUntaggedItemsDirectoryNode) ... ok 7 | testItemLinksReplaceUntaggedDirectory (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 8 | testNodeAttrMTimeIsItemAccessParseTime (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 9 | testNodeContainerContainsTaggedNodeLinks (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 10 | testNodeIsDirectory (tagfs_test_small.test_root_directory_node.TestRootDirectoryNode) ... ok 11 | testNodeContainsUntaggedDirectory (tagfs_test_small.test_root_directory_node.TestRootDirectoryNodeUntaggedDirectory) ... ok 12 | testNodeAttrMTimeIsItemAccessParseTime (tagfs_test_small.test_filter_context_value_list_directory_node.TestContextValueListDirectoryNode) ... ok 13 | testNodeIsDirectory (tagfs_test_small.test_filter_context_value_list_directory_node.TestContextValueListDirectoryNode) ... ok 14 | testMatchingItemIsAvailableAsLink (tagfs_test_small.test_filter_context_value_filter_directory_node.TestContextValueFilterDirectoryNode) ... ok 15 | testNodeAttrMTimeIsItemAccessParseTime (tagfs_test_small.test_filter_context_value_filter_directory_node.TestContextValueFilterDirectoryNode) ... ok 16 | testNodeIsDirectory (tagfs_test_small.test_filter_context_value_filter_directory_node.TestContextValueFilterDirectoryNode) ... ok 17 | 18 | ---------------------------------------------------------------------- 19 | Ran 16 tests in 0.006s 20 | 21 | OK 22 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_untagged_items_directory_node.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from unittest import TestCase 21 | 22 | from tagfs.node_untagged_items import UntaggedItemsDirectoryNode 23 | 24 | from tagfs_test.node_asserter import validateLinkInterface, validateDirectoryInterface 25 | from tagfs_test.item_access_mock import ItemAccessMock 26 | from tagfs_test.item_mock import createItemMocks 27 | 28 | class TestUntaggedItemsDirectoryNode(TestCase): 29 | 30 | def setUp(self): 31 | self.itemAccess = ItemAccessMock() 32 | self.itemAccess.untaggedItems = createItemMocks(['item1', 'item2']) 33 | 34 | self.nodeName = 'e' 35 | self.node = UntaggedItemsDirectoryNode(self.nodeName, self.itemAccess) 36 | 37 | def testNodeAttrMTimeIsItemAccessParseTime(self): 38 | attr = self.node.attr 39 | 40 | self.assertEqual(self.itemAccess.parseTime, attr.st_mtime) 41 | 42 | def testNodeIsDirectory(self): 43 | validateDirectoryInterface(self, self.node) 44 | 45 | def testUntaggedItemAccessItemsAreUntaggedItemsDirectoryEntries(self): 46 | entries = self.node.entries 47 | 48 | self.assertEqual(len(self.itemAccess.untaggedItems), len(entries)) 49 | 50 | for i in self.itemAccess.untaggedItems: 51 | self.assertTrue(i.name in entries) 52 | 53 | validateLinkInterface(self, entries[i.name]) 54 | 55 | def testNodeHasName(self): 56 | self.assertEqual(self.nodeName, self.node.name) 57 | -------------------------------------------------------------------------------- /reports/2011-02-07_10_10_40/tests.txt: -------------------------------------------------------------------------------- 1 | Tests an item with tags assigned to. ... ok 2 | Tests the results for items which got no tags assigned. ... ok 3 | Tests the results for items which don't exist. ... ok 4 | Tests AndFilter filter arguments at once. ... ok 5 | Tests TagValueFilter filter argument. ... ok 6 | Test the items property of ItemAccess. ... FAIL 7 | Test the items property of ItemAccess. ... ok 8 | Test the tag property of ItemAccess ... ok 9 | Test the untaggedItems property of ItemAccess ... FAIL 10 | testItemNodeInterface (test.test_all.TestItemNode) ... ok 11 | testRecurse (test.test_all.TestNodeRecurse) ... ok 12 | Tests the parseTagsFromFile(...) method. ... ok 13 | testRootNode (test.test_all.TestRootNode) ... ok 14 | testTagNode (test.test_all.TestTagNode) ... ok 15 | Makes sure that the events directory is accessible. ... ok 16 | testUntaggedItemsNodeInterface (test.test_all.TestUntaggedItemsNode) ... ok 17 | Test the forgett feature ... ok 18 | Test some simple get, set an in calls. ... ok 19 | Testing view interface ... ok 20 | testConfig (test.test_config.TestConfig) ... ok 21 | 22 | ====================================================================== 23 | FAIL: Test the items property of ItemAccess. 24 | ---------------------------------------------------------------------- 25 | Traceback (most recent call last): 26 | File "/home/marook/work/devel/projects/tagfs/src/test/test_all.py", line 147, in testItems 27 | set(items)) 28 | AssertionError: set(['2008-12-25 - holiday india', '2009-07-29 - no tags', '2008-03-29 - holiday south korea', '2008-11-11 - airport underground railway']) != set(['.tagfs', '2008-12-25 - holiday india', '2008-03-29 - holiday south korea', '2009-07-29 - no tags', '2008-11-11 - airport underground railway']) 29 | 30 | ====================================================================== 31 | FAIL: Test the untaggedItems property of ItemAccess 32 | ---------------------------------------------------------------------- 33 | Traceback (most recent call last): 34 | File "/home/marook/work/devel/projects/tagfs/src/test/test_all.py", line 184, in testUntaggedItems 35 | set([item.name for item in untaggedItems])) 36 | AssertionError: set(['2009-07-29 - no tags']) != set(['.tagfs', '2009-07-29 - no tags']) 37 | 38 | ---------------------------------------------------------------------- 39 | Ran 20 tests in 1.370s 40 | 41 | FAILED (failures=2) 42 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_export.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from cache import cache 21 | from node import Stat, ItemLinkNode, DirectoryNode 22 | from node_untagged_items import UntaggedItemsDirectoryNode 23 | from node_export_csv import ExportCsvFileNode 24 | from node_export_chart import ChartImageNode 25 | 26 | class SumTransformation(object): 27 | 28 | def __init__(self): 29 | self.sum = 0.0 30 | 31 | def transform(self, y): 32 | self.sum += y 33 | 34 | return self.sum 35 | 36 | class ExportDirectoryNode(DirectoryNode): 37 | 38 | def __init__(self, itemAccess, parentNode): 39 | self.itemAccess = itemAccess 40 | self.parentNode = parentNode 41 | 42 | @property 43 | def name(self): 44 | return '.export' 45 | 46 | @property 47 | def attr(self): 48 | s = super(ExportDirectoryNode, self).attr 49 | 50 | # TODO why nlink == 2? 51 | s.st_nlink = 2 52 | 53 | # TODO write test case which tests st_mtime == itemAccess.parseTime 54 | s.st_mtime = self.itemAccess.parseTime 55 | s.st_ctime = s.st_mtime 56 | s.st_atime = s.st_mtime 57 | 58 | return s 59 | 60 | @property 61 | def items(self): 62 | return self.parentNode.items 63 | 64 | @property 65 | def _entries(self): 66 | yield ExportCsvFileNode(self.itemAccess, self.parentNode) 67 | 68 | for context in self.parentNode.contexts: 69 | yield ChartImageNode(self.itemAccess, self.parentNode, context, 'value', lambda y: y) 70 | yield ChartImageNode(self.itemAccess, self.parentNode, context, 'sum', SumTransformation().transform) 71 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_item_access_item.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import unittest 20 | 21 | import tagfs.item_access as item_access 22 | import systemMocks 23 | 24 | class ItemAccessMock(object): 25 | 26 | def __init__(self, dataDirectory, tagFileName): 27 | self.dataDirectory = dataDirectory 28 | self.tagFileName = tagFileName 29 | 30 | class FreebaseQueryParserMock(object): 31 | 32 | def __init__(self, test): 33 | self.test = test 34 | 35 | def parse(self, queryString): 36 | return queryString 37 | 38 | class FreebaseAdapterMock(object): 39 | 40 | def __init__(self, test): 41 | self.test = test 42 | 43 | def execute(self, query): 44 | return { 45 | 'freebaseContext': ['freebaseValue'], 46 | } 47 | 48 | class WhenItemHasFreebaseQueryTag(unittest.TestCase): 49 | 50 | def setUp(self): 51 | super(WhenItemHasFreebaseQueryTag, self).setUp() 52 | 53 | self.system = systemMocks.SystemMock(self) 54 | self.system.readFiles['/path/to/my/data/directory/myItem/.tag'] = systemMocks.ReadLineFileMock(['_freebase: myFreebaseQuery',]) 55 | 56 | self.itemAccess = ItemAccessMock('/path/to/my/data/directory', '.tag') 57 | self.freebaseQueryParser = FreebaseQueryParserMock(self) 58 | self.freebaseAdapter = FreebaseAdapterMock(self) 59 | 60 | self.item = item_access.Item('myItem', self.system, self.itemAccess, self.freebaseQueryParser, self.freebaseAdapter) 61 | 62 | def testThenItemHasFreebaseTaggingsFromItemAccess(self): 63 | self.assertEqual(list(self.item.getTagsByContext('freebaseContext')), [item_access.Tag('freebaseValue', 'freebaseContext'),]) 64 | -------------------------------------------------------------------------------- /src/modules/tagfs/node.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2009 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | import fuse 21 | import stat 22 | 23 | from cache import cache 24 | 25 | class Stat(fuse.Stat): 26 | 27 | def __init__(self): 28 | self.st_mode = 0 29 | self.st_ino = 0 30 | self.st_dev = 0 31 | self.st_nlink = 0 32 | self.st_uid = 0 33 | self.st_gid = 0 34 | self.st_size = 0 35 | self.st_atime = 0 36 | self.st_mtime = 0 37 | self.st_ctime = 0 38 | 39 | def __str__(self): 40 | return '[' + ', '.join([field + ': ' + str(self.__dict__[field]) for field in self.__dict__]) + ']' 41 | 42 | class ItemLinkNode(object): 43 | 44 | def __init__(self, item): 45 | self.item = item 46 | 47 | @property 48 | def name(self): 49 | return self.item.name 50 | 51 | @property 52 | def attr(self): 53 | s = Stat() 54 | 55 | s.st_mode = stat.S_IFLNK | 0444 56 | s.st_nlink = 2 57 | 58 | return s 59 | 60 | def addsValue(self, items): 61 | return True 62 | 63 | @property 64 | def link(self): 65 | return self.item.itemDirectory 66 | 67 | class DirectoryNode(object): 68 | 69 | @property 70 | def attr(self): 71 | s = Stat() 72 | 73 | s.st_mode = stat.S_IFDIR | 0555 74 | 75 | s.st_mtime = 0 76 | s.st_ctime = s.st_mtime 77 | s.st_atime = s.st_mtime 78 | 79 | return s 80 | 81 | def addsValue(self, items): 82 | return True 83 | 84 | def _addsValue(self, child): 85 | return True 86 | 87 | @property 88 | @cache 89 | def entries(self): 90 | return dict([[e.name, e] for e in self._entries if self._addsValue(e)]) 91 | -------------------------------------------------------------------------------- /src/modules/tagfs/config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009, 2010, 2012 Markus Pielmeier 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | 21 | import ConfigParser 22 | import logging 23 | import os 24 | 25 | def parseConfig(itemsDir): 26 | config = ConfigParser.SafeConfigParser({ 27 | 'tagFileName': '.tag', 28 | 'enableValueFilters': 'False', 29 | 'enableRootItemLinks': 'False', 30 | }) 31 | config.add_section(Config.GLOBAL_SECTION) 32 | 33 | parsedFiles = config.read([os.path.join('/', 'etc', 'tagfs', 'tagfs.conf'), 34 | os.path.expanduser(os.path.join('~', '.tagfs', 'tagfs.conf')), 35 | os.path.join(itemsDir, '.tagfs', 'tagfs.conf'), 36 | ]) 37 | 38 | logging.debug('Parsed the following config files: %s' % ', '.join(parsedFiles)) 39 | 40 | return Config(config) 41 | 42 | class Config(object): 43 | 44 | GLOBAL_SECTION = 'global' 45 | 46 | def __init__(self, _config): 47 | self._config = _config 48 | 49 | @property 50 | def tagFileName(self): 51 | return self._config.get(Config.GLOBAL_SECTION, 'tagFileName') 52 | 53 | @property 54 | def enableValueFilters(self): 55 | return self._config.getboolean(Config.GLOBAL_SECTION, 'enableValueFilters') 56 | 57 | @property 58 | def enableRootItemLinks(self): 59 | return self._config.getboolean(Config.GLOBAL_SECTION, 'enableRootItemLinks') 60 | 61 | def __str__(self): 62 | #return '[' + ', '.join([field + ': ' + str(self.__dict__[field]) for field in ['tagFileName', 'enableValueFilters', 'enableRootItemLinks']]) + ']' 63 | return '[tagFileName: %s, enableValueFilters: %s, enableRootItemLinks: %s]' % (self.tagFileName, self.enableValueFilters, self.enableRootItemLinks) 64 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_export_chart.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2013 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from cache import cache 21 | from node_file import FileNode 22 | import pylab 23 | import cStringIO 24 | 25 | class ChartImageNode(FileNode): 26 | 27 | def __init__(self, itemAccess, parentNode, context, title, transform): 28 | self.itemAccess = itemAccess 29 | self.parentNode = parentNode 30 | self.context = context 31 | self.title = title 32 | self.transform = transform 33 | 34 | @property 35 | def name(self): 36 | return '%s-%s.png' % (self.title, self.context,) 37 | 38 | @property 39 | def items(self): 40 | return self.parentNode.items 41 | 42 | @property 43 | @cache 44 | def content(self): 45 | pylab.clf() 46 | 47 | xValues = [] 48 | yValues = [] 49 | 50 | for x, item in enumerate(sorted(self.items, key = lambda item: item.name)): 51 | for tag in item.tags: 52 | c = tag.context 53 | 54 | if(c != self.context): 55 | continue 56 | 57 | try: 58 | y = float(tag.value) 59 | except: 60 | y = None 61 | 62 | if(y is None): 63 | try: 64 | # some love for our german people 65 | y = float(tag.value.replace('.', '').replace(',', '.')) 66 | except: 67 | continue 68 | 69 | xValues.append(x) 70 | yValues.append(self.transform(y)) 71 | 72 | pylab.plot(xValues, yValues, label = self.context) 73 | 74 | pylab.grid(True) 75 | 76 | out = cStringIO.StringIO() 77 | 78 | pylab.savefig(out, format = 'png') 79 | 80 | return out.getvalue() 81 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_export_csv.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from cache import cache 21 | from node_file import FileNode 22 | 23 | class ExportCsvFileNode(FileNode): 24 | 25 | COL_SEPARATOR = ';' 26 | 27 | TEXT_CHAR = '"' 28 | 29 | ROW_SEPARATOR = '\n' 30 | 31 | TAG_VALUE_SEPARATOR = '\n' 32 | 33 | def __init__(self, itemAccess, parentNode): 34 | self.itemAccess = itemAccess 35 | self.parentNode = parentNode 36 | 37 | @property 38 | def name(self): 39 | return 'export.csv' 40 | 41 | @property 42 | def items(self): 43 | return self.parentNode.items 44 | 45 | def formatRow(self, row): 46 | first = True 47 | 48 | for col in row: 49 | if first: 50 | first = False 51 | else: 52 | yield ExportCsvFileNode.COL_SEPARATOR 53 | 54 | # TODO escape TEXT_CHAR in col string 55 | yield ExportCsvFileNode.TEXT_CHAR 56 | yield str(col) 57 | yield ExportCsvFileNode.TEXT_CHAR 58 | 59 | yield ExportCsvFileNode.ROW_SEPARATOR 60 | 61 | @property 62 | def _content(self): 63 | contexts = set() 64 | for i in self.items: 65 | for t in i.tags: 66 | contexts.add(t.context) 67 | 68 | headline = ['name', ] 69 | for c in contexts: 70 | headline.append(c) 71 | for s in self.formatRow(headline): 72 | yield s 73 | 74 | for i in self.items: 75 | row = [i.name, ] 76 | 77 | for c in contexts: 78 | row.append(ExportCsvFileNode.TAG_VALUE_SEPARATOR.join([t.value for t in i.getTagsByContext(c)])) 79 | 80 | for s in self.formatRow(row): 81 | yield s 82 | 83 | @property 84 | @cache 85 | def content(self): 86 | return ''.join(self._content) 87 | -------------------------------------------------------------------------------- /src/modules/tagfs/transient_dict.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | class TransientDict(object): 21 | 22 | class Version(object): 23 | 24 | def __init__(self, key): 25 | self.key = key 26 | 27 | def touch(self, version): 28 | self.version = version 29 | 30 | class Value(object): 31 | 32 | def __init__(self, value, version): 33 | self.value = value 34 | self.version = version 35 | 36 | def __init__(self, averageCapacity): 37 | self.averageCapacity = averageCapacity 38 | self.nextVersion = 0 39 | self.setCounter = 0 40 | self.data = {} 41 | self.versions = [] 42 | 43 | def __getitem__(self, k): 44 | v = self.data[k] 45 | 46 | if not v: 47 | return None 48 | 49 | v.version.touch(self.nextVersion) 50 | self.nextVersion += 1 51 | 52 | return v.value 53 | 54 | def _cleanUpCache(self): 55 | if len(self.data) < self.averageCapacity: 56 | return 57 | 58 | def versionCmp(a, b): 59 | if a.version < b.version: 60 | return 1 61 | if b.version < a.version: 62 | return -1 63 | 64 | return 0 65 | 66 | self.versions.sort(versionCmp) 67 | 68 | while len(self.versions) > self.averageCapacity: 69 | version = self.versions.pop() 70 | 71 | self.data.pop(version.key) 72 | 73 | def __setitem__(self, k, v): 74 | if k in self.data: 75 | value = self.data[k] 76 | 77 | value.value = v 78 | else: 79 | self.setCounter += 1 80 | if self.setCounter % self.averageCapacity == 0: 81 | self._cleanUpCache() 82 | 83 | version = TransientDict.Version(k) 84 | self.versions.append(version) 85 | 86 | value = TransientDict.Value(v, version) 87 | self.data[k] = value 88 | 89 | value.version.touch(self.nextVersion) 90 | self.nextVersion += 1 91 | 92 | def __contains__(self, k): 93 | return k in self.data 94 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_root_directory_node.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from unittest import TestCase 21 | 22 | from tagfs.node_root import RootDirectoryNode 23 | 24 | from tagfs_test.node_asserter import validateDirectoryInterface, validateLinkInterface 25 | from tagfs_test.item_access_mock import ItemAccessMock 26 | from tagfs_test.item_mock import createItemMocks 27 | 28 | class ConfigMock(object): 29 | 30 | @property 31 | def enableValueFilters(self): 32 | return False 33 | 34 | @property 35 | def enableRootItemLinks(self): 36 | return True 37 | 38 | class AbstractRootDirectoryNodeTest(TestCase): 39 | 40 | @property 41 | def _itemNames(self): 42 | return self._taggedItemNames 43 | 44 | def setUp(self): 45 | self._taggedItemNames = ['item1'] 46 | 47 | self.itemAccess = ItemAccessMock() 48 | self.itemAccess.taggedItems = createItemMocks(self._itemNames) 49 | 50 | self.config = ConfigMock() 51 | 52 | self.node = RootDirectoryNode(self.itemAccess, self.config) 53 | 54 | class TestRootDirectoryNode(AbstractRootDirectoryNodeTest): 55 | 56 | @property 57 | def _itemNames(self): 58 | return self._taggedItemNames + ['.untagged'] 59 | 60 | def testNodeAttrMTimeIsItemAccessParseTime(self): 61 | attr = self.node.attr 62 | 63 | self.assertEqual(self.itemAccess.parseTime, attr.st_mtime) 64 | 65 | def testNodeIsDirectory(self): 66 | validateDirectoryInterface(self, self.node) 67 | 68 | def testItemLinksReplaceUntaggedDirectory(self): 69 | untaggedNode = self.node.entries['.untagged'] 70 | 71 | # untagged node must be a link as the untagged directory node 72 | # weights less than the '.untagged' item from the tagged items. 73 | validateLinkInterface(self, untaggedNode) 74 | 75 | def testNodeContainerContainsTaggedNodeLinks(self): 76 | entries = self.node.entries 77 | 78 | for itemName in self._taggedItemNames: 79 | self.assertTrue(itemName in entries) 80 | 81 | validateLinkInterface(self, entries[itemName]) 82 | 83 | class TestRootDirectoryNodeUntaggedDirectory(AbstractRootDirectoryNodeTest): 84 | 85 | def testNodeContainsUntaggedDirectory(self): 86 | untaggedNode = self.node.entries['.untagged'] 87 | 88 | validateDirectoryInterface(self, untaggedNode) 89 | -------------------------------------------------------------------------------- /src/test/tagfs_test_small/test_filter_context_value_filter_directory_node.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from unittest import TestCase 21 | 22 | from tagfs.node_filter_context import ContextValueFilterDirectoryNode 23 | 24 | from tagfs_test.node_asserter import validateDirectoryInterface, validateLinkInterface 25 | from tagfs_test.item_access_mock import ItemAccessMock 26 | from tagfs_test.item_mock import ItemMock 27 | 28 | class TagMock(object): 29 | 30 | def __init__(self, context, value): 31 | self.context = context 32 | self.value = value 33 | 34 | class TaggedItemMock(ItemMock): 35 | 36 | def __init__(self, name, context, value): 37 | super(TaggedItemMock, self).__init__(name, [TagMock(context, value), ]) 38 | 39 | self._context = context 40 | self._value = value 41 | 42 | def isTaggedWithContext(self, context): 43 | return self._context == context 44 | 45 | def isTaggedWithContextValue(self, context, value): 46 | return self._context == context and self._value == value 47 | 48 | def getTagsByContext(self, context): 49 | if(context == self._context): 50 | return self.tags 51 | else: 52 | return [] 53 | 54 | class ParentNodeMock(object): 55 | 56 | def __init__(self, items): 57 | self.items = items 58 | 59 | class ConfigMock(object): 60 | 61 | @property 62 | def enableValueFilters(self): 63 | return False 64 | 65 | class TestContextValueFilterDirectoryNode(TestCase): 66 | 67 | def setUp(self): 68 | self.context = 'c1' 69 | self.value = 'v1' 70 | 71 | self.itemAccess = ItemAccessMock() 72 | self.itemAccess.taggedItems = [TaggedItemMock('item1', self.context, self.value), ] 73 | 74 | self.config = ConfigMock() 75 | 76 | self.parentNode = ParentNodeMock(self.itemAccess.taggedItems) 77 | self.node = ContextValueFilterDirectoryNode(self.itemAccess, self.config, self.parentNode, self.context, self.value) 78 | 79 | def testNodeAttrMTimeIsItemAccessParseTime(self): 80 | attr = self.node.attr 81 | 82 | self.assertEqual(self.itemAccess.parseTime, attr.st_mtime) 83 | 84 | def testNodeIsDirectory(self): 85 | validateDirectoryInterface(self, self.node) 86 | 87 | def testMatchingItemIsAvailableAsLink(self): 88 | e = self.node.entries['item1'] 89 | 90 | validateLinkInterface(self, e) 91 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2009, 2010 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | prefix = /usr/local 21 | bindir = $(prefix)/bin 22 | docdir = $(prefix)/share/doc/tagfs 23 | installdirs = $(bindir) $(docdir) 24 | 25 | srcdir = . 26 | targetdir = $(srcdir)/target 27 | 28 | testdatadir = $(srcdir)/etc/test/events 29 | testmntdir = $(shell pwd)/mnt 30 | 31 | pymoddir = $(srcdir)/src/modules 32 | 33 | PYTHON = python 34 | INSTALL = install 35 | INSTALL_DATA = $(INSTALL) -m 644 36 | INSTALL_PROGRAM = $(INSTALL) 37 | 38 | DOCS = AUTHORS COPYING README VERSION 39 | 40 | VERSION = `cat VERSION` 41 | TSTAMP = `date '+%Y%m%d_%H%M'` 42 | 43 | .PHONY: all 44 | all: 45 | @echo "42. That's all." 46 | @echo "Try 'make mounttest' for something more interesting." 47 | 48 | .PHONY: clean 49 | clean: 50 | find $(srcdir) -name '*.pyc' -type f -exec rm {} \; 51 | @if test "`mount | grep -e 'tagfs.*on.*$(testmntdir)'`"; then \ 52 | echo "tagfs mounted on '$(testmntdir)' -- keeping it."; \ 53 | elif test -d '$(testmntdir)'; then \ 54 | echo 'removing $(testmntdir)'; \ 55 | rmdir '$(testmntdir)'; \ 56 | fi 57 | 58 | rm -r -- "$(targetdir)" 59 | 60 | .PHONY: test 61 | test: 62 | $(PYTHON) $(srcdir)/test/test_all.py 63 | 64 | $(installdirs): 65 | $(INSTALL) -d $(installdirs) 66 | 67 | .PHONY: install 68 | install: $(installdirs) 69 | $(INSTALL_PROGRAM) $(srcdir)/src/tagfs $(bindir)/tagfs 70 | $(INSTALL_DATA) $(DOCS) $(docdir) 71 | 72 | .PHONY: uninstall 73 | uninstall: 74 | rm -- $(bindir)/tagfs 75 | rm -r -- $(docdir) 76 | 77 | $(testmntdir): 78 | mkdir -p $@ 79 | 80 | .PHONY: mounttest 81 | mounttest: $(testmntdir) 82 | PYTHONPATH=$(pymoddir):$(PYTHONPATH) \ 83 | $(PYTHON) $(srcdir)/src/bin/tagfs -i $(testdatadir) $(testmntdir) 84 | 85 | .PHONY: unmounttest 86 | unmounttest: 87 | fusermount -u $(testmntdir) 88 | rmdir -- $(testmntdir) 89 | 90 | .PHONY: umounttest 91 | umounttest: unmounttest 92 | 93 | .PHONY: mt 94 | mt: mounttest 95 | 96 | .PHONY: umt 97 | umt: unmounttest 98 | 99 | .PHONY: distsnapshot 100 | distsnapshot: 101 | mkdir -p -- "$(targetdir)/tagfs_$(VERSION)_snapshot_$(TSTAMP)" 102 | 103 | cp -a $(DOCS) etc src test util setup.py README.dev Makefile "$(targetdir)/tagfs_$(VERSION)_snapshot_$(TSTAMP)" 104 | 105 | tar cjf $(targetdir)/tagfs_$(VERSION)_snapshot_$(TSTAMP)-src.tar.bz2 '--exclude=*~' '--exclude=*.pyc' -C "$(targetdir)" "tagfs_$(VERSION)_snapshot_$(TSTAMP)" 106 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_filter_any_context.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from cache import cache 21 | from node import Stat, ItemLinkNode, DirectoryNode 22 | from node_filter import FilterDirectoryNode 23 | from node_untagged_items import UntaggedItemsDirectoryNode 24 | 25 | class AnyContextValueFilterDirectoryNode(FilterDirectoryNode): 26 | 27 | def __init__(self, itemAccess, config, parentNode, value): 28 | super(AnyContextValueFilterDirectoryNode, self).__init__(itemAccess, config) 29 | self.parentNode = parentNode 30 | self.value = value 31 | 32 | @property 33 | def name(self): 34 | return self.value 35 | 36 | @property 37 | def items(self): 38 | for item in self.parentNode.items: 39 | if not item.isTaggedWithValue(self.value): 40 | continue 41 | 42 | yield item 43 | 44 | class AnyContextValueListDirectoryNode(DirectoryNode): 45 | 46 | def __init__(self, itemAccess, config, parentNode): 47 | self.itemAccess = itemAccess 48 | self.config = config 49 | self.parentNode = parentNode 50 | 51 | @property 52 | def name(self): 53 | return '.any_context' 54 | 55 | @property 56 | def attr(self): 57 | s = super(AnyContextValueListDirectoryNode, self).attr 58 | 59 | # TODO why nlink == 2? 60 | s.st_nlink = 2 61 | 62 | # TODO write test case which tests st_mtime == itemAccess.parseTime 63 | s.st_mtime = self.itemAccess.parseTime 64 | s.st_ctime = s.st_mtime 65 | s.st_atime = s.st_mtime 66 | 67 | return s 68 | 69 | @property 70 | def items(self): 71 | return self.parentNode.items 72 | 73 | @property 74 | def contextValues(self): 75 | values = set() 76 | 77 | for item in self.parentNode.items: 78 | for v in item.values: 79 | values.add(v) 80 | 81 | return values 82 | 83 | @property 84 | def _entries(self): 85 | for value in self.contextValues: 86 | yield AnyContextValueFilterDirectoryNode(self.itemAccess, self.config, self, value) 87 | 88 | def addsValue(self, parentItems): 89 | if(super(AnyContextValueListDirectoryNode, self).addsValue(parentItems)): 90 | return True 91 | 92 | for e in self._entries: 93 | if(e.addsValue(parentItems)): 94 | return True 95 | 96 | return False 97 | -------------------------------------------------------------------------------- /README.dev: -------------------------------------------------------------------------------- 1 | tagfs - tag file system 2 | developer readme 3 | 4 | 1) Roadmap 5 | 2) Logging 6 | 3) Profiling 7 | 4) Tracing 8 | 5) Distribution 9 | 5.1) tar Distribution 10 | 6) Tests 11 | 7) Code Coverage 12 | 8) End-To-End Tests 13 | 14 | 15 | --------------------------------------------------------------------- 16 | Roadmap 17 | 18 | The upcomming tagfs features are listed in the 'backlog' file. The file is 19 | best viewed using emacs org-mode. 20 | 21 | 22 | --------------------------------------------------------------------- 23 | Logging 24 | 25 | You can enable logging by setting a debug environment variable before you 26 | launch tagfs: 27 | $ export DEBUG=1 28 | 29 | tagfs will log to the console and the file /tmp/tagfs.log 30 | 31 | 32 | --------------------------------------------------------------------- 33 | Profiling 34 | 35 | You can enable profiling by setting a profile environment variable before you 36 | launch tagfs: 37 | $ export PROFILE=1 38 | 39 | After unmounting your tagfs file system a profile file will be written. The 40 | profile file will be written to the current directory. The profile file will 41 | be named 'tagfs.profile'. 42 | 43 | 44 | --------------------------------------------------------------------- 45 | Tracing 46 | 47 | Tracing is done via the log output. There is a utility script to analyze the 48 | log files. To analyze a log file execute the following 49 | 50 | $ util/trace_logfiles.py /tmp/tagfs.log 51 | 52 | The tracing script will output some statistics. 53 | 54 | 55 | --------------------------------------------------------------------- 56 | tar Distribution 57 | 58 | The tagfs project contains scripts for creating source distribution packages. 59 | To create a tar distribution package you execute the following: 60 | 61 | $ make distsnapshot 62 | 63 | The make call will create an archive within the target directory. The created 64 | tar file is used for tagfs source distribution. 65 | 66 | 67 | --------------------------------------------------------------------- 68 | Tests 69 | 70 | You can execute the test cases via the setup.py script in the project's root 71 | directory. 72 | 73 | $ python setup.py test 74 | 75 | 76 | --------------------------------------------------------------------- 77 | Code Coverage 78 | 79 | The tagfs unit tests can be executed with code coverage measurement enabled. 80 | setup.py will measure the code coverage if the coverage lib is installed. 81 | 82 | The coverage lib is available here: http://nedbatchelder.com/code/coverage 83 | 84 | If you're a debian user you can try: 85 | $ apt-get install python-coverage 86 | 87 | The code coverage will be written below the reports directory after executing 88 | the test cases: 89 | $ python setup.py test 90 | 91 | 92 | --------------------------------------------------------------------- 93 | End-To-End Tests 94 | 95 | tagfs contains some end-to-end tests. The end-to-end tests first mount an 96 | items directory and afterwards execute a shell script which can assert certain 97 | conditions in the mounted tagfs. 98 | 99 | The end-to-end tests can be run via the setup.py: 100 | 101 | $ python setup.py e2e_test 102 | 103 | The end-to-end tests are located below the test/e2e directory. 104 | -------------------------------------------------------------------------------- /src/modules/tagfs/cache.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009 Markus Pielmeier 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | 21 | import time 22 | import functools 23 | 24 | class NoCacheStrategy(object): 25 | """This cache strategy reloads the cache on every call. 26 | """ 27 | 28 | def isCacheValid(self, f, *args, **kwargs): 29 | return False 30 | 31 | class NoReloadStrategy(object): 32 | """This cache strategy never reloads the cache. 33 | """ 34 | 35 | def isCacheValid(self, f, *args, **kwargs): 36 | return True 37 | 38 | class TimeoutReloadStrategy(object): 39 | 40 | def __init__(self, timeoutDuration = 10 * 60): 41 | self.timeoutDuration = timeoutDuration 42 | 43 | def isCacheValid(self, f, *args, **kwargs): 44 | obj = args[0] 45 | 46 | timestampFieldName = '__' + f.__name__ + 'Timestamp' 47 | now = time.time() 48 | 49 | if not hasattr(obj, timestampFieldName): 50 | setattr(obj, timestampFieldName, now) 51 | 52 | return False 53 | 54 | lastTime = getattr(obj, timestampFieldName) 55 | 56 | if now - lastTime < self.timeoutDuration: 57 | return True 58 | 59 | setattr(obj, timestampFieldName, now) 60 | 61 | return False 62 | 63 | 64 | def cache(f, reloadStrategy = NoReloadStrategy()): 65 | """This annotation is used to cache the result of a method call. 66 | 67 | @param f: This is the wrapped function which's return value will be cached. 68 | @param reload: This is the reload strategy. This function returns True when 69 | the cache should be reloaded. Otherwise False. 70 | @attention: The cache is never deleted. The first call initializes the 71 | cache. The method's parameters just passed to the called method. The cache 72 | is not evaluating the parameters. 73 | """ 74 | 75 | @functools.wraps(f) 76 | def cacher(*args, **kwargs): 77 | obj = args[0] 78 | 79 | cacheMemberName = '__' + f.__name__ + 'Cache' 80 | 81 | # the reload(...) call has to be first as we always have to call the 82 | # method. not only when there is a cache member available in the object. 83 | if (not reloadStrategy.isCacheValid(f, *args, **kwargs)) or (not hasattr(obj, cacheMemberName)): 84 | value = f(*args, **kwargs) 85 | 86 | setattr(obj, cacheMemberName, value) 87 | 88 | return value 89 | 90 | return getattr(obj, cacheMemberName) 91 | 92 | return cacher 93 | 94 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_filter.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from cache import cache 21 | from node import Stat, ItemLinkNode, DirectoryNode 22 | from node_export import ExportDirectoryNode 23 | 24 | class FilterDirectoryNode(DirectoryNode): 25 | 26 | def __init__(self, itemAccess, config): 27 | self.itemAccess = itemAccess 28 | self.config = config 29 | 30 | @property 31 | def attr(self): 32 | s = super(FilterDirectoryNode, self).attr 33 | 34 | # TODO why nlink == 2? 35 | s.st_nlink = 2 36 | 37 | # TODO write test case which tests st_mtime == itemAccess.parseTime 38 | s.st_mtime = self.itemAccess.parseTime 39 | s.st_ctime = s.st_mtime 40 | s.st_atime = s.st_mtime 41 | 42 | return s 43 | 44 | @property 45 | def contexts(self): 46 | c = set() 47 | 48 | for item in self.items: 49 | for t in item.tags: 50 | context = t.context 51 | 52 | if context is None: 53 | continue 54 | 55 | c.add(context) 56 | 57 | return c 58 | 59 | @property 60 | def _enableItemLinks(self): 61 | return True 62 | 63 | @property 64 | def _entries(self): 65 | # the import is not global because we want to prevent a cyclic 66 | # dependency (ugly but works) 67 | from node_filter_context import ContextValueListDirectoryNode 68 | from node_filter_value import ValueFilterDirectoryNode 69 | from node_filter_any_context import AnyContextValueListDirectoryNode 70 | 71 | yield ExportDirectoryNode(self.itemAccess, self) 72 | 73 | yield AnyContextValueListDirectoryNode(self.itemAccess, self.config, self) 74 | 75 | if(self.config.enableValueFilters): 76 | for value in self.itemAccess.values: 77 | yield ValueFilterDirectoryNode(self.itemAccess, self.config, self, value) 78 | 79 | for context in self.contexts: 80 | yield ContextValueListDirectoryNode(self.itemAccess, self.config, self, context) 81 | 82 | if(self._enableItemLinks): 83 | for item in self.items: 84 | yield ItemLinkNode(item) 85 | 86 | def addsValue(self, parentItems): 87 | itemsLen = len(list(self.items)) 88 | if(itemsLen == 0): 89 | return False 90 | 91 | # TODO we should not compare the lengths but whether the child and 92 | # parent items are different 93 | parentItemsLen = len(list(parentItems)) 94 | 95 | return itemsLen != parentItemsLen 96 | 97 | def _addsValue(self, child): 98 | return child.addsValue(self.items) 99 | -------------------------------------------------------------------------------- /src/modules/tagfs/freebase_support.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import json 20 | import logging 21 | 22 | def createFreebaseAdapter(): 23 | # freebase is an optional dependency. tagfs should execute even if it's not 24 | # available. 25 | try: 26 | import freebase 27 | 28 | logging.info('freebase support enabled') 29 | 30 | return FreebaseAdapter() 31 | except ImportError: 32 | logging.warn('freebase support disabled') 33 | 34 | return FreebaseAdapterStub() 35 | 36 | class FreebaseAdapterStub(object): 37 | 38 | def execute(self, *args, **kwargs): 39 | return {} 40 | 41 | class FreebaseAdapter(object): 42 | 43 | def execute(self, query): 44 | import freebase 45 | 46 | fbResult = freebase.mqlread(query.freebaseQuery) 47 | 48 | result = {} 49 | 50 | for key in query.selectedKeys: 51 | result[key] = fbResult[key] 52 | 53 | return result 54 | 55 | class Query(object): 56 | 57 | def __init__(self, queryObject): 58 | self.queryObject = queryObject 59 | 60 | @property 61 | def freebaseQuery(self): 62 | q = {} 63 | 64 | for key, value in self.queryObject.iteritems(): 65 | if(value is None): 66 | q[key] = [] 67 | else: 68 | q[key] = value 69 | 70 | return q 71 | 72 | @property 73 | def queryString(self): 74 | # TODO this func is only used in tests => remove 75 | return json.dumps(self.freebaseQuery, separators = (',', ':')) 76 | 77 | @property 78 | def selectedKeys(self): 79 | for key, value in self.queryObject.iteritems(): 80 | if(value is None): 81 | yield key 82 | 83 | class QueryParser(object): 84 | 85 | def parse(self, queryString): 86 | return Query(json.loads(queryString)) 87 | 88 | class QueryFileParser(object): 89 | 90 | def __init__(self, system, queryParser): 91 | self.system = system 92 | self.queryParser = queryParser 93 | 94 | def parseFile(self, path): 95 | with self.system.open(path, 'r') as f: 96 | for line in f: 97 | yield self.queryParser.parse(line) 98 | 99 | class GenericQueryFactory(object): 100 | 101 | def __init__(self, resolveVar): 102 | self.resolveVar = resolveVar 103 | 104 | def evaluate(self, value): 105 | if(value is None): 106 | return None 107 | 108 | valueLen = len(value) 109 | 110 | if(valueLen < 2): 111 | return value 112 | 113 | if(value[0] != '$'): 114 | return value 115 | 116 | key = value[1:] 117 | 118 | return self.resolveVar(key) 119 | 120 | def createQuery(self, genericQuery): 121 | q = {} 122 | 123 | for key, genericValue in genericQuery.iteritems(): 124 | value = self.evaluate(genericValue) 125 | 126 | q[key] = value 127 | 128 | return q 129 | -------------------------------------------------------------------------------- /src/modules/tagfs/node_filter_context.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | # 19 | 20 | from cache import cache 21 | from node import Stat, ItemLinkNode, DirectoryNode 22 | from node_filter import FilterDirectoryNode 23 | from node_untagged_items import UntaggedItemsDirectoryNode 24 | 25 | class ContextValueFilterDirectoryNode(FilterDirectoryNode): 26 | 27 | def __init__(self, itemAccess, config, parentNode, context, value): 28 | super(ContextValueFilterDirectoryNode, self).__init__(itemAccess, config) 29 | self.parentNode = parentNode 30 | self.context = context 31 | self.value = value 32 | 33 | @property 34 | def name(self): 35 | return self.value 36 | 37 | @property 38 | def items(self): 39 | for item in self.parentNode.items: 40 | if not item.isTaggedWithContextValue(self.context, self.value): 41 | continue 42 | 43 | yield item 44 | 45 | class UnsetContextFilterDirectoryNode(FilterDirectoryNode): 46 | 47 | def __init__(self, itemAccess, config, parentNode, context): 48 | super(UnsetContextFilterDirectoryNode, self).__init__(itemAccess, config) 49 | self.parentNode = parentNode 50 | self.context = context 51 | 52 | @property 53 | def name(self): 54 | return '.unset' 55 | 56 | @property 57 | def items(self): 58 | for item in self.parentNode.parentNode.items: 59 | if item.isTaggedWithContext(self.context): 60 | continue 61 | 62 | yield item 63 | 64 | class ContextValueListDirectoryNode(DirectoryNode): 65 | 66 | def __init__(self, itemAccess, config, parentNode, context): 67 | self.itemAccess = itemAccess 68 | self.config = config 69 | self.parentNode = parentNode 70 | self.context = context 71 | 72 | @property 73 | def name(self): 74 | return self.context 75 | 76 | @property 77 | def attr(self): 78 | s = super(ContextValueListDirectoryNode, self).attr 79 | 80 | # TODO why nlink == 2? 81 | s.st_nlink = 2 82 | 83 | # TODO write test case which tests st_mtime == itemAccess.parseTime 84 | s.st_mtime = self.itemAccess.parseTime 85 | s.st_ctime = s.st_mtime 86 | s.st_atime = s.st_mtime 87 | 88 | return s 89 | 90 | @property 91 | def items(self): 92 | for item in self.parentNode.items: 93 | if not item.isTaggedWithContext(self.context): 94 | continue 95 | 96 | yield item 97 | 98 | @property 99 | def contextValues(self): 100 | values = set() 101 | 102 | for item in self.parentNode.items: 103 | for tag in item.getTagsByContext(self.context): 104 | values.add(tag.value) 105 | 106 | return values 107 | 108 | @property 109 | def _entries(self): 110 | yield UnsetContextFilterDirectoryNode(self.itemAccess, self.config, self, self.context) 111 | 112 | for value in self.contextValues: 113 | yield ContextValueFilterDirectoryNode(self.itemAccess, self.config, self, self.context, value) 114 | 115 | def addsValue(self, parentItems): 116 | for e in self._entries: 117 | if(e.addsValue(parentItems)): 118 | return True 119 | 120 | return False 121 | -------------------------------------------------------------------------------- /util/trace_logfiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2010 Markus Pielmeier 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | 21 | import logging 22 | import re 23 | 24 | class TraceLogEntry(object): 25 | 26 | def __init__(self, context, path): 27 | self.context = context 28 | self.path = path 29 | 30 | class TraceLog(object): 31 | 32 | LINE_BUFFER_SIZE = 100000 33 | 34 | TRACE_PATTERN = re.compile('[0-9\-,: ]+DEBUG (readlink|getattr|readdir) (.*)$') 35 | 36 | def __init__(self): 37 | self.entries = [] 38 | 39 | def _readLogLine(self, line): 40 | m = TraceLog.TRACE_PATTERN.match(line) 41 | 42 | if not m: 43 | return 44 | 45 | context = m.group(1) 46 | path = m.group(2) 47 | 48 | self.entries.append(TraceLogEntry(context, path)) 49 | 50 | def readLogFile(self, fileName): 51 | logging.info('Reading logfile ' + fileName) 52 | 53 | f = open(fileName) 54 | 55 | while True: 56 | lines = f.readlines(TraceLog.LINE_BUFFER_SIZE) 57 | if not lines: 58 | break; 59 | 60 | for line in lines: 61 | self._readLogLine(line) 62 | 63 | class TraceResult(object): 64 | 65 | def __init__(self): 66 | self.contextHistogram = {} 67 | self.contextPathHistogram = {} 68 | 69 | def _analyzeContextHistogram(self, traceLog): 70 | for e in traceLog.entries: 71 | if not e.context in self.contextHistogram: 72 | self.contextHistogram[e.context] = 0 73 | 74 | self.contextHistogram[e.context] += 1 75 | 76 | def _analyzeContextPathHistogram(self, traceLog): 77 | for e in traceLog.entries: 78 | if not e.context in self.contextPathHistogram: 79 | self.contextPathHistogram[e.context] = {} 80 | 81 | ph = self.contextPathHistogram[e.context] 82 | 83 | if not e.path in ph: 84 | ph[e.path] = 0 85 | 86 | ph[e.path] += 1 87 | 88 | 89 | def _analyzeTraceLog(self, traceLog): 90 | self._analyzeContextHistogram(traceLog) 91 | self._analyzeContextPathHistogram(traceLog) 92 | 93 | def analyzeLogFile(self, fileName): 94 | tl = TraceLog() 95 | tl.readLogFile(fileName) 96 | 97 | self._analyzeTraceLog(tl) 98 | 99 | def usage(): 100 | # TODO print usage 101 | 102 | pass 103 | 104 | def writeCSV(fileName, pathHistogram): 105 | import csv 106 | 107 | w = csv.writer(open(fileName, 'w')) 108 | 109 | for path, histogram in pathHistogram.iteritems(): 110 | w.writerow([path, histogram]) 111 | 112 | if __name__ == '__main__': 113 | logging.basicConfig(level = logging.DEBUG) 114 | 115 | import getopt 116 | import sys 117 | 118 | try: 119 | opts, args = getopt.getopt(sys.argv[1:], "", []) 120 | except getopt.GetoptError: 121 | usage() 122 | 123 | sys.exit(1) 124 | 125 | for opt, arg in opts: 126 | if opt in ("-h", "--help"): 127 | usage() 128 | sys.exit() 129 | 130 | tr = TraceResult() 131 | 132 | for fileName in args: 133 | tr.analyzeLogFile(fileName) 134 | 135 | print "Context Histogram" 136 | for context, calls in tr.contextHistogram.iteritems(): 137 | print ' %s: %s' % (context, calls) 138 | 139 | for context, pathHistogram in tr.contextPathHistogram.iteritems(): 140 | writeCSV('pathHistogram_' + context + '.csv', pathHistogram) 141 | -------------------------------------------------------------------------------- /src/modules/tagfs/view.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009, 2010 Markus Pielmeier 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | 21 | import errno 22 | import logging 23 | import os 24 | from log import logCall, logException 25 | from cache import cache 26 | from transient_dict import TransientDict 27 | from node_root import RootDirectoryNode 28 | from fuse import Direntry 29 | 30 | class View(object): 31 | """Abstraction layer from fuse API. 32 | 33 | This class is an abstraction layer from the fuse API. This should ease 34 | writing test cases for the file system. 35 | """ 36 | 37 | DEFAULT_NODES = { 38 | # directory icons for rox filer 39 | '.DirIcon': None, 40 | 41 | # launch script for rox filer application directories 42 | 'AppRun': None 43 | } 44 | 45 | def __init__(self, itemAccess, config): 46 | self.itemAccess = itemAccess 47 | self.config = config 48 | self._entryCache = TransientDict(100) 49 | 50 | @property 51 | @cache 52 | def rootNode(self): 53 | return RootDirectoryNode(self.itemAccess, self.config) 54 | 55 | def getNode(self, path): 56 | if path in self._entryCache: 57 | # simple path name based caching is implemented here 58 | 59 | logging.debug('tagfs _entryCache hit') 60 | 61 | return self._entryCache[path] 62 | 63 | # ps contains the path segments 64 | ps = [x for x in os.path.normpath(path).split(os.sep) if x != ''] 65 | 66 | psLen = len(ps) 67 | if psLen > 0: 68 | lastSegment = ps[psLen - 1] 69 | 70 | if lastSegment in View.DEFAULT_NODES: 71 | logging.debug('Using default node for path ' + path) 72 | 73 | return View.DEFAULT_NODES[lastSegment] 74 | 75 | e = self.rootNode 76 | 77 | for pe in path.split('/')[1:]: 78 | if pe == '': 79 | continue 80 | 81 | entries = e.entries 82 | 83 | if not pe in entries: 84 | # it seems like we are trying to fetch a node for an illegal 85 | # path 86 | 87 | return None 88 | 89 | e = entries[pe] 90 | 91 | logging.debug('tagfs _entryCache miss') 92 | self._entryCache[path] = e 93 | 94 | return e 95 | 96 | @logCall 97 | def getattr(self, path): 98 | e = self.getNode(path) 99 | 100 | if not e: 101 | logging.debug('Try to read attributes from not existing node: ' + path) 102 | 103 | return -errno.ENOENT 104 | 105 | return e.attr 106 | 107 | @logCall 108 | def readdir(self, path, offset): 109 | e = self.getNode(path) 110 | 111 | if not e: 112 | logging.warn('Try to read not existing directory: ' + path) 113 | 114 | return -errno.ENOENT 115 | 116 | # TODO care about offset parameter 117 | 118 | return [Direntry(name) for name in e.entries.iterkeys()] 119 | 120 | @logCall 121 | def readlink(self, path): 122 | n = self.getNode(path) 123 | 124 | if not n: 125 | logging.warn('Try to read not existing link from node: ' + path) 126 | 127 | return -errno.ENOENT 128 | 129 | return n.link 130 | 131 | @logCall 132 | def symlink(self, path, linkPath): 133 | linkPathSegs = linkPath.split('/') 134 | 135 | n = self.getNode('/'.join(linkPathSegs[0:len(linkPathSegs) - 2])) 136 | 137 | if not n: 138 | return -errno.ENOENT 139 | 140 | return n.symlink(path, linkPath) 141 | 142 | @logCall 143 | def open(self, path, flags): 144 | n = self.getNode(path) 145 | 146 | if not n: 147 | logging.warn('Try to open not existing node: ' + path) 148 | 149 | return -errno.ENOENT 150 | 151 | return n.open(path, flags) 152 | 153 | @logCall 154 | def read(self, path, len, offset): 155 | n = self.getNode(path) 156 | 157 | if not n: 158 | logging.warn('Try to read from not existing node: ' + path) 159 | 160 | return -errno.ENOENT 161 | 162 | return n.read(path, len, offset) 163 | 164 | @logCall 165 | def write(self, path, data, pos): 166 | n = self.getNode(path) 167 | 168 | if not n: 169 | logging.warn('Try to write to not existing node: ' + path) 170 | 171 | return -errno.ENOENT 172 | 173 | return n.write(path, data, pos) 174 | 175 | -------------------------------------------------------------------------------- /etc/demo/README: -------------------------------------------------------------------------------- 1 | The demo subdirectory contains the file structure for a little example. It shows 2 | what tagfs is doing and how you can use it. 3 | 4 | --------------------------------------------------------------------- 5 | tagfs is used to organize your documents using tags. tagfs requires you to 6 | keep your files in a simple directory structure. 7 | 8 | In our example we are organizing some holiday pictues from india and south korea. 9 | So we create two item directories below the events directory: 10 | * 2008-03-29 - holiday south korea 11 | * 2008-12-25 - holiday india 12 | 13 | The names of the item directories can be anything you want but it's recommended 14 | to add date timestamps. These timestamps allow you to have a look at your 15 | documents in a chronological order and prevent you from specifying duplicate 16 | names. For tagfs the timestamp is irrelevant. 17 | 18 | Now that we have created the item directories below the event directory we can 19 | tag them. To do so we add .tag files within them. And to make it more exciting 20 | we add some images which represent our documents. Then we have a directory 21 | structure like this: 22 | 23 | events/ 24 | |-- 2008-03-29 - holiday south korea 25 | | |-- .tag 26 | | `-- 00_IMG008.jpg 27 | `-- 2008-12-25 - holiday india 28 | |-- .tag 29 | `-- cimg1029.jpg 30 | 31 | In this example the directory structure below the item directories is flat. In 32 | the real world the content and directory structure below the item directories 33 | is not limited. Except that the tag file must be named .tag. 34 | 35 | As already mentioned the .tag files contain the tags. The .tag file for the 36 | south korea holiday looks like this: 37 | 38 | holiday 39 | airport 40 | korea 41 | 42 | As you can imagine we have applied three tags: holiday, airport and korea. The 43 | tags are newline separated and can contain spaces too. Empty lines are ignored. 44 | For the india holiday we use the following .tag file: 45 | 46 | holiday 47 | airport 48 | india 49 | 50 | Now that we have organized our documents and applied tags on them we can start 51 | to search for our data. To do so we first mount the tagfs. Open your bash, enter 52 | the demo directory and execute the following: 53 | 54 | $ tagfs.py -i events tags 55 | 56 | This will mount the tagfs below the tags directory. The event directory contains 57 | the item directories which will be parsed for tags. As a result you will get the 58 | following directory tree below the tags directory: 59 | 60 | tags/ 61 | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 62 | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 63 | |-- airport 64 | | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 65 | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 66 | | |-- holiday 67 | | | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 68 | | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 69 | | | |-- india 70 | | | | `-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 71 | | | `-- korea 72 | | | `-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 73 | | |-- india 74 | | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 75 | | | `-- holiday 76 | | | `-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 77 | | `-- korea 78 | | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 79 | | `-- holiday 80 | | `-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 81 | |-- holiday 82 | | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 83 | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 84 | | |-- airport 85 | | | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 86 | | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 87 | | | |-- india 88 | | | | `-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 89 | | | `-- korea 90 | | | `-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 91 | | |-- india 92 | | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 93 | | | `-- airport 94 | | | `-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 95 | | `-- korea 96 | | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 97 | | `-- airport 98 | | `-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 99 | |-- india 100 | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 101 | | |-- airport 102 | | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 103 | | | `-- holiday 104 | | | `-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 105 | | `-- holiday 106 | | |-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 107 | | `-- airport 108 | | `-- 2008-12-25 - holiday india -> /demo/events/2008-12-25 - holiday india 109 | `-- korea 110 | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 111 | |-- airport 112 | | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 113 | | `-- holiday 114 | | `-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 115 | `-- holiday 116 | |-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 117 | `-- airport 118 | `-- 2008-03-29 - holiday south korea -> /demo/events/2008-03-29 - holiday south korea 119 | 120 | OK... that's a lot! The idea behind the tagfs is a simple directory based filter 121 | system. If you want to see anything relevant for the tags india you type: 122 | 123 | $ ls -1 tags/india 124 | 125 | The output will be: 126 | 127 | 2008-12-25 - holiday india 128 | airport 129 | holiday 130 | 131 | The output will show you all item directories as links which are tagged with 132 | india. Additionally you will see all tags which can be further combined with 133 | india and show you further results. The tag korea is not shown as there would 134 | be no results if you filter by india and korea. 135 | 136 | Filtering for multiple tags at once can be done like this: 137 | 138 | $ ls -1 tags/india/holiday 139 | 140 | You will get the output: 141 | 142 | 2008-12-25 - holiday india 143 | airport 144 | 145 | I hope this explains the concept. Now it's your turn :-) Try tagfs yourself! 146 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | tagfs - tag file system 2 | 3 | 1) Introduction 4 | 2) Requirements 5 | 3) Installation 6 | 4) Tagging Files 7 | 5) Usage 8 | 6) Configuration 9 | 6.1) Options 10 | 6.1.1) tagFileName 11 | 6.1.2) enableValueFilters 12 | 6.1.3) enableRootItemLinks 13 | 7) Freebase Integration 14 | 8) Bugs 15 | 9) Further Reading 16 | 10) Contact 17 | 18 | 19 | --------------------------------------------------------------------- 20 | Introduction 21 | 22 | tagfs is used to organize your files using tags. 23 | 24 | This document contains basic usage instructions for users. To develop or debug 25 | tagfs see the README.dev file. 26 | 27 | 28 | --------------------------------------------------------------------- 29 | Requirements 30 | 31 | * python 2.5, 2.6, 2.7 32 | * Linux kernel with fuse enabled 33 | * python-fuse installed 34 | * python-matplotlib 35 | 36 | 37 | --------------------------------------------------------------------- 38 | Installation 39 | 40 | To install tagfs into your home directory type the following: 41 | 42 | $ python setup.py test e2e_test install --home ~/.local 43 | 44 | If you haven't already extended your local python path then add the following 45 | to your environment configuration script. For example to your ~/.bashrc: 46 | 47 | $ export PYTHONPATH=~/.local/lib/python:$PYTHONPATH 48 | 49 | You may also need to add ~/.local/bin to your PATH environment variable: 50 | 51 | $ export PATH=~/.local/bin:$PATH 52 | 53 | 54 | --------------------------------------------------------------------- 55 | Tagging Files 56 | 57 | Before you can filter anything using tagfs you need to tag your items. An item 58 | is a directory which contains a file called .tag. All items must be below one 59 | directory. 60 | 61 | Let's create a simple item structure. 62 | 63 | First we create the root directory for all items: 64 | $ mkdir items 65 | 66 | Then we create our first item: 67 | $ mkdir items/Ted 68 | 69 | We tag the 'Ted' item as movie: 70 | $ echo movie >> items/Ted/.tag 71 | 72 | We also tag 'Ted' as genre comedy: 73 | $ echo 'genre: comedy' >> items/Ted/.tag 74 | 75 | Then we add a second item: 76 | $ mkdir items/banana 77 | $ echo fruit >> items/banana/.tag 78 | $ echo 'genre: delicious' >> items/banana/.tag 79 | 80 | Modifying .tag files using echo, grep, sed may be a little hard sometimes. 81 | There are some convenience scripts available through the tagfs-utils project. 82 | See https://github.com/marook/tagfs-utils for details. 83 | 84 | 85 | --------------------------------------------------------------------- 86 | Usage 87 | 88 | After installation tagfs can be started the following way. 89 | 90 | Mount a tagged directory: 91 | $ tagfs -i /path/to/my/items/directory /path/to/my/mount/point 92 | 93 | Unmount a tagged directory: 94 | $ fusermount -u /path/to/my/mount/point 95 | 96 | Right now tagfs reads the taggings only when it's getting mounted. So if you 97 | modify the tags after mounting you will not see any changes in the tagfs file 98 | system. 99 | 100 | In general tagfs will try to reduce the number of filter directories below the 101 | virtual file system. That's why you may not see some filters which would not 102 | reduce the number of selected items. 103 | 104 | 105 | --------------------------------------------------------------------- 106 | Configuration 107 | 108 | tagfs can be configured through configuration files. Configuration files are 109 | searched in different locations by tagfs. The following locations are used. 110 | Locations with higher priority come first: 111 | - /.tagfs/tagfs.conf 112 | - ~/.tagfs/tagfs.conf 113 | - /etc/tagfs/tagfs.conf 114 | 115 | Right now the following configuration options are supported. 116 | 117 | 118 | --------------------------------------------------------------------- 119 | Configuration - Options - tagFileName 120 | 121 | Through this option the name of the parsed tag files can be specified. The 122 | default value is '.tag'. 123 | 124 | Example: 125 | 126 | [global] 127 | tagFileName = ABOUT 128 | 129 | 130 | --------------------------------------------------------------------- 131 | Configuration - Options - enableValueFilters 132 | 133 | You can enable or disable value filters. If you enable value filters you will 134 | see filter directories for each tag value. For value filters the tag's 135 | context can be anyone. The default value is 'false'. 136 | 137 | Example: 138 | 139 | [global] 140 | enableValueFilters = true 141 | 142 | 143 | --------------------------------------------------------------------- 144 | Configuration - Options - enableRootItemLinks 145 | 146 | To show links to all items in the tagfs '/' directory enable this option. The 147 | default value is 'false'. 148 | 149 | Example: 150 | 151 | [global] 152 | enableRootItemLinks = true 153 | 154 | 155 | --------------------------------------------------------------------- 156 | Freebase Integration 157 | 158 | Freebase is an open graph of people, places and things. See 159 | http://www.freebase.com/ for details. tagfs allows you to extend your own 160 | taggings with data directly from the freebase graph. 161 | 162 | WARNING! Freebase support is currently experimental. It is very likely that the 163 | freebase syntax within the .tag files will change in future releases of tagfs. 164 | 165 | In order to use freebase you need to install the freebase-python bindings. They 166 | are available via https://code.google.com/p/freebase-python/ 167 | 168 | To extend an item's taggings with freebase data you have to add a freebase query 169 | to the item's .tag file. Here's an example: 170 | 171 | _freebase: {"id": "/m/0clpml", "type": "/fictional_universe/fictional_character", "name": null, "occupation": null} 172 | 173 | tagfs uses the freebase MQL query format which is described below the following 174 | link http://wiki.freebase.com/wiki/MQL 175 | 176 | The query properties with null values are added as context/tag pairs to the 177 | .tag file's item. 178 | 179 | Generic freebase mappings for all items can be specified in the file 180 | '/.tagfs/freebase'. Every line is one freebase query. You can 181 | reference tagged values via the '$' operator. Here's an example MQL query with 182 | some demo .tag files: 183 | 184 | /.tagfs/freebase: 185 | {"type": "/film/film", "name": "$name", "genre": null, "directed_by": null} 186 | 187 | /Ted/.tag: 188 | name: Ted 189 | 190 | /Family Guy/.tag: 191 | name: Family Guy 192 | 193 | When mounting this example the genre and director will be fetched from freebase 194 | and made available as filtering directories. 195 | 196 | 197 | --------------------------------------------------------------------- 198 | Bugs 199 | 200 | Viewing existing and reporting new bugs can be done via the github issue 201 | tracker: 202 | https://github.com/marook/tagfs/issues 203 | 204 | 205 | --------------------------------------------------------------------- 206 | Further Reading 207 | 208 | Using a file system for my bank account (Markus Pielmeier) 209 | http://pielmeier.blogspot.com/2010/08/using-file-system-for-my-bank-account.html 210 | 211 | 212 | --------------------------------------------------------------------- 213 | Contact 214 | 215 | * homepage: http://wiki.github.com/marook/tagfs 216 | * author: Markus Peröbner 217 | -------------------------------------------------------------------------------- /src/modules/tagfs/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009, 2010 Markus Pielmeier 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | # 21 | # = tag fs = 22 | # == glossary == 23 | # * item: An item is a directory in the item container directory. Items can be 24 | # tagged using a tag file. 25 | # * tag: A tag is a text string which can be assigned to an item. Tags can 26 | # consist of any character except newlines. 27 | 28 | import os 29 | import stat 30 | import errno 31 | import exceptions 32 | import time 33 | import functools 34 | import logging 35 | 36 | import fuse 37 | if not hasattr(fuse, '__version__'): 38 | raise RuntimeError, \ 39 | "your fuse-py doesn't know of fuse.__version__, probably it's too old." 40 | fuse.fuse_python_api = (0, 2) 41 | 42 | from view import View 43 | from cache import cache 44 | from item_access import ItemAccess 45 | from config import parseConfig 46 | from log import logException 47 | 48 | import sysIO 49 | import freebase_support 50 | 51 | class TagFS(fuse.Fuse): 52 | 53 | def __init__(self, initwd, *args, **kw): 54 | fuse.Fuse.__init__(self, *args, **kw) 55 | 56 | self._initwd = initwd 57 | self._itemsRoot = None 58 | 59 | self.system = sysIO.createSystem() 60 | 61 | # TODO change command line arguments structure 62 | # goal: tagfs 63 | self.parser.add_option('-i', 64 | '--items-dir', 65 | dest = 'itemsDir', 66 | help = 'items directory', 67 | metavar = 'dir') 68 | self.parser.add_option('-t', 69 | '--tag-file', 70 | dest = 'tagFileName', 71 | help = 'tag file name', 72 | metavar = 'file', 73 | default = None) 74 | self.parser.add_option('--value-filter', 75 | action = 'store_true', 76 | dest = 'enableValueFilters', 77 | help = 'Displays value filter directories on toplevel instead of only context entries', 78 | default = None) 79 | self.parser.add_option('--root-items', 80 | action = 'store_true', 81 | dest = 'enableRootItemLinks', 82 | help = 'Display item links in tagfs root directory.', 83 | default = None) 84 | 85 | def parseGenericFreebaseQueries(self, itemsRoot): 86 | freebaseQueriesFilePath = os.path.join(itemsRoot, '.tagfs', 'freebase') 87 | 88 | if(not os.path.exists(freebaseQueriesFilePath)): 89 | return [] 90 | 91 | queries = list(freebase_support.QueryFileParser(self.system, freebase_support.QueryParser()).parseFile(freebaseQueriesFilePath)) 92 | 93 | logging.info('Parsed %s generic freebase queries', len(queries)) 94 | 95 | return queries 96 | 97 | def getItemAccess(self): 98 | # Maybe we should move the parser run from main here. 99 | # Or we should at least check if it was run once... 100 | opts, args = self.cmdline 101 | 102 | # Maybe we should add expand user? Maybe even vars??? 103 | assert opts.itemsDir != None and opts.itemsDir != '' 104 | itemsRoot = os.path.normpath( 105 | os.path.join(self._initwd, opts.itemsDir)) 106 | 107 | # TODO rel https://github.com/marook/tagfs/issues#issue/2 108 | # Ensure that mount-point and items dir are disjoined. 109 | # Something along 110 | # assert not os.path.normpath(itemsDir).startswith(itemsRoot) 111 | 112 | # try/except here? 113 | try: 114 | return ItemAccess(self.system, itemsRoot, self.config.tagFileName, freebase_support.QueryParser(), freebase_support.createFreebaseAdapter(), self.parseGenericFreebaseQueries(itemsRoot)) 115 | except OSError, e: 116 | logging.error("Can't create item access from items directory %s. Reason: %s", 117 | itemsRoot, str(e.strerror)) 118 | raise 119 | 120 | @property 121 | @cache 122 | def config(self): 123 | opts, args = self.cmdline 124 | 125 | c = parseConfig(os.path.normpath(os.path.join(self._initwd, opts.itemsDir))) 126 | 127 | if opts.tagFileName: 128 | c.tagFileName = opts.tagFileName 129 | 130 | if opts.enableValueFilters: 131 | c.enableValueFilters = opts.enableValueFilters 132 | 133 | if opts.enableRootItemLinks: 134 | c.enableRootItemLinks = opts.enableRootItemLinks 135 | 136 | logging.debug('Using configuration %s' % c) 137 | 138 | return c 139 | 140 | @property 141 | @cache 142 | def view(self): 143 | itemAccess = self.getItemAccess() 144 | 145 | return View(itemAccess, self.config) 146 | 147 | @logException 148 | def getattr(self, path): 149 | return self.view.getattr(path) 150 | 151 | @logException 152 | def readdir(self, path, offset): 153 | return self.view.readdir(path, offset) 154 | 155 | @logException 156 | def readlink(self, path): 157 | return self.view.readlink(path) 158 | 159 | @logException 160 | def open(self, path, flags): 161 | return self.view.open(path, flags) 162 | 163 | @logException 164 | def read(self, path, size, offset): 165 | return self.view.read(path, size, offset) 166 | 167 | @logException 168 | def write(self, path, data, pos): 169 | return self.view.write(path, data, pos) 170 | 171 | @logException 172 | def symlink(self, path, linkPath): 173 | return self.view.symlink(path, linkPath) 174 | 175 | def main(): 176 | fs = TagFS(os.getcwd(), 177 | version = "%prog " + fuse.__version__, 178 | dash_s_do = 'setsingle') 179 | 180 | fs.parse(errex = 1) 181 | opts, args = fs.cmdline 182 | 183 | if opts.itemsDir == None: 184 | fs.parser.print_help() 185 | # items dir should probably be an arg, not an option. 186 | print "Error: Missing items directory option." 187 | # Quickfix rel https://github.com/marook/tagfs/issues/#issue/3 188 | # FIXME: since we run main via sys.exit(main()), this should 189 | # probably be handled via some return code. 190 | import sys 191 | sys.exit() 192 | 193 | return fs.main() 194 | 195 | if __name__ == '__main__': 196 | import sys 197 | sys.exit(main()) 198 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2009 Peter Prohaska 4 | # 5 | # This file is part of tagfs. 6 | # 7 | # tagfs is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation, either version 3 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # tagfs is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with tagfs. If not, see . 19 | # 20 | 21 | from distutils.core import setup, Command 22 | import sys 23 | import os 24 | from os.path import ( 25 | basename, 26 | dirname, 27 | abspath, 28 | splitext, 29 | join as pjoin 30 | ) 31 | from glob import glob 32 | from unittest import TestLoader, TextTestRunner 33 | import re 34 | import datetime 35 | from subprocess import call 36 | 37 | projectdir = dirname(abspath(__file__)) 38 | reportdir = pjoin(projectdir, 'reports') 39 | 40 | srcdir = pjoin(projectdir, 'src') 41 | bindir = pjoin(srcdir, 'bin') 42 | moddir = pjoin(srcdir, 'modules') 43 | testdir = pjoin(srcdir, 'test') 44 | endToEndTestDir = pjoin(projectdir, 'test', 'e2e') 45 | 46 | testdatadir = pjoin(projectdir, 'etc', 'test', 'events') 47 | testmntdir = pjoin(projectdir, 'mnt') 48 | 49 | assert os.path.isdir(srcdir) 50 | assert os.path.isdir(bindir) 51 | assert os.path.isdir(moddir) 52 | assert os.path.isdir(testdir) 53 | 54 | assert os.path.isdir(testdatadir) 55 | 56 | class Report(object): 57 | 58 | def __init__(self): 59 | self.reportDateTime = datetime.datetime.utcnow() 60 | self.reportDir = os.path.join(reportdir, self.reportDateTime.strftime('%Y-%m-%d_%H_%M_%S')) 61 | 62 | # fails when dir already exists which is nice 63 | os.makedirs(self.reportDir) 64 | 65 | @property 66 | def coverageReportFileName(self): 67 | return os.path.join(self.reportDir, 'coverage.txt') 68 | 69 | @property 70 | def unitTestReportFileName(self): 71 | return os.path.join(self.reportDir, 'tests.txt') 72 | 73 | def sourceFiles(): 74 | yield os.path.join(bindir, 'tagfs') 75 | 76 | sourceFilePattern = re.compile('^.*[.]py$') 77 | for root, dirs, files in os.walk(moddir): 78 | for f in files: 79 | if(not sourceFilePattern.match(f)): 80 | continue 81 | 82 | if(f.startswith('.#')): 83 | continue 84 | 85 | yield os.path.join(root, f) 86 | 87 | def fullSplit(p): 88 | head, tail = os.path.split(p) 89 | 90 | if(len(head) > 0): 91 | for n in fullSplit(head): 92 | yield n 93 | 94 | yield tail 95 | 96 | def testModules(): 97 | testFilePattern = re.compile('^(test.*)[.]py$', re.IGNORECASE) 98 | 99 | for root, dirs, files in os.walk(testdir): 100 | for f in files: 101 | m = testFilePattern.match(f) 102 | 103 | if(not m): 104 | continue 105 | 106 | relDir = os.path.relpath(root, testdir) 107 | 108 | yield '.'.join([n for n in fullSplit(relDir)] + [m.group(1), ]) 109 | 110 | def printFile(fileName): 111 | if(not os.path.exists(fileName)): 112 | # TODO maybe we should not silently return? 113 | return 114 | 115 | with open(fileName, 'r') as f: 116 | for line in f: 117 | sys.stdout.write(line) 118 | 119 | class TestFailException(Exception): 120 | '''Indicates that at lease one of the unit tests has failed 121 | ''' 122 | 123 | pass 124 | 125 | class test(Command): 126 | description = 'run tests' 127 | user_options = [] 128 | 129 | def initialize_options(self): 130 | self._cwd = os.getcwd() 131 | self._verbosity = 2 132 | 133 | def finalize_options(self): pass 134 | 135 | def run(self): 136 | report = Report() 137 | 138 | tests = [m for m in testModules()] 139 | 140 | print "..using:" 141 | print " moddir:", moddir 142 | print " testdir:", testdir 143 | print " testdatadir:", testdatadir 144 | print " testmntdir:", testmntdir 145 | print " tests:", tests 146 | print " sys.path:", sys.path 147 | print 148 | 149 | # insert project lookup paths at index 0 to make sure they are used 150 | # over global libraries 151 | sys.path.insert(0, moddir) 152 | sys.path.insert(0, testdir) 153 | 154 | # TODO try to import all test cases here. the TestLoader is throwing 155 | # very confusing errors when imports can't be resolved. 156 | 157 | # configure logging 158 | # TODO not sure how to enable this... it's a bit complicate to enable 159 | # logging only for 'make mt' and disable it then for 160 | # 'python setup.py test'. 'python setup.py test' is such a gabber... 161 | #if 'DEBUG' in os.environ: 162 | # from tagfs import log_config 163 | # log_config.setUpLogging() 164 | 165 | if 'DEBUG' in os.environ: 166 | import logging 167 | logging.basicConfig(level = logging.DEBUG) 168 | 169 | suite = TestLoader().loadTestsFromNames(tests) 170 | 171 | try: 172 | with open(report.unitTestReportFileName, 'w') as testResultsFile: 173 | r = TextTestRunner(stream = testResultsFile, verbosity = self._verbosity) 174 | 175 | def runTests(): 176 | result = r.run(suite) 177 | 178 | if(not result.wasSuccessful()): 179 | raise TestFailException() 180 | 181 | try: 182 | import coverage 183 | 184 | c = coverage.coverage() 185 | c.start() 186 | runTests() 187 | c.stop() 188 | 189 | with open(report.coverageReportFileName, 'w') as reportFile: 190 | c.report([f for f in sourceFiles()], file = reportFile) 191 | 192 | except ImportError: 193 | # TODO ImportErrors from runTests() may look like coverage is missing 194 | 195 | print '' 196 | print 'coverage module not found.' 197 | print 'To view source coverage stats install http://nedbatchelder.com/code/coverage/' 198 | print '' 199 | 200 | runTests() 201 | finally: 202 | # TODO use two streams instead of printing files after writing 203 | printFile(report.unitTestReportFileName) 204 | printFile(report.coverageReportFileName) 205 | 206 | class EndToEndTestFailure(Exception): 207 | 208 | def __init__(self, testPath): 209 | super(EndToEndTestFailure, self).__init__('end-to-end test failed: %s' % testPath) 210 | 211 | class EndToEndTests(Command): 212 | description = 'execute the end-to-end tests' 213 | user_options = [] 214 | 215 | def initialize_options(self): 216 | pass 217 | 218 | def finalize_options(self): 219 | pass 220 | 221 | def runTest(self, testPath): 222 | if(not call(['bin/runEndToEndTest.sh', testPath]) is 0): 223 | raise EndToEndTestFailure(testPath) 224 | 225 | def run(self): 226 | for endToEndDirName in os.listdir(endToEndTestDir): 227 | testPath = os.path.join(endToEndTestDir, endToEndDirName) 228 | 229 | if(not os.path.isdir(testPath)): 230 | continue 231 | 232 | self.runTest(testPath) 233 | 234 | # Overrides default clean (which cleans from build runs) 235 | # This clean should probably be hooked into that somehow. 236 | class clean_pyc(Command): 237 | description = 'remove *.pyc files from source directory' 238 | user_options = [] 239 | 240 | def initialize_options(self): 241 | self._delete = [] 242 | for cwd, dirs, files in os.walk(projectdir): 243 | self._delete.extend( 244 | pjoin(cwd, f) for f in files if f.endswith('.pyc') 245 | ) 246 | 247 | def finalize_options(self): 248 | pass 249 | 250 | def run(self): 251 | for f in self._delete: 252 | try: 253 | os.unlink(f) 254 | except OSError, e: 255 | print "Strange '%s': %s" % (f, e) 256 | # Could be a directory. 257 | # Can we detect file in use errors or are they OSErrors 258 | # as well? 259 | # Shall we catch all? 260 | 261 | setup( 262 | cmdclass = { 263 | 'test': test, 264 | 'clean_pyc': clean_pyc, 265 | 'e2e_test': EndToEndTests, 266 | }, 267 | name = 'tagfs', 268 | version = '0.1', 269 | url = 'http://wiki.github.com/marook/tagfs', 270 | description = '', 271 | long_description = '', 272 | author = 'Markus Pielmeier', 273 | author_email = 'markus.pielmeier@gmail.com', 274 | license = 'GPLv3', 275 | download_url = 'http://github.com/marook/tagfs/downloads/tagfs_0.1-src.tar.bz2', 276 | platforms = 'Linux', 277 | requires = [], 278 | classifiers = [ 279 | 'Development Status :: 2 - Pre-Alpha', 280 | 'Environment :: Console', 281 | 'Intended Audience :: Developers', 282 | 'License :: OSI Approved :: GNU General Public License (GPL)', 283 | 'Natural Language :: English', 284 | 'Operating System :: POSIX :: Linux', 285 | 'Programming Language :: Python', 286 | 'Topic :: System :: Filesystems' 287 | ], 288 | data_files = [ 289 | (pjoin('share', 'doc', 'tagfs'), ['AUTHORS', 'COPYING', 'README']) 290 | ], 291 | # TODO maybe we should include src/bin/*? 292 | scripts = [pjoin(bindir, 'tagfs')], 293 | packages = ['tagfs'], 294 | package_dir = {'': moddir}, 295 | ) 296 | -------------------------------------------------------------------------------- /src/modules/tagfs/item_access.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2009 Markus Pielmeier 3 | # 4 | # This file is part of tagfs. 5 | # 6 | # tagfs is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # tagfs is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with tagfs. If not, see . 18 | 19 | import logging 20 | import os 21 | import time 22 | import traceback 23 | 24 | from cache import cache 25 | import sysIO 26 | import freebase_support 27 | 28 | class Tag(object): 29 | 30 | def __init__(self, value, context = None): 31 | if context == None: 32 | self.context = None 33 | else: 34 | self.context = context.strip() 35 | 36 | self.value = value.strip() 37 | 38 | if not self.context == None and len(self.context) == 0: 39 | # we don't allow empty strings as they can't be represented as a 40 | # directory very well 41 | raise ValueError() 42 | 43 | if len(self.value) == 0: 44 | # we don't allow empty strings as they can't be represented as a 45 | # directory very well 46 | raise ValueError() 47 | 48 | def __hash__(self): 49 | return (self.context, self.value).__hash__() 50 | 51 | def __eq__(self, other): 52 | return self.value == other.value and self.context == other.context 53 | 54 | def __repr__(self): 55 | return '' % (self.context, self.value) 56 | 57 | def parseTagsFromFile(system, tagFileName): 58 | """Parses the tags from the specified file. 59 | 60 | @return: The parsed values are returned as a set containing Tag objects. 61 | @see: Tag 62 | """ 63 | 64 | tags = set() 65 | 66 | with system.open(tagFileName, 'r') as tagFile: 67 | for rawTag in tagFile: 68 | rawTag = rawTag.strip() 69 | 70 | try: 71 | if len(rawTag) == 0: 72 | continue 73 | 74 | tagTuple = rawTag.split(':', 1) 75 | 76 | if len(tagTuple) == 1: 77 | tagContext = None 78 | tagValue = tagTuple[0] 79 | else: 80 | tagContext = tagTuple[0] 81 | tagValue = tagTuple[1] 82 | 83 | tag = Tag(tagValue, context = tagContext) 84 | 85 | tags.add(tag) 86 | except: 87 | logging.warning('Skipping tagging \'%s\' from file \'%s\' as it can\'t be parsed\n%s.' % (rawTag, tagFileName, traceback.format_exc())) 88 | 89 | return tags 90 | 91 | class NoSuchTagValue(Exception): 92 | 93 | pass 94 | 95 | class Item(object): 96 | 97 | def __init__(self, name, system, itemAccess, freebaseQueryParser, freebaseAdapter, genericFreebaseQueries = [], parseTagsFromFile = parseTagsFromFile): 98 | self.name = name 99 | self.system = system 100 | self.itemAccess = itemAccess 101 | self.freebaseQueryParser = freebaseQueryParser 102 | self.freebaseAdapter = freebaseAdapter 103 | self.parseTagsFromFile = parseTagsFromFile 104 | self.genericFreebaseQueries = genericFreebaseQueries 105 | 106 | # TODO register at file system to receive tag file change events. 107 | 108 | @property 109 | @cache 110 | def itemDirectory(self): 111 | return os.path.join(self.itemAccess.dataDirectory, self.name) 112 | 113 | @property 114 | @cache 115 | def _tagFileName(self): 116 | """Returns the name of the tag file for this item. 117 | """ 118 | 119 | return os.path.join(self.itemDirectory, self.itemAccess.tagFileName) 120 | 121 | @property 122 | @cache 123 | def tagFileExists(self): 124 | return self.system.pathExists(self._tagFileName) 125 | 126 | def __getFreebaseTags(self, query): 127 | try: 128 | for context, values in self.freebaseAdapter.execute(query).iteritems(): 129 | for value in values: 130 | # without the decode/encode operations fuse refuses to show 131 | # directory entries which are based on freebase data 132 | yield Tag(value.decode('ascii', 'ignore').encode('ascii'), context) 133 | except Exception as e: 134 | logging.error('Failed to execute freebase query %s: %s', query, e) 135 | 136 | def __parseTags(self): 137 | tagFileName = self._tagFileName 138 | 139 | for rawTag in self.parseTagsFromFile(self.system, tagFileName): 140 | if(rawTag.context == '_freebase'): 141 | query = self.freebaseQueryParser.parse(rawTag.value) 142 | 143 | for tag in self.__getFreebaseTags(query): 144 | yield tag 145 | else: 146 | yield rawTag 147 | 148 | @property 149 | @cache 150 | def tagsCreationTime(self): 151 | if not self.tagFileExists: 152 | return None 153 | 154 | return os.path.getctime(self._tagFileName) 155 | 156 | @property 157 | @cache 158 | def tagsModificationTime(self): 159 | """Returns the last time when the tags have been modified. 160 | """ 161 | 162 | if not self.tagFileExists: 163 | return None 164 | 165 | return os.path.getmtime(self._tagFileName) 166 | 167 | @property 168 | @cache 169 | def tags(self): 170 | """Returns the tags as a list for this item. 171 | """ 172 | 173 | if not self.tagFileExists: 174 | return None 175 | 176 | tags = list(self.__parseTags()) 177 | 178 | def getValue(context): 179 | for tag in tags: 180 | if(tag.context == context): 181 | return tag.value 182 | 183 | raise NoSuchTagValue() 184 | 185 | queryFactory = freebase_support.GenericQueryFactory(getValue) 186 | for genericQuery in self.genericFreebaseQueries: 187 | try: 188 | query = queryFactory.createQuery(genericQuery.queryObject) 189 | 190 | for tag in self.__getFreebaseTags(freebase_support.Query(query)): 191 | tags.append(tag) 192 | except NoSuchTagValue: 193 | pass 194 | 195 | return tags 196 | 197 | @property 198 | def values(self): 199 | for t in self.tags: 200 | yield t.value 201 | 202 | def getTagsByContext(self, context): 203 | for t in self.tags: 204 | if context != t.context: 205 | continue 206 | 207 | yield t 208 | 209 | def getValuesByContext(self, context): 210 | return [t.value for t in self.getTagsByContext(context)] 211 | 212 | def getValueByContext(self, context): 213 | values = self.getValuesByContext(context) 214 | valuesLen = len(values) 215 | 216 | if(valuesLen == 0): 217 | return None 218 | 219 | if(valuesLen == 1): 220 | return values[0] 221 | 222 | raise Exception('Too many values found for context %s' % (context,)) 223 | 224 | def isTaggedWithContextValue(self, context, value): 225 | for t in self.getTagsByContext(context): 226 | if value == t.value: 227 | return True 228 | 229 | return False 230 | 231 | def isTaggedWithContext(self, context): 232 | # TODO don't create whole list... just check wheather list is empty 233 | return (len([c for c in self.getTagsByContext(context)]) > 0) 234 | 235 | def isTaggedWithValue(self, value): 236 | for v in self.values: 237 | if value == v: 238 | return True 239 | 240 | return False 241 | 242 | @property 243 | def tagged(self): 244 | return self.tagFileExists 245 | 246 | def __repr__(self): 247 | return '' % (self.name, self.tags) 248 | 249 | class ItemAccess(object): 250 | """This is the access point to the Items. 251 | """ 252 | 253 | def __init__(self, system, dataDirectory, tagFileName, freebaseQueryParser, freebaseAdapter, genericFreebaseQueries): 254 | self.system = system 255 | self.dataDirectory = dataDirectory 256 | self.tagFileName = tagFileName 257 | self.freebaseQueryParser = freebaseQueryParser 258 | self.freebaseAdapter = freebaseAdapter 259 | self.genericFreebaseQueries = genericFreebaseQueries 260 | 261 | self.parseTime = 0 262 | 263 | def __parseItems(self): 264 | items = {} 265 | 266 | logging.debug('Start parsing items from dir: %s', self.dataDirectory) 267 | 268 | for itemName in os.listdir(self.dataDirectory): 269 | if itemName == '.tagfs': 270 | # skip directory with configuration 271 | continue 272 | 273 | try: 274 | item = Item(itemName, self.system, self, self.freebaseQueryParser, self.freebaseAdapter, self.genericFreebaseQueries) 275 | 276 | items[itemName] = item 277 | 278 | except IOError, (error, strerror): 279 | logging.error('Can \'t read tags for item %s: %s', 280 | itemName, 281 | strerror) 282 | 283 | logging.debug('Found %s items', len(items)) 284 | 285 | self.parseTime = time.time() 286 | 287 | return items 288 | 289 | @property 290 | @cache 291 | def items(self): 292 | return self.__parseItems() 293 | 294 | @property 295 | @cache 296 | def tags(self): 297 | tags = set() 298 | 299 | for item in self.items.itervalues(): 300 | if not item.tagged: 301 | continue 302 | 303 | tags = tags | set(item.tags) 304 | 305 | return tags 306 | 307 | @property 308 | @cache 309 | def taggedItems(self): 310 | return set([item for item in self.items.itervalues() if item.tagged]) 311 | 312 | @property 313 | @cache 314 | def untaggedItems(self): 315 | return set([item for item in self.items.itervalues() if not item.tagged]) 316 | 317 | def getItemDirectory(self, item): 318 | return os.path.join(self.dataDirectory, item) 319 | 320 | def contextTags(self, context): 321 | contextTags = set() 322 | 323 | for tag in self.tags: 324 | if tag.context == context: 325 | contextTags.add(tag) 326 | 327 | return contextTags 328 | 329 | @property 330 | @cache 331 | def contexts(self): 332 | contexts = set() 333 | 334 | for tag in self.tags: 335 | if tag.context == None: 336 | continue 337 | 338 | contexts.add(tag.context) 339 | 340 | return contexts 341 | 342 | @property 343 | @cache 344 | def values(self): 345 | values = set() 346 | 347 | for tag in self.tags: 348 | values.add(tag.value) 349 | 350 | return values 351 | 352 | def __str__(self): 353 | return '[' + ', '.join([field + ': ' + str(self.__dict__[field]) for field in ['dataDirectory', 'tagFileName']]) + ']' 354 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | The tagfs is a virtual file system for filtering tagged directories. 635 | Copyright (C) 2009 Markus Pielmeier 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | tagfs Copyright (C) 2009 Markus Pielmeier 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------