repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
praekeltfoundation/molo
molo/core/utils.py
separate_fields
def separate_fields(fields): """ Non-foreign key fields can be mapped to new article instances directly. Foreign key fields require a bit more work. This method returns a tuple, of the same format: (flat fields, nested fields) """ flat_fields = {} nested_fields = {} # exclude "id" a...
python
def separate_fields(fields): """ Non-foreign key fields can be mapped to new article instances directly. Foreign key fields require a bit more work. This method returns a tuple, of the same format: (flat fields, nested fields) """ flat_fields = {} nested_fields = {} # exclude "id" a...
Non-foreign key fields can be mapped to new article instances directly. Foreign key fields require a bit more work. This method returns a tuple, of the same format: (flat fields, nested fields)
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/utils.py#L238-L257
praekeltfoundation/molo
molo/core/utils.py
attach_image
def attach_image(field, nested_fields, page, record_keeper=None): ''' Returns a function that attaches an image to page if it exists Currenlty assumes that images have already been imported and info has been stored in record_keeper ''' if (field in nested_fields) and nested_fields[field]: ...
python
def attach_image(field, nested_fields, page, record_keeper=None): ''' Returns a function that attaches an image to page if it exists Currenlty assumes that images have already been imported and info has been stored in record_keeper ''' if (field in nested_fields) and nested_fields[field]: ...
Returns a function that attaches an image to page if it exists Currenlty assumes that images have already been imported and info has been stored in record_keeper
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/utils.py#L295-L323
praekeltfoundation/molo
molo/core/tasks.py
rotate_content
def rotate_content(day=None): """ this method gets the parameters that are needed for rotate_latest and rotate_featured_in_homepage methods, and calls them both""" # getting the content rotation settings from site settings for main in Main.objects.all(): site = main.sites_rooted_here.all().firs...
python
def rotate_content(day=None): """ this method gets the parameters that are needed for rotate_latest and rotate_featured_in_homepage methods, and calls them both""" # getting the content rotation settings from site settings for main in Main.objects.all(): site = main.sites_rooted_here.all().firs...
this method gets the parameters that are needed for rotate_latest and rotate_featured_in_homepage methods, and calls them both
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/tasks.py#L54-L71
praekeltfoundation/molo
molo/core/migrations/0001_squashed_0077_molo_page.py
run_wagtail_migration_before_core_34
def run_wagtail_migration_before_core_34(apps, schema_editor): """ Migration 34 needs migration 0040 from wagtail core and this Migration will run wagtail migration before molo core migration 34 """ db_alias = schema_editor.connection.alias emit_pre_migrate_signal(verbosity=2, interactive=Fa...
python
def run_wagtail_migration_before_core_34(apps, schema_editor): """ Migration 34 needs migration 0040 from wagtail core and this Migration will run wagtail migration before molo core migration 34 """ db_alias = schema_editor.connection.alias emit_pre_migrate_signal(verbosity=2, interactive=Fa...
Migration 34 needs migration 0040 from wagtail core and this Migration will run wagtail migration before molo core migration 34
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/migrations/0001_squashed_0077_molo_page.py#L438-L445
praekeltfoundation/molo
molo/core/templatetags/core_tags.py
load_descendant_articles_for_section
def load_descendant_articles_for_section( context, section, featured_in_homepage=None, featured_in_section=None, featured_in_latest=None, count=5): """ Returns all descendant articles (filtered using the parameters) If the `locale_code` in the context is not the main language, it will re...
python
def load_descendant_articles_for_section( context, section, featured_in_homepage=None, featured_in_section=None, featured_in_latest=None, count=5): """ Returns all descendant articles (filtered using the parameters) If the `locale_code` in the context is not the main language, it will re...
Returns all descendant articles (filtered using the parameters) If the `locale_code` in the context is not the main language, it will return the translations of the live articles.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/templatetags/core_tags.py#L262-L308
praekeltfoundation/molo
molo/core/templatetags/core_tags.py
load_child_articles_for_section
def load_child_articles_for_section( context, section, featured_in_section=None, count=5): """ Returns all child articles If the `locale_code` in the context is not the main language, it will return the translations of the live articles. """ request = context.get('request') locale = ...
python
def load_child_articles_for_section( context, section, featured_in_section=None, count=5): """ Returns all child articles If the `locale_code` in the context is not the main language, it will return the translations of the live articles. """ request = context.get('request') locale = ...
Returns all child articles If the `locale_code` in the context is not the main language, it will return the translations of the live articles.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/templatetags/core_tags.py#L312-L370
praekeltfoundation/molo
molo/core/templatetags/core_tags.py
load_child_sections_for_section
def load_child_sections_for_section(context, section, count=None): ''' Returns all child sections If the `locale_code` in the context is not the main language, it will return the translations of the live articles. ''' page = section.get_main_language_page() locale = context.get('locale_code'...
python
def load_child_sections_for_section(context, section, count=None): ''' Returns all child sections If the `locale_code` in the context is not the main language, it will return the translations of the live articles. ''' page = section.get_main_language_page() locale = context.get('locale_code'...
Returns all child sections If the `locale_code` in the context is not the main language, it will return the translations of the live articles.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/templatetags/core_tags.py#L640-L654
praekeltfoundation/molo
molo/core/templatetags/core_tags.py
load_sibling_sections
def load_sibling_sections(context, section, count=None): ''' Returns all sibling sections If the `locale_code` in the context is not the main language, it will return the translations of the live articles. ''' page = section.get_main_language_page() locale = context.get('locale_code') q...
python
def load_sibling_sections(context, section, count=None): ''' Returns all sibling sections If the `locale_code` in the context is not the main language, it will return the translations of the live articles. ''' page = section.get_main_language_page() locale = context.get('locale_code') q...
Returns all sibling sections If the `locale_code` in the context is not the main language, it will return the translations of the live articles.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/templatetags/core_tags.py#L658-L672
praekeltfoundation/molo
molo/core/templatetags/core_tags.py
handle_markdown
def handle_markdown(value): md = markdown( value, extensions=[ 'markdown.extensions.fenced_code', 'codehilite', ] ) """ For some unknown reason markdown wraps the value in <p> tags. Currently there doesn't seem to be an extension to turn this off. ...
python
def handle_markdown(value): md = markdown( value, extensions=[ 'markdown.extensions.fenced_code', 'codehilite', ] ) """ For some unknown reason markdown wraps the value in <p> tags. Currently there doesn't seem to be an extension to turn this off. ...
For some unknown reason markdown wraps the value in <p> tags. Currently there doesn't seem to be an extension to turn this off.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/templatetags/core_tags.py#L676-L691
praekeltfoundation/molo
molo/core/models.py
ImportableMixin.create_page
def create_page(self, content, class_, record_keeper=None, logger=None): ''' Robust as possible Attempts to create the page If any of the functions used to attach content to the page fail, keep going, keep a record of those errors in a context dict return the page and th...
python
def create_page(self, content, class_, record_keeper=None, logger=None): ''' Robust as possible Attempts to create the page If any of the functions used to attach content to the page fail, keep going, keep a record of those errors in a context dict return the page and th...
Robust as possible Attempts to create the page If any of the functions used to attach content to the page fail, keep going, keep a record of those errors in a context dict return the page and the context dict in a tuple
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/models.py#L477-L561
praekeltfoundation/molo
molo/core/admin.py
SectionListFilter.lookups
def lookups(self, request, model_admin): """ Returns a list of tuples. The first element in each tuple is the coded value for the option that will appear in the URL query. The second element is the human-readable name for the option that will appear in the right sidebar. ...
python
def lookups(self, request, model_admin): """ Returns a list of tuples. The first element in each tuple is the coded value for the option that will appear in the URL query. The second element is the human-readable name for the option that will appear in the right sidebar. ...
Returns a list of tuples. The first element in each tuple is the coded value for the option that will appear in the URL query. The second element is the human-readable name for the option that will appear in the right sidebar.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/admin.py#L138-L155
praekeltfoundation/molo
molo/core/admin.py
SectionListFilter.queryset
def queryset(self, request, queryset): """ Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. """ if self.value(): try: section = SectionPage.objects.get(id=self.value()) ...
python
def queryset(self, request, queryset): """ Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`. """ if self.value(): try: section = SectionPage.objects.get(id=self.value()) ...
Returns the filtered queryset based on the value provided in the query string and retrievable via `self.value()`.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/admin.py#L157-L168
praekeltfoundation/molo
molo/core/views.py
upload_file
def upload_file(request): '''Upload a Zip File Containing a single file containing media.''' if request.method == 'POST': form = MediaForm(request.POST, request.FILES) if form.is_valid(): context_dict = {} try: context_dict['copied_files'] = update_media_f...
python
def upload_file(request): '''Upload a Zip File Containing a single file containing media.''' if request.method == 'POST': form = MediaForm(request.POST, request.FILES) if form.is_valid(): context_dict = {} try: context_dict['copied_files'] = update_media_f...
Upload a Zip File Containing a single file containing media.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/views.py#L319-L335
praekeltfoundation/molo
molo/core/views.py
download_file
def download_file(request): '''Create and download a zip file containing the media file.''' if request.method == "GET": if path.exists(settings.MEDIA_ROOT): zipfile_name = 'media_%s.zip' % settings.SITE_NAME in_memory_file = BytesIO() media_zipfile = zipfile.ZipFile(...
python
def download_file(request): '''Create and download a zip file containing the media file.''' if request.method == "GET": if path.exists(settings.MEDIA_ROOT): zipfile_name = 'media_%s.zip' % settings.SITE_NAME in_memory_file = BytesIO() media_zipfile = zipfile.ZipFile(...
Create and download a zip file containing the media file.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/views.py#L339-L369
praekeltfoundation/molo
molo/core/migrations/0052_update_permissions_for_groups.py
update_permissions_for_group
def update_permissions_for_group(apps, schema_editor): ''' Update permissions for some users. Give bulk-delete permissions to moderators. Give edit permission to moderators and editors in order to display 'Main' page in the explorer. ''' db_alias = schema_editor.connection.alias try: ...
python
def update_permissions_for_group(apps, schema_editor): ''' Update permissions for some users. Give bulk-delete permissions to moderators. Give edit permission to moderators and editors in order to display 'Main' page in the explorer. ''' db_alias = schema_editor.connection.alias try: ...
Update permissions for some users. Give bulk-delete permissions to moderators. Give edit permission to moderators and editors in order to display 'Main' page in the explorer.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/migrations/0052_update_permissions_for_groups.py#L11-L61
praekeltfoundation/molo
molo/core/api/filters.py
MainLanguageFilter.filter_queryset
def filter_queryset(self, request, queryset, view): """ Returns only pages in the main language for a site """ if 'is_main_language' in request.GET: # TODO investigate possible error cases where page # does not have language return queryset.filter(lang...
python
def filter_queryset(self, request, queryset, view): """ Returns only pages in the main language for a site """ if 'is_main_language' in request.GET: # TODO investigate possible error cases where page # does not have language return queryset.filter(lang...
Returns only pages in the main language for a site
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/filters.py#L5-L14
praekeltfoundation/molo
molo/core/page_utils.py
create_recomended_articles
def create_recomended_articles(main_article, article_list): ''' Creates recommended article objects from article_list and _prepends_ to existing recommended articles. ''' # store existing recommended articles existing_recommended_articles = [ ra.recommended_article.specific for ...
python
def create_recomended_articles(main_article, article_list): ''' Creates recommended article objects from article_list and _prepends_ to existing recommended articles. ''' # store existing recommended articles existing_recommended_articles = [ ra.recommended_article.specific for ...
Creates recommended article objects from article_list and _prepends_ to existing recommended articles.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/page_utils.py#L12-L35
praekeltfoundation/molo
molo/core/page_utils.py
seperate_end_page_links
def seperate_end_page_links(stream_data): ''' Seperate out page blocks at the end of a StreamField. Accepts: List of streamfield blocks Returns: Tuple of 2 lists of blocks - (remaining body, final article) ''' stream_data_copy = list(stream_data) end_page_links = [] for block in stream...
python
def seperate_end_page_links(stream_data): ''' Seperate out page blocks at the end of a StreamField. Accepts: List of streamfield blocks Returns: Tuple of 2 lists of blocks - (remaining body, final article) ''' stream_data_copy = list(stream_data) end_page_links = [] for block in stream...
Seperate out page blocks at the end of a StreamField. Accepts: List of streamfield blocks Returns: Tuple of 2 lists of blocks - (remaining body, final article)
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/page_utils.py#L38-L55
praekeltfoundation/molo
molo/core/page_utils.py
get_pages_from_id_list
def get_pages_from_id_list(id_list): ''' Accepts: list of page ids Returns: list of specific page objects ''' page_list = [] for id_ in id_list: try: page_list.append( Page.objects.get(id=id_).specific) except ObjectDoesNotExist: logging.er...
python
def get_pages_from_id_list(id_list): ''' Accepts: list of page ids Returns: list of specific page objects ''' page_list = [] for id_ in id_list: try: page_list.append( Page.objects.get(id=id_).specific) except ObjectDoesNotExist: logging.er...
Accepts: list of page ids Returns: list of specific page objects
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/page_utils.py#L71-L85
praekeltfoundation/molo
molo/core/page_utils.py
move_page_links_to_recommended_articles
def move_page_links_to_recommended_articles(): ''' Derived from https://github.com/wagtail/wagtail/issues/2110 ''' articles = ArticlePage.objects.all() for article in articles: (remaining_blocks, linked_article_blocks) = seperate_end_page_links( article.body.stream_data) ...
python
def move_page_links_to_recommended_articles(): ''' Derived from https://github.com/wagtail/wagtail/issues/2110 ''' articles = ArticlePage.objects.all() for article in articles: (remaining_blocks, linked_article_blocks) = seperate_end_page_links( article.body.stream_data) ...
Derived from https://github.com/wagtail/wagtail/issues/2110
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/page_utils.py#L88-L111
praekeltfoundation/molo
molo/core/cookiecutter.py
cookiecutter
def cookiecutter(template, checkout=None, no_input=False, extra_context=None): """ Replacement for cookiecutter's own cookiecutter. The difference with cookiecutter's cookiecutter function is that this one doesn't automatically str() all the values passed along to the template. :param template...
python
def cookiecutter(template, checkout=None, no_input=False, extra_context=None): """ Replacement for cookiecutter's own cookiecutter. The difference with cookiecutter's cookiecutter function is that this one doesn't automatically str() all the values passed along to the template. :param template...
Replacement for cookiecutter's own cookiecutter. The difference with cookiecutter's cookiecutter function is that this one doesn't automatically str() all the values passed along to the template. :param template: A directory containing a project template directory, or a URL to a git repository...
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/cookiecutter.py#L12-L60
praekeltfoundation/molo
molo/core/api/endpoints.py
MoloPagesEndpoint.get_queryset
def get_queryset(self): ''' This is overwritten in order to not exclude drafts and pages submitted for moderation ''' request = self.request # Allow pages to be filtered to a specific type if 'type' not in request.GET: model = Page else: ...
python
def get_queryset(self): ''' This is overwritten in order to not exclude drafts and pages submitted for moderation ''' request = self.request # Allow pages to be filtered to a specific type if 'type' not in request.GET: model = Page else: ...
This is overwritten in order to not exclude drafts and pages submitted for moderation
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/endpoints.py#L48-L74
praekeltfoundation/molo
molo/core/api/endpoints.py
LanguagesAPIEndpoint.get_queryset
def get_queryset(self): ''' Only serve site-specific languages ''' request = self.request return (Languages.for_site(request.site) .languages.filter().order_by('pk'))
python
def get_queryset(self): ''' Only serve site-specific languages ''' request = self.request return (Languages.for_site(request.site) .languages.filter().order_by('pk'))
Only serve site-specific languages
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/endpoints.py#L84-L90
praekeltfoundation/molo
molo/core/api/importers.py
list_of_objects_from_api
def list_of_objects_from_api(url): ''' API only serves 20 pages by default This fetches info on all of items and return them as a list Assumption: limit of API is not less than 20 ''' response = requests.get(url) content = json.loads(response.content) count = content["meta"]["total_cou...
python
def list_of_objects_from_api(url): ''' API only serves 20 pages by default This fetches info on all of items and return them as a list Assumption: limit of API is not less than 20 ''' response = requests.get(url) content = json.loads(response.content) count = content["meta"]["total_cou...
API only serves 20 pages by default This fetches info on all of items and return them as a list Assumption: limit of API is not less than 20
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L53-L76
praekeltfoundation/molo
molo/core/api/importers.py
PageImporter.get_content_from_url
def get_content_from_url(self, base_url): """ Sections can have SectionPage and ArticlePage child objects. These have different fields, and thus have to be treated differently. """ # assemble url base_url = base_url.rstrip("/") url = base_url + API_PAGES_E...
python
def get_content_from_url(self, base_url): """ Sections can have SectionPage and ArticlePage child objects. These have different fields, and thus have to be treated differently. """ # assemble url base_url = base_url.rstrip("/") url = base_url + API_PAGES_E...
Sections can have SectionPage and ArticlePage child objects. These have different fields, and thus have to be treated differently.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L87-L111
praekeltfoundation/molo
molo/core/api/importers.py
SectionPageImporter.save
def save(self, indexes, parent_id): """ Save the selected section. This will save the selected section as well as its direct child pages obtained through the ?child_of query parameter. The ?descendant_of query parameter is probably better suited because it all pages under that p...
python
def save(self, indexes, parent_id): """ Save the selected section. This will save the selected section as well as its direct child pages obtained through the ?child_of query parameter. The ?descendant_of query parameter is probably better suited because it all pages under that p...
Save the selected section. This will save the selected section as well as its direct child pages obtained through the ?child_of query parameter. The ?descendant_of query parameter is probably better suited because it all pages under that part of the tree will be obtained. The problem ,...
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L229-L248
praekeltfoundation/molo
molo/core/api/importers.py
ImageImporter.get_image_details
def get_image_details(self): ''' Create a reference of site images by hash If there are duplicate images, only store the first and create warnings for other images ''' if Image.objects.count() == 0: return None total = Image.objects.count() c...
python
def get_image_details(self): ''' Create a reference of site images by hash If there are duplicate images, only store the first and create warnings for other images ''' if Image.objects.count() == 0: return None total = Image.objects.count() c...
Create a reference of site images by hash If there are duplicate images, only store the first and create warnings for other images
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L417-L446
praekeltfoundation/molo
molo/core/api/importers.py
ImageImporter.fetch_and_create_image
def fetch_and_create_image(self, url, image_title): ''' fetches, creates image object returns tuple with Image object and context dictionary containing request URL ''' context = { "file_url": url, "foreign_title": image_title, } t...
python
def fetch_and_create_image(self, url, image_title): ''' fetches, creates image object returns tuple with Image object and context dictionary containing request URL ''' context = { "file_url": url, "foreign_title": image_title, } t...
fetches, creates image object returns tuple with Image object and context dictionary containing request URL
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L453-L480
praekeltfoundation/molo
molo/core/api/importers.py
ImageImporter.import_image
def import_image(self, image_id): ''' Imports and returns tuple with image and context dict Input: foreign image ID Output: (Image: imported image, Dict: info about import) Side effects: If Importer object has a record_keeper, it will update the record of foreign to lo...
python
def import_image(self, image_id): ''' Imports and returns tuple with image and context dict Input: foreign image ID Output: (Image: imported image, Dict: info about import) Side effects: If Importer object has a record_keeper, it will update the record of foreign to lo...
Imports and returns tuple with image and context dict Input: foreign image ID Output: (Image: imported image, Dict: info about import) Side effects: If Importer object has a record_keeper, it will update the record of foreign to local images. Attempts to avoid duplicates by m...
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L482-L550
praekeltfoundation/molo
molo/core/api/importers.py
ImageImporter.import_images
def import_images(self): ''' Fetches all images from site Handles Errors in creation process Updates record_keeper Logs the result of each attempt to create an image ''' self.log(ACTION, "Importing Images") try: images = list_of_objects_from_a...
python
def import_images(self): ''' Fetches all images from site Handles Errors in creation process Updates record_keeper Logs the result of each attempt to create an image ''' self.log(ACTION, "Importing Images") try: images = list_of_objects_from_a...
Fetches all images from site Handles Errors in creation process Updates record_keeper Logs the result of each attempt to create an image
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L552-L588
praekeltfoundation/molo
molo/core/api/importers.py
LanguageImporter.get_language_ids
def get_language_ids(self): ''' Return list of foreign language IDs from API language endpoint TODO: add in validation before creating languages ''' languages = list_of_objects_from_api(self.language_url) language_ids = [] for language in languages: ...
python
def get_language_ids(self): ''' Return list of foreign language IDs from API language endpoint TODO: add in validation before creating languages ''' languages = list_of_objects_from_api(self.language_url) language_ids = [] for language in languages: ...
Return list of foreign language IDs from API language endpoint TODO: add in validation before creating languages
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L598-L609
praekeltfoundation/molo
molo/core/api/importers.py
ContentImporter.recreate_relationships
def recreate_relationships(self, class_, attribute_name, key): ''' Recreates one-to-many relationship ''' iterable = self.record_keeper.foreign_to_many_foreign_map[key] for foreign_page_id, foreign_page_id_list in iteritems(iterable): # Assumption: local page has bee...
python
def recreate_relationships(self, class_, attribute_name, key): ''' Recreates one-to-many relationship ''' iterable = self.record_keeper.foreign_to_many_foreign_map[key] for foreign_page_id, foreign_page_id_list in iteritems(iterable): # Assumption: local page has bee...
Recreates one-to-many relationship
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L633-L665
praekeltfoundation/molo
molo/core/api/importers.py
ContentImporter.recreate_relationship
def recreate_relationship(self, attribute_name, key): ''' Recreates one-to-one relationship ''' iterable = self.record_keeper.foreign_to_foreign_map["banner_link_page"] # noqa for foreign_page_id, linked_page_foreign_id in iteritems(iterable): # get local banner page...
python
def recreate_relationship(self, attribute_name, key): ''' Recreates one-to-one relationship ''' iterable = self.record_keeper.foreign_to_foreign_map["banner_link_page"] # noqa for foreign_page_id, linked_page_foreign_id in iteritems(iterable): # get local banner page...
Recreates one-to-one relationship
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L667-L685
praekeltfoundation/molo
molo/core/api/importers.py
ContentImporter.recreate_article_body
def recreate_article_body(self): ''' Handles case where article body contained page or image. Assumes all articles and images have been created. ''' for foreign_id, body in iteritems(self.record_keeper.article_bodies): try: local_page_id = self.record...
python
def recreate_article_body(self): ''' Handles case where article body contained page or image. Assumes all articles and images have been created. ''' for foreign_id, body in iteritems(self.record_keeper.article_bodies): try: local_page_id = self.record...
Handles case where article body contained page or image. Assumes all articles and images have been created.
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L718-L755
praekeltfoundation/molo
molo/core/api/importers.py
ContentImporter.get_foreign_page_id_from_type
def get_foreign_page_id_from_type(self, page_type): ''' Get the foreign page id based on type Only works for index pages ''' # TODO: log this response = requests.get("{}pages/?type={}".format( self.api_url, page_type)) content = json.loads(response.co...
python
def get_foreign_page_id_from_type(self, page_type): ''' Get the foreign page id based on type Only works for index pages ''' # TODO: log this response = requests.get("{}pages/?type={}".format( self.api_url, page_type)) content = json.loads(response.co...
Get the foreign page id based on type Only works for index pages
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L757-L767
praekeltfoundation/molo
molo/core/api/importers.py
ContentImporter.attach_translated_content
def attach_translated_content(self, local_main_lang_page, content, locale): ''' Wrapper for attach_page Creates the content Then attaches a language relation from the main language page to the newly created Page Note: we get the parent ...
python
def attach_translated_content(self, local_main_lang_page, content, locale): ''' Wrapper for attach_page Creates the content Then attaches a language relation from the main language page to the newly created Page Note: we get the parent ...
Wrapper for attach_page Creates the content Then attaches a language relation from the main language page to the newly created Page Note: we get the parent from the main language page
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L820-L852
praekeltfoundation/molo
molo/core/api/importers.py
ContentImporter.copy_page_and_children
def copy_page_and_children(self, foreign_id, parent_id, depth=0): ''' Recusively copies over pages, their translations, and child pages ''' url = "{}/api/v2/pages/{}/".format(self.base_url, foreign_id) self.log(ACTION, "Requesting Data", {"url": url}, depth) try: ...
python
def copy_page_and_children(self, foreign_id, parent_id, depth=0): ''' Recusively copies over pages, their translations, and child pages ''' url = "{}/api/v2/pages/{}/".format(self.base_url, foreign_id) self.log(ACTION, "Requesting Data", {"url": url}, depth) try: ...
Recusively copies over pages, their translations, and child pages
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L854-L926
praekeltfoundation/molo
molo/core/api/importers.py
ContentImporter.copy_children
def copy_children(self, foreign_id, existing_node): ''' Initiates copying of tree, with existing_node acting as root ''' url = "{}/api/v2/pages/{}/".format(self.base_url, foreign_id) self.log( ACTION, "Copying Children", {"existing node type": ...
python
def copy_children(self, foreign_id, existing_node): ''' Initiates copying of tree, with existing_node acting as root ''' url = "{}/api/v2/pages/{}/".format(self.base_url, foreign_id) self.log( ACTION, "Copying Children", {"existing node type": ...
Initiates copying of tree, with existing_node acting as root
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L928-L954
praekeltfoundation/molo
molo/core/api/importers.py
Logger.get_email_logs
def get_email_logs(self): ''' Returns a string representation of logs. Only displays errors and warnings in the email logs to avoid being verbose ''' message = "" for log in self.record: if log["log_type"] in [ERROR, WARNING]: message ...
python
def get_email_logs(self): ''' Returns a string representation of logs. Only displays errors and warnings in the email logs to avoid being verbose ''' message = "" for log in self.record: if log["log_type"] in [ERROR, WARNING]: message ...
Returns a string representation of logs. Only displays errors and warnings in the email logs to avoid being verbose
https://github.com/praekeltfoundation/molo/blob/57702fda4fab261d67591415f7d46bc98fa38525/molo/core/api/importers.py#L978-L990
blockchain-certificates/cert-core
cert_core/__init__.py
chain_to_bitcoin_network
def chain_to_bitcoin_network(chain): """ Used or bitcoin.SelectParams :param chain: :return: """ if chain == Chain.bitcoin_mainnet: return SYS_NETWORK_BITCOIN_MAINNET elif chain == Chain.bitcoin_testnet: return SYS_NETWORK_BITCOIN_TESTNET elif chain == Chain.bitcoin_regte...
python
def chain_to_bitcoin_network(chain): """ Used or bitcoin.SelectParams :param chain: :return: """ if chain == Chain.bitcoin_mainnet: return SYS_NETWORK_BITCOIN_MAINNET elif chain == Chain.bitcoin_testnet: return SYS_NETWORK_BITCOIN_TESTNET elif chain == Chain.bitcoin_regte...
Used or bitcoin.SelectParams :param chain: :return:
https://github.com/blockchain-certificates/cert-core/blob/b6a6c29bc87ccd9d2cf15a2c4301f986cfb31453/cert_core/__init__.py#L103-L121
Vauxoo/travis2docker
ci/appveyor-download.py
ensure_dirs
def ensure_dirs(filename): """Make sure the directories exist for `filename`.""" dirname, _ = os.path.split(filename) if dirname and not os.path.exists(dirname): os.makedirs(dirname)
python
def ensure_dirs(filename): """Make sure the directories exist for `filename`.""" dirname, _ = os.path.split(filename) if dirname and not os.path.exists(dirname): os.makedirs(dirname)
Make sure the directories exist for `filename`.
https://github.com/Vauxoo/travis2docker/blob/a61349442d864f1cbc37ee6e2e288da97d0507ea/ci/appveyor-download.py#L65-L69
blockchain-certificates/cert-core
cert_core/cert_store/certificate_store.py
CertificateStore.get_certificate
def get_certificate(self, certificate_uid): """ Returns a certificate. Propagates KeyError if key isn't found :param certificate_uid: :return: """ certificate_json = self.get_certificate_json(certificate_uid) return model.to_certificate_model(certificate_json)
python
def get_certificate(self, certificate_uid): """ Returns a certificate. Propagates KeyError if key isn't found :param certificate_uid: :return: """ certificate_json = self.get_certificate_json(certificate_uid) return model.to_certificate_model(certificate_json)
Returns a certificate. Propagates KeyError if key isn't found :param certificate_uid: :return:
https://github.com/blockchain-certificates/cert-core/blob/b6a6c29bc87ccd9d2cf15a2c4301f986cfb31453/cert_core/cert_store/certificate_store.py#L20-L27
blockchain-certificates/cert-core
cert_core/cert_store/certificate_store.py
CertificateStore.get_certificate_json
def get_certificate_json(self, certificate_uid): """ Returns certificate as json. Propagates KeyError if key isn't found :param certificate_uid: :return: """ if certificate_uid.startswith(URN_UUID_PREFIX): uid = certificate_uid[len(URN_UUID_PREFIX):] ...
python
def get_certificate_json(self, certificate_uid): """ Returns certificate as json. Propagates KeyError if key isn't found :param certificate_uid: :return: """ if certificate_uid.startswith(URN_UUID_PREFIX): uid = certificate_uid[len(URN_UUID_PREFIX):] ...
Returns certificate as json. Propagates KeyError if key isn't found :param certificate_uid: :return:
https://github.com/blockchain-certificates/cert-core/blob/b6a6c29bc87ccd9d2cf15a2c4301f986cfb31453/cert_core/cert_store/certificate_store.py#L29-L47
blockchain-certificates/cert-core
cert_core/cert_store/certificate_store.py
CertificateStore._get_certificate_raw
def _get_certificate_raw(self, certificate_uid): """ Returns certificate as raw bytes. Per kvstore contract, raises an KeyError if key isn't found. :param certificate_uid: :return: """ cert_file_bytes = self.kv_store.get(certificate_uid_to_filename(certificate_uid)) ...
python
def _get_certificate_raw(self, certificate_uid): """ Returns certificate as raw bytes. Per kvstore contract, raises an KeyError if key isn't found. :param certificate_uid: :return: """ cert_file_bytes = self.kv_store.get(certificate_uid_to_filename(certificate_uid)) ...
Returns certificate as raw bytes. Per kvstore contract, raises an KeyError if key isn't found. :param certificate_uid: :return:
https://github.com/blockchain-certificates/cert-core/blob/b6a6c29bc87ccd9d2cf15a2c4301f986cfb31453/cert_core/cert_store/certificate_store.py#L49-L56
blockchain-certificates/cert-core
cert_core/cert_store/certificate_store.py
V1AwareCertificateStore.get_certificate
def get_certificate(self, certificate_uid): """ Returns certificate as byte array. We need this for v1 certs, which compute a binary hash. Raises KeyError if not found :param certificate_uid: :return: """ logging.debug('Retrieving certificate for uid=%s', certific...
python
def get_certificate(self, certificate_uid): """ Returns certificate as byte array. We need this for v1 certs, which compute a binary hash. Raises KeyError if not found :param certificate_uid: :return: """ logging.debug('Retrieving certificate for uid=%s', certific...
Returns certificate as byte array. We need this for v1 certs, which compute a binary hash. Raises KeyError if not found :param certificate_uid: :return:
https://github.com/blockchain-certificates/cert-core/blob/b6a6c29bc87ccd9d2cf15a2c4301f986cfb31453/cert_core/cert_store/certificate_store.py#L72-L94
blockchain-certificates/cert-core
cert_core/cert_store/certificate_store.py
V1AwareCertificateStore._find_certificate_metadata
def _find_certificate_metadata(self, uid=None): """ Find certificate by certificate uid :param uid: certificate uid :return: certificate from certificates collection """ certificate = self.db.certificates.find_one({'uid': uid}) return certificate
python
def _find_certificate_metadata(self, uid=None): """ Find certificate by certificate uid :param uid: certificate uid :return: certificate from certificates collection """ certificate = self.db.certificates.find_one({'uid': uid}) return certificate
Find certificate by certificate uid :param uid: certificate uid :return: certificate from certificates collection
https://github.com/blockchain-certificates/cert-core/blob/b6a6c29bc87ccd9d2cf15a2c4301f986cfb31453/cert_core/cert_store/certificate_store.py#L96-L103
Vauxoo/travis2docker
src/travis2docker/git_run.py
GitRun.run
def run(self, cmd): """Execute git command in bash""" cmd = ['git', '--git-dir=%s' % self.path] + cmd print("cmd list", cmd) print("cmd", ' '.join(cmd)) res = None try: res = subprocess.check_output(cmd) except BaseException: pass i...
python
def run(self, cmd): """Execute git command in bash""" cmd = ['git', '--git-dir=%s' % self.path] + cmd print("cmd list", cmd) print("cmd", ' '.join(cmd)) res = None try: res = subprocess.check_output(cmd) except BaseException: pass i...
Execute git command in bash
https://github.com/Vauxoo/travis2docker/blob/a61349442d864f1cbc37ee6e2e288da97d0507ea/src/travis2docker/git_run.py#L61-L76
Vauxoo/travis2docker
src/travis2docker/git_run.py
GitRun.update
def update(self): """Get a repository git or update it""" if not os.path.isdir(os.path.join(self.path)): os.makedirs(self.path) if not os.path.isdir(os.path.join(self.path, 'refs')): subprocess.check_output([ 'git', 'clone', '--bare', self.repo_git, self.p...
python
def update(self): """Get a repository git or update it""" if not os.path.isdir(os.path.join(self.path)): os.makedirs(self.path) if not os.path.isdir(os.path.join(self.path, 'refs')): subprocess.check_output([ 'git', 'clone', '--bare', self.repo_git, self.p...
Get a repository git or update it
https://github.com/Vauxoo/travis2docker/blob/a61349442d864f1cbc37ee6e2e288da97d0507ea/src/travis2docker/git_run.py#L100-L114
mrogaski/django-discord-bind
discord_bind/views.py
oauth_session
def oauth_session(request, state=None, token=None): """ Constructs the OAuth2 session object. """ if settings.DISCORD_REDIRECT_URI is not None: redirect_uri = settings.DISCORD_REDIRECT_URI else: redirect_uri = request.build_absolute_uri( reverse('discord_bind_callback')) scop...
python
def oauth_session(request, state=None, token=None): """ Constructs the OAuth2 session object. """ if settings.DISCORD_REDIRECT_URI is not None: redirect_uri = settings.DISCORD_REDIRECT_URI else: redirect_uri = request.build_absolute_uri( reverse('discord_bind_callback')) scop...
Constructs the OAuth2 session object.
https://github.com/mrogaski/django-discord-bind/blob/3848ceb2c2ebcea57595a56919ee2f990ea1a4b1/discord_bind/views.py#L50-L63
Vauxoo/travis2docker
src/travis2docker/travis2docker.py
Travis2Docker.copy_path
def copy_path(self, path): """ :param paths list: List of paths to copy """ src = os.path.expandvars(os.path.expanduser(path)) basename = os.path.basename(src) dest_path = os.path.expandvars(os.path.expanduser( os.path.join(self.curr_work_path, basename))) ...
python
def copy_path(self, path): """ :param paths list: List of paths to copy """ src = os.path.expandvars(os.path.expanduser(path)) basename = os.path.basename(src) dest_path = os.path.expandvars(os.path.expanduser( os.path.join(self.curr_work_path, basename))) ...
:param paths list: List of paths to copy
https://github.com/Vauxoo/travis2docker/blob/a61349442d864f1cbc37ee6e2e288da97d0507ea/src/travis2docker/travis2docker.py#L324-L344
edx/edx-val
edxval/migrations/0011_data__add_audio_mp3_profile.py
create_audio_mp3_profile
def create_audio_mp3_profile(apps, schema_editor): """ Create audio_mp3 profile """ Profile = apps.get_model('edxval', 'Profile') Profile.objects.get_or_create(profile_name=AUDIO_MP3_PROFILE)
python
def create_audio_mp3_profile(apps, schema_editor): """ Create audio_mp3 profile """ Profile = apps.get_model('edxval', 'Profile') Profile.objects.get_or_create(profile_name=AUDIO_MP3_PROFILE)
Create audio_mp3 profile
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/migrations/0011_data__add_audio_mp3_profile.py#L11-L14
edx/edx-val
edxval/migrations/0011_data__add_audio_mp3_profile.py
delete_audio_mp3_profile
def delete_audio_mp3_profile(apps, schema_editor): """ Delete audio_mp3 profile """ Profile = apps.get_model('edxval', 'Profile') Profile.objects.filter(profile_name=AUDIO_MP3_PROFILE).delete()
python
def delete_audio_mp3_profile(apps, schema_editor): """ Delete audio_mp3 profile """ Profile = apps.get_model('edxval', 'Profile') Profile.objects.filter(profile_name=AUDIO_MP3_PROFILE).delete()
Delete audio_mp3 profile
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/migrations/0011_data__add_audio_mp3_profile.py#L17-L20
edx/edx-val
edxval/transcript_utils.py
Transcript.generate_sjson_from_srt
def generate_sjson_from_srt(srt_subs): """ Generate transcripts from sjson to SubRip (*.srt). Arguments: srt_subs(SubRip): "SRT" subs object Returns: Subs converted to "SJSON" format. """ sub_starts = [] sub_ends = [] sub_texts = ...
python
def generate_sjson_from_srt(srt_subs): """ Generate transcripts from sjson to SubRip (*.srt). Arguments: srt_subs(SubRip): "SRT" subs object Returns: Subs converted to "SJSON" format. """ sub_starts = [] sub_ends = [] sub_texts = ...
Generate transcripts from sjson to SubRip (*.srt). Arguments: srt_subs(SubRip): "SRT" subs object Returns: Subs converted to "SJSON" format.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/transcript_utils.py#L24-L47
edx/edx-val
edxval/transcript_utils.py
Transcript.generate_srt_from_sjson
def generate_srt_from_sjson(sjson_subs): """ Generate transcripts from sjson to SubRip (*.srt). Arguments: sjson_subs (dict): `sjson` subs. Returns: Subtitles in SRT format. """ output = '' equal_len = len(sjson_subs['start']) == len(sj...
python
def generate_srt_from_sjson(sjson_subs): """ Generate transcripts from sjson to SubRip (*.srt). Arguments: sjson_subs (dict): `sjson` subs. Returns: Subtitles in SRT format. """ output = '' equal_len = len(sjson_subs['start']) == len(sj...
Generate transcripts from sjson to SubRip (*.srt). Arguments: sjson_subs (dict): `sjson` subs. Returns: Subtitles in SRT format.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/transcript_utils.py#L50-L76
edx/edx-val
edxval/transcript_utils.py
Transcript.convert
def convert(cls, content, input_format, output_format): """ Convert transcript `content` from `input_format` to `output_format`. Arguments: content: Transcript content byte-stream. input_format: Input transcript format. output_format: Output transcript format...
python
def convert(cls, content, input_format, output_format): """ Convert transcript `content` from `input_format` to `output_format`. Arguments: content: Transcript content byte-stream. input_format: Input transcript format. output_format: Output transcript format...
Convert transcript `content` from `input_format` to `output_format`. Arguments: content: Transcript content byte-stream. input_format: Input transcript format. output_format: Output transcript format. Accepted input formats: sjson, srt. Accepted output forma...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/transcript_utils.py#L79-L120
edx/edx-val
edxval/migrations/0004_data__add_hls_profile.py
create_hls_profile
def create_hls_profile(apps, schema_editor): """ Create hls profile """ Profile = apps.get_model("edxval", "Profile") Profile.objects.get_or_create(profile_name=HLS_PROFILE)
python
def create_hls_profile(apps, schema_editor): """ Create hls profile """ Profile = apps.get_model("edxval", "Profile") Profile.objects.get_or_create(profile_name=HLS_PROFILE)
Create hls profile
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/migrations/0004_data__add_hls_profile.py#L11-L14
edx/edx-val
edxval/migrations/0004_data__add_hls_profile.py
delete_hls_profile
def delete_hls_profile(apps, schema_editor): """ Delete hls profile """ Profile = apps.get_model("edxval", "Profile") Profile.objects.filter(profile_name=HLS_PROFILE).delete()
python
def delete_hls_profile(apps, schema_editor): """ Delete hls profile """ Profile = apps.get_model("edxval", "Profile") Profile.objects.filter(profile_name=HLS_PROFILE).delete()
Delete hls profile
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/migrations/0004_data__add_hls_profile.py#L17-L20
edx/edx-val
edxval/migrations/0002_data__default_profiles.py
create_default_profiles
def create_default_profiles(apps, schema_editor): """ Add default profiles """ Profile = apps.get_model("edxval", "Profile") for profile in DEFAULT_PROFILES: Profile.objects.get_or_create(profile_name=profile)
python
def create_default_profiles(apps, schema_editor): """ Add default profiles """ Profile = apps.get_model("edxval", "Profile") for profile in DEFAULT_PROFILES: Profile.objects.get_or_create(profile_name=profile)
Add default profiles
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/migrations/0002_data__default_profiles.py#L17-L21
edx/edx-val
edxval/migrations/0002_data__default_profiles.py
delete_default_profiles
def delete_default_profiles(apps, schema_editor): """ Remove default profiles """ Profile = apps.get_model("edxval", "Profile") Profile.objects.filter(profile_name__in=DEFAULT_PROFILES).delete()
python
def delete_default_profiles(apps, schema_editor): """ Remove default profiles """ Profile = apps.get_model("edxval", "Profile") Profile.objects.filter(profile_name__in=DEFAULT_PROFILES).delete()
Remove default profiles
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/migrations/0002_data__default_profiles.py#L24-L27
edx/edx-val
edxval/serializers.py
TranscriptSerializer.validate
def validate(self, data): """ Validates the transcript data. """ video_id = self.context.get('video_id') video = Video.get_or_none(edx_video_id=video_id) if not video: raise serializers.ValidationError('Video "{video_id}" is not valid.'.format(video_id=video_i...
python
def validate(self, data): """ Validates the transcript data. """ video_id = self.context.get('video_id') video = Video.get_or_none(edx_video_id=video_id) if not video: raise serializers.ValidationError('Video "{video_id}" is not valid.'.format(video_id=video_i...
Validates the transcript data.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/serializers.py#L78-L88
edx/edx-val
edxval/serializers.py
CourseSerializer.to_internal_value
def to_internal_value(self, data): """ Convert data into CourseVideo instance and image filename tuple. """ course_id = data course_video = image = '' if data: if isinstance(data, dict): (course_id, image), = list(data.items()) cou...
python
def to_internal_value(self, data): """ Convert data into CourseVideo instance and image filename tuple. """ course_id = data course_video = image = '' if data: if isinstance(data, dict): (course_id, image), = list(data.items()) cou...
Convert data into CourseVideo instance and image filename tuple.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/serializers.py#L109-L122
edx/edx-val
edxval/serializers.py
VideoSerializer.validate
def validate(self, data): """ Check that the video data is valid. """ if data is not None and not isinstance(data, dict): raise serializers.ValidationError("Invalid data") try: profiles = [ev["profile"] for ev in data.get("encoded_videos", [])] ...
python
def validate(self, data): """ Check that the video data is valid. """ if data is not None and not isinstance(data, dict): raise serializers.ValidationError("Invalid data") try: profiles = [ev["profile"] for ev in data.get("encoded_videos", [])] ...
Check that the video data is valid.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/serializers.py#L155-L175
edx/edx-val
edxval/serializers.py
VideoSerializer.create
def create(self, validated_data): """ Create the video and its nested resources. """ courses = validated_data.pop("courses", []) encoded_videos = validated_data.pop("encoded_videos", []) video = Video.objects.create(**validated_data) EncodedVideo.objects.bulk_cr...
python
def create(self, validated_data): """ Create the video and its nested resources. """ courses = validated_data.pop("courses", []) encoded_videos = validated_data.pop("encoded_videos", []) video = Video.objects.create(**validated_data) EncodedVideo.objects.bulk_cr...
Create the video and its nested resources.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/serializers.py#L177-L200
edx/edx-val
edxval/serializers.py
VideoSerializer.update
def update(self, instance, validated_data): """ Update an existing video resource. """ instance.status = validated_data["status"] instance.client_video_id = validated_data["client_video_id"] instance.duration = validated_data["duration"] instance.save() #...
python
def update(self, instance, validated_data): """ Update an existing video resource. """ instance.status = validated_data["status"] instance.client_video_id = validated_data["client_video_id"] instance.duration = validated_data["duration"] instance.save() #...
Update an existing video resource.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/serializers.py#L202-L228
edx/edx-val
edxval/utils.py
get_video_image_storage
def get_video_image_storage(): """ Return the configured django storage backend. """ if hasattr(settings, 'VIDEO_IMAGE_SETTINGS'): return get_storage_class( settings.VIDEO_IMAGE_SETTINGS.get('STORAGE_CLASS'), )(**settings.VIDEO_IMAGE_SETTINGS.get('STORAGE_KWARGS', {})) el...
python
def get_video_image_storage(): """ Return the configured django storage backend. """ if hasattr(settings, 'VIDEO_IMAGE_SETTINGS'): return get_storage_class( settings.VIDEO_IMAGE_SETTINGS.get('STORAGE_CLASS'), )(**settings.VIDEO_IMAGE_SETTINGS.get('STORAGE_KWARGS', {})) el...
Return the configured django storage backend.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/utils.py#L150-L161
edx/edx-val
edxval/utils.py
get_video_transcript_storage
def get_video_transcript_storage(): """ Return the configured django storage backend for video transcripts. """ if hasattr(settings, 'VIDEO_TRANSCRIPTS_SETTINGS'): return get_storage_class( settings.VIDEO_TRANSCRIPTS_SETTINGS.get('STORAGE_CLASS'), )(**settings.VIDEO_TRANSCRIP...
python
def get_video_transcript_storage(): """ Return the configured django storage backend for video transcripts. """ if hasattr(settings, 'VIDEO_TRANSCRIPTS_SETTINGS'): return get_storage_class( settings.VIDEO_TRANSCRIPTS_SETTINGS.get('STORAGE_CLASS'), )(**settings.VIDEO_TRANSCRIP...
Return the configured django storage backend for video transcripts.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/utils.py#L175-L186
edx/edx-val
edxval/utils.py
create_file_in_fs
def create_file_in_fs(file_data, file_name, file_system, static_dir): """ Writes file in specific file system. Arguments: file_data (str): Data to store into the file. file_name (str): File name of the file to be created. file_system (OSFS): Import file system. static_dir (s...
python
def create_file_in_fs(file_data, file_name, file_system, static_dir): """ Writes file in specific file system. Arguments: file_data (str): Data to store into the file. file_name (str): File name of the file to be created. file_system (OSFS): Import file system. static_dir (s...
Writes file in specific file system. Arguments: file_data (str): Data to store into the file. file_name (str): File name of the file to be created. file_system (OSFS): Import file system. static_dir (str): The Directory to retrieve transcript file.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/utils.py#L189-L200
edx/edx-val
edxval/utils.py
get_transcript_format
def get_transcript_format(transcript_content): """ Returns transcript format. Arguments: transcript_content (str): Transcript file content. """ try: sjson_obj = json.loads(transcript_content) except ValueError: # With error handling (set to 'ERROR_RAISE'), we will be get...
python
def get_transcript_format(transcript_content): """ Returns transcript format. Arguments: transcript_content (str): Transcript file content. """ try: sjson_obj = json.loads(transcript_content) except ValueError: # With error handling (set to 'ERROR_RAISE'), we will be get...
Returns transcript format. Arguments: transcript_content (str): Transcript file content.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/utils.py#L203-L218
edx/edx-val
edxval/views.py
MultipleFieldLookupMixin.get_object
def get_object(self): """ Returns an object instance that should be used for detail views. """ queryset = self.get_queryset() # Get the base queryset queryset = self.filter_queryset(queryset) # Apply any filter backends filter = {} # pylint: disable=W0622 ...
python
def get_object(self): """ Returns an object instance that should be used for detail views. """ queryset = self.get_queryset() # Get the base queryset queryset = self.filter_queryset(queryset) # Apply any filter backends filter = {} # pylint: disable=W0622 ...
Returns an object instance that should be used for detail views.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/views.py#L62-L71
edx/edx-val
edxval/views.py
VideoTranscriptView.post
def post(self, request): """ Creates a video transcript instance with the given information. Arguments: request: A WSGI request. """ attrs = ('video_id', 'name', 'language_code', 'provider', 'file_format') missing = [attr for attr in attrs if attr not in requ...
python
def post(self, request): """ Creates a video transcript instance with the given information. Arguments: request: A WSGI request. """ attrs = ('video_id', 'name', 'language_code', 'provider', 'file_format') missing = [attr for attr in attrs if attr not in requ...
Creates a video transcript instance with the given information. Arguments: request: A WSGI request.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/views.py#L117-L169
edx/edx-val
edxval/views.py
VideoStatusView.patch
def patch(self, request): """ Update the status of a video. """ attrs = ('edx_video_id', 'status') missing = [attr for attr in attrs if attr not in request.data] if missing: return Response( status=status.HTTP_400_BAD_REQUEST, d...
python
def patch(self, request): """ Update the status of a video. """ attrs = ('edx_video_id', 'status') missing = [attr for attr in attrs if attr not in request.data] if missing: return Response( status=status.HTTP_400_BAD_REQUEST, d...
Update the status of a video.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/views.py#L183-L217
edx/edx-val
edxval/views.py
VideoImagesView.post
def post(self, request): """ Update a course video image instance with auto generated image names. """ attrs = ('course_id', 'edx_video_id', 'generated_images') missing = [attr for attr in attrs if attr not in request.data] if missing: return Response( ...
python
def post(self, request): """ Update a course video image instance with auto generated image names. """ attrs = ('course_id', 'edx_video_id', 'generated_images') missing = [attr for attr in attrs if attr not in request.data] if missing: return Response( ...
Update a course video image instance with auto generated image names.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/views.py#L226-L264
edx/edx-val
edxval/views.py
HLSMissingVideoView.post
def post(self, request): """ Retrieve video IDs that are missing HLS profiles. This endpoint supports 2 types of input data: 1. If we want a batch of video ids which are missing HLS profile irrespective of their courses, the request data should be in following format: ...
python
def post(self, request): """ Retrieve video IDs that are missing HLS profiles. This endpoint supports 2 types of input data: 1. If we want a batch of video ids which are missing HLS profile irrespective of their courses, the request data should be in following format: ...
Retrieve video IDs that are missing HLS profiles. This endpoint supports 2 types of input data: 1. If we want a batch of video ids which are missing HLS profile irrespective of their courses, the request data should be in following format: { 'batch_size': 50, ...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/views.py#L273-L335
edx/edx-val
edxval/views.py
HLSMissingVideoView.put
def put(self, request): """ Update a single profile for a given video. Example request data: { 'edx_video_id': '1234' 'profile': 'hls', 'encode_data': { 'url': 'foo.com/qwe.m3u8' 'file_size': 34 ...
python
def put(self, request): """ Update a single profile for a given video. Example request data: { 'edx_video_id': '1234' 'profile': 'hls', 'encode_data': { 'url': 'foo.com/qwe.m3u8' 'file_size': 34 ...
Update a single profile for a given video. Example request data: { 'edx_video_id': '1234' 'profile': 'hls', 'encode_data': { 'url': 'foo.com/qwe.m3u8' 'file_size': 34 'bitrate': 12 ...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/views.py#L337-L364
edx/edx-val
edxval/models.py
video_status_update_callback
def video_status_update_callback(sender, **kwargs): # pylint: disable=unused-argument """ Log video status for an existing video instance """ video = kwargs['instance'] if kwargs['created']: logger.info('VAL: Video created with id [%s] and status [%s]', video.edx_video_id, video.status) ...
python
def video_status_update_callback(sender, **kwargs): # pylint: disable=unused-argument """ Log video status for an existing video instance """ video = kwargs['instance'] if kwargs['created']: logger.info('VAL: Video created with id [%s] and status [%s]', video.edx_video_id, video.status) ...
Log video status for an existing video instance
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L676-L685
edx/edx-val
edxval/models.py
ModelFactoryWithValidation.create_with_validation
def create_with_validation(cls, *args, **kwargs): """ Factory method that creates and validates the model object before it is saved. """ ret_val = cls(*args, **kwargs) ret_val.full_clean() ret_val.save() return ret_val
python
def create_with_validation(cls, *args, **kwargs): """ Factory method that creates and validates the model object before it is saved. """ ret_val = cls(*args, **kwargs) ret_val.full_clean() ret_val.save() return ret_val
Factory method that creates and validates the model object before it is saved.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L46-L53
edx/edx-val
edxval/models.py
ModelFactoryWithValidation.get_or_create_with_validation
def get_or_create_with_validation(cls, *args, **kwargs): """ Factory method that gets or creates-and-validates the model object before it is saved. Similar to the get_or_create method on Models, it returns a tuple of (object, created), where created is a boolean specifying whether an obj...
python
def get_or_create_with_validation(cls, *args, **kwargs): """ Factory method that gets or creates-and-validates the model object before it is saved. Similar to the get_or_create method on Models, it returns a tuple of (object, created), where created is a boolean specifying whether an obj...
Factory method that gets or creates-and-validates the model object before it is saved. Similar to the get_or_create method on Models, it returns a tuple of (object, created), where created is a boolean specifying whether an object was created.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L56-L65
edx/edx-val
edxval/models.py
Video.get_or_none
def get_or_none(cls, **filter_kwargs): """ Returns a video or None. """ try: video = cls.objects.get(**filter_kwargs) except cls.DoesNotExist: video = None return video
python
def get_or_none(cls, **filter_kwargs): """ Returns a video or None. """ try: video = cls.objects.get(**filter_kwargs) except cls.DoesNotExist: video = None return video
Returns a video or None.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L129-L138
edx/edx-val
edxval/models.py
Video.by_youtube_id
def by_youtube_id(cls, youtube_id): """ Look up video by youtube id """ qset = cls.objects.filter( encoded_videos__profile__profile_name='youtube', encoded_videos__url=youtube_id ).prefetch_related('encoded_videos', 'courses') return qset
python
def by_youtube_id(cls, youtube_id): """ Look up video by youtube id """ qset = cls.objects.filter( encoded_videos__profile__profile_name='youtube', encoded_videos__url=youtube_id ).prefetch_related('encoded_videos', 'courses') return qset
Look up video by youtube id
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L141-L149
edx/edx-val
edxval/models.py
ListField.get_prep_value
def get_prep_value(self, value): """ Converts a list to its json representation to store in database as text. """ if value and not isinstance(value, list): raise ValidationError(u'ListField value {} is not a list.'.format(value)) return json.dumps(self.validate_list(v...
python
def get_prep_value(self, value): """ Converts a list to its json representation to store in database as text. """ if value and not isinstance(value, list): raise ValidationError(u'ListField value {} is not a list.'.format(value)) return json.dumps(self.validate_list(v...
Converts a list to its json representation to store in database as text.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L233-L239
edx/edx-val
edxval/models.py
ListField.to_python
def to_python(self, value): """ Converts the value into a list. """ if not value: value = [] # If a list is set then validated its items if isinstance(value, list): py_list = self.validate_list(value) else: # try to de-serialize value and...
python
def to_python(self, value): """ Converts the value into a list. """ if not value: value = [] # If a list is set then validated its items if isinstance(value, list): py_list = self.validate_list(value) else: # try to de-serialize value and...
Converts the value into a list.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L247-L268
edx/edx-val
edxval/models.py
ListField.validate_list
def validate_list(self, value): """ Validate data before saving to database. Arguemtns: value(list): list to be validated Returns: list if validation is successful Raises: ValidationError """ if len(value) > self.max_items: ...
python
def validate_list(self, value): """ Validate data before saving to database. Arguemtns: value(list): list to be validated Returns: list if validation is successful Raises: ValidationError """ if len(value) > self.max_items: ...
Validate data before saving to database. Arguemtns: value(list): list to be validated Returns: list if validation is successful Raises: ValidationError
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L270-L291
edx/edx-val
edxval/models.py
VideoImage.create_or_update
def create_or_update(cls, course_video, file_name=None, image_data=None, generated_images=None): """ Create a VideoImage object for a CourseVideo. NOTE: If `image_data` is None then `file_name` value will be used as it is, otherwise a new file name is constructed based on uuid and exten...
python
def create_or_update(cls, course_video, file_name=None, image_data=None, generated_images=None): """ Create a VideoImage object for a CourseVideo. NOTE: If `image_data` is None then `file_name` value will be used as it is, otherwise a new file name is constructed based on uuid and exten...
Create a VideoImage object for a CourseVideo. NOTE: If `image_data` is None then `file_name` value will be used as it is, otherwise a new file name is constructed based on uuid and extension from `file_name` value. `image_data` will be None in case of course re-run and export. `generated_images...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L311-L359
edx/edx-val
edxval/models.py
VideoTranscript.filename
def filename(self): """ Returns readable filename for a transcript """ client_id, __ = os.path.splitext(self.video.client_video_id) file_name = u'{name}-{language}.{format}'.format( name=client_id, language=self.language_code, format=self.file_...
python
def filename(self): """ Returns readable filename for a transcript """ client_id, __ = os.path.splitext(self.video.client_video_id) file_name = u'{name}-{language}.{format}'.format( name=client_id, language=self.language_code, format=self.file_...
Returns readable filename for a transcript
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L429-L440
edx/edx-val
edxval/models.py
VideoTranscript.get_or_none
def get_or_none(cls, video_id, language_code): """ Returns a data model object if found or none otherwise. Arguments: video_id(unicode): video id to which transcript may be associated language_code(unicode): language of the requested transcript """ try: ...
python
def get_or_none(cls, video_id, language_code): """ Returns a data model object if found or none otherwise. Arguments: video_id(unicode): video id to which transcript may be associated language_code(unicode): language of the requested transcript """ try: ...
Returns a data model object if found or none otherwise. Arguments: video_id(unicode): video id to which transcript may be associated language_code(unicode): language of the requested transcript
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L443-L456
edx/edx-val
edxval/models.py
VideoTranscript.create
def create(cls, video, language_code, file_format, content, provider): """ Create a Video Transcript. Arguments: video(Video): Video data model object language_code(unicode): A language code. file_format(unicode): Transcript file format. content(I...
python
def create(cls, video, language_code, file_format, content, provider): """ Create a Video Transcript. Arguments: video(Video): Video data model object language_code(unicode): A language code. file_format(unicode): Transcript file format. content(I...
Create a Video Transcript. Arguments: video(Video): Video data model object language_code(unicode): A language code. file_format(unicode): Transcript file format. content(InMemoryUploadedFile): Transcript content. provider(unicode): Transcript provide...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L459-L484
edx/edx-val
edxval/models.py
VideoTranscript.create_or_update
def create_or_update(cls, video, language_code, metadata, file_data=None): """ Create or update Transcript object. Arguments: video (Video): Video for which transcript is going to be saved. language_code (str): language code for (to be created/updated) transcript ...
python
def create_or_update(cls, video, language_code, metadata, file_data=None): """ Create or update Transcript object. Arguments: video (Video): Video for which transcript is going to be saved. language_code (str): language code for (to be created/updated) transcript ...
Create or update Transcript object. Arguments: video (Video): Video for which transcript is going to be saved. language_code (str): language code for (to be created/updated) transcript metadata (dict): A dict containing (to be overwritten) properties file_data (I...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L487-L530
edx/edx-val
edxval/models.py
ThirdPartyTranscriptCredentialsState.update_or_create
def update_or_create(cls, org, provider, exists): """ Update or create credentials state. """ instance, created = cls.objects.update_or_create( org=org, provider=provider, defaults={'exists': exists}, ) return instance, created
python
def update_or_create(cls, org, provider, exists): """ Update or create credentials state. """ instance, created = cls.objects.update_or_create( org=org, provider=provider, defaults={'exists': exists}, ) return instance, created
Update or create credentials state.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/models.py#L650-L660
edx/edx-val
edxval/api.py
create_video
def create_video(video_data): """ Called on to create Video objects in the database create_video is used to create Video objects whose children are EncodedVideo objects which are linked to Profile objects. This is an alternative to the HTTP requests so it can be used internally. The VideoSerializer...
python
def create_video(video_data): """ Called on to create Video objects in the database create_video is used to create Video objects whose children are EncodedVideo objects which are linked to Profile objects. This is an alternative to the HTTP requests so it can be used internally. The VideoSerializer...
Called on to create Video objects in the database create_video is used to create Video objects whose children are EncodedVideo objects which are linked to Profile objects. This is an alternative to the HTTP requests so it can be used internally. The VideoSerializer is used to deserialize this object. I...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L79-L115
edx/edx-val
edxval/api.py
update_video
def update_video(video_data): """ Called on to update Video objects in the database update_video is used to update Video objects by the given edx_video_id in the video_data. Args: video_data (dict): { url: api url to the video edx_video_id: ID of the vi...
python
def update_video(video_data): """ Called on to update Video objects in the database update_video is used to update Video objects by the given edx_video_id in the video_data. Args: video_data (dict): { url: api url to the video edx_video_id: ID of the vi...
Called on to update Video objects in the database update_video is used to update Video objects by the given edx_video_id in the video_data. Args: video_data (dict): { url: api url to the video edx_video_id: ID of the video duration: Length of vi...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L135-L173
edx/edx-val
edxval/api.py
update_video_status
def update_video_status(edx_video_id, status): """ Update status for an existing video. Args: edx_video_id: ID of the video status: video status Raises: Raises ValVideoNotFoundError if the video cannot be retrieved. """ try: video = _get_video(edx_video_id) ...
python
def update_video_status(edx_video_id, status): """ Update status for an existing video. Args: edx_video_id: ID of the video status: video status Raises: Raises ValVideoNotFoundError if the video cannot be retrieved. """ try: video = _get_video(edx_video_id) ...
Update status for an existing video. Args: edx_video_id: ID of the video status: video status Raises: Raises ValVideoNotFoundError if the video cannot be retrieved.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L176-L197
edx/edx-val
edxval/api.py
get_transcript_credentials_state_for_org
def get_transcript_credentials_state_for_org(org, provider=None): """ Returns transcript credentials state for an org Arguments: org (unicode): course organization provider (unicode): transcript provider Returns: dict: provider name and their credential existance map {...
python
def get_transcript_credentials_state_for_org(org, provider=None): """ Returns transcript credentials state for an org Arguments: org (unicode): course organization provider (unicode): transcript provider Returns: dict: provider name and their credential existance map {...
Returns transcript credentials state for an org Arguments: org (unicode): course organization provider (unicode): transcript provider Returns: dict: provider name and their credential existance map { u'Cielo24': True } { u'3PlayMedia': F...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L210-L236
edx/edx-val
edxval/api.py
is_transcript_available
def is_transcript_available(video_id, language_code=None): """ Returns whether the transcripts are available for a video. Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: it will the language code of the re...
python
def is_transcript_available(video_id, language_code=None): """ Returns whether the transcripts are available for a video. Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: it will the language code of the re...
Returns whether the transcripts are available for a video. Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: it will the language code of the requested transcript.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L251-L264
edx/edx-val
edxval/api.py
get_video_transcript
def get_video_transcript(video_id, language_code): """ Get video transcript info Arguments: video_id(unicode): A video id, it can be an edx_video_id or an external video id extracted from external sources of a video component. language_code(unicode): it will be the language code of ...
python
def get_video_transcript(video_id, language_code): """ Get video transcript info Arguments: video_id(unicode): A video id, it can be an edx_video_id or an external video id extracted from external sources of a video component. language_code(unicode): it will be the language code of ...
Get video transcript info Arguments: video_id(unicode): A video id, it can be an edx_video_id or an external video id extracted from external sources of a video component. language_code(unicode): it will be the language code of the requested transcript.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L267-L277
edx/edx-val
edxval/api.py
get_video_transcript_data
def get_video_transcript_data(video_id, language_code): """ Get video transcript data Arguments: video_id(unicode): An id identifying the Video. language_code(unicode): it will be the language code of the requested transcript. Returns: A dict containing transcript file name and...
python
def get_video_transcript_data(video_id, language_code): """ Get video transcript data Arguments: video_id(unicode): An id identifying the Video. language_code(unicode): it will be the language code of the requested transcript. Returns: A dict containing transcript file name and...
Get video transcript data Arguments: video_id(unicode): An id identifying the Video. language_code(unicode): it will be the language code of the requested transcript. Returns: A dict containing transcript file name and its content.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L280-L301
edx/edx-val
edxval/api.py
get_available_transcript_languages
def get_available_transcript_languages(video_id): """ Get available transcript languages Arguments: video_id(unicode): An id identifying the Video. Returns: A list containing transcript language codes for the Video. """ available_languages = VideoTranscript.objects.filter( ...
python
def get_available_transcript_languages(video_id): """ Get available transcript languages Arguments: video_id(unicode): An id identifying the Video. Returns: A list containing transcript language codes for the Video. """ available_languages = VideoTranscript.objects.filter( ...
Get available transcript languages Arguments: video_id(unicode): An id identifying the Video. Returns: A list containing transcript language codes for the Video.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L304-L319
edx/edx-val
edxval/api.py
get_video_transcript_url
def get_video_transcript_url(video_id, language_code): """ Returns course video transcript url or None if no transcript Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: language code of a video transcript ...
python
def get_video_transcript_url(video_id, language_code): """ Returns course video transcript url or None if no transcript Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: language code of a video transcript ...
Returns course video transcript url or None if no transcript Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: language code of a video transcript
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L322-L332
edx/edx-val
edxval/api.py
create_video_transcript
def create_video_transcript(video_id, language_code, file_format, content, provider=TranscriptProviderType.CUSTOM): """ Create a video transcript. Arguments: video_id(unicode): An Id identifying the Video data model object. language_code(unicode): A language code. file_format(unicod...
python
def create_video_transcript(video_id, language_code, file_format, content, provider=TranscriptProviderType.CUSTOM): """ Create a video transcript. Arguments: video_id(unicode): An Id identifying the Video data model object. language_code(unicode): A language code. file_format(unicod...
Create a video transcript. Arguments: video_id(unicode): An Id identifying the Video data model object. language_code(unicode): A language code. file_format(unicode): Transcript file format. content(InMemoryUploadedFile): Transcript content. provider(unicode): Transcript pro...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L335-L354
edx/edx-val
edxval/api.py
create_or_update_video_transcript
def create_or_update_video_transcript(video_id, language_code, metadata, file_data=None): """ Create or Update video transcript for an existing video. Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: langua...
python
def create_or_update_video_transcript(video_id, language_code, metadata, file_data=None): """ Create or Update video transcript for an existing video. Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: langua...
Create or Update video transcript for an existing video. Arguments: video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component. language_code: language code of a video transcript metadata (dict): A dict containing (to be overwritten) propertie...
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L357-L392
edx/edx-val
edxval/api.py
delete_video_transcript
def delete_video_transcript(video_id, language_code): """ Delete transcript for an existing video. Arguments: video_id: id identifying the video to which the transcript is associated. language_code: language code of a video transcript. """ video_transcript = VideoTranscript.get_or_n...
python
def delete_video_transcript(video_id, language_code): """ Delete transcript for an existing video. Arguments: video_id: id identifying the video to which the transcript is associated. language_code: language code of a video transcript. """ video_transcript = VideoTranscript.get_or_n...
Delete transcript for an existing video. Arguments: video_id: id identifying the video to which the transcript is associated. language_code: language code of a video transcript.
https://github.com/edx/edx-val/blob/30df48061e77641edb5272895b7c7f7f25eb7aa7/edxval/api.py#L395-L409