The JPython Registry - Python

JPython, as Java, uses its own environment variable namespace. The reason for that is because there isn't a standard cross -platform way to handle environment variables, doing what the Windows Registry does for the Win32 platform, for example. The required namespace can be obtained from the following sources:

  1. The Java system properties, which are usually informed through the -D option on the command line prompt of the interpreter.
  2. The JPython registry file, which contains prop=value pairs. The location of this file is identified according to the algorithm listed in the next subtopic.
  3. The user's personal registry file, which contains correspondingly prop =value pairs of properties. This file is located at user.home"+"/.jpython.

The previous sources are listed in the same order in which they are invoked when trying to build the namespace. Note that if you have values provided for later options, they override the values defined by default for the prior options.

Registry Properties

Next is a list of the properties that are recognized by the JPython interpreter. You can easily study these and others, with more accuracy, by examining the JPython's registry file. python .cachedir — Stores the name of the directory to use for caches. If noabsolute path is informed, it is assumed that its location is relative to the sys.prefixvariable.

python.jpythonc.classpath — Stores a list of extensions to the standard java.class .path property for use with jpythonc .python .jpythonc .compiler — Contains the absolute (or relative) path of the Java compiler to use with jpythonc. If just the compiler name is provided, it isassumed that the executable can be located by looking at your system PATH variable. python.jpythonc.compileropts — Keeps the list of options to pass to the Java compiler when using jpythonc.python.path — Corresponds to CPython's PYTHON PATH environment variable. — Setting this property to false (in case you have a Java 1.2 installation) provides you access to non-public members of classes, such as methods and constructors.

python.verbose— Setting this property to one of the following values:

"error", "warning","message", "comment", "debug"

sets the verbosity level for varying degrees of informative messages. Note that these values are listed in order of increasing verbosity.

Finding the Registry File

The following steps are required to correctly identify the JPython registry file to use.

Step 1: You need to create a root directory, which can be based either on the value of the property python.home, or the value of the property install.root, whichever is found first.

Step 2: If none of them is found, JPython tries to locate a file called jpython.jar by looking at the system property java.class.path. Note that one of the paths listed in this property must explicitly include the jpython.jar file.

Step 3: Now, that JPython has identified our root directory, it populates the values of both sys .prefixand sys .exec _prefixvariables based on the root information.

Step 4: The variable sys.pathhas an entry added to its list, <rootdir> /Lib, where <rootdir>is the root dir that we've found previously.

Step 5: Our initial goal can be finally reached now because the registry file is stored at the <rootdir> directory, and to have permission to it, you just need to access the location <rootdir> /registry.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

Python Topics