当前位置: 首页>>代码示例>>Python>>正文


Python core.Py类代码示例

本文整理汇总了Python中org.python.core.Py的典型用法代码示例。如果您正苦于以下问题:Python Py类的具体用法?Python Py怎么用?Python Py使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Py类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_datetime

 def test_datetime(self):
     self.assertEquals(datetime.datetime(2008, 1, 1),
                       Py.newDatetime(Timestamp(108, 0, 1, 0, 0, 0, 0)))
     self.assertEquals(datetime.datetime(2008, 5, 29, 16, 50, 0),
                       Py.newDatetime(Timestamp(108, 4, 29, 16, 50, 0, 0)))
     self.assertEquals(datetime.datetime(2008, 5, 29, 16, 50, 1, 1),
                       Py.newDatetime(Timestamp(108, 4, 29, 16, 50, 1, 1000)))
开发者ID:Stewori,项目名称:jython,代码行数:7,代码来源:test_jy_internals.py

示例2: getPyObject

 def getPyObject(self, set, col, datatype):
     "Convert Java types into Python ones"
     if datatype in (Types.VARCHAR, Types.CHAR):
         return Py.newUnicode(set.getString(col))
     elif datatype == Types.TIMESTAMP:
         # Convert java.sql.TimeStamp into datetime
         cal = GregorianCalendar()
         cal.time = set.getTimestamp(col)
         return datetime.datetime(cal.get(Calendar.YEAR),
                                  cal.get(Calendar.MONTH) + 1,
                                  cal.get(Calendar.DAY_OF_MONTH),
                                  cal.get(Calendar.HOUR_OF_DAY),
                                  cal.get(Calendar.MINUTE),
                                  cal.get(Calendar.SECOND),
                                  cal.get(Calendar.MILLISECOND) * 1000)
     elif datatype == Types.TIME:
         # Convert java.sql.Time into time
         cal = GregorianCalendar()
         cal.time = set.getTime(col)
         return datetime.time(cal.get(Calendar.HOUR_OF_DAY),
                              cal.get(Calendar.MINUTE),
                              cal.get(Calendar.SECOND),
                              cal.get(Calendar.MILLISECOND) * 1000)
     elif datatype == Types.DATE:
         # Convert java.sql.Date into datetime
         cal = GregorianCalendar()
         cal.time = set.getDate(col)
         return datetime.date(cal.get(Calendar.YEAR),
                              cal.get(Calendar.MONTH) + 1,
                              cal.get(Calendar.DAY_OF_MONTH))
     else:
         return FilterDataHandler.getPyObject(self, set, col, datatype)
开发者ID:kabir,项目名称:jython-jbossorg,代码行数:32,代码来源:base.py

示例3: createMindMap

 def createMindMap( self ):
     
     import org.python.core.Py as Py
     system_state = Py.getSystemState()
     sscl = system_state.getClassLoader()
     try:
         try:
             ccl = java.lang.Thread.currentThread().getContextClassLoader()
             cpath = java.lang.System.getProperty( "java.class.path" )
         
             import leoFreeMindView
         
             #Each of these 3 calls play a pivotal role in loading the system
             java.lang.System.setProperty( "java.class.path", "" )
             java.lang.Thread.currentThread().setContextClassLoader( leoFreeMindView.mmcl )
             system_state.setClassLoader( leoFreeMindView.mmcl )
             
             self.mm = leoFreeMindView.mindmap( self.c )
             self.mindmap = self.mm.mindmapview
             ml = MListener( self.mm._free_leo_mind.updateMenus )
             self.mm._free_leo_mind.getMainMenu().addMenuListener( ml )
             
         except java.lang.Exception, x:
             x.printStackTrace()
             swing.JOptionPane.showMessageDialog( None, "Cant Load MindMap View." )
     finally:   
         java.lang.System.setProperty( "java.class.path", cpath )
         java.lang.Thread.currentThread().setContextClassLoader( ccl )
         system_state.setClassLoader( sscl )
开发者ID:leo-editor,项目名称:leo-editor-contrib,代码行数:29,代码来源:MindMapPlugin.py

示例4: __makeModule

def __makeModule(name, code, path):
    module = _imp.addModule(name)
    builtins = _Py.getSystemState().builtins
    frame = _Frame(code, module.__dict__, module.__dict__, builtins)
    module.__file__ = path
    code.call(frame) # execute module code
    return module
