partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | DataClient.matched_file_count | Returns the number of files matching a pattern in a dataset.
:param dataset_id: The ID of the dataset to search for files.
:type dataset_id: int
:param glob: A pattern which will be matched against files in the dataset.
:type glob: str
:param is_dir: A boolean indicating whether... | citrination_client/data/client.py | def matched_file_count(self, dataset_id, glob=".", is_dir=False):
"""
Returns the number of files matching a pattern in a dataset.
:param dataset_id: The ID of the dataset to search for files.
:type dataset_id: int
:param glob: A pattern which will be matched against files in th... | def matched_file_count(self, dataset_id, glob=".", is_dir=False):
"""
Returns the number of files matching a pattern in a dataset.
:param dataset_id: The ID of the dataset to search for files.
:type dataset_id: int
:param glob: A pattern which will be matched against files in th... | [
"Returns",
"the",
"number",
"of",
"files",
"matching",
"a",
"pattern",
"in",
"a",
"dataset",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L120-L134 | [
"def",
"matched_file_count",
"(",
"self",
",",
"dataset_id",
",",
"glob",
"=",
"\".\"",
",",
"is_dir",
"=",
"False",
")",
":",
"list_result",
"=",
"self",
".",
"list_files",
"(",
"dataset_id",
",",
"glob",
",",
"is_dir",
")",
"return",
"len",
"(",
"list_... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.get_ingest_status | Returns the current status of dataset ingestion. If any file uploaded to a dataset is in an error/failure state
this endpoint will return error/failure. If any files are still processing, will return processing.
:param dataset_id: Dataset identifier
:return: Status of dataset ingestion as a s... | citrination_client/data/client.py | def get_ingest_status(self, dataset_id):
"""
Returns the current status of dataset ingestion. If any file uploaded to a dataset is in an error/failure state
this endpoint will return error/failure. If any files are still processing, will return processing.
:param dataset_id: Dataset i... | def get_ingest_status(self, dataset_id):
"""
Returns the current status of dataset ingestion. If any file uploaded to a dataset is in an error/failure state
this endpoint will return error/failure. If any files are still processing, will return processing.
:param dataset_id: Dataset i... | [
"Returns",
"the",
"current",
"status",
"of",
"dataset",
"ingestion",
".",
"If",
"any",
"file",
"uploaded",
"to",
"a",
"dataset",
"is",
"in",
"an",
"error",
"/",
"failure",
"state",
"this",
"endpoint",
"will",
"return",
"error",
"/",
"failure",
".",
"If",
... | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L136-L151 | [
"def",
"get_ingest_status",
"(",
"self",
",",
"dataset_id",
")",
":",
"failure_message",
"=",
"\"Failed to create dataset ingest status for dataset {}\"",
".",
"format",
"(",
"dataset_id",
")",
"response",
"=",
"self",
".",
"_get_success_json",
"(",
"self",
".",
"_get... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.get_dataset_files | Retrieves URLs for the files matched by a glob or a path to a directory
in a given dataset.
:param dataset_id: The id of the dataset to retrieve files from
:type dataset_id: int
:param glob: A regex used to select one or more files in the dataset
:type glob: str
:param i... | citrination_client/data/client.py | def get_dataset_files(self, dataset_id, glob=".", is_dir=False, version_number=None):
"""
Retrieves URLs for the files matched by a glob or a path to a directory
in a given dataset.
:param dataset_id: The id of the dataset to retrieve files from
:type dataset_id: int
:pa... | def get_dataset_files(self, dataset_id, glob=".", is_dir=False, version_number=None):
"""
Retrieves URLs for the files matched by a glob or a path to a directory
in a given dataset.
:param dataset_id: The id of the dataset to retrieve files from
:type dataset_id: int
:pa... | [
"Retrieves",
"URLs",
"for",
"the",
"files",
"matched",
"by",
"a",
"glob",
"or",
"a",
"path",
"to",
"a",
"directory",
"in",
"a",
"given",
"dataset",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L153-L200 | [
"def",
"get_dataset_files",
"(",
"self",
",",
"dataset_id",
",",
"glob",
"=",
"\".\"",
",",
"is_dir",
"=",
"False",
",",
"version_number",
"=",
"None",
")",
":",
"if",
"version_number",
"is",
"None",
":",
"latest",
"=",
"True",
"else",
":",
"latest",
"="... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.get_dataset_file | Retrieves a dataset file matching a provided file path
:param dataset_id: The id of the dataset to retrieve file from
:type dataset_id: int
:param file_path: The file path within the dataset
:type file_path: str
:param version: The dataset version to look for the file in. If not... | citrination_client/data/client.py | def get_dataset_file(self, dataset_id, file_path, version = None):
"""
Retrieves a dataset file matching a provided file path
:param dataset_id: The id of the dataset to retrieve file from
:type dataset_id: int
:param file_path: The file path within the dataset
:type fil... | def get_dataset_file(self, dataset_id, file_path, version = None):
"""
Retrieves a dataset file matching a provided file path
:param dataset_id: The id of the dataset to retrieve file from
:type dataset_id: int
:param file_path: The file path within the dataset
:type fil... | [
"Retrieves",
"a",
"dataset",
"file",
"matching",
"a",
"provided",
"file",
"path"
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L202-L215 | [
"def",
"get_dataset_file",
"(",
"self",
",",
"dataset_id",
",",
"file_path",
",",
"version",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_dataset_files",
"(",
"dataset_id",
",",
"\"^{}$\"",
".",
"format",
"(",
"file_path",
")",
",",
"version_number",
"... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.download_files | Downloads file(s) to a local destination.
:param dataset_files:
:type dataset_files: list of :class: `DatasetFile`
:param destination: The path to the desired local download destination
:type destination: str
:param chunk: Whether or not to chunk the file. Default True
:... | citrination_client/data/client.py | def download_files(self, dataset_files, destination='.'):
"""
Downloads file(s) to a local destination.
:param dataset_files:
:type dataset_files: list of :class: `DatasetFile`
:param destination: The path to the desired local download destination
:type destination: str
... | def download_files(self, dataset_files, destination='.'):
"""
Downloads file(s) to a local destination.
:param dataset_files:
:type dataset_files: list of :class: `DatasetFile`
:param destination: The path to the desired local download destination
:type destination: str
... | [
"Downloads",
"file",
"(",
"s",
")",
"to",
"a",
"local",
"destination",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L217-L241 | [
"def",
"download_files",
"(",
"self",
",",
"dataset_files",
",",
"destination",
"=",
"'.'",
")",
":",
"if",
"not",
"isinstance",
"(",
"dataset_files",
",",
"list",
")",
":",
"dataset_files",
"=",
"[",
"dataset_files",
"]",
"for",
"f",
"in",
"dataset_files",
... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.get_pif | Retrieves a PIF from a given dataset.
:param dataset_id: The id of the dataset to retrieve PIF from
:type dataset_id: int
:param uid: The uid of the PIF to retrieve
:type uid: str
:param dataset_version: The dataset version to look for the PIF in. If nothing is supplied, the lat... | citrination_client/data/client.py | def get_pif(self, dataset_id, uid, dataset_version = None):
"""
Retrieves a PIF from a given dataset.
:param dataset_id: The id of the dataset to retrieve PIF from
:type dataset_id: int
:param uid: The uid of the PIF to retrieve
:type uid: str
:param dataset_vers... | def get_pif(self, dataset_id, uid, dataset_version = None):
"""
Retrieves a PIF from a given dataset.
:param dataset_id: The id of the dataset to retrieve PIF from
:type dataset_id: int
:param uid: The uid of the PIF to retrieve
:type uid: str
:param dataset_vers... | [
"Retrieves",
"a",
"PIF",
"from",
"a",
"given",
"dataset",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L243-L262 | [
"def",
"get_pif",
"(",
"self",
",",
"dataset_id",
",",
"uid",
",",
"dataset_version",
"=",
"None",
")",
":",
"failure_message",
"=",
"\"An error occurred retrieving PIF {}\"",
".",
"format",
"(",
"uid",
")",
"if",
"dataset_version",
"==",
"None",
":",
"response"... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.create_dataset | Create a new data set.
:param name: name of the dataset
:type name: str
:param description: description for the dataset
:type description: str
:param public: A boolean indicating whether or not the dataset should be public.
:type public: bool
:return: The newly c... | citrination_client/data/client.py | def create_dataset(self, name=None, description=None, public=False):
"""
Create a new data set.
:param name: name of the dataset
:type name: str
:param description: description for the dataset
:type description: str
:param public: A boolean indicating whether or ... | def create_dataset(self, name=None, description=None, public=False):
"""
Create a new data set.
:param name: name of the dataset
:type name: str
:param description: description for the dataset
:type description: str
:param public: A boolean indicating whether or ... | [
"Create",
"a",
"new",
"data",
"set",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L264-L288 | [
"def",
"create_dataset",
"(",
"self",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"public",
"=",
"False",
")",
":",
"data",
"=",
"{",
"\"public\"",
":",
"_convert_bool_to_public_value",
"(",
"public",
")",
"}",
"if",
"name",
":",
"dat... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.update_dataset | Update a data set.
:param dataset_id: The ID of the dataset to update
:type dataset_id: int
:param name: name of the dataset
:type name: str
:param description: description for the dataset
:type description: str
:param public: A boolean indicating whether or not ... | citrination_client/data/client.py | def update_dataset(self, dataset_id, name=None, description=None, public=None):
"""
Update a data set.
:param dataset_id: The ID of the dataset to update
:type dataset_id: int
:param name: name of the dataset
:type name: str
:param description: description for th... | def update_dataset(self, dataset_id, name=None, description=None, public=None):
"""
Update a data set.
:param dataset_id: The ID of the dataset to update
:type dataset_id: int
:param name: name of the dataset
:type name: str
:param description: description for th... | [
"Update",
"a",
"data",
"set",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L290-L319 | [
"def",
"update_dataset",
"(",
"self",
",",
"dataset_id",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"public",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"public\"",
":",
"_convert_bool_to_public_value",
"(",
"public",
")",
"}",
"if",
... | 409984fc65ce101a620f069263f155303492465c |
valid | DataClient.create_dataset_version | Create a new data set version.
:param dataset_id: The ID of the dataset for which the version must be bumped.
:type dataset_id: int
:return: The new dataset version.
:rtype: :class:`DatasetVersion` | citrination_client/data/client.py | def create_dataset_version(self, dataset_id):
"""
Create a new data set version.
:param dataset_id: The ID of the dataset for which the version must be bumped.
:type dataset_id: int
:return: The new dataset version.
:rtype: :class:`DatasetVersion`
"""
fai... | def create_dataset_version(self, dataset_id):
"""
Create a new data set version.
:param dataset_id: The ID of the dataset for which the version must be bumped.
:type dataset_id: int
:return: The new dataset version.
:rtype: :class:`DatasetVersion`
"""
fai... | [
"Create",
"a",
"new",
"data",
"set",
"version",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/data/client.py#L321-L333 | [
"def",
"create_dataset_version",
"(",
"self",
",",
"dataset_id",
")",
":",
"failure_message",
"=",
"\"Failed to create dataset version for dataset {}\"",
".",
"format",
"(",
"dataset_id",
")",
"number",
"=",
"self",
".",
"_get_success_json",
"(",
"self",
".",
"_post_j... | 409984fc65ce101a620f069263f155303492465c |
valid | SearchTemplateClient.get_available_columns | Retrieves the set of columns from the combination of dataset ids given
:param dataset_ids: The id of the dataset to retrieve columns from
:type dataset_ids: list of int
:return: A list of column names from the dataset ids given.
:rtype: list of str | citrination_client/views/search_template/client.py | def get_available_columns(self, dataset_ids):
"""
Retrieves the set of columns from the combination of dataset ids given
:param dataset_ids: The id of the dataset to retrieve columns from
:type dataset_ids: list of int
:return: A list of column names from the dataset ids given.
... | def get_available_columns(self, dataset_ids):
"""
Retrieves the set of columns from the combination of dataset ids given
:param dataset_ids: The id of the dataset to retrieve columns from
:type dataset_ids: list of int
:return: A list of column names from the dataset ids given.
... | [
"Retrieves",
"the",
"set",
"of",
"columns",
"from",
"the",
"combination",
"of",
"dataset",
"ids",
"given"
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/views/search_template/client.py#L17-L37 | [
"def",
"get_available_columns",
"(",
"self",
",",
"dataset_ids",
")",
":",
"if",
"not",
"isinstance",
"(",
"dataset_ids",
",",
"list",
")",
":",
"dataset_ids",
"=",
"[",
"dataset_ids",
"]",
"data",
"=",
"{",
"\"dataset_ids\"",
":",
"dataset_ids",
"}",
"failu... | 409984fc65ce101a620f069263f155303492465c |
valid | SearchTemplateClient.__generate_search_template | Generates a default search templates from the available columns in the dataset ids given.
:param dataset_ids: The id of the dataset to retrieve files from
:type dataset_ids: list of int
:return: A search template based on the columns in the datasets given | citrination_client/views/search_template/client.py | def __generate_search_template(self, dataset_ids):
"""
Generates a default search templates from the available columns in the dataset ids given.
:param dataset_ids: The id of the dataset to retrieve files from
:type dataset_ids: list of int
:return: A search template based on th... | def __generate_search_template(self, dataset_ids):
"""
Generates a default search templates from the available columns in the dataset ids given.
:param dataset_ids: The id of the dataset to retrieve files from
:type dataset_ids: list of int
:return: A search template based on th... | [
"Generates",
"a",
"default",
"search",
"templates",
"from",
"the",
"available",
"columns",
"in",
"the",
"dataset",
"ids",
"given",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/views/search_template/client.py#L39-L56 | [
"def",
"__generate_search_template",
"(",
"self",
",",
"dataset_ids",
")",
":",
"data",
"=",
"{",
"\"dataset_ids\"",
":",
"dataset_ids",
"}",
"failure_message",
"=",
"\"Failed to generate a search template from columns in dataset(s) {}\"",
".",
"format",
"(",
"dataset_ids",... | 409984fc65ce101a620f069263f155303492465c |
valid | SearchTemplateClient.__prune_search_template | Returns a new search template, but the new template has only the extract_as_keys given.
:param extract_as_keys: List of extract as keys to keep
:param search_template: The search template to prune
:return: New search template with pruned columns | citrination_client/views/search_template/client.py | def __prune_search_template(self, extract_as_keys, search_template):
"""
Returns a new search template, but the new template has only the extract_as_keys given.
:param extract_as_keys: List of extract as keys to keep
:param search_template: The search template to prune
:return: ... | def __prune_search_template(self, extract_as_keys, search_template):
"""
Returns a new search template, but the new template has only the extract_as_keys given.
:param extract_as_keys: List of extract as keys to keep
:param search_template: The search template to prune
:return: ... | [
"Returns",
"a",
"new",
"search",
"template",
"but",
"the",
"new",
"template",
"has",
"only",
"the",
"extract_as_keys",
"given",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/views/search_template/client.py#L59-L78 | [
"def",
"__prune_search_template",
"(",
"self",
",",
"extract_as_keys",
",",
"search_template",
")",
":",
"data",
"=",
"{",
"\"extract_as_keys\"",
":",
"extract_as_keys",
",",
"\"search_template\"",
":",
"search_template",
"}",
"failure_message",
"=",
"\"Failed to prune ... | 409984fc65ce101a620f069263f155303492465c |
valid | QueryEncoder.default | Convert an object to a form ready to dump to json.
:param obj: Object being serialized. The type of this object must be one of the following: None; a single object derived from the Pio class; or a list of objects, each derived from the Pio class.
:return: List of dictionaries, each representing a physi... | citrination_client/search/query_encoder.py | def default(self, obj):
"""
Convert an object to a form ready to dump to json.
:param obj: Object being serialized. The type of this object must be one of the following: None; a single object derived from the Pio class; or a list of objects, each derived from the Pio class.
:return: Lis... | def default(self, obj):
"""
Convert an object to a form ready to dump to json.
:param obj: Object being serialized. The type of this object must be one of the following: None; a single object derived from the Pio class; or a list of objects, each derived from the Pio class.
:return: Lis... | [
"Convert",
"an",
"object",
"to",
"a",
"form",
"ready",
"to",
"dump",
"to",
"json",
"."
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/search/query_encoder.py#L11-L25 | [
"def",
"default",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"[",
"i",
".",
"as_dictionary",
"(",
")",
"for",
"i",
"in",
"obj",
"]",
... | 409984fc65ce101a620f069263f155303492465c |
valid | QueryEncoder._keys_to_camel_case | Make a copy of a dictionary with all keys converted to camel case. This is just calls to_camel_case on each of the keys in the dictionary and returns a new dictionary.
:param obj: Dictionary to convert keys to camel case.
:return: Dictionary with the input values and all keys in camel case | citrination_client/search/query_encoder.py | def _keys_to_camel_case(self, obj):
"""
Make a copy of a dictionary with all keys converted to camel case. This is just calls to_camel_case on each of the keys in the dictionary and returns a new dictionary.
:param obj: Dictionary to convert keys to camel case.
:return: Dictionary with ... | def _keys_to_camel_case(self, obj):
"""
Make a copy of a dictionary with all keys converted to camel case. This is just calls to_camel_case on each of the keys in the dictionary and returns a new dictionary.
:param obj: Dictionary to convert keys to camel case.
:return: Dictionary with ... | [
"Make",
"a",
"copy",
"of",
"a",
"dictionary",
"with",
"all",
"keys",
"converted",
"to",
"camel",
"case",
".",
"This",
"is",
"just",
"calls",
"to_camel_case",
"on",
"each",
"of",
"the",
"keys",
"in",
"the",
"dictionary",
"and",
"returns",
"a",
"new",
"dic... | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/search/query_encoder.py#L27-L34 | [
"def",
"_keys_to_camel_case",
"(",
"self",
",",
"obj",
")",
":",
"return",
"dict",
"(",
"(",
"to_camel_case",
"(",
"key",
")",
",",
"value",
")",
"for",
"(",
"key",
",",
"value",
")",
"in",
"obj",
".",
"items",
"(",
")",
")"
] | 409984fc65ce101a620f069263f155303492465c |
valid | ModelTemplateClient.validate | Runs the template against the validation endpoint, returns a message indicating status of the templte
:param ml_template: Template to validate
:return: OK or error message if validation failed | citrination_client/views/model_template/client.py | def validate(self, ml_template):
"""
Runs the template against the validation endpoint, returns a message indicating status of the templte
:param ml_template: Template to validate
:return: OK or error message if validation failed
"""
data = {
"ml_template":
... | def validate(self, ml_template):
"""
Runs the template against the validation endpoint, returns a message indicating status of the templte
:param ml_template: Template to validate
:return: OK or error message if validation failed
"""
data = {
"ml_template":
... | [
"Runs",
"the",
"template",
"against",
"the",
"validation",
"endpoint",
"returns",
"a",
"message",
"indicating",
"status",
"of",
"the",
"templte"
] | CitrineInformatics/python-citrination-client | python | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/views/model_template/client.py#L15-L34 | [
"def",
"validate",
"(",
"self",
",",
"ml_template",
")",
":",
"data",
"=",
"{",
"\"ml_template\"",
":",
"ml_template",
"}",
"failure_message",
"=",
"\"ML template validation invoke failed\"",
"res",
"=",
"self",
".",
"_get_success_json",
"(",
"self",
".",
"_post_j... | 409984fc65ce101a620f069263f155303492465c |
valid | _validate_course_key | Validation helper | organizations/api.py | def _validate_course_key(course_key):
""" Validation helper """
if not validators.course_key_is_valid(course_key):
exceptions.raise_exception(
"CourseKey",
course_key,
exceptions.InvalidCourseKeyException
) | def _validate_course_key(course_key):
""" Validation helper """
if not validators.course_key_is_valid(course_key):
exceptions.raise_exception(
"CourseKey",
course_key,
exceptions.InvalidCourseKeyException
) | [
"Validation",
"helper"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/api.py#L17-L24 | [
"def",
"_validate_course_key",
"(",
"course_key",
")",
":",
"if",
"not",
"validators",
".",
"course_key_is_valid",
"(",
"course_key",
")",
":",
"exceptions",
".",
"raise_exception",
"(",
"\"CourseKey\"",
",",
"course_key",
",",
"exceptions",
".",
"InvalidCourseKeyEx... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | _validate_organization_data | Validation helper | organizations/api.py | def _validate_organization_data(organization_data):
""" Validation helper """
if not validators.organization_data_is_valid(organization_data):
exceptions.raise_exception(
"Organization",
organization_data,
exceptions.InvalidOrganizationException
) | def _validate_organization_data(organization_data):
""" Validation helper """
if not validators.organization_data_is_valid(organization_data):
exceptions.raise_exception(
"Organization",
organization_data,
exceptions.InvalidOrganizationException
) | [
"Validation",
"helper"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/api.py#L27-L34 | [
"def",
"_validate_organization_data",
"(",
"organization_data",
")",
":",
"if",
"not",
"validators",
".",
"organization_data_is_valid",
"(",
"organization_data",
")",
":",
"exceptions",
".",
"raise_exception",
"(",
"\"Organization\"",
",",
"organization_data",
",",
"exc... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | add_organization_course | Adds a organization-course link to the system | organizations/api.py | def add_organization_course(organization_data, course_key):
"""
Adds a organization-course link to the system
"""
_validate_course_key(course_key)
_validate_organization_data(organization_data)
data.create_organization_course(
organization=organization_data,
course_key=course_key... | def add_organization_course(organization_data, course_key):
"""
Adds a organization-course link to the system
"""
_validate_course_key(course_key)
_validate_organization_data(organization_data)
data.create_organization_course(
organization=organization_data,
course_key=course_key... | [
"Adds",
"a",
"organization",
"-",
"course",
"link",
"to",
"the",
"system"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/api.py#L86-L95 | [
"def",
"add_organization_course",
"(",
"organization_data",
",",
"course_key",
")",
":",
"_validate_course_key",
"(",
"course_key",
")",
"_validate_organization_data",
"(",
"organization_data",
")",
"data",
".",
"create_organization_course",
"(",
"organization",
"=",
"org... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | remove_organization_course | Removes the specfied course from the specified organization | organizations/api.py | def remove_organization_course(organization, course_key):
"""
Removes the specfied course from the specified organization
"""
_validate_organization_data(organization)
_validate_course_key(course_key)
return data.delete_organization_course(course_key=course_key, organization=organization) | def remove_organization_course(organization, course_key):
"""
Removes the specfied course from the specified organization
"""
_validate_organization_data(organization)
_validate_course_key(course_key)
return data.delete_organization_course(course_key=course_key, organization=organization) | [
"Removes",
"the",
"specfied",
"course",
"from",
"the",
"specified",
"organization"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/api.py#L107-L113 | [
"def",
"remove_organization_course",
"(",
"organization",
",",
"course_key",
")",
":",
"_validate_organization_data",
"(",
"organization",
")",
"_validate_course_key",
"(",
"course_key",
")",
"return",
"data",
".",
"delete_organization_course",
"(",
"course_key",
"=",
"... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | raise_exception | Exception helper | organizations/exceptions.py | def raise_exception(entity_type, entity, exception):
""" Exception helper """
raise exception(
u'The {} you have provided is not valid: {}'.format(entity_type, entity).encode('utf-8')
) | def raise_exception(entity_type, entity, exception):
""" Exception helper """
raise exception(
u'The {} you have provided is not valid: {}'.format(entity_type, entity).encode('utf-8')
) | [
"Exception",
"helper"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/exceptions.py#L16-L20 | [
"def",
"raise_exception",
"(",
"entity_type",
",",
"entity",
",",
"exception",
")",
":",
"raise",
"exception",
"(",
"u'The {} you have provided is not valid: {}'",
".",
"format",
"(",
"entity_type",
",",
"entity",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")"
] | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | course_key_is_valid | Course key object validation | organizations/validators.py | def course_key_is_valid(course_key):
"""
Course key object validation
"""
if course_key is None:
return False
try:
CourseKey.from_string(text_type(course_key))
except (InvalidKeyError, UnicodeDecodeError):
return False
return True | def course_key_is_valid(course_key):
"""
Course key object validation
"""
if course_key is None:
return False
try:
CourseKey.from_string(text_type(course_key))
except (InvalidKeyError, UnicodeDecodeError):
return False
return True | [
"Course",
"key",
"object",
"validation"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/validators.py#L10-L20 | [
"def",
"course_key_is_valid",
"(",
"course_key",
")",
":",
"if",
"course_key",
"is",
"None",
":",
"return",
"False",
"try",
":",
"CourseKey",
".",
"from_string",
"(",
"text_type",
"(",
"course_key",
")",
")",
"except",
"(",
"InvalidKeyError",
",",
"UnicodeDeco... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | organization_data_is_valid | Organization data validation | organizations/validators.py | def organization_data_is_valid(organization_data):
"""
Organization data validation
"""
if organization_data is None:
return False
if 'id' in organization_data and not organization_data.get('id'):
return False
if 'name' in organization_data and not organization_data.get('name'):
... | def organization_data_is_valid(organization_data):
"""
Organization data validation
"""
if organization_data is None:
return False
if 'id' in organization_data and not organization_data.get('id'):
return False
if 'name' in organization_data and not organization_data.get('name'):
... | [
"Organization",
"data",
"validation"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/validators.py#L23-L33 | [
"def",
"organization_data_is_valid",
"(",
"organization_data",
")",
":",
"if",
"organization_data",
"is",
"None",
":",
"return",
"False",
"if",
"'id'",
"in",
"organization_data",
"and",
"not",
"organization_data",
".",
"get",
"(",
"'id'",
")",
":",
"return",
"Fa... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | _activate_organization | Activates an inactivated (soft-deleted) organization as well as any inactive relationships | organizations/data.py | def _activate_organization(organization):
"""
Activates an inactivated (soft-deleted) organization as well as any inactive relationships
"""
[_activate_organization_course_relationship(record) for record
in internal.OrganizationCourse.objects.filter(organization_id=organization.id, active=False)]
... | def _activate_organization(organization):
"""
Activates an inactivated (soft-deleted) organization as well as any inactive relationships
"""
[_activate_organization_course_relationship(record) for record
in internal.OrganizationCourse.objects.filter(organization_id=organization.id, active=False)]
... | [
"Activates",
"an",
"inactivated",
"(",
"soft",
"-",
"deleted",
")",
"organization",
"as",
"well",
"as",
"any",
"inactive",
"relationships"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L53-L61 | [
"def",
"_activate_organization",
"(",
"organization",
")",
":",
"[",
"_activate_organization_course_relationship",
"(",
"record",
")",
"for",
"record",
"in",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"filter",
"(",
"organization_id",
"=",
"organizati... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | _inactivate_organization | Inactivates an activated organization as well as any active relationships | organizations/data.py | def _inactivate_organization(organization):
"""
Inactivates an activated organization as well as any active relationships
"""
[_inactivate_organization_course_relationship(record) for record
in internal.OrganizationCourse.objects.filter(organization_id=organization.id, active=True)]
[_inactiva... | def _inactivate_organization(organization):
"""
Inactivates an activated organization as well as any active relationships
"""
[_inactivate_organization_course_relationship(record) for record
in internal.OrganizationCourse.objects.filter(organization_id=organization.id, active=True)]
[_inactiva... | [
"Inactivates",
"an",
"activated",
"organization",
"as",
"well",
"as",
"any",
"active",
"relationships"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L64-L72 | [
"def",
"_inactivate_organization",
"(",
"organization",
")",
":",
"[",
"_inactivate_organization_course_relationship",
"(",
"record",
")",
"for",
"record",
"in",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"filter",
"(",
"organization_id",
"=",
"organi... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | _activate_organization_course_relationship | Activates an inactive organization-course relationship | organizations/data.py | def _activate_organization_course_relationship(relationship): # pylint: disable=invalid-name
"""
Activates an inactive organization-course relationship
"""
# If the relationship doesn't exist or the organization isn't active we'll want to raise an error
relationship = internal.OrganizationCourse.ob... | def _activate_organization_course_relationship(relationship): # pylint: disable=invalid-name
"""
Activates an inactive organization-course relationship
"""
# If the relationship doesn't exist or the organization isn't active we'll want to raise an error
relationship = internal.OrganizationCourse.ob... | [
"Activates",
"an",
"inactive",
"organization",
"-",
"course",
"relationship"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L75-L85 | [
"def",
"_activate_organization_course_relationship",
"(",
"relationship",
")",
":",
"# pylint: disable=invalid-name",
"# If the relationship doesn't exist or the organization isn't active we'll want to raise an error",
"relationship",
"=",
"internal",
".",
"OrganizationCourse",
".",
"obj... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | _inactivate_organization_course_relationship | Inactivates an active organization-course relationship | organizations/data.py | def _inactivate_organization_course_relationship(relationship): # pylint: disable=invalid-name
"""
Inactivates an active organization-course relationship
"""
relationship = internal.OrganizationCourse.objects.get(
id=relationship.id,
active=True
)
_inactivate_record(relationship... | def _inactivate_organization_course_relationship(relationship): # pylint: disable=invalid-name
"""
Inactivates an active organization-course relationship
"""
relationship = internal.OrganizationCourse.objects.get(
id=relationship.id,
active=True
)
_inactivate_record(relationship... | [
"Inactivates",
"an",
"active",
"organization",
"-",
"course",
"relationship"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L88-L96 | [
"def",
"_inactivate_organization_course_relationship",
"(",
"relationship",
")",
":",
"# pylint: disable=invalid-name",
"relationship",
"=",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"relationship",
".",
"id",
",",
"active",
"=... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | create_organization | Inserts a new organization into app/local state given the following dictionary:
{
'name': string,
'description': string
}
Returns an updated dictionary including a new 'id': integer field/value | organizations/data.py | def create_organization(organization):
"""
Inserts a new organization into app/local state given the following dictionary:
{
'name': string,
'description': string
}
Returns an updated dictionary including a new 'id': integer field/value
"""
# Trust, but verify...
if not o... | def create_organization(organization):
"""
Inserts a new organization into app/local state given the following dictionary:
{
'name': string,
'description': string
}
Returns an updated dictionary including a new 'id': integer field/value
"""
# Trust, but verify...
if not o... | [
"Inserts",
"a",
"new",
"organization",
"into",
"app",
"/",
"local",
"state",
"given",
"the",
"following",
"dictionary",
":",
"{",
"name",
":",
"string",
"description",
":",
"string",
"}",
"Returns",
"an",
"updated",
"dictionary",
"including",
"a",
"new",
"id... | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L100-L128 | [
"def",
"create_organization",
"(",
"organization",
")",
":",
"# Trust, but verify...",
"if",
"not",
"organization",
".",
"get",
"(",
"'name'",
")",
":",
"exceptions",
".",
"raise_exception",
"(",
"\"organization\"",
",",
"organization",
",",
"exceptions",
".",
"In... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | update_organization | Updates an existing organization in app/local state
Returns a dictionary representation of the object | organizations/data.py | def update_organization(organization):
"""
Updates an existing organization in app/local state
Returns a dictionary representation of the object
"""
organization_obj = serializers.deserialize_organization(organization)
try:
organization = internal.Organization.objects.get(id=organization... | def update_organization(organization):
"""
Updates an existing organization in app/local state
Returns a dictionary representation of the object
"""
organization_obj = serializers.deserialize_organization(organization)
try:
organization = internal.Organization.objects.get(id=organization... | [
"Updates",
"an",
"existing",
"organization",
"in",
"app",
"/",
"local",
"state",
"Returns",
"a",
"dictionary",
"representation",
"of",
"the",
"object"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L131-L146 | [
"def",
"update_organization",
"(",
"organization",
")",
":",
"organization_obj",
"=",
"serializers",
".",
"deserialize_organization",
"(",
"organization",
")",
"try",
":",
"organization",
"=",
"internal",
".",
"Organization",
".",
"objects",
".",
"get",
"(",
"id",... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | fetch_organization | Retrieves a specific organization from app/local state
Returns a dictionary representation of the object | organizations/data.py | def fetch_organization(organization_id):
"""
Retrieves a specific organization from app/local state
Returns a dictionary representation of the object
"""
organization = {'id': organization_id}
if not organization_id:
exceptions.raise_exception("organization", organization, exceptions.Inv... | def fetch_organization(organization_id):
"""
Retrieves a specific organization from app/local state
Returns a dictionary representation of the object
"""
organization = {'id': organization_id}
if not organization_id:
exceptions.raise_exception("organization", organization, exceptions.Inv... | [
"Retrieves",
"a",
"specific",
"organization",
"from",
"app",
"/",
"local",
"state",
"Returns",
"a",
"dictionary",
"representation",
"of",
"the",
"object"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L158-L171 | [
"def",
"fetch_organization",
"(",
"organization_id",
")",
":",
"organization",
"=",
"{",
"'id'",
":",
"organization_id",
"}",
"if",
"not",
"organization_id",
":",
"exceptions",
".",
"raise_exception",
"(",
"\"organization\"",
",",
"organization",
",",
"exceptions",
... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | fetch_organization_by_short_name | Retrieves a specific organization from app/local state by short name
Returns a dictionary representation of the object | organizations/data.py | def fetch_organization_by_short_name(organization_short_name):
"""
Retrieves a specific organization from app/local state by short name
Returns a dictionary representation of the object
"""
organization = {'short_name': organization_short_name}
if not organization_short_name:
exceptions.... | def fetch_organization_by_short_name(organization_short_name):
"""
Retrieves a specific organization from app/local state by short name
Returns a dictionary representation of the object
"""
organization = {'short_name': organization_short_name}
if not organization_short_name:
exceptions.... | [
"Retrieves",
"a",
"specific",
"organization",
"from",
"app",
"/",
"local",
"state",
"by",
"short",
"name",
"Returns",
"a",
"dictionary",
"representation",
"of",
"the",
"object"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L174-L187 | [
"def",
"fetch_organization_by_short_name",
"(",
"organization_short_name",
")",
":",
"organization",
"=",
"{",
"'short_name'",
":",
"organization_short_name",
"}",
"if",
"not",
"organization_short_name",
":",
"exceptions",
".",
"raise_exception",
"(",
"\"organization\"",
... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | create_organization_course | Inserts a new organization-course relationship into app/local state
No response currently defined for this operation | organizations/data.py | def create_organization_course(organization, course_key):
"""
Inserts a new organization-course relationship into app/local state
No response currently defined for this operation
"""
organization_obj = serializers.deserialize_organization(organization)
try:
relationship = internal.Organi... | def create_organization_course(organization, course_key):
"""
Inserts a new organization-course relationship into app/local state
No response currently defined for this operation
"""
organization_obj = serializers.deserialize_organization(organization)
try:
relationship = internal.Organi... | [
"Inserts",
"a",
"new",
"organization",
"-",
"course",
"relationship",
"into",
"app",
"/",
"local",
"state",
"No",
"response",
"currently",
"defined",
"for",
"this",
"operation"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L198-L217 | [
"def",
"create_organization_course",
"(",
"organization",
",",
"course_key",
")",
":",
"organization_obj",
"=",
"serializers",
".",
"deserialize_organization",
"(",
"organization",
")",
"try",
":",
"relationship",
"=",
"internal",
".",
"OrganizationCourse",
".",
"obje... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | delete_organization_course | Removes an existing organization-course relationship from app/local state
No response currently defined for this operation | organizations/data.py | def delete_organization_course(organization, course_key):
"""
Removes an existing organization-course relationship from app/local state
No response currently defined for this operation
"""
try:
relationship = internal.OrganizationCourse.objects.get(
organization=organization['id'... | def delete_organization_course(organization, course_key):
"""
Removes an existing organization-course relationship from app/local state
No response currently defined for this operation
"""
try:
relationship = internal.OrganizationCourse.objects.get(
organization=organization['id'... | [
"Removes",
"an",
"existing",
"organization",
"-",
"course",
"relationship",
"from",
"app",
"/",
"local",
"state",
"No",
"response",
"currently",
"defined",
"for",
"this",
"operation"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L220-L235 | [
"def",
"delete_organization_course",
"(",
"organization",
",",
"course_key",
")",
":",
"try",
":",
"relationship",
"=",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"get",
"(",
"organization",
"=",
"organization",
"[",
"'id'",
"]",
",",
"course_id... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | fetch_organization_courses | Retrieves the set of courses currently linked to the specified organization | organizations/data.py | def fetch_organization_courses(organization):
"""
Retrieves the set of courses currently linked to the specified organization
"""
organization_obj = serializers.deserialize_organization(organization)
queryset = internal.OrganizationCourse.objects.filter(
organization=organization_obj,
... | def fetch_organization_courses(organization):
"""
Retrieves the set of courses currently linked to the specified organization
"""
organization_obj = serializers.deserialize_organization(organization)
queryset = internal.OrganizationCourse.objects.filter(
organization=organization_obj,
... | [
"Retrieves",
"the",
"set",
"of",
"courses",
"currently",
"linked",
"to",
"the",
"specified",
"organization"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L238-L247 | [
"def",
"fetch_organization_courses",
"(",
"organization",
")",
":",
"organization_obj",
"=",
"serializers",
".",
"deserialize_organization",
"(",
"organization",
")",
"queryset",
"=",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"filter",
"(",
"organiza... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | fetch_course_organizations | Retrieves the organizations linked to the specified course | organizations/data.py | def fetch_course_organizations(course_key):
"""
Retrieves the organizations linked to the specified course
"""
queryset = internal.OrganizationCourse.objects.filter(
course_id=text_type(course_key),
active=True
).select_related('organization')
return [serializers.serialize_organi... | def fetch_course_organizations(course_key):
"""
Retrieves the organizations linked to the specified course
"""
queryset = internal.OrganizationCourse.objects.filter(
course_id=text_type(course_key),
active=True
).select_related('organization')
return [serializers.serialize_organi... | [
"Retrieves",
"the",
"organizations",
"linked",
"to",
"the",
"specified",
"course"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L250-L258 | [
"def",
"fetch_course_organizations",
"(",
"course_key",
")",
":",
"queryset",
"=",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"filter",
"(",
"course_id",
"=",
"text_type",
"(",
"course_key",
")",
",",
"active",
"=",
"True",
")",
".",
"select_r... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | delete_course_references | Inactivates references to course keys within this app (ref: receivers.py and api.py) | organizations/data.py | def delete_course_references(course_key):
"""
Inactivates references to course keys within this app (ref: receivers.py and api.py)
"""
[_inactivate_record(record) for record in internal.OrganizationCourse.objects.filter(
course_id=text_type(course_key),
active=True
)] | def delete_course_references(course_key):
"""
Inactivates references to course keys within this app (ref: receivers.py and api.py)
"""
[_inactivate_record(record) for record in internal.OrganizationCourse.objects.filter(
course_id=text_type(course_key),
active=True
)] | [
"Inactivates",
"references",
"to",
"course",
"keys",
"within",
"this",
"app",
"(",
"ref",
":",
"receivers",
".",
"py",
"and",
"api",
".",
"py",
")"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/data.py#L261-L268 | [
"def",
"delete_course_references",
"(",
"course_key",
")",
":",
"[",
"_inactivate_record",
"(",
"record",
")",
"for",
"record",
"in",
"internal",
".",
"OrganizationCourse",
".",
"objects",
".",
"filter",
"(",
"course_id",
"=",
"text_type",
"(",
"course_key",
")"... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | serialize_organization | Organization object-to-dict serialization | organizations/serializers.py | def serialize_organization(organization):
"""
Organization object-to-dict serialization
"""
return {
'id': organization.id,
'name': organization.name,
'short_name': organization.short_name,
'description': organization.description,
'logo': organization.logo
} | def serialize_organization(organization):
"""
Organization object-to-dict serialization
"""
return {
'id': organization.id,
'name': organization.name,
'short_name': organization.short_name,
'description': organization.description,
'logo': organization.logo
} | [
"Organization",
"object",
"-",
"to",
"-",
"dict",
"serialization"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/serializers.py#L18-L28 | [
"def",
"serialize_organization",
"(",
"organization",
")",
":",
"return",
"{",
"'id'",
":",
"organization",
".",
"id",
",",
"'name'",
":",
"organization",
".",
"name",
",",
"'short_name'",
":",
"organization",
".",
"short_name",
",",
"'description'",
":",
"org... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | serialize_organization_with_course | OrganizationCourse serialization (composite object) | organizations/serializers.py | def serialize_organization_with_course(organization_course):
"""
OrganizationCourse serialization (composite object)
"""
return {
'id': organization_course.organization.id,
'name': organization_course.organization.name,
'short_name': organization_course.organization.short_name,
... | def serialize_organization_with_course(organization_course):
"""
OrganizationCourse serialization (composite object)
"""
return {
'id': organization_course.organization.id,
'name': organization_course.organization.name,
'short_name': organization_course.organization.short_name,
... | [
"OrganizationCourse",
"serialization",
"(",
"composite",
"object",
")"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/serializers.py#L31-L42 | [
"def",
"serialize_organization_with_course",
"(",
"organization_course",
")",
":",
"return",
"{",
"'id'",
":",
"organization_course",
".",
"organization",
".",
"id",
",",
"'name'",
":",
"organization_course",
".",
"organization",
".",
"name",
",",
"'short_name'",
":... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | deserialize_organization | Organization dict-to-object serialization | organizations/serializers.py | def deserialize_organization(organization_dict):
"""
Organization dict-to-object serialization
"""
return models.Organization(
id=organization_dict.get('id'),
name=organization_dict.get('name', ''),
short_name=organization_dict.get('short_name', ''),
description=organizat... | def deserialize_organization(organization_dict):
"""
Organization dict-to-object serialization
"""
return models.Organization(
id=organization_dict.get('id'),
name=organization_dict.get('name', ''),
short_name=organization_dict.get('short_name', ''),
description=organizat... | [
"Organization",
"dict",
"-",
"to",
"-",
"object",
"serialization"
] | edx/edx-organizations | python | https://github.com/edx/edx-organizations/blob/51000d5d359d880a6eb3a79345f60744f1982c00/organizations/serializers.py#L53-L63 | [
"def",
"deserialize_organization",
"(",
"organization_dict",
")",
":",
"return",
"models",
".",
"Organization",
"(",
"id",
"=",
"organization_dict",
".",
"get",
"(",
"'id'",
")",
",",
"name",
"=",
"organization_dict",
".",
"get",
"(",
"'name'",
",",
"''",
")... | 51000d5d359d880a6eb3a79345f60744f1982c00 |
valid | ImageExtractor.check_large_images | \
although slow the best way to determine the best image is to download
them and check the actual dimensions of the image when on disk
so we'll go through a phased approach...
1. get a list of ALL images from the parent node
2. filter out any bad image names that we know of (gifs... | goose3/extractors/images.py | def check_large_images(self, node, parent_depth_level, sibling_depth_level):
"""\
although slow the best way to determine the best image is to download
them and check the actual dimensions of the image when on disk
so we'll go through a phased approach...
1. get a list of ALL ima... | def check_large_images(self, node, parent_depth_level, sibling_depth_level):
"""\
although slow the best way to determine the best image is to download
them and check the actual dimensions of the image when on disk
so we'll go through a phased approach...
1. get a list of ALL ima... | [
"\\",
"although",
"slow",
"the",
"best",
"way",
"to",
"determine",
"the",
"best",
"image",
"is",
"to",
"download",
"them",
"and",
"check",
"the",
"actual",
"dimensions",
"of",
"the",
"image",
"when",
"on",
"disk",
"so",
"we",
"ll",
"go",
"through",
"a",
... | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L95-L130 | [
"def",
"check_large_images",
"(",
"self",
",",
"node",
",",
"parent_depth_level",
",",
"sibling_depth_level",
")",
":",
"good_images",
"=",
"self",
".",
"get_image_candidates",
"(",
"node",
")",
"if",
"good_images",
":",
"scored_images",
"=",
"self",
".",
"fetch... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageExtractor.is_banner_dimensions | \
returns true if we think this is kind of a bannery dimension
like 600 / 100 = 6 may be a fishy dimension for a good image | goose3/extractors/images.py | def is_banner_dimensions(width, height):
"""\
returns true if we think this is kind of a bannery dimension
like 600 / 100 = 6 may be a fishy dimension for a good image
"""
if width == height:
return False
if width > height:
diff = float(width / he... | def is_banner_dimensions(width, height):
"""\
returns true if we think this is kind of a bannery dimension
like 600 / 100 = 6 may be a fishy dimension for a good image
"""
if width == height:
return False
if width > height:
diff = float(width / he... | [
"\\",
"returns",
"true",
"if",
"we",
"think",
"this",
"is",
"kind",
"of",
"a",
"bannery",
"dimension",
"like",
"600",
"/",
"100",
"=",
"6",
"may",
"be",
"a",
"fishy",
"dimension",
"for",
"a",
"good",
"image"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L213-L231 | [
"def",
"is_banner_dimensions",
"(",
"width",
",",
"height",
")",
":",
"if",
"width",
"==",
"height",
":",
"return",
"False",
"if",
"width",
">",
"height",
":",
"diff",
"=",
"float",
"(",
"width",
"/",
"height",
")",
"if",
"diff",
">",
"5",
":",
"retu... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageExtractor.is_valid_filename | \
will check the image src against a list
of bad image files we know of like buttons, etc... | goose3/extractors/images.py | def is_valid_filename(self, image_node):
"""\
will check the image src against a list
of bad image files we know of like buttons, etc...
"""
src = self.parser.getAttribute(image_node, attr='src')
if not src:
return False
if self.badimages_names_re.se... | def is_valid_filename(self, image_node):
"""\
will check the image src against a list
of bad image files we know of like buttons, etc...
"""
src = self.parser.getAttribute(image_node, attr='src')
if not src:
return False
if self.badimages_names_re.se... | [
"\\",
"will",
"check",
"the",
"image",
"src",
"against",
"a",
"list",
"of",
"bad",
"image",
"files",
"we",
"know",
"of",
"like",
"buttons",
"etc",
"..."
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L250-L263 | [
"def",
"is_valid_filename",
"(",
"self",
",",
"image_node",
")",
":",
"src",
"=",
"self",
".",
"parser",
".",
"getAttribute",
"(",
"image_node",
",",
"attr",
"=",
"'src'",
")",
"if",
"not",
"src",
":",
"return",
"False",
"if",
"self",
".",
"badimages_nam... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageExtractor.get_images_bytesize_match | \
loop through all the images and find the ones
that have the best bytez to even make them a candidate | goose3/extractors/images.py | def get_images_bytesize_match(self, images):
"""\
loop through all the images and find the ones
that have the best bytez to even make them a candidate
"""
cnt = 0
max_bytes_size = 15728640
good_images = []
for image in images:
if cnt > 30:
... | def get_images_bytesize_match(self, images):
"""\
loop through all the images and find the ones
that have the best bytez to even make them a candidate
"""
cnt = 0
max_bytes_size = 15728640
good_images = []
for image in images:
if cnt > 30:
... | [
"\\",
"loop",
"through",
"all",
"the",
"images",
"and",
"find",
"the",
"ones",
"that",
"have",
"the",
"best",
"bytez",
"to",
"even",
"make",
"them",
"a",
"candidate"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L275-L297 | [
"def",
"get_images_bytesize_match",
"(",
"self",
",",
"images",
")",
":",
"cnt",
"=",
"0",
"max_bytes_size",
"=",
"15728640",
"good_images",
"=",
"[",
"]",
"for",
"image",
"in",
"images",
":",
"if",
"cnt",
">",
"30",
":",
"return",
"good_images",
"src",
... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageExtractor.check_link_tag | \
checks to see if we were able to
find open link_src on this page | goose3/extractors/images.py | def check_link_tag(self):
"""\
checks to see if we were able to
find open link_src on this page
"""
node = self.article.raw_doc
meta = self.parser.getElementsByTag(node, tag='link', attr='rel', value='image_src')
for item in meta:
src = self.parser.get... | def check_link_tag(self):
"""\
checks to see if we were able to
find open link_src on this page
"""
node = self.article.raw_doc
meta = self.parser.getElementsByTag(node, tag='link', attr='rel', value='image_src')
for item in meta:
src = self.parser.get... | [
"\\",
"checks",
"to",
"see",
"if",
"we",
"were",
"able",
"to",
"find",
"open",
"link_src",
"on",
"this",
"page"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L303-L314 | [
"def",
"check_link_tag",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"article",
".",
"raw_doc",
"meta",
"=",
"self",
".",
"parser",
".",
"getElementsByTag",
"(",
"node",
",",
"tag",
"=",
"'link'",
",",
"attr",
"=",
"'rel'",
",",
"value",
"=",
"'... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageExtractor.check_known_schemas | \
checks to see if we were able to find the image via known schemas:
Supported Schemas
- Open Graph
- schema.org | goose3/extractors/images.py | def check_known_schemas(self):
"""\
checks to see if we were able to find the image via known schemas:
Supported Schemas
- Open Graph
- schema.org
"""
if 'image' in self.article.opengraph:
return self.get_image(self.article.opengraph["image"],
... | def check_known_schemas(self):
"""\
checks to see if we were able to find the image via known schemas:
Supported Schemas
- Open Graph
- schema.org
"""
if 'image' in self.article.opengraph:
return self.get_image(self.article.opengraph["image"],
... | [
"\\",
"checks",
"to",
"see",
"if",
"we",
"were",
"able",
"to",
"find",
"the",
"image",
"via",
"known",
"schemas",
":"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L316-L331 | [
"def",
"check_known_schemas",
"(",
"self",
")",
":",
"if",
"'image'",
"in",
"self",
".",
"article",
".",
"opengraph",
":",
"return",
"self",
".",
"get_image",
"(",
"self",
".",
"article",
".",
"opengraph",
"[",
"\"image\"",
"]",
",",
"extraction_type",
"="... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageExtractor.get_local_image | \
returns the bytes of the image file on disk | goose3/extractors/images.py | def get_local_image(self, src):
"""\
returns the bytes of the image file on disk
"""
return ImageUtils.store_image(self.fetcher, self.article.link_hash, src, self.config) | def get_local_image(self, src):
"""\
returns the bytes of the image file on disk
"""
return ImageUtils.store_image(self.fetcher, self.article.link_hash, src, self.config) | [
"\\",
"returns",
"the",
"bytes",
"of",
"the",
"image",
"file",
"on",
"disk"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L333-L337 | [
"def",
"get_local_image",
"(",
"self",
",",
"src",
")",
":",
"return",
"ImageUtils",
".",
"store_image",
"(",
"self",
".",
"fetcher",
",",
"self",
".",
"article",
".",
"link_hash",
",",
"src",
",",
"self",
".",
"config",
")"
] | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageExtractor.build_image_path | \
This method will take an image path and build
out the absolute path to that image
* using the initial url we crawled
so we can find a link to the image
if they use relative urls like ../myimage.jpg | goose3/extractors/images.py | def build_image_path(self, src):
"""\
This method will take an image path and build
out the absolute path to that image
* using the initial url we crawled
so we can find a link to the image
if they use relative urls like ../myimage.jpg
"""
o = urlparse... | def build_image_path(self, src):
"""\
This method will take an image path and build
out the absolute path to that image
* using the initial url we crawled
so we can find a link to the image
if they use relative urls like ../myimage.jpg
"""
o = urlparse... | [
"\\",
"This",
"method",
"will",
"take",
"an",
"image",
"path",
"and",
"build",
"out",
"the",
"absolute",
"path",
"to",
"that",
"image",
"*",
"using",
"the",
"initial",
"url",
"we",
"crawled",
"so",
"we",
"can",
"find",
"a",
"link",
"to",
"the",
"image"... | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/images.py#L392-L405 | [
"def",
"build_image_path",
"(",
"self",
",",
"src",
")",
":",
"o",
"=",
"urlparse",
"(",
"src",
")",
"# we have a full url",
"if",
"o",
".",
"netloc",
"!=",
"''",
":",
"return",
"o",
".",
"geturl",
"(",
")",
"# we have a relative url",
"return",
"urljoin",... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | VideoExtractor.get_video | Create a video object from a video embed | goose3/extractors/videos.py | def get_video(self, node):
"""
Create a video object from a video embed
"""
video = Video()
video._embed_code = self.get_embed_code(node)
video._embed_type = self.get_embed_type(node)
video._width = self.get_width(node)
video._height = self.get_height(node... | def get_video(self, node):
"""
Create a video object from a video embed
"""
video = Video()
video._embed_code = self.get_embed_code(node)
video._embed_type = self.get_embed_type(node)
video._width = self.get_width(node)
video._height = self.get_height(node... | [
"Create",
"a",
"video",
"object",
"from",
"a",
"video",
"embed"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/videos.py#L67-L78 | [
"def",
"get_video",
"(",
"self",
",",
"node",
")",
":",
"video",
"=",
"Video",
"(",
")",
"video",
".",
"_embed_code",
"=",
"self",
".",
"get_embed_code",
"(",
"node",
")",
"video",
".",
"_embed_type",
"=",
"self",
".",
"get_embed_type",
"(",
"node",
")... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | get_encodings_from_content | Code from:
https://github.com/sigmavirus24/requests-toolbelt/blob/master/requests_toolbelt/utils/deprecated.py
Return encodings from given content string.
:param content: string to extract encodings from. | goose3/text.py | def get_encodings_from_content(content):
"""
Code from:
https://github.com/sigmavirus24/requests-toolbelt/blob/master/requests_toolbelt/utils/deprecated.py
Return encodings from given content string.
:param content: string to extract encodings from.
"""
if isinstance(content, bytes):
... | def get_encodings_from_content(content):
"""
Code from:
https://github.com/sigmavirus24/requests-toolbelt/blob/master/requests_toolbelt/utils/deprecated.py
Return encodings from given content string.
:param content: string to extract encodings from.
"""
if isinstance(content, bytes):
... | [
"Code",
"from",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"sigmavirus24",
"/",
"requests",
"-",
"toolbelt",
"/",
"blob",
"/",
"master",
"/",
"requests_toolbelt",
"/",
"utils",
"/",
"deprecated",
".",
"py",
"Return",
"encodings",
"from",
"given",
... | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/text.py#L35-L60 | [
"def",
"get_encodings_from_content",
"(",
"content",
")",
":",
"if",
"isinstance",
"(",
"content",
",",
"bytes",
")",
":",
"find_charset",
"=",
"re",
".",
"compile",
"(",
"br'<meta.*?charset=[\"\\']*([a-z0-9\\-_]+?) *?[\"\\'>]'",
",",
"flags",
"=",
"re",
".",
"I",... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ImageUtils.store_image | \
Writes an image src http string to disk as a temporary file
and returns the LocallyStoredImage object
that has the info you should need on the image | goose3/utils/images.py | def store_image(cls, http_client, link_hash, src, config):
"""\
Writes an image src http string to disk as a temporary file
and returns the LocallyStoredImage object
that has the info you should need on the image
"""
# check for a cache hit already on disk
image =... | def store_image(cls, http_client, link_hash, src, config):
"""\
Writes an image src http string to disk as a temporary file
and returns the LocallyStoredImage object
that has the info you should need on the image
"""
# check for a cache hit already on disk
image =... | [
"\\",
"Writes",
"an",
"image",
"src",
"http",
"string",
"to",
"disk",
"as",
"a",
"temporary",
"file",
"and",
"returns",
"the",
"LocallyStoredImage",
"object",
"that",
"has",
"the",
"info",
"you",
"should",
"need",
"on",
"the",
"image"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/utils/images.py#L60-L85 | [
"def",
"store_image",
"(",
"cls",
",",
"http_client",
",",
"link_hash",
",",
"src",
",",
"config",
")",
":",
"# check for a cache hit already on disk",
"image",
"=",
"cls",
".",
"read_localfile",
"(",
"link_hash",
",",
"src",
",",
"config",
")",
"if",
"image",... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | Configuration.known_context_patterns | val must be an ArticleContextPattern, a dictionary, or list of \
dictionaries
e.g., {'attr': 'class', 'value': 'my-article-class'}
or [{'attr': 'class', 'value': 'my-article-class'},
{'attr': 'id', 'value': 'my-article-id'}] | goose3/configuration.py | def known_context_patterns(self, val):
''' val must be an ArticleContextPattern, a dictionary, or list of \
dictionaries
e.g., {'attr': 'class', 'value': 'my-article-class'}
or [{'attr': 'class', 'value': 'my-article-class'},
{'attr': 'id', 'value': 'm... | def known_context_patterns(self, val):
''' val must be an ArticleContextPattern, a dictionary, or list of \
dictionaries
e.g., {'attr': 'class', 'value': 'my-article-class'}
or [{'attr': 'class', 'value': 'my-article-class'},
{'attr': 'id', 'value': 'm... | [
"val",
"must",
"be",
"an",
"ArticleContextPattern",
"a",
"dictionary",
"or",
"list",
"of",
"\\",
"dictionaries",
"e",
".",
"g",
".",
"{",
"attr",
":",
"class",
"value",
":",
"my",
"-",
"article",
"-",
"class",
"}",
"or",
"[",
"{",
"attr",
":",
"class... | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/configuration.py#L216-L249 | [
"def",
"known_context_patterns",
"(",
"self",
",",
"val",
")",
":",
"def",
"create_pat_from_dict",
"(",
"val",
")",
":",
"'''Helper function used to create an ArticleContextPattern from a dictionary\n '''",
"if",
"\"tag\"",
"in",
"val",
":",
"pat",
"=",
"Articl... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | Configuration.known_publish_date_tags | val must be a dictionary or list of dictionaries
e.g., {'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'}
or [{'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'},
{'attrribute': 'property', 'value': 'pub_time', 'content': 'content'}] | goose3/configuration.py | def known_publish_date_tags(self, val):
''' val must be a dictionary or list of dictionaries
e.g., {'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'}
or [{'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'},
{'attrribute': 'proper... | def known_publish_date_tags(self, val):
''' val must be a dictionary or list of dictionaries
e.g., {'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'}
or [{'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'},
{'attrribute': 'proper... | [
"val",
"must",
"be",
"a",
"dictionary",
"or",
"list",
"of",
"dictionaries",
"e",
".",
"g",
".",
"{",
"attrribute",
":",
"name",
"value",
":",
"my",
"-",
"pubdate",
"content",
":",
"datetime",
"}",
"or",
"[",
"{",
"attrribute",
":",
"name",
"value",
"... | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/configuration.py#L262-L297 | [
"def",
"known_publish_date_tags",
"(",
"self",
",",
"val",
")",
":",
"def",
"create_pat_from_dict",
"(",
"val",
")",
":",
"'''Helper function used to create an PublishDatePattern from a dictionary\n '''",
"if",
"\"tag\"",
"in",
"val",
":",
"pat",
"=",
"PublishD... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | Configuration.known_author_patterns | val must be a dictionary or list of dictionaries
e.g., {'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'}
or [{'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'},
{'attrribute': 'property', 'value': 'pub_time', 'content': 'content'}] | goose3/configuration.py | def known_author_patterns(self, val):
''' val must be a dictionary or list of dictionaries
e.g., {'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'}
or [{'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'},
{'attrribute': 'property... | def known_author_patterns(self, val):
''' val must be a dictionary or list of dictionaries
e.g., {'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'}
or [{'attrribute': 'name', 'value': 'my-pubdate', 'content': 'datetime'},
{'attrribute': 'property... | [
"val",
"must",
"be",
"a",
"dictionary",
"or",
"list",
"of",
"dictionaries",
"e",
".",
"g",
".",
"{",
"attrribute",
":",
"name",
"value",
":",
"my",
"-",
"pubdate",
"content",
":",
"datetime",
"}",
"or",
"[",
"{",
"attrribute",
":",
"name",
"value",
"... | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/configuration.py#L310-L343 | [
"def",
"known_author_patterns",
"(",
"self",
",",
"val",
")",
":",
"def",
"create_pat_from_dict",
"(",
"val",
")",
":",
"'''Helper function used to create an AuthorPatterns from a dictionary\n '''",
"if",
"\"tag\"",
"in",
"val",
":",
"pat",
"=",
"AuthorPattern"... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ContentExtractor.get_siblings_content | adds any siblings that may have a decent score to this node | goose3/extractors/content.py | def get_siblings_content(self, current_sibling, baselinescore_siblings_para):
"""
adds any siblings that may have a decent score to this node
"""
if current_sibling.tag == 'p' and self.parser.getText(current_sibling):
tmp = current_sibling
if tmp.tail:
... | def get_siblings_content(self, current_sibling, baselinescore_siblings_para):
"""
adds any siblings that may have a decent score to this node
"""
if current_sibling.tag == 'p' and self.parser.getText(current_sibling):
tmp = current_sibling
if tmp.tail:
... | [
"adds",
"any",
"siblings",
"that",
"may",
"have",
"a",
"decent",
"score",
"to",
"this",
"node"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/content.py#L198-L225 | [
"def",
"get_siblings_content",
"(",
"self",
",",
"current_sibling",
",",
"baselinescore_siblings_para",
")",
":",
"if",
"current_sibling",
".",
"tag",
"==",
"'p'",
"and",
"self",
".",
"parser",
".",
"getText",
"(",
"current_sibling",
")",
":",
"tmp",
"=",
"cur... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ContentExtractor.is_highlink_density | checks the density of links within a node,
is there not much text and most of it contains linky shit?
if so it's no good | goose3/extractors/content.py | def is_highlink_density(self, element):
"""
checks the density of links within a node,
is there not much text and most of it contains linky shit?
if so it's no good
"""
links = self.parser.getElementsByTag(element, tag='a')
if not links:
return False
... | def is_highlink_density(self, element):
"""
checks the density of links within a node,
is there not much text and most of it contains linky shit?
if so it's no good
"""
links = self.parser.getElementsByTag(element, tag='a')
if not links:
return False
... | [
"checks",
"the",
"density",
"of",
"links",
"within",
"a",
"node",
"is",
"there",
"not",
"much",
"text",
"and",
"most",
"of",
"it",
"contains",
"linky",
"shit?",
"if",
"so",
"it",
"s",
"no",
"good"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/content.py#L281-L306 | [
"def",
"is_highlink_density",
"(",
"self",
",",
"element",
")",
":",
"links",
"=",
"self",
".",
"parser",
".",
"getElementsByTag",
"(",
"element",
",",
"tag",
"=",
"'a'",
")",
"if",
"not",
"links",
":",
"return",
"False",
"text",
"=",
"self",
".",
"par... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ContentExtractor.nodes_to_check | \
returns a list of nodes we want to search
on like paragraphs and tables | goose3/extractors/content.py | def nodes_to_check(self, docs):
"""\
returns a list of nodes we want to search
on like paragraphs and tables
"""
nodes_to_check = []
for doc in docs:
for tag in ['p', 'pre', 'td']:
items = self.parser.getElementsByTag(doc, tag=tag)
... | def nodes_to_check(self, docs):
"""\
returns a list of nodes we want to search
on like paragraphs and tables
"""
nodes_to_check = []
for doc in docs:
for tag in ['p', 'pre', 'td']:
items = self.parser.getElementsByTag(doc, tag=tag)
... | [
"\\",
"returns",
"a",
"list",
"of",
"nodes",
"we",
"want",
"to",
"search",
"on",
"like",
"paragraphs",
"and",
"tables"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/content.py#L321-L332 | [
"def",
"nodes_to_check",
"(",
"self",
",",
"docs",
")",
":",
"nodes_to_check",
"=",
"[",
"]",
"for",
"doc",
"in",
"docs",
":",
"for",
"tag",
"in",
"[",
"'p'",
",",
"'pre'",
",",
"'td'",
"]",
":",
"items",
"=",
"self",
".",
"parser",
".",
"getElemen... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | ContentExtractor.post_cleanup | \
remove any divs that looks like non-content,
clusters of links, or paras with no gusto | goose3/extractors/content.py | def post_cleanup(self):
"""\
remove any divs that looks like non-content,
clusters of links, or paras with no gusto
"""
parse_tags = ['p']
if self.config.parse_lists:
parse_tags.extend(['ul', 'ol'])
if self.config.parse_headers:
parse_tags.... | def post_cleanup(self):
"""\
remove any divs that looks like non-content,
clusters of links, or paras with no gusto
"""
parse_tags = ['p']
if self.config.parse_lists:
parse_tags.extend(['ul', 'ol'])
if self.config.parse_headers:
parse_tags.... | [
"\\",
"remove",
"any",
"divs",
"that",
"looks",
"like",
"non",
"-",
"content",
"clusters",
"of",
"links",
"or",
"paras",
"with",
"no",
"gusto"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/content.py#L355-L374 | [
"def",
"post_cleanup",
"(",
"self",
")",
":",
"parse_tags",
"=",
"[",
"'p'",
"]",
"if",
"self",
".",
"config",
".",
"parse_lists",
":",
"parse_tags",
".",
"extend",
"(",
"[",
"'ul'",
",",
"'ol'",
"]",
")",
"if",
"self",
".",
"config",
".",
"parse_hea... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | Article.infos | dict: The summation of all data available about the extracted article
Note:
Read only | goose3/article.py | def infos(self):
''' dict: The summation of all data available about the extracted article
Note:
Read only '''
data = {
"meta": {
"description": self.meta_description,
"lang": self.meta_lang,
"keywords": self.meta_k... | def infos(self):
''' dict: The summation of all data available about the extracted article
Note:
Read only '''
data = {
"meta": {
"description": self.meta_description,
"lang": self.meta_lang,
"keywords": self.meta_k... | [
"dict",
":",
"The",
"summation",
"of",
"all",
"data",
"available",
"about",
"the",
"extracted",
"article"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/article.py#L271-L318 | [
"def",
"infos",
"(",
"self",
")",
":",
"data",
"=",
"{",
"\"meta\"",
":",
"{",
"\"description\"",
":",
"self",
".",
"meta_description",
",",
"\"lang\"",
":",
"self",
".",
"meta_lang",
",",
"\"keywords\"",
":",
"self",
".",
"meta_keywords",
",",
"\"favicon\... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | TitleExtractor.clean_title | Clean title with the use of og:site_name
in this case try to get rid of site name
and use TITLE_SPLITTERS to reformat title | goose3/extractors/title.py | def clean_title(self, title):
"""Clean title with the use of og:site_name
in this case try to get rid of site name
and use TITLE_SPLITTERS to reformat title
"""
# check if we have the site name in opengraph data
if "site_name" in list(self.article.opengraph.keys()):
... | def clean_title(self, title):
"""Clean title with the use of og:site_name
in this case try to get rid of site name
and use TITLE_SPLITTERS to reformat title
"""
# check if we have the site name in opengraph data
if "site_name" in list(self.article.opengraph.keys()):
... | [
"Clean",
"title",
"with",
"the",
"use",
"of",
"og",
":",
"site_name",
"in",
"this",
"case",
"try",
"to",
"get",
"rid",
"of",
"site",
"name",
"and",
"use",
"TITLE_SPLITTERS",
"to",
"reformat",
"title"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/title.py#L33-L77 | [
"def",
"clean_title",
"(",
"self",
",",
"title",
")",
":",
"# check if we have the site name in opengraph data",
"if",
"\"site_name\"",
"in",
"list",
"(",
"self",
".",
"article",
".",
"opengraph",
".",
"keys",
"(",
")",
")",
":",
"site_name",
"=",
"self",
".",... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | TitleExtractor.get_title | \
Fetch the article title and analyze it | goose3/extractors/title.py | def get_title(self):
"""\
Fetch the article title and analyze it
"""
title = ''
# rely on opengraph in case we have the data
if "title" in list(self.article.opengraph.keys()):
return self.clean_title(self.article.opengraph['title'])
elif self.article.... | def get_title(self):
"""\
Fetch the article title and analyze it
"""
title = ''
# rely on opengraph in case we have the data
if "title" in list(self.article.opengraph.keys()):
return self.clean_title(self.article.opengraph['title'])
elif self.article.... | [
"\\",
"Fetch",
"the",
"article",
"title",
"and",
"analyze",
"it"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/title.py#L79-L106 | [
"def",
"get_title",
"(",
"self",
")",
":",
"title",
"=",
"''",
"# rely on opengraph in case we have the data",
"if",
"\"title\"",
"in",
"list",
"(",
"self",
".",
"article",
".",
"opengraph",
".",
"keys",
"(",
")",
")",
":",
"return",
"self",
".",
"clean_titl... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | MetasExtractor.get_canonical_link | if the article has meta canonical link set in the url | goose3/extractors/metas.py | def get_canonical_link(self):
"""
if the article has meta canonical link set in the url
"""
if self.article.final_url:
kwargs = {'tag': 'link', 'attr': 'rel', 'value': 'canonical'}
meta = self.parser.getElementsByTag(self.article.doc, **kwargs)
if meta... | def get_canonical_link(self):
"""
if the article has meta canonical link set in the url
"""
if self.article.final_url:
kwargs = {'tag': 'link', 'attr': 'rel', 'value': 'canonical'}
meta = self.parser.getElementsByTag(self.article.doc, **kwargs)
if meta... | [
"if",
"the",
"article",
"has",
"meta",
"canonical",
"link",
"set",
"in",
"the",
"url"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/extractors/metas.py#L57-L74 | [
"def",
"get_canonical_link",
"(",
"self",
")",
":",
"if",
"self",
".",
"article",
".",
"final_url",
":",
"kwargs",
"=",
"{",
"'tag'",
":",
"'link'",
",",
"'attr'",
":",
"'rel'",
",",
"'value'",
":",
"'canonical'",
"}",
"meta",
"=",
"self",
".",
"parser... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | OutputFormatter.make_list_elms_pretty | make any list element read like a list | goose3/outputformatters.py | def make_list_elms_pretty(self):
""" make any list element read like a list
"""
for elm in self.parser.getElementsByTag(self.top_node, tag='li'):
elm.text = r'• {}'.format(elm.text) | def make_list_elms_pretty(self):
""" make any list element read like a list
"""
for elm in self.parser.getElementsByTag(self.top_node, tag='li'):
elm.text = r'• {}'.format(elm.text) | [
"make",
"any",
"list",
"element",
"read",
"like",
"a",
"list"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/outputformatters.py#L104-L108 | [
"def",
"make_list_elms_pretty",
"(",
"self",
")",
":",
"for",
"elm",
"in",
"self",
".",
"parser",
".",
"getElementsByTag",
"(",
"self",
".",
"top_node",
",",
"tag",
"=",
"'li'",
")",
":",
"elm",
".",
"text",
"=",
"r'• {}'.f",
"o",
"rmat(e",
"l",
"m.t",... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | Goose.close | Close the network connection and perform any other required cleanup
Note:
Auto closed when using goose as a context manager or when garbage collected | goose3/__init__.py | def close(self):
''' Close the network connection and perform any other required cleanup
Note:
Auto closed when using goose as a context manager or when garbage collected '''
if self.fetcher is not None:
self.shutdown_network()
self.finalizer.atexit = Fal... | def close(self):
''' Close the network connection and perform any other required cleanup
Note:
Auto closed when using goose as a context manager or when garbage collected '''
if self.fetcher is not None:
self.shutdown_network()
self.finalizer.atexit = Fal... | [
"Close",
"the",
"network",
"connection",
"and",
"perform",
"any",
"other",
"required",
"cleanup"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/__init__.py#L94-L101 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"fetcher",
"is",
"not",
"None",
":",
"self",
".",
"shutdown_network",
"(",
")",
"self",
".",
"finalizer",
".",
"atexit",
"=",
"False"
] | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | Goose.extract | Extract the most likely article content from the html page
Args:
url (str): URL to pull and parse
raw_html (str): String representation of the HTML page
Returns:
Article: Representation of the article contents \
including other par... | goose3/__init__.py | def extract(self, url=None, raw_html=None):
''' Extract the most likely article content from the html page
Args:
url (str): URL to pull and parse
raw_html (str): String representation of the HTML page
Returns:
Article: Representation of th... | def extract(self, url=None, raw_html=None):
''' Extract the most likely article content from the html page
Args:
url (str): URL to pull and parse
raw_html (str): String representation of the HTML page
Returns:
Article: Representation of th... | [
"Extract",
"the",
"most",
"likely",
"article",
"content",
"from",
"the",
"html",
"page"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/__init__.py#L103-L113 | [
"def",
"extract",
"(",
"self",
",",
"url",
"=",
"None",
",",
"raw_html",
"=",
"None",
")",
":",
"crawl_candidate",
"=",
"CrawlCandidate",
"(",
"self",
".",
"config",
",",
"url",
",",
"raw_html",
")",
"return",
"self",
".",
"__crawl",
"(",
"crawl_candidat... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | Goose.__crawl | wrap the crawling functionality | goose3/__init__.py | def __crawl(self, crawl_candidate):
''' wrap the crawling functionality '''
def crawler_wrapper(parser, parsers_lst, crawl_candidate):
try:
crawler = Crawler(self.config, self.fetcher)
article = crawler.crawl(crawl_candidate)
except (UnicodeDecodeE... | def __crawl(self, crawl_candidate):
''' wrap the crawling functionality '''
def crawler_wrapper(parser, parsers_lst, crawl_candidate):
try:
crawler = Crawler(self.config, self.fetcher)
article = crawler.crawl(crawl_candidate)
except (UnicodeDecodeE... | [
"wrap",
"the",
"crawling",
"functionality"
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/__init__.py#L123-L140 | [
"def",
"__crawl",
"(",
"self",
",",
"crawl_candidate",
")",
":",
"def",
"crawler_wrapper",
"(",
"parser",
",",
"parsers_lst",
",",
"crawl_candidate",
")",
":",
"try",
":",
"crawler",
"=",
"Crawler",
"(",
"self",
".",
"config",
",",
"self",
".",
"fetcher",
... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | smart_unicode | Returns a unicode object representing 's'. Treats bytestrings using the
'encoding' codec.
If strings_only is True, don't convert (some) non-string-like objects. | goose3/utils/encoding.py | def smart_unicode(string, encoding='utf-8', strings_only=False, errors='strict'):
"""
Returns a unicode object representing 's'. Treats bytestrings using the
'encoding' codec.
If strings_only is True, don't convert (some) non-string-like objects.
"""
# if isinstance(s, Promise):
# # The... | def smart_unicode(string, encoding='utf-8', strings_only=False, errors='strict'):
"""
Returns a unicode object representing 's'. Treats bytestrings using the
'encoding' codec.
If strings_only is True, don't convert (some) non-string-like objects.
"""
# if isinstance(s, Promise):
# # The... | [
"Returns",
"a",
"unicode",
"object",
"representing",
"s",
".",
"Treats",
"bytestrings",
"using",
"the",
"encoding",
"codec",
"."
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/utils/encoding.py#L28-L38 | [
"def",
"smart_unicode",
"(",
"string",
",",
"encoding",
"=",
"'utf-8'",
",",
"strings_only",
"=",
"False",
",",
"errors",
"=",
"'strict'",
")",
":",
"# if isinstance(s, Promise):",
"# # The input is the result of a gettext_lazy() call.",
"# return s",
"return",
"f... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | force_unicode | Similar to smart_unicode, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects. | goose3/utils/encoding.py | def force_unicode(string, encoding='utf-8', strings_only=False, errors='strict'):
"""
Similar to smart_unicode, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects.
"""
# Handle the common ca... | def force_unicode(string, encoding='utf-8', strings_only=False, errors='strict'):
"""
Similar to smart_unicode, except that lazy instances are resolved to
strings, rather than kept as lazy objects.
If strings_only is True, don't convert (some) non-string-like objects.
"""
# Handle the common ca... | [
"Similar",
"to",
"smart_unicode",
"except",
"that",
"lazy",
"instances",
"are",
"resolved",
"to",
"strings",
"rather",
"than",
"kept",
"as",
"lazy",
"objects",
"."
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/utils/encoding.py#L52-L101 | [
"def",
"force_unicode",
"(",
"string",
",",
"encoding",
"=",
"'utf-8'",
",",
"strings_only",
"=",
"False",
",",
"errors",
"=",
"'strict'",
")",
":",
"# Handle the common case first, saves 30-40% in performance when s",
"# is an instance of unicode. This function gets called oft... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | smart_str | Returns a bytestring version of 's', encoded as specified in 'encoding'.
If strings_only is True, don't convert (some) non-string-like objects. | goose3/utils/encoding.py | def smart_str(string, encoding='utf-8', strings_only=False, errors='strict'):
"""
Returns a bytestring version of 's', encoded as specified in 'encoding'.
If strings_only is True, don't convert (some) non-string-like objects.
"""
if strings_only and isinstance(string, (type(None), int)):
re... | def smart_str(string, encoding='utf-8', strings_only=False, errors='strict'):
"""
Returns a bytestring version of 's', encoded as specified in 'encoding'.
If strings_only is True, don't convert (some) non-string-like objects.
"""
if strings_only and isinstance(string, (type(None), int)):
re... | [
"Returns",
"a",
"bytestring",
"version",
"of",
"s",
"encoded",
"as",
"specified",
"in",
"encoding",
"."
] | goose3/goose3 | python | https://github.com/goose3/goose3/blob/e6994b1b1826af2720a091d1bff5ca15594f558d/goose3/utils/encoding.py#L104-L131 | [
"def",
"smart_str",
"(",
"string",
",",
"encoding",
"=",
"'utf-8'",
",",
"strings_only",
"=",
"False",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"strings_only",
"and",
"isinstance",
"(",
"string",
",",
"(",
"type",
"(",
"None",
")",
",",
"int",
"... | e6994b1b1826af2720a091d1bff5ca15594f558d |
valid | QuillAdmin.get_urls | Add URLs needed to handle image uploads. | quill/admin.py | def get_urls(self):
"""Add URLs needed to handle image uploads."""
urls = patterns(
'',
url(r'^upload/$', self.admin_site.admin_view(self.handle_upload), name='quill-file-upload'),
)
return urls + super(QuillAdmin, self).get_urls() | def get_urls(self):
"""Add URLs needed to handle image uploads."""
urls = patterns(
'',
url(r'^upload/$', self.admin_site.admin_view(self.handle_upload), name='quill-file-upload'),
)
return urls + super(QuillAdmin, self).get_urls() | [
"Add",
"URLs",
"needed",
"to",
"handle",
"image",
"uploads",
"."
] | coremke/django-quill | python | https://github.com/coremke/django-quill/blob/6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f/quill/admin.py#L15-L21 | [
"def",
"get_urls",
"(",
"self",
")",
":",
"urls",
"=",
"patterns",
"(",
"''",
",",
"url",
"(",
"r'^upload/$'",
",",
"self",
".",
"admin_site",
".",
"admin_view",
"(",
"self",
".",
"handle_upload",
")",
",",
"name",
"=",
"'quill-file-upload'",
")",
",",
... | 6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f |
valid | QuillAdmin.handle_upload | Handle file uploads from WYSIWYG. | quill/admin.py | def handle_upload(self, request):
"""Handle file uploads from WYSIWYG."""
if request.method != 'POST':
raise Http404
if request.is_ajax():
try:
filename = request.GET['quillUploadFile']
data = request
is_raw = True
... | def handle_upload(self, request):
"""Handle file uploads from WYSIWYG."""
if request.method != 'POST':
raise Http404
if request.is_ajax():
try:
filename = request.GET['quillUploadFile']
data = request
is_raw = True
... | [
"Handle",
"file",
"uploads",
"from",
"WYSIWYG",
"."
] | coremke/django-quill | python | https://github.com/coremke/django-quill/blob/6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f/quill/admin.py#L23-L51 | [
"def",
"handle_upload",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"method",
"!=",
"'POST'",
":",
"raise",
"Http404",
"if",
"request",
".",
"is_ajax",
"(",
")",
":",
"try",
":",
"filename",
"=",
"request",
".",
"GET",
"[",
"'quillUplo... | 6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f |
valid | QuillEditorWidget.render | Render the Quill WYSIWYG. | quill/widgets.py | def render(self, name, value, attrs={}):
"""Render the Quill WYSIWYG."""
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, name=name)
quill_app = apps.get_app_config('quill')
quill_config = getattr(quill_app, self.config)
return mark_safe(ren... | def render(self, name, value, attrs={}):
"""Render the Quill WYSIWYG."""
if value is None:
value = ''
final_attrs = self.build_attrs(attrs, name=name)
quill_app = apps.get_app_config('quill')
quill_config = getattr(quill_app, self.config)
return mark_safe(ren... | [
"Render",
"the",
"Quill",
"WYSIWYG",
"."
] | coremke/django-quill | python | https://github.com/coremke/django-quill/blob/6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f/quill/widgets.py#L35-L48 | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"{",
"}",
")",
":",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"''",
"final_attrs",
"=",
"self",
".",
"build_attrs",
"(",
"attrs",
",",
"name",
"=",
"name",
")",
"qu... | 6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f |
valid | RichTextField.formfield | Get the form for field. | quill/fields.py | def formfield(self, **kwargs):
"""Get the form for field."""
defaults = {
'form_class': RichTextFormField,
'config': self.config,
}
defaults.update(kwargs)
return super(RichTextField, self).formfield(**defaults) | def formfield(self, **kwargs):
"""Get the form for field."""
defaults = {
'form_class': RichTextFormField,
'config': self.config,
}
defaults.update(kwargs)
return super(RichTextField, self).formfield(**defaults) | [
"Get",
"the",
"form",
"for",
"field",
"."
] | coremke/django-quill | python | https://github.com/coremke/django-quill/blob/6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f/quill/fields.py#L20-L27 | [
"def",
"formfield",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'form_class'",
":",
"RichTextFormField",
",",
"'config'",
":",
"self",
".",
"config",
",",
"}",
"defaults",
".",
"update",
"(",
"kwargs",
")",
"return",
"super",
... | 6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f |
valid | render_toolbar | Render the toolbar for the given config. | quill/templatetags/quill_tags.py | def render_toolbar(context, config):
"""Render the toolbar for the given config."""
quill_config = getattr(quill_app, config)
t = template.loader.get_template(quill_config['toolbar_template'])
return t.render(context) | def render_toolbar(context, config):
"""Render the toolbar for the given config."""
quill_config = getattr(quill_app, config)
t = template.loader.get_template(quill_config['toolbar_template'])
return t.render(context) | [
"Render",
"the",
"toolbar",
"for",
"the",
"given",
"config",
"."
] | coremke/django-quill | python | https://github.com/coremke/django-quill/blob/6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f/quill/templatetags/quill_tags.py#L26-L30 | [
"def",
"render_toolbar",
"(",
"context",
",",
"config",
")",
":",
"quill_config",
"=",
"getattr",
"(",
"quill_app",
",",
"config",
")",
"t",
"=",
"template",
".",
"loader",
".",
"get_template",
"(",
"quill_config",
"[",
"'toolbar_template'",
"]",
")",
"retur... | 6c5ace1a96e291f0a8e401f6d61d634dd0cb7c9f |
valid | get_meta_image_url | Resize an image for metadata tags, and return an absolute URL to it. | wagtailmetadata/tags.py | def get_meta_image_url(request, image):
"""
Resize an image for metadata tags, and return an absolute URL to it.
"""
rendition = image.get_rendition(filter='original')
return request.build_absolute_uri(rendition.url) | def get_meta_image_url(request, image):
"""
Resize an image for metadata tags, and return an absolute URL to it.
"""
rendition = image.get_rendition(filter='original')
return request.build_absolute_uri(rendition.url) | [
"Resize",
"an",
"image",
"for",
"metadata",
"tags",
"and",
"return",
"an",
"absolute",
"URL",
"to",
"it",
"."
] | neon-jungle/wagtail-metadata | python | https://github.com/neon-jungle/wagtail-metadata/blob/f8592dc3f2b644fa28de5b3585504899b1bb796a/wagtailmetadata/tags.py#L4-L9 | [
"def",
"get_meta_image_url",
"(",
"request",
",",
"image",
")",
":",
"rendition",
"=",
"image",
".",
"get_rendition",
"(",
"filter",
"=",
"'original'",
")",
"return",
"request",
".",
"build_absolute_uri",
"(",
"rendition",
".",
"url",
")"
] | f8592dc3f2b644fa28de5b3585504899b1bb796a |
valid | MDP.read | Read and parse mdp file *filename*. | gromacs/fileformats/mdp.py | def read(self, filename=None):
"""Read and parse mdp file *filename*."""
self._init_filename(filename)
def BLANK(i):
return "B{0:04d}".format(i)
def COMMENT(i):
return "C{0:04d}".format(i)
data = odict()
iblank = icomment = 0
with open(se... | def read(self, filename=None):
"""Read and parse mdp file *filename*."""
self._init_filename(filename)
def BLANK(i):
return "B{0:04d}".format(i)
def COMMENT(i):
return "C{0:04d}".format(i)
data = odict()
iblank = icomment = 0
with open(se... | [
"Read",
"and",
"parse",
"mdp",
"file",
"*",
"filename",
"*",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/fileformats/mdp.py#L95-L130 | [
"def",
"read",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"self",
".",
"_init_filename",
"(",
"filename",
")",
"def",
"BLANK",
"(",
"i",
")",
":",
"return",
"\"B{0:04d}\"",
".",
"format",
"(",
"i",
")",
"def",
"COMMENT",
"(",
"i",
")",
":... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | MDP.write | Write mdp file to *filename*.
:Keywords:
*filename*
output mdp file; default is the filename the mdp
was read from
*skipempty* : boolean
``True`` removes any parameter lines from output that
contain empty values [``False``]
... | gromacs/fileformats/mdp.py | def write(self, filename=None, skipempty=False):
"""Write mdp file to *filename*.
:Keywords:
*filename*
output mdp file; default is the filename the mdp
was read from
*skipempty* : boolean
``True`` removes any parameter lines from outpu... | def write(self, filename=None, skipempty=False):
"""Write mdp file to *filename*.
:Keywords:
*filename*
output mdp file; default is the filename the mdp
was read from
*skipempty* : boolean
``True`` removes any parameter lines from outpu... | [
"Write",
"mdp",
"file",
"to",
"*",
"filename",
"*",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/fileformats/mdp.py#L133-L160 | [
"def",
"write",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"skipempty",
"=",
"False",
")",
":",
"with",
"open",
"(",
"self",
".",
"filename",
"(",
"filename",
",",
"ext",
"=",
"'mdp'",
")",
",",
"'w'",
")",
"as",
"mdp",
":",
"for",
"k",
",",... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | find_gromacs_command | Return *driver* and *name* of the first command that can be found on :envvar:`PATH` | gromacs/run.py | def find_gromacs_command(commands):
"""Return *driver* and *name* of the first command that can be found on :envvar:`PATH`"""
# We could try executing 'name' or 'driver name' but to keep things lean we
# just check if the executables can be found and then hope for the best.
commands = utilities.asiter... | def find_gromacs_command(commands):
"""Return *driver* and *name* of the first command that can be found on :envvar:`PATH`"""
# We could try executing 'name' or 'driver name' but to keep things lean we
# just check if the executables can be found and then hope for the best.
commands = utilities.asiter... | [
"Return",
"*",
"driver",
"*",
"and",
"*",
"name",
"*",
"of",
"the",
"first",
"command",
"that",
"can",
"be",
"found",
"on",
":",
"envvar",
":",
"PATH"
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L52-L71 | [
"def",
"find_gromacs_command",
"(",
"commands",
")",
":",
"# We could try executing 'name' or 'driver name' but to keep things lean we",
"# just check if the executables can be found and then hope for the best.",
"commands",
"=",
"utilities",
".",
"asiterable",
"(",
"commands",
")",
... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | check_mdrun_success | Check if ``mdrun`` finished successfully.
Analyses the output from ``mdrun`` in *logfile*. Right now we are
simply looking for the line "Finished mdrun on node" in the last 1kb of
the file. (The file must be seeakable.)
:Arguments:
*logfile* : filename
Logfile produced by ``mdrun``.
... | gromacs/run.py | def check_mdrun_success(logfile):
"""Check if ``mdrun`` finished successfully.
Analyses the output from ``mdrun`` in *logfile*. Right now we are
simply looking for the line "Finished mdrun on node" in the last 1kb of
the file. (The file must be seeakable.)
:Arguments:
*logfile* : filename
... | def check_mdrun_success(logfile):
"""Check if ``mdrun`` finished successfully.
Analyses the output from ``mdrun`` in *logfile*. Right now we are
simply looking for the line "Finished mdrun on node" in the last 1kb of
the file. (The file must be seeakable.)
:Arguments:
*logfile* : filename
... | [
"Check",
"if",
"mdrun",
"finished",
"successfully",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L314-L336 | [
"def",
"check_mdrun_success",
"(",
"logfile",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"logfile",
")",
":",
"return",
"None",
"with",
"open",
"(",
"logfile",
",",
"'rb'",
")",
"as",
"log",
":",
"log",
".",
"seek",
"(",
"-",
"10... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | get_double_or_single_prec_mdrun | Return double precision ``mdrun`` or fall back to single precision.
This convenience function tries :func:`gromacs.mdrun_d` first and
if it cannot run it, falls back to :func:`gromacs.mdrun` (without
further checking).
.. versionadded:: 0.5.1 | gromacs/run.py | def get_double_or_single_prec_mdrun():
"""Return double precision ``mdrun`` or fall back to single precision.
This convenience function tries :func:`gromacs.mdrun_d` first and
if it cannot run it, falls back to :func:`gromacs.mdrun` (without
further checking).
.. versionadded:: 0.5.1
"""
t... | def get_double_or_single_prec_mdrun():
"""Return double precision ``mdrun`` or fall back to single precision.
This convenience function tries :func:`gromacs.mdrun_d` first and
if it cannot run it, falls back to :func:`gromacs.mdrun` (without
further checking).
.. versionadded:: 0.5.1
"""
t... | [
"Return",
"double",
"precision",
"mdrun",
"or",
"fall",
"back",
"to",
"single",
"precision",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L339-L358 | [
"def",
"get_double_or_single_prec_mdrun",
"(",
")",
":",
"try",
":",
"gromacs",
".",
"mdrun_d",
"(",
"h",
"=",
"True",
",",
"stdout",
"=",
"False",
",",
"stderr",
"=",
"False",
")",
"logger",
".",
"debug",
"(",
"\"using double precision gromacs.mdrun_d\"",
")"... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | MDrunner.commandline | Returns simple command line to invoke mdrun.
If :attr:`mpiexec` is set then :meth:`mpicommand` provides the mpi
launcher command that prefixes the actual ``mdrun`` invocation:
:attr:`mpiexec` [*mpiargs*] :attr:`mdrun` [*mdrun-args*]
The *mdrun-args* are set on initializing the cla... | gromacs/run.py | def commandline(self, **mpiargs):
"""Returns simple command line to invoke mdrun.
If :attr:`mpiexec` is set then :meth:`mpicommand` provides the mpi
launcher command that prefixes the actual ``mdrun`` invocation:
:attr:`mpiexec` [*mpiargs*] :attr:`mdrun` [*mdrun-args*]
The... | def commandline(self, **mpiargs):
"""Returns simple command line to invoke mdrun.
If :attr:`mpiexec` is set then :meth:`mpicommand` provides the mpi
launcher command that prefixes the actual ``mdrun`` invocation:
:attr:`mpiexec` [*mpiargs*] :attr:`mdrun` [*mdrun-args*]
The... | [
"Returns",
"simple",
"command",
"line",
"to",
"invoke",
"mdrun",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L160-L175 | [
"def",
"commandline",
"(",
"self",
",",
"*",
"*",
"mpiargs",
")",
":",
"cmd",
"=",
"self",
".",
"MDRUN",
".",
"commandline",
"(",
")",
"if",
"self",
".",
"mpiexec",
":",
"cmd",
"=",
"self",
".",
"mpicommand",
"(",
"*",
"*",
"mpiargs",
")",
"+",
"... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | MDrunner.mpicommand | Return a list of the mpi command portion of the commandline.
Only allows primitive mpi at the moment:
*mpiexec* -n *ncores* *mdrun* *mdrun-args*
(This is a primitive example for OpenMP. Override it for more
complicated cases.) | gromacs/run.py | def mpicommand(self, *args, **kwargs):
"""Return a list of the mpi command portion of the commandline.
Only allows primitive mpi at the moment:
*mpiexec* -n *ncores* *mdrun* *mdrun-args*
(This is a primitive example for OpenMP. Override it for more
complicated cases.)
... | def mpicommand(self, *args, **kwargs):
"""Return a list of the mpi command portion of the commandline.
Only allows primitive mpi at the moment:
*mpiexec* -n *ncores* *mdrun* *mdrun-args*
(This is a primitive example for OpenMP. Override it for more
complicated cases.)
... | [
"Return",
"a",
"list",
"of",
"the",
"mpi",
"command",
"portion",
"of",
"the",
"commandline",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L177-L190 | [
"def",
"mpicommand",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"mpiexec",
"is",
"None",
":",
"raise",
"NotImplementedError",
"(",
"\"Override mpiexec to enable the simple OpenMP launcher\"",
")",
"# example implementation",... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | MDrunner.run | Execute the mdrun command (possibly as a MPI command) and run the simulation.
:Keywords:
*pre*
a dictionary containing keyword arguments for the :meth:`prehook`
*post*
a dictionary containing keyword arguments for the :meth:`posthook`
*mdrunargs*
... | gromacs/run.py | def run(self, pre=None, post=None, mdrunargs=None, **mpiargs):
"""Execute the mdrun command (possibly as a MPI command) and run the simulation.
:Keywords:
*pre*
a dictionary containing keyword arguments for the :meth:`prehook`
*post*
a dictionary containing... | def run(self, pre=None, post=None, mdrunargs=None, **mpiargs):
"""Execute the mdrun command (possibly as a MPI command) and run the simulation.
:Keywords:
*pre*
a dictionary containing keyword arguments for the :meth:`prehook`
*post*
a dictionary containing... | [
"Execute",
"the",
"mdrun",
"command",
"(",
"possibly",
"as",
"a",
"MPI",
"command",
")",
"and",
"run",
"the",
"simulation",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L200-L243 | [
"def",
"run",
"(",
"self",
",",
"pre",
"=",
"None",
",",
"post",
"=",
"None",
",",
"mdrunargs",
"=",
"None",
",",
"*",
"*",
"mpiargs",
")",
":",
"if",
"pre",
"is",
"None",
":",
"pre",
"=",
"{",
"}",
"if",
"post",
"is",
"None",
":",
"post",
"=... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | MDrunner.run_check | Run :program:`mdrun` and check if run completed when it finishes.
This works by looking at the mdrun log file for 'Finished
mdrun on node'. It is useful to implement robust simulation
techniques.
:Arguments:
*kwargs* are keyword arguments that are passed on to
:me... | gromacs/run.py | def run_check(self, **kwargs):
"""Run :program:`mdrun` and check if run completed when it finishes.
This works by looking at the mdrun log file for 'Finished
mdrun on node'. It is useful to implement robust simulation
techniques.
:Arguments:
*kwargs* are keyword argu... | def run_check(self, **kwargs):
"""Run :program:`mdrun` and check if run completed when it finishes.
This works by looking at the mdrun log file for 'Finished
mdrun on node'. It is useful to implement robust simulation
techniques.
:Arguments:
*kwargs* are keyword argu... | [
"Run",
":",
"program",
":",
"mdrun",
"and",
"check",
"if",
"run",
"completed",
"when",
"it",
"finishes",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L245-L270 | [
"def",
"run_check",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"rc",
"=",
"None",
"# set to something in case we ever want to look at it later (and bomb in the try block)",
"try",
":",
"rc",
"=",
"self",
".",
"run",
"(",
"*",
"*",
"kwargs",
")",
"except",
"... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | MDrunnerMpich2Smpd.prehook | Launch local smpd. | gromacs/run.py | def prehook(self, **kwargs):
"""Launch local smpd."""
cmd = ['smpd', '-s']
logger.info("Starting smpd: "+" ".join(cmd))
rc = subprocess.call(cmd)
return rc | def prehook(self, **kwargs):
"""Launch local smpd."""
cmd = ['smpd', '-s']
logger.info("Starting smpd: "+" ".join(cmd))
rc = subprocess.call(cmd)
return rc | [
"Launch",
"local",
"smpd",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/run.py#L299-L304 | [
"def",
"prehook",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"cmd",
"=",
"[",
"'smpd'",
",",
"'-s'",
"]",
"logger",
".",
"info",
"(",
"\"Starting smpd: \"",
"+",
"\" \"",
".",
"join",
"(",
"cmd",
")",
")",
"rc",
"=",
"subprocess",
".",
"call",... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | _define_canned_commands | Define functions for the top level name space.
Definitions are collected here so that they can all be wrapped in
a try-except block that avoids code failing when the Gromacs tools
are not available --- in some cases they are not necessary to use
parts of GromacsWrapper.
.. Note:: Any function defi... | gromacs/cbook.py | def _define_canned_commands():
"""Define functions for the top level name space.
Definitions are collected here so that they can all be wrapped in
a try-except block that avoids code failing when the Gromacs tools
are not available --- in some cases they are not necessary to use
parts of GromacsWra... | def _define_canned_commands():
"""Define functions for the top level name space.
Definitions are collected here so that they can all be wrapped in
a try-except block that avoids code failing when the Gromacs tools
are not available --- in some cases they are not necessary to use
parts of GromacsWra... | [
"Define",
"functions",
"for",
"the",
"top",
"level",
"name",
"space",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L150-L197 | [
"def",
"_define_canned_commands",
"(",
")",
":",
"global",
"trj_compact",
",",
"rmsd_backbone",
",",
"trj_fitted",
",",
"trj_xyfitted",
"trj_compact",
"=",
"tools",
".",
"Trjconv",
"(",
"ur",
"=",
"'compact'",
",",
"center",
"=",
"True",
",",
"boxcenter",
"=",... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | trj_fitandcenter | Center everything and make a compact representation (pass 1) and fit the system to a reference (pass 2).
:Keywords:
*s*
input structure file (tpr file required to make molecule whole);
if a list or tuple is provided then s[0] is used for pass 1 (should be a tpr)
and s[1] is ... | gromacs/cbook.py | def trj_fitandcenter(xy=False, **kwargs):
"""Center everything and make a compact representation (pass 1) and fit the system to a reference (pass 2).
:Keywords:
*s*
input structure file (tpr file required to make molecule whole);
if a list or tuple is provided then s[0] is used for... | def trj_fitandcenter(xy=False, **kwargs):
"""Center everything and make a compact representation (pass 1) and fit the system to a reference (pass 2).
:Keywords:
*s*
input structure file (tpr file required to make molecule whole);
if a list or tuple is provided then s[0] is used for... | [
"Center",
"everything",
"and",
"make",
"a",
"compact",
"representation",
"(",
"pass",
"1",
")",
"and",
"fit",
"the",
"system",
"to",
"a",
"reference",
"(",
"pass",
"2",
")",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L212-L343 | [
"def",
"trj_fitandcenter",
"(",
"xy",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"xy",
":",
"fitmode",
"=",
"'rotxy+transxy'",
"kwargs",
".",
"pop",
"(",
"'fit'",
",",
"None",
")",
"else",
":",
"fitmode",
"=",
"kwargs",
".",
"pop",
"(",
... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | cat | Concatenate all parts of a simulation.
The xtc, trr, and edr files in *dirname* such as prefix.xtc,
prefix.part0002.xtc, prefix.part0003.xtc, ... are
1) moved to the *partsdir* (under *dirname*)
2) concatenated with the Gromacs tools to yield prefix.xtc, prefix.trr,
prefix.edr, prefix.... | gromacs/cbook.py | def cat(prefix="md", dirname=os.path.curdir, partsdir="parts", fulldir="full",
resolve_multi="pass"):
"""Concatenate all parts of a simulation.
The xtc, trr, and edr files in *dirname* such as prefix.xtc,
prefix.part0002.xtc, prefix.part0003.xtc, ... are
1) moved to the *partsdir* (under *d... | def cat(prefix="md", dirname=os.path.curdir, partsdir="parts", fulldir="full",
resolve_multi="pass"):
"""Concatenate all parts of a simulation.
The xtc, trr, and edr files in *dirname* such as prefix.xtc,
prefix.part0002.xtc, prefix.part0003.xtc, ... are
1) moved to the *partsdir* (under *d... | [
"Concatenate",
"all",
"parts",
"of",
"a",
"simulation",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L345-L464 | [
"def",
"cat",
"(",
"prefix",
"=",
"\"md\"",
",",
"dirname",
"=",
"os",
".",
"path",
".",
"curdir",
",",
"partsdir",
"=",
"\"parts\"",
",",
"fulldir",
"=",
"\"full\"",
",",
"resolve_multi",
"=",
"\"pass\"",
")",
":",
"gmxcat",
"=",
"{",
"'xtc'",
":",
... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | glob_parts | Find files from a continuation run | gromacs/cbook.py | def glob_parts(prefix, ext):
"""Find files from a continuation run"""
if ext.startswith('.'):
ext = ext[1:]
files = glob.glob(prefix+'.'+ext) + glob.glob(prefix+'.part[0-9][0-9][0-9][0-9].'+ext)
files.sort() # at least some rough sorting...
return files | def glob_parts(prefix, ext):
"""Find files from a continuation run"""
if ext.startswith('.'):
ext = ext[1:]
files = glob.glob(prefix+'.'+ext) + glob.glob(prefix+'.part[0-9][0-9][0-9][0-9].'+ext)
files.sort() # at least some rough sorting...
return files | [
"Find",
"files",
"from",
"a",
"continuation",
"run"
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L466-L472 | [
"def",
"glob_parts",
"(",
"prefix",
",",
"ext",
")",
":",
"if",
"ext",
".",
"startswith",
"(",
"'.'",
")",
":",
"ext",
"=",
"ext",
"[",
"1",
":",
"]",
"files",
"=",
"glob",
".",
"glob",
"(",
"prefix",
"+",
"'.'",
"+",
"ext",
")",
"+",
"glob",
... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | grompp_qtot | Run ``gromacs.grompp`` and return the total charge of the system.
:Arguments:
The arguments are the ones one would pass to :func:`gromacs.grompp`.
:Returns:
The total charge as reported
Some things to keep in mind:
* The stdout output of grompp is only shown when an error occurs. For
... | gromacs/cbook.py | def grompp_qtot(*args, **kwargs):
"""Run ``gromacs.grompp`` and return the total charge of the system.
:Arguments:
The arguments are the ones one would pass to :func:`gromacs.grompp`.
:Returns:
The total charge as reported
Some things to keep in mind:
* The stdout output of grompp ... | def grompp_qtot(*args, **kwargs):
"""Run ``gromacs.grompp`` and return the total charge of the system.
:Arguments:
The arguments are the ones one would pass to :func:`gromacs.grompp`.
:Returns:
The total charge as reported
Some things to keep in mind:
* The stdout output of grompp ... | [
"Run",
"gromacs",
".",
"grompp",
"and",
"return",
"the",
"total",
"charge",
"of",
"the",
"system",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L589-L637 | [
"def",
"grompp_qtot",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"qtot_pattern",
"=",
"re",
".",
"compile",
"(",
"'System has non-zero total charge: *(?P<qtot>[-+]?\\d*\\.\\d+([eE][-+]\\d+)?)'",
")",
"# make sure to capture ALL output",
"kwargs",
"[",
"'stdout'"... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | _mdp_include_string | Generate a string that can be added to a mdp 'include = ' line. | gromacs/cbook.py | def _mdp_include_string(dirs):
"""Generate a string that can be added to a mdp 'include = ' line."""
include_paths = [os.path.expanduser(p) for p in dirs]
return ' -I'.join([''] + include_paths) | def _mdp_include_string(dirs):
"""Generate a string that can be added to a mdp 'include = ' line."""
include_paths = [os.path.expanduser(p) for p in dirs]
return ' -I'.join([''] + include_paths) | [
"Generate",
"a",
"string",
"that",
"can",
"be",
"added",
"to",
"a",
"mdp",
"include",
"=",
"line",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L639-L642 | [
"def",
"_mdp_include_string",
"(",
"dirs",
")",
":",
"include_paths",
"=",
"[",
"os",
".",
"path",
".",
"expanduser",
"(",
"p",
")",
"for",
"p",
"in",
"dirs",
"]",
"return",
"' -I'",
".",
"join",
"(",
"[",
"''",
"]",
"+",
"include_paths",
")"
] | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | add_mdp_includes | Set the mdp *include* key in the *kwargs* dict.
1. Add the directory containing *topology*.
2. Add all directories appearing under the key *includes*
3. Generate a string of the form "-Idir1 -Idir2 ..." that
is stored under the key *include* (the corresponding
mdp parameter)
By default, ... | gromacs/cbook.py | def add_mdp_includes(topology=None, kwargs=None):
"""Set the mdp *include* key in the *kwargs* dict.
1. Add the directory containing *topology*.
2. Add all directories appearing under the key *includes*
3. Generate a string of the form "-Idir1 -Idir2 ..." that
is stored under the key *include* (... | def add_mdp_includes(topology=None, kwargs=None):
"""Set the mdp *include* key in the *kwargs* dict.
1. Add the directory containing *topology*.
2. Add all directories appearing under the key *includes*
3. Generate a string of the form "-Idir1 -Idir2 ..." that
is stored under the key *include* (... | [
"Set",
"the",
"mdp",
"*",
"include",
"*",
"key",
"in",
"the",
"*",
"kwargs",
"*",
"dict",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L644-L697 | [
"def",
"add_mdp_includes",
"(",
"topology",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"include_dirs",
"=",
"[",
"'.'",
",",
"'..'",
"]",
"# should . & .. always be added?",
"if",
"topolog... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | filter_grompp_options | Returns one dictionary only containing valid :program:`grompp` options and everything else.
Option list is hard coded and nased on :class:`~gromacs.tools.grompp` 4.5.3.
:Returns: ``(grompp_dict, other_dict)``
.. versionadded:: 0.2.4 | gromacs/cbook.py | def filter_grompp_options(**kwargs):
"""Returns one dictionary only containing valid :program:`grompp` options and everything else.
Option list is hard coded and nased on :class:`~gromacs.tools.grompp` 4.5.3.
:Returns: ``(grompp_dict, other_dict)``
.. versionadded:: 0.2.4
"""
grompp_options =... | def filter_grompp_options(**kwargs):
"""Returns one dictionary only containing valid :program:`grompp` options and everything else.
Option list is hard coded and nased on :class:`~gromacs.tools.grompp` 4.5.3.
:Returns: ``(grompp_dict, other_dict)``
.. versionadded:: 0.2.4
"""
grompp_options =... | [
"Returns",
"one",
"dictionary",
"only",
"containing",
"valid",
":",
"program",
":",
"grompp",
"options",
"and",
"everything",
"else",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L699-L714 | [
"def",
"filter_grompp_options",
"(",
"*",
"*",
"kwargs",
")",
":",
"grompp_options",
"=",
"(",
"'f'",
",",
"'po'",
",",
"'c'",
",",
"'r'",
",",
"'rb'",
",",
"'n'",
",",
"'p'",
",",
"'pp'",
",",
"'o'",
",",
"'t'",
",",
"'e'",
",",
"# files",
"'h'",
... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | create_portable_topology | Create a processed topology.
The processed (or portable) topology file does not contain any
``#include`` statements and hence can be easily copied around. It
also makes it possible to re-grompp without having any special itp
files available.
:Arguments:
*topol*
topology file
... | gromacs/cbook.py | def create_portable_topology(topol, struct, **kwargs):
"""Create a processed topology.
The processed (or portable) topology file does not contain any
``#include`` statements and hence can be easily copied around. It
also makes it possible to re-grompp without having any special itp
files available.... | def create_portable_topology(topol, struct, **kwargs):
"""Create a processed topology.
The processed (or portable) topology file does not contain any
``#include`` statements and hence can be easily copied around. It
also makes it possible to re-grompp without having any special itp
files available.... | [
"Create",
"a",
"processed",
"topology",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L716-L759 | [
"def",
"create_portable_topology",
"(",
"topol",
",",
"struct",
",",
"*",
"*",
"kwargs",
")",
":",
"_topoldir",
",",
"_topol",
"=",
"os",
".",
"path",
".",
"split",
"(",
"topol",
")",
"processed",
"=",
"kwargs",
".",
"pop",
"(",
"'processed'",
",",
"os... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | get_volume | Return the volume in nm^3 of structure file *f*.
(Uses :func:`gromacs.editconf`; error handling is not good) | gromacs/cbook.py | def get_volume(f):
"""Return the volume in nm^3 of structure file *f*.
(Uses :func:`gromacs.editconf`; error handling is not good)
"""
fd, temp = tempfile.mkstemp('.gro')
try:
rc,out,err = gromacs.editconf(f=f, o=temp, stdout=False)
finally:
os.unlink(temp)
return [float(x.s... | def get_volume(f):
"""Return the volume in nm^3 of structure file *f*.
(Uses :func:`gromacs.editconf`; error handling is not good)
"""
fd, temp = tempfile.mkstemp('.gro')
try:
rc,out,err = gromacs.editconf(f=f, o=temp, stdout=False)
finally:
os.unlink(temp)
return [float(x.s... | [
"Return",
"the",
"volume",
"in",
"nm^3",
"of",
"structure",
"file",
"*",
"f",
"*",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L761-L772 | [
"def",
"get_volume",
"(",
"f",
")",
":",
"fd",
",",
"temp",
"=",
"tempfile",
".",
"mkstemp",
"(",
"'.gro'",
")",
"try",
":",
"rc",
",",
"out",
",",
"err",
"=",
"gromacs",
".",
"editconf",
"(",
"f",
"=",
"f",
",",
"o",
"=",
"temp",
",",
"stdout"... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | edit_mdp | Change values in a Gromacs mdp file.
Parameters and values are supplied as substitutions, eg ``nsteps=1000``.
By default the template mdp file is **overwritten in place**.
If a parameter does not exist in the template then it cannot be substituted
and the parameter/value pair is returned. The user ha... | gromacs/cbook.py | def edit_mdp(mdp, new_mdp=None, extend_parameters=None, **substitutions):
"""Change values in a Gromacs mdp file.
Parameters and values are supplied as substitutions, eg ``nsteps=1000``.
By default the template mdp file is **overwritten in place**.
If a parameter does not exist in the template then i... | def edit_mdp(mdp, new_mdp=None, extend_parameters=None, **substitutions):
"""Change values in a Gromacs mdp file.
Parameters and values are supplied as substitutions, eg ``nsteps=1000``.
By default the template mdp file is **overwritten in place**.
If a parameter does not exist in the template then i... | [
"Change",
"values",
"in",
"a",
"Gromacs",
"mdp",
"file",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L778-L899 | [
"def",
"edit_mdp",
"(",
"mdp",
",",
"new_mdp",
"=",
"None",
",",
"extend_parameters",
"=",
"None",
",",
"*",
"*",
"substitutions",
")",
":",
"if",
"new_mdp",
"is",
"None",
":",
"new_mdp",
"=",
"mdp",
"if",
"extend_parameters",
"is",
"None",
":",
"extend_... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | edit_txt | Primitive text file stream editor.
This function can be used to edit free-form text files such as the
topology file. By default it does an **in-place edit** of
*filename*. If *newname* is supplied then the edited
file is written to *newname*.
:Arguments:
*filename*
input text fil... | gromacs/cbook.py | def edit_txt(filename, substitutions, newname=None):
"""Primitive text file stream editor.
This function can be used to edit free-form text files such as the
topology file. By default it does an **in-place edit** of
*filename*. If *newname* is supplied then the edited
file is written to *newname*.
... | def edit_txt(filename, substitutions, newname=None):
"""Primitive text file stream editor.
This function can be used to edit free-form text files such as the
topology file. By default it does an **in-place edit** of
*filename*. If *newname* is supplied then the edited
file is written to *newname*.
... | [
"Primitive",
"text",
"file",
"stream",
"editor",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L901-L983 | [
"def",
"edit_txt",
"(",
"filename",
",",
"substitutions",
",",
"newname",
"=",
"None",
")",
":",
"if",
"newname",
"is",
"None",
":",
"newname",
"=",
"filename",
"# No sanity checks (figure out later how to give decent diagnostics).",
"# Filter out any rules that have None i... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | remove_molecules_from_topology | Remove autogenerated [ molecules ] entries from *filename*.
Valid entries in ``[ molecules ]`` below the default *marker*
are removed. For example, a topology file such as ::
[ molecules ]
Protein 1
SOL 213
; The next line is the marker!
; Gromacs auto-generated entr... | gromacs/cbook.py | def remove_molecules_from_topology(filename, **kwargs):
"""Remove autogenerated [ molecules ] entries from *filename*.
Valid entries in ``[ molecules ]`` below the default *marker*
are removed. For example, a topology file such as ::
[ molecules ]
Protein 1
SOL 213
; Th... | def remove_molecules_from_topology(filename, **kwargs):
"""Remove autogenerated [ molecules ] entries from *filename*.
Valid entries in ``[ molecules ]`` below the default *marker*
are removed. For example, a topology file such as ::
[ molecules ]
Protein 1
SOL 213
; Th... | [
"Remove",
"autogenerated",
"[",
"molecules",
"]",
"entries",
"from",
"*",
"filename",
"*",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L985-L1051 | [
"def",
"remove_molecules_from_topology",
"(",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"marker",
"=",
"kwargs",
".",
"pop",
"(",
"'marker'",
",",
"None",
")",
"if",
"marker",
"is",
"None",
":",
"marker",
"=",
"\"; Gromacs auto-generated entries follow:\"",... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | make_ndx_captured | make_ndx that captures all output
Standard :func:`~gromacs.make_ndx` command with the input and
output pre-set in such a way that it can be conveniently used for
:func:`parse_ndxlist`.
Example::
ndx_groups = parse_ndxlist(make_ndx_captured(n=ndx)[0])
Note that the convenient :func:`get_ndx_... | gromacs/cbook.py | def make_ndx_captured(**kwargs):
"""make_ndx that captures all output
Standard :func:`~gromacs.make_ndx` command with the input and
output pre-set in such a way that it can be conveniently used for
:func:`parse_ndxlist`.
Example::
ndx_groups = parse_ndxlist(make_ndx_captured(n=ndx)[0])
... | def make_ndx_captured(**kwargs):
"""make_ndx that captures all output
Standard :func:`~gromacs.make_ndx` command with the input and
output pre-set in such a way that it can be conveniently used for
:func:`parse_ndxlist`.
Example::
ndx_groups = parse_ndxlist(make_ndx_captured(n=ndx)[0])
... | [
"make_ndx",
"that",
"captures",
"all",
"output"
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L1078-L1100 | [
"def",
"make_ndx_captured",
"(",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'stdout'",
"]",
"=",
"False",
"# required for proper output as described in doc",
"user_input",
"=",
"kwargs",
".",
"pop",
"(",
"'input'",
",",
"[",
"]",
")",
"user_input",
"=",
"["... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | get_ndx_groups | Return a list of index groups in the index file *ndx*.
:Arguments:
- *ndx* is a Gromacs index file.
- kwargs are passed to :func:`make_ndx_captured`.
:Returns:
list of groups as supplied by :func:`parse_ndxlist`
Alternatively, load the index file with
:class:`gromacs.formats.... | gromacs/cbook.py | def get_ndx_groups(ndx, **kwargs):
"""Return a list of index groups in the index file *ndx*.
:Arguments:
- *ndx* is a Gromacs index file.
- kwargs are passed to :func:`make_ndx_captured`.
:Returns:
list of groups as supplied by :func:`parse_ndxlist`
Alternatively, load the in... | def get_ndx_groups(ndx, **kwargs):
"""Return a list of index groups in the index file *ndx*.
:Arguments:
- *ndx* is a Gromacs index file.
- kwargs are passed to :func:`make_ndx_captured`.
:Returns:
list of groups as supplied by :func:`parse_ndxlist`
Alternatively, load the in... | [
"Return",
"a",
"list",
"of",
"index",
"groups",
"in",
"the",
"index",
"file",
"*",
"ndx",
"*",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L1102-L1121 | [
"def",
"get_ndx_groups",
"(",
"ndx",
",",
"*",
"*",
"kwargs",
")",
":",
"fd",
",",
"tmp_ndx",
"=",
"tempfile",
".",
"mkstemp",
"(",
"suffix",
"=",
"'.ndx'",
")",
"kwargs",
"[",
"'o'",
"]",
"=",
"tmp_ndx",
"try",
":",
"g",
"=",
"parse_ndxlist",
"(",
... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | parse_ndxlist | Parse output from make_ndx to build list of index groups::
groups = parse_ndxlist(output)
output should be the standard output from ``make_ndx``, e.g.::
rc,output,junk = gromacs.make_ndx(..., input=('', 'q'), stdout=False, stderr=True)
(or simply use
rc,output,junk = cbook.make_ndx_capt... | gromacs/cbook.py | def parse_ndxlist(output):
"""Parse output from make_ndx to build list of index groups::
groups = parse_ndxlist(output)
output should be the standard output from ``make_ndx``, e.g.::
rc,output,junk = gromacs.make_ndx(..., input=('', 'q'), stdout=False, stderr=True)
(or simply use
rc... | def parse_ndxlist(output):
"""Parse output from make_ndx to build list of index groups::
groups = parse_ndxlist(output)
output should be the standard output from ``make_ndx``, e.g.::
rc,output,junk = gromacs.make_ndx(..., input=('', 'q'), stdout=False, stderr=True)
(or simply use
rc... | [
"Parse",
"output",
"from",
"make_ndx",
"to",
"build",
"list",
"of",
"index",
"groups",
"::"
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L1123-L1152 | [
"def",
"parse_ndxlist",
"(",
"output",
")",
":",
"m",
"=",
"NDXLIST",
".",
"search",
"(",
"output",
")",
"# make sure we pick up a proper full list",
"grouplist",
"=",
"m",
".",
"group",
"(",
"'LIST'",
")",
"return",
"parse_groups",
"(",
"grouplist",
")"
] | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
valid | parse_groups | Parse ``make_ndx`` output and return groups as a list of dicts. | gromacs/cbook.py | def parse_groups(output):
"""Parse ``make_ndx`` output and return groups as a list of dicts."""
groups = []
for line in output.split('\n'):
m = NDXGROUP.match(line)
if m:
d = m.groupdict()
groups.append({'name': d['GROUPNAME'],
'nr': int(d['... | def parse_groups(output):
"""Parse ``make_ndx`` output and return groups as a list of dicts."""
groups = []
for line in output.split('\n'):
m = NDXGROUP.match(line)
if m:
d = m.groupdict()
groups.append({'name': d['GROUPNAME'],
'nr': int(d['... | [
"Parse",
"make_ndx",
"output",
"and",
"return",
"groups",
"as",
"a",
"list",
"of",
"dicts",
"."
] | Becksteinlab/GromacsWrapper | python | https://github.com/Becksteinlab/GromacsWrapper/blob/d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9/gromacs/cbook.py#L1154-L1164 | [
"def",
"parse_groups",
"(",
"output",
")",
":",
"groups",
"=",
"[",
"]",
"for",
"line",
"in",
"output",
".",
"split",
"(",
"'\\n'",
")",
":",
"m",
"=",
"NDXGROUP",
".",
"match",
"(",
"line",
")",
"if",
"m",
":",
"d",
"=",
"m",
".",
"groupdict",
... | d4f9a8cb6f48292732cf7c7e4ef4a6d2ccbc51b9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.