nwo
stringlengths
10
28
sha
stringlengths
40
40
path
stringlengths
11
97
identifier
stringlengths
1
64
parameters
stringlengths
2
2.24k
return_statement
stringlengths
0
2.17k
docstring
stringlengths
0
5.45k
docstring_summary
stringlengths
0
3.83k
func_begin
int64
1
13.4k
func_end
int64
2
13.4k
function
stringlengths
28
56.4k
url
stringlengths
106
209
project
int64
1
48
executed_lines
list
executed_lines_pc
float64
0
153
missing_lines
list
missing_lines_pc
float64
0
100
covered
bool
2 classes
filecoverage
float64
2.53
100
function_lines
int64
2
1.46k
mccabe
int64
1
253
coverage
float64
0
100
docstring_lines
int64
0
112
function_nodoc
stringlengths
9
56.4k
id
int64
0
29.8k
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/multiply_speed.py
multiply_speed
(clip, factor=None, final_duration=None)
return new_clip
Returns a clip playing the current clip but at a speed multiplied by ``factor``. Instead of factor one can indicate the desired ``final_duration`` of the clip, and the factor will be automatically computed. The same effect is applied to the clip's audio and mask if any.
Returns a clip playing the current clip but at a speed multiplied by ``factor``.
1
16
def multiply_speed(clip, factor=None, final_duration=None): """Returns a clip playing the current clip but at a speed multiplied by ``factor``. Instead of factor one can indicate the desired ``final_duration`` of the clip, and the factor will be automatically computed. The same effect is applied to the cli...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/multiply_speed.py#L1-L16
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
100
[]
0
true
100
16
3
100
5
def multiply_speed(clip, factor=None, final_duration=None): if final_duration: factor = 1.0 * clip.duration / final_duration new_clip = clip.time_transform(lambda t: factor * t, apply_to=["mask", "audio"]) if clip.duration is not None: new_clip = new_clip.with_duration(1.0 * clip.duration ...
28,567
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/resize.py
_get_cv2_resizer
()
return (resizer, [])
4
20
def _get_cv2_resizer(): try: import cv2 except ImportError: return (None, ["OpenCV not found (install 'opencv-python')"]) def resizer(pic, new_size): lx, ly = int(new_size[0]), int(new_size[1]) if lx > pic.shape[1] or ly > pic.shape[0]: # For upsizing use linear ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/resize.py#L4-L20
46
[ 0, 1, 2, 3, 4, 5 ]
35.294118
[ 6, 7, 8, 10, 13, 14, 16 ]
41.176471
false
78.095238
17
5
58.823529
0
def _get_cv2_resizer(): try: import cv2 except ImportError: return (None, ["OpenCV not found (install 'opencv-python')"]) def resizer(pic, new_size): lx, ly = int(new_size[0]), int(new_size[1]) if lx > pic.shape[1] or ly > pic.shape[0]: # For upsizing use linear ...
28,568
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/resize.py
_get_PIL_resizer
()
return (resizer, [])
23
45
def _get_PIL_resizer(): try: from PIL import Image except ImportError: return (None, ["PIL not found (install 'Pillow')"]) import numpy as np def resizer(pic, new_size): new_size = list(map(int, new_size))[::-1] # shape = pic.shape # if len(shape) == 3: ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/resize.py#L23-L45
46
[ 0, 1, 2, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 ]
91.304348
[ 3, 4 ]
8.695652
false
78.095238
23
3
91.304348
0
def _get_PIL_resizer(): try: from PIL import Image except ImportError: return (None, ["PIL not found (install 'Pillow')"]) import numpy as np def resizer(pic, new_size): new_size = list(map(int, new_size))[::-1] # shape = pic.shape # if len(shape) == 3: ...
28,569
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/resize.py
_get_scipy_resizer
()
return (resizer, [])
48
77
def _get_scipy_resizer(): try: from scipy.misc import imresize except ImportError: try: from scipy import __version__ as __scipy_version__ except ImportError: return (None, ["Scipy not found (install 'scipy' or 'Pillow')"]) scipy_version_info = tuple( ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/resize.py#L48-L77
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
30
[ 9, 14, 15, 24, 26, 27, 29 ]
23.333333
false
78.095238
30
5
76.666667
0
def _get_scipy_resizer(): try: from scipy.misc import imresize except ImportError: try: from scipy import __version__ as __scipy_version__ except ImportError: return (None, ["Scipy not found (install 'scipy' or 'Pillow')"]) scipy_version_info = tuple( ...
28,570
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/resize.py
_get_resizer
()
return {"resizer": None, "origin": None, "error_msgs": reversed(error_messages)}
Tries to define a ``resizer`` function using next libraries, in the given order: - cv2 - PIL - scipy Returns a dictionary with following attributes: - ``resizer``: Function used to resize images in ``resize`` FX function. - ``origin``: Library used to resize. - ``error_msgs``: If any ...
Tries to define a ``resizer`` function using next libraries, in the given order:
80
110
def _get_resizer(): """Tries to define a ``resizer`` function using next libraries, in the given order: - cv2 - PIL - scipy Returns a dictionary with following attributes: - ``resizer``: Function used to resize images in ``resize`` FX function. - ``origin``: Library used to resize. ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/resize.py#L80-L110
46
[ 0, 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 ]
96.774194
[ 30 ]
3.225806
false
78.095238
31
3
96.774194
14
def _get_resizer(): error_messages = [] resizer_getters = { "cv2": _get_cv2_resizer, "PIL": _get_PIL_resizer, "scipy": _get_scipy_resizer, } for origin, resizer_getter in resizer_getters.items(): resizer, _error_messages = resizer_getter() if resizer is not None:...
28,571
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/resize.py
resize
(clip, new_size=None, height=None, width=None, apply_to_mask=True)
return new_clip
Returns a video clip that is a resized version of the clip. Parameters ---------- new_size : tuple or float or function, optional Can be either - ``(width, height)`` in pixels or a float representing - A scaling factor, like ``0.5``. - A function of time returning one of thes...
Returns a video clip that is a resized version of the clip.
121
236
def resize(clip, new_size=None, height=None, width=None, apply_to_mask=True): """Returns a video clip that is a resized version of the clip. Parameters ---------- new_size : tuple or float or function, optional Can be either - ``(width, height)`` in pixels or a float representing ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/resize.py#L121-L236
46
[ 0, 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, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54...
100
[]
0
true
78.095238
116
22
100
26
def resize(clip, new_size=None, height=None, width=None, apply_to_mask=True): w, h = clip.size if new_size is not None: def translate_new_size(new_size_): if isinstance(new_size_, numbers.Number): return [new_size_ * w, new_size_ * h] else: retur...
28,572
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/blackwhite.py
blackwhite
(clip, RGB=None, preserve_luminosity=True)
return clip.image_transform(filter)
Desaturates the picture, makes it black and white. Parameter RGB allows to set weights for the different color channels. If RBG is 'CRT_phosphor' a special set of values is used. preserve_luminosity maintains the sum of RGB to 1.
Desaturates the picture, makes it black and white. Parameter RGB allows to set weights for the different color channels. If RBG is 'CRT_phosphor' a special set of values is used. preserve_luminosity maintains the sum of RGB to 1.
4
23
def blackwhite(clip, RGB=None, preserve_luminosity=True): """Desaturates the picture, makes it black and white. Parameter RGB allows to set weights for the different color channels. If RBG is 'CRT_phosphor' a special set of values is used. preserve_luminosity maintains the sum of RGB to 1. """ ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/blackwhite.py#L4-L23
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 ]
100
[]
0
true
100
20
4
100
5
def blackwhite(clip, RGB=None, preserve_luminosity=True): if RGB is None: RGB = [1, 1, 1] if RGB == "CRT_phosphor": RGB = [0.2125, 0.7154, 0.0721] R, G, B = 1.0 * np.array(RGB) / (sum(RGB) if preserve_luminosity else 1) def filter(im): im = R * im[:, :, 0] + G * im[:, :, 1] + ...
28,573
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/mask_color.py
mask_color
(clip, color=None, threshold=0, stiffness=1)
return new_clip
Returns a new clip with a mask for transparency where the original clip is of the given color. You can also have a "progressive" mask by specifying a non-null distance threshold ``threshold``. In this case, if the distance between a pixel and the given color is d, the transparency will be d**stiff...
Returns a new clip with a mask for transparency where the original clip is of the given color.
4
34
def mask_color(clip, color=None, threshold=0, stiffness=1): """Returns a new clip with a mask for transparency where the original clip is of the given color. You can also have a "progressive" mask by specifying a non-null distance threshold ``threshold``. In this case, if the distance between a pixel a...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/mask_color.py#L4-L34
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 ]
93.548387
[ 14, 20 ]
6.451613
false
86.666667
31
5
93.548387
11
def mask_color(clip, color=None, threshold=0, stiffness=1): if color is None: color = [0, 0, 0] color = np.array(color) def hill(x): if threshold: return x**stiffness / (threshold**stiffness + x**stiffness) else: return 1.0 * (x != 0) def flim(im): ...
28,574
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/freeze.py
freeze
(clip, t=0, freeze_duration=None, total_duration=None, padding_end=0)
return concatenate_videoclips(before + freeze + after)
Momentarily freeze the clip at time t. Set `t='end'` to freeze the clip at the end (actually it will freeze on the frame at time clip.duration - padding_end seconds - 1 / clip_fps). With ``duration`` you can specify the duration of the freeze. With ``total_duration`` you can specify the total duration ...
Momentarily freeze the clip at time t.
6
29
def freeze(clip, t=0, freeze_duration=None, total_duration=None, padding_end=0): """Momentarily freeze the clip at time t. Set `t='end'` to freeze the clip at the end (actually it will freeze on the frame at time clip.duration - padding_end seconds - 1 / clip_fps). With ``duration`` you can specify the...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/freeze.py#L6-L29
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 ]
100
[]
0
true
100
24
4
100
8
def freeze(clip, t=0, freeze_duration=None, total_duration=None, padding_end=0): if t == "end": t = clip.duration - padding_end - 1 / clip.fps if freeze_duration is None: if total_duration is None: raise ValueError( "You must provide either 'freeze_duration' or 'tota...
28,575
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/headblur.py
headblur
(clip, fx, fy, radius, intensity=None)
return clip.transform(filter)
Returns a filter that will blur a moving part (a head ?) of the frames. The position of the blur at time t is defined by (fx(t), fy(t)), the radius of the blurring by ``radius`` and the intensity of the blurring by ``intensity``. Requires OpenCV for the circling and the blurring. Automatically deals with ...
Returns a filter that will blur a moving part (a head ?) of the frames.
16
46
def headblur(clip, fx, fy, radius, intensity=None): """Returns a filter that will blur a moving part (a head ?) of the frames. The position of the blur at time t is defined by (fx(t), fy(t)), the radius of the blurring by ``radius`` and the intensity of the blurring by ``intensity``. Requires OpenCV f...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/headblur.py#L16-L46
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
29.032258
[ 9, 10, 12, 13, 14, 15, 16, 17, 18, 20, 21, 23, 25, 26, 27, 28, 30 ]
54.83871
false
32.258065
31
3
45.16129
7
def headblur(clip, fx, fy, radius, intensity=None): if intensity is None: intensity = int(2 * radius / 3) def filter(gf, t): im = gf(t).copy() h, w, d = im.shape x, y = int(fx(t)), int(fy(t)) x1, x2 = max(0, x - radius), min(x + radius, w) y1, y2 = max(0, y - rad...
28,576
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/fadeout.py
fadeout
(clip, duration, final_color=None)
return clip.transform(filter)
Makes the clip progressively fade to some color (black by default), over ``duration`` seconds at the end of the clip. Can be used for masks too, where the final color must be a number between 0 and 1. For cross-fading (progressive appearance or disappearance of a clip over another clip, see ``transfx.c...
Makes the clip progressively fade to some color (black by default), over ``duration`` seconds at the end of the clip. Can be used for masks too, where the final color must be a number between 0 and 1.
7
27
def fadeout(clip, duration, final_color=None): """Makes the clip progressively fade to some color (black by default), over ``duration`` seconds at the end of the clip. Can be used for masks too, where the final color must be a number between 0 and 1. For cross-fading (progressive appearance or disappea...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/fadeout.py#L7-L27
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
100
[]
0
true
100
21
4
100
6
def fadeout(clip, duration, final_color=None): if final_color is None: final_color = 0 if clip.is_mask else [0, 0, 0] final_color = np.array(final_color) def filter(get_frame, t): if (clip.duration - t) >= duration: return get_frame(t) else: fading = 1.0 * (...
28,577
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/mirror_x.py
mirror_x
(clip, apply_to="mask")
return clip.image_transform(lambda img: img[:, ::-1], apply_to=apply_to)
Flips the clip horizontally (and its mask too, by default).
Flips the clip horizontally (and its mask too, by default).
1
3
def mirror_x(clip, apply_to="mask"): """Flips the clip horizontally (and its mask too, by default).""" return clip.image_transform(lambda img: img[:, ::-1], apply_to=apply_to)
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/mirror_x.py#L1-L3
46
[ 0, 1, 2 ]
100
[]
0
true
100
3
1
100
1
def mirror_x(clip, apply_to="mask"): return clip.image_transform(lambda img: img[:, ::-1], apply_to=apply_to)
28,578
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/mirror_y.py
mirror_y
(clip, apply_to="mask")
return clip.image_transform(lambda img: img[::-1], apply_to=apply_to)
Flips the clip vertically (and its mask too, by default).
Flips the clip vertically (and its mask too, by default).
1
3
def mirror_y(clip, apply_to="mask"): """Flips the clip vertically (and its mask too, by default).""" return clip.image_transform(lambda img: img[::-1], apply_to=apply_to)
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/mirror_y.py#L1-L3
46
[ 0, 1, 2 ]
100
[]
0
true
100
3
1
100
1
def mirror_y(clip, apply_to="mask"): return clip.image_transform(lambda img: img[::-1], apply_to=apply_to)
28,579
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/even_size.py
even_size
(clip)
return clip.image_transform(image_filter)
Crops the clip to make dimensions even.
Crops the clip to make dimensions even.
5
28
def even_size(clip): """Crops the clip to make dimensions even.""" w, h = clip.size w_even = w % 2 == 0 h_even = h % 2 == 0 if w_even and h_even: return clip if not w_even and not h_even: def image_filter(a): return a[:-1, :-1, :] elif h_even: def imag...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/even_size.py#L5-L28
46
[ 0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 ]
95.833333
[ 6 ]
4.166667
false
94.117647
24
9
95.833333
1
def even_size(clip): w, h = clip.size w_even = w % 2 == 0 h_even = h % 2 == 0 if w_even and h_even: return clip if not w_even and not h_even: def image_filter(a): return a[:-1, :-1, :] elif h_even: def image_filter(a): return a[:, :-1, :] ...
28,580
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/freeze_region.py
freeze_region
(clip, t=0, region=None, outside_region=None, mask=None)
Freezes one region of the clip while the rest remains animated. You can choose one of three methods by providing either `region`, `outside_region`, or `mask`. Parameters ---------- t Time at which to freeze the freezed region. region A tuple (x1, y1, x2, y2) defining the region o...
Freezes one region of the clip while the rest remains animated.
5
51
def freeze_region(clip, t=0, region=None, outside_region=None, mask=None): """Freezes one region of the clip while the rest remains animated. You can choose one of three methods by providing either `region`, `outside_region`, or `mask`. Parameters ---------- t Time at which to freeze th...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/freeze_region.py#L5-L51
46
[ 0, 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 ]
93.617021
[ 44, 45, 46 ]
6.382979
false
80
47
4
93.617021
23
def freeze_region(clip, t=0, region=None, outside_region=None, mask=None): if region is not None: x1, y1, x2, y2 = region freeze = ( clip.fx(crop, *region) .to_ImageClip(t=t) .with_duration(clip.duration) .with_position((x1, y1)) ) ret...
28,581
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/fadein.py
fadein
(clip, duration, initial_color=None)
return clip.transform(filter)
Makes the clip progressively appear from some color (black by default), over ``duration`` seconds at the beginning of the clip. Can be used for masks too, where the initial color must be a number between 0 and 1. For cross-fading (progressive appearance or disappearance of a clip over another clip, see...
Makes the clip progressively appear from some color (black by default), over ``duration`` seconds at the beginning of the clip. Can be used for masks too, where the initial color must be a number between 0 and 1.
4
24
def fadein(clip, duration, initial_color=None): """Makes the clip progressively appear from some color (black by default), over ``duration`` seconds at the beginning of the clip. Can be used for masks too, where the initial color must be a number between 0 and 1. For cross-fading (progressive appearanc...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/fadein.py#L4-L24
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
100
[]
0
true
100
21
4
100
6
def fadein(clip, duration, initial_color=None): if initial_color is None: initial_color = 0 if clip.is_mask else [0, 0, 0] initial_color = np.array(initial_color) def filter(get_frame, t): if t >= duration: return get_frame(t) else: fading = 1.0 * t / durati...
28,582
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/gamma_corr.py
gamma_corr
(clip, gamma)
return clip.image_transform(filter)
Gamma-correction of a video clip.
Gamma-correction of a video clip.
1
8
def gamma_corr(clip, gamma): """Gamma-correction of a video clip.""" def filter(im): corrected = 255 * (1.0 * im / 255) ** gamma return corrected.astype("uint8") return clip.image_transform(filter)
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/gamma_corr.py#L1-L8
46
[ 0, 1, 2 ]
37.5
[ 3, 4, 5, 7 ]
50
false
20
8
2
50
1
def gamma_corr(clip, gamma): def filter(im): corrected = 255 * (1.0 * im / 255) ** gamma return corrected.astype("uint8") return clip.image_transform(filter)
28,583
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/multiply_color.py
multiply_color
(clip, factor)
return clip.image_transform( lambda frame: np.minimum(255, (factor * frame)).astype("uint8") )
Multiplies the clip's colors by the given factor, can be used to decrease or increase the clip's brightness (is that the right word ?)
Multiplies the clip's colors by the given factor, can be used to decrease or increase the clip's brightness (is that the right word ?)
4
12
def multiply_color(clip, factor): """ Multiplies the clip's colors by the given factor, can be used to decrease or increase the clip's brightness (is that the right word ?) """ return clip.image_transform( lambda frame: np.minimum(255, (factor * frame)).astype("uint8") )
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/multiply_color.py#L4-L12
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
100
[]
0
true
100
9
1
100
3
def multiply_color(clip, factor): return clip.image_transform( lambda frame: np.minimum(255, (factor * frame)).astype("uint8") )
28,584
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/fx/time_symmetrize.py
time_symmetrize
(clip)
return concatenate_videoclips([clip, clip.fx(time_mirror)])
Returns a clip that plays the current clip once forwards and then once backwards. This is very practival to make video that loop well, e.g. to create animated GIFs. This effect is automatically applied to the clip's mask and audio if they exist.
Returns a clip that plays the current clip once forwards and then once backwards. This is very practival to make video that loop well, e.g. to create animated GIFs. This effect is automatically applied to the clip's mask and audio if they exist.
8
16
def time_symmetrize(clip): """ Returns a clip that plays the current clip once forwards and then once backwards. This is very practival to make video that loop well, e.g. to create animated GIFs. This effect is automatically applied to the clip's mask and audio if they exist. """ return ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/fx/time_symmetrize.py#L8-L16
46
[ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
100
[]
0
true
100
9
1
100
5
def time_symmetrize(clip): return concatenate_videoclips([clip, clip.fx(time_mirror)])
28,585
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/concatenate.py
concatenate_videoclips
( clips, method="chain", transition=None, bg_color=None, is_mask=False, padding=0 )
return result
Concatenates several video clips. Returns a video clip made by clip by concatenating several video clips. (Concatenated means that they will be played one after another). There are two methods: - method="chain": will produce a clip that simply outputs the frames of the successive clips, without...
Concatenates several video clips.
12
122
def concatenate_videoclips( clips, method="chain", transition=None, bg_color=None, is_mask=False, padding=0 ): """Concatenates several video clips. Returns a video clip made by clip by concatenating several video clips. (Concatenated means that they will be played one after another). There are two...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/concatenate.py#L12-L122
46
[ 0, 48, 49, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102...
54.954955
[ 50, 51, 52 ]
2.702703
false
92.857143
111
20
97.297297
44
def concatenate_videoclips( clips, method="chain", transition=None, bg_color=None, is_mask=False, padding=0 ): if transition is not None: clip_transition_pairs = [[v, transition] for v in clips[:-1]] clips = reduce(lambda x, y: x + y, clip_transition_pairs) + [clips[-1]] transition = Non...
28,586
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/CompositeVideoClip.py
clips_array
(array, rows_widths=None, cols_heights=None, bg_color=None)
return CompositeVideoClip(array.flatten(), size=(xs[-1], ys[-1]), bg_color=bg_color)
Given a matrix whose rows are clips, creates a CompositeVideoClip where all clips are placed side by side horizontally for each clip in each row and one row on top of the other for each row. So given next matrix of clips with same size: ```python clips_array([[clip1, clip2, clip3], [clip4, clip5, c...
Given a matrix whose rows are clips, creates a CompositeVideoClip where all clips are placed side by side horizontally for each clip in each row and one row on top of the other for each row. So given next matrix of clips with same size:
151
217
def clips_array(array, rows_widths=None, cols_heights=None, bg_color=None): """Given a matrix whose rows are clips, creates a CompositeVideoClip where all clips are placed side by side horizontally for each clip in each row and one row on top of the other for each row. So given next matrix of clips with...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/CompositeVideoClip.py#L151-L217
46
[ 0, 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, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54...
95.522388
[ 60 ]
1.492537
false
92
67
9
98.507463
39
def clips_array(array, rows_widths=None, cols_heights=None, bg_color=None): array = np.array(array) sizes_array = np.array([[clip.size for clip in line] for line in array]) # find row width and col_widths automatically if not provided if rows_widths is None: rows_widths = sizes_array[:, :, 1].m...
28,587
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/CompositeVideoClip.py
CompositeVideoClip.__init__
( self, clips, size=None, bg_color=None, use_bgclip=False, is_mask=False )
54
116
def __init__( self, clips, size=None, bg_color=None, use_bgclip=False, is_mask=False ): if size is None: size = clips[0].size if use_bgclip and (clips[0].mask is None): transparent = False else: transparent = bg_color is None if bg_color...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/CompositeVideoClip.py#L54-L116
46
[ 0, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 59, 60 ]
79.365079
[]
0
false
92
63
13
100
0
def __init__( self, clips, size=None, bg_color=None, use_bgclip=False, is_mask=False ): if size is None: size = clips[0].size if use_bgclip and (clips[0].mask is None): transparent = False else: transparent = bg_color is None if bg_color...
28,588
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/CompositeVideoClip.py
CompositeVideoClip.make_frame
(self, t)
return np.array(im)
The clips playing at time `t` are blitted over one another.
The clips playing at time `t` are blitted over one another.
118
131
def make_frame(self, t): """The clips playing at time `t` are blitted over one another.""" frame = self.bg.get_frame(t).astype("uint8") im = Image.fromarray(frame) if self.bg.mask is not None: frame_mask = self.bg.mask.get_frame(t) im_mask = Image.fromarray(255 *...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/CompositeVideoClip.py#L118-L131
46
[ 0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13 ]
78.571429
[ 6, 7, 8 ]
21.428571
false
92
14
3
78.571429
1
def make_frame(self, t): frame = self.bg.get_frame(t).astype("uint8") im = Image.fromarray(frame) if self.bg.mask is not None: frame_mask = self.bg.mask.get_frame(t) im_mask = Image.fromarray(255 * frame_mask).convert("L") im = im.putalpha(im_mask) f...
28,589
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/CompositeVideoClip.py
CompositeVideoClip.playing_clips
(self, t=0)
return [clip for clip in self.clips if clip.is_playing(t)]
Returns a list of the clips in the composite clips that are actually playing at the given time `t`.
Returns a list of the clips in the composite clips that are actually playing at the given time `t`.
133
137
def playing_clips(self, t=0): """Returns a list of the clips in the composite clips that are actually playing at the given time `t`. """ return [clip for clip in self.clips if clip.is_playing(t)]
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/CompositeVideoClip.py#L133-L137
46
[ 0, 1, 2, 3, 4 ]
100
[]
0
true
92
5
2
100
2
def playing_clips(self, t=0): return [clip for clip in self.clips if clip.is_playing(t)]
28,590
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/CompositeVideoClip.py
CompositeVideoClip.close
(self)
Closes the instance, releasing all the resources.
Closes the instance, releasing all the resources.
139
148
def close(self): """Closes the instance, releasing all the resources.""" if self.created_bg and self.bg: # Only close the background clip if it was locally created. # Otherwise, it remains the job of whoever created it. self.bg.close() self.bg = None ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/CompositeVideoClip.py#L139-L148
46
[ 0, 1, 2, 3, 4, 5, 6, 7 ]
80
[ 8, 9 ]
20
false
92
10
5
80
1
def close(self): if self.created_bg and self.bg: # Only close the background clip if it was locally created. # Otherwise, it remains the job of whoever created it. self.bg.close() self.bg = None if hasattr(self, "audio") and self.audio: self.au...
28,591
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/transitions.py
crossfadein
(clip, duration)
return new_clip
Makes the clip appear progressively, over ``duration`` seconds. Only works when the clip is included in a CompositeVideoClip.
Makes the clip appear progressively, over ``duration`` seconds. Only works when the clip is included in a CompositeVideoClip.
15
22
def crossfadein(clip, duration): """Makes the clip appear progressively, over ``duration`` seconds. Only works when the clip is included in a CompositeVideoClip. """ clip.mask.duration = clip.duration new_clip = clip.copy() new_clip.mask = clip.mask.fx(fadein, duration) return new_clip
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/transitions.py#L15-L22
46
[ 0, 1, 2, 3, 4, 5, 6, 7 ]
100
[]
0
true
100
8
1
100
2
def crossfadein(clip, duration): clip.mask.duration = clip.duration new_clip = clip.copy() new_clip.mask = clip.mask.fx(fadein, duration) return new_clip
28,592
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/transitions.py
crossfadeout
(clip, duration)
return new_clip
Makes the clip disappear progressively, over ``duration`` seconds. Only works when the clip is included in a CompositeVideoClip.
Makes the clip disappear progressively, over ``duration`` seconds. Only works when the clip is included in a CompositeVideoClip.
27
34
def crossfadeout(clip, duration): """Makes the clip disappear progressively, over ``duration`` seconds. Only works when the clip is included in a CompositeVideoClip. """ clip.mask.duration = clip.duration new_clip = clip.copy() new_clip.mask = clip.mask.fx(fadeout, duration) return new_clip
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/transitions.py#L27-L34
46
[ 0, 1, 2, 3, 4, 5, 6, 7 ]
100
[]
0
true
100
8
1
100
2
def crossfadeout(clip, duration): clip.mask.duration = clip.duration new_clip = clip.copy() new_clip.mask = clip.mask.fx(fadeout, duration) return new_clip
28,593
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/transitions.py
slide_in
(clip, duration, side)
return clip.with_position(pos_dict[side])
Makes the clip arrive from one side of the screen. Only works when the clip is included in a CompositeVideoClip, and if the clip has the same size as the whole composition. Parameters ---------- clip : moviepy.Clip.Clip A video clip. duration : float Time taken for the clip to be...
Makes the clip arrive from one side of the screen.
37
81
def slide_in(clip, duration, side): """Makes the clip arrive from one side of the screen. Only works when the clip is included in a CompositeVideoClip, and if the clip has the same size as the whole composition. Parameters ---------- clip : moviepy.Clip.Clip A video clip. duration ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/transitions.py#L37-L81
46
[ 0, 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, 44 ]
100
[]
0
true
100
45
1
100
34
def slide_in(clip, duration, side): w, h = clip.size pos_dict = { "left": lambda t: (min(0, w * (t / duration - 1)), "center"), "right": lambda t: (max(0, w * (1 - t / duration)), "center"), "top": lambda t: ("center", min(0, h * (t / duration - 1))), "bottom": lambda t: ("center...
28,594
Zulko/moviepy
858bb81fba7e09f1f562283ed6d1394db883b6c7
moviepy/video/compositing/transitions.py
slide_out
(clip, duration, side)
return clip.with_position(pos_dict[side])
Makes the clip go away by one side of the screen. Only works when the clip is included in a CompositeVideoClip, and if the clip has the same size as the whole composition. Parameters ---------- clip : moviepy.Clip.Clip A video clip. duration : float Time taken for the clip to ful...
Makes the clip go away by one side of the screen.
85
128
def slide_out(clip, duration, side): """Makes the clip go away by one side of the screen. Only works when the clip is included in a CompositeVideoClip, and if the clip has the same size as the whole composition. Parameters ---------- clip : moviepy.Clip.Clip A video clip. duration ...
https://github.com/Zulko/moviepy/blob/858bb81fba7e09f1f562283ed6d1394db883b6c7/project46/moviepy/video/compositing/transitions.py#L85-L128
46
[ 0, 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 ]
100
[]
0
true
100
44
1
100
32
def slide_out(clip, duration, side): w, h = clip.size ts = clip.duration - duration # start time of the effect. pos_dict = { "left": lambda t: (min(0, w * (-(t - ts) / duration)), "center"), "right": lambda t: (max(0, w * ((t - ts) / duration)), "center"), "top": lambda t: ("center"...
28,595
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
hn
(tag: str)
return 0
13
18
def hn(tag: str) -> int: if tag[0] == "h" and len(tag) == 2: n = tag[1] if "0" < n <= "9": return int(n) return 0
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L13-L18
48
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
98.461538
6
4
100
0
def hn(tag: str) -> int: if tag[0] == "h" and len(tag) == 2: n = tag[1] if "0" < n <= "9": return int(n) return 0
29,729
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
dumb_property_dict
(style: str)
return { x.strip().lower(): y.strip().lower() for x, y in [z.split(":", 1) for z in style.split(";") if ":" in z] }
:returns: A hash of css attributes
:returns: A hash of css attributes
21
28
def dumb_property_dict(style: str) -> Dict[str, str]: """ :returns: A hash of css attributes """ return { x.strip().lower(): y.strip().lower() for x, y in [z.split(":", 1) for z in style.split(";") if ":" in z] }
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L21-L28
48
[ 0, 1, 2, 3, 4, 5, 6, 7 ]
100
[]
0
true
98.461538
8
2
100
1
def dumb_property_dict(style: str) -> Dict[str, str]: return { x.strip().lower(): y.strip().lower() for x, y in [z.split(":", 1) for z in style.split(";") if ":" in z] }
29,730
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
dumb_css_parser
(data: str)
return elements
:type data: str :returns: A hash of css selectors, each of which contains a hash of css attributes. :rtype: dict
:type data: str
31
54
def dumb_css_parser(data: str) -> Dict[str, Dict[str, str]]: """ :type data: str :returns: A hash of css selectors, each of which contains a hash of css attributes. :rtype: dict """ # remove @import sentences data += ";" importIndex = data.find("@import") while importIndex != -1...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L31-L54
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23 ]
91.666667
[ 20, 21 ]
8.333333
false
98.461538
24
4
91.666667
5
def dumb_css_parser(data: str) -> Dict[str, Dict[str, str]]: # remove @import sentences data += ";" importIndex = data.find("@import") while importIndex != -1: data = data[0:importIndex] + data[data.find(";", importIndex) + 1 :] importIndex = data.find("@import") # parse the css. re...
29,731
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
element_style
( attrs: Dict[str, Optional[str]], style_def: Dict[str, Dict[str, str]], parent_style: Dict[str, str], )
return style
:type attrs: dict :type style_def: dict :type style_def: dict :returns: A hash of the 'final' style attributes of the element :rtype: dict
:type attrs: dict :type style_def: dict :type style_def: dict
57
81
def element_style( attrs: Dict[str, Optional[str]], style_def: Dict[str, Dict[str, str]], parent_style: Dict[str, str], ) -> Dict[str, str]: """ :type attrs: dict :type style_def: dict :type style_def: dict :returns: A hash of the 'final' style attributes of the element :rtype: dict...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L57-L81
48
[ 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ]
56
[]
0
false
98.461538
25
6
100
6
def element_style( attrs: Dict[str, Optional[str]], style_def: Dict[str, Dict[str, str]], parent_style: Dict[str, str], ) -> Dict[str, str]: style = parent_style.copy() if "class" in attrs: assert attrs["class"] is not None for css_class in attrs["class"].split(): css_sty...
29,732
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
google_list_style
(style: Dict[str, str])
return "ol"
Finds out whether this is an ordered or unordered list :type style: dict :rtype: str
Finds out whether this is an ordered or unordered list
84
97
def google_list_style(style: Dict[str, str]) -> str: """ Finds out whether this is an ordered or unordered list :type style: dict :rtype: str """ if "list-style-type" in style: list_style = style["list-style-type"] if list_style in ["disc", "circle", "square", "none"]: ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L84-L97
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
100
[]
0
true
98.461538
14
3
100
5
def google_list_style(style: Dict[str, str]) -> str: if "list-style-type" in style: list_style = style["list-style-type"] if list_style in ["disc", "circle", "square", "none"]: return "ul" return "ol"
29,733
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
google_has_height
(style: Dict[str, str])
return "height" in style
Check if the style of the element has the 'height' attribute explicitly defined :type style: dict :rtype: bool
Check if the style of the element has the 'height' attribute explicitly defined
100
109
def google_has_height(style: Dict[str, str]) -> bool: """ Check if the style of the element has the 'height' attribute explicitly defined :type style: dict :rtype: bool """ return "height" in style
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L100-L109
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
100
[]
0
true
98.461538
10
1
100
6
def google_has_height(style: Dict[str, str]) -> bool: return "height" in style
29,734
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
google_text_emphasis
(style: Dict[str, str])
return emphasis
:type style: dict :returns: A list of all emphasis modifiers of the element :rtype: list
:type style: dict
112
127
def google_text_emphasis(style: Dict[str, str]) -> List[str]: """ :type style: dict :returns: A list of all emphasis modifiers of the element :rtype: list """ emphasis = [] if "text-decoration" in style: emphasis.append(style["text-decoration"]) if "font-style" in style: ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L112-L127
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
100
[]
0
true
98.461538
16
4
100
4
def google_text_emphasis(style: Dict[str, str]) -> List[str]: emphasis = [] if "text-decoration" in style: emphasis.append(style["text-decoration"]) if "font-style" in style: emphasis.append(style["font-style"]) if "font-weight" in style: emphasis.append(style["font-weight"]) ...
29,735
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
google_fixed_width_font
(style: Dict[str, str])
return "courier new" == font_family or "consolas" == font_family
Check if the css of the current element defines a fixed width font :type style: dict :rtype: bool
Check if the css of the current element defines a fixed width font
130
141
def google_fixed_width_font(style: Dict[str, str]) -> bool: """ Check if the css of the current element defines a fixed width font :type style: dict :rtype: bool """ font_family = "" if "font-family" in style: font_family = style["font-family"] return "courier new" == font_fami...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L130-L141
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
100
[]
0
true
98.461538
12
3
100
5
def google_fixed_width_font(style: Dict[str, str]) -> bool: font_family = "" if "font-family" in style: font_family = style["font-family"] return "courier new" == font_family or "consolas" == font_family
29,736
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
list_numbering_start
(attrs: Dict[str, Optional[str]])
return 0
Extract numbering from list element attributes :type attrs: dict :rtype: int or None
Extract numbering from list element attributes
144
159
def list_numbering_start(attrs: Dict[str, Optional[str]]) -> int: """ Extract numbering from list element attributes :type attrs: dict :rtype: int or None """ if "start" in attrs: assert attrs["start"] is not None try: return int(attrs["start"]) - 1 except V...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L144-L159
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ]
100
[]
0
true
98.461538
16
4
100
5
def list_numbering_start(attrs: Dict[str, Optional[str]]) -> int: if "start" in attrs: assert attrs["start"] is not None try: return int(attrs["start"]) - 1 except ValueError: pass return 0
29,737
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
skipwrap
( para: str, wrap_links: bool, wrap_list_items: bool, wrap_tables: bool )
return bool( config.RE_ORDERED_LIST_MATCHER.match(stripped) or config.RE_UNORDERED_LIST_MATCHER.match(stripped) )
162
196
def skipwrap( para: str, wrap_links: bool, wrap_list_items: bool, wrap_tables: bool ) -> bool: # If it appears to contain a link # don't wrap if not wrap_links and config.RE_LINK.search(para): return True # If the text begins with four spaces or one tab, it's a code block; # don't wrap ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L162-L196
48
[ 0, 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 ]
82.857143
[]
0
false
98.461538
35
13
100
0
def skipwrap( para: str, wrap_links: bool, wrap_list_items: bool, wrap_tables: bool ) -> bool: # If it appears to contain a link # don't wrap if not wrap_links and config.RE_LINK.search(para): return True # If the text begins with four spaces or one tab, it's a code block; # don't wrap ...
29,738
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
escape_md
(text: str)
return config.RE_MD_CHARS_MATCHER.sub(r"\\\1", text)
Escapes markdown-sensitive characters within other markdown constructs.
Escapes markdown-sensitive characters within other markdown constructs.
199
204
def escape_md(text: str) -> str: """ Escapes markdown-sensitive characters within other markdown constructs. """ return config.RE_MD_CHARS_MATCHER.sub(r"\\\1", text)
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L199-L204
48
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
98.461538
6
1
100
2
def escape_md(text: str) -> str: return config.RE_MD_CHARS_MATCHER.sub(r"\\\1", text)
29,739
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
escape_md_section
(text: str, snob: bool = False)
return text
Escapes markdown-sensitive characters across whole document sections.
Escapes markdown-sensitive characters across whole document sections.
207
220
def escape_md_section(text: str, snob: bool = False) -> str: """ Escapes markdown-sensitive characters across whole document sections. """ text = config.RE_MD_BACKSLASH_MATCHER.sub(r"\\\1", text) if snob: text = config.RE_MD_CHARS_MATCHER_ALL.sub(r"\\\1", text) text = config.RE_MD_DOT_...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L207-L220
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
100
[]
0
true
98.461538
14
2
100
1
def escape_md_section(text: str, snob: bool = False) -> str: text = config.RE_MD_BACKSLASH_MATCHER.sub(r"\\\1", text) if snob: text = config.RE_MD_CHARS_MATCHER_ALL.sub(r"\\\1", text) text = config.RE_MD_DOT_MATCHER.sub(r"\1\\\2", text) text = config.RE_MD_PLUS_MATCHER.sub(r"\1\\\2", text) ...
29,740
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
reformat_table
(lines: List[str], right_margin: int)
return new_lines
Given the lines of a table padds the cells and returns the new lines
Given the lines of a table padds the cells and returns the new lines
223
264
def reformat_table(lines: List[str], right_margin: int) -> List[str]: """ Given the lines of a table padds the cells and returns the new lines """ # find the maximum width of the columns max_width = [len(x.rstrip()) + right_margin for x in lines[0].split("|")] max_cols = len(max_width) f...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L223-L264
48
[ 0, 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 ]
100
[]
0
true
98.461538
42
13
100
2
def reformat_table(lines: List[str], right_margin: int) -> List[str]: # find the maximum width of the columns max_width = [len(x.rstrip()) + right_margin for x in lines[0].split("|")] max_cols = len(max_width) for line in lines: cols = [x.rstrip() for x in line.split("|")] num_cols = len...
29,741
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/utils.py
pad_tables_in_text
(text: str, right_margin: int = 1)
return "\n".join(new_lines)
Provide padding for tables in the text
Provide padding for tables in the text
267
290
def pad_tables_in_text(text: str, right_margin: int = 1) -> str: """ Provide padding for tables in the text """ lines = text.split("\n") table_buffer = [] # type: List[str] table_started = False new_lines = [] for line in lines: # Toggle table started if config.TABLE_MAR...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/utils.py#L267-L290
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 ]
100
[]
0
true
98.461538
24
5
100
1
def pad_tables_in_text(text: str, right_margin: int = 1) -> str: lines = text.split("\n") table_buffer = [] # type: List[str] table_started = False new_lines = [] for line in lines: # Toggle table started if config.TABLE_MARKER_FOR_PAD in line: table_started = not table_...
29,742
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
html2text
(html: str, baseurl: str = "", bodywidth: Optional[int] = None)
return h.handle(html)
994
999
def html2text(html: str, baseurl: str = "", bodywidth: Optional[int] = None) -> str: if bodywidth is None: bodywidth = config.BODY_WIDTH h = HTML2Text(baseurl=baseurl, bodywidth=bodywidth) return h.handle(html)
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L994-L999
48
[ 0, 1, 2, 3, 4, 5 ]
100
[]
0
true
97.322835
6
2
100
0
def html2text(html: str, baseurl: str = "", bodywidth: Optional[int] = None) -> str: if bodywidth is None: bodywidth = config.BODY_WIDTH h = HTML2Text(baseurl=baseurl, bodywidth=bodywidth) return h.handle(html)
29,743
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.__init__
( self, out: Optional[OutCallback] = None, baseurl: str = "", bodywidth: int = config.BODY_WIDTH, )
Input parameters: out: possible custom replacement for self.outtextf (which appends lines of text). baseurl: base URL of the document we process
Input parameters: out: possible custom replacement for self.outtextf (which appends lines of text). baseurl: base URL of the document we process
38
138
def __init__( self, out: Optional[OutCallback] = None, baseurl: str = "", bodywidth: int = config.BODY_WIDTH, ) -> None: """ Input parameters: out: possible custom replacement for self.outtextf (which appends lines of text). ba...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L38-L138
48
[ 0, 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, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 57, 58, 59, 60, 61, 62, 63, 64, ...
88.118812
[ 55 ]
0.990099
false
97.322835
101
2
99.009901
4
def __init__( self, out: Optional[OutCallback] = None, baseurl: str = "", bodywidth: int = config.BODY_WIDTH, ) -> None: super().__init__(convert_charrefs=False) # Config options self.split_next_td = False self.td_count = 0 self.table_start = ...
29,744
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.feed
(self, data: str)
140
142
def feed(self, data: str) -> None: data = data.replace("</' + 'script>", "</ignore>") super().feed(data)
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L140-L142
48
[ 0, 1, 2 ]
100
[]
0
true
97.322835
3
1
100
0
def feed(self, data: str) -> None: data = data.replace("</' + 'script>", "</ignore>") super().feed(data)
29,745
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle
(self, data: str)
144
151
def handle(self, data: str) -> str: self.feed(data) self.feed("") markdown = self.optwrap(self.finish()) if self.pad_tables: return pad_tables_in_text(markdown) else: return markdown
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L144-L151
48
[ 0, 1, 2, 3, 4, 5, 7 ]
87.5
[]
0
false
97.322835
8
2
100
0
def handle(self, data: str) -> str: self.feed(data) self.feed("") markdown = self.optwrap(self.finish()) if self.pad_tables: return pad_tables_in_text(markdown) else: return markdown
29,746
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.outtextf
(self, s: str)
153
156
def outtextf(self, s: str) -> None: self.outtextlist.append(s) if s: self.lastWasNL = s[-1] == "\n"
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L153-L156
48
[ 0, 1, 2, 3 ]
100
[]
0
true
97.322835
4
2
100
0
def outtextf(self, s: str) -> None: self.outtextlist.append(s) if s: self.lastWasNL = s[-1] == "\n"
29,747
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.finish
(self)
return outtext
158
176
def finish(self) -> str: self.close() self.pbr() self.o("", force="end") outtext = "".join(self.outtextlist) if self.unicode_snob: nbsp = html.entities.html5["nbsp;"] else: nbsp = " " outtext = outtext.replace("&nbsp_place_holder;", nbsp...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L158-L176
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18 ]
94.736842
[]
0
false
97.322835
19
2
100
0
def finish(self) -> str: self.close() self.pbr() self.o("", force="end") outtext = "".join(self.outtextlist) if self.unicode_snob: nbsp = html.entities.html5["nbsp;"] else: nbsp = " " outtext = outtext.replace("&nbsp_place_holder;", nbsp...
29,748
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle_charref
(self, c: str)
178
179
def handle_charref(self, c: str) -> None: self.handle_data(self.charref(c), True)
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L178-L179
48
[ 0, 1 ]
100
[]
0
true
97.322835
2
1
100
0
def handle_charref(self, c: str) -> None: self.handle_data(self.charref(c), True)
29,749
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle_entityref
(self, c: str)
181
191
def handle_entityref(self, c: str) -> None: ref = self.entityref(c) # ref may be an empty string (e.g. for &lrm;/&rlm; markers that should # not contribute to the final output). # self.handle_data cannot handle a zero-length string right after a # stressed tag or mid-text within...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L181-L191
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
100
[]
0
true
97.322835
11
2
100
0
def handle_entityref(self, c: str) -> None: ref = self.entityref(c) # ref may be an empty string (e.g. for &lrm;/&rlm; markers that should # not contribute to the final output). # self.handle_data cannot handle a zero-length string right after a # stressed tag or mid-text within...
29,750
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle_starttag
(self, tag: str, attrs: List[Tuple[str, Optional[str]]])
193
194
def handle_starttag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: self.handle_tag(tag, dict(attrs), start=True)
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L193-L194
48
[ 0, 1 ]
100
[]
0
true
97.322835
2
1
100
0
def handle_starttag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]) -> None: self.handle_tag(tag, dict(attrs), start=True)
29,751
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle_endtag
(self, tag: str)
196
197
def handle_endtag(self, tag: str) -> None: self.handle_tag(tag, {}, start=False)
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L196-L197
48
[ 0, 1 ]
100
[]
0
true
97.322835
2
1
100
0
def handle_endtag(self, tag: str) -> None: self.handle_tag(tag, {}, start=False)
29,752
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.previousIndex
(self, attrs: Dict[str, Optional[str]])
return None
:type attrs: dict :returns: The index of certain set of attributes (of a link) in the self.a list. If the set of attributes is not found, returns None :rtype: int
:type attrs: dict
199
225
def previousIndex(self, attrs: Dict[str, Optional[str]]) -> Optional[int]: """ :type attrs: dict :returns: The index of certain set of attributes (of a link) in the self.a list. If the set of attributes is not found, returns None :rtype: int """ if "href" not in ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L199-L225
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ]
96.296296
[ 9 ]
3.703704
false
97.322835
27
11
96.296296
5
def previousIndex(self, attrs: Dict[str, Optional[str]]) -> Optional[int]: if "href" not in attrs: return None match = False for i, a in enumerate(self.a): if "href" in a.attrs and a.attrs["href"] == attrs["href"]: if "title" in a.attrs or "title" in attr...
29,753
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle_emphasis
( self, start: bool, tag_style: Dict[str, str], parent_style: Dict[str, str] )
Handles various text emphases
Handles various text emphases
227
298
def handle_emphasis( self, start: bool, tag_style: Dict[str, str], parent_style: Dict[str, str] ) -> None: """ Handles various text emphases """ tag_emphasis = google_text_emphasis(tag_style) parent_emphasis = google_text_emphasis(parent_style) # handle Googl...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L227-L298
48
[ 0, 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, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, ...
94.444444
[]
0
false
97.322835
72
29
100
1
def handle_emphasis( self, start: bool, tag_style: Dict[str, str], parent_style: Dict[str, str] ) -> None: tag_emphasis = google_text_emphasis(tag_style) parent_emphasis = google_text_emphasis(parent_style) # handle Google's text emphasis strikethrough = "line-through" in ta...
29,754
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle_tag
( self, tag: str, attrs: Dict[str, Optional[str]], start: bool )
300
721
def handle_tag( self, tag: str, attrs: Dict[str, Optional[str]], start: bool ) -> None: self.current_tag = tag if self.tag_callback is not None: if self.tag_callback(self, tag, attrs, start) is True: return # first thing inside the anchor tag is another ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L300-L721
48
[ 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 33, 36, 37, 38, 39, 40, 41, 55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 68, 69, 70, 72, 73, 74, 75, 76, 77, 78, 80, ...
79.620853
[ 42, 43, 45, 46, 47, 48, 49, 51, 52, 53, 336 ]
2.606635
false
97.322835
422
161
97.393365
0
def handle_tag( self, tag: str, attrs: Dict[str, Optional[str]], start: bool ) -> None: self.current_tag = tag if self.tag_callback is not None: if self.tag_callback(self, tag, attrs, start) is True: return # first thing inside the anchor tag is another ...
29,755
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.pbr
(self)
Pretty print has a line break
Pretty print has a line break
724
727
def pbr(self) -> None: "Pretty print has a line break" if self.p_p == 0: self.p_p = 1
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L724-L727
48
[ 0, 2, 3 ]
75
[]
0
false
97.322835
4
2
100
1
def pbr(self) -> None: "Pretty print has a line break" if self.p_p == 0: self.p_p = 1
29,756
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.p
(self)
Set pretty print to 1 or 2 lines
Set pretty print to 1 or 2 lines
729
731
def p(self) -> None: "Set pretty print to 1 or 2 lines" self.p_p = 1 if self.single_line_break else 2
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L729-L731
48
[ 0, 2 ]
66.666667
[]
0
false
97.322835
3
1
100
1
def p(self) -> None: "Set pretty print to 1 or 2 lines" self.p_p = 1 if self.single_line_break else 2
29,757
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.soft_br
(self)
Soft breaks
Soft breaks
733
736
def soft_br(self) -> None: "Soft breaks" self.pbr() self.br_toggle = " "
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L733-L736
48
[ 0, 2, 3 ]
75
[]
0
false
97.322835
4
1
100
1
def soft_br(self) -> None: "Soft breaks" self.pbr() self.br_toggle = " "
29,758
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.o
( self, data: str, puredata: bool = False, force: Union[bool, str] = False )
Deal with indentation and whitespace
Deal with indentation and whitespace
738
849
def o( self, data: str, puredata: bool = False, force: Union[bool, str] = False ) -> None: """ Deal with indentation and whitespace """ if self.abbr_data is not None: self.abbr_data += data if not self.quiet: if self.google_doc: ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L738-L849
48
[ 0, 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, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, ...
94.642857
[ 97 ]
0.892857
false
97.322835
112
44
99.107143
1
def o( self, data: str, puredata: bool = False, force: Union[bool, str] = False ) -> None: if self.abbr_data is not None: self.abbr_data += data if not self.quiet: if self.google_doc: # prevent white space immediately after 'begin emphasis' ...
29,759
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.handle_data
(self, data: str, entity_char: bool = False)
851
892
def handle_data(self, data: str, entity_char: bool = False) -> None: if not data: # Data may be empty for some HTML entities. For example, # LEFT-TO-RIGHT MARK. return if self.stressed: data = data.strip() self.stressed = False sel...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L851-L892
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41 ]
78.571429
[]
0
false
97.322835
42
15
100
0
def handle_data(self, data: str, entity_char: bool = False) -> None: if not data: # Data may be empty for some HTML entities. For example, # LEFT-TO-RIGHT MARK. return if self.stressed: data = data.strip() self.stressed = False sel...
29,760
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.charref
(self, name: str)
894
906
def charref(self, name: str) -> str: if name[0] in ["x", "X"]: c = int(name[1:], 16) else: c = int(name) if not self.unicode_snob and c in unifiable_n: return unifiable_n[c] else: try: return chr(c) except Value...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L894-L906
48
[ 0, 1, 4, 5, 6, 7, 9, 10, 11, 12 ]
76.923077
[ 2 ]
7.692308
false
97.322835
13
5
92.307692
0
def charref(self, name: str) -> str: if name[0] in ["x", "X"]: c = int(name[1:], 16) else: c = int(name) if not self.unicode_snob and c in unifiable_n: return unifiable_n[c] else: try: return chr(c) except Value...
29,761
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.entityref
(self, c: str)
return config.UNIFIABLE[c] if c == "nbsp" else ch
908
915
def entityref(self, c: str) -> str: if not self.unicode_snob and c in config.UNIFIABLE: return config.UNIFIABLE[c] try: ch = html.entities.html5[c + ";"] except KeyError: return "&" + c + ";" return config.UNIFIABLE[c] if c == "nbsp" else ch
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L908-L915
48
[ 0, 1, 2, 3, 4, 7 ]
75
[ 5, 6 ]
25
false
97.322835
8
4
75
0
def entityref(self, c: str) -> str: if not self.unicode_snob and c in config.UNIFIABLE: return config.UNIFIABLE[c] try: ch = html.entities.html5[c + ";"] except KeyError: return "&" + c + ";" return config.UNIFIABLE[c] if c == "nbsp" else ch
29,762
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.google_nest_count
(self, style: Dict[str, str])
return nest_count
Calculate the nesting count of google doc lists :type style: dict :rtype: int
Calculate the nesting count of google doc lists
917
929
def google_nest_count(self, style: Dict[str, str]) -> int: """ Calculate the nesting count of google doc lists :type style: dict :rtype: int """ nest_count = 0 if "margin-left" in style: nest_count = int(style["margin-left"][:-2]) // self.google_list...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L917-L929
48
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
100
[]
0
true
97.322835
13
2
100
5
def google_nest_count(self, style: Dict[str, str]) -> int: nest_count = 0 if "margin-left" in style: nest_count = int(style["margin-left"][:-2]) // self.google_list_indent return nest_count
29,763
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/__init__.py
HTML2Text.optwrap
(self, text: str)
return result
Wrap all paragraphs in the provided text. :type text: str :rtype: str
Wrap all paragraphs in the provided text.
931
991
def optwrap(self, text: str) -> str: """ Wrap all paragraphs in the provided text. :type text: str :rtype: str """ if not self.body_width: return text result = "" newlines = 0 # I cannot think of a better solution for now. # ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/__init__.py#L931-L991
48
[ 0, 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, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54...
100
[]
0
true
97.322835
61
12
100
5
def optwrap(self, text: str) -> str: if not self.body_width: return text result = "" newlines = 0 # I cannot think of a better solution for now. # To avoid the non-wrap behaviour for entire paras # because of the presence of a link in it if not self.w...
29,764
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/elements.py
AnchorElement.__init__
(self, attrs: Dict[str, Optional[str]], count: int, outcount: int)
7
10
def __init__(self, attrs: Dict[str, Optional[str]], count: int, outcount: int): self.attrs = attrs self.count = count self.outcount = outcount
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/elements.py#L7-L10
48
[ 0, 1, 2, 3 ]
100
[]
0
true
100
4
1
100
0
def __init__(self, attrs: Dict[str, Optional[str]], count: int, outcount: int): self.attrs = attrs self.count = count self.outcount = outcount
29,765
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/elements.py
ListElement.__init__
(self, name: str, num: int)
16
18
def __init__(self, name: str, num: int): self.name = name self.num = num
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/elements.py#L16-L18
48
[ 0, 1, 2 ]
100
[]
0
true
100
3
1
100
0
def __init__(self, name: str, num: int): self.name = name self.num = num
29,766
Alir3z4/html2text
a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1
html2text/typing.py
OutCallback.__call__
(self, s: str)
2
3
def __call__(self, s: str) -> None: ...
https://github.com/Alir3z4/html2text/blob/a3ed67b69160746b03a5861bf5c1b7a5ba76a4e1/project48/html2text/typing.py#L2-L3
48
[ 0 ]
50
[ 1 ]
50
false
66.666667
2
1
50
0
def __call__(self, s: str) -> None: ...
29,768