开发者ID:343829084,项目名称:OpenRefine,代码行数:7,代码来源:pycimport.py

示例5: compile_command

def compile_command(source, filename="<input>", symbol="single"):
    r"""Compile a command and determine whether it is incomplete.

    Arguments:

    source -- the source string; may contain \n characters
    filename -- optional filename from which source was read; default
                "<input>"
    symbol -- optional grammar start symbol; "single" (default) or "eval"

    Return value / exceptions raised:

    - Return a code object if the command is complete and valid
    - Return None if the command is incomplete
    - Raise SyntaxError, ValueError or OverflowError if the command is a
      syntax error (OverflowError and ValueError can be produced by
      malformed literals).
    """
    if symbol not in ['single','eval']:
        raise ValueError,"symbol arg must be either single or eval"
    return Py.compile_command_flags(source,filename,symbol,Py.getCompilerFlags(),0)
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:21,代码来源:codeop.py

示例6: finalize_options

    def finalize_options(self):
        if self.plat_name is None:
            self.plat_name = get_platform()
        else:
            # plat-name only supported for windows (other platforms are
            # supported via ./configure flags, if at all).  Avoid misleading
            # other platforms.
            if os.name != 'nt':
                raise DistutilsOptionError(
                            "--plat-name only supported on Windows (try "
                            "using './configure --help' on your platform)")

        plat_specifier = ".%s-%s" % (self.plat_name, sys.version[0:3])

        # Make it so Python 2.x and Python 2.x with --with-pydebug don't
        # share the same build directories. Doing so confuses the build
        # process for C modules
        if hasattr(sys, 'gettotalrefcount'):
            plat_specifier += '-pydebug'

        # 'build_purelib' and 'build_platlib' just default to 'lib' and
        # 'lib.<plat>' under the base build directory.  We only use one of
        # them for a given distribution, though --
        if self.build_purelib is None:
            self.build_purelib = os.path.join(self.build_base, 'lib')
        if self.build_platlib is None:
            self.build_platlib = os.path.join(self.build_base,
                                              'lib' + plat_specifier)

        # 'build_lib' is the actual directory that we will use for this
        # particular module distribution -- if user didn't supply it, pick
        # one of 'build_purelib' or 'build_platlib'.
        if self.build_lib is None:
            if self.distribution.ext_modules:
                self.build_lib = self.build_platlib
            else:
                self.build_lib = self.build_purelib

        # 'build_temp' -- temporary directory for compiler turds,
        # "build/temp.<plat>"
        if self.build_temp is None:
            self.build_temp = os.path.join(self.build_base,
                                           'temp' + plat_specifier)
        if self.build_scripts is None:
            self.build_scripts = os.path.join(self.build_base,
                                              'scripts-' + sys.version[0:3])

        if self.executable is None:
            if not sys.executable is None:
                self.executable = os.path.normpath(sys.executable)
            else:
                from org.python.core import Py
                self.executable = Py.getDefaultExecutableName()
开发者ID:Techcable,项目名称:jython,代码行数:53,代码来源:build.py

示例7: replaceAllByArray

def replaceAllByArray(query,data):
    q = Py.newString(query)
    spliter = re.compile("[\?]{2}")
    split = spliter.split(q)
    sb=[]
    count = len(split)
    sb.append(split[0])
    idx = 1
    while idx<count:
        sb.append(data[idx-1])
        sb.append(split[idx])
        idx=idx+1
    return ''.join(sb)
开发者ID:Rillanon,项目名称:ucmdb_10.01_CUP8_CP12_production_code_changes,代码行数:13,代码来源:Util.py

示例8: makeClass

 def makeClass(self):
     global _builder
     print "Entering makeClass", self
     try:
         import sys
         print "sys.path", sys.path
         # If already defined on sys.path (including CLASSPATH), simply return this class
         # if you need to tune this, derive accordingly from this class or create another CustomMaker
         cls = Py.findClass(self.myClass)
         print "Looked up proxy", self.myClass, cls
         if cls is None:
             raise TypeError("No proxy class")
     except:
         if _builder:
             print "Calling super...", self.package
             cls = CustomMaker.makeClass(self)
             print "Built proxy", self.myClass
         else:
             raise TypeError("FIXME better err msg - Cannot construct class without a defined builder")
     return cls
开发者ID:philk,项目名称:clamp,代码行数:20,代码来源:__init__.py

