本文整理汇总了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)))
示例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)
示例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 )
示例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
示例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)
示例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()
示例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)
示例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
示例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
示例10: __call__
def __call__(self, src, filename):
code = Py.compile_flags(src, filename, CompileMode.exec, self.cflags)
return code
示例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
示例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)))
示例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)))
示例14: getJythonBinDir
def getJythonBinDir():
if not sys.executable is None:
return os.path.dirname(os.path.realpath(sys.executable))
else:
return Py.getDefaultBinDir()
示例15: findClass
def findClass(c):
return Py.findClassEx(c, "java class")