From 4dcb23cfe521f344ac1412c8831b92585bce3695 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sat, 28 Apr 2018 17:15:42 +0200 Subject: [PATCH] {Post,Profile,StoryItem}.get_node() -> ._as_dict() This is consistend with namedtuple._as_dict() and marks it as a protected member, which is good as it should be only accessed by save_structure_to_file(). --- instaloader/structures.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/instaloader/structures.py b/instaloader/structures.py index 78cffd4..3b309cf 100644 --- a/instaloader/structures.py +++ b/instaloader/structures.py @@ -75,13 +75,13 @@ class Post: """Create a post object from a given mediaid""" return cls.from_shortcode(context, mediaid_to_shortcode(mediaid)) - def get_node(self): + def _asdict(self): if self._full_metadata_dict: node = self._full_metadata_dict else: node = self._node if self._owner_profile: - node['owner'] = self.owner_profile.get_node() + node['owner'] = self.owner_profile._asdict() if self._location: node['location'] = self._location._asdict() return node @@ -399,7 +399,7 @@ class Profile: username = Post.from_mediaid(context, int(data['edges'][0]["node"]["id"])).owner_username return cls(context, {'username': username.lower(), 'id': profile_id}) - def get_node(self): + def _asdict(self): json_node = self._node.copy() # remove posts json_node.pop('edge_media_collections', None) @@ -578,10 +578,10 @@ class StoryItem: self._node = node self._owner_profile = owner_profile - def get_node(self): + def _asdict(self): node = self._node if self._owner_profile: - node['owner'] = self._owner_profile.get_node() + node['owner'] = self._owner_profile._asdict() return node @property @@ -776,7 +776,7 @@ def save_structure_to_file(structure: JsonExportable, filename: str) -> None: :param structure: :class:`Post`, :class:`Profile` or :class:`StoryItem` :param filename: Filename, ends in '.json' or '.json.xz' """ - json_structure = {'node': structure.get_node(), + json_structure = {'node': structure._asdict(), 'instaloader': {'version': __version__, 'node_type': structure.__class__.__name__}} compress = filename.endswith('.xz') if compress: