Mercurial > kallithea
annotate rhodecode/lib/dbmigrate/migrate/versioning/util/importpath.py @ 1976:a76e9bacbedc beta
garden
- unified logging formatting to use only %
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 02 Feb 2012 00:31:00 +0200 |
parents | 6832ef664673 |
children |
rev | line source |
---|---|
833
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 import os |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 import sys |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 def import_path(fullpath): |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 """ Import a file with full path specification. Allows one to |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
833
diff
changeset
|
6 import from anywhere, something __import__ does not do. |
833
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 """ |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 # http://zephyrfalcon.org/weblog/arch_d7_2002_08_31.html |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 path, filename = os.path.split(fullpath) |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 filename, ext = os.path.splitext(filename) |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 sys.path.append(path) |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 module = __import__(filename) |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 reload(module) # Might be out of date during tests |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 del sys.path[-1] |
9753e0907827
added dbmigrate package, added model changes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 return module |