summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Schaf <flying-sheep@web.de>2013-11-24 11:00:14 +0000
committerPhil Schaf <flying-sheep@web.de>2013-11-24 11:00:14 +0000
commit6e145bdd08b5e9f06448cb5a991e4d8ea3476c58 (patch)
treed6d4b2e999d80fd626a88f0454448a7455ceb3b4
parenta151d5467ce042f903ebc1a166a37fba5ec7d0d5 (diff)
downloadastroid-6e145bdd08b5e9f06448cb5a991e4d8ea3476c58.tar.gz
extracted string_build from file_build. now string_build allows for file_stream to be accessed.
-rw-r--r--builder.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/builder.py b/builder.py
index 6b80f35..e69ae97 100644
--- a/builder.py
+++ b/builder.py
@@ -124,13 +124,18 @@ class AstroidBuilder(InspectBuilder):
except ImportError:
modname = splitext(basename(path))[0]
# build astroid representation
- node = self.string_build(data, modname, path)
- node.file_encoding = encoding
- return node
+ module = self._post_build(self._data_build(data, modname, path))
+ module.file_encoding = encoding
+ return module
def string_build(self, data, modname='', path=None):
"""build astroid from source code string and return rebuilded astroid"""
- module = self._data_build(data, modname, path)
+ module = self._post_build(self._data_build(data, modname, path))
+ module.file_bytes = data.encode('utf-8')
+ module.file_encoding = 'utf-8'
+ return module
+
+ def _post_build(self, module):
self._manager.astroid_cache[module.name] = module
# post tree building steps after we stored the module in the cache:
for from_node in module._from_nodes: