Skip to content

Commit

Permalink
Reorganization (#334)
Browse files Browse the repository at this point in the history
* Completion of reorg.
* Squash CI porting work.
* Fix exception
* Applied autopep8
  • Loading branch information
Thrameos committed Aug 8, 2018
1 parent 490eb65 commit a36f892
Show file tree
Hide file tree
Showing 199 changed files with 13,989 additions and 11,775 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.h text eol=lf

*.xml text eol=lf
*.md text
*.txt text
.gitignore text eol=lf
.gitattributes text eol=lf
10 changes: 10 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@ coverage.xml
docs/_build/
# PyBuilder
target/
/project/jpype_java/nbproject/private/
/project/jpype_cpython/nbproject/private/
/project/jpype_cpython/nbproject/Makefile*
/project/jpype_java/nbproject/build-impl.xml
/project/jpype_java/nbproject/genfiles.properties
/project/jpype_java/dist
/project/jpype_java/build
/project/jpype_cpython/Makefile
/project/jpype_cpython/nbproject/Package-Release.bash
/project/jpype_python/nbproject/private/
471 changes: 471 additions & 0 deletions doc/ChangeLog-0.7.md

Large diffs are not rendered by default.

32 changes: 20 additions & 12 deletions jpype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#*****************************************************************************
# *****************************************************************************
# Copyright 2004-2008 Steve Menard
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,30 +13,38 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
#*****************************************************************************
# *****************************************************************************
from ._jpackage import *
from ._jclass import *
from ._jarray import *
from ._jwrapper import *
from ._jproxy import *
from ._jexception import *
from ._jboxed import *
from ._core import *
from ._gui import *
from ._classpath import *
from .types import *
from . import reflect
from . import nio
from . import types

from . import JClassUtil

# Support for isinstance(obj, )
from ._jclass import _JavaObject as JavaObject
from ._jclass import _JavaClass as JavaClass
__all__ = ['java', 'javax', 'JIterator', 'JException']
__all__.extend(_core.__all__)
__all__.extend(_classpath.__all__)
__all__.extend(types.__all__)
__all__.extend(_jproxy.__all__)
__all__.extend(_jpackage.__all__)
__all__.extend(_gui.__all__)

__version_info__ = (0, 6, 3)
__version_info__ = (0, 7, 0)
__version__ = ".".join(str(i) for i in __version_info__)


@_core.deprecated
def JIterator(it):
"""Deprecated"""
return it


# FIXME these should be deprecated. The old JPackage system is only for
# python2 series and generates lots of deceptive classes. At some point
# these two are going to have to go away.
java = JPackage("java")
javax = JPackage("javax")
69 changes: 37 additions & 32 deletions jpype/_classpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,90 @@
import sys as _sys
import glob as _glob

__all__=['addClassPath', 'getClassPath']
__all__ = ['addClassPath', 'getClassPath']

_CLASSPATHS=set()
_CLASSPATHS = set()
_SEP = _os.path.pathsep
if _sys.platform=='cygwin':
_SEP=';'
if _sys.platform == 'cygwin':
_SEP = ';'


def _init():
global _CLASSPATHS
global _SEP
classpath=_os.environ.get("CLASSPATH")
classpath = _os.environ.get("CLASSPATH")
if classpath:
_CLASSPATHS|=set(classpath.split(_SEP))
_CLASSPATHS |= set(classpath.split(_SEP))


_init()

# Cygwin needs to convert to windows paths
if _sys.platform=='cygwin':
_root=None
if _sys.platform == 'cygwin':
_root = None

def _get_root():
global _root
if _root!=None:
if _root != None:
return _root
import subprocess
proc = subprocess.Popen("cygpath -wa /", shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, close_fds=True)
_root=proc.stdout.read().strip().decode('utf-8')
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, close_fds=True)
_root = proc.stdout.read().strip().decode('utf-8')
return _root

def _splitpath(path):
parts=[]
(path, tail)=_os.path.split( path)
parts = []
(path, tail) = _os.path.split(path)
while path and tail:
parts.insert(0,tail)
(path,tail)=_os.path.split(path)
parts.insert(0, tail)
(path, tail) = _os.path.split(path)
return parts

def _posix2win(directory):
root=_get_root()
directory=_os.path.abspath(directory)
paths=_splitpath(directory)
if paths[0]=="cygdrive":
root = _get_root()
directory = _os.path.abspath(directory)
paths = _splitpath(directory)
if paths[0] == "cygdrive":
paths.pop(0)
drive=paths.pop(0)
paths.insert(0, "%s:"%drive)
drive = paths.pop(0)
paths.insert(0, "%s:" % drive)
return '\\'.join(paths)
paths.insert(0,root)
paths.insert(0, root)
return '\\'.join(paths)
# needed for testing
__all__.append("_posix2win")


def addClassPath(path1):
""" Add a path to the java class path"""
global _CLASSPATHS
path1=_os.path.abspath(path1)
if _sys.platform=='cygwin':
path1=_posix2win(path1)
path1 = _os.path.abspath(path1)
if _sys.platform == 'cygwin':
path1 = _posix2win(path1)
_CLASSPATHS.add(str(path1))


def getClassPath():
""" Get the full java class path.
Includes user added paths and the environment CLASSPATH.
"""
global _CLASSPATHS
global _SEP
out=[]
out = []
for path in _CLASSPATHS:
if path=='':
if path == '':
continue
if path.endswith('*'):
paths=_glob.glob(path+".jar")
if len(path)==0:
continue
paths = _glob.glob(path+".jar")
if len(path) == 0:
continue
out.extend(paths)
else:
out.append(path)
return _SEP.join(out)


#print(getClassPath())
# print(getClassPath())
Loading

0 comments on commit a36f892

Please sign in to comment.