Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
beem
Commits
c1dff293
Commit
c1dff293
authored
6 years ago
by
Holger
Browse files
Options
Downloads
Patches
Plain Diff
Add d.tube format to resolve_authorperm,
disable_chain_detection added to graphenerpc (for testing hivemind e.g.)
parent
d3c86505
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
beem/utils.py
+21
-0
21 additions, 0 deletions
beem/utils.py
beemapi/graphenerpc.py
+8
-0
8 additions, 0 deletions
beemapi/graphenerpc.py
beemapi/rpcutils.py
+1
-1
1 addition, 1 deletion
beemapi/rpcutils.py
tests/beem/test_utils.py
+10
-6
10 additions, 6 deletions
tests/beem/test_utils.py
with
40 additions
and
7 deletions
beem/utils.py
+
21
−
0
View file @
c1dff293
...
...
@@ -133,10 +133,31 @@ def resolve_authorperm(identifier):
Splits the string into author and permlink with the
following separator: ``/``.
Examples:
.. code-block:: python
>>>
from
beem.utils
import
resolve_authorperm
>>>
print
(
resolve_authorperm
(
'
https://d.tube/#!/v/pottlund/m5cqkd1a
'
))
(
'
pottlund
'
,
'
m5cqkd1a
'
)
>>>
print
(
resolve_authorperm
(
"
https://steemit.com/witness-category/@gtg/24lfrm-gtg-witness-log
"
))
(
'
gtg
'
,
'
24lfrm-gtg-witness-log
'
)
>>>
print
(
resolve_authorperm
(
"
@gtg/24lfrm-gtg-witness-log
"
))
(
'
gtg
'
,
'
24lfrm-gtg-witness-log
'
)
>>>
print
(
resolve_authorperm
(
"
https://busy.org/@gtg/24lfrm-gtg-witness-log
"
))
(
'
gtg
'
,
'
24lfrm-gtg-witness-log
'
)
"""
# without any http(s)
match
=
re
.
match
(
"
@?([\w\-\.]*)/([\w\-]*)
"
,
identifier
)
if
hasattr
(
match
,
"
group
"
):
return
match
.
group
(
1
),
match
.
group
(
2
)
# dtube url
match
=
re
.
match
(
"
([\w\-\.]+[^#?\s]+)/#!/v/?([\w\-\.]*)/([\w\-]*)
"
,
identifier
)
if
hasattr
(
match
,
"
group
"
):
return
match
.
group
(
2
),
match
.
group
(
3
)
# url
match
=
re
.
match
(
"
([\w\-\.]+[^#?\s]+)/@?([\w\-\.]*)/([\w\-]*)
"
,
identifier
)
if
not
hasattr
(
match
,
"
group
"
):
raise
ValueError
(
"
Invalid identifier
"
)
...
...
This diff is collapsed.
Click to expand it.
beemapi/graphenerpc.py
+
8
−
0
View file @
c1dff293
...
...
@@ -133,6 +133,7 @@ class GrapheneRPC(object):
num_retries
=
kwargs
.
get
(
"
num_retries
"
,
-
1
)
num_retries_call
=
kwargs
.
get
(
"
num_retries_call
"
,
5
)
self
.
use_condenser
=
kwargs
.
get
(
"
use_condenser
"
,
False
)
self
.
disable_chain_detection
=
kwargs
.
get
(
"
disable_chain_detection
"
,
False
)
self
.
known_chains
=
known_chains
custom_chain
=
kwargs
.
get
(
"
custom_chains
"
,
{})
if
len
(
custom_chain
)
>
0
:
...
...
@@ -218,6 +219,13 @@ class GrapheneRPC(object):
if
self
.
ws
:
self
.
ws
.
connect
(
self
.
url
)
self
.
rpclogin
(
self
.
user
,
self
.
password
)
if
self
.
disable_chain_detection
:
# Set to appbase rpc format
if
self
.
current_rpc
==
self
.
rpc_methods
[
'
ws
'
]:
self
.
current_rpc
=
self
.
rpc_methods
[
'
wsappbase
'
]
else
:
self
.
current_rpc
=
self
.
rpc_methods
[
'
appbase
'
]
break
try
:
props
=
None
if
not
self
.
use_condenser
:
...
...
This diff is collapsed.
Click to expand it.
beemapi/rpcutils.py
+
1
−
1
View file @
c1dff293
...
...
@@ -75,7 +75,7 @@ def get_api_name(appbase, *args, **kwargs):
else
:
# Sepcify the api to talk to
if
(
"
api
"
in
kwargs
)
and
len
(
kwargs
[
"
api
"
])
>
0
:
if
kwargs
[
"
api
"
]
!=
"
jsonrpc
"
:
if
kwargs
[
"
api
"
]
not
in
[
"
jsonrpc
"
,
"
hive
"
]
:
api_name
=
kwargs
[
"
api
"
].
replace
(
"
_api
"
,
""
)
+
"
_api
"
else
:
api_name
=
kwargs
[
"
api
"
]
...
...
This diff is collapsed.
Click to expand it.
tests/beem/test_utils.py
+
10
−
6
View file @
c1dff293
...
...
@@ -40,12 +40,16 @@ class Testcases(unittest.TestCase):
self
.
assertEqual
(
assets_from_string
(
'
BTSBOTS.S1:BTS
'
),
[
'
BTSBOTS.S1
'
,
'
BTS
'
])
def
test_authorperm_resolve
(
self
):
self
.
assertEqual
(
resolve_authorperm
(
'
theaussiegame/cryptokittie-giveaway-number-2
'
),
(
'
theaussiegame
'
,
'
cryptokittie-giveaway-number-2
'
))
self
.
assertEqual
(
resolve_authorperm
(
'
holger80/virtuelle-cloud-mining-ponzi-schemen-auch-bekannt-als-hypt
'
),
(
'
holger80
'
,
'
virtuelle-cloud-mining-ponzi-schemen-auch-bekannt-als-hypt
'
))
self
.
assertEqual
(
resolve_authorperm
(
'
https://steemit.com/deutsch/holger80/virtuelle-cloud-mining-ponzi-schemen-auch-bekannt-als-hypt
'
),
(
'
holger80
'
,
'
virtuelle-cloud-mining-ponzi-schemen-auch-bekannt-als-hypt
'
))
self
.
assertEqual
(
resolve_authorperm
(
'
https://d.tube/#!/v/pottlund/m5cqkd1a
'
),
(
'
pottlund
'
,
'
m5cqkd1a
'
))
self
.
assertEqual
(
resolve_authorperm
(
"
https://steemit.com/witness-category/@gtg/24lfrm-gtg-witness-log
"
),
(
'
gtg
'
,
'
24lfrm-gtg-witness-log
'
))
self
.
assertEqual
(
resolve_authorperm
(
"
@gtg/24lfrm-gtg-witness-log
"
),
(
'
gtg
'
,
'
24lfrm-gtg-witness-log
'
))
self
.
assertEqual
(
resolve_authorperm
(
"
https://busy.org/@gtg/24lfrm-gtg-witness-log
"
),
(
'
gtg
'
,
'
24lfrm-gtg-witness-log
'
))
self
.
assertEqual
(
resolve_authorperm
(
'
https://dlive.io/livestream/atnazo/61dd94c1-8ff3-11e8-976f-0242ac110003
'
),
(
'
atnazo
'
,
'
61dd94c1-8ff3-11e8-976f-0242ac110003
'
))
def
test_authorpermvoter_resolve
(
self
):
self
.
assertEqual
(
resolve_authorpermvoter
(
'
theaussiegame/cryptokittie-giveaway-number-2|test
'
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment