Redirect a Python import by using a dummy Python module that deletes its own reference and replaces it with relative module or package.
Allows more control over a relative directory structure
// Modified excerpt from: | |
// https://developer.mozilla.org/en-US/docs/JavaScript/Introduction_to_Object-Oriented_JavaScript | |
// define the Person Class | |
function Person(name) { | |
//Public property | |
this.name = name; | |
//Private property |
#Compact example to get the name of the primary key field of a Django model. | |
loc_fields = self._model._meta.fields | |
loc_pk = next((f.db_column or f.name for f in loc_fields if f.primary_key)) | |
#Get all related model classes for a model class or instance | |
related_models = [f.rel.to for f in loc_record._meta.fields if f.rel] |
class DictWrap(object): | |
""" Wrap an existing dict, or create a new one, and access with either dot | |
notation or key lookup. | |
The attribute _data is reserved and stores the underlying dictionary. | |
When using the += operator with create=True, the empty nested dict is | |
replaced with the operand, effectively creating a default dictionary | |
of mixed types. | |
args: |
""" ArcGIS 10.0 ToolValidator - Import package or module relative to .tbx file | |
Rules for packages: | |
1. You can't import a subpackage (__init__.py) directly for example: | |
# This works: | |
import myPackage | |
myPackage.mySubPackage.doSomething() | |
# This doesn't work |