FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ffmpeg-python/ffmpeg/_utils.py at extra-examples2 · GamemakerY/ffmpeg-python · GitHub
GamemakerY
/
ffmpeg-python
Public
forked from
kkroening/ffmpeg-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ffmpeg-python
/
ffmpeg
/
_utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (34 loc) · 1.24 KB
Breadcrumbs
ffmpeg-python
/
ffmpeg
/
_utils.py
Copy path
File metadata and controls
43 lines (34 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from
__future__
import
unicode_literals
from
builtins
import
str
from
past
.
builtins
import
basestring
import
hashlib
def
_recursive_repr
(
item
):
"""Hack around python `repr` to deterministically represent dictionaries.
This is able to represent more things than json.dumps, since it does not require things to be JSON serializable
(e.g. datetimes).
"""
if
isinstance
(
item
,
basestring
):
result
=
str
(
item
)
elif
isinstance
(
item
,
list
):
result
=
'[{}]'
.
format
(
', '
.
join
([
_recursive_repr
(
x
)
for
x
in
item
]))
elif
isinstance
(
item
,
dict
):
kv_pairs
=
[
'{}: {}'
.
format
(
_recursive_repr
(
k
),
_recursive_repr
(
item
[
k
]))
for
k
in
sorted
(
item
)]
result
=
'{'
+
', '
.
join
(
kv_pairs
)
+
'}'
else
:
result
=
repr
(
item
)
return
result
def
get_hash
(
item
):
repr_
=
_recursive_repr
(
item
).
encode
(
'utf-8'
)
return
hashlib
.
md5
(
repr_
).
hexdigest
()
def
get_hash_int
(
item
):
return
int
(
get_hash
(
item
),
base
=
16
)
def
escape_chars
(
text
,
chars
):
"""Helper function to escape uncomfortable characters."""
text
=
str
(
text
)
chars
=
list
(
set
(
chars
))
if
'
\\
'
in
chars
:
chars
.
remove
(
'
\\
'
)
chars
.
insert
(
0
,
'
\\
'
)
for
ch
in
chars
:
text
=
text
.
replace
(
ch
,
'
\\
'
+
ch
)
return
text
Back
|
FazBrowse Home
|
New Git URL