示例9: makeClass

 def makeClass(self):
     builder = get_builder()
     log.debug("Entering makeClass for %r", self)
     try:
         import sys
         log.debug("Current sys.path: %s", sys.path)
         # If already defined on sys.path (including CLASSPATH), simply return this class
         # if you need to tune this, derive accordingly from this class or create another CustomMaker
         cls = Py.findClass(self.myClass)
         log.debug("Looked up proxy: %r, %r", self.myClass, cls)
         if cls is None:
             raise TypeError("No proxy class")
     except:
         if builder:
             log.debug("Calling super... for %r", self.package)
             cls = CustomMaker.makeClass(self)
             log.info("Built proxy: %r", self.myClass)
         else:
             raise TypeError("Cannot clamp proxy class {} without a defined builder".format(self.myClass))
     return cls
开发者ID:RackerWilliams,项目名称:clamp,代码行数:20,代码来源:proxymaker.py

示例10: __call__

 def __call__(self, src, filename):
     code = Py.compile_flags(src, filename, CompileMode.exec, self.cflags)
     return code
开发者ID:Bloodevil,项目名称:socialite,代码行数:3,代码来源:impSocialite.py

示例11: SpellDictionaryHashMap

    clb2.importClass( "SpellDictionaryHashMap", "com.swabunga.spell.engine.SpellDictionaryHashMap" )
    #clb2.importClass( "SpellDictionaryCachedDichoDisk", "com.swabunga.spell.engine.SpellDictionaryCachedDichoDisk" )
    clb2.importClass( "StringWordTokenizer", "com.swabunga.spell.event.StringWordTokenizer" )
    
    proppath = g.os_path_join( g.app.loadDir, "..", "plugins", "spellingdicts", "which.txt" ) #we start to determine which dictionary to use
    fis = io.FileInputStream( io.File( proppath ) )
    properties = util.Properties()
    properties.load( fis )
    fis.close()
    fis = None
    lfile = properties.getProperty( "dict" )
    dpath = g.os_path_join( g.app.loadDir, "..", "plugins", "spellingdicts", lfile )
    dictionary = SpellDictionaryHashMap( io.File( dpath ) )  
    
    import org.python.core.Py as Py #now we descend into the Jython internals...
    sstate = Py.getSystemState()
    cloader = sstate.getClassLoader()
    sstate.setClassLoader( clb2 )#we do this so the JyLeoSpellChecker class can implement SpellCheckListener, otherwise it fails
    
except java.lang.Exception:
    load_ok = False

if load_ok:
    #@    <<JyLeoSpellChecker>>
    #@+node:zorcanda!.20051111215311.1:<<JyLeoSpellChecker>>
    class JyLeoSpellChecker( SpellCheckListener ):
        
        def __init__( self, editor ):
            self.c = editor.c
            self.editor = editor.editor
            self.foldprotection = editor.foldprotection
开发者ID:leo-editor,项目名称:leo-editor-contrib,代码行数:31,代码来源:JyLeoSpellChecker.py

示例12: test_time

 def test_time(self):
     self.assertEquals(datetime.time(0, 0, 0),
                       Py.newTime(Time(0, 0, 0)))
     self.assertEquals(datetime.time(23, 59, 59),
                       Py.newTime(Time(23, 59, 59)))
开发者ID:Stewori,项目名称:jython,代码行数:5,代码来源:test_jy_internals.py

示例13: test_date

 def test_date(self):
     self.assertEquals(datetime.date(2008, 5, 29),
                       Py.newDate(Date(108, 4, 29)))
     self.assertEquals(datetime.date(1999, 1, 1),
                       Py.newDate(Date(99, 0, 1)))
开发者ID:Stewori,项目名称:jython,代码行数:5,代码来源:test_jy_internals.py

示例14: getJythonBinDir

def getJythonBinDir():
    if not sys.executable is None:
        return os.path.dirname(os.path.realpath(sys.executable))
    else:
        return Py.getDefaultBinDir()
开发者ID:Stewori,项目名称:jython,代码行数:5,代码来源:sysconfig.py

示例15: findClass

def findClass(c):
    return Py.findClassEx(c, "java class")
开发者ID:denis-vilyuzhanin,项目名称:OpenModelSphereMirror,代码行数:2,代码来源:util.py


注:本文中的org.python.core.Py类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。