partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | YouTube.get_vid_from_url | Extracts video ID from URL. | src/you_get/extractors/youtube.py | def get_vid_from_url(url):
"""Extracts video ID from URL.
"""
return match1(url, r'youtu\.be/([^?/]+)') or \
match1(url, r'youtube\.com/embed/([^/?]+)') or \
match1(url, r'youtube\.com/v/([^/?]+)') or \
match1(url, r'youtube\.com/watch/([^/?]+)') or \
pars... | def get_vid_from_url(url):
"""Extracts video ID from URL.
"""
return match1(url, r'youtu\.be/([^?/]+)') or \
match1(url, r'youtube\.com/embed/([^/?]+)') or \
match1(url, r'youtube\.com/v/([^/?]+)') or \
match1(url, r'youtube\.com/watch/([^/?]+)') or \
pars... | [
"Extracts",
"video",
"ID",
"from",
"URL",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/youtube.py#L135-L143 | [
"def",
"get_vid_from_url",
"(",
"url",
")",
":",
"return",
"match1",
"(",
"url",
",",
"r'youtu\\.be/([^?/]+)'",
")",
"or",
"match1",
"(",
"url",
",",
"r'youtube\\.com/embed/([^/?]+)'",
")",
"or",
"match1",
"(",
"url",
",",
"r'youtube\\.com/v/([^/?]+)'",
")",
"or... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | sina_xml_to_url_list | str->list
Convert XML to URL List.
From Biligrab. | src/you_get/extractors/miomio.py | def sina_xml_to_url_list(xml_data):
"""str->list
Convert XML to URL List.
From Biligrab.
"""
rawurl = []
dom = parseString(xml_data)
for node in dom.getElementsByTagName('durl'):
url = node.getElementsByTagName('url')[0]
rawurl.append(url.childNodes[0].data)
return rawurl | def sina_xml_to_url_list(xml_data):
"""str->list
Convert XML to URL List.
From Biligrab.
"""
rawurl = []
dom = parseString(xml_data)
for node in dom.getElementsByTagName('durl'):
url = node.getElementsByTagName('url')[0]
rawurl.append(url.childNodes[0].data)
return rawurl | [
"str",
"-",
">",
"list",
"Convert",
"XML",
"to",
"URL",
"List",
".",
"From",
"Biligrab",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/miomio.py#L41-L51 | [
"def",
"sina_xml_to_url_list",
"(",
"xml_data",
")",
":",
"rawurl",
"=",
"[",
"]",
"dom",
"=",
"parseString",
"(",
"xml_data",
")",
"for",
"node",
"in",
"dom",
".",
"getElementsByTagName",
"(",
"'durl'",
")",
":",
"url",
"=",
"node",
".",
"getElementsByTag... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | makeMimi | From http://cdn37.atwikiimg.com/sitescript/pub/dksitescript/FC2.site.js
Also com.hps.util.fc2.FC2EncrptUtil.makeMimiLocal
L110 | src/you_get/extractors/fc2video.py | def makeMimi(upid):
"""From http://cdn37.atwikiimg.com/sitescript/pub/dksitescript/FC2.site.js
Also com.hps.util.fc2.FC2EncrptUtil.makeMimiLocal
L110"""
strSeed = "gGddgPfeaf_gzyr"
prehash = upid + "_" + strSeed
return md5(prehash.encode('utf-8')).hexdigest() | def makeMimi(upid):
"""From http://cdn37.atwikiimg.com/sitescript/pub/dksitescript/FC2.site.js
Also com.hps.util.fc2.FC2EncrptUtil.makeMimiLocal
L110"""
strSeed = "gGddgPfeaf_gzyr"
prehash = upid + "_" + strSeed
return md5(prehash.encode('utf-8')).hexdigest() | [
"From",
"http",
":",
"//",
"cdn37",
".",
"atwikiimg",
".",
"com",
"/",
"sitescript",
"/",
"pub",
"/",
"dksitescript",
"/",
"FC2",
".",
"site",
".",
"js",
"Also",
"com",
".",
"hps",
".",
"util",
".",
"fc2",
".",
"FC2EncrptUtil",
".",
"makeMimiLocal",
... | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/fc2video.py#L11-L17 | [
"def",
"makeMimi",
"(",
"upid",
")",
":",
"strSeed",
"=",
"\"gGddgPfeaf_gzyr\"",
"prehash",
"=",
"upid",
"+",
"\"_\"",
"+",
"strSeed",
"return",
"md5",
"(",
"prehash",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"hexdigest",
"(",
")"
] | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | fc2video_download | wrapper | src/you_get/extractors/fc2video.py | def fc2video_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
"""wrapper"""
#'http://video.fc2.com/en/content/20151021bTVKnbEw'
#'http://xiaojiadianvideo.asia/content/20151021bTVKnbEw'
#'http://video.fc2.com/ja/content/20151021bTVKnbEw'
#'http://video.fc2.com/tw/content/20... | def fc2video_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
"""wrapper"""
#'http://video.fc2.com/en/content/20151021bTVKnbEw'
#'http://xiaojiadianvideo.asia/content/20151021bTVKnbEw'
#'http://video.fc2.com/ja/content/20151021bTVKnbEw'
#'http://video.fc2.com/tw/content/20... | [
"wrapper"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/fc2video.py#L46-L57 | [
"def",
"fc2video_download",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"#'http://video.fc2.com/en/content/20151021bTVKnbEw'",
"#'http://xiaojiadianvideo.asia/content/20151021bT... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | dailymotion_download | Downloads Dailymotion videos by URL. | src/you_get/extractors/dailymotion.py | def dailymotion_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""Downloads Dailymotion videos by URL.
"""
html = get_content(rebuilt_url(url))
info = json.loads(match1(html, r'qualities":({.+?}),"'))
title = match1(html, r'"video_title"\s*:\s*"([^"]+)"') or \
mat... | def dailymotion_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""Downloads Dailymotion videos by URL.
"""
html = get_content(rebuilt_url(url))
info = json.loads(match1(html, r'qualities":({.+?}),"'))
title = match1(html, r'"video_title"\s*:\s*"([^"]+)"') or \
mat... | [
"Downloads",
"Dailymotion",
"videos",
"by",
"URL",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/dailymotion.py#L13-L35 | [
"def",
"dailymotion_download",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"get_content",
"(",
"rebuilt_url",
"(",
"url",
")",
")",
"info",
"=",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | dictify | http://stackoverflow.com/a/30923963/2946714 | src/you_get/extractors/ucas.py | def dictify(r,root=True):
"""http://stackoverflow.com/a/30923963/2946714"""
if root:
return {r.tag : dictify(r, False)}
d=copy(r.attrib)
if r.text:
d["_text"]=r.text
for x in r.findall("./*"):
if x.tag not in d:
d[x.tag]=[]
d[x.tag].append(dictify(x,False)... | def dictify(r,root=True):
"""http://stackoverflow.com/a/30923963/2946714"""
if root:
return {r.tag : dictify(r, False)}
d=copy(r.attrib)
if r.text:
d["_text"]=r.text
for x in r.findall("./*"):
if x.tag not in d:
d[x.tag]=[]
d[x.tag].append(dictify(x,False)... | [
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"30923963",
"/",
"2946714"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/ucas.py#L18-L29 | [
"def",
"dictify",
"(",
"r",
",",
"root",
"=",
"True",
")",
":",
"if",
"root",
":",
"return",
"{",
"r",
".",
"tag",
":",
"dictify",
"(",
"r",
",",
"False",
")",
"}",
"d",
"=",
"copy",
"(",
"r",
".",
"attrib",
")",
"if",
"r",
".",
"text",
":"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | ucas_download_single | video page | src/you_get/extractors/ucas.py | def ucas_download_single(url, output_dir = '.', merge = False, info_only = False, **kwargs):
'''video page'''
html = get_content(url)
# resourceID is UUID
resourceID = re.findall( r'resourceID":"([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})', html)[0]
assert resourceID != '', 'Canno... | def ucas_download_single(url, output_dir = '.', merge = False, info_only = False, **kwargs):
'''video page'''
html = get_content(url)
# resourceID is UUID
resourceID = re.findall( r'resourceID":"([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})', html)[0]
assert resourceID != '', 'Canno... | [
"video",
"page"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/ucas.py#L102-L117 | [
"def",
"ucas_download_single",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"get_content",
"(",
"url",
")",
"# resourceID is UUID",
"resourceID",
"=",... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | ucas_download_playlist | course page | src/you_get/extractors/ucas.py | def ucas_download_playlist(url, output_dir = '.', merge = False, info_only = False, **kwargs):
'''course page'''
html = get_content(url)
parts = re.findall( r'(getplaytitle.do\?.+)"', html)
assert parts, 'No part found!'
for part_path in parts:
ucas_download('http://v.ucas.ac.cn/course/' +... | def ucas_download_playlist(url, output_dir = '.', merge = False, info_only = False, **kwargs):
'''course page'''
html = get_content(url)
parts = re.findall( r'(getplaytitle.do\?.+)"', html)
assert parts, 'No part found!'
for part_path in parts:
ucas_download('http://v.ucas.ac.cn/course/' +... | [
"course",
"page"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/ucas.py#L119-L127 | [
"def",
"ucas_download_playlist",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"get_content",
"(",
"url",
")",
"parts",
"=",
"re",
".",
"findall",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | sina_download_by_vid | Downloads a Sina video by its unique vid.
http://video.sina.com.cn/ | src/you_get/extractors/sina.py | def sina_download_by_vid(vid, title=None, output_dir='.', merge=True, info_only=False):
"""Downloads a Sina video by its unique vid.
http://video.sina.com.cn/
"""
xml = api_req(vid)
urls, name, size = video_info(xml)
if urls is None:
log.wtf(name)
title = name
print_info(site_inf... | def sina_download_by_vid(vid, title=None, output_dir='.', merge=True, info_only=False):
"""Downloads a Sina video by its unique vid.
http://video.sina.com.cn/
"""
xml = api_req(vid)
urls, name, size = video_info(xml)
if urls is None:
log.wtf(name)
title = name
print_info(site_inf... | [
"Downloads",
"a",
"Sina",
"video",
"by",
"its",
"unique",
"vid",
".",
"http",
":",
"//",
"video",
".",
"sina",
".",
"com",
".",
"cn",
"/"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/sina.py#L41-L52 | [
"def",
"sina_download_by_vid",
"(",
"vid",
",",
"title",
"=",
"None",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
")",
":",
"xml",
"=",
"api_req",
"(",
"vid",
")",
"urls",
",",
"name",
",",
"size",
"=",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | sina_download_by_vkey | Downloads a Sina video by its unique vkey.
http://video.sina.com/ | src/you_get/extractors/sina.py | def sina_download_by_vkey(vkey, title=None, output_dir='.', merge=True, info_only=False):
"""Downloads a Sina video by its unique vkey.
http://video.sina.com/
"""
url = 'http://video.sina.com/v/flvideo/%s_0.flv' % vkey
type, ext, size = url_info(url)
print_info(site_info, title, 'flv', size)
... | def sina_download_by_vkey(vkey, title=None, output_dir='.', merge=True, info_only=False):
"""Downloads a Sina video by its unique vkey.
http://video.sina.com/
"""
url = 'http://video.sina.com/v/flvideo/%s_0.flv' % vkey
type, ext, size = url_info(url)
print_info(site_info, title, 'flv', size)
... | [
"Downloads",
"a",
"Sina",
"video",
"by",
"its",
"unique",
"vkey",
".",
"http",
":",
"//",
"video",
".",
"sina",
".",
"com",
"/"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/sina.py#L54-L64 | [
"def",
"sina_download_by_vkey",
"(",
"vkey",
",",
"title",
"=",
"None",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
")",
":",
"url",
"=",
"'http://video.sina.com/v/flvideo/%s_0.flv'",
"%",
"vkey",
"type",
",",
"e... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | sina_download | Downloads Sina videos by URL. | src/you_get/extractors/sina.py | def sina_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""Downloads Sina videos by URL.
"""
if 'news.sina.com.cn/zxt' in url:
sina_zxt(url, output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)
return
vid = match1(url, r'vid=(\d+)')
if vid is Non... | def sina_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""Downloads Sina videos by URL.
"""
if 'news.sina.com.cn/zxt' in url:
sina_zxt(url, output_dir=output_dir, merge=merge, info_only=info_only, **kwargs)
return
vid = match1(url, r'vid=(\d+)')
if vid is Non... | [
"Downloads",
"Sina",
"videos",
"by",
"URL",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/sina.py#L94-L121 | [
"def",
"sina_download",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'news.sina.com.cn/zxt'",
"in",
"url",
":",
"sina_zxt",
"(",
"url",
",",
"output_dir",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | yixia_download | wrapper | src/you_get/extractors/yixia.py | def yixia_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
"""wrapper"""
hostname = urlparse(url).hostname
if 'n.miaopai.com' == hostname:
smid = match1(url, r'n\.miaopai\.com/media/([^.]+)')
miaopai_download_by_smid(smid, output_dir, merge, info_only)
re... | def yixia_download(url, output_dir = '.', merge = True, info_only = False, **kwargs):
"""wrapper"""
hostname = urlparse(url).hostname
if 'n.miaopai.com' == hostname:
smid = match1(url, r'n\.miaopai\.com/media/([^.]+)')
miaopai_download_by_smid(smid, output_dir, merge, info_only)
re... | [
"wrapper"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/yixia.py#L65-L93 | [
"def",
"yixia_download",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"hostname",
"=",
"urlparse",
"(",
"url",
")",
".",
"hostname",
"if",
"'n.miaopai.com'",
"=... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | veoh_download | Get item_id | src/you_get/extractors/veoh.py | def veoh_download(url, output_dir = '.', merge = False, info_only = False, **kwargs):
'''Get item_id'''
if re.match(r'http://www.veoh.com/watch/\w+', url):
item_id = match1(url, r'http://www.veoh.com/watch/(\w+)')
elif re.match(r'http://www.veoh.com/m/watch.php\?v=\.*', url):
item_id = match... | def veoh_download(url, output_dir = '.', merge = False, info_only = False, **kwargs):
'''Get item_id'''
if re.match(r'http://www.veoh.com/watch/\w+', url):
item_id = match1(url, r'http://www.veoh.com/watch/(\w+)')
elif re.match(r'http://www.veoh.com/m/watch.php\?v=\.*', url):
item_id = match... | [
"Get",
"item_id"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/veoh.py#L8-L16 | [
"def",
"veoh_download",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"re",
".",
"match",
"(",
"r'http://www.veoh.com/watch/\\w+'",
",",
"url",
")",
":",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | veoh_download_by_id | Source: Android mobile | src/you_get/extractors/veoh.py | def veoh_download_by_id(item_id, output_dir = '.', merge = False, info_only = False, **kwargs):
"""Source: Android mobile"""
webpage_url = 'http://www.veoh.com/m/watch.php?v={item_id}&quality=1'.format(item_id = item_id)
#grab download URL
a = get_content(webpage_url, decoded=True)
url = match1(a, ... | def veoh_download_by_id(item_id, output_dir = '.', merge = False, info_only = False, **kwargs):
"""Source: Android mobile"""
webpage_url = 'http://www.veoh.com/m/watch.php?v={item_id}&quality=1'.format(item_id = item_id)
#grab download URL
a = get_content(webpage_url, decoded=True)
url = match1(a, ... | [
"Source",
":",
"Android",
"mobile"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/veoh.py#L19-L33 | [
"def",
"veoh_download_by_id",
"(",
"item_id",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"webpage_url",
"=",
"'http://www.veoh.com/m/watch.php?v={item_id}&quality=1'",
".",
"format"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | BokeCC.download_by_id | self, str->None
Keyword arguments:
self: self
vid: The video ID for BokeCC cloud, something like
FE3BB999594978049C33DC5901307461
Calls the prepare() to download the video.
If no title is provided, this method shall try to find a proper title
... | src/you_get/extractors/bokecc.py | def download_by_id(self, vid = '', title = None, output_dir='.', merge=True, info_only=False,**kwargs):
"""self, str->None
Keyword arguments:
self: self
vid: The video ID for BokeCC cloud, something like
FE3BB999594978049C33DC5901307461
Calls the prepare... | def download_by_id(self, vid = '', title = None, output_dir='.', merge=True, info_only=False,**kwargs):
"""self, str->None
Keyword arguments:
self: self
vid: The video ID for BokeCC cloud, something like
FE3BB999594978049C33DC5901307461
Calls the prepare... | [
"self",
"str",
"-",
">",
"None",
"Keyword",
"arguments",
":",
"self",
":",
"self",
"vid",
":",
"The",
"video",
"ID",
"for",
"BokeCC",
"cloud",
"something",
"like",
"FE3BB999594978049C33DC5901307461",
"Calls",
"the",
"prepare",
"()",
"to",
"download",
"the",
... | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/bokecc.py#L17-L39 | [
"def",
"download_by_id",
"(",
"self",
",",
"vid",
"=",
"''",
",",
"title",
"=",
"None",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"vid",
"self",
".",
"prep... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | QiE.get_vid_from_url | Extracts video ID from live.qq.com. | src/you_get/extractors/qie.py | def get_vid_from_url(self, url):
"""Extracts video ID from live.qq.com.
"""
hit = re.search(r'live.qq.com/(\d+)', url)
if hit is not None:
return hit.group(1)
hit = re.search(r'live.qq.com/directory/match/(\d+)', url)
if hit is not None:
return sel... | def get_vid_from_url(self, url):
"""Extracts video ID from live.qq.com.
"""
hit = re.search(r'live.qq.com/(\d+)', url)
if hit is not None:
return hit.group(1)
hit = re.search(r'live.qq.com/directory/match/(\d+)', url)
if hit is not None:
return sel... | [
"Extracts",
"video",
"ID",
"from",
"live",
".",
"qq",
".",
"com",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/qie.py#L35-L48 | [
"def",
"get_vid_from_url",
"(",
"self",
",",
"url",
")",
":",
"hit",
"=",
"re",
".",
"search",
"(",
"r'live.qq.com/(\\d+)'",
",",
"url",
")",
"if",
"hit",
"is",
"not",
"None",
":",
"return",
"hit",
".",
"group",
"(",
"1",
")",
"hit",
"=",
"re",
"."... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | sprint | Format text with color or other effects into ANSI escaped string. | src/you_get/util/log.py | def sprint(text, *colors):
"""Format text with color or other effects into ANSI escaped string."""
return "\33[{}m{content}\33[{}m".format(";".join([str(color) for color in colors]), RESET, content=text) if IS_ANSI_TERMINAL and colors else text | def sprint(text, *colors):
"""Format text with color or other effects into ANSI escaped string."""
return "\33[{}m{content}\33[{}m".format(";".join([str(color) for color in colors]), RESET, content=text) if IS_ANSI_TERMINAL and colors else text | [
"Format",
"text",
"with",
"color",
"or",
"other",
"effects",
"into",
"ANSI",
"escaped",
"string",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/log.py#L60-L62 | [
"def",
"sprint",
"(",
"text",
",",
"*",
"colors",
")",
":",
"return",
"\"\\33[{}m{content}\\33[{}m\"",
".",
"format",
"(",
"\";\"",
".",
"join",
"(",
"[",
"str",
"(",
"color",
")",
"for",
"color",
"in",
"colors",
"]",
")",
",",
"RESET",
",",
"content",... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | print_log | Print a log message to standard error. | src/you_get/util/log.py | def print_log(text, *colors):
"""Print a log message to standard error."""
sys.stderr.write(sprint("{}: {}".format(script_name, text), *colors) + "\n") | def print_log(text, *colors):
"""Print a log message to standard error."""
sys.stderr.write(sprint("{}: {}".format(script_name, text), *colors) + "\n") | [
"Print",
"a",
"log",
"message",
"to",
"standard",
"error",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/log.py#L72-L74 | [
"def",
"print_log",
"(",
"text",
",",
"*",
"colors",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"sprint",
"(",
"\"{}: {}\"",
".",
"format",
"(",
"script_name",
",",
"text",
")",
",",
"*",
"colors",
")",
"+",
"\"\\n\"",
")"
] | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | e | Print an error log message. | src/you_get/util/log.py | def e(message, exit_code=None):
"""Print an error log message."""
print_log(message, YELLOW, BOLD)
if exit_code is not None:
sys.exit(exit_code) | def e(message, exit_code=None):
"""Print an error log message."""
print_log(message, YELLOW, BOLD)
if exit_code is not None:
sys.exit(exit_code) | [
"Print",
"an",
"error",
"log",
"message",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/log.py#L88-L92 | [
"def",
"e",
"(",
"message",
",",
"exit_code",
"=",
"None",
")",
":",
"print_log",
"(",
"message",
",",
"YELLOW",
",",
"BOLD",
")",
"if",
"exit_code",
"is",
"not",
"None",
":",
"sys",
".",
"exit",
"(",
"exit_code",
")"
] | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | wtf | What a Terrible Failure! | src/you_get/util/log.py | def wtf(message, exit_code=1):
"""What a Terrible Failure!"""
print_log(message, RED, BOLD)
if exit_code is not None:
sys.exit(exit_code) | def wtf(message, exit_code=1):
"""What a Terrible Failure!"""
print_log(message, RED, BOLD)
if exit_code is not None:
sys.exit(exit_code) | [
"What",
"a",
"Terrible",
"Failure!"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/log.py#L94-L98 | [
"def",
"wtf",
"(",
"message",
",",
"exit_code",
"=",
"1",
")",
":",
"print_log",
"(",
"message",
",",
"RED",
",",
"BOLD",
")",
"if",
"exit_code",
"is",
"not",
"None",
":",
"sys",
".",
"exit",
"(",
"exit_code",
")"
] | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | detect_os | Detect operating system. | src/you_get/util/os.py | def detect_os():
"""Detect operating system.
"""
# Inspired by:
# https://github.com/scivision/pybashutils/blob/78b7f2b339cb03b1c37df94015098bbe462f8526/pybashutils/windows_linux_detect.py
syst = system().lower()
os = 'unknown'
if 'cygwin' in syst:
os = 'cygwin'
elif 'darwin' ... | def detect_os():
"""Detect operating system.
"""
# Inspired by:
# https://github.com/scivision/pybashutils/blob/78b7f2b339cb03b1c37df94015098bbe462f8526/pybashutils/windows_linux_detect.py
syst = system().lower()
os = 'unknown'
if 'cygwin' in syst:
os = 'cygwin'
elif 'darwin' ... | [
"Detect",
"operating",
"system",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/os.py#L5-L32 | [
"def",
"detect_os",
"(",
")",
":",
"# Inspired by:",
"# https://github.com/scivision/pybashutils/blob/78b7f2b339cb03b1c37df94015098bbe462f8526/pybashutils/windows_linux_detect.py",
"syst",
"=",
"system",
"(",
")",
".",
"lower",
"(",
")",
"os",
"=",
"'unknown'",
"if",
"'cygwin... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | miaopai_download_by_fid | Source: Android mobile | src/you_get/extractors/miaopai.py | def miaopai_download_by_fid(fid, output_dir = '.', merge = False, info_only = False, **kwargs):
'''Source: Android mobile'''
page_url = 'http://video.weibo.com/show?fid=' + fid + '&type=mp4'
mobile_page = get_content(page_url, headers=fake_headers_mobile)
url = match1(mobile_page, r'<video id=.*?src=[\... | def miaopai_download_by_fid(fid, output_dir = '.', merge = False, info_only = False, **kwargs):
'''Source: Android mobile'''
page_url = 'http://video.weibo.com/show?fid=' + fid + '&type=mp4'
mobile_page = get_content(page_url, headers=fake_headers_mobile)
url = match1(mobile_page, r'<video id=.*?src=[\... | [
"Source",
":",
"Android",
"mobile"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/miaopai.py#L20-L37 | [
"def",
"miaopai_download_by_fid",
"(",
"fid",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"page_url",
"=",
"'http://video.weibo.com/show?fid='",
"+",
"fid",
"+",
"'&type=mp4'",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | vimeo_download_by_channel | str->None | src/you_get/extractors/vimeo.py | def vimeo_download_by_channel(url, output_dir='.', merge=False, info_only=False, **kwargs):
"""str->None"""
# https://vimeo.com/channels/464686
channel_id = match1(url, r'http://vimeo.com/channels/(\w+)')
vimeo_download_by_channel_id(channel_id, output_dir, merge, info_only, **kwargs) | def vimeo_download_by_channel(url, output_dir='.', merge=False, info_only=False, **kwargs):
"""str->None"""
# https://vimeo.com/channels/464686
channel_id = match1(url, r'http://vimeo.com/channels/(\w+)')
vimeo_download_by_channel_id(channel_id, output_dir, merge, info_only, **kwargs) | [
"str",
"-",
">",
"None"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/vimeo.py#L15-L19 | [
"def",
"vimeo_download_by_channel",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# https://vimeo.com/channels/464686",
"channel_id",
"=",
"match1",
"(",
"url",
",",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | vimeo_download_by_channel_id | str/int->None | src/you_get/extractors/vimeo.py | def vimeo_download_by_channel_id(channel_id, output_dir='.', merge=False, info_only=False, **kwargs):
"""str/int->None"""
html = get_content('https://api.vimeo.com/channels/{channel_id}/videos?access_token={access_token}'.format(channel_id=channel_id, access_token=access_token))
data = loads(html)
id_li... | def vimeo_download_by_channel_id(channel_id, output_dir='.', merge=False, info_only=False, **kwargs):
"""str/int->None"""
html = get_content('https://api.vimeo.com/channels/{channel_id}/videos?access_token={access_token}'.format(channel_id=channel_id, access_token=access_token))
data = loads(html)
id_li... | [
"str",
"/",
"int",
"-",
">",
"None"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/vimeo.py#L22-L36 | [
"def",
"vimeo_download_by_channel_id",
"(",
"channel_id",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"get_content",
"(",
"'https://api.vimeo.com/channels/{channel_id}/v... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | vimeo_download_by_id | try:
# normal Vimeo video
html = get_content('https://vimeo.com/' + id)
cfg_patt = r'clip_page_config\s*=\s*(\{.+?\});'
cfg = json.loads(match1(html, cfg_patt))
video_page = get_content(cfg['player']['config_url'], headers=fake_headers)
title = cfg['clip']['title']
... | src/you_get/extractors/vimeo.py | def vimeo_download_by_id(id, title=None, output_dir='.', merge=True, info_only=False, **kwargs):
'''
try:
# normal Vimeo video
html = get_content('https://vimeo.com/' + id)
cfg_patt = r'clip_page_config\s*=\s*(\{.+?\});'
cfg = json.loads(match1(html, cfg_patt))
video_page... | def vimeo_download_by_id(id, title=None, output_dir='.', merge=True, info_only=False, **kwargs):
'''
try:
# normal Vimeo video
html = get_content('https://vimeo.com/' + id)
cfg_patt = r'clip_page_config\s*=\s*(\{.+?\});'
cfg = json.loads(match1(html, cfg_patt))
video_page... | [
"try",
":",
"#",
"normal",
"Vimeo",
"video",
"html",
"=",
"get_content",
"(",
"https",
":",
"//",
"vimeo",
".",
"com",
"/",
"+",
"id",
")",
"cfg_patt",
"=",
"r",
"clip_page_config",
"\\",
"s",
"*",
"=",
"\\",
"s",
"*",
"(",
"\\",
"{",
".",
"+",
... | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/vimeo.py#L134-L164 | [
"def",
"vimeo_download_by_id",
"(",
"id",
",",
"title",
"=",
"None",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"site",
"=",
"VimeoExtractor",
"(",
")",
"site",
".",
"d... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | ckplayer_get_info_by_xml | str->dict
Information for CKPlayer API content. | src/you_get/extractors/ckplayer.py | def ckplayer_get_info_by_xml(ckinfo):
"""str->dict
Information for CKPlayer API content."""
e = ET.XML(ckinfo)
video_dict = {'title': '',
#'duration': 0,
'links': [],
'size': 0,
'flashvars': '',}
dictified = dictify(e)['ckplayer... | def ckplayer_get_info_by_xml(ckinfo):
"""str->dict
Information for CKPlayer API content."""
e = ET.XML(ckinfo)
video_dict = {'title': '',
#'duration': 0,
'links': [],
'size': 0,
'flashvars': '',}
dictified = dictify(e)['ckplayer... | [
"str",
"-",
">",
"dict",
"Information",
"for",
"CKPlayer",
"API",
"content",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/ckplayer.py#L13-L39 | [
"def",
"ckplayer_get_info_by_xml",
"(",
"ckinfo",
")",
":",
"e",
"=",
"ET",
".",
"XML",
"(",
"ckinfo",
")",
"video_dict",
"=",
"{",
"'title'",
":",
"''",
",",
"#'duration': 0,",
"'links'",
":",
"[",
"]",
",",
"'size'",
":",
"0",
",",
"'flashvars'",
":"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | get_video_url_from_video_id | Splicing URLs according to video ID to get video details | src/you_get/extractors/ixigua.py | def get_video_url_from_video_id(video_id):
"""Splicing URLs according to video ID to get video details"""
# from js
data = [""] * 256
for index, _ in enumerate(data):
t = index
for i in range(8):
t = -306674912 ^ unsigned_right_shitf(t, 1) if 1 & t else unsigned_right_shitf(t... | def get_video_url_from_video_id(video_id):
"""Splicing URLs according to video ID to get video details"""
# from js
data = [""] * 256
for index, _ in enumerate(data):
t = index
for i in range(8):
t = -306674912 ^ unsigned_right_shitf(t, 1) if 1 & t else unsigned_right_shitf(t... | [
"Splicing",
"URLs",
"according",
"to",
"video",
"ID",
"to",
"get",
"video",
"details"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/ixigua.py#L34-L78 | [
"def",
"get_video_url_from_video_id",
"(",
"video_id",
")",
":",
"# from js",
"data",
"=",
"[",
"\"\"",
"]",
"*",
"256",
"for",
"index",
",",
"_",
"in",
"enumerate",
"(",
"data",
")",
":",
"t",
"=",
"index",
"for",
"i",
"in",
"range",
"(",
"8",
")",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | MGTV.get_vid_from_url | Extracts video ID from URL. | src/you_get/extractors/mgtv.py | def get_vid_from_url(url):
"""Extracts video ID from URL.
"""
vid = match1(url, 'https?://www.mgtv.com/(?:b|l)/\d+/(\d+).html')
if not vid:
vid = match1(url, 'https?://www.mgtv.com/hz/bdpz/\d+/(\d+).html')
return vid | def get_vid_from_url(url):
"""Extracts video ID from URL.
"""
vid = match1(url, 'https?://www.mgtv.com/(?:b|l)/\d+/(\d+).html')
if not vid:
vid = match1(url, 'https?://www.mgtv.com/hz/bdpz/\d+/(\d+).html')
return vid | [
"Extracts",
"video",
"ID",
"from",
"URL",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/mgtv.py#L27-L33 | [
"def",
"get_vid_from_url",
"(",
"url",
")",
":",
"vid",
"=",
"match1",
"(",
"url",
",",
"'https?://www.mgtv.com/(?:b|l)/\\d+/(\\d+).html'",
")",
"if",
"not",
"vid",
":",
"vid",
"=",
"match1",
"(",
"url",
",",
"'https?://www.mgtv.com/hz/bdpz/\\d+/(\\d+).html'",
")",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | MGTV.get_mgtv_real_url | str->list of str
Give you the real URLs. | src/you_get/extractors/mgtv.py | def get_mgtv_real_url(url):
"""str->list of str
Give you the real URLs."""
content = loads(get_content(url))
m3u_url = content['info']
split = urlsplit(m3u_url)
base_url = "{scheme}://{netloc}{path}/".format(scheme = split[0],
... | def get_mgtv_real_url(url):
"""str->list of str
Give you the real URLs."""
content = loads(get_content(url))
m3u_url = content['info']
split = urlsplit(m3u_url)
base_url = "{scheme}://{netloc}{path}/".format(scheme = split[0],
... | [
"str",
"-",
">",
"list",
"of",
"str",
"Give",
"you",
"the",
"real",
"URLs",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/mgtv.py#L37-L58 | [
"def",
"get_mgtv_real_url",
"(",
"url",
")",
":",
"content",
"=",
"loads",
"(",
"get_content",
"(",
"url",
")",
")",
"m3u_url",
"=",
"content",
"[",
"'info'",
"]",
"split",
"=",
"urlsplit",
"(",
"m3u_url",
")",
"base_url",
"=",
"\"{scheme}://{netloc}{path}/\... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | get_head | Get (branch, commit) from HEAD of a git repo. | src/you_get/util/git.py | def get_head(repo_path):
"""Get (branch, commit) from HEAD of a git repo."""
try:
ref = open(os.path.join(repo_path, '.git', 'HEAD'), 'r').read().strip()[5:].split('/')
branch = ref[-1]
commit = open(os.path.join(repo_path, '.git', *ref), 'r').read().strip()[:7]
return branch, co... | def get_head(repo_path):
"""Get (branch, commit) from HEAD of a git repo."""
try:
ref = open(os.path.join(repo_path, '.git', 'HEAD'), 'r').read().strip()[5:].split('/')
branch = ref[-1]
commit = open(os.path.join(repo_path, '.git', *ref), 'r').read().strip()[:7]
return branch, co... | [
"Get",
"(",
"branch",
"commit",
")",
"from",
"HEAD",
"of",
"a",
"git",
"repo",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/git.py#L7-L15 | [
"def",
"get_head",
"(",
"repo_path",
")",
":",
"try",
":",
"ref",
"=",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"repo_path",
",",
"'.git'",
",",
"'HEAD'",
")",
",",
"'r'",
")",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
"[",
"5",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | legitimize | Converts a string to a valid filename. | src/you_get/util/fs.py | def legitimize(text, os=detect_os()):
"""Converts a string to a valid filename.
"""
# POSIX systems
text = text.translate({
0: None,
ord('/'): '-',
ord('|'): '-',
})
# FIXME: do some filesystem detection
if os == 'windows' or os == 'cygwin' or os == 'wsl':
#... | def legitimize(text, os=detect_os()):
"""Converts a string to a valid filename.
"""
# POSIX systems
text = text.translate({
0: None,
ord('/'): '-',
ord('|'): '-',
})
# FIXME: do some filesystem detection
if os == 'windows' or os == 'cygwin' or os == 'wsl':
#... | [
"Converts",
"a",
"string",
"to",
"a",
"valid",
"filename",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/fs.py#L5-L47 | [
"def",
"legitimize",
"(",
"text",
",",
"os",
"=",
"detect_os",
"(",
")",
")",
":",
"# POSIX systems",
"text",
"=",
"text",
".",
"translate",
"(",
"{",
"0",
":",
"None",
",",
"ord",
"(",
"'/'",
")",
":",
"'-'",
",",
"ord",
"(",
"'|'",
")",
":",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | get_terminal_size | Get (width, height) of the current terminal. | src/you_get/util/term.py | def get_terminal_size():
"""Get (width, height) of the current terminal."""
try:
import fcntl, termios, struct # fcntl module only available on Unix
return struct.unpack('hh', fcntl.ioctl(1, termios.TIOCGWINSZ, '1234'))
except:
return (40, 80) | def get_terminal_size():
"""Get (width, height) of the current terminal."""
try:
import fcntl, termios, struct # fcntl module only available on Unix
return struct.unpack('hh', fcntl.ioctl(1, termios.TIOCGWINSZ, '1234'))
except:
return (40, 80) | [
"Get",
"(",
"width",
"height",
")",
"of",
"the",
"current",
"terminal",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/util/term.py#L3-L9 | [
"def",
"get_terminal_size",
"(",
")",
":",
"try",
":",
"import",
"fcntl",
",",
"termios",
",",
"struct",
"# fcntl module only available on Unix",
"return",
"struct",
".",
"unpack",
"(",
"'hh'",
",",
"fcntl",
".",
"ioctl",
"(",
"1",
",",
"termios",
".",
"TIOC... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | cbs_download | Downloads CBS videos by URL. | src/you_get/extractors/cbs.py | def cbs_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""Downloads CBS videos by URL.
"""
html = get_content(url)
pid = match1(html, r'video\.settings\.pid\s*=\s*\'([^\']+)\'')
title = match1(html, r'video\.settings\.title\s*=\s*\"([^\"]+)\"')
theplatform_download_by_pi... | def cbs_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
"""Downloads CBS videos by URL.
"""
html = get_content(url)
pid = match1(html, r'video\.settings\.pid\s*=\s*\'([^\']+)\'')
title = match1(html, r'video\.settings\.title\s*=\s*\"([^\"]+)\"')
theplatform_download_by_pi... | [
"Downloads",
"CBS",
"videos",
"by",
"URL",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/cbs.py#L9-L17 | [
"def",
"cbs_download",
"(",
"url",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"get_content",
"(",
"url",
")",
"pid",
"=",
"match1",
"(",
"html",
",",
"r'... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | Iqiyi.download | Override the original one
Ugly ugly dirty hack | src/you_get/extractors/iqiyi.py | def download(self, **kwargs):
"""Override the original one
Ugly ugly dirty hack"""
if 'json_output' in kwargs and kwargs['json_output']:
json_output.output(self)
elif 'info_only' in kwargs and kwargs['info_only']:
if 'stream_id' in kwargs and kwargs['stream_id']:
... | def download(self, **kwargs):
"""Override the original one
Ugly ugly dirty hack"""
if 'json_output' in kwargs and kwargs['json_output']:
json_output.output(self)
elif 'info_only' in kwargs and kwargs['info_only']:
if 'stream_id' in kwargs and kwargs['stream_id']:
... | [
"Override",
"the",
"original",
"one",
"Ugly",
"ugly",
"dirty",
"hack"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/iqiyi.py#L158-L218 | [
"def",
"download",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'json_output'",
"in",
"kwargs",
"and",
"kwargs",
"[",
"'json_output'",
"]",
":",
"json_output",
".",
"output",
"(",
"self",
")",
"elif",
"'info_only'",
"in",
"kwargs",
"and",
"kwar... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | acfun_download_by_vid | str, str, str, bool, bool ->None
Download Acfun video by vid.
Call Acfun API, decide which site to use, and pass the job to its
extractor. | src/you_get/extractors/acfun.py | def acfun_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False, **kwargs):
"""str, str, str, bool, bool ->None
Download Acfun video by vid.
Call Acfun API, decide which site to use, and pass the job to its
extractor.
"""
#first call the main parasing API
info = json.loa... | def acfun_download_by_vid(vid, title, output_dir='.', merge=True, info_only=False, **kwargs):
"""str, str, str, bool, bool ->None
Download Acfun video by vid.
Call Acfun API, decide which site to use, and pass the job to its
extractor.
"""
#first call the main parasing API
info = json.loa... | [
"str",
"str",
"str",
"bool",
"bool",
"-",
">",
"None"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/acfun.py#L42-L109 | [
"def",
"acfun_download_by_vid",
"(",
"vid",
",",
"title",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"#first call the main parasing API",
"info",
"=",
"json",
".",
"loads",
"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | main_dev | Main entry point.
you-get-dev | src/you_get/__main__.py | def main_dev(**kwargs):
"""Main entry point.
you-get-dev
"""
# Get (branch, commit) if running from a git repo.
head = git.get_head(kwargs['repo_path'])
# Get options and arguments.
try:
opts, args = getopt.getopt(sys.argv[1:], _short_options, _options)
except getopt.GetoptErro... | def main_dev(**kwargs):
"""Main entry point.
you-get-dev
"""
# Get (branch, commit) if running from a git repo.
head = git.get_head(kwargs['repo_path'])
# Get options and arguments.
try:
opts, args = getopt.getopt(sys.argv[1:], _short_options, _options)
except getopt.GetoptErro... | [
"Main",
"entry",
"point",
".",
"you",
"-",
"get",
"-",
"dev"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/__main__.py#L24-L85 | [
"def",
"main_dev",
"(",
"*",
"*",
"kwargs",
")",
":",
"# Get (branch, commit) if running from a git repo.",
"head",
"=",
"git",
".",
"get_head",
"(",
"kwargs",
"[",
"'repo_path'",
"]",
")",
"# Get options and arguments.",
"try",
":",
"opts",
",",
"args",
"=",
"g... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | ffmpeg_download_stream | str, str->True
WARNING: NOT THE SAME PARMS AS OTHER FUNCTIONS!!!!!!
You can basicly download anything with this function
but better leave it alone with | src/you_get/processor/ffmpeg.py | def ffmpeg_download_stream(files, title, ext, params={}, output_dir='.', stream=True):
"""str, str->True
WARNING: NOT THE SAME PARMS AS OTHER FUNCTIONS!!!!!!
You can basicly download anything with this function
but better leave it alone with
"""
output = title + '.' + ext
if not (output_dir... | def ffmpeg_download_stream(files, title, ext, params={}, output_dir='.', stream=True):
"""str, str->True
WARNING: NOT THE SAME PARMS AS OTHER FUNCTIONS!!!!!!
You can basicly download anything with this function
but better leave it alone with
"""
output = title + '.' + ext
if not (output_dir... | [
"str",
"str",
"-",
">",
"True",
"WARNING",
":",
"NOT",
"THE",
"SAME",
"PARMS",
"AS",
"OTHER",
"FUNCTIONS!!!!!!",
"You",
"can",
"basicly",
"download",
"anything",
"with",
"this",
"function",
"but",
"better",
"leave",
"it",
"alone",
"with"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/processor/ffmpeg.py#L220-L262 | [
"def",
"ffmpeg_download_stream",
"(",
"files",
",",
"title",
",",
"ext",
",",
"params",
"=",
"{",
"}",
",",
"output_dir",
"=",
"'.'",
",",
"stream",
"=",
"True",
")",
":",
"output",
"=",
"title",
"+",
"'.'",
"+",
"ext",
"if",
"not",
"(",
"output_dir"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | match1 | Scans through a string for substrings matched some patterns (first-subgroups only).
Args:
text: A string to be scanned.
patterns: Arbitrary number of regex patterns.
Returns:
When only one pattern is given, returns a string (None if no match found).
When more than one pattern a... | src/you_get/common.py | def match1(text, *patterns):
"""Scans through a string for substrings matched some patterns (first-subgroups only).
Args:
text: A string to be scanned.
patterns: Arbitrary number of regex patterns.
Returns:
When only one pattern is given, returns a string (None if no match found).
... | def match1(text, *patterns):
"""Scans through a string for substrings matched some patterns (first-subgroups only).
Args:
text: A string to be scanned.
patterns: Arbitrary number of regex patterns.
Returns:
When only one pattern is given, returns a string (None if no match found).
... | [
"Scans",
"through",
"a",
"string",
"for",
"substrings",
"matched",
"some",
"patterns",
"(",
"first",
"-",
"subgroups",
"only",
")",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L224-L249 | [
"def",
"match1",
"(",
"text",
",",
"*",
"patterns",
")",
":",
"if",
"len",
"(",
"patterns",
")",
"==",
"1",
":",
"pattern",
"=",
"patterns",
"[",
"0",
"]",
"match",
"=",
"re",
".",
"search",
"(",
"pattern",
",",
"text",
")",
"if",
"match",
":",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | matchall | Scans through a string for substrings matched some patterns.
Args:
text: A string to be scanned.
patterns: a list of regex pattern.
Returns:
a list if matched. empty if not. | src/you_get/common.py | def matchall(text, patterns):
"""Scans through a string for substrings matched some patterns.
Args:
text: A string to be scanned.
patterns: a list of regex pattern.
Returns:
a list if matched. empty if not.
"""
ret = []
for pattern in patterns:
match = re.finda... | def matchall(text, patterns):
"""Scans through a string for substrings matched some patterns.
Args:
text: A string to be scanned.
patterns: a list of regex pattern.
Returns:
a list if matched. empty if not.
"""
ret = []
for pattern in patterns:
match = re.finda... | [
"Scans",
"through",
"a",
"string",
"for",
"substrings",
"matched",
"some",
"patterns",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L252-L268 | [
"def",
"matchall",
"(",
"text",
",",
"patterns",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"pattern",
"in",
"patterns",
":",
"match",
"=",
"re",
".",
"findall",
"(",
"pattern",
",",
"text",
")",
"ret",
"+=",
"match",
"return",
"ret"
] | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | parse_query_param | Parses the query string of a URL and returns the value of a parameter.
Args:
url: A URL.
param: A string representing the name of the parameter.
Returns:
The value of the parameter. | src/you_get/common.py | def parse_query_param(url, param):
"""Parses the query string of a URL and returns the value of a parameter.
Args:
url: A URL.
param: A string representing the name of the parameter.
Returns:
The value of the parameter.
"""
try:
return parse.parse_qs(parse.urlparse... | def parse_query_param(url, param):
"""Parses the query string of a URL and returns the value of a parameter.
Args:
url: A URL.
param: A string representing the name of the parameter.
Returns:
The value of the parameter.
"""
try:
return parse.parse_qs(parse.urlparse... | [
"Parses",
"the",
"query",
"string",
"of",
"a",
"URL",
"and",
"returns",
"the",
"value",
"of",
"a",
"parameter",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L285-L299 | [
"def",
"parse_query_param",
"(",
"url",
",",
"param",
")",
":",
"try",
":",
"return",
"parse",
".",
"parse_qs",
"(",
"parse",
".",
"urlparse",
"(",
"url",
")",
".",
"query",
")",
"[",
"param",
"]",
"[",
"0",
"]",
"except",
":",
"return",
"None"
] | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | ungzip | Decompresses data for Content-Encoding: gzip. | src/you_get/common.py | def ungzip(data):
"""Decompresses data for Content-Encoding: gzip.
"""
from io import BytesIO
import gzip
buffer = BytesIO(data)
f = gzip.GzipFile(fileobj=buffer)
return f.read() | def ungzip(data):
"""Decompresses data for Content-Encoding: gzip.
"""
from io import BytesIO
import gzip
buffer = BytesIO(data)
f = gzip.GzipFile(fileobj=buffer)
return f.read() | [
"Decompresses",
"data",
"for",
"Content",
"-",
"Encoding",
":",
"gzip",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L319-L326 | [
"def",
"ungzip",
"(",
"data",
")",
":",
"from",
"io",
"import",
"BytesIO",
"import",
"gzip",
"buffer",
"=",
"BytesIO",
"(",
"data",
")",
"f",
"=",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"buffer",
")",
"return",
"f",
".",
"read",
"(",
")"
] | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | undeflate | Decompresses data for Content-Encoding: deflate.
(the zlib compression is used.) | src/you_get/common.py | def undeflate(data):
"""Decompresses data for Content-Encoding: deflate.
(the zlib compression is used.)
"""
import zlib
decompressobj = zlib.decompressobj(-zlib.MAX_WBITS)
return decompressobj.decompress(data)+decompressobj.flush() | def undeflate(data):
"""Decompresses data for Content-Encoding: deflate.
(the zlib compression is used.)
"""
import zlib
decompressobj = zlib.decompressobj(-zlib.MAX_WBITS)
return decompressobj.decompress(data)+decompressobj.flush() | [
"Decompresses",
"data",
"for",
"Content",
"-",
"Encoding",
":",
"deflate",
".",
"(",
"the",
"zlib",
"compression",
"is",
"used",
".",
")"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L329-L335 | [
"def",
"undeflate",
"(",
"data",
")",
":",
"import",
"zlib",
"decompressobj",
"=",
"zlib",
".",
"decompressobj",
"(",
"-",
"zlib",
".",
"MAX_WBITS",
")",
"return",
"decompressobj",
".",
"decompress",
"(",
"data",
")",
"+",
"decompressobj",
".",
"flush",
"(... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | get_content | Gets the content of a URL via sending a HTTP GET request.
Args:
url: A URL.
headers: Request headers used by the client.
decoded: Whether decode the response body using UTF-8 or the charset specified in Content-Type.
Returns:
The content as a string. | src/you_get/common.py | def get_content(url, headers={}, decoded=True):
"""Gets the content of a URL via sending a HTTP GET request.
Args:
url: A URL.
headers: Request headers used by the client.
decoded: Whether decode the response body using UTF-8 or the charset specified in Content-Type.
Returns:
... | def get_content(url, headers={}, decoded=True):
"""Gets the content of a URL via sending a HTTP GET request.
Args:
url: A URL.
headers: Request headers used by the client.
decoded: Whether decode the response body using UTF-8 or the charset specified in Content-Type.
Returns:
... | [
"Gets",
"the",
"content",
"of",
"a",
"URL",
"via",
"sending",
"a",
"HTTP",
"GET",
"request",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L415-L454 | [
"def",
"get_content",
"(",
"url",
",",
"headers",
"=",
"{",
"}",
",",
"decoded",
"=",
"True",
")",
":",
"logging",
".",
"debug",
"(",
"'get_content: %s'",
"%",
"url",
")",
"req",
"=",
"request",
".",
"Request",
"(",
"url",
",",
"headers",
"=",
"heade... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | post_content | Post the content of a URL via sending a HTTP POST request.
Args:
url: A URL.
headers: Request headers used by the client.
decoded: Whether decode the response body using UTF-8 or the charset specified in Content-Type.
Returns:
The content as a string. | src/you_get/common.py | def post_content(url, headers={}, post_data={}, decoded=True, **kwargs):
"""Post the content of a URL via sending a HTTP POST request.
Args:
url: A URL.
headers: Request headers used by the client.
decoded: Whether decode the response body using UTF-8 or the charset specified in Content... | def post_content(url, headers={}, post_data={}, decoded=True, **kwargs):
"""Post the content of a URL via sending a HTTP POST request.
Args:
url: A URL.
headers: Request headers used by the client.
decoded: Whether decode the response body using UTF-8 or the charset specified in Content... | [
"Post",
"the",
"content",
"of",
"a",
"URL",
"via",
"sending",
"a",
"HTTP",
"POST",
"request",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L457-L501 | [
"def",
"post_content",
"(",
"url",
",",
"headers",
"=",
"{",
"}",
",",
"post_data",
"=",
"{",
"}",
",",
"decoded",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'post_data_raw'",
")",
":",
"logging",
".",
"debug"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | parse_host | Parses host name and port number from a string. | src/you_get/common.py | def parse_host(host):
"""Parses host name and port number from a string.
"""
if re.match(r'^(\d+)$', host) is not None:
return ("0.0.0.0", int(host))
if re.match(r'^(\w+)://', host) is None:
host = "//" + host
o = parse.urlparse(host)
hostname = o.hostname or "0.0.0.0"
port =... | def parse_host(host):
"""Parses host name and port number from a string.
"""
if re.match(r'^(\d+)$', host) is not None:
return ("0.0.0.0", int(host))
if re.match(r'^(\w+)://', host) is None:
host = "//" + host
o = parse.urlparse(host)
hostname = o.hostname or "0.0.0.0"
port =... | [
"Parses",
"host",
"name",
"and",
"port",
"number",
"from",
"a",
"string",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L1216-L1226 | [
"def",
"parse_host",
"(",
"host",
")",
":",
"if",
"re",
".",
"match",
"(",
"r'^(\\d+)$'",
",",
"host",
")",
"is",
"not",
"None",
":",
"return",
"(",
"\"0.0.0.0\"",
",",
"int",
"(",
"host",
")",
")",
"if",
"re",
".",
"match",
"(",
"r'^(\\w+)://'",
"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | print_more_compatible | Overload default print function as py (<3.3) does not support 'flush' keyword.
Although the function name can be same as print to get itself overloaded automatically,
I'd rather leave it with a different name and only overload it when importing to make less confusion. | src/you_get/common.py | def print_more_compatible(*args, **kwargs):
import builtins as __builtin__
"""Overload default print function as py (<3.3) does not support 'flush' keyword.
Although the function name can be same as print to get itself overloaded automatically,
I'd rather leave it with a different name and only overload... | def print_more_compatible(*args, **kwargs):
import builtins as __builtin__
"""Overload default print function as py (<3.3) does not support 'flush' keyword.
Although the function name can be same as print to get itself overloaded automatically,
I'd rather leave it with a different name and only overload... | [
"Overload",
"default",
"print",
"function",
"as",
"py",
"(",
"<3",
".",
"3",
")",
"does",
"not",
"support",
"flush",
"keyword",
".",
"Although",
"the",
"function",
"name",
"can",
"be",
"same",
"as",
"print",
"to",
"get",
"itself",
"overloaded",
"automatica... | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/common.py#L1258-L1273 | [
"def",
"print_more_compatible",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"builtins",
"as",
"__builtin__",
"# nothing happens on py3.3 and later",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
">=",
"(",
"3",
",",
"3",
")",
":"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | showroom_get_roomid_by_room_url_key | str->str | src/you_get/extractors/showroom.py | def showroom_get_roomid_by_room_url_key(room_url_key):
"""str->str"""
fake_headers_mobile = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'UTF-8,*;q=0.5',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8... | def showroom_get_roomid_by_room_url_key(room_url_key):
"""str->str"""
fake_headers_mobile = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'UTF-8,*;q=0.5',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8... | [
"str",
"-",
">",
"str"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/showroom.py#L11-L24 | [
"def",
"showroom_get_roomid_by_room_url_key",
"(",
"room_url_key",
")",
":",
"fake_headers_mobile",
"=",
"{",
"'Accept'",
":",
"'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'",
",",
"'Accept-Charset'",
":",
"'UTF-8,*;q=0.5'",
",",
"'Accept-Encoding'",
":",
"'... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | showroom_download_by_room_id | Source: Android mobile | src/you_get/extractors/showroom.py | def showroom_download_by_room_id(room_id, output_dir = '.', merge = False, info_only = False, **kwargs):
'''Source: Android mobile'''
while True:
timestamp = str(int(time() * 1000))
api_endpoint = 'https://www.showroom-live.com/api/live/streaming_url?room_id={room_id}&_={timestamp}'.format(room_... | def showroom_download_by_room_id(room_id, output_dir = '.', merge = False, info_only = False, **kwargs):
'''Source: Android mobile'''
while True:
timestamp = str(int(time() * 1000))
api_endpoint = 'https://www.showroom-live.com/api/live/streaming_url?room_id={room_id}&_={timestamp}'.format(room_... | [
"Source",
":",
"Android",
"mobile"
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/showroom.py#L26-L56 | [
"def",
"showroom_download_by_room_id",
"(",
"room_id",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"False",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"while",
"True",
":",
"timestamp",
"=",
"str",
"(",
"int",
"(",
"time",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | _wanmen_get_title_by_json_topic_part | JSON, int, int, int->str
Get a proper title with courseid+topicID+partID. | src/you_get/extractors/wanmen.py | def _wanmen_get_title_by_json_topic_part(json_content, tIndex, pIndex):
"""JSON, int, int, int->str
Get a proper title with courseid+topicID+partID."""
return '_'.join([json_content[0]['name'],
json_content[0]['Topics'][tIndex]['name'],
json_content[0]['Topics']... | def _wanmen_get_title_by_json_topic_part(json_content, tIndex, pIndex):
"""JSON, int, int, int->str
Get a proper title with courseid+topicID+partID."""
return '_'.join([json_content[0]['name'],
json_content[0]['Topics'][tIndex]['name'],
json_content[0]['Topics']... | [
"JSON",
"int",
"int",
"int",
"-",
">",
"str",
"Get",
"a",
"proper",
"title",
"with",
"courseid",
"+",
"topicID",
"+",
"partID",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/wanmen.py#L18-L25 | [
"def",
"_wanmen_get_title_by_json_topic_part",
"(",
"json_content",
",",
"tIndex",
",",
"pIndex",
")",
":",
"return",
"'_'",
".",
"join",
"(",
"[",
"json_content",
"[",
"0",
"]",
"[",
"'name'",
"]",
",",
"json_content",
"[",
"0",
"]",
"[",
"'Topics'",
"]",... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | wanmen_download_by_course | int->None
Download a WHOLE course.
Reuse the API call to save time. | src/you_get/extractors/wanmen.py | def wanmen_download_by_course(json_api_content, output_dir='.', merge=True, info_only=False, **kwargs):
"""int->None
Download a WHOLE course.
Reuse the API call to save time."""
for tIndex in range(len(json_api_content[0]['Topics'])):
for pIndex in range(len(json_api_content[0]['Topics'][t... | def wanmen_download_by_course(json_api_content, output_dir='.', merge=True, info_only=False, **kwargs):
"""int->None
Download a WHOLE course.
Reuse the API call to save time."""
for tIndex in range(len(json_api_content[0]['Topics'])):
for pIndex in range(len(json_api_content[0]['Topics'][t... | [
"int",
"-",
">",
"None",
"Download",
"a",
"WHOLE",
"course",
".",
"Reuse",
"the",
"API",
"call",
"to",
"save",
"time",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/wanmen.py#L37-L51 | [
"def",
"wanmen_download_by_course",
"(",
"json_api_content",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"tIndex",
"in",
"range",
"(",
"len",
"(",
"json_api_content",
"... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | wanmen_download_by_course_topic_part | int, int, int->None
Download ONE PART of the course. | src/you_get/extractors/wanmen.py | def wanmen_download_by_course_topic_part(json_api_content, tIndex, pIndex, output_dir='.', merge=True, info_only=False, **kwargs):
"""int, int, int->None
Download ONE PART of the course."""
html = json_api_content
title = _wanmen_get_title_by_json_topic_part(html,
... | def wanmen_download_by_course_topic_part(json_api_content, tIndex, pIndex, output_dir='.', merge=True, info_only=False, **kwargs):
"""int, int, int->None
Download ONE PART of the course."""
html = json_api_content
title = _wanmen_get_title_by_json_topic_part(html,
... | [
"int",
"int",
"int",
"-",
">",
"None",
"Download",
"ONE",
"PART",
"of",
"the",
"course",
"."
] | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/wanmen.py#L69-L84 | [
"def",
"wanmen_download_by_course_topic_part",
"(",
"json_api_content",
",",
"tIndex",
",",
"pIndex",
",",
"output_dir",
"=",
"'.'",
",",
"merge",
"=",
"True",
",",
"info_only",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"html",
"=",
"json_api_content",
... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | Bigthink.get_streams_by_id | int, int->list
Get the height of the videos.
Since brightcove is using 3 kinds of links: rtmp, http and https,
we will be using the HTTPS one to make it secure.
If somehow akamaihd.net is blocked by the Great Fucking Wall,
change the "startswith https" ... | src/you_get/extractors/bigthink.py | def get_streams_by_id(account_number, video_id):
"""
int, int->list
Get the height of the videos.
Since brightcove is using 3 kinds of links: rtmp, http and https,
we will be using the HTTPS one to make it secure.
If somehow akamaihd.net is bloc... | def get_streams_by_id(account_number, video_id):
"""
int, int->list
Get the height of the videos.
Since brightcove is using 3 kinds of links: rtmp, http and https,
we will be using the HTTPS one to make it secure.
If somehow akamaihd.net is bloc... | [
"int",
"int",
"-",
">",
"list",
"Get",
"the",
"height",
"of",
"the",
"videos",
".",
"Since",
"brightcove",
"is",
"using",
"3",
"kinds",
"of",
"links",
":",
"rtmp",
"http",
"and",
"https",
"we",
"will",
"be",
"using",
"the",
"HTTPS",
"one",
"to",
"mak... | soimort/you-get | python | https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/bigthink.py#L22-L49 | [
"def",
"get_streams_by_id",
"(",
"account_number",
",",
"video_id",
")",
":",
"endpoint",
"=",
"'https://edge.api.brightcove.com/playback/v1/accounts/{account_number}/videos/{video_id}'",
".",
"format",
"(",
"account_number",
"=",
"account_number",
",",
"video_id",
"=",
"vide... | b746ac01c9f39de94cac2d56f665285b0523b974 |
test | BaseExecutor.has_task | Checks if a task is either queued or running in this executor
:param task_instance: TaskInstance
:return: True if the task is known to this executor | airflow/executors/base_executor.py | def has_task(self, task_instance):
"""
Checks if a task is either queued or running in this executor
:param task_instance: TaskInstance
:return: True if the task is known to this executor
"""
if task_instance.key in self.queued_tasks or task_instance.key in self.running:... | def has_task(self, task_instance):
"""
Checks if a task is either queued or running in this executor
:param task_instance: TaskInstance
:return: True if the task is known to this executor
"""
if task_instance.key in self.queued_tasks or task_instance.key in self.running:... | [
"Checks",
"if",
"a",
"task",
"is",
"either",
"queued",
"or",
"running",
"in",
"this",
"executor"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/executors/base_executor.py#L97-L105 | [
"def",
"has_task",
"(",
"self",
",",
"task_instance",
")",
":",
"if",
"task_instance",
".",
"key",
"in",
"self",
".",
"queued_tasks",
"or",
"task_instance",
".",
"key",
"in",
"self",
".",
"running",
":",
"return",
"True"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | BaseExecutor.get_event_buffer | Returns and flush the event buffer. In case dag_ids is specified
it will only return and flush events for the given dag_ids. Otherwise
it returns and flushes all
:param dag_ids: to dag_ids to return events for, if None returns all
:return: a dict of events | airflow/executors/base_executor.py | def get_event_buffer(self, dag_ids=None):
"""
Returns and flush the event buffer. In case dag_ids is specified
it will only return and flush events for the given dag_ids. Otherwise
it returns and flushes all
:param dag_ids: to dag_ids to return events for, if None returns all
... | def get_event_buffer(self, dag_ids=None):
"""
Returns and flush the event buffer. In case dag_ids is specified
it will only return and flush events for the given dag_ids. Otherwise
it returns and flushes all
:param dag_ids: to dag_ids to return events for, if None returns all
... | [
"Returns",
"and",
"flush",
"the",
"event",
"buffer",
".",
"In",
"case",
"dag_ids",
"is",
"specified",
"it",
"will",
"only",
"return",
"and",
"flush",
"events",
"for",
"the",
"given",
"dag_ids",
".",
"Otherwise",
"it",
"returns",
"and",
"flushes",
"all"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/executors/base_executor.py#L160-L179 | [
"def",
"get_event_buffer",
"(",
"self",
",",
"dag_ids",
"=",
"None",
")",
":",
"cleared_events",
"=",
"dict",
"(",
")",
"if",
"dag_ids",
"is",
"None",
":",
"cleared_events",
"=",
"self",
".",
"event_buffer",
"self",
".",
"event_buffer",
"=",
"dict",
"(",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SnowflakeHook._get_conn_params | one method to fetch connection params as a dict
used in get_uri() and get_connection() | airflow/contrib/hooks/snowflake_hook.py | def _get_conn_params(self):
"""
one method to fetch connection params as a dict
used in get_uri() and get_connection()
"""
conn = self.get_connection(self.snowflake_conn_id)
account = conn.extra_dejson.get('account', None)
warehouse = conn.extra_dejson.get('wareho... | def _get_conn_params(self):
"""
one method to fetch connection params as a dict
used in get_uri() and get_connection()
"""
conn = self.get_connection(self.snowflake_conn_id)
account = conn.extra_dejson.get('account', None)
warehouse = conn.extra_dejson.get('wareho... | [
"one",
"method",
"to",
"fetch",
"connection",
"params",
"as",
"a",
"dict",
"used",
"in",
"get_uri",
"()",
"and",
"get_connection",
"()"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/snowflake_hook.py#L47-L96 | [
"def",
"_get_conn_params",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
"self",
".",
"snowflake_conn_id",
")",
"account",
"=",
"conn",
".",
"extra_dejson",
".",
"get",
"(",
"'account'",
",",
"None",
")",
"warehouse",
"=",
"conn",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SnowflakeHook.get_uri | override DbApiHook get_uri method for get_sqlalchemy_engine() | airflow/contrib/hooks/snowflake_hook.py | def get_uri(self):
"""
override DbApiHook get_uri method for get_sqlalchemy_engine()
"""
conn_config = self._get_conn_params()
uri = 'snowflake://{user}:{password}@{account}/{database}/'
uri += '{schema}?warehouse={warehouse}&role={role}'
return uri.format(**conn_... | def get_uri(self):
"""
override DbApiHook get_uri method for get_sqlalchemy_engine()
"""
conn_config = self._get_conn_params()
uri = 'snowflake://{user}:{password}@{account}/{database}/'
uri += '{schema}?warehouse={warehouse}&role={role}'
return uri.format(**conn_... | [
"override",
"DbApiHook",
"get_uri",
"method",
"for",
"get_sqlalchemy_engine",
"()"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/snowflake_hook.py#L98-L105 | [
"def",
"get_uri",
"(",
"self",
")",
":",
"conn_config",
"=",
"self",
".",
"_get_conn_params",
"(",
")",
"uri",
"=",
"'snowflake://{user}:{password}@{account}/{database}/'",
"uri",
"+=",
"'{schema}?warehouse={warehouse}&role={role}'",
"return",
"uri",
".",
"format",
"(",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SnowflakeHook.get_conn | Returns a snowflake.connection object | airflow/contrib/hooks/snowflake_hook.py | def get_conn(self):
"""
Returns a snowflake.connection object
"""
conn_config = self._get_conn_params()
conn = snowflake.connector.connect(**conn_config)
return conn | def get_conn(self):
"""
Returns a snowflake.connection object
"""
conn_config = self._get_conn_params()
conn = snowflake.connector.connect(**conn_config)
return conn | [
"Returns",
"a",
"snowflake",
".",
"connection",
"object"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/snowflake_hook.py#L107-L113 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"conn_config",
"=",
"self",
".",
"_get_conn_params",
"(",
")",
"conn",
"=",
"snowflake",
".",
"connector",
".",
"connect",
"(",
"*",
"*",
"conn_config",
")",
"return",
"conn"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | SnowflakeHook._get_aws_credentials | returns aws_access_key_id, aws_secret_access_key
from extra
intended to be used by external import and export statements | airflow/contrib/hooks/snowflake_hook.py | def _get_aws_credentials(self):
"""
returns aws_access_key_id, aws_secret_access_key
from extra
intended to be used by external import and export statements
"""
if self.snowflake_conn_id:
connection_object = self.get_connection(self.snowflake_conn_id)
... | def _get_aws_credentials(self):
"""
returns aws_access_key_id, aws_secret_access_key
from extra
intended to be used by external import and export statements
"""
if self.snowflake_conn_id:
connection_object = self.get_connection(self.snowflake_conn_id)
... | [
"returns",
"aws_access_key_id",
"aws_secret_access_key",
"from",
"extra"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/snowflake_hook.py#L115-L129 | [
"def",
"_get_aws_credentials",
"(",
"self",
")",
":",
"if",
"self",
".",
"snowflake_conn_id",
":",
"connection_object",
"=",
"self",
".",
"get_connection",
"(",
"self",
".",
"snowflake_conn_id",
")",
"if",
"'aws_secret_access_key'",
"in",
"connection_object",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | GrpcHook._get_field | Fetches a field from extras, and returns it. This is some Airflow
magic. The grpc hook type adds custom UI elements
to the hook page, which allow admins to specify scopes, credential pem files, etc.
They get formatted as shown below. | airflow/contrib/hooks/grpc_hook.py | def _get_field(self, field_name, default=None):
"""
Fetches a field from extras, and returns it. This is some Airflow
magic. The grpc hook type adds custom UI elements
to the hook page, which allow admins to specify scopes, credential pem files, etc.
They get formatted as shown b... | def _get_field(self, field_name, default=None):
"""
Fetches a field from extras, and returns it. This is some Airflow
magic. The grpc hook type adds custom UI elements
to the hook page, which allow admins to specify scopes, credential pem files, etc.
They get formatted as shown b... | [
"Fetches",
"a",
"field",
"from",
"extras",
"and",
"returns",
"it",
".",
"This",
"is",
"some",
"Airflow",
"magic",
".",
"The",
"grpc",
"hook",
"type",
"adds",
"custom",
"UI",
"elements",
"to",
"the",
"hook",
"page",
"which",
"allow",
"admins",
"to",
"spec... | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/grpc_hook.py#L112-L123 | [
"def",
"_get_field",
"(",
"self",
",",
"field_name",
",",
"default",
"=",
"None",
")",
":",
"full_field_name",
"=",
"'extra__grpc__{}'",
".",
"format",
"(",
"field_name",
")",
"if",
"full_field_name",
"in",
"self",
".",
"extras",
":",
"return",
"self",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | PostgresHook.copy_expert | Executes SQL using psycopg2 copy_expert method.
Necessary to execute COPY command without access to a superuser.
Note: if this method is called with a "COPY FROM" statement and
the specified input file does not exist, it creates an empty
file and no data is loaded, but the operation suc... | airflow/hooks/postgres_hook.py | def copy_expert(self, sql, filename, open=open):
"""
Executes SQL using psycopg2 copy_expert method.
Necessary to execute COPY command without access to a superuser.
Note: if this method is called with a "COPY FROM" statement and
the specified input file does not exist, it creat... | def copy_expert(self, sql, filename, open=open):
"""
Executes SQL using psycopg2 copy_expert method.
Necessary to execute COPY command without access to a superuser.
Note: if this method is called with a "COPY FROM" statement and
the specified input file does not exist, it creat... | [
"Executes",
"SQL",
"using",
"psycopg2",
"copy_expert",
"method",
".",
"Necessary",
"to",
"execute",
"COPY",
"command",
"without",
"access",
"to",
"a",
"superuser",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/postgres_hook.py#L63-L83 | [
"def",
"copy_expert",
"(",
"self",
",",
"sql",
",",
"filename",
",",
"open",
"=",
"open",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
":",
"pass",
"with",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | PostgresHook.bulk_load | Loads a tab-delimited file into a database table | airflow/hooks/postgres_hook.py | def bulk_load(self, table, tmp_file):
"""
Loads a tab-delimited file into a database table
"""
self.copy_expert("COPY {table} FROM STDIN".format(table=table), tmp_file) | def bulk_load(self, table, tmp_file):
"""
Loads a tab-delimited file into a database table
"""
self.copy_expert("COPY {table} FROM STDIN".format(table=table), tmp_file) | [
"Loads",
"a",
"tab",
"-",
"delimited",
"file",
"into",
"a",
"database",
"table"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/postgres_hook.py#L85-L89 | [
"def",
"bulk_load",
"(",
"self",
",",
"table",
",",
"tmp_file",
")",
":",
"self",
".",
"copy_expert",
"(",
"\"COPY {table} FROM STDIN\"",
".",
"format",
"(",
"table",
"=",
"table",
")",
",",
"tmp_file",
")"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | PostgresHook.bulk_dump | Dumps a database table into a tab-delimited file | airflow/hooks/postgres_hook.py | def bulk_dump(self, table, tmp_file):
"""
Dumps a database table into a tab-delimited file
"""
self.copy_expert("COPY {table} TO STDOUT".format(table=table), tmp_file) | def bulk_dump(self, table, tmp_file):
"""
Dumps a database table into a tab-delimited file
"""
self.copy_expert("COPY {table} TO STDOUT".format(table=table), tmp_file) | [
"Dumps",
"a",
"database",
"table",
"into",
"a",
"tab",
"-",
"delimited",
"file"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/postgres_hook.py#L91-L95 | [
"def",
"bulk_dump",
"(",
"self",
",",
"table",
",",
"tmp_file",
")",
":",
"self",
".",
"copy_expert",
"(",
"\"COPY {table} TO STDOUT\"",
".",
"format",
"(",
"table",
"=",
"table",
")",
",",
"tmp_file",
")"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | FileToGoogleCloudStorageOperator.execute | Uploads the file to Google cloud storage | airflow/contrib/operators/file_to_gcs.py | def execute(self, context):
"""
Uploads the file to Google cloud storage
"""
hook = GoogleCloudStorageHook(
google_cloud_storage_conn_id=self.google_cloud_storage_conn_id,
delegate_to=self.delegate_to)
hook.upload(
bucket_name=self.bucket,
... | def execute(self, context):
"""
Uploads the file to Google cloud storage
"""
hook = GoogleCloudStorageHook(
google_cloud_storage_conn_id=self.google_cloud_storage_conn_id,
delegate_to=self.delegate_to)
hook.upload(
bucket_name=self.bucket,
... | [
"Uploads",
"the",
"file",
"to",
"Google",
"cloud",
"storage"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/operators/file_to_gcs.py#L68-L82 | [
"def",
"execute",
"(",
"self",
",",
"context",
")",
":",
"hook",
"=",
"GoogleCloudStorageHook",
"(",
"google_cloud_storage_conn_id",
"=",
"self",
".",
"google_cloud_storage_conn_id",
",",
"delegate_to",
"=",
"self",
".",
"delegate_to",
")",
"hook",
".",
"upload",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | max_partition | Gets the max partition for a table.
:param schema: The hive schema the table lives in
:type schema: str
:param table: The hive table you are interested in, supports the dot
notation as in "my_database.my_table", if a dot is found,
the schema param is disregarded
:type table: str
:pa... | airflow/macros/hive.py | def max_partition(
table, schema="default", field=None, filter_map=None,
metastore_conn_id='metastore_default'):
"""
Gets the max partition for a table.
:param schema: The hive schema the table lives in
:type schema: str
:param table: The hive table you are interested in, supports t... | def max_partition(
table, schema="default", field=None, filter_map=None,
metastore_conn_id='metastore_default'):
"""
Gets the max partition for a table.
:param schema: The hive schema the table lives in
:type schema: str
:param table: The hive table you are interested in, supports t... | [
"Gets",
"the",
"max",
"partition",
"for",
"a",
"table",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/macros/hive.py#L23-L55 | [
"def",
"max_partition",
"(",
"table",
",",
"schema",
"=",
"\"default\"",
",",
"field",
"=",
"None",
",",
"filter_map",
"=",
"None",
",",
"metastore_conn_id",
"=",
"'metastore_default'",
")",
":",
"from",
"airflow",
".",
"hooks",
".",
"hive_hooks",
"import",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | _closest_date | This function finds the date in a list closest to the target date.
An optional parameter can be given to get the closest before or after.
:param target_dt: The target date
:type target_dt: datetime.date
:param date_list: The list of dates to search
:type date_list: list[datetime.date]
:param be... | airflow/macros/hive.py | def _closest_date(target_dt, date_list, before_target=None):
"""
This function finds the date in a list closest to the target date.
An optional parameter can be given to get the closest before or after.
:param target_dt: The target date
:type target_dt: datetime.date
:param date_list: The list ... | def _closest_date(target_dt, date_list, before_target=None):
"""
This function finds the date in a list closest to the target date.
An optional parameter can be given to get the closest before or after.
:param target_dt: The target date
:type target_dt: datetime.date
:param date_list: The list ... | [
"This",
"function",
"finds",
"the",
"date",
"in",
"a",
"list",
"closest",
"to",
"the",
"target",
"date",
".",
"An",
"optional",
"parameter",
"can",
"be",
"given",
"to",
"get",
"the",
"closest",
"before",
"or",
"after",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/macros/hive.py#L58-L80 | [
"def",
"_closest_date",
"(",
"target_dt",
",",
"date_list",
",",
"before_target",
"=",
"None",
")",
":",
"fb",
"=",
"lambda",
"d",
":",
"target_dt",
"-",
"d",
"if",
"d",
"<=",
"target_dt",
"else",
"datetime",
".",
"timedelta",
".",
"max",
"fa",
"=",
"l... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | closest_ds_partition | This function finds the date in a list closest to the target date.
An optional parameter can be given to get the closest before or after.
:param table: A hive table name
:type table: str
:param ds: A datestamp ``%Y-%m-%d`` e.g. ``yyyy-mm-dd``
:type ds: list[datetime.date]
:param before: closest... | airflow/macros/hive.py | def closest_ds_partition(
table, ds, before=True, schema="default",
metastore_conn_id='metastore_default'):
"""
This function finds the date in a list closest to the target date.
An optional parameter can be given to get the closest before or after.
:param table: A hive table name
:... | def closest_ds_partition(
table, ds, before=True, schema="default",
metastore_conn_id='metastore_default'):
"""
This function finds the date in a list closest to the target date.
An optional parameter can be given to get the closest before or after.
:param table: A hive table name
:... | [
"This",
"function",
"finds",
"the",
"date",
"in",
"a",
"list",
"closest",
"to",
"the",
"target",
"date",
".",
"An",
"optional",
"parameter",
"can",
"be",
"given",
"to",
"get",
"the",
"closest",
"before",
"or",
"after",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/macros/hive.py#L83-L118 | [
"def",
"closest_ds_partition",
"(",
"table",
",",
"ds",
",",
"before",
"=",
"True",
",",
"schema",
"=",
"\"default\"",
",",
"metastore_conn_id",
"=",
"'metastore_default'",
")",
":",
"from",
"airflow",
".",
"hooks",
".",
"hive_hooks",
"import",
"HiveMetastoreHoo... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | MySqlHook.get_conn | Returns a mysql connection object | airflow/hooks/mysql_hook.py | def get_conn(self):
"""
Returns a mysql connection object
"""
conn = self.get_connection(self.mysql_conn_id)
conn_config = {
"user": conn.login,
"passwd": conn.password or '',
"host": conn.host or 'localhost',
"db": self.schema or c... | def get_conn(self):
"""
Returns a mysql connection object
"""
conn = self.get_connection(self.mysql_conn_id)
conn_config = {
"user": conn.login,
"passwd": conn.password or '',
"host": conn.host or 'localhost',
"db": self.schema or c... | [
"Returns",
"a",
"mysql",
"connection",
"object"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/mysql_hook.py#L62-L105 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"get_connection",
"(",
"self",
".",
"mysql_conn_id",
")",
"conn_config",
"=",
"{",
"\"user\"",
":",
"conn",
".",
"login",
",",
"\"passwd\"",
":",
"conn",
".",
"password",
"or",
"''",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | MySqlHook.bulk_load | Loads a tab-delimited file into a database table | airflow/hooks/mysql_hook.py | def bulk_load(self, table, tmp_file):
"""
Loads a tab-delimited file into a database table
"""
conn = self.get_conn()
cur = conn.cursor()
cur.execute("""
LOAD DATA LOCAL INFILE '{tmp_file}'
INTO TABLE {table}
""".format(tmp_file=tmp_fil... | def bulk_load(self, table, tmp_file):
"""
Loads a tab-delimited file into a database table
"""
conn = self.get_conn()
cur = conn.cursor()
cur.execute("""
LOAD DATA LOCAL INFILE '{tmp_file}'
INTO TABLE {table}
""".format(tmp_file=tmp_fil... | [
"Loads",
"a",
"tab",
"-",
"delimited",
"file",
"into",
"a",
"database",
"table"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/hooks/mysql_hook.py#L107-L117 | [
"def",
"bulk_load",
"(",
"self",
",",
"table",
",",
"tmp_file",
")",
":",
"conn",
"=",
"self",
".",
"get_conn",
"(",
")",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"cur",
".",
"execute",
"(",
"\"\"\"\n LOAD DATA LOCAL INFILE '{tmp_file}'\n ... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | GoogleCloudStorageUploadSessionCompleteSensor.is_bucket_updated | Checks whether new objects have been uploaded and the inactivity_period
has passed and updates the state of the sensor accordingly.
:param current_num_objects: number of objects in bucket during last poke.
:type current_num_objects: int | airflow/contrib/sensors/gcs_sensor.py | def is_bucket_updated(self, current_num_objects):
"""
Checks whether new objects have been uploaded and the inactivity_period
has passed and updates the state of the sensor accordingly.
:param current_num_objects: number of objects in bucket during last poke.
:type current_num_o... | def is_bucket_updated(self, current_num_objects):
"""
Checks whether new objects have been uploaded and the inactivity_period
has passed and updates the state of the sensor accordingly.
:param current_num_objects: number of objects in bucket during last poke.
:type current_num_o... | [
"Checks",
"whether",
"new",
"objects",
"have",
"been",
"uploaded",
"and",
"the",
"inactivity_period",
"has",
"passed",
"and",
"updates",
"the",
"state",
"of",
"the",
"sensor",
"accordingly",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/sensors/gcs_sensor.py#L242-L310 | [
"def",
"is_bucket_updated",
"(",
"self",
",",
"current_num_objects",
")",
":",
"if",
"current_num_objects",
">",
"self",
".",
"previous_num_objects",
":",
"# When new objects arrived, reset the inactivity_seconds",
"# previous_num_objects for the next poke.",
"self",
".",
"log"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | sigquit_handler | Helps debug deadlocks by printing stacktraces when this gets a SIGQUIT
e.g. kill -s QUIT <PID> or CTRL+\ | airflow/bin/cli.py | def sigquit_handler(sig, frame):
"""Helps debug deadlocks by printing stacktraces when this gets a SIGQUIT
e.g. kill -s QUIT <PID> or CTRL+\
"""
print("Dumping stack traces for all threads in PID {}".format(os.getpid()))
id_to_name = dict([(th.ident, th.name) for th in threading.enumerate()])
co... | def sigquit_handler(sig, frame):
"""Helps debug deadlocks by printing stacktraces when this gets a SIGQUIT
e.g. kill -s QUIT <PID> or CTRL+\
"""
print("Dumping stack traces for all threads in PID {}".format(os.getpid()))
id_to_name = dict([(th.ident, th.name) for th in threading.enumerate()])
co... | [
"Helps",
"debug",
"deadlocks",
"by",
"printing",
"stacktraces",
"when",
"this",
"gets",
"a",
"SIGQUIT",
"e",
".",
"g",
".",
"kill",
"-",
"s",
"QUIT",
"<PID",
">",
"or",
"CTRL",
"+",
"\\"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L88-L103 | [
"def",
"sigquit_handler",
"(",
"sig",
",",
"frame",
")",
":",
"print",
"(",
"\"Dumping stack traces for all threads in PID {}\"",
".",
"format",
"(",
"os",
".",
"getpid",
"(",
")",
")",
")",
"id_to_name",
"=",
"dict",
"(",
"[",
"(",
"th",
".",
"ident",
","... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | trigger_dag | Creates a dag run for the specified dag
:param args:
:return: | airflow/bin/cli.py | def trigger_dag(args):
"""
Creates a dag run for the specified dag
:param args:
:return:
"""
log = LoggingMixin().log
try:
message = api_client.trigger_dag(dag_id=args.dag_id,
run_id=args.run_id,
conf=a... | def trigger_dag(args):
"""
Creates a dag run for the specified dag
:param args:
:return:
"""
log = LoggingMixin().log
try:
message = api_client.trigger_dag(dag_id=args.dag_id,
run_id=args.run_id,
conf=a... | [
"Creates",
"a",
"dag",
"run",
"for",
"the",
"specified",
"dag",
":",
"param",
"args",
":",
":",
"return",
":"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L221-L236 | [
"def",
"trigger_dag",
"(",
"args",
")",
":",
"log",
"=",
"LoggingMixin",
"(",
")",
".",
"log",
"try",
":",
"message",
"=",
"api_client",
".",
"trigger_dag",
"(",
"dag_id",
"=",
"args",
".",
"dag_id",
",",
"run_id",
"=",
"args",
".",
"run_id",
",",
"c... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | delete_dag | Deletes all DB records related to the specified dag
:param args:
:return: | airflow/bin/cli.py | def delete_dag(args):
"""
Deletes all DB records related to the specified dag
:param args:
:return:
"""
log = LoggingMixin().log
if args.yes or input(
"This will drop all existing records related to the specified DAG. "
"Proceed? (y/n)").upper() == "Y":
try:
... | def delete_dag(args):
"""
Deletes all DB records related to the specified dag
:param args:
:return:
"""
log = LoggingMixin().log
if args.yes or input(
"This will drop all existing records related to the specified DAG. "
"Proceed? (y/n)").upper() == "Y":
try:
... | [
"Deletes",
"all",
"DB",
"records",
"related",
"to",
"the",
"specified",
"dag",
":",
"param",
"args",
":",
":",
"return",
":"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L240-L257 | [
"def",
"delete_dag",
"(",
"args",
")",
":",
"log",
"=",
"LoggingMixin",
"(",
")",
".",
"log",
"if",
"args",
".",
"yes",
"or",
"input",
"(",
"\"This will drop all existing records related to the specified DAG. \"",
"\"Proceed? (y/n)\"",
")",
".",
"upper",
"(",
")",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | task_failed_deps | Returns the unmet dependencies for a task instance from the perspective of the
scheduler (i.e. why a task instance doesn't get scheduled and then queued by the
scheduler, and then run by an executor).
>>> airflow task_failed_deps tutorial sleep 2015-01-01
Task instance dependencies not met:
Dagrun R... | airflow/bin/cli.py | def task_failed_deps(args):
"""
Returns the unmet dependencies for a task instance from the perspective of the
scheduler (i.e. why a task instance doesn't get scheduled and then queued by the
scheduler, and then run by an executor).
>>> airflow task_failed_deps tutorial sleep 2015-01-01
Task ins... | def task_failed_deps(args):
"""
Returns the unmet dependencies for a task instance from the perspective of the
scheduler (i.e. why a task instance doesn't get scheduled and then queued by the
scheduler, and then run by an executor).
>>> airflow task_failed_deps tutorial sleep 2015-01-01
Task ins... | [
"Returns",
"the",
"unmet",
"dependencies",
"for",
"a",
"task",
"instance",
"from",
"the",
"perspective",
"of",
"the",
"scheduler",
"(",
"i",
".",
"e",
".",
"why",
"a",
"task",
"instance",
"doesn",
"t",
"get",
"scheduled",
"and",
"then",
"queued",
"by",
"... | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L527-L550 | [
"def",
"task_failed_deps",
"(",
"args",
")",
":",
"dag",
"=",
"get_dag",
"(",
"args",
")",
"task",
"=",
"dag",
".",
"get_task",
"(",
"task_id",
"=",
"args",
".",
"task_id",
")",
"ti",
"=",
"TaskInstance",
"(",
"task",
",",
"args",
".",
"execution_date"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | task_state | Returns the state of a TaskInstance at the command line.
>>> airflow task_state tutorial sleep 2015-01-01
success | airflow/bin/cli.py | def task_state(args):
"""
Returns the state of a TaskInstance at the command line.
>>> airflow task_state tutorial sleep 2015-01-01
success
"""
dag = get_dag(args)
task = dag.get_task(task_id=args.task_id)
ti = TaskInstance(task, args.execution_date)
print(ti.current_state()) | def task_state(args):
"""
Returns the state of a TaskInstance at the command line.
>>> airflow task_state tutorial sleep 2015-01-01
success
"""
dag = get_dag(args)
task = dag.get_task(task_id=args.task_id)
ti = TaskInstance(task, args.execution_date)
print(ti.current_state()) | [
"Returns",
"the",
"state",
"of",
"a",
"TaskInstance",
"at",
"the",
"command",
"line",
".",
">>>",
"airflow",
"task_state",
"tutorial",
"sleep",
"2015",
"-",
"01",
"-",
"01",
"success"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L554-L563 | [
"def",
"task_state",
"(",
"args",
")",
":",
"dag",
"=",
"get_dag",
"(",
"args",
")",
"task",
"=",
"dag",
".",
"get_task",
"(",
"task_id",
"=",
"args",
".",
"task_id",
")",
"ti",
"=",
"TaskInstance",
"(",
"task",
",",
"args",
".",
"execution_date",
")... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | dag_state | Returns the state of a DagRun at the command line.
>>> airflow dag_state tutorial 2015-01-01T00:00:00.000000
running | airflow/bin/cli.py | def dag_state(args):
"""
Returns the state of a DagRun at the command line.
>>> airflow dag_state tutorial 2015-01-01T00:00:00.000000
running
"""
dag = get_dag(args)
dr = DagRun.find(dag.dag_id, execution_date=args.execution_date)
print(dr[0].state if len(dr) > 0 else None) | def dag_state(args):
"""
Returns the state of a DagRun at the command line.
>>> airflow dag_state tutorial 2015-01-01T00:00:00.000000
running
"""
dag = get_dag(args)
dr = DagRun.find(dag.dag_id, execution_date=args.execution_date)
print(dr[0].state if len(dr) > 0 else None) | [
"Returns",
"the",
"state",
"of",
"a",
"DagRun",
"at",
"the",
"command",
"line",
".",
">>>",
"airflow",
"dag_state",
"tutorial",
"2015",
"-",
"01",
"-",
"01T00",
":",
"00",
":",
"00",
".",
"000000",
"running"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L567-L575 | [
"def",
"dag_state",
"(",
"args",
")",
":",
"dag",
"=",
"get_dag",
"(",
"args",
")",
"dr",
"=",
"DagRun",
".",
"find",
"(",
"dag",
".",
"dag_id",
",",
"execution_date",
"=",
"args",
".",
"execution_date",
")",
"print",
"(",
"dr",
"[",
"0",
"]",
".",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | next_execution | Returns the next execution datetime of a DAG at the command line.
>>> airflow next_execution tutorial
2018-08-31 10:38:00 | airflow/bin/cli.py | def next_execution(args):
"""
Returns the next execution datetime of a DAG at the command line.
>>> airflow next_execution tutorial
2018-08-31 10:38:00
"""
dag = get_dag(args)
if dag.is_paused:
print("[INFO] Please be reminded this DAG is PAUSED now.")
if dag.latest_execution_d... | def next_execution(args):
"""
Returns the next execution datetime of a DAG at the command line.
>>> airflow next_execution tutorial
2018-08-31 10:38:00
"""
dag = get_dag(args)
if dag.is_paused:
print("[INFO] Please be reminded this DAG is PAUSED now.")
if dag.latest_execution_d... | [
"Returns",
"the",
"next",
"execution",
"datetime",
"of",
"a",
"DAG",
"at",
"the",
"command",
"line",
".",
">>>",
"airflow",
"next_execution",
"tutorial",
"2018",
"-",
"08",
"-",
"31",
"10",
":",
"38",
":",
"00"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L579-L600 | [
"def",
"next_execution",
"(",
"args",
")",
":",
"dag",
"=",
"get_dag",
"(",
"args",
")",
"if",
"dag",
".",
"is_paused",
":",
"print",
"(",
"\"[INFO] Please be reminded this DAG is PAUSED now.\"",
")",
"if",
"dag",
".",
"latest_execution_date",
":",
"next_execution... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | restart_workers | Runs forever, monitoring the child processes of @gunicorn_master_proc and
restarting workers occasionally.
Each iteration of the loop traverses one edge of this state transition
diagram, where each state (node) represents
[ num_ready_workers_running / num_workers_running ]. We expect most time to
be... | airflow/bin/cli.py | def restart_workers(gunicorn_master_proc, num_workers_expected, master_timeout):
"""
Runs forever, monitoring the child processes of @gunicorn_master_proc and
restarting workers occasionally.
Each iteration of the loop traverses one edge of this state transition
diagram, where each state (node) repr... | def restart_workers(gunicorn_master_proc, num_workers_expected, master_timeout):
"""
Runs forever, monitoring the child processes of @gunicorn_master_proc and
restarting workers occasionally.
Each iteration of the loop traverses one edge of this state transition
diagram, where each state (node) repr... | [
"Runs",
"forever",
"monitoring",
"the",
"child",
"processes",
"of"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/bin/cli.py#L763-L868 | [
"def",
"restart_workers",
"(",
"gunicorn_master_proc",
",",
"num_workers_expected",
",",
"master_timeout",
")",
":",
"def",
"wait_until_true",
"(",
"fn",
",",
"timeout",
"=",
"0",
")",
":",
"\"\"\"\n Sleeps until fn is true\n \"\"\"",
"t",
"=",
"time",
"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudTranslateHook.get_conn | Retrieves connection to Cloud Translate
:return: Google Cloud Translate client object.
:rtype: Client | airflow/contrib/hooks/gcp_translate_hook.py | def get_conn(self):
"""
Retrieves connection to Cloud Translate
:return: Google Cloud Translate client object.
:rtype: Client
"""
if not self._client:
self._client = Client(credentials=self._get_credentials())
return self._client | def get_conn(self):
"""
Retrieves connection to Cloud Translate
:return: Google Cloud Translate client object.
:rtype: Client
"""
if not self._client:
self._client = Client(credentials=self._get_credentials())
return self._client | [
"Retrieves",
"connection",
"to",
"Cloud",
"Translate"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_translate_hook.py#L34-L43 | [
"def",
"get_conn",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_client",
":",
"self",
".",
"_client",
"=",
"Client",
"(",
"credentials",
"=",
"self",
".",
"_get_credentials",
"(",
")",
")",
"return",
"self",
".",
"_client"
] | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudTranslateHook.translate | Translate a string or list of strings.
See https://cloud.google.com/translate/docs/translating-text
:type values: str or list
:param values: String or list of strings to translate.
:type target_language: str
:param target_language: The language to translate results into. This
... | airflow/contrib/hooks/gcp_translate_hook.py | def translate(
self, values, target_language, format_=None, source_language=None, model=None
):
"""Translate a string or list of strings.
See https://cloud.google.com/translate/docs/translating-text
:type values: str or list
:param values: String or list of strings to trans... | def translate(
self, values, target_language, format_=None, source_language=None, model=None
):
"""Translate a string or list of strings.
See https://cloud.google.com/translate/docs/translating-text
:type values: str or list
:param values: String or list of strings to trans... | [
"Translate",
"a",
"string",
"or",
"list",
"of",
"strings",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_translate_hook.py#L45-L97 | [
"def",
"translate",
"(",
"self",
",",
"values",
",",
"target_language",
",",
"format_",
"=",
"None",
",",
"source_language",
"=",
"None",
",",
"model",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"get_conn",
"(",
")",
"return",
"client",
".",
"t... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | BashOperator.execute | Execute the bash command in a temporary directory
which will be cleaned afterwards | airflow/operators/bash_operator.py | def execute(self, context):
"""
Execute the bash command in a temporary directory
which will be cleaned afterwards
"""
self.log.info('Tmp dir root location: \n %s', gettempdir())
# Prepare env for child process.
if self.env is None:
self.env = os.envi... | def execute(self, context):
"""
Execute the bash command in a temporary directory
which will be cleaned afterwards
"""
self.log.info('Tmp dir root location: \n %s', gettempdir())
# Prepare env for child process.
if self.env is None:
self.env = os.envi... | [
"Execute",
"the",
"bash",
"command",
"in",
"a",
"temporary",
"directory",
"which",
"will",
"be",
"cleaned",
"afterwards"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/operators/bash_operator.py#L86-L144 | [
"def",
"execute",
"(",
"self",
",",
"context",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"'Tmp dir root location: \\n %s'",
",",
"gettempdir",
"(",
")",
")",
"# Prepare env for child process.",
"if",
"self",
".",
"env",
"is",
"None",
":",
"self",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.get_instance | Retrieves a resource containing information about a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param project_id: Project ID of the project that contains the instance. If set
to None or missing, the default pr... | airflow/contrib/hooks/gcp_sql_hook.py | def get_instance(self, instance, project_id=None):
"""
Retrieves a resource containing information about a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param project_id: Project ID of the project that conta... | def get_instance(self, instance, project_id=None):
"""
Retrieves a resource containing information about a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param project_id: Project ID of the project that conta... | [
"Retrieves",
"a",
"resource",
"containing",
"information",
"about",
"a",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L97-L112 | [
"def",
"get_instance",
"(",
"self",
",",
"instance",
",",
"project_id",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_conn",
"(",
")",
".",
"instances",
"(",
")",
".",
"get",
"(",
"project",
"=",
"project_id",
",",
"instance",
"=",
"instance",
")"... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.create_instance | Creates a new Cloud SQL instance.
:param body: Body required by the Cloud SQL insert API, as described in
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/insert#request-body.
:type body: dict
:param project_id: Project ID of the project that contains the instance... | airflow/contrib/hooks/gcp_sql_hook.py | def create_instance(self, body, project_id=None):
"""
Creates a new Cloud SQL instance.
:param body: Body required by the Cloud SQL insert API, as described in
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/insert#request-body.
:type body: dict
:... | def create_instance(self, body, project_id=None):
"""
Creates a new Cloud SQL instance.
:param body: Body required by the Cloud SQL insert API, as described in
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/insert#request-body.
:type body: dict
:... | [
"Creates",
"a",
"new",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L115-L133 | [
"def",
"create_instance",
"(",
"self",
",",
"body",
",",
"project_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_conn",
"(",
")",
".",
"instances",
"(",
")",
".",
"insert",
"(",
"project",
"=",
"project_id",
",",
"body",
"=",
"body",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.patch_instance | Updates settings of a Cloud SQL instance.
Caution: This is not a partial update, so you must include values for
all the settings that you want to retain.
:param body: Body required by the Cloud SQL patch API, as described in
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4... | airflow/contrib/hooks/gcp_sql_hook.py | def patch_instance(self, body, instance, project_id=None):
"""
Updates settings of a Cloud SQL instance.
Caution: This is not a partial update, so you must include values for
all the settings that you want to retain.
:param body: Body required by the Cloud SQL patch API, as des... | def patch_instance(self, body, instance, project_id=None):
"""
Updates settings of a Cloud SQL instance.
Caution: This is not a partial update, so you must include values for
all the settings that you want to retain.
:param body: Body required by the Cloud SQL patch API, as des... | [
"Updates",
"settings",
"of",
"a",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L136-L160 | [
"def",
"patch_instance",
"(",
"self",
",",
"body",
",",
"instance",
",",
"project_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_conn",
"(",
")",
".",
"instances",
"(",
")",
".",
"patch",
"(",
"project",
"=",
"project_id",
",",
"instanc... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.delete_instance | Deletes a Cloud SQL instance.
:param project_id: Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.
:type project_id: str
:param instance: Cloud SQL instance ID. This does not include the project I... | airflow/contrib/hooks/gcp_sql_hook.py | def delete_instance(self, instance, project_id=None):
"""
Deletes a Cloud SQL instance.
:param project_id: Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.
:type project_id: str
:... | def delete_instance(self, instance, project_id=None):
"""
Deletes a Cloud SQL instance.
:param project_id: Project ID of the project that contains the instance. If set
to None or missing, the default project_id from the GCP connection is used.
:type project_id: str
:... | [
"Deletes",
"a",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L163-L180 | [
"def",
"delete_instance",
"(",
"self",
",",
"instance",
",",
"project_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_conn",
"(",
")",
".",
"instances",
"(",
")",
".",
"delete",
"(",
"project",
"=",
"project_id",
",",
"instance",
"=",
"i... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.get_database | Retrieves a database resource from a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param database: Name of the database in the instance.
:type database: str
:param project_id: Project ID of the project that ... | airflow/contrib/hooks/gcp_sql_hook.py | def get_database(self, instance, database, project_id=None):
"""
Retrieves a database resource from a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param database: Name of the database in the instance.
... | def get_database(self, instance, database, project_id=None):
"""
Retrieves a database resource from a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param database: Name of the database in the instance.
... | [
"Retrieves",
"a",
"database",
"resource",
"from",
"a",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L183-L202 | [
"def",
"get_database",
"(",
"self",
",",
"instance",
",",
"database",
",",
"project_id",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_conn",
"(",
")",
".",
"databases",
"(",
")",
".",
"get",
"(",
"project",
"=",
"project_id",
",",
"instance",
"="... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.create_database | Creates a new database inside a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param body: The request body, as described in
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/databases/insert#request-body... | airflow/contrib/hooks/gcp_sql_hook.py | def create_database(self, instance, body, project_id=None):
"""
Creates a new database inside a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param body: The request body, as described in
https:/... | def create_database(self, instance, body, project_id=None):
"""
Creates a new database inside a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param body: The request body, as described in
https:/... | [
"Creates",
"a",
"new",
"database",
"inside",
"a",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L205-L226 | [
"def",
"create_database",
"(",
"self",
",",
"instance",
",",
"body",
",",
"project_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_conn",
"(",
")",
".",
"databases",
"(",
")",
".",
"insert",
"(",
"project",
"=",
"project_id",
",",
"insta... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.patch_database | Updates a database resource inside a Cloud SQL instance.
This method supports patch semantics.
See https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/performance#patch.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:para... | airflow/contrib/hooks/gcp_sql_hook.py | def patch_database(self, instance, database, body, project_id=None):
"""
Updates a database resource inside a Cloud SQL instance.
This method supports patch semantics.
See https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/performance#patch.
:param instance: Database ins... | def patch_database(self, instance, database, body, project_id=None):
"""
Updates a database resource inside a Cloud SQL instance.
This method supports patch semantics.
See https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/performance#patch.
:param instance: Database ins... | [
"Updates",
"a",
"database",
"resource",
"inside",
"a",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L229-L256 | [
"def",
"patch_database",
"(",
"self",
",",
"instance",
",",
"database",
",",
"body",
",",
"project_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_conn",
"(",
")",
".",
"databases",
"(",
")",
".",
"patch",
"(",
"project",
"=",
"project_i... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.delete_database | Deletes a database from a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param database: Name of the database to be deleted in the instance.
:type database: str
:param project_id: Project ID of the project th... | airflow/contrib/hooks/gcp_sql_hook.py | def delete_database(self, instance, database, project_id=None):
"""
Deletes a database from a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param database: Name of the database to be deleted in the instance.... | def delete_database(self, instance, database, project_id=None):
"""
Deletes a database from a Cloud SQL instance.
:param instance: Database instance ID. This does not include the project ID.
:type instance: str
:param database: Name of the database to be deleted in the instance.... | [
"Deletes",
"a",
"database",
"from",
"a",
"Cloud",
"SQL",
"instance",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L259-L279 | [
"def",
"delete_database",
"(",
"self",
",",
"instance",
",",
"database",
",",
"project_id",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"get_conn",
"(",
")",
".",
"databases",
"(",
")",
".",
"delete",
"(",
"project",
"=",
"project_id",
",",
"i... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook.export_instance | Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump
or CSV file.
:param instance: Database instance ID of the Cloud SQL instance. This does not include the
project ID.
:type instance: str
:param body: The request body, as described in
h... | airflow/contrib/hooks/gcp_sql_hook.py | def export_instance(self, instance, body, project_id=None):
"""
Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump
or CSV file.
:param instance: Database instance ID of the Cloud SQL instance. This does not include the
project ID.
:type in... | def export_instance(self, instance, body, project_id=None):
"""
Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump
or CSV file.
:param instance: Database instance ID of the Cloud SQL instance. This does not include the
project ID.
:type in... | [
"Exports",
"data",
"from",
"a",
"Cloud",
"SQL",
"instance",
"to",
"a",
"Cloud",
"Storage",
"bucket",
"as",
"a",
"SQL",
"dump",
"or",
"CSV",
"file",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L282-L310 | [
"def",
"export_instance",
"(",
"self",
",",
"instance",
",",
"body",
",",
"project_id",
"=",
"None",
")",
":",
"try",
":",
"response",
"=",
"self",
".",
"get_conn",
"(",
")",
".",
"instances",
"(",
")",
".",
"export",
"(",
"project",
"=",
"project_id",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlHook._wait_for_operation_to_complete | Waits for the named operation to complete - checks status of the
asynchronous call.
:param project_id: Project ID of the project that contains the instance.
:type project_id: str
:param operation_name: Name of the operation.
:type operation_name: str
:return: None | airflow/contrib/hooks/gcp_sql_hook.py | def _wait_for_operation_to_complete(self, project_id, operation_name):
"""
Waits for the named operation to complete - checks status of the
asynchronous call.
:param project_id: Project ID of the project that contains the instance.
:type project_id: str
:param operation_... | def _wait_for_operation_to_complete(self, project_id, operation_name):
"""
Waits for the named operation to complete - checks status of the
asynchronous call.
:param project_id: Project ID of the project that contains the instance.
:type project_id: str
:param operation_... | [
"Waits",
"for",
"the",
"named",
"operation",
"to",
"complete",
"-",
"checks",
"status",
"of",
"the",
"asynchronous",
"call",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L343-L368 | [
"def",
"_wait_for_operation_to_complete",
"(",
"self",
",",
"project_id",
",",
"operation_name",
")",
":",
"service",
"=",
"self",
".",
"get_conn",
"(",
")",
"while",
"True",
":",
"operation_response",
"=",
"service",
".",
"operations",
"(",
")",
".",
"get",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlProxyRunner.start_proxy | Starts Cloud SQL Proxy.
You have to remember to stop the proxy if you started it! | airflow/contrib/hooks/gcp_sql_hook.py | def start_proxy(self):
"""
Starts Cloud SQL Proxy.
You have to remember to stop the proxy if you started it!
"""
self._download_sql_proxy_if_needed()
if self.sql_proxy_process:
raise AirflowException("The sql proxy is already running: {}".format(
... | def start_proxy(self):
"""
Starts Cloud SQL Proxy.
You have to remember to stop the proxy if you started it!
"""
self._download_sql_proxy_if_needed()
if self.sql_proxy_process:
raise AirflowException("The sql proxy is already running: {}".format(
... | [
"Starts",
"Cloud",
"SQL",
"Proxy",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L524-L565 | [
"def",
"start_proxy",
"(",
"self",
")",
":",
"self",
".",
"_download_sql_proxy_if_needed",
"(",
")",
"if",
"self",
".",
"sql_proxy_process",
":",
"raise",
"AirflowException",
"(",
"\"The sql proxy is already running: {}\"",
".",
"format",
"(",
"self",
".",
"sql_prox... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlProxyRunner.stop_proxy | Stops running proxy.
You should stop the proxy after you stop using it. | airflow/contrib/hooks/gcp_sql_hook.py | def stop_proxy(self):
"""
Stops running proxy.
You should stop the proxy after you stop using it.
"""
if not self.sql_proxy_process:
raise AirflowException("The sql proxy is not started yet")
else:
self.log.info("Stopping the cloud_sql_proxy pid: ... | def stop_proxy(self):
"""
Stops running proxy.
You should stop the proxy after you stop using it.
"""
if not self.sql_proxy_process:
raise AirflowException("The sql proxy is not started yet")
else:
self.log.info("Stopping the cloud_sql_proxy pid: ... | [
"Stops",
"running",
"proxy",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L567-L599 | [
"def",
"stop_proxy",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"sql_proxy_process",
":",
"raise",
"AirflowException",
"(",
"\"The sql proxy is not started yet\"",
")",
"else",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Stopping the cloud_sql_proxy pid: %s\... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlProxyRunner.get_proxy_version | Returns version of the Cloud SQL Proxy. | airflow/contrib/hooks/gcp_sql_hook.py | def get_proxy_version(self):
"""
Returns version of the Cloud SQL Proxy.
"""
self._download_sql_proxy_if_needed()
command_to_run = [self.sql_proxy_path]
command_to_run.extend(['--version'])
command_to_run.extend(self._get_credential_parameters())
result = ... | def get_proxy_version(self):
"""
Returns version of the Cloud SQL Proxy.
"""
self._download_sql_proxy_if_needed()
command_to_run = [self.sql_proxy_path]
command_to_run.extend(['--version'])
command_to_run.extend(self._get_credential_parameters())
result = ... | [
"Returns",
"version",
"of",
"the",
"Cloud",
"SQL",
"Proxy",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L601-L615 | [
"def",
"get_proxy_version",
"(",
"self",
")",
":",
"self",
".",
"_download_sql_proxy_if_needed",
"(",
")",
"command_to_run",
"=",
"[",
"self",
".",
"sql_proxy_path",
"]",
"command_to_run",
".",
"extend",
"(",
"[",
"'--version'",
"]",
")",
"command_to_run",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlDatabaseHook.create_connection | Create connection in the Connection table, according to whether it uses
proxy, TCP, UNIX sockets, SSL. Connection ID will be randomly generated.
:param session: Session of the SQL Alchemy ORM (automatically generated with
decorator). | airflow/contrib/hooks/gcp_sql_hook.py | def create_connection(self, session=None):
"""
Create connection in the Connection table, according to whether it uses
proxy, TCP, UNIX sockets, SSL. Connection ID will be randomly generated.
:param session: Session of the SQL Alchemy ORM (automatically generated with
... | def create_connection(self, session=None):
"""
Create connection in the Connection table, according to whether it uses
proxy, TCP, UNIX sockets, SSL. Connection ID will be randomly generated.
:param session: Session of the SQL Alchemy ORM (automatically generated with
... | [
"Create",
"connection",
"in",
"the",
"Connection",
"table",
"according",
"to",
"whether",
"it",
"uses",
"proxy",
"TCP",
"UNIX",
"sockets",
"SSL",
".",
"Connection",
"ID",
"will",
"be",
"randomly",
"generated",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L895-L908 | [
"def",
"create_connection",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"connection",
"=",
"Connection",
"(",
"conn_id",
"=",
"self",
".",
"db_conn_id",
")",
"uri",
"=",
"self",
".",
"_generate_connection_uri",
"(",
")",
"self",
".",
"log",
".",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlDatabaseHook.retrieve_connection | Retrieves the dynamically created connection from the Connection table.
:param session: Session of the SQL Alchemy ORM (automatically generated with
decorator). | airflow/contrib/hooks/gcp_sql_hook.py | def retrieve_connection(self, session=None):
"""
Retrieves the dynamically created connection from the Connection table.
:param session: Session of the SQL Alchemy ORM (automatically generated with
decorator).
"""
self.log.info("Retrieving connection %s",... | def retrieve_connection(self, session=None):
"""
Retrieves the dynamically created connection from the Connection table.
:param session: Session of the SQL Alchemy ORM (automatically generated with
decorator).
"""
self.log.info("Retrieving connection %s",... | [
"Retrieves",
"the",
"dynamically",
"created",
"connection",
"from",
"the",
"Connection",
"table",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L911-L923 | [
"def",
"retrieve_connection",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Retrieving connection %s\"",
",",
"self",
".",
"db_conn_id",
")",
"connections",
"=",
"session",
".",
"query",
"(",
"Connection",
")",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlDatabaseHook.delete_connection | Delete the dynamically created connection from the Connection table.
:param session: Session of the SQL Alchemy ORM (automatically generated with
decorator). | airflow/contrib/hooks/gcp_sql_hook.py | def delete_connection(self, session=None):
"""
Delete the dynamically created connection from the Connection table.
:param session: Session of the SQL Alchemy ORM (automatically generated with
decorator).
"""
self.log.info("Deleting connection %s", self.d... | def delete_connection(self, session=None):
"""
Delete the dynamically created connection from the Connection table.
:param session: Session of the SQL Alchemy ORM (automatically generated with
decorator).
"""
self.log.info("Deleting connection %s", self.d... | [
"Delete",
"the",
"dynamically",
"created",
"connection",
"from",
"the",
"Connection",
"table",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L926-L941 | [
"def",
"delete_connection",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Deleting connection %s\"",
",",
"self",
".",
"db_conn_id",
")",
"connections",
"=",
"session",
".",
"query",
"(",
"Connection",
")",
".... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlDatabaseHook.get_sqlproxy_runner | Retrieve Cloud SQL Proxy runner. It is used to manage the proxy
lifecycle per task.
:return: The Cloud SQL Proxy runner.
:rtype: CloudSqlProxyRunner | airflow/contrib/hooks/gcp_sql_hook.py | def get_sqlproxy_runner(self):
"""
Retrieve Cloud SQL Proxy runner. It is used to manage the proxy
lifecycle per task.
:return: The Cloud SQL Proxy runner.
:rtype: CloudSqlProxyRunner
"""
if not self.use_proxy:
raise AirflowException("Proxy runner can... | def get_sqlproxy_runner(self):
"""
Retrieve Cloud SQL Proxy runner. It is used to manage the proxy
lifecycle per task.
:return: The Cloud SQL Proxy runner.
:rtype: CloudSqlProxyRunner
"""
if not self.use_proxy:
raise AirflowException("Proxy runner can... | [
"Retrieve",
"Cloud",
"SQL",
"Proxy",
"runner",
".",
"It",
"is",
"used",
"to",
"manage",
"the",
"proxy",
"lifecycle",
"per",
"task",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L943-L959 | [
"def",
"get_sqlproxy_runner",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"use_proxy",
":",
"raise",
"AirflowException",
"(",
"\"Proxy runner can only be retrieved in case of use_proxy = True\"",
")",
"return",
"CloudSqlProxyRunner",
"(",
"path_prefix",
"=",
"self",
... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlDatabaseHook.get_database_hook | Retrieve database hook. This is the actual Postgres or MySQL database hook
that uses proxy or connects directly to the Google Cloud SQL database. | airflow/contrib/hooks/gcp_sql_hook.py | def get_database_hook(self):
"""
Retrieve database hook. This is the actual Postgres or MySQL database hook
that uses proxy or connects directly to the Google Cloud SQL database.
"""
if self.database_type == 'postgres':
self.db_hook = PostgresHook(postgres_conn_id=sel... | def get_database_hook(self):
"""
Retrieve database hook. This is the actual Postgres or MySQL database hook
that uses proxy or connects directly to the Google Cloud SQL database.
"""
if self.database_type == 'postgres':
self.db_hook = PostgresHook(postgres_conn_id=sel... | [
"Retrieve",
"database",
"hook",
".",
"This",
"is",
"the",
"actual",
"Postgres",
"or",
"MySQL",
"database",
"hook",
"that",
"uses",
"proxy",
"or",
"connects",
"directly",
"to",
"the",
"Google",
"Cloud",
"SQL",
"database",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L961-L972 | [
"def",
"get_database_hook",
"(",
"self",
")",
":",
"if",
"self",
".",
"database_type",
"==",
"'postgres'",
":",
"self",
".",
"db_hook",
"=",
"PostgresHook",
"(",
"postgres_conn_id",
"=",
"self",
".",
"db_conn_id",
",",
"schema",
"=",
"self",
".",
"database",... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlDatabaseHook.cleanup_database_hook | Clean up database hook after it was used. | airflow/contrib/hooks/gcp_sql_hook.py | def cleanup_database_hook(self):
"""
Clean up database hook after it was used.
"""
if self.database_type == 'postgres':
if hasattr(self.db_hook,
'conn') and self.db_hook.conn and self.db_hook.conn.notices:
for output in self.db_hook.conn... | def cleanup_database_hook(self):
"""
Clean up database hook after it was used.
"""
if self.database_type == 'postgres':
if hasattr(self.db_hook,
'conn') and self.db_hook.conn and self.db_hook.conn.notices:
for output in self.db_hook.conn... | [
"Clean",
"up",
"database",
"hook",
"after",
"it",
"was",
"used",
"."
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L974-L982 | [
"def",
"cleanup_database_hook",
"(",
"self",
")",
":",
"if",
"self",
".",
"database_type",
"==",
"'postgres'",
":",
"if",
"hasattr",
"(",
"self",
".",
"db_hook",
",",
"'conn'",
")",
"and",
"self",
".",
"db_hook",
".",
"conn",
"and",
"self",
".",
"db_hook... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
test | CloudSqlDatabaseHook.reserve_free_tcp_port | Reserve free TCP port to be used by Cloud SQL Proxy | airflow/contrib/hooks/gcp_sql_hook.py | def reserve_free_tcp_port(self):
"""
Reserve free TCP port to be used by Cloud SQL Proxy
"""
self.reserved_tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.reserved_tcp_socket.bind(('127.0.0.1', 0))
self.sql_proxy_tcp_port = self.reserved_tcp_socket.get... | def reserve_free_tcp_port(self):
"""
Reserve free TCP port to be used by Cloud SQL Proxy
"""
self.reserved_tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.reserved_tcp_socket.bind(('127.0.0.1', 0))
self.sql_proxy_tcp_port = self.reserved_tcp_socket.get... | [
"Reserve",
"free",
"TCP",
"port",
"to",
"be",
"used",
"by",
"Cloud",
"SQL",
"Proxy"
] | apache/airflow | python | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_sql_hook.py#L984-L990 | [
"def",
"reserve_free_tcp_port",
"(",
"self",
")",
":",
"self",
".",
"reserved_tcp_socket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"self",
".",
"reserved_tcp_socket",
".",
"bind",
"(",
"(",
"'127.0... | b69c686ad8a0c89b9136bb4b31767257eb7b2597 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.