Module ImportFrom alias Expr Str ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias identifier ImportFrom alias alias ImportFrom alias alias Assign NameStore Str ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign SubscriptStore NameLoad Index Str Str Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return BinOpMod Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign SubscriptStore NameLoad Index Str Str Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return BinOpMod Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign SubscriptStore NameLoad Index Str Str Return NameLoad decorator_list decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore NameLoad If CompareIs NameLoad NameLoad body Assign NameStore NameLoad orelse If BoolOpOr Call AttributeLoad NameLoad attr Str CompareEq NameLoad Str body Raise Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad If UnaryOpNot Call NameLoad NameLoad body Raise Call NameLoad NameLoad If UnaryOpNot Call NameLoad NameLoad NameLoad body Raise Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad For NameStore TupleLoad NameLoad NameLoad body If Call NameLoad NameLoad body Raise Call NameLoad NameLoad If BoolOpAnd CompareNotEq NameLoad Str CompareNotEq SubscriptLoad NameLoad Index Num Str body Assign NameStore BinOpAdd NameLoad Str With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr NameLoad With Call NameLoad NameLoad Str NameStore body Pass Return Dict Str NameLoad decorator_list If CompareEq NameLoad Str body Expr Str
N/A __future__ with_statement N/A 
Simple interface to for importing files into the data directory.

Author:     Pontus Stenetorp    <pontus is s u-tokyo ac jp>
Version:    2011-02-21
 annotation open_textfile common ProtocolError config DATA_DIR document real_directory annotation JOINED_ANN_FILE_SUFF TEXT_FILE_SUFFIX os.path join join_path os.path isdir isfile os access W_OK N/A DEFAULT_IMPORT_DIR import InvalidDirError N/A ProtocolError N/A __init__ N/A N/A self path N/A N/A N/A N/A self path path N/A __str__ N/A N/A self N/A N/A N/A Invalid directory N/A json N/A N/A self json_dic N/A N/A N/A N/A json_dic N/A exception invalidDirError N/A json_dic N/A N/A FileExistsError N/A ProtocolError N/A __init__ N/A N/A self path N/A N/A N/A N/A self path path N/A __str__ N/A N/A self N/A N/A N/A N/A File exists: %s N/A self path N/A json N/A N/A self json_dic N/A N/A N/A N/A json_dic N/A exception fileExistsError N/A json_dic N/A N/A NoWritePermissionError N/A ProtocolError N/A __init__ N/A N/A self path N/A N/A N/A N/A self path path N/A __str__ N/A N/A self N/A N/A N/A N/A No write permission to %s N/A self path N/A json N/A N/A self json_dic N/A N/A N/A N/A json_dic N/A exception noWritePermissionError N/A json_dic N/A N/A save_import N/A N/A text docid collection N/A None N/A N/A 
    TODO: DOC:
     N/A directory collection N/A N/A directory None N/A N/A dir_path DATA_DIR N/A N/A N/A N/A N/A directory count ../ N/A directory .. N/A N/A N/A InvalidDirError directory N/A dir_path N/A real_directory directory N/A N/A N/A isdir dir_path N/A N/A N/A InvalidDirError dir_path N/A N/A N/A access dir_path W_OK N/A N/A N/A NoWritePermissionError dir_path N/A base_path N/A join_path dir_path docid N/A txt_path N/A N/A base_path . TEXT_FILE_SUFFIX N/A ann_path N/A N/A base_path . JOINED_ANN_FILE_SUFF N/A path N/A txt_path ann_path N/A N/A N/A isfile path N/A N/A N/A FileExistsError path N/A N/A N/A text N/A N/A text N/A -1 N/A N/A text N/A text N/A N/A open_textfile txt_path w txt_file N/A N/A N/A N/A txt_file write text N/A N/A open ann_path w _ N/A N/A N/A N/A document docid N/A N/A N/A __name__ __main__ N/A N/A 
    from unittest import TestCase
    from tempfile import mkdtemp
    from shutil import rmtree
    from os import mkdir


    class SaveImportTest(TestCase):
        test_text = 'This is not a drill, this is a drill *BRRR!*'
        test_dir = 'test'
        test_filename = 'test'

        def setUp(self):
            self.tmpdir = mkdtemp()
            mkdir(join_path(self.tmpdir, SaveImportTest.test_dir))
            mkdir(join_path(self.tmpdir, DEFAULT_IMPORT_DIR))

        def tearDown(self):
            rmtree(self.tmpdir)

        def test_import(self):
            save_import(SaveImportTest.test_text, SaveImportTest.test_filename,
                    relative_dir=SaveImportTest.test_dir,
                    directory=self.tmpdir)
        
        def test_default_import_dir(self):
            save_import(SaveImportTest.test_text, SaveImportTest.test_filename,
                    directory=self.tmpdir)
   

    import unittest
    unittest.main()
    