Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jpush-api-python-client
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
jpush-api-python-client
Commits
b012beea
Commit
b012beea
authored
Aug 21, 2014
by
hupantingxue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add device entity files;
parent
c6ad335d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
__init__.py
jpush/device/__init__.py
+2
-0
entity.py
jpush/device/entity.py
+98
-0
No files found.
jpush/device/__init__.py
0 → 100644
View file @
b012beea
__author__
=
"wuliang"
__email__
=
"wuliang@jpush.cn"
jpush/device/entity.py
0 → 100644
View file @
b012beea
#!/usr/bin/env python
#-*- coding:utf8 -*-
def
add
(
*
types
):
"""Select a (list of) to be added objects(s)
>>> add("registrationid1", "registrationid2")
{'add': ['registrationid1', 'registrationid2']}
>>> add("tag1", "tag2")
{'add': ['tag1', 'tag2']}
>>> add("alias1", "alias2")
{'add': ['alias1', 'alias2']}
"""
vadd
=
[
v
for
v
in
types
]
return
{
"add"
:
vadd
}
def
remove
(
*
types
):
"""Select a (list of) to be removed objects(s)
>>> remove("registrationid1", "registrationid2")
{'remove': ['registrationid1', 'registrationid2']}
>>> remove("tag1", "tag2")
{'remove': ['tag1', 'tag2']}
>>> remove("alias1", "alias2")
{'remove': ['alias1', 'alias2']}
"""
vremove
=
[
v
for
v
in
types
]
return
{
"remove"
:
vremove
}
def
tag
(
*
types
):
"""Get a tag object
>>> tag("")
{'tag': ''}
>>> tag("tag1")
{'tag': 'tag1'}
>>> tag(add("tag1", "tag2"), remove("tag3", "tag4"))
{'tag': {'add': ['tag1', 'tag2'], 'remove': ['tag3', 'tag4']}}
"""
tag
=
{}
if
1
==
len
(
types
)
and
isinstance
(
types
[
0
],
(
str
,
unicode
)):
tag
[
"tag"
]
=
types
[
0
]
return
tag
tag
[
"tag"
]
=
{}
for
t
in
types
:
for
key
in
t
:
if
key
not
in
(
'add'
,
'remove'
):
raise
ValueError
(
"Invalid tag '
%
s'"
%
t
)
tag
[
"tag"
][
key
]
=
t
[
key
]
return
tag
def
alias
(
*
types
):
"""Get an alias object
>>> alias("")
{'alias': ''}
>>> alias("alias1")
{'alias': 'alias1'}
>>> alias(add("alias1", "alias2"), remove("alias3", "alias4"))
{'alias': {'add': ['alias1', 'alias2'], 'remove': ['alias3', 'alias4']}}
"""
alias
=
{}
if
1
==
len
(
types
)
and
isinstance
(
types
[
0
],
(
str
,
unicode
)):
alias
[
"alias"
]
=
types
[
0
]
return
alias
alias
[
"alias"
]
=
{}
for
t
in
types
:
for
key
in
t
:
if
key
not
in
(
'add'
,
'remove'
):
raise
ValueError
(
"Invalid alias '
%
s'"
%
t
)
alias
[
"alias"
][
key
]
=
t
[
key
]
return
alias
def
registration_id
(
*
types
):
"""Get a registration_id object
>>> registration_id("")
{'registration_id': ''}
>>> registration_id("registration_id1")
{'registration_id': 'registration_id1'}
>>> registration_id(add("registration_id1", "registration_id2"), remove("registration_id3", "registration_id4"))
{'registration_id': {'add': ['registration_id1', 'registration_id2'], 'remove': ['registration_id3', 'registration_id4']}}
"""
registration_id
=
{}
if
1
==
len
(
types
)
and
isinstance
(
types
[
0
],
(
str
,
unicode
)):
registration_id
[
"registration_id"
]
=
types
[
0
]
return
registration_id
registration_id
[
"registration_id"
]
=
{}
for
t
in
types
:
for
key
in
t
:
if
key
not
in
(
'add'
,
'remove'
):
raise
ValueError
(
"Invalid registration_id '
%
s'"
%
t
)
registration_id
[
"registration_id"
][
key
]
=
t
[
key
]
return
registration_id
if
"__main__"
==
__name__
:
print
add
(
"1"
,
"2"
)
print
tag
(
add
(
"a"
,
"b"
),
remove
(
'1'
,
'2'
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment