def _java_getprop(name,default): from java.lang import System from org.python.core.Py import newString try: return newString(System.getProperty(name)) except: return default
def _resolve_link(path): """Internal helper function. Takes a path and follows symlinks until we either arrive at something that isn't a symlink, or encounter a path we've seen before (meaning that there's a loop). """ try: return newString(java.io.File(abspath(path)).getCanonicalPath()) except java.io.IOException: return None
def abspath(path): """Return the absolute version of a path.""" if not isabs(path): path = join(os.getcwd(), path) if not splitunc(path)[0] and not splitdrive(path)[0]: # cwd lacks a UNC mount point, so it should have a drive # letter (but lacks one): determine it canon_path = newString(java.io.File(path).getCanonicalPath()) drive = splitdrive(canon_path)[0] path = join(drive, path) return normpath(path)
def samefile(f1, f2): """Test whether two pathnames reference the same actual file""" canon1 = newString(java.io.File(_ensure_str(f1)).getCanonicalPath()) canon2 = newString(java.io.File(_ensure_str(f2)).getCanonicalPath()) return canon1 == canon2
def _java_getprop(name,default): try: return newString(System.getProperty(name)) except: return default
def __new__(cls, grp): grp = (newString(grp.name), newString(grp.password), int(grp.GID), [newString(member) for member in grp.members]) return tuple.__new__(cls, grp)
def __new__(cls, pwd): pwd = (newString(pwd.loginName), newString(pwd.password), int(pwd.UID), int(pwd.GID), newString(pwd.GECOS), newString(pwd.home), newString(pwd.shell)) return tuple.__new__(cls, pwd)