org.python.indexer
Class Util
- java.lang.Object
-
- org.python.indexer.Util
-
public class Util extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor and Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.lang.StringarrayToSortedStringSet(java.util.Collection<java.lang.String> strings)static java.lang.StringarrayToString(java.util.Collection<java.lang.String> strings)static java.lang.Stringcanonicalize(java.lang.String path)Return absolute path forpath.static java.lang.Stringgensym(java.lang.String base)static byte[]getBytesFromFile(java.io.File file)static java.lang.StringgetMD5(byte[] fileContents)static java.lang.StringgetMD5(java.io.File path)static java.lang.StringgetQnameParent(java.lang.String qname)Returns the parent qname ofqname-- everything up to the last dot (exclusive), or if there are no dots, the empty string.static java.lang.StringgetSystemTempDir()static java.io.FilejoinPath(java.io.File dir, java.lang.String file)static java.io.FilejoinPath(java.lang.String dir, java.lang.String file)static java.lang.StringmoduleNameFor(java.lang.String path)Given an absolutepathto a file (not a directory), returns the module name for the file.static java.lang.StringmoduleQname(java.lang.String file)Determines the fully-qualified module name for the specified file.static java.lang.StringreadFile(java.io.File path)static java.lang.StringreadFile(java.lang.String filename)static voidwriteFile(java.lang.String path, java.lang.String contents)
-
-
-
Method Detail
-
gensym
public static java.lang.String gensym(java.lang.String base)
-
getSystemTempDir
public static java.lang.String getSystemTempDir()
-
getQnameParent
public static java.lang.String getQnameParent(java.lang.String qname)
Returns the parent qname ofqname-- everything up to the last dot (exclusive), or if there are no dots, the empty string.
-
moduleQname
public static java.lang.String moduleQname(java.lang.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- absolute canonical path to a file (__init__.py for dirs)- Returns:
- null if
fileis not somewhere under the load path
-
arrayToString
public static java.lang.String arrayToString(java.util.Collection<java.lang.String> strings)
-
arrayToSortedStringSet
public static java.lang.String arrayToSortedStringSet(java.util.Collection<java.lang.String> strings)
-
moduleNameFor
public static java.lang.String moduleNameFor(java.lang.String path)
Given an absolutepathto 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.
-
joinPath
public static java.io.File joinPath(java.io.File dir, java.lang.String file)
-
joinPath
public static java.io.File joinPath(java.lang.String dir, java.lang.String file)
-
writeFile
public static void writeFile(java.lang.String path, java.lang.String contents) throws java.lang.Exception- Throws:
java.lang.Exception
-
readFile
public static java.lang.String readFile(java.lang.String filename) throws java.lang.Exception- Throws:
java.lang.Exception
-
readFile
public static java.lang.String readFile(java.io.File path) throws java.lang.Exception- Throws:
java.lang.Exception
-
getBytesFromFile
public static byte[] getBytesFromFile(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
getMD5
public static java.lang.String getMD5(java.io.File path) throws java.lang.Exception- Throws:
java.lang.Exception
-
getMD5
public static java.lang.String getMD5(byte[] fileContents) throws java.lang.Exception- Throws:
java.lang.Exception
-
canonicalize
public static java.lang.String canonicalize(java.lang.String path)
Return absolute path forpath. 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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG