repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
coursera-dl/coursera-dl
coursera/utils.py
fix_url
def fix_url(url): """ Strip whitespace characters from the beginning and the end of the url and add a default scheme. """ if url is None: return None url = url.strip() if url and not urlparse(url).scheme: url = "http://" + url return url
python
def fix_url(url): """ Strip whitespace characters from the beginning and the end of the url and add a default scheme. """ if url is None: return None url = url.strip() if url and not urlparse(url).scheme: url = "http://" + url return url
[ "def", "fix_url", "(", "url", ")", ":", "if", "url", "is", "None", ":", "return", "None", "url", "=", "url", ".", "strip", "(", ")", "if", "url", "and", "not", "urlparse", "(", "url", ")", ".", "scheme", ":", "url", "=", "\"http://\"", "+", "url"...
Strip whitespace characters from the beginning and the end of the url and add a default scheme.
[ "Strip", "whitespace", "characters", "from", "the", "beginning", "and", "the", "end", "of", "the", "url", "and", "add", "a", "default", "scheme", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/utils.py#L216-L229
train
Fixes the URL to be a valid URL.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/utils.py
is_course_complete
def is_course_complete(last_update): """ Determine is the course is likely to have been terminated or not. We return True if the timestamp given by last_update is 30 days or older than today's date. Otherwise, we return True. The intended use case for this is to detect if a given courses has not ...
python
def is_course_complete(last_update): """ Determine is the course is likely to have been terminated or not. We return True if the timestamp given by last_update is 30 days or older than today's date. Otherwise, we return True. The intended use case for this is to detect if a given courses has not ...
[ "def", "is_course_complete", "(", "last_update", ")", ":", "rv", "=", "False", "if", "last_update", ">=", "0", ":", "delta", "=", "time", ".", "time", "(", ")", "-", "last_update", "max_delta", "=", "total_seconds", "(", "datetime", ".", "timedelta", "(", ...
Determine is the course is likely to have been terminated or not. We return True if the timestamp given by last_update is 30 days or older than today's date. Otherwise, we return True. The intended use case for this is to detect if a given courses has not seen any update in the last 30 days or more. ...
[ "Determine", "is", "the", "course", "is", "likely", "to", "have", "been", "terminated", "or", "not", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/utils.py#L232-L249
train
Determines if a given course has been terminated or not.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/utils.py
make_coursera_absolute_url
def make_coursera_absolute_url(url): """ If given url is relative adds coursera netloc, otherwise returns it without any changes. """ if not bool(urlparse(url).netloc): return urljoin(COURSERA_URL, url) return url
python
def make_coursera_absolute_url(url): """ If given url is relative adds coursera netloc, otherwise returns it without any changes. """ if not bool(urlparse(url).netloc): return urljoin(COURSERA_URL, url) return url
[ "def", "make_coursera_absolute_url", "(", "url", ")", ":", "if", "not", "bool", "(", "urlparse", "(", "url", ")", ".", "netloc", ")", ":", "return", "urljoin", "(", "COURSERA_URL", ",", "url", ")", "return", "url" ]
If given url is relative adds coursera netloc, otherwise returns it without any changes.
[ "If", "given", "url", "is", "relative", "adds", "coursera", "netloc", "otherwise", "returns", "it", "without", "any", "changes", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/utils.py#L262-L271
train
Make coursera absolute url.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/utils.py
extend_supplement_links
def extend_supplement_links(destination, source): """ Extends (merges) destination dictionary with supplement_links from source dictionary. Values are expected to be lists, or any data structure that has `extend` method. @param destination: Destination dictionary that will be extended. @type de...
python
def extend_supplement_links(destination, source): """ Extends (merges) destination dictionary with supplement_links from source dictionary. Values are expected to be lists, or any data structure that has `extend` method. @param destination: Destination dictionary that will be extended. @type de...
[ "def", "extend_supplement_links", "(", "destination", ",", "source", ")", ":", "for", "key", ",", "value", "in", "iteritems", "(", "source", ")", ":", "if", "key", "not", "in", "destination", ":", "destination", "[", "key", "]", "=", "value", "else", ":"...
Extends (merges) destination dictionary with supplement_links from source dictionary. Values are expected to be lists, or any data structure that has `extend` method. @param destination: Destination dictionary that will be extended. @type destination: @see CourseraOnDemand._extract_links_from_text ...
[ "Extends", "(", "merges", ")", "destination", "dictionary", "with", "supplement_links", "from", "source", "dictionary", ".", "Values", "are", "expected", "to", "be", "lists", "or", "any", "data", "structure", "that", "has", "extend", "method", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/utils.py#L274-L291
train
Extends the destination dictionary with supplement_links from source dictionary.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/utils.py
print_ssl_error_message
def print_ssl_error_message(exception): """ Print SSLError message with URL to instructions on how to fix it. """ message = """ ##################################################################### # ATTENTION! PLEASE READ THIS! # # The following error has just occurred: # %s %s # # Please read instruct...
python
def print_ssl_error_message(exception): """ Print SSLError message with URL to instructions on how to fix it. """ message = """ ##################################################################### # ATTENTION! PLEASE READ THIS! # # The following error has just occurred: # %s %s # # Please read instruct...
[ "def", "print_ssl_error_message", "(", "exception", ")", ":", "message", "=", "\"\"\"\n#####################################################################\n# ATTENTION! PLEASE READ THIS!\n#\n# The following error has just occurred:\n# %s %s\n#\n# Please read instructions on how to fix this error h...
Print SSLError message with URL to instructions on how to fix it.
[ "Print", "SSLError", "message", "with", "URL", "to", "instructions", "on", "how", "to", "fix", "it", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/utils.py#L294-L309
train
Print SSLError message with URL to instructions on how to fix it.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/coursera_dl.py
list_courses
def list_courses(args): """ List enrolled courses. @param args: Command-line arguments. @type args: namedtuple """ session = get_session() login(session, args.username, args.password) extractor = CourseraExtractor(session) courses = extractor.list_courses() logging.info('Found %...
python
def list_courses(args): """ List enrolled courses. @param args: Command-line arguments. @type args: namedtuple """ session = get_session() login(session, args.username, args.password) extractor = CourseraExtractor(session) courses = extractor.list_courses() logging.info('Found %...
[ "def", "list_courses", "(", "args", ")", ":", "session", "=", "get_session", "(", ")", "login", "(", "session", ",", "args", ".", "username", ",", "args", ".", "password", ")", "extractor", "=", "CourseraExtractor", "(", "session", ")", "courses", "=", "...
List enrolled courses. @param args: Command-line arguments. @type args: namedtuple
[ "List", "enrolled", "courses", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/coursera_dl.py#L100-L113
train
List enrolled courses.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/coursera_dl.py
download_on_demand_class
def download_on_demand_class(session, args, class_name): """ Download all requested resources from the on-demand class given in class_name. @return: Tuple of (bool, bool), where the first bool indicates whether errors occurred while parsing syllabus, the second bool indicates whether th...
python
def download_on_demand_class(session, args, class_name): """ Download all requested resources from the on-demand class given in class_name. @return: Tuple of (bool, bool), where the first bool indicates whether errors occurred while parsing syllabus, the second bool indicates whether th...
[ "def", "download_on_demand_class", "(", "session", ",", "args", ",", "class_name", ")", ":", "error_occurred", "=", "False", "extractor", "=", "CourseraExtractor", "(", "session", ")", "cached_syllabus_filename", "=", "'%s-syllabus-parsed.json'", "%", "class_name", "i...
Download all requested resources from the on-demand class given in class_name. @return: Tuple of (bool, bool), where the first bool indicates whether errors occurred while parsing syllabus, the second bool indicates whether the course appears to be completed. @rtype: (bool, bool)
[ "Download", "all", "requested", "resources", "from", "the", "on", "-", "demand", "class", "given", "in", "class_name", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/coursera_dl.py#L116-L181
train
Download all requested resources from the on - demand class given in class_name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/coursera_dl.py
download_class
def download_class(session, args, class_name): """ Try to download on-demand class. @return: Tuple of (bool, bool), where the first bool indicates whether errors occurred while parsing syllabus, the second bool indicates whether the course appears to be completed. @rtype: (bool, bool) ...
python
def download_class(session, args, class_name): """ Try to download on-demand class. @return: Tuple of (bool, bool), where the first bool indicates whether errors occurred while parsing syllabus, the second bool indicates whether the course appears to be completed. @rtype: (bool, bool) ...
[ "def", "download_class", "(", "session", ",", "args", ",", "class_name", ")", ":", "logging", ".", "debug", "(", "'Downloading new style (on demand) class %s'", ",", "class_name", ")", "return", "download_on_demand_class", "(", "session", ",", "args", ",", "class_na...
Try to download on-demand class. @return: Tuple of (bool, bool), where the first bool indicates whether errors occurred while parsing syllabus, the second bool indicates whether the course appears to be completed. @rtype: (bool, bool)
[ "Try", "to", "download", "on", "-", "demand", "class", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/coursera_dl.py#L204-L214
train
Try to download on - demand class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/coursera_dl.py
main
def main(): """ Main entry point for execution as a program (instead of as a module). """ args = parse_args() logging.info('coursera_dl version %s', __version__) completed_classes = [] classes_with_errors = [] mkdir_p(PATH_CACHE, 0o700) if args.clear_cache: shutil.rmtree(PA...
python
def main(): """ Main entry point for execution as a program (instead of as a module). """ args = parse_args() logging.info('coursera_dl version %s', __version__) completed_classes = [] classes_with_errors = [] mkdir_p(PATH_CACHE, 0o700) if args.clear_cache: shutil.rmtree(PA...
[ "def", "main", "(", ")", ":", "args", "=", "parse_args", "(", ")", "logging", ".", "info", "(", "'coursera_dl version %s'", ",", "__version__", ")", "completed_classes", "=", "[", "]", "classes_with_errors", "=", "[", "]", "mkdir_p", "(", "PATH_CACHE", ",", ...
Main entry point for execution as a program (instead of as a module).
[ "Main", "entry", "point", "for", "execution", "as", "a", "program", "(", "instead", "of", "as", "a", "module", ")", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/coursera_dl.py#L217-L283
train
Main entry point for the coursera_dl script.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
prepare_auth_headers
def prepare_auth_headers(session, include_cauth=False): """ This function prepares headers with CSRF/CAUTH tokens that can be used in POST requests such as login/get_quiz. @param session: Requests session. @type session: requests.Session @param include_cauth: Flag that indicates whether CAUTH ...
python
def prepare_auth_headers(session, include_cauth=False): """ This function prepares headers with CSRF/CAUTH tokens that can be used in POST requests such as login/get_quiz. @param session: Requests session. @type session: requests.Session @param include_cauth: Flag that indicates whether CAUTH ...
[ "def", "prepare_auth_headers", "(", "session", ",", "include_cauth", "=", "False", ")", ":", "# csrftoken is simply a 20 char random string.", "csrftoken", "=", "random_string", "(", "20", ")", "# Now make a call to the authenticator url.", "csrf2cookie", "=", "'csrf2_token_%...
This function prepares headers with CSRF/CAUTH tokens that can be used in POST requests such as login/get_quiz. @param session: Requests session. @type session: requests.Session @param include_cauth: Flag that indicates whether CAUTH cookies should be included as well. @type include_cauth:...
[ "This", "function", "prepares", "headers", "with", "CSRF", "/", "CAUTH", "tokens", "that", "can", "be", "used", "in", "POST", "requests", "such", "as", "login", "/", "get_quiz", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L72-L108
train
This function prepares headers with CSRF and CAUTH tokens that can be used in POST requests such as login and get_quiz.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
login
def login(session, username, password, class_name=None): """ Login on coursera.org with the given credentials. This adds the following cookies to the session: sessionid, maestro_login, maestro_login_flag """ logging.debug('Initiating login.') try: session.cookies.clear('.course...
python
def login(session, username, password, class_name=None): """ Login on coursera.org with the given credentials. This adds the following cookies to the session: sessionid, maestro_login, maestro_login_flag """ logging.debug('Initiating login.') try: session.cookies.clear('.course...
[ "def", "login", "(", "session", ",", "username", ",", "password", ",", "class_name", "=", "None", ")", ":", "logging", ".", "debug", "(", "'Initiating login.'", ")", "try", ":", "session", ".", "cookies", ".", "clear", "(", "'.coursera.org'", ")", "logging...
Login on coursera.org with the given credentials. This adds the following cookies to the session: sessionid, maestro_login, maestro_login_flag
[ "Login", "on", "coursera", ".", "org", "with", "the", "given", "credentials", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L111-L157
train
Login on coursera. org with the given credentials.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
down_the_wabbit_hole
def down_the_wabbit_hole(session, class_name): """ Authenticate on class.coursera.org """ auth_redirector_url = AUTH_REDIRECT_URL.format(class_name=class_name) r = session.get(auth_redirector_url) logging.debug('Following %s to authenticate on class.coursera.org.', auth_redir...
python
def down_the_wabbit_hole(session, class_name): """ Authenticate on class.coursera.org """ auth_redirector_url = AUTH_REDIRECT_URL.format(class_name=class_name) r = session.get(auth_redirector_url) logging.debug('Following %s to authenticate on class.coursera.org.', auth_redir...
[ "def", "down_the_wabbit_hole", "(", "session", ",", "class_name", ")", ":", "auth_redirector_url", "=", "AUTH_REDIRECT_URL", ".", "format", "(", "class_name", "=", "class_name", ")", "r", "=", "session", ".", "get", "(", "auth_redirector_url", ")", "logging", "....
Authenticate on class.coursera.org
[ "Authenticate", "on", "class", ".", "coursera", ".", "org" ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L160-L177
train
Authenticate on class. coursera. org and return the object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
get_authentication_cookies
def get_authentication_cookies(session, class_name, username, password): """ Get the necessary cookies to authenticate on class.coursera.org. To access the class pages we need two cookies on class.coursera.org: csrf_token, session """ # First, check if we already have the .coursera.org coo...
python
def get_authentication_cookies(session, class_name, username, password): """ Get the necessary cookies to authenticate on class.coursera.org. To access the class pages we need two cookies on class.coursera.org: csrf_token, session """ # First, check if we already have the .coursera.org coo...
[ "def", "get_authentication_cookies", "(", "session", ",", "class_name", ",", "username", ",", "password", ")", ":", "# First, check if we already have the .coursera.org cookies.", "if", "session", ".", "cookies", ".", "get", "(", "'CAUTH'", ",", "domain", "=", "\".cou...
Get the necessary cookies to authenticate on class.coursera.org. To access the class pages we need two cookies on class.coursera.org: csrf_token, session
[ "Get", "the", "necessary", "cookies", "to", "authenticate", "on", "class", ".", "coursera", ".", "org", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L180-L206
train
Get the necessary cookies to authenticate on class. coursera. org.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
do_we_have_enough_cookies
def do_we_have_enough_cookies(cj, class_name): """ Check whether we have all the required cookies to authenticate on class.coursera.org. """ domain = 'class.coursera.org' path = "/" + class_name return cj.get('csrf_token', domain=domain, path=path) is not None
python
def do_we_have_enough_cookies(cj, class_name): """ Check whether we have all the required cookies to authenticate on class.coursera.org. """ domain = 'class.coursera.org' path = "/" + class_name return cj.get('csrf_token', domain=domain, path=path) is not None
[ "def", "do_we_have_enough_cookies", "(", "cj", ",", "class_name", ")", ":", "domain", "=", "'class.coursera.org'", "path", "=", "\"/\"", "+", "class_name", "return", "cj", ".", "get", "(", "'csrf_token'", ",", "domain", "=", "domain", ",", "path", "=", "path...
Check whether we have all the required cookies to authenticate on class.coursera.org.
[ "Check", "whether", "we", "have", "all", "the", "required", "cookies", "to", "authenticate", "on", "class", ".", "coursera", ".", "org", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L209-L217
train
Check whether we have enough cookies to authenticate on class. coursera. org.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
validate_cookies
def validate_cookies(session, class_name): """ Checks whether we have all the required cookies to authenticate on class.coursera.org. Also check for and remove stale session. """ if not do_we_have_enough_cookies(session.cookies, class_name): return False url = CLASS_URL.format(class...
python
def validate_cookies(session, class_name): """ Checks whether we have all the required cookies to authenticate on class.coursera.org. Also check for and remove stale session. """ if not do_we_have_enough_cookies(session.cookies, class_name): return False url = CLASS_URL.format(class...
[ "def", "validate_cookies", "(", "session", ",", "class_name", ")", ":", "if", "not", "do_we_have_enough_cookies", "(", "session", ".", "cookies", ",", "class_name", ")", ":", "return", "False", "url", "=", "CLASS_URL", ".", "format", "(", "class_name", "=", ...
Checks whether we have all the required cookies to authenticate on class.coursera.org. Also check for and remove stale session.
[ "Checks", "whether", "we", "have", "all", "the", "required", "cookies", "to", "authenticate", "on", "class", ".", "coursera", ".", "org", ".", "Also", "check", "for", "and", "remove", "stale", "session", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L220-L240
train
Checks whether we have all the required cookies on class. coursera. org.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
make_cookie_values
def make_cookie_values(cj, class_name): """ Makes a string of cookie keys and values. Can be used to set a Cookie header. """ path = "/" + class_name cookies = [c.name + '=' + c.value for c in cj if c.domain == "class.coursera.org" and c.path == path...
python
def make_cookie_values(cj, class_name): """ Makes a string of cookie keys and values. Can be used to set a Cookie header. """ path = "/" + class_name cookies = [c.name + '=' + c.value for c in cj if c.domain == "class.coursera.org" and c.path == path...
[ "def", "make_cookie_values", "(", "cj", ",", "class_name", ")", ":", "path", "=", "\"/\"", "+", "class_name", "cookies", "=", "[", "c", ".", "name", "+", "'='", "+", "c", ".", "value", "for", "c", "in", "cj", "if", "c", ".", "domain", "==", "\"clas...
Makes a string of cookie keys and values. Can be used to set a Cookie header.
[ "Makes", "a", "string", "of", "cookie", "keys", "and", "values", ".", "Can", "be", "used", "to", "set", "a", "Cookie", "header", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L243-L255
train
Makes a string of cookie keys and values.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
find_cookies_for_class
def find_cookies_for_class(cookies_file, class_name): """ Return a RequestsCookieJar containing the cookies for .coursera.org and class.coursera.org found in the given cookies_file. """ path = "/" + class_name def cookies_filter(c): return c.domain == ".coursera.org" \ or (...
python
def find_cookies_for_class(cookies_file, class_name): """ Return a RequestsCookieJar containing the cookies for .coursera.org and class.coursera.org found in the given cookies_file. """ path = "/" + class_name def cookies_filter(c): return c.domain == ".coursera.org" \ or (...
[ "def", "find_cookies_for_class", "(", "cookies_file", ",", "class_name", ")", ":", "path", "=", "\"/\"", "+", "class_name", "def", "cookies_filter", "(", "c", ")", ":", "return", "c", ".", "domain", "==", "\".coursera.org\"", "or", "(", "c", ".", "domain", ...
Return a RequestsCookieJar containing the cookies for .coursera.org and class.coursera.org found in the given cookies_file.
[ "Return", "a", "RequestsCookieJar", "containing", "the", "cookies", "for", ".", "coursera", ".", "org", "and", "class", ".", "coursera", ".", "org", "found", "in", "the", "given", "cookies_file", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L258-L276
train
Find the cookies for the given class. coursera. org and return a RequestsCookieJar containing the cookies for the given class. coursera. org and class. coursera. org.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
load_cookies_file
def load_cookies_file(cookies_file): """ Load cookies file. We pre-pend the file with the special Netscape header because the cookie loader is very particular about this string. """ logging.debug('Loading cookie file %s into memory.', cookies_file) cookies = StringIO() cookies.write('...
python
def load_cookies_file(cookies_file): """ Load cookies file. We pre-pend the file with the special Netscape header because the cookie loader is very particular about this string. """ logging.debug('Loading cookie file %s into memory.', cookies_file) cookies = StringIO() cookies.write('...
[ "def", "load_cookies_file", "(", "cookies_file", ")", ":", "logging", ".", "debug", "(", "'Loading cookie file %s into memory.'", ",", "cookies_file", ")", "cookies", "=", "StringIO", "(", ")", "cookies", ".", "write", "(", "'# Netscape HTTP Cookie File'", ")", "coo...
Load cookies file. We pre-pend the file with the special Netscape header because the cookie loader is very particular about this string.
[ "Load", "cookies", "file", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L279-L294
train
Load cookies file into memory.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
get_cookies_from_cache
def get_cookies_from_cache(username): """ Returns a RequestsCookieJar containing the cached cookies for the given user. """ logging.debug('Trying to get cookies from the cache.') path = get_cookies_cache_path(username) cj = requests.cookies.RequestsCookieJar() try: cached_cj = ...
python
def get_cookies_from_cache(username): """ Returns a RequestsCookieJar containing the cached cookies for the given user. """ logging.debug('Trying to get cookies from the cache.') path = get_cookies_cache_path(username) cj = requests.cookies.RequestsCookieJar() try: cached_cj = ...
[ "def", "get_cookies_from_cache", "(", "username", ")", ":", "logging", ".", "debug", "(", "'Trying to get cookies from the cache.'", ")", "path", "=", "get_cookies_cache_path", "(", "username", ")", "cj", "=", "requests", ".", "cookies", ".", "RequestsCookieJar", "(...
Returns a RequestsCookieJar containing the cached cookies for the given user.
[ "Returns", "a", "RequestsCookieJar", "containing", "the", "cached", "cookies", "for", "the", "given", "user", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L313-L332
train
Returns a RequestsCookieJar containing the cached cookies for the given username.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
write_cookies_to_cache
def write_cookies_to_cache(cj, username): """ Save RequestsCookieJar to disk in Mozilla's cookies.txt file format. This prevents us from repeated authentications on the accounts.coursera.org and class.coursera.org/class_name sites. """ mkdir_p(PATH_COOKIES, 0o700) path = get_cookies_cache_p...
python
def write_cookies_to_cache(cj, username): """ Save RequestsCookieJar to disk in Mozilla's cookies.txt file format. This prevents us from repeated authentications on the accounts.coursera.org and class.coursera.org/class_name sites. """ mkdir_p(PATH_COOKIES, 0o700) path = get_cookies_cache_p...
[ "def", "write_cookies_to_cache", "(", "cj", ",", "username", ")", ":", "mkdir_p", "(", "PATH_COOKIES", ",", "0o700", ")", "path", "=", "get_cookies_cache_path", "(", "username", ")", "cached_cj", "=", "cookielib", ".", "MozillaCookieJar", "(", ")", "for", "coo...
Save RequestsCookieJar to disk in Mozilla's cookies.txt file format. This prevents us from repeated authentications on the accounts.coursera.org and class.coursera.org/class_name sites.
[ "Save", "RequestsCookieJar", "to", "disk", "in", "Mozilla", "s", "cookies", ".", "txt", "file", "format", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L335-L347
train
Writes the cookies. txt file to disk in Mozilla s cookies. txt file format.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/cookies.py
get_cookies_for_class
def get_cookies_for_class(session, class_name, cookies_file=None, username=None, password=None): """ Get the cookies for the given class. We do not validate the cookies if they are loaded from a cookies file because this is i...
python
def get_cookies_for_class(session, class_name, cookies_file=None, username=None, password=None): """ Get the cookies for the given class. We do not validate the cookies if they are loaded from a cookies file because this is i...
[ "def", "get_cookies_for_class", "(", "session", ",", "class_name", ",", "cookies_file", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "cookies_file", ":", "cookies", "=", "find_cookies_for_class", "(", "cookies_file", ...
Get the cookies for the given class. We do not validate the cookies if they are loaded from a cookies file because this is intended for debugging purposes or if the coursera authentication process has changed.
[ "Get", "the", "cookies", "for", "the", "given", "class", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/cookies.py#L350-L372
train
Get the cookies for the given class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/network.py
get_reply
def get_reply(session, url, post=False, data=None, headers=None, quiet=False): """ Download an HTML page using the requests session. Low-level function that allows for flexible request configuration. @param session: Requests session. @type session: requests.Session @param url: URL pattern with...
python
def get_reply(session, url, post=False, data=None, headers=None, quiet=False): """ Download an HTML page using the requests session. Low-level function that allows for flexible request configuration. @param session: Requests session. @type session: requests.Session @param url: URL pattern with...
[ "def", "get_reply", "(", "session", ",", "url", ",", "post", "=", "False", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "quiet", "=", "False", ")", ":", "request_headers", "=", "{", "}", "if", "headers", "is", "None", "else", "headers"...
Download an HTML page using the requests session. Low-level function that allows for flexible request configuration. @param session: Requests session. @type session: requests.Session @param url: URL pattern with optional keywords to format. @type url: str @param post: Flag that indicates whet...
[ "Download", "an", "HTML", "page", "using", "the", "requests", "session", ".", "Low", "-", "level", "function", "that", "allows", "for", "flexible", "request", "configuration", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/network.py#L12-L58
train
Download an HTML page using requests. Session and return the response.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/network.py
get_page
def get_page(session, url, json=False, post=False, data=None, headers=None, quiet=False, **kwargs): """ Download an HTML page using the requests session. @param session: Requests session. @type session: requests....
python
def get_page(session, url, json=False, post=False, data=None, headers=None, quiet=False, **kwargs): """ Download an HTML page using the requests session. @param session: Requests session. @type session: requests....
[ "def", "get_page", "(", "session", ",", "url", ",", "json", "=", "False", ",", "post", "=", "False", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "quiet", "=", "False", ",", "*", "*", "kwargs", ")", ":", "url", "=", "url", ".", "...
Download an HTML page using the requests session. @param session: Requests session. @type session: requests.Session @param url: URL pattern with optional keywords to format. @type url: str @param post: Flag that indicates whether POST request should be sent. @type post: bool @param data:...
[ "Download", "an", "HTML", "page", "using", "the", "requests", "session", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/network.py#L61-L93
train
Download an HTML page using the requests library.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/network.py
get_page_and_url
def get_page_and_url(session, url): """ Download an HTML page using the requests session and return the final URL after following redirects. """ reply = get_reply(session, url) return reply.text, reply.url
python
def get_page_and_url(session, url): """ Download an HTML page using the requests session and return the final URL after following redirects. """ reply = get_reply(session, url) return reply.text, reply.url
[ "def", "get_page_and_url", "(", "session", ",", "url", ")", ":", "reply", "=", "get_reply", "(", "session", ",", "url", ")", "return", "reply", ".", "text", ",", "reply", ".", "url" ]
Download an HTML page using the requests session and return the final URL after following redirects.
[ "Download", "an", "HTML", "page", "using", "the", "requests", "session", "and", "return", "the", "final", "URL", "after", "following", "redirects", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/network.py#L96-L102
train
Download an HTML page using requests session and return the final URL after following redirects.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/filtering.py
skip_format_url
def skip_format_url(format_, url): """ Checks whether a give format/url should be skipped and not downloaded. @param format_: Filename format (extension). @type format_: str (e.g. html, txt, zip, pdf) @param url: URL. @type url: str @return: True if format/url should be skipped, False oth...
python
def skip_format_url(format_, url): """ Checks whether a give format/url should be skipped and not downloaded. @param format_: Filename format (extension). @type format_: str (e.g. html, txt, zip, pdf) @param url: URL. @type url: str @return: True if format/url should be skipped, False oth...
[ "def", "skip_format_url", "(", "format_", ",", "url", ")", ":", "# Do not download empty formats", "if", "format_", "==", "''", ":", "return", "True", "# Do not download email addresses", "if", "(", "'mailto:'", "in", "url", ")", "and", "(", "'@'", "in", "url", ...
Checks whether a give format/url should be skipped and not downloaded. @param format_: Filename format (extension). @type format_: str (e.g. html, txt, zip, pdf) @param url: URL. @type url: str @return: True if format/url should be skipped, False otherwise. @rtype bool
[ "Checks", "whether", "a", "give", "format", "/", "url", "should", "be", "skipped", "and", "not", "downloaded", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/filtering.py#L41-L81
train
Checks whether a give format or url should be skipped and not downloaded.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/filtering.py
find_resources_to_get
def find_resources_to_get(lecture, file_formats, resource_filter, ignored_formats=None): """ Select formats to download. """ resources_to_get = [] if ignored_formats is None: ignored_formats = [] if len(ignored_formats): logging.info("The following file formats will be ignored:...
python
def find_resources_to_get(lecture, file_formats, resource_filter, ignored_formats=None): """ Select formats to download. """ resources_to_get = [] if ignored_formats is None: ignored_formats = [] if len(ignored_formats): logging.info("The following file formats will be ignored:...
[ "def", "find_resources_to_get", "(", "lecture", ",", "file_formats", ",", "resource_filter", ",", "ignored_formats", "=", "None", ")", ":", "resources_to_get", "=", "[", "]", "if", "ignored_formats", "is", "None", ":", "ignored_formats", "=", "[", "]", "if", "...
Select formats to download.
[ "Select", "formats", "to", "download", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/filtering.py#L84-L117
train
Find resources to download.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
setup.py
generate_readme_rst
def generate_readme_rst(): """ Generate README.rst from README.md via pandoc. In case of errors, we show a message having the error that we got and exit the program. """ pandoc_cmd = [ 'pandoc', '--from=markdown', '--to=rst', '--output=README.rst', 'READ...
python
def generate_readme_rst(): """ Generate README.rst from README.md via pandoc. In case of errors, we show a message having the error that we got and exit the program. """ pandoc_cmd = [ 'pandoc', '--from=markdown', '--to=rst', '--output=README.rst', 'READ...
[ "def", "generate_readme_rst", "(", ")", ":", "pandoc_cmd", "=", "[", "'pandoc'", ",", "'--from=markdown'", ",", "'--to=rst'", ",", "'--output=README.rst'", ",", "'README.md'", "]", "if", "os", ".", "path", ".", "exists", "(", "'README.rst'", ")", ":", "return"...
Generate README.rst from README.md via pandoc. In case of errors, we show a message having the error that we got and exit the program.
[ "Generate", "README", ".", "rst", "from", "README", ".", "md", "via", "pandoc", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/setup.py#L21-L43
train
Generate README. rst from README. md via pandoc.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
setup.py
read_file
def read_file(filename, alt=None): """ Read the contents of filename or give an alternative result instead. """ lines = None try: with open(filename, encoding='utf-8') as f: lines = f.read() except IOError: lines = [] if alt is None else alt return lines
python
def read_file(filename, alt=None): """ Read the contents of filename or give an alternative result instead. """ lines = None try: with open(filename, encoding='utf-8') as f: lines = f.read() except IOError: lines = [] if alt is None else alt return lines
[ "def", "read_file", "(", "filename", ",", "alt", "=", "None", ")", ":", "lines", "=", "None", "try", ":", "with", "open", "(", "filename", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "lines", "=", "f", ".", "read", "(", ")", "except", "...
Read the contents of filename or give an alternative result instead.
[ "Read", "the", "contents", "of", "filename", "or", "give", "an", "alternative", "result", "instead", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/setup.py#L46-L57
train
Read the contents of filename or give an alternative result instead.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
fabfile.py
release_check
def release_check(): """Check if there is a Git tag already in place""" tags = local("git tag", capture=True) tags = set(tags.splitlines()) if env.version in tags: raise Exception("Already released v. %r" % env.version)
python
def release_check(): """Check if there is a Git tag already in place""" tags = local("git tag", capture=True) tags = set(tags.splitlines()) if env.version in tags: raise Exception("Already released v. %r" % env.version)
[ "def", "release_check", "(", ")", ":", "tags", "=", "local", "(", "\"git tag\"", ",", "capture", "=", "True", ")", "tags", "=", "set", "(", "tags", ".", "splitlines", "(", ")", ")", "if", "env", ".", "version", "in", "tags", ":", "raise", "Exception"...
Check if there is a Git tag already in place
[ "Check", "if", "there", "is", "a", "Git", "tag", "already", "in", "place" ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/fabfile.py#L75-L80
train
Check if there is a Git tag already in place
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
fabfile.py
release
def release(): """Release a new version""" release_check() build() print("Releasing %s version %s." % (env.projname, env.version)) local("git tag %s" % env.version) local('gpg --detach-sign --armor dist/coursera-*.tar.gz*') local('twine upload dist/coursera-*.tar.gz*') local("git push") ...
python
def release(): """Release a new version""" release_check() build() print("Releasing %s version %s." % (env.projname, env.version)) local("git tag %s" % env.version) local('gpg --detach-sign --armor dist/coursera-*.tar.gz*') local('twine upload dist/coursera-*.tar.gz*') local("git push") ...
[ "def", "release", "(", ")", ":", "release_check", "(", ")", "build", "(", ")", "print", "(", "\"Releasing %s version %s.\"", "%", "(", "env", ".", "projname", ",", "env", ".", "version", ")", ")", "local", "(", "\"git tag %s\"", "%", "env", ".", "version...
Release a new version
[ "Release", "a", "new", "version" ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/fabfile.py#L84-L93
train
Release a new version
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
expand_specializations
def expand_specializations(session, class_names): """ Checks whether any given name is not a class but a specialization. If it's a specialization, expand the list of class names with the child class names. """ result = [] for class_name in class_names: specialization = Specializatio...
python
def expand_specializations(session, class_names): """ Checks whether any given name is not a class but a specialization. If it's a specialization, expand the list of class names with the child class names. """ result = [] for class_name in class_names: specialization = Specializatio...
[ "def", "expand_specializations", "(", "session", ",", "class_names", ")", ":", "result", "=", "[", "]", "for", "class_name", "in", "class_names", ":", "specialization", "=", "SpecializationV1", ".", "create", "(", "session", ",", "class_name", ")", "if", "spec...
Checks whether any given name is not a class but a specialization. If it's a specialization, expand the list of class names with the child class names.
[ "Checks", "whether", "any", "given", "name", "is", "not", "a", "class", "but", "a", "specialization", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L545-L563
train
Expand the list of class names with the child classes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
MarkupToHTMLConverter._convert_markup_basic
def _convert_markup_basic(self, soup): """ Perform basic conversion of instructions markup. This includes replacement of several textual markup tags with their HTML equivalents. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup """ # Inject meta char...
python
def _convert_markup_basic(self, soup): """ Perform basic conversion of instructions markup. This includes replacement of several textual markup tags with their HTML equivalents. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup """ # Inject meta char...
[ "def", "_convert_markup_basic", "(", "self", ",", "soup", ")", ":", "# Inject meta charset tag", "meta", "=", "soup", ".", "new_tag", "(", "'meta'", ",", "charset", "=", "'UTF-8'", ")", "soup", ".", "insert", "(", "0", ",", "meta", ")", "# 1. Inject basic CS...
Perform basic conversion of instructions markup. This includes replacement of several textual markup tags with their HTML equivalents. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup
[ "Perform", "basic", "conversion", "of", "instructions", "markup", ".", "This", "includes", "replacement", "of", "several", "textual", "markup", "tags", "with", "their", "HTML", "equivalents", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L186-L223
train
Perform basic conversion of markup. This includes the basic CSS style of several textual markup tags with their HTML equivalents.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
MarkupToHTMLConverter._convert_markup_images
def _convert_markup_images(self, soup): """ Convert images of instructions markup. Images are downloaded, base64-encoded and inserted into <img> tags. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup """ # 6. Replace <img> assets with actual image c...
python
def _convert_markup_images(self, soup): """ Convert images of instructions markup. Images are downloaded, base64-encoded and inserted into <img> tags. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup """ # 6. Replace <img> assets with actual image c...
[ "def", "_convert_markup_images", "(", "self", ",", "soup", ")", ":", "# 6. Replace <img> assets with actual image contents", "images", "=", "[", "image", "for", "image", "in", "soup", ".", "find_all", "(", "'img'", ")", "if", "image", ".", "attrs", ".", "get", ...
Convert images of instructions markup. Images are downloaded, base64-encoded and inserted into <img> tags. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup
[ "Convert", "images", "of", "instructions", "markup", ".", "Images", "are", "downloaded", "base64", "-", "encoded", "and", "inserted", "into", "<img", ">", "tags", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L225-L249
train
Convert images of instructions markup. Images are downloaded base64 - encoded and inserted into <img > tags.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
MarkupToHTMLConverter._convert_markup_audios
def _convert_markup_audios(self, soup): """ Convert audios of instructions markup. Audios are downloaded, base64-encoded and inserted as <audio controls> <source> tag. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup """ # 7. Replace <asset> audio a...
python
def _convert_markup_audios(self, soup): """ Convert audios of instructions markup. Audios are downloaded, base64-encoded and inserted as <audio controls> <source> tag. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup """ # 7. Replace <asset> audio a...
[ "def", "_convert_markup_audios", "(", "self", ",", "soup", ")", ":", "# 7. Replace <asset> audio assets with actual audio contents", "audios", "=", "[", "audio", "for", "audio", "in", "soup", ".", "find_all", "(", "'asset'", ")", "if", "audio", ".", "attrs", ".", ...
Convert audios of instructions markup. Audios are downloaded, base64-encoded and inserted as <audio controls> <source> tag. @param soup: BeautifulSoup instance. @type soup: BeautifulSoup
[ "Convert", "audios", "of", "instructions", "markup", ".", "Audios", "are", "downloaded", "base64", "-", "encoded", "and", "inserted", "as", "<audio", "controls", ">", "<source", ">", "tag", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L251-L284
train
Convert audios of instructions markup. Audios are downloaded base64 - encoded and inserted as audio controls.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
OnDemandCourseMaterialItemsV1.create
def create(session, course_name): """ Create an instance using a session and a course_name. @param session: Requests session. @type session: requests.Session @param course_name: Course name (slug) from course json. @type course_name: str @return: Instance of On...
python
def create(session, course_name): """ Create an instance using a session and a course_name. @param session: Requests session. @type session: requests.Session @param course_name: Course name (slug) from course json. @type course_name: str @return: Instance of On...
[ "def", "create", "(", "session", ",", "course_name", ")", ":", "dom", "=", "get_page", "(", "session", ",", "OPENCOURSE_ONDEMAND_COURSE_MATERIALS", ",", "json", "=", "True", ",", "class_name", "=", "course_name", ")", "return", "OnDemandCourseMaterialItemsV1", "("...
Create an instance using a session and a course_name. @param session: Requests session. @type session: requests.Session @param course_name: Course name (slug) from course json. @type course_name: str @return: Instance of OnDemandCourseMaterialItems @rtype: OnDemandCour...
[ "Create", "an", "instance", "using", "a", "session", "and", "a", "course_name", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L304-L322
train
Create an instance of OnDemandCourseMaterialItemsV1 from a session and a course_name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand.list_courses
def list_courses(self): """ List enrolled courses. @return: List of enrolled courses. @rtype: [str] """ reply = get_page(self._session, OPENCOURSE_MEMBERSHIPS, json=True) course_list = reply['linked']['courses.v1'] slugs = [element['slug'] for element in ...
python
def list_courses(self): """ List enrolled courses. @return: List of enrolled courses. @rtype: [str] """ reply = get_page(self._session, OPENCOURSE_MEMBERSHIPS, json=True) course_list = reply['linked']['courses.v1'] slugs = [element['slug'] for element in ...
[ "def", "list_courses", "(", "self", ")", ":", "reply", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_MEMBERSHIPS", ",", "json", "=", "True", ")", "course_list", "=", "reply", "[", "'linked'", "]", "[", "'courses.v1'", "]", "slugs", "=", ...
List enrolled courses. @return: List of enrolled courses. @rtype: [str]
[ "List", "enrolled", "courses", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L628-L638
train
List enrolled courses.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand.extract_links_from_lecture
def extract_links_from_lecture(self, course_id, video_id, subtitle_language='en', resolution='540p'): """ Return the download URLs of on-demand course video. @param video_id: Video ID. @type video_id: str @pa...
python
def extract_links_from_lecture(self, course_id, video_id, subtitle_language='en', resolution='540p'): """ Return the download URLs of on-demand course video. @param video_id: Video ID. @type video_id: str @pa...
[ "def", "extract_links_from_lecture", "(", "self", ",", "course_id", ",", "video_id", ",", "subtitle_language", "=", "'en'", ",", "resolution", "=", "'540p'", ")", ":", "try", ":", "links", "=", "self", ".", "_extract_videos_and_subtitles_from_lecture", "(", "cours...
Return the download URLs of on-demand course video. @param video_id: Video ID. @type video_id: str @param subtitle_language: Subtitle language. @type subtitle_language: str @param resolution: Preferred video resolution. @type resolution: str @return: @see Cour...
[ "Return", "the", "download", "URLs", "of", "on", "-", "demand", "course", "video", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L863-L896
train
Extract the URLs of on - demand course video from lecture.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._get_lecture_asset_ids
def _get_lecture_asset_ids(self, course_id, video_id): """ Obtain a list of asset ids from a lecture. """ dom = get_page(self._session, OPENCOURSE_ONDEMAND_LECTURE_ASSETS_URL, json=True, course_id=course_id, video_id=video_id) # Note that we extract here "i...
python
def _get_lecture_asset_ids(self, course_id, video_id): """ Obtain a list of asset ids from a lecture. """ dom = get_page(self._session, OPENCOURSE_ONDEMAND_LECTURE_ASSETS_URL, json=True, course_id=course_id, video_id=video_id) # Note that we extract here "i...
[ "def", "_get_lecture_asset_ids", "(", "self", ",", "course_id", ",", "video_id", ")", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_ONDEMAND_LECTURE_ASSETS_URL", ",", "json", "=", "True", ",", "course_id", "=", "course_id", ",", "...
Obtain a list of asset ids from a lecture.
[ "Obtain", "a", "list", "of", "asset", "ids", "from", "a", "lecture", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L898-L907
train
Obtain a list of asset ids from a lecture.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._normalize_assets
def _normalize_assets(self, assets): """ Perform asset normalization. For some reason, assets that are sometimes present in lectures, have "@1" at the end of their id. Such "uncut" asset id when fed to OPENCOURSE_ASSETS_URL results in error that says: "Routing error: 'get-all' no...
python
def _normalize_assets(self, assets): """ Perform asset normalization. For some reason, assets that are sometimes present in lectures, have "@1" at the end of their id. Such "uncut" asset id when fed to OPENCOURSE_ASSETS_URL results in error that says: "Routing error: 'get-all' no...
[ "def", "_normalize_assets", "(", "self", ",", "assets", ")", ":", "new_assets", "=", "[", "]", "for", "asset", "in", "assets", ":", "# For example: giAxucdaEeWJTQ5WTi8YJQ@1", "if", "len", "(", "asset", ")", "==", "24", ":", "# Turn it into: giAxucdaEeWJTQ5WTi8YJQ"...
Perform asset normalization. For some reason, assets that are sometimes present in lectures, have "@1" at the end of their id. Such "uncut" asset id when fed to OPENCOURSE_ASSETS_URL results in error that says: "Routing error: 'get-all' not implemented". To avoid that, the last two chara...
[ "Perform", "asset", "normalization", ".", "For", "some", "reason", "assets", "that", "are", "sometimes", "present", "in", "lectures", "have", "@1", "at", "the", "end", "of", "their", "id", ".", "Such", "uncut", "asset", "id", "when", "fed", "to", "OPENCOUR...
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L909-L933
train
Normalizes the list of asset ids to be consistent with the openCOURSE_ASSETS_URL.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_links_from_lecture_assets
def _extract_links_from_lecture_assets(self, asset_ids): """ Extract links to files of the asset ids. @param asset_ids: List of asset ids. @type asset_ids: [str] @return: @see CourseraOnDemand._extract_links_from_text """ links = {} def _add_asset(name,...
python
def _extract_links_from_lecture_assets(self, asset_ids): """ Extract links to files of the asset ids. @param asset_ids: List of asset ids. @type asset_ids: [str] @return: @see CourseraOnDemand._extract_links_from_text """ links = {} def _add_asset(name,...
[ "def", "_extract_links_from_lecture_assets", "(", "self", ",", "asset_ids", ")", ":", "links", "=", "{", "}", "def", "_add_asset", "(", "name", ",", "url", ",", "destination", ")", ":", "filename", ",", "extension", "=", "os", ".", "path", ".", "splitext",...
Extract links to files of the asset ids. @param asset_ids: List of asset ids. @type asset_ids: [str] @return: @see CourseraOnDemand._extract_links_from_text
[ "Extract", "links", "to", "files", "of", "the", "asset", "ids", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L935-L967
train
Extract links to files of the asset ids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._get_asset_urls
def _get_asset_urls(self, asset_id): """ Get list of asset urls and file names. This method may internally use AssetRetriever to extract `asset` element types. @param asset_id: Asset ID. @type asset_id: str @return List of dictionaries with asset file names and urls. ...
python
def _get_asset_urls(self, asset_id): """ Get list of asset urls and file names. This method may internally use AssetRetriever to extract `asset` element types. @param asset_id: Asset ID. @type asset_id: str @return List of dictionaries with asset file names and urls. ...
[ "def", "_get_asset_urls", "(", "self", ",", "asset_id", ")", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_ASSETS_URL", ",", "json", "=", "True", ",", "id", "=", "asset_id", ")", "logging", ".", "debug", "(", "'Parsing JSON fo...
Get list of asset urls and file names. This method may internally use AssetRetriever to extract `asset` element types. @param asset_id: Asset ID. @type asset_id: str @return List of dictionaries with asset file names and urls. @rtype [{ 'name': '<filename.ext>' ...
[ "Get", "list", "of", "asset", "urls", "and", "file", "names", ".", "This", "method", "may", "internally", "use", "AssetRetriever", "to", "extract", "asset", "element", "types", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L969-L1029
train
Get list of asset file names and urls. This method may internally be used by AssetRetriever to extract asset element types.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand.extract_links_from_peer_assignment
def extract_links_from_peer_assignment(self, element_id): """ Return a dictionary with links to supplement files (pdf, csv, zip, ipynb, html and so on) extracted from peer assignment. @param element_id: Element ID to extract files from. @type element_id: str @return: @s...
python
def extract_links_from_peer_assignment(self, element_id): """ Return a dictionary with links to supplement files (pdf, csv, zip, ipynb, html and so on) extracted from peer assignment. @param element_id: Element ID to extract files from. @type element_id: str @return: @s...
[ "def", "extract_links_from_peer_assignment", "(", "self", ",", "element_id", ")", ":", "logging", ".", "debug", "(", "'Gathering supplement URLs for element_id <%s>.'", ",", "element_id", ")", "try", ":", "# Assignment text (instructions) contains asset tags which describe", "#...
Return a dictionary with links to supplement files (pdf, csv, zip, ipynb, html and so on) extracted from peer assignment. @param element_id: Element ID to extract files from. @type element_id: str @return: @see CourseraOnDemand._extract_links_from_text
[ "Return", "a", "dictionary", "with", "links", "to", "supplement", "files", "(", "pdf", "csv", "zip", "ipynb", "html", "and", "so", "on", ")", "extracted", "from", "peer", "assignment", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1204-L1236
train
Extract links to supplementary files from peer assignment text.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand.extract_links_from_supplement
def extract_links_from_supplement(self, element_id): """ Return a dictionary with supplement files (pdf, csv, zip, ipynb, html and so on) extracted from supplement page. @return: @see CourseraOnDemand._extract_links_from_text """ logging.debug( 'Gathering sup...
python
def extract_links_from_supplement(self, element_id): """ Return a dictionary with supplement files (pdf, csv, zip, ipynb, html and so on) extracted from supplement page. @return: @see CourseraOnDemand._extract_links_from_text """ logging.debug( 'Gathering sup...
[ "def", "extract_links_from_supplement", "(", "self", ",", "element_id", ")", ":", "logging", ".", "debug", "(", "'Gathering supplement URLs for element_id <%s>.'", ",", "element_id", ")", "try", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPEN...
Return a dictionary with supplement files (pdf, csv, zip, ipynb, html and so on) extracted from supplement page. @return: @see CourseraOnDemand._extract_links_from_text
[ "Return", "a", "dictionary", "with", "supplement", "files", "(", "pdf", "csv", "zip", "ipynb", "html", "and", "so", "on", ")", "extracted", "from", "supplement", "page", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1238-L1282
train
Extract links from supplement page.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_asset_tags
def _extract_asset_tags(self, text): """ Extract asset tags from text into a convenient form. @param text: Text to extract asset tags from. This text contains HTML code that is parsed by BeautifulSoup. @type text: str @return: Asset map. @rtype: { ...
python
def _extract_asset_tags(self, text): """ Extract asset tags from text into a convenient form. @param text: Text to extract asset tags from. This text contains HTML code that is parsed by BeautifulSoup. @type text: str @return: Asset map. @rtype: { ...
[ "def", "_extract_asset_tags", "(", "self", ",", "text", ")", ":", "soup", "=", "BeautifulSoup", "(", "text", ")", "asset_tags_map", "=", "{", "}", "for", "asset", "in", "soup", ".", "find_all", "(", "'asset'", ")", ":", "asset_tags_map", "[", "asset", "[...
Extract asset tags from text into a convenient form. @param text: Text to extract asset tags from. This text contains HTML code that is parsed by BeautifulSoup. @type text: str @return: Asset map. @rtype: { '<id>': { 'name': '<name>', ...
[ "Extract", "asset", "tags", "from", "text", "into", "a", "convenient", "form", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1284-L1308
train
Extract asset tags from text into a convenient form.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_asset_urls
def _extract_asset_urls(self, asset_ids): """ Extract asset URLs along with asset ids. @param asset_ids: List of ids to get URLs for. @type assertn: [str] @return: List of dictionaries with asset URLs and ids. @rtype: [{ 'id': '<id>', 'url': '<ur...
python
def _extract_asset_urls(self, asset_ids): """ Extract asset URLs along with asset ids. @param asset_ids: List of ids to get URLs for. @type assertn: [str] @return: List of dictionaries with asset URLs and ids. @rtype: [{ 'id': '<id>', 'url': '<ur...
[ "def", "_extract_asset_urls", "(", "self", ",", "asset_ids", ")", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_ASSET_URL", ",", "json", "=", "True", ",", "ids", "=", "quote_plus", "(", "','", ".", "join", "(", "asset_ids", ...
Extract asset URLs along with asset ids. @param asset_ids: List of ids to get URLs for. @type assertn: [str] @return: List of dictionaries with asset URLs and ids. @rtype: [{ 'id': '<id>', 'url': '<url>' }]
[ "Extract", "asset", "URLs", "along", "with", "asset", "ids", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1310-L1329
train
Extract asset URLs along with asset ids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand.extract_links_from_reference
def extract_links_from_reference(self, short_id): """ Return a dictionary with supplement files (pdf, csv, zip, ipynb, html and so on) extracted from supplement page. @return: @see CourseraOnDemand._extract_links_from_text """ logging.debug('Gathering resource URLs for s...
python
def extract_links_from_reference(self, short_id): """ Return a dictionary with supplement files (pdf, csv, zip, ipynb, html and so on) extracted from supplement page. @return: @see CourseraOnDemand._extract_links_from_text """ logging.debug('Gathering resource URLs for s...
[ "def", "extract_links_from_reference", "(", "self", ",", "short_id", ")", ":", "logging", ".", "debug", "(", "'Gathering resource URLs for short_id <%s>.'", ",", "short_id", ")", "try", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_RE...
Return a dictionary with supplement files (pdf, csv, zip, ipynb, html and so on) extracted from supplement page. @return: @see CourseraOnDemand._extract_links_from_text
[ "Return", "a", "dictionary", "with", "supplement", "files", "(", "pdf", "csv", "zip", "ipynb", "html", "and", "so", "on", ")", "extracted", "from", "supplement", "page", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1349-L1392
train
Extract links from supplement page.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_programming_immediate_instructions_text
def _extract_programming_immediate_instructions_text(self, element_id): """ Extract assignment text (instructions). @param element_id: Element id to extract assignment instructions from. @type element_id: str @return: List of assignment text (instructions). @rtype: [str...
python
def _extract_programming_immediate_instructions_text(self, element_id): """ Extract assignment text (instructions). @param element_id: Element id to extract assignment instructions from. @type element_id: str @return: List of assignment text (instructions). @rtype: [str...
[ "def", "_extract_programming_immediate_instructions_text", "(", "self", ",", "element_id", ")", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_PROGRAMMING_IMMEDIATE_INSTRUCTIOINS_URL", ",", "json", "=", "True", ",", "course_id", "=", "self...
Extract assignment text (instructions). @param element_id: Element id to extract assignment instructions from. @type element_id: str @return: List of assignment text (instructions). @rtype: [str]
[ "Extract", "assignment", "text", "(", "instructions", ")", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1394-L1410
train
Extract assignment instructions text from an element.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_notebook_text
def _extract_notebook_text(self, element_id): """ Extract notebook text (instructions). @param element_id: Element id to extract notebook links. @type element_id: str @return: Notebook URL. @rtype: [str] """ headers = self._auth_headers_with_json() ...
python
def _extract_notebook_text(self, element_id): """ Extract notebook text (instructions). @param element_id: Element id to extract notebook links. @type element_id: str @return: Notebook URL. @rtype: [str] """ headers = self._auth_headers_with_json() ...
[ "def", "_extract_notebook_text", "(", "self", ",", "element_id", ")", ":", "headers", "=", "self", ".", "_auth_headers_with_json", "(", ")", "data", "=", "{", "'courseId'", ":", "self", ".", "_course_id", ",", "'learnerId'", ":", "self", ".", "_user_id", ","...
Extract notebook text (instructions). @param element_id: Element id to extract notebook links. @type element_id: str @return: Notebook URL. @rtype: [str]
[ "Extract", "notebook", "text", "(", "instructions", ")", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1412-L1436
train
Extract notebook text.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_assignment_text
def _extract_assignment_text(self, element_id): """ Extract assignment text (instructions). @param element_id: Element id to extract assignment instructions from. @type element_id: str @return: List of assignment text (instructions). @rtype: [str] """ do...
python
def _extract_assignment_text(self, element_id): """ Extract assignment text (instructions). @param element_id: Element id to extract assignment instructions from. @type element_id: str @return: List of assignment text (instructions). @rtype: [str] """ do...
[ "def", "_extract_assignment_text", "(", "self", ",", "element_id", ")", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_PROGRAMMING_ASSIGNMENTS_URL", ",", "json", "=", "True", ",", "course_id", "=", "self", ".", "_course_id", ",", "...
Extract assignment text (instructions). @param element_id: Element id to extract assignment instructions from. @type element_id: str @return: List of assignment text (instructions). @rtype: [str]
[ "Extract", "assignment", "text", "(", "instructions", ")", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1438-L1455
train
Extract assignment text from the submissionLearnerSchema.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_peer_assignment_text
def _extract_peer_assignment_text(self, element_id): """ Extract peer assignment text (instructions). @param element_id: Element id to extract peer assignment instructions from. @type element_id: str @return: List of peer assignment text (instructions). @rtype: [str] ...
python
def _extract_peer_assignment_text(self, element_id): """ Extract peer assignment text (instructions). @param element_id: Element id to extract peer assignment instructions from. @type element_id: str @return: List of peer assignment text (instructions). @rtype: [str] ...
[ "def", "_extract_peer_assignment_text", "(", "self", ",", "element_id", ")", ":", "dom", "=", "get_page", "(", "self", ".", "_session", ",", "OPENCOURSE_PEER_ASSIGNMENT_INSTRUCTIONS", ",", "json", "=", "True", ",", "user_id", "=", "self", ".", "_user_id", ",", ...
Extract peer assignment text (instructions). @param element_id: Element id to extract peer assignment instructions from. @type element_id: str @return: List of peer assignment text (instructions). @rtype: [str]
[ "Extract", "peer", "assignment", "text", "(", "instructions", ")", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1457-L1492
train
Extract peer assignment text from an element.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_links_from_text
def _extract_links_from_text(self, text): """ Extract supplement links from the html text. Links may be provided in two ways: 1. <a> tags with href attribute 2. <asset> tags with id attribute (requires additional request to get the direct URL to the asset f...
python
def _extract_links_from_text(self, text): """ Extract supplement links from the html text. Links may be provided in two ways: 1. <a> tags with href attribute 2. <asset> tags with id attribute (requires additional request to get the direct URL to the asset f...
[ "def", "_extract_links_from_text", "(", "self", ",", "text", ")", ":", "supplement_links", "=", "self", ".", "_extract_links_from_a_tags_in_text", "(", "text", ")", "extend_supplement_links", "(", "supplement_links", ",", "self", ".", "_extract_links_from_asset_tags_in_te...
Extract supplement links from the html text. Links may be provided in two ways: 1. <a> tags with href attribute 2. <asset> tags with id attribute (requires additional request to get the direct URL to the asset file) @param text: HTML text. @type text: str ...
[ "Extract", "supplement", "links", "from", "the", "html", "text", ".", "Links", "may", "be", "provided", "in", "two", "ways", ":", "1", ".", "<a", ">", "tags", "with", "href", "attribute", "2", ".", "<asset", ">", "tags", "with", "id", "attribute", "(",...
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1494-L1524
train
Extract supplement links from the html text.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_links_from_asset_tags_in_text
def _extract_links_from_asset_tags_in_text(self, text): """ Scan the text and extract asset tags and links to corresponding files. @param text: Page text. @type text: str @return: @see CourseraOnDemand._extract_links_from_text """ # Extract asset tags fr...
python
def _extract_links_from_asset_tags_in_text(self, text): """ Scan the text and extract asset tags and links to corresponding files. @param text: Page text. @type text: str @return: @see CourseraOnDemand._extract_links_from_text """ # Extract asset tags fr...
[ "def", "_extract_links_from_asset_tags_in_text", "(", "self", ",", "text", ")", ":", "# Extract asset tags from instructions text", "asset_tags_map", "=", "self", ".", "_extract_asset_tags", "(", "text", ")", "ids", "=", "list", "(", "iterkeys", "(", "asset_tags_map", ...
Scan the text and extract asset tags and links to corresponding files. @param text: Page text. @type text: str @return: @see CourseraOnDemand._extract_links_from_text
[ "Scan", "the", "text", "and", "extract", "asset", "tags", "and", "links", "to", "corresponding", "files", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1526-L1561
train
Scan the text and extract asset tags and links to corresponding asset files.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/api.py
CourseraOnDemand._extract_links_from_a_tags_in_text
def _extract_links_from_a_tags_in_text(self, text): """ Extract supplement links from the html text that contains <a> tags with href attribute. @param text: HTML text. @type text: str @return: Dictionary with supplement links grouped by extension. @rtype: { ...
python
def _extract_links_from_a_tags_in_text(self, text): """ Extract supplement links from the html text that contains <a> tags with href attribute. @param text: HTML text. @type text: str @return: Dictionary with supplement links grouped by extension. @rtype: { ...
[ "def", "_extract_links_from_a_tags_in_text", "(", "self", ",", "text", ")", ":", "soup", "=", "BeautifulSoup", "(", "text", ")", "links", "=", "[", "item", "[", "'href'", "]", ".", "strip", "(", ")", "for", "item", "in", "soup", ".", "find_all", "(", "...
Extract supplement links from the html text that contains <a> tags with href attribute. @param text: HTML text. @type text: str @return: Dictionary with supplement links grouped by extension. @rtype: { '<extension1>': [ ('<link1>', '<title1>'), ...
[ "Extract", "supplement", "links", "from", "the", "html", "text", "that", "contains", "<a", ">", "tags", "with", "href", "attribute", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/api.py#L1563-L1613
train
Extract supplement links from the html text that contains a tags with href attribute.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/playlist.py
create_m3u_playlist
def create_m3u_playlist(section_dir): """ Create M3U playlist with contents of `section_dir`/*.mp4. The playlist will be created in that directory. @param section_dir: Path where to scan for *.mp4 files. @type section_dir: str """ path_to_return = os.getcwd() for (_path, subdirs, files...
python
def create_m3u_playlist(section_dir): """ Create M3U playlist with contents of `section_dir`/*.mp4. The playlist will be created in that directory. @param section_dir: Path where to scan for *.mp4 files. @type section_dir: str """ path_to_return = os.getcwd() for (_path, subdirs, files...
[ "def", "create_m3u_playlist", "(", "section_dir", ")", ":", "path_to_return", "=", "os", ".", "getcwd", "(", ")", "for", "(", "_path", ",", "subdirs", ",", "files", ")", "in", "os", ".", "walk", "(", "section_dir", ")", ":", "os", ".", "chdir", "(", ...
Create M3U playlist with contents of `section_dir`/*.mp4. The playlist will be created in that directory. @param section_dir: Path where to scan for *.mp4 files. @type section_dir: str
[ "Create", "M3U", "playlist", "with", "contents", "of", "section_dir", "/", "*", ".", "mp4", ".", "The", "playlist", "will", "be", "created", "in", "that", "directory", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/playlist.py#L5-L25
train
Create M3U playlist with contents of section_dir. mp4 files.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/extractors.py
CourseraExtractor.list_courses
def list_courses(self): """ List enrolled courses. @return: List of enrolled courses. @rtype: [str] """ course = CourseraOnDemand(session=self._session, course_id=None, course_name=None) return c...
python
def list_courses(self): """ List enrolled courses. @return: List of enrolled courses. @rtype: [str] """ course = CourseraOnDemand(session=self._session, course_id=None, course_name=None) return c...
[ "def", "list_courses", "(", "self", ")", ":", "course", "=", "CourseraOnDemand", "(", "session", "=", "self", ".", "_session", ",", "course_id", "=", "None", ",", "course_name", "=", "None", ")", "return", "course", ".", "list_courses", "(", ")" ]
List enrolled courses. @return: List of enrolled courses. @rtype: [str]
[ "List", "enrolled", "courses", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/extractors.py#L34-L44
train
List enrolled courses.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/extractors.py
CourseraExtractor._get_on_demand_syllabus
def _get_on_demand_syllabus(self, class_name): """ Get the on-demand course listing webpage. """ url = OPENCOURSE_ONDEMAND_COURSE_MATERIALS_V2.format( class_name=class_name) page = get_page(self._session, url) logging.debug('Downloaded %s (%d bytes)', url, le...
python
def _get_on_demand_syllabus(self, class_name): """ Get the on-demand course listing webpage. """ url = OPENCOURSE_ONDEMAND_COURSE_MATERIALS_V2.format( class_name=class_name) page = get_page(self._session, url) logging.debug('Downloaded %s (%d bytes)', url, le...
[ "def", "_get_on_demand_syllabus", "(", "self", ",", "class_name", ")", ":", "url", "=", "OPENCOURSE_ONDEMAND_COURSE_MATERIALS_V2", ".", "format", "(", "class_name", "=", "class_name", ")", "page", "=", "get_page", "(", "self", ".", "_session", ",", "url", ")", ...
Get the on-demand course listing webpage.
[ "Get", "the", "on", "-", "demand", "course", "listing", "webpage", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/extractors.py#L61-L71
train
Get the on - demand course listing webpage.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/extractors.py
CourseraExtractor._parse_on_demand_syllabus
def _parse_on_demand_syllabus(self, course_name, page, reverse=False, unrestricted_filenames=False, subtitle_language='en', video_resolution=None, download_quizzes=False, ...
python
def _parse_on_demand_syllabus(self, course_name, page, reverse=False, unrestricted_filenames=False, subtitle_language='en', video_resolution=None, download_quizzes=False, ...
[ "def", "_parse_on_demand_syllabus", "(", "self", ",", "course_name", ",", "page", ",", "reverse", "=", "False", ",", "unrestricted_filenames", "=", "False", ",", "subtitle_language", "=", "'en'", ",", "video_resolution", "=", "None", ",", "download_quizzes", "=", ...
Parse a Coursera on-demand course listing/syllabus page. @return: Tuple of (bool, list), where bool indicates whether there was at least on error while parsing syllabus, the list is a list of parsed modules. @rtype: (bool, list)
[ "Parse", "a", "Coursera", "on", "-", "demand", "course", "listing", "/", "syllabus", "page", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/extractors.py#L73-L239
train
Parse a Coursera on - demand course listing page.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/workflow.py
_iter_modules
def _iter_modules(modules, class_name, path, ignored_formats, args): """ This huge function generates a hierarchy with hopefully more clear structure of modules/sections/lectures. """ file_formats = args.file_formats lecture_filter = args.lecture_filter resource_filter = args.resource_filter...
python
def _iter_modules(modules, class_name, path, ignored_formats, args): """ This huge function generates a hierarchy with hopefully more clear structure of modules/sections/lectures. """ file_formats = args.file_formats lecture_filter = args.lecture_filter resource_filter = args.resource_filter...
[ "def", "_iter_modules", "(", "modules", ",", "class_name", ",", "path", ",", "ignored_formats", ",", "args", ")", ":", "file_formats", "=", "args", ".", "file_formats", "lecture_filter", "=", "args", ".", "lecture_filter", "resource_filter", "=", "args", ".", ...
This huge function generates a hierarchy with hopefully more clear structure of modules/sections/lectures.
[ "This", "huge", "function", "generates", "a", "hierarchy", "with", "hopefully", "more", "clear", "structure", "of", "modules", "/", "sections", "/", "lectures", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/workflow.py#L18-L97
train
This function generates a hierarchy of modules and lectures.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/workflow.py
_walk_modules
def _walk_modules(modules, class_name, path, ignored_formats, args): """ Helper generator that traverses modules in returns a flattened iterator. """ for module in _iter_modules(modules=modules, class_name=class_name, path=path, ...
python
def _walk_modules(modules, class_name, path, ignored_formats, args): """ Helper generator that traverses modules in returns a flattened iterator. """ for module in _iter_modules(modules=modules, class_name=class_name, path=path, ...
[ "def", "_walk_modules", "(", "modules", ",", "class_name", ",", "path", ",", "ignored_formats", ",", "args", ")", ":", "for", "module", "in", "_iter_modules", "(", "modules", "=", "modules", ",", "class_name", "=", "class_name", ",", "path", "=", "path", "...
Helper generator that traverses modules in returns a flattened iterator.
[ "Helper", "generator", "that", "traverses", "modules", "in", "returns", "a", "flattened", "iterator", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/workflow.py#L100-L113
train
Helper generator that traverses modules in returns a flattened iterator.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/workflow.py
CourseraDownloader._handle_resource
def _handle_resource(self, url, fmt, lecture_filename, callback, last_update): """ Handle resource. This function builds up resource file name and downloads it if necessary. @param url: URL of the resource. @type url: str @param fmt: Format of the resource (pdf, csv, et...
python
def _handle_resource(self, url, fmt, lecture_filename, callback, last_update): """ Handle resource. This function builds up resource file name and downloads it if necessary. @param url: URL of the resource. @type url: str @param fmt: Format of the resource (pdf, csv, et...
[ "def", "_handle_resource", "(", "self", ",", "url", ",", "fmt", ",", "lecture_filename", ",", "callback", ",", "last_update", ")", ":", "overwrite", "=", "self", ".", "_args", ".", "overwrite", "resume", "=", "self", ".", "_args", ".", "resume", "skip_down...
Handle resource. This function builds up resource file name and downloads it if necessary. @param url: URL of the resource. @type url: str @param fmt: Format of the resource (pdf, csv, etc) @type fmt: str @param lecture_filename: File name of the lecture. @type...
[ "Handle", "resource", ".", "This", "function", "builds", "up", "resource", "file", "name", "and", "downloads", "it", "if", "necessary", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/workflow.py#L195-L246
train
Handle a resource. This function downloads the resource if necessary and updates the last_update timestamp.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/formatting.py
get_lecture_filename
def get_lecture_filename(combined_section_lectures_nums, section_dir, secnum, lecnum, lecname, title, fmt): """ Prepare a destination lecture filename. @para...
python
def get_lecture_filename(combined_section_lectures_nums, section_dir, secnum, lecnum, lecname, title, fmt): """ Prepare a destination lecture filename. @para...
[ "def", "get_lecture_filename", "(", "combined_section_lectures_nums", ",", "section_dir", ",", "secnum", ",", "lecnum", ",", "lecname", ",", "title", ",", "fmt", ")", ":", "# FIXME: this is a quick and dirty solution to Filename too long", "# problem. We need to think of a more...
Prepare a destination lecture filename. @param combined_section_lectures_nums: Flag that indicates whether section lectures should have combined numbering. @type combined_section_lectures_nums: bool @param section_dir: Path to current section directory. @type section_dir: str @param secnu...
[ "Prepare", "a", "destination", "lecture", "filename", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/formatting.py#L25-L76
train
Prepare a destination lecture filename.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/downloaders.py
format_bytes
def format_bytes(bytes): """ Get human readable version of given bytes. Ripped from https://github.com/rg3/youtube-dl """ if bytes is None: return 'N/A' if type(bytes) is str: bytes = float(bytes) if bytes == 0.0: exponent = 0 else: exponent = int(math.log...
python
def format_bytes(bytes): """ Get human readable version of given bytes. Ripped from https://github.com/rg3/youtube-dl """ if bytes is None: return 'N/A' if type(bytes) is str: bytes = float(bytes) if bytes == 0.0: exponent = 0 else: exponent = int(math.log...
[ "def", "format_bytes", "(", "bytes", ")", ":", "if", "bytes", "is", "None", ":", "return", "'N/A'", "if", "type", "(", "bytes", ")", "is", "str", ":", "bytes", "=", "float", "(", "bytes", ")", "if", "bytes", "==", "0.0", ":", "exponent", "=", "0", ...
Get human readable version of given bytes. Ripped from https://github.com/rg3/youtube-dl
[ "Get", "human", "readable", "version", "of", "given", "bytes", ".", "Ripped", "from", "https", ":", "//", "github", ".", "com", "/", "rg3", "/", "youtube", "-", "dl" ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/downloaders.py#L214-L229
train
Returns a human readable version of given bytes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/downloaders.py
get_downloader
def get_downloader(session, class_name, args): """ Decides which downloader to use. """ external = { 'wget': WgetDownloader, 'curl': CurlDownloader, 'aria2': Aria2Downloader, 'axel': AxelDownloader, } for bin, class_ in iteritems(external): if getattr(ar...
python
def get_downloader(session, class_name, args): """ Decides which downloader to use. """ external = { 'wget': WgetDownloader, 'curl': CurlDownloader, 'aria2': Aria2Downloader, 'axel': AxelDownloader, } for bin, class_ in iteritems(external): if getattr(ar...
[ "def", "get_downloader", "(", "session", ",", "class_name", ",", "args", ")", ":", "external", "=", "{", "'wget'", ":", "WgetDownloader", ",", "'curl'", ":", "CurlDownloader", ",", "'aria2'", ":", "Aria2Downloader", ",", "'axel'", ":", "AxelDownloader", ",", ...
Decides which downloader to use.
[ "Decides", "which", "downloader", "to", "use", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/downloaders.py#L389-L406
train
Returns a downloader for the specified class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/downloaders.py
Downloader.download
def download(self, url, filename, resume=False): """ Download the given url to the given file. When the download is aborted by the user, the partially downloaded file is also removed. """ try: self._start_download(url, filename, resume) except KeyboardInterru...
python
def download(self, url, filename, resume=False): """ Download the given url to the given file. When the download is aborted by the user, the partially downloaded file is also removed. """ try: self._start_download(url, filename, resume) except KeyboardInterru...
[ "def", "download", "(", "self", ",", "url", ",", "filename", ",", "resume", "=", "False", ")", ":", "try", ":", "self", ".", "_start_download", "(", "url", ",", "filename", ",", "resume", ")", "except", "KeyboardInterrupt", "as", "e", ":", "# keep the fi...
Download the given url to the given file. When the download is aborted by the user, the partially downloaded file is also removed.
[ "Download", "the", "given", "url", "to", "the", "given", "file", ".", "When", "the", "download", "is", "aborted", "by", "the", "user", "the", "partially", "downloaded", "file", "is", "also", "removed", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/downloaders.py#L47-L64
train
Download the given url to the given file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/downloaders.py
ExternalDownloader._prepare_cookies
def _prepare_cookies(self, command, url): """ Extract cookies from the requests session and add them to the command """ req = requests.models.Request() req.method = 'GET' req.url = url cookie_values = requests.cookies.get_cookie_header( self.session....
python
def _prepare_cookies(self, command, url): """ Extract cookies from the requests session and add them to the command """ req = requests.models.Request() req.method = 'GET' req.url = url cookie_values = requests.cookies.get_cookie_header( self.session....
[ "def", "_prepare_cookies", "(", "self", ",", "command", ",", "url", ")", ":", "req", "=", "requests", ".", "models", ".", "Request", "(", ")", "req", ".", "method", "=", "'GET'", "req", ".", "url", "=", "url", "cookie_values", "=", "requests", ".", "...
Extract cookies from the requests session and add them to the command
[ "Extract", "cookies", "from", "the", "requests", "session", "and", "add", "them", "to", "the", "command" ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/downloaders.py#L89-L102
train
Extract cookies from the requests session and add them to the command
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/downloaders.py
DownloadProgress.report_progress
def report_progress(self): """Report download progress.""" percent = self.calc_percent() total = format_bytes(self._total) speed = self.calc_speed() total_speed_report = '{0} at {1}'.format(total, speed) report = '\r{0: <56} {1: >30}'.format(percent, total_speed_report)...
python
def report_progress(self): """Report download progress.""" percent = self.calc_percent() total = format_bytes(self._total) speed = self.calc_speed() total_speed_report = '{0} at {1}'.format(total, speed) report = '\r{0: <56} {1: >30}'.format(percent, total_speed_report)...
[ "def", "report_progress", "(", "self", ")", ":", "percent", "=", "self", ".", "calc_percent", "(", ")", "total", "=", "format_bytes", "(", "self", ".", "_total", ")", "speed", "=", "self", ".", "calc_speed", "(", ")", "total_speed_report", "=", "'{0} at {1...
Report download progress.
[ "Report", "download", "progress", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/downloaders.py#L285-L299
train
Report download progress.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/parallel.py
AbstractDownloader._download_wrapper
def _download_wrapper(self, url, *args, **kwargs): """ Actual download call. Calls the underlying file downloader, catches all exceptions and returns the result. """ try: return url, self._file_downloader.download(url, *args, **kwargs) except Exception as e: ...
python
def _download_wrapper(self, url, *args, **kwargs): """ Actual download call. Calls the underlying file downloader, catches all exceptions and returns the result. """ try: return url, self._file_downloader.download(url, *args, **kwargs) except Exception as e: ...
[ "def", "_download_wrapper", "(", "self", ",", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "url", ",", "self", ".", "_file_downloader", ".", "download", "(", "url", ",", "*", "args", ",", "*", "*", "kwargs", ")"...
Actual download call. Calls the underlying file downloader, catches all exceptions and returns the result.
[ "Actual", "download", "call", ".", "Calls", "the", "underlying", "file", "downloader", "catches", "all", "exceptions", "and", "returns", "the", "result", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/parallel.py#L26-L35
train
Wrapper for the download method.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/credentials.py
get_config_paths
def get_config_paths(config_name): # pragma: no test """ Return a list of config files paths to try in order, given config file name and possibly a user-specified path. For Windows platforms, there are several paths that can be tried to retrieve the netrc file. There is, however, no "standard way"...
python
def get_config_paths(config_name): # pragma: no test """ Return a list of config files paths to try in order, given config file name and possibly a user-specified path. For Windows platforms, there are several paths that can be tried to retrieve the netrc file. There is, however, no "standard way"...
[ "def", "get_config_paths", "(", "config_name", ")", ":", "# pragma: no test", "if", "platform", ".", "system", "(", ")", "!=", "'Windows'", ":", "return", "[", "None", "]", "# Now, we only treat the case of Windows", "env_vars", "=", "[", "[", "\"HOME\"", "]", "...
Return a list of config files paths to try in order, given config file name and possibly a user-specified path. For Windows platforms, there are several paths that can be tried to retrieve the netrc file. There is, however, no "standard way" of doing things. A brief recap of the situation (all fil...
[ "Return", "a", "list", "of", "config", "files", "paths", "to", "try", "in", "order", "given", "config", "file", "name", "and", "possibly", "a", "user", "-", "specified", "path", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/credentials.py#L37-L110
train
Returns a list of config file paths to try in order given a config file name and possibly a user - specified path.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/credentials.py
authenticate_through_netrc
def authenticate_through_netrc(path=None): """ Return the tuple user / password given a path for the .netrc file. Raises CredentialsError if no valid netrc file is found. """ errors = [] netrc_machine = 'coursera-dl' paths = [path] if path else get_config_paths("netrc") for path in path...
python
def authenticate_through_netrc(path=None): """ Return the tuple user / password given a path for the .netrc file. Raises CredentialsError if no valid netrc file is found. """ errors = [] netrc_machine = 'coursera-dl' paths = [path] if path else get_config_paths("netrc") for path in path...
[ "def", "authenticate_through_netrc", "(", "path", "=", "None", ")", ":", "errors", "=", "[", "]", "netrc_machine", "=", "'coursera-dl'", "paths", "=", "[", "path", "]", "if", "path", "else", "get_config_paths", "(", "\"netrc\"", ")", "for", "path", "in", "...
Return the tuple user / password given a path for the .netrc file. Raises CredentialsError if no valid netrc file is found.
[ "Return", "the", "tuple", "user", "/", "password", "given", "a", "path", "for", "the", ".", "netrc", "file", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/credentials.py#L113-L138
train
Authenticate through the netrc file and return the user and password.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
coursera-dl/coursera-dl
coursera/credentials.py
get_credentials
def get_credentials(username=None, password=None, netrc=None, use_keyring=False): """ Return valid username, password tuple. Raises CredentialsError if username or password is missing. """ if netrc: path = None if netrc is True else netrc return authenticate_through_netrc(path) ...
python
def get_credentials(username=None, password=None, netrc=None, use_keyring=False): """ Return valid username, password tuple. Raises CredentialsError if username or password is missing. """ if netrc: path = None if netrc is True else netrc return authenticate_through_netrc(path) ...
[ "def", "get_credentials", "(", "username", "=", "None", ",", "password", "=", "None", ",", "netrc", "=", "None", ",", "use_keyring", "=", "False", ")", ":", "if", "netrc", ":", "path", "=", "None", "if", "netrc", "is", "True", "else", "netrc", "return"...
Return valid username, password tuple. Raises CredentialsError if username or password is missing.
[ "Return", "valid", "username", "password", "tuple", "." ]
9b434bcf3c4011bf3181429fe674633ae5fb7d4d
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/coursera/credentials.py#L141-L164
train
Get username and password tuple.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/wrappers/common_descriptors.py
CommonResponseDescriptorsMixin.mimetype
def mimetype(self): """The mimetype (content type without charset etc.)""" ct = self.headers.get("content-type") if ct: return ct.split(";")[0].strip()
python
def mimetype(self): """The mimetype (content type without charset etc.)""" ct = self.headers.get("content-type") if ct: return ct.split(";")[0].strip()
[ "def", "mimetype", "(", "self", ")", ":", "ct", "=", "self", ".", "headers", ".", "get", "(", "\"content-type\"", ")", "if", "ct", ":", "return", "ct", ".", "split", "(", "\";\"", ")", "[", "0", "]", ".", "strip", "(", ")" ]
The mimetype (content type without charset etc.)
[ "The", "mimetype", "(", "content", "type", "without", "charset", "etc", ".", ")" ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/wrappers/common_descriptors.py#L136-L140
train
The mimetype of the response.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/wrappers/common_descriptors.py
CommonResponseDescriptorsMixin.mimetype_params
def mimetype_params(self): """The mimetype parameters as dict. For example if the content type is ``text/html; charset=utf-8`` the params would be ``{'charset': 'utf-8'}``. .. versionadded:: 0.5 """ def on_update(d): self.headers["Content-Type"] = dump_optio...
python
def mimetype_params(self): """The mimetype parameters as dict. For example if the content type is ``text/html; charset=utf-8`` the params would be ``{'charset': 'utf-8'}``. .. versionadded:: 0.5 """ def on_update(d): self.headers["Content-Type"] = dump_optio...
[ "def", "mimetype_params", "(", "self", ")", ":", "def", "on_update", "(", "d", ")", ":", "self", ".", "headers", "[", "\"Content-Type\"", "]", "=", "dump_options_header", "(", "self", ".", "mimetype", ",", "d", ")", "d", "=", "parse_options_header", "(", ...
The mimetype parameters as dict. For example if the content type is ``text/html; charset=utf-8`` the params would be ``{'charset': 'utf-8'}``. .. versionadded:: 0.5
[ "The", "mimetype", "parameters", "as", "dict", ".", "For", "example", "if", "the", "content", "type", "is", "text", "/", "html", ";", "charset", "=", "utf", "-", "8", "the", "params", "would", "be", "{", "charset", ":", "utf", "-", "8", "}", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/wrappers/common_descriptors.py#L147-L159
train
The mimetype parameters as dict. For example the mimetype is text - html charset = utf - 8.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
examples/simplewiki/specialpages.py
page_index
def page_index(request): """Index of all pages.""" letters = {} for page in Page.query.order_by(Page.name): letters.setdefault(page.name.capitalize()[0], []).append(page) return Response( generate_template("page_index.html", letters=sorted(letters.items())) )
python
def page_index(request): """Index of all pages.""" letters = {} for page in Page.query.order_by(Page.name): letters.setdefault(page.name.capitalize()[0], []).append(page) return Response( generate_template("page_index.html", letters=sorted(letters.items())) )
[ "def", "page_index", "(", "request", ")", ":", "letters", "=", "{", "}", "for", "page", "in", "Page", ".", "query", ".", "order_by", "(", "Page", ".", "name", ")", ":", "letters", ".", "setdefault", "(", "page", ".", "name", ".", "capitalize", "(", ...
Index of all pages.
[ "Index", "of", "all", "pages", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/simplewiki/specialpages.py#L20-L27
train
Index of all pages.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
examples/simplewiki/specialpages.py
recent_changes
def recent_changes(request): """Display the recent changes.""" page = max(1, request.args.get("page", type=int)) query = RevisionedPage.query.order_by(RevisionedPage.revision_id.desc()) return Response( generate_template( "recent_changes.html", pagination=Pagination(query...
python
def recent_changes(request): """Display the recent changes.""" page = max(1, request.args.get("page", type=int)) query = RevisionedPage.query.order_by(RevisionedPage.revision_id.desc()) return Response( generate_template( "recent_changes.html", pagination=Pagination(query...
[ "def", "recent_changes", "(", "request", ")", ":", "page", "=", "max", "(", "1", ",", "request", ".", "args", ".", "get", "(", "\"page\"", ",", "type", "=", "int", ")", ")", "query", "=", "RevisionedPage", ".", "query", ".", "order_by", "(", "Revisio...
Display the recent changes.
[ "Display", "the", "recent", "changes", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/simplewiki/specialpages.py#L30-L39
train
Display the recent changes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
examples/manage-plnt.py
make_app
def make_app(): """Helper function that creates a plnt app.""" from plnt import Plnt database_uri = os.environ.get("PLNT_DATABASE_URI") app = Plnt(database_uri or "sqlite:////tmp/plnt.db") app.bind_to_context() return app
python
def make_app(): """Helper function that creates a plnt app.""" from plnt import Plnt database_uri = os.environ.get("PLNT_DATABASE_URI") app = Plnt(database_uri or "sqlite:////tmp/plnt.db") app.bind_to_context() return app
[ "def", "make_app", "(", ")", ":", "from", "plnt", "import", "Plnt", "database_uri", "=", "os", ".", "environ", ".", "get", "(", "\"PLNT_DATABASE_URI\"", ")", "app", "=", "Plnt", "(", "database_uri", "or", "\"sqlite:////tmp/plnt.db\"", ")", "app", ".", "bind_...
Helper function that creates a plnt app.
[ "Helper", "function", "that", "creates", "a", "plnt", "app", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/manage-plnt.py#L18-L25
train
Helper function that creates a plnt app.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
examples/manage-plnt.py
initdb
def initdb(): """Initialize the database""" from plnt.database import Blog, session make_app().init_database() # and now fill in some python blogs everybody should read (shamelessly # added my own blog too) blogs = [ Blog( "Armin Ronacher", "http://lucumr.pocoo.o...
python
def initdb(): """Initialize the database""" from plnt.database import Blog, session make_app().init_database() # and now fill in some python blogs everybody should read (shamelessly # added my own blog too) blogs = [ Blog( "Armin Ronacher", "http://lucumr.pocoo.o...
[ "def", "initdb", "(", ")", ":", "from", "plnt", ".", "database", "import", "Blog", ",", "session", "make_app", "(", ")", ".", "init_database", "(", ")", "# and now fill in some python blogs everybody should read (shamelessly", "# added my own blog too)", "blogs", "=", ...
Initialize the database
[ "Initialize", "the", "database" ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/manage-plnt.py#L34-L76
train
Initialize the database
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
examples/manage-plnt.py
runserver
def runserver(hostname, port, no_reloader, debugger, no_evalex, threaded, processes): """Start a new development server.""" app = make_app() reloader = not no_reloader evalex = not no_evalex run_simple( hostname, port, app, use_reloader=reloader, use_debugger=...
python
def runserver(hostname, port, no_reloader, debugger, no_evalex, threaded, processes): """Start a new development server.""" app = make_app() reloader = not no_reloader evalex = not no_evalex run_simple( hostname, port, app, use_reloader=reloader, use_debugger=...
[ "def", "runserver", "(", "hostname", ",", "port", ",", "no_reloader", ",", "debugger", ",", "no_evalex", ",", "threaded", ",", "processes", ")", ":", "app", "=", "make_app", "(", ")", "reloader", "=", "not", "no_reloader", "evalex", "=", "not", "no_evalex"...
Start a new development server.
[ "Start", "a", "new", "development", "server", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/examples/manage-plnt.py#L87-L101
train
Start a new development server.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
iter_multi_items
def iter_multi_items(mapping): """Iterates over the items of a mapping yielding keys and values without dropping any from more complex structures. """ if isinstance(mapping, MultiDict): for item in iteritems(mapping, multi=True): yield item elif isinstance(mapping, dict): ...
python
def iter_multi_items(mapping): """Iterates over the items of a mapping yielding keys and values without dropping any from more complex structures. """ if isinstance(mapping, MultiDict): for item in iteritems(mapping, multi=True): yield item elif isinstance(mapping, dict): ...
[ "def", "iter_multi_items", "(", "mapping", ")", ":", "if", "isinstance", "(", "mapping", ",", "MultiDict", ")", ":", "for", "item", "in", "iteritems", "(", "mapping", ",", "multi", "=", "True", ")", ":", "yield", "item", "elif", "isinstance", "(", "mappi...
Iterates over the items of a mapping yielding keys and values without dropping any from more complex structures.
[ "Iterates", "over", "the", "items", "of", "a", "mapping", "yielding", "keys", "and", "values", "without", "dropping", "any", "from", "more", "complex", "structures", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L39-L55
train
Iterates over the items of a mapping yielding keys and values without dropping any from more complex structures.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
TypeConversionDict.get
def get(self, key, default=None, type=None): """Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the de...
python
def get(self, key, default=None, type=None): """Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the de...
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ",", "type", "=", "None", ")", ":", "try", ":", "rv", "=", "self", "[", "key", "]", "except", "KeyError", ":", "return", "default", "if", "type", "is", "not", "None", ":", "try",...
Return the default value if the requested data doesn't exist. If `type` is provided and is a callable it should convert the value, return it or raise a :exc:`ValueError` if that is not possible. In this case the function will return the default as if the value was not found: >>...
[ "Return", "the", "default", "value", "if", "the", "requested", "data", "doesn", "t", "exist", ".", "If", "type", "is", "provided", "and", "is", "a", "callable", "it", "should", "convert", "the", "value", "return", "it", "or", "raise", "a", ":", "exc", ...
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L292-L322
train
Get the value of the requested key from the dict.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
_CacheControl._get_cache_value
def _get_cache_value(self, key, empty, type): """Used internally by the accessor properties.""" if type is bool: return key in self if key in self: value = self[key] if value is None: return empty elif type is not None: ...
python
def _get_cache_value(self, key, empty, type): """Used internally by the accessor properties.""" if type is bool: return key in self if key in self: value = self[key] if value is None: return empty elif type is not None: ...
[ "def", "_get_cache_value", "(", "self", ",", "key", ",", "empty", ",", "type", ")", ":", "if", "type", "is", "bool", ":", "return", "key", "in", "self", "if", "key", "in", "self", ":", "value", "=", "self", "[", "key", "]", "if", "value", "is", "...
Used internally by the accessor properties.
[ "Used", "internally", "by", "the", "accessor", "properties", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L1914-L1927
train
Used internally by the accessor properties.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
_CacheControl._set_cache_value
def _set_cache_value(self, key, value, type): """Used internally by the accessor properties.""" if type is bool: if value: self[key] = None else: self.pop(key, None) else: if value is None: self.pop(key) ...
python
def _set_cache_value(self, key, value, type): """Used internally by the accessor properties.""" if type is bool: if value: self[key] = None else: self.pop(key, None) else: if value is None: self.pop(key) ...
[ "def", "_set_cache_value", "(", "self", ",", "key", ",", "value", ",", "type", ")", ":", "if", "type", "is", "bool", ":", "if", "value", ":", "self", "[", "key", "]", "=", "None", "else", ":", "self", ".", "pop", "(", "key", ",", "None", ")", "...
Used internally by the accessor properties.
[ "Used", "internally", "by", "the", "accessor", "properties", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L1929-L1942
train
Used internally by the accessor properties.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
HeaderSet.remove
def remove(self, header): """Remove a header from the set. This raises an :exc:`KeyError` if the header is not in the set. .. versionchanged:: 0.5 In older versions a :exc:`IndexError` was raised instead of a :exc:`KeyError` if the object was missing. :param he...
python
def remove(self, header): """Remove a header from the set. This raises an :exc:`KeyError` if the header is not in the set. .. versionchanged:: 0.5 In older versions a :exc:`IndexError` was raised instead of a :exc:`KeyError` if the object was missing. :param he...
[ "def", "remove", "(", "self", ",", "header", ")", ":", "key", "=", "header", ".", "lower", "(", ")", "if", "key", "not", "in", "self", ".", "_set", ":", "raise", "KeyError", "(", "header", ")", "self", ".", "_set", ".", "remove", "(", "key", ")",...
Remove a header from the set. This raises an :exc:`KeyError` if the header is not in the set. .. versionchanged:: 0.5 In older versions a :exc:`IndexError` was raised instead of a :exc:`KeyError` if the object was missing. :param header: the header to be removed.
[ "Remove", "a", "header", "from", "the", "set", ".", "This", "raises", "an", ":", "exc", ":", "KeyError", "if", "the", "header", "is", "not", "in", "the", "set", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2045-L2064
train
Removes a header from the set.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
HeaderSet.update
def update(self, iterable): """Add all the headers from the iterable to the set. :param iterable: updates the set with the items from the iterable. """ inserted_any = False for header in iterable: key = header.lower() if key not in self._set: ...
python
def update(self, iterable): """Add all the headers from the iterable to the set. :param iterable: updates the set with the items from the iterable. """ inserted_any = False for header in iterable: key = header.lower() if key not in self._set: ...
[ "def", "update", "(", "self", ",", "iterable", ")", ":", "inserted_any", "=", "False", "for", "header", "in", "iterable", ":", "key", "=", "header", ".", "lower", "(", ")", "if", "key", "not", "in", "self", ".", "_set", ":", "self", ".", "_headers", ...
Add all the headers from the iterable to the set. :param iterable: updates the set with the items from the iterable.
[ "Add", "all", "the", "headers", "from", "the", "iterable", "to", "the", "set", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2066-L2079
train
Adds all the headers from the iterable to the set.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
HeaderSet.find
def find(self, header): """Return the index of the header in the set or return -1 if not found. :param header: the header to be looked up. """ header = header.lower() for idx, item in enumerate(self._headers): if item.lower() == header: return idx ...
python
def find(self, header): """Return the index of the header in the set or return -1 if not found. :param header: the header to be looked up. """ header = header.lower() for idx, item in enumerate(self._headers): if item.lower() == header: return idx ...
[ "def", "find", "(", "self", ",", "header", ")", ":", "header", "=", "header", ".", "lower", "(", ")", "for", "idx", ",", "item", "in", "enumerate", "(", "self", ".", "_headers", ")", ":", "if", "item", ".", "lower", "(", ")", "==", "header", ":",...
Return the index of the header in the set or return -1 if not found. :param header: the header to be looked up.
[ "Return", "the", "index", "of", "the", "header", "in", "the", "set", "or", "return", "-", "1", "if", "not", "found", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2091-L2100
train
Return the index of the header in the set or - 1 if not found.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
HeaderSet.index
def index(self, header): """Return the index of the header in the set or raise an :exc:`IndexError`. :param header: the header to be looked up. """ rv = self.find(header) if rv < 0: raise IndexError(header) return rv
python
def index(self, header): """Return the index of the header in the set or raise an :exc:`IndexError`. :param header: the header to be looked up. """ rv = self.find(header) if rv < 0: raise IndexError(header) return rv
[ "def", "index", "(", "self", ",", "header", ")", ":", "rv", "=", "self", ".", "find", "(", "header", ")", "if", "rv", "<", "0", ":", "raise", "IndexError", "(", "header", ")", "return", "rv" ]
Return the index of the header in the set or raise an :exc:`IndexError`. :param header: the header to be looked up.
[ "Return", "the", "index", "of", "the", "header", "in", "the", "set", "or", "raise", "an", ":", "exc", ":", "IndexError", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2102-L2111
train
Return the index of the header in the set or raise an exception.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
HeaderSet.clear
def clear(self): """Clear the set.""" self._set.clear() del self._headers[:] if self.on_update is not None: self.on_update(self)
python
def clear(self): """Clear the set.""" self._set.clear() del self._headers[:] if self.on_update is not None: self.on_update(self)
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_set", ".", "clear", "(", ")", "del", "self", ".", "_headers", "[", ":", "]", "if", "self", ".", "on_update", "is", "not", "None", ":", "self", ".", "on_update", "(", "self", ")" ]
Clear the set.
[ "Clear", "the", "set", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2113-L2118
train
Clear the set.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
HeaderSet.as_set
def as_set(self, preserve_casing=False): """Return the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost. :param preserve_casing: if set to `True` the items in the set returned will have the origina...
python
def as_set(self, preserve_casing=False): """Return the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost. :param preserve_casing: if set to `True` the items in the set returned will have the origina...
[ "def", "as_set", "(", "self", ",", "preserve_casing", "=", "False", ")", ":", "if", "preserve_casing", ":", "return", "set", "(", "self", ".", "_headers", ")", "return", "set", "(", "self", ".", "_set", ")" ]
Return the set as real python set type. When calling this, all the items are converted to lowercase and the ordering is lost. :param preserve_casing: if set to `True` the items in the set returned will have the original case like in the :...
[ "Return", "the", "set", "as", "real", "python", "set", "type", ".", "When", "calling", "this", "all", "the", "items", "are", "converted", "to", "lowercase", "and", "the", "ordering", "is", "lost", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2120-L2131
train
Return the set as real python set type.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
ETags.as_set
def as_set(self, include_weak=False): """Convert the `ETags` object into a python set. Per default all the weak etags are not part of this set.""" rv = set(self._strong) if include_weak: rv.update(self._weak) return rv
python
def as_set(self, include_weak=False): """Convert the `ETags` object into a python set. Per default all the weak etags are not part of this set.""" rv = set(self._strong) if include_weak: rv.update(self._weak) return rv
[ "def", "as_set", "(", "self", ",", "include_weak", "=", "False", ")", ":", "rv", "=", "set", "(", "self", ".", "_strong", ")", "if", "include_weak", ":", "rv", ".", "update", "(", "self", ".", "_weak", ")", "return", "rv" ]
Convert the `ETags` object into a python set. Per default all the weak etags are not part of this set.
[ "Convert", "the", "ETags", "object", "into", "a", "python", "set", ".", "Per", "default", "all", "the", "weak", "etags", "are", "not", "part", "of", "this", "set", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2183-L2189
train
Convert the ETags object into a python set.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
ETags.contains_raw
def contains_raw(self, etag): """When passed a quoted tag it will check if this tag is part of the set. If the tag is weak it is checked against weak and strong tags, otherwise strong only.""" etag, weak = unquote_etag(etag) if weak: return self.contains_weak(etag) ...
python
def contains_raw(self, etag): """When passed a quoted tag it will check if this tag is part of the set. If the tag is weak it is checked against weak and strong tags, otherwise strong only.""" etag, weak = unquote_etag(etag) if weak: return self.contains_weak(etag) ...
[ "def", "contains_raw", "(", "self", ",", "etag", ")", ":", "etag", ",", "weak", "=", "unquote_etag", "(", "etag", ")", "if", "weak", ":", "return", "self", ".", "contains_weak", "(", "etag", ")", "return", "self", ".", "contains", "(", "etag", ")" ]
When passed a quoted tag it will check if this tag is part of the set. If the tag is weak it is checked against weak and strong tags, otherwise strong only.
[ "When", "passed", "a", "quoted", "tag", "it", "will", "check", "if", "this", "tag", "is", "part", "of", "the", "set", ".", "If", "the", "tag", "is", "weak", "it", "is", "checked", "against", "weak", "and", "strong", "tags", "otherwise", "strong", "only...
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2211-L2218
train
Returns True if the tag is in the set False otherwise.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
ETags.to_header
def to_header(self): """Convert the etags set into a HTTP header string.""" if self.star_tag: return "*" return ", ".join( ['"%s"' % x for x in self._strong] + ['W/"%s"' % x for x in self._weak] )
python
def to_header(self): """Convert the etags set into a HTTP header string.""" if self.star_tag: return "*" return ", ".join( ['"%s"' % x for x in self._strong] + ['W/"%s"' % x for x in self._weak] )
[ "def", "to_header", "(", "self", ")", ":", "if", "self", ".", "star_tag", ":", "return", "\"*\"", "return", "\", \"", ".", "join", "(", "[", "'\"%s\"'", "%", "x", "for", "x", "in", "self", ".", "_strong", "]", "+", "[", "'W/\"%s\"'", "%", "x", "for...
Convert the etags set into a HTTP header string.
[ "Convert", "the", "etags", "set", "into", "a", "HTTP", "header", "string", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2220-L2226
train
Convert the etags set into a HTTP header string.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
IfRange.to_header
def to_header(self): """Converts the object back into an HTTP header.""" if self.date is not None: return http_date(self.date) if self.etag is not None: return quote_etag(self.etag) return ""
python
def to_header(self): """Converts the object back into an HTTP header.""" if self.date is not None: return http_date(self.date) if self.etag is not None: return quote_etag(self.etag) return ""
[ "def", "to_header", "(", "self", ")", ":", "if", "self", ".", "date", "is", "not", "None", ":", "return", "http_date", "(", "self", ".", "date", ")", "if", "self", ".", "etag", "is", "not", "None", ":", "return", "quote_etag", "(", "self", ".", "et...
Converts the object back into an HTTP header.
[ "Converts", "the", "object", "back", "into", "an", "HTTP", "header", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2271-L2277
train
Converts the object back into an HTTP header.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
Range.range_for_length
def range_for_length(self, length): """If the range is for bytes, the length is not None and there is exactly one range and it is satisfiable it returns a ``(start, stop)`` tuple, otherwise `None`. """ if self.units != "bytes" or length is None or len(self.ranges) != 1: ...
python
def range_for_length(self, length): """If the range is for bytes, the length is not None and there is exactly one range and it is satisfiable it returns a ``(start, stop)`` tuple, otherwise `None`. """ if self.units != "bytes" or length is None or len(self.ranges) != 1: ...
[ "def", "range_for_length", "(", "self", ",", "length", ")", ":", "if", "self", ".", "units", "!=", "\"bytes\"", "or", "length", "is", "None", "or", "len", "(", "self", ".", "ranges", ")", "!=", "1", ":", "return", "None", "start", ",", "end", "=", ...
If the range is for bytes, the length is not None and there is exactly one range and it is satisfiable it returns a ``(start, stop)`` tuple, otherwise `None`.
[ "If", "the", "range", "is", "for", "bytes", "the", "length", "is", "not", "None", "and", "there", "is", "exactly", "one", "range", "and", "it", "is", "satisfiable", "it", "returns", "a", "(", "start", "stop", ")", "tuple", "otherwise", "None", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2310-L2323
train
Returns a tuple of start stop that is satisfiable for the given length.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
Range.make_content_range
def make_content_range(self, length): """Creates a :class:`~werkzeug.datastructures.ContentRange` object from the current range and given content length. """ rng = self.range_for_length(length) if rng is not None: return ContentRange(self.units, rng[0], rng[1], length...
python
def make_content_range(self, length): """Creates a :class:`~werkzeug.datastructures.ContentRange` object from the current range and given content length. """ rng = self.range_for_length(length) if rng is not None: return ContentRange(self.units, rng[0], rng[1], length...
[ "def", "make_content_range", "(", "self", ",", "length", ")", ":", "rng", "=", "self", ".", "range_for_length", "(", "length", ")", "if", "rng", "is", "not", "None", ":", "return", "ContentRange", "(", "self", ".", "units", ",", "rng", "[", "0", "]", ...
Creates a :class:`~werkzeug.datastructures.ContentRange` object from the current range and given content length.
[ "Creates", "a", ":", "class", ":", "~werkzeug", ".", "datastructures", ".", "ContentRange", "object", "from", "the", "current", "range", "and", "given", "content", "length", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2325-L2331
train
Creates a : class : ~werkzeug. datastructures. ContentRange object from the current range and given content length.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
Range.to_header
def to_header(self): """Converts the object back into an HTTP header.""" ranges = [] for begin, end in self.ranges: if end is None: ranges.append("%s-" % begin if begin >= 0 else str(begin)) else: ranges.append("%s-%s" % (begin, end - 1)) ...
python
def to_header(self): """Converts the object back into an HTTP header.""" ranges = [] for begin, end in self.ranges: if end is None: ranges.append("%s-" % begin if begin >= 0 else str(begin)) else: ranges.append("%s-%s" % (begin, end - 1)) ...
[ "def", "to_header", "(", "self", ")", ":", "ranges", "=", "[", "]", "for", "begin", ",", "end", "in", "self", ".", "ranges", ":", "if", "end", "is", "None", ":", "ranges", ".", "append", "(", "\"%s-\"", "%", "begin", "if", "begin", ">=", "0", "el...
Converts the object back into an HTTP header.
[ "Converts", "the", "object", "back", "into", "an", "HTTP", "header", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2333-L2341
train
Converts the object back into an HTTP header.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
Range.to_content_range_header
def to_content_range_header(self, length): """Converts the object into `Content-Range` HTTP header, based on given length """ range_for_length = self.range_for_length(length) if range_for_length is not None: return "%s %d-%d/%d" % ( self.units, ...
python
def to_content_range_header(self, length): """Converts the object into `Content-Range` HTTP header, based on given length """ range_for_length = self.range_for_length(length) if range_for_length is not None: return "%s %d-%d/%d" % ( self.units, ...
[ "def", "to_content_range_header", "(", "self", ",", "length", ")", ":", "range_for_length", "=", "self", ".", "range_for_length", "(", "length", ")", "if", "range_for_length", "is", "not", "None", ":", "return", "\"%s %d-%d/%d\"", "%", "(", "self", ".", "units...
Converts the object into `Content-Range` HTTP header, based on given length
[ "Converts", "the", "object", "into", "Content", "-", "Range", "HTTP", "header", "based", "on", "given", "length" ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2343-L2355
train
Converts the object into a Content - Range HTTP header based on given length.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
WWWAuthenticate.set_digest
def set_digest( self, realm, nonce, qop=("auth",), opaque=None, algorithm=None, stale=False ): """Clear the auth info and enable digest auth.""" d = { "__auth_type__": "digest", "realm": realm, "nonce": nonce, "qop": dump_header(qop), }...
python
def set_digest( self, realm, nonce, qop=("auth",), opaque=None, algorithm=None, stale=False ): """Clear the auth info and enable digest auth.""" d = { "__auth_type__": "digest", "realm": realm, "nonce": nonce, "qop": dump_header(qop), }...
[ "def", "set_digest", "(", "self", ",", "realm", ",", "nonce", ",", "qop", "=", "(", "\"auth\"", ",", ")", ",", "opaque", "=", "None", ",", "algorithm", "=", "None", ",", "stale", "=", "False", ")", ":", "d", "=", "{", "\"__auth_type__\"", ":", "\"d...
Clear the auth info and enable digest auth.
[ "Clear", "the", "auth", "info", "and", "enable", "digest", "auth", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2538-L2557
train
Set the auth info and enable digest auth.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
WWWAuthenticate.to_header
def to_header(self): """Convert the stored values into a WWW-Authenticate header.""" d = dict(self) auth_type = d.pop("__auth_type__", None) or "basic" return "%s %s" % ( auth_type.title(), ", ".join( [ "%s=%s" ...
python
def to_header(self): """Convert the stored values into a WWW-Authenticate header.""" d = dict(self) auth_type = d.pop("__auth_type__", None) or "basic" return "%s %s" % ( auth_type.title(), ", ".join( [ "%s=%s" ...
[ "def", "to_header", "(", "self", ")", ":", "d", "=", "dict", "(", "self", ")", "auth_type", "=", "d", ".", "pop", "(", "\"__auth_type__\"", ",", "None", ")", "or", "\"basic\"", "return", "\"%s %s\"", "%", "(", "auth_type", ".", "title", "(", ")", ","...
Convert the stored values into a WWW-Authenticate header.
[ "Convert", "the", "stored", "values", "into", "a", "WWW", "-", "Authenticate", "header", "." ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2559-L2577
train
Convert the stored values into a WWW - Authenticate header.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
WWWAuthenticate.auth_property
def auth_property(name, doc=None): # noqa: B902 """A static helper function for subclasses to add extra authentication system properties onto a class:: class FooAuthenticate(WWWAuthenticate): special_realm = auth_property('special_realm') For more information have ...
python
def auth_property(name, doc=None): # noqa: B902 """A static helper function for subclasses to add extra authentication system properties onto a class:: class FooAuthenticate(WWWAuthenticate): special_realm = auth_property('special_realm') For more information have ...
[ "def", "auth_property", "(", "name", ",", "doc", "=", "None", ")", ":", "# noqa: B902", "def", "_set_value", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "self", ".", "pop", "(", "name", ",", "None", ")", "else", ":", "sel...
A static helper function for subclasses to add extra authentication system properties onto a class:: class FooAuthenticate(WWWAuthenticate): special_realm = auth_property('special_realm') For more information have a look at the sourcecode to see how the regular prop...
[ "A", "static", "helper", "function", "for", "subclasses", "to", "add", "extra", "authentication", "system", "properties", "onto", "a", "class", "::" ]
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2585-L2602
train
A property that provides a static helper function for subclasses to add extra authentication system properties onto a class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/datastructures.py
FileStorage.save
def save(self, dst, buffer_size=16384): """Save the file to a destination path or file object. If the destination is a file object you have to close it yourself after the call. The buffer size is the number of bytes held in memory during the copy process. It defaults to 16KB. ...
python
def save(self, dst, buffer_size=16384): """Save the file to a destination path or file object. If the destination is a file object you have to close it yourself after the call. The buffer size is the number of bytes held in memory during the copy process. It defaults to 16KB. ...
[ "def", "save", "(", "self", ",", "dst", ",", "buffer_size", "=", "16384", ")", ":", "from", "shutil", "import", "copyfileobj", "close_dst", "=", "False", "if", "isinstance", "(", "dst", ",", "string_types", ")", ":", "dst", "=", "open", "(", "dst", ","...
Save the file to a destination path or file object. If the destination is a file object you have to close it yourself after the call. The buffer size is the number of bytes held in memory during the copy process. It defaults to 16KB. For secure file saving also have a look at :func:`...
[ "Save", "the", "file", "to", "a", "destination", "path", "or", "file", "object", ".", "If", "the", "destination", "is", "a", "file", "object", "you", "have", "to", "close", "it", "yourself", "after", "the", "call", ".", "The", "buffer", "size", "is", "...
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2766-L2790
train
Save the file to a destination path or file object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pallets/werkzeug
src/werkzeug/wrappers/base_response.py
BaseResponse.force_type
def force_type(cls, response, environ=None): """Enforce that the WSGI response is a response object of the current type. Werkzeug will use the :class:`BaseResponse` internally in many situations like the exceptions. If you call :meth:`get_response` on an exception you will get back a r...
python
def force_type(cls, response, environ=None): """Enforce that the WSGI response is a response object of the current type. Werkzeug will use the :class:`BaseResponse` internally in many situations like the exceptions. If you call :meth:`get_response` on an exception you will get back a r...
[ "def", "force_type", "(", "cls", ",", "response", ",", "environ", "=", "None", ")", ":", "if", "not", "isinstance", "(", "response", ",", "BaseResponse", ")", ":", "if", "environ", "is", "None", ":", "raise", "TypeError", "(", "\"cannot convert WSGI applicat...
Enforce that the WSGI response is a response object of the current type. Werkzeug will use the :class:`BaseResponse` internally in many situations like the exceptions. If you call :meth:`get_response` on an exception you will get back a regular :class:`BaseResponse` object, even if you...
[ "Enforce", "that", "the", "WSGI", "response", "is", "a", "response", "object", "of", "the", "current", "type", ".", "Werkzeug", "will", "use", "the", ":", "class", ":", "BaseResponse", "internally", "in", "many", "situations", "like", "the", "exceptions", "....
a220671d66755a94630a212378754bb432811158
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/wrappers/base_response.py#L235-L271
train
Enforces that the WSGI response is a response object of the current one.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...