steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
154 stars 100 forks source link

Removed '@' from construct_identifier. #184

Closed cyon1c closed 6 years ago

cyon1c commented 6 years ago

construct_identifier was responsible for formatting the permlink, and had wonky handling of the '@' at the beginning of the permlink. Removed to improve clarity.

roadscape commented 6 years ago

Quick search for relevant @'s in the code base:

steem/post.py:30:            post (str or dict): ``@author/permlink`` or raw ``comment`` as
steem/post.py:50:            post["author"] = post["author"].replace('@', '')
steem/post.py:62:        return '%s' % uri.split('@')[-1]
steem/post.py:71:        if "body" in post and re.match("^@@", post["body"]):
steem/post.py:140:        m = re.match("/([^/]*)/@([^/]*)/([^#]*).*", post.get("url", ""))
steem/post.py:160:        Usage: all_comments = Post.get_all_replies(Post('@foo/bar'))
steem/commit.py:184:        `@author/permlink`).
steem/commit.py:359:                                   the form ``@author/permlink``
steem/commit.py:1311:            :param str identifier: post identifier (@<account>/<permlink>)
steem/cli.py:178:        help='@author/permlink-identifier of the post to upvote ' +
steem/cli.py:179:             'to (e.g. @xeroc/python-steem-0-1)')
steem/cli.py:205:        help='@author/permlink-identifier of the post to downvote ' +
steem/cli.py:206:             'to (e.g. @xeroc/python-steem-0-1)')
steem/cli.py:587:        help='@author/permlink-identifier of the post to resteem')
steem/cli.py:779:        if (args.key in ["default_account"] and args.value[0] == "@"):
steem/cli.py:869:            elif re.match(".*@.{3,16}/.*$", obj):
steem/cli.py:1014:                print("\n@%s" % a.name)
steem/utils.py:26:# @@ (source offset, length) (target offset, length) @@ (section header)
steem/utils.py:28:    r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?\ @@[ ]?(.*)$",
steem/utils.py:291:    match = re.match("@?([\w\-\.]*)/([\w\-]*)", identifier)
steem/steemd.py:82:        state = self.get_state("/@%s/recent-replies" % author)
steem/steemd.py:111:                              identifier of the form ``@author/permlink``

Any remaining suspects in here?

cyon1c commented 6 years ago

@roadscape - excellent catch. I performed a much more limited search of '@'.

After reviewing the code a little more, it does look like documentation directed users to pass in an identifier with the @ sign attached. So that we don't break any legacy code, I just added to both construct_identifier and resolve_identifier to remove any @ signs that users may pass to us.