Top Fields Constructors Methods
org.python.indexer

public Class Util

extends Object
Class Inheritance
Imports
java.io.BufferedWriter, .File, .FileInputStream, .FileWriter, .IOException, .InputStream, .PrintWriter, java.security.MessageDigest, java.util.Collection, .Set, .TreeSet

Field Summary

Modifier and TypeField and Description
private static int
private static final String
private static final String
private static final String
private static final char
private static final String

Constructor Summary

AccessConstructor and Description
public
Util()

Method Summary

Modifier and TypeMethod and Description
public static String
public static String
public static String
canonicalize(String path)

Return absolute path for path.

public static String
gensym(String base)

public static byte[]
public static String
getMD5(File path)

public static String
getMD5(byte[] fileContents)

public static String
getQnameParent(String qname)

Returns the parent qname of qname -- everything up to the last dot (exclusive), or if there are no dots, the empty string.

public static String
pack-priv static boolean
public static File
joinPath(File dir, String file)

public static File
joinPath(String dir, String file)

public static String
moduleNameFor(String path)

Given an absolute path to a file (not a directory), returns the module name for the file.

public static String

Returns:

null if file is not somewhere under the load path
moduleQname
(String
absolute canonical path to a file (__init__.py for dirs)
file
)

Determines the fully-qualified module name for the specified file.

public static String
readFile(String filename)

public static String
readFile(File path)

public static void
writeFile(String path, String contents)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

gensymCountback to summary
private static int gensymCount
INIT_PYback to summary
private static final String INIT_PY
SEPback to summary
private static final String SEP
SEP_INIT_PYback to summary
private static final String SEP_INIT_PY
SEPCHARback to summary
private static final char SEPCHAR
UTF_8back to summary
private static final String UTF_8

Constructor Detail

Utilback to summary
public Util()

Method Detail

arrayToSortedStringSetback to summary
public static String arrayToSortedStringSet(Collection<String> strings)
arrayToStringback to summary
public static String arrayToString(Collection<String> strings)
canonicalizeback to summary
public static String canonicalize(String path)

Return absolute path for path. Make sure path ends with SEP if it's a directory. Does _not_ resolve symlinks, since the caller may need to play symlink tricks to produce the desired paths for loaded modules.

gensymback to summary
public static String gensym(String base)
getBytesFromFileback to summary
public static byte[] getBytesFromFile(File file) throws IOException
getMD5back to summary
public static String getMD5(File path) throws Exception
getMD5back to summary
public static String getMD5(byte[] fileContents) throws Exception
getQnameParentback to summary
public static String getQnameParent(String qname)

Returns the parent qname of qname -- everything up to the last dot (exclusive), or if there are no dots, the empty string.

getSystemTempDirback to summary
public static String getSystemTempDir()
isReadableFileback to summary
pack-priv static boolean isReadableFile(String path)
joinPathback to summary
public static File joinPath(File dir, String file)
joinPathback to summary
public static File joinPath(String dir, String file)
moduleNameForback to summary
public static String moduleNameFor(String path)

Given an absolute path to a file (not a directory), returns the module name for the file. If the file is an __init__.py, returns the last component of the file's parent directory, else returns the filename without path or extension.

moduleQnameback to summary
public static String moduleQname(String file)

Determines the fully-qualified module name for the specified file. A module's qname is a function of the module's absolute path and the sys path; it does not depend on how the module name may have been specified in import statements. The module qname is the relative path of the module under the load path, with slashes converted to dots.

Parameters
file:String

absolute canonical path to a file (__init__.py for dirs)

Returns:String

null if file is not somewhere under the load path

readFileback to summary
public static String readFile(String filename) throws Exception
readFileback to summary
public static String readFile(File path) throws Exception
writeFileback to summary
public static void writeFile(String path, String contents) throws Exception