Beispiel #1
0
def test_explicit_assembly_load():
    """Test explicit assembly loading using standard CLR tools."""
    from CLR.System.Reflection import Assembly
    from CLR import System
    import sys

    assembly = Assembly.LoadWithPartialName('System.Data')
    assert assembly is not None

    import CLR.System.Data
    assert 'System.Data' in sys.modules

    assembly = Assembly.LoadWithPartialName('SpamSpamSpamSpamEggsAndSpam')
    assert assembly is None
Beispiel #2
0
    def testExplicitAssemblyLoad(self):
        """Test explicit assembly loading using standard CLR tools."""
        from CLR.System.Reflection import Assembly
        from CLR import System
        import sys

        assembly = Assembly.LoadWithPartialName('System.Data')
        self.failUnless(assembly != None)

        import CLR.System.Data
        self.failUnless(sys.modules.has_key('System.Data'))

        assembly = Assembly.LoadWithPartialName('SpamSpamSpamSpamEggsAndSpam')
        self.failUnless(assembly == None)
#python defaults to ascii, so switch the console to unicode
import sys, codecs
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

#this is the python.net piece that interfaces us to the .net
#FieldWorks libraries
import clr
from CLR.System.Reflection import Assembly

#FDO (FieldWorks Data Objects) is the
#Object-Relational-Mapper layer of FieldWorks
fdo = Assembly.LoadWithPartialName("FDO")
from CLR.SIL.FieldWorks.FDO import FdoCache

#open up a language project to work on
db = FdoCache.Create("TestLangProj")
lp = db.LangProject
vern = lp.DefaultVernacularWritingSystem
analysisWs = lp.DefaultAnalysisWritingSystem
lexicon = lp.LexDbOA
for e in lexicon.EntriesOC:
    print "\lx " + e.LexemeFormOA.Form.GetAlternative(vern)
    for sense in e.SensesOS:
        print "\ge " + sense.Gloss.GetAlternative(analysisWs)
        if sense.MorphoSyntaxAnalysisRA <> None:
            print "\pos " + sense.MorphoSyntaxAnalysisRA.InterlinearAbbr
    print