repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
logston/py3s3
py3s3/utils.py
validate_values
def validate_values(func, dic): """ Validate each value in ``dic`` by passing it through ``func``. Raise a ``ValueError`` if ``func`` does not return ``True``. """ for value_name, value in dic.items(): if not func(value): raise ValueError('{} can not be {}'.format(value_name, val...
python
def validate_values(func, dic): """ Validate each value in ``dic`` by passing it through ``func``. Raise a ``ValueError`` if ``func`` does not return ``True``. """ for value_name, value in dic.items(): if not func(value): raise ValueError('{} can not be {}'.format(value_name, val...
[ "def", "validate_values", "(", "func", ",", "dic", ")", ":", "for", "value_name", ",", "value", "in", "dic", ".", "items", "(", ")", ":", "if", "not", "func", "(", "value", ")", ":", "raise", "ValueError", "(", "'{} can not be {}'", ".", "format", "(",...
Validate each value in ``dic`` by passing it through ``func``. Raise a ``ValueError`` if ``func`` does not return ``True``.
[ "Validate", "each", "value", "in", "dic", "by", "passing", "it", "through", "func", ".", "Raise", "a", "ValueError", "if", "func", "does", "not", "return", "True", "." ]
train
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/utils.py#L46-L53
jonathansick/paperweight
paperweight/document.py
TexDocument.find_input_documents
def find_input_documents(self): """Find all tex documents input by this root document. Returns ------- paths : list List of filepaths for input documents. Paths are relative to the document (i.e., as written in the latex document). """ paths = [] ...
python
def find_input_documents(self): """Find all tex documents input by this root document. Returns ------- paths : list List of filepaths for input documents. Paths are relative to the document (i.e., as written in the latex document). """ paths = [] ...
[ "def", "find_input_documents", "(", "self", ")", ":", "paths", "=", "[", "]", "itr", "=", "chain", "(", "texutils", ".", "input_pattern", ".", "finditer", "(", "self", ".", "text", ")", ",", "texutils", ".", "input_ifexists_pattern", ".", "finditer", "(", ...
Find all tex documents input by this root document. Returns ------- paths : list List of filepaths for input documents. Paths are relative to the document (i.e., as written in the latex document).
[ "Find", "all", "tex", "documents", "input", "by", "this", "root", "document", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L54-L73
jonathansick/paperweight
paperweight/document.py
TexDocument.sections
def sections(self): """List with tuples of section names and positions. Positions of section names are measured by cumulative word count. """ sections = [] for match in texutils.section_pattern.finditer(self.text): textbefore = self.text[0:match.start()] ...
python
def sections(self): """List with tuples of section names and positions. Positions of section names are measured by cumulative word count. """ sections = [] for match in texutils.section_pattern.finditer(self.text): textbefore = self.text[0:match.start()] ...
[ "def", "sections", "(", "self", ")", ":", "sections", "=", "[", "]", "for", "match", "in", "texutils", ".", "section_pattern", ".", "finditer", "(", "self", ".", "text", ")", ":", "textbefore", "=", "self", ".", "text", "[", "0", ":", "match", ".", ...
List with tuples of section names and positions. Positions of section names are measured by cumulative word count.
[ "List", "with", "tuples", "of", "section", "names", "and", "positions", ".", "Positions", "of", "section", "names", "are", "measured", "by", "cumulative", "word", "count", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L76-L89
jonathansick/paperweight
paperweight/document.py
TexDocument.bib_name
def bib_name(self): """Name of the BibTeX bibliography file (e.g., ``'mybibliography.bib'``). """ bib_name = None for match in texutils.bib_pattern.finditer(self.text): bib_name = match.group(1) if not bib_name.endswith('.bib'): bib_name = ...
python
def bib_name(self): """Name of the BibTeX bibliography file (e.g., ``'mybibliography.bib'``). """ bib_name = None for match in texutils.bib_pattern.finditer(self.text): bib_name = match.group(1) if not bib_name.endswith('.bib'): bib_name = ...
[ "def", "bib_name", "(", "self", ")", ":", "bib_name", "=", "None", "for", "match", "in", "texutils", ".", "bib_pattern", ".", "finditer", "(", "self", ".", "text", ")", ":", "bib_name", "=", "match", ".", "group", "(", "1", ")", "if", "not", "bib_nam...
Name of the BibTeX bibliography file (e.g., ``'mybibliography.bib'``).
[ "Name", "of", "the", "BibTeX", "bibliography", "file", "(", "e", ".", "g", ".", "mybibliography", ".", "bib", ")", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L92-L101
jonathansick/paperweight
paperweight/document.py
TexDocument.bib_path
def bib_path(self): """Absolute file path to the .bib bibliography document.""" bib_name = self.bib_name # FIXME need to bake in search paths for tex documents in all platforms osx_path = os.path.expanduser( "~/Library/texmf/bibtex/bib/{0}".format(bib_name)) if self._...
python
def bib_path(self): """Absolute file path to the .bib bibliography document.""" bib_name = self.bib_name # FIXME need to bake in search paths for tex documents in all platforms osx_path = os.path.expanduser( "~/Library/texmf/bibtex/bib/{0}".format(bib_name)) if self._...
[ "def", "bib_path", "(", "self", ")", ":", "bib_name", "=", "self", ".", "bib_name", "# FIXME need to bake in search paths for tex documents in all platforms", "osx_path", "=", "os", ".", "path", ".", "expanduser", "(", "\"~/Library/texmf/bibtex/bib/{0}\"", ".", "format", ...
Absolute file path to the .bib bibliography document.
[ "Absolute", "file", "path", "to", "the", ".", "bib", "bibliography", "document", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L104-L115
jonathansick/paperweight
paperweight/document.py
TexDocument.remove_comments
def remove_comments(self, recursive=True): """Remove latex comments from document (modifies document in place). Parameters ---------- recursive : bool Remove comments from all input LaTeX documents (default ``True``). """ self.text = texutils.remove_comments(...
python
def remove_comments(self, recursive=True): """Remove latex comments from document (modifies document in place). Parameters ---------- recursive : bool Remove comments from all input LaTeX documents (default ``True``). """ self.text = texutils.remove_comments(...
[ "def", "remove_comments", "(", "self", ",", "recursive", "=", "True", ")", ":", "self", ".", "text", "=", "texutils", ".", "remove_comments", "(", "self", ".", "text", ")", "if", "recursive", ":", "for", "path", ",", "document", "in", "self", ".", "_ch...
Remove latex comments from document (modifies document in place). Parameters ---------- recursive : bool Remove comments from all input LaTeX documents (default ``True``).
[ "Remove", "latex", "comments", "from", "document", "(", "modifies", "document", "in", "place", ")", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L117-L128
jonathansick/paperweight
paperweight/document.py
TexDocument.bib_keys
def bib_keys(self): """List of all bib keys in the document (and input documents).""" bib_keys = [] # Get bib keys in this document for match in texutils.cite_pattern.finditer(self.text): keys = match.group(5).split(',') bib_keys += keys # Recursion ...
python
def bib_keys(self): """List of all bib keys in the document (and input documents).""" bib_keys = [] # Get bib keys in this document for match in texutils.cite_pattern.finditer(self.text): keys = match.group(5).split(',') bib_keys += keys # Recursion ...
[ "def", "bib_keys", "(", "self", ")", ":", "bib_keys", "=", "[", "]", "# Get bib keys in this document", "for", "match", "in", "texutils", ".", "cite_pattern", ".", "finditer", "(", "self", ".", "text", ")", ":", "keys", "=", "match", ".", "group", "(", "...
List of all bib keys in the document (and input documents).
[ "List", "of", "all", "bib", "keys", "in", "the", "document", "(", "and", "input", "documents", ")", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L131-L144
jonathansick/paperweight
paperweight/document.py
TexDocument.extract_citation_context
def extract_citation_context(self, n_words=20): """Generate a dictionary of all bib keys in the document (and input documents), with rich of metadata about the context of each citation in the document. For example, suppose ``'Sick:2014'`` is cited twice within a document. Then t...
python
def extract_citation_context(self, n_words=20): """Generate a dictionary of all bib keys in the document (and input documents), with rich of metadata about the context of each citation in the document. For example, suppose ``'Sick:2014'`` is cited twice within a document. Then t...
[ "def", "extract_citation_context", "(", "self", ",", "n_words", "=", "20", ")", ":", "bib_keys", "=", "defaultdict", "(", "list", ")", "# Get bib keys in this document", "for", "match", "in", "texutils", ".", "cite_pattern", ".", "finditer", "(", "self", ".", ...
Generate a dictionary of all bib keys in the document (and input documents), with rich of metadata about the context of each citation in the document. For example, suppose ``'Sick:2014'`` is cited twice within a document. Then the dictionary returned by this method will have a length-2 ...
[ "Generate", "a", "dictionary", "of", "all", "bib", "keys", "in", "the", "document", "(", "and", "input", "documents", ")", "with", "rich", "of", "metadata", "about", "the", "context", "of", "each", "citation", "in", "the", "document", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L146-L210
jonathansick/paperweight
paperweight/document.py
TexDocument.write
def write(self, path): """Write the document's text to a ``path`` on the filesystem.""" with codecs.open(path, 'w', encoding='utf-8') as f: f.write(self.text)
python
def write(self, path): """Write the document's text to a ``path`` on the filesystem.""" with codecs.open(path, 'w', encoding='utf-8') as f: f.write(self.text)
[ "def", "write", "(", "self", ",", "path", ")", ":", "with", "codecs", ".", "open", "(", "path", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "text", ")" ]
Write the document's text to a ``path`` on the filesystem.
[ "Write", "the", "document", "s", "text", "to", "a", "path", "on", "the", "filesystem", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L212-L215
jonathansick/paperweight
paperweight/document.py
TexDocument.bibitems
def bibitems(self): """List of bibitem strings appearing in the document.""" bibitems = [] lines = self.text.split('\n') for i, line in enumerate(lines): if line.lstrip().startswith(u'\\bibitem'): # accept this line # check if next line is also...
python
def bibitems(self): """List of bibitem strings appearing in the document.""" bibitems = [] lines = self.text.split('\n') for i, line in enumerate(lines): if line.lstrip().startswith(u'\\bibitem'): # accept this line # check if next line is also...
[ "def", "bibitems", "(", "self", ")", ":", "bibitems", "=", "[", "]", "lines", "=", "self", ".", "text", ".", "split", "(", "'\\n'", ")", "for", "i", ",", "line", "in", "enumerate", "(", "lines", ")", ":", "if", "line", ".", "lstrip", "(", ")", ...
List of bibitem strings appearing in the document.
[ "List", "of", "bibitem", "strings", "appearing", "in", "the", "document", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L218-L244
jonathansick/paperweight
paperweight/document.py
FilesystemTexDocument.inline_bbl
def inline_bbl(self): """Inline a compiled bibliography (.bbl) in place of a bibliography environment. The document is modified in place. """ bbl_path = os.path.splitext(self._filepath)[0] + ".bbl" try: with codecs.open(bbl_path, 'r', encoding='utf-8') as f: ...
python
def inline_bbl(self): """Inline a compiled bibliography (.bbl) in place of a bibliography environment. The document is modified in place. """ bbl_path = os.path.splitext(self._filepath)[0] + ".bbl" try: with codecs.open(bbl_path, 'r', encoding='utf-8') as f: ...
[ "def", "inline_bbl", "(", "self", ")", ":", "bbl_path", "=", "os", ".", "path", ".", "splitext", "(", "self", ".", "_filepath", ")", "[", "0", "]", "+", "\".bbl\"", "try", ":", "with", "codecs", ".", "open", "(", "bbl_path", ",", "'r'", ",", "encod...
Inline a compiled bibliography (.bbl) in place of a bibliography environment. The document is modified in place.
[ "Inline", "a", "compiled", "bibliography", "(", ".", "bbl", ")", "in", "place", "of", "a", "bibliography", "environment", ".", "The", "document", "is", "modified", "in", "place", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L274-L284
jonathansick/paperweight
paperweight/document.py
FilesystemTexDocument.inline_inputs
def inline_inputs(self): """Inline all input latex files references by this document. The inlining is accomplished recursively. The document is modified in place. """ self.text = texutils.inline(self.text, os.path.dirname(self._filepath)) ...
python
def inline_inputs(self): """Inline all input latex files references by this document. The inlining is accomplished recursively. The document is modified in place. """ self.text = texutils.inline(self.text, os.path.dirname(self._filepath)) ...
[ "def", "inline_inputs", "(", "self", ")", ":", "self", ".", "text", "=", "texutils", ".", "inline", "(", "self", ".", "text", ",", "os", ".", "path", ".", "dirname", "(", "self", ".", "_filepath", ")", ")", "# Remove children", "self", ".", "_children"...
Inline all input latex files references by this document. The inlining is accomplished recursively. The document is modified in place.
[ "Inline", "all", "input", "latex", "files", "references", "by", "this", "document", ".", "The", "inlining", "is", "accomplished", "recursively", ".", "The", "document", "is", "modified", "in", "place", "." ]
train
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/document.py#L286-L294
shreyaspotnis/rampage
rampage/widgets/RampEditor.py
clearLayout
def clearLayout(layout): """Removes all widgets in the layout. Useful when opening a new file, want to clear everything.""" while layout.count(): child = layout.takeAt(0) child.widget().deleteLater()
python
def clearLayout(layout): """Removes all widgets in the layout. Useful when opening a new file, want to clear everything.""" while layout.count(): child = layout.takeAt(0) child.widget().deleteLater()
[ "def", "clearLayout", "(", "layout", ")", ":", "while", "layout", ".", "count", "(", ")", ":", "child", "=", "layout", ".", "takeAt", "(", "0", ")", "child", ".", "widget", "(", ")", ".", "deleteLater", "(", ")" ]
Removes all widgets in the layout. Useful when opening a new file, want to clear everything.
[ "Removes", "all", "widgets", "in", "the", "layout", ".", "Useful", "when", "opening", "a", "new", "file", "want", "to", "clear", "everything", "." ]
train
https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/widgets/RampEditor.py#L12-L17
DallasMorningNews/django-datafreezer
datafreezer/views.py
map_hubs_to_verticals
def map_hubs_to_verticals(): """Return all verticals (sections) mapped to hubs (subsections). """ vertical_hub_map = {} for hub in HUBS_LIST: vertical_slug = hub['vertical']['slug'] if vertical_slug not in vertical_hub_map: vertical_hub_map[vertical_slug] = { ...
python
def map_hubs_to_verticals(): """Return all verticals (sections) mapped to hubs (subsections). """ vertical_hub_map = {} for hub in HUBS_LIST: vertical_slug = hub['vertical']['slug'] if vertical_slug not in vertical_hub_map: vertical_hub_map[vertical_slug] = { ...
[ "def", "map_hubs_to_verticals", "(", ")", ":", "vertical_hub_map", "=", "{", "}", "for", "hub", "in", "HUBS_LIST", ":", "vertical_slug", "=", "hub", "[", "'vertical'", "]", "[", "'slug'", "]", "if", "vertical_slug", "not", "in", "vertical_hub_map", ":", "ver...
Return all verticals (sections) mapped to hubs (subsections).
[ "Return", "all", "verticals", "(", "sections", ")", "mapped", "to", "hubs", "(", "subsections", ")", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L94-L109
DallasMorningNews/django-datafreezer
datafreezer/views.py
add_dataset
def add_dataset(request, dataset_id=None): """Handles creation of Dataset models from form POST information. Called by edit_dataset_metadata(...) view between Dataset entry and Data Dictionary entry. If dataset_id is passed as an argument, this function edits a given dataset rather than adding a datase...
python
def add_dataset(request, dataset_id=None): """Handles creation of Dataset models from form POST information. Called by edit_dataset_metadata(...) view between Dataset entry and Data Dictionary entry. If dataset_id is passed as an argument, this function edits a given dataset rather than adding a datase...
[ "def", "add_dataset", "(", "request", ",", "dataset_id", "=", "None", ")", ":", "# Save form to create dataset model", "# Populate non-form fields", "if", "dataset_id", ":", "dataset_instance", "=", "Dataset", ".", "objects", ".", "get", "(", "pk", "=", "dataset_id"...
Handles creation of Dataset models from form POST information. Called by edit_dataset_metadata(...) view between Dataset entry and Data Dictionary entry. If dataset_id is passed as an argument, this function edits a given dataset rather than adding a dataset. Otherwise, a new model is saved to the data...
[ "Handles", "creation", "of", "Dataset", "models", "from", "form", "POST", "information", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L115-L250
DallasMorningNews/django-datafreezer
datafreezer/views.py
parse_csv_headers
def parse_csv_headers(dataset_id): """Return the first row of a CSV as a list of headers.""" data = Dataset.objects.get(pk=dataset_id) with open(data.dataset_file.path, 'r') as datasetFile: csvReader = reader(datasetFile, delimiter=',', quotechar='"') headers = next(csvReader) # prin...
python
def parse_csv_headers(dataset_id): """Return the first row of a CSV as a list of headers.""" data = Dataset.objects.get(pk=dataset_id) with open(data.dataset_file.path, 'r') as datasetFile: csvReader = reader(datasetFile, delimiter=',', quotechar='"') headers = next(csvReader) # prin...
[ "def", "parse_csv_headers", "(", "dataset_id", ")", ":", "data", "=", "Dataset", ".", "objects", ".", "get", "(", "pk", "=", "dataset_id", ")", "with", "open", "(", "data", ".", "dataset_file", ".", "path", ",", "'r'", ")", "as", "datasetFile", ":", "c...
Return the first row of a CSV as a list of headers.
[ "Return", "the", "first", "row", "of", "a", "CSV", "as", "a", "list", "of", "headers", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L253-L260
DallasMorningNews/django-datafreezer
datafreezer/views.py
grab_names_from_emails
def grab_names_from_emails(email_list): """Return a dictionary mapping names to email addresses. Only gives a response if the email is found in the staff API/JSON. Expects an API of the format = [ { 'email': 'foo@bar.net', ... 'fullName': 'Frank Oo' ...
python
def grab_names_from_emails(email_list): """Return a dictionary mapping names to email addresses. Only gives a response if the email is found in the staff API/JSON. Expects an API of the format = [ { 'email': 'foo@bar.net', ... 'fullName': 'Frank Oo' ...
[ "def", "grab_names_from_emails", "(", "email_list", ")", ":", "all_staff", "=", "STAFF_LIST", "emails_names", "=", "{", "}", "for", "email", "in", "email_list", ":", "for", "person", "in", "all_staff", ":", "if", "email", "==", "person", "[", "'email'", "]",...
Return a dictionary mapping names to email addresses. Only gives a response if the email is found in the staff API/JSON. Expects an API of the format = [ { 'email': 'foo@bar.net', ... 'fullName': 'Frank Oo' }, ... ]
[ "Return", "a", "dictionary", "mapping", "names", "to", "email", "addresses", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L264-L299
DallasMorningNews/django-datafreezer
datafreezer/views.py
tag_lookup
def tag_lookup(request): """JSON endpoint that returns a list of potential tags. Used for upload template autocomplete. """ tag = request.GET['tag'] tagSlug = slugify(tag.strip()) tagCandidates = Tag.objects.values('word').filter(slug__startswith=tagSlug) tags = json.dumps([candidate['word...
python
def tag_lookup(request): """JSON endpoint that returns a list of potential tags. Used for upload template autocomplete. """ tag = request.GET['tag'] tagSlug = slugify(tag.strip()) tagCandidates = Tag.objects.values('word').filter(slug__startswith=tagSlug) tags = json.dumps([candidate['word...
[ "def", "tag_lookup", "(", "request", ")", ":", "tag", "=", "request", ".", "GET", "[", "'tag'", "]", "tagSlug", "=", "slugify", "(", "tag", ".", "strip", "(", ")", ")", "tagCandidates", "=", "Tag", ".", "objects", ".", "values", "(", "'word'", ")", ...
JSON endpoint that returns a list of potential tags. Used for upload template autocomplete.
[ "JSON", "endpoint", "that", "returns", "a", "list", "of", "potential", "tags", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L321-L331
DallasMorningNews/django-datafreezer
datafreezer/views.py
source_lookup
def source_lookup(request): """JSON endpoint that returns a list of potential sources. Used for upload template autocomplete. """ source = request.GET['source'] source_slug = slugify(source.strip()) source_candidates = Dataset.objects.values('source').filter( source_slug__startswith=sou...
python
def source_lookup(request): """JSON endpoint that returns a list of potential sources. Used for upload template autocomplete. """ source = request.GET['source'] source_slug = slugify(source.strip()) source_candidates = Dataset.objects.values('source').filter( source_slug__startswith=sou...
[ "def", "source_lookup", "(", "request", ")", ":", "source", "=", "request", ".", "GET", "[", "'source'", "]", "source_slug", "=", "slugify", "(", "source", ".", "strip", "(", ")", ")", "source_candidates", "=", "Dataset", ".", "objects", ".", "values", "...
JSON endpoint that returns a list of potential sources. Used for upload template autocomplete.
[ "JSON", "endpoint", "that", "returns", "a", "list", "of", "potential", "sources", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L335-L347
DallasMorningNews/django-datafreezer
datafreezer/views.py
download_data_dictionary
def download_data_dictionary(request, dataset_id): """Generates and returns compiled data dictionary from database. Returned as a CSV response. """ dataset = Dataset.objects.get(pk=dataset_id) dataDict = dataset.data_dictionary fields = DataDictionaryField.objects.filter( parent_dict=da...
python
def download_data_dictionary(request, dataset_id): """Generates and returns compiled data dictionary from database. Returned as a CSV response. """ dataset = Dataset.objects.get(pk=dataset_id) dataDict = dataset.data_dictionary fields = DataDictionaryField.objects.filter( parent_dict=da...
[ "def", "download_data_dictionary", "(", "request", ",", "dataset_id", ")", ":", "dataset", "=", "Dataset", ".", "objects", ".", "get", "(", "pk", "=", "dataset_id", ")", "dataDict", "=", "dataset", ".", "data_dictionary", "fields", "=", "DataDictionaryField", ...
Generates and returns compiled data dictionary from database. Returned as a CSV response.
[ "Generates", "and", "returns", "compiled", "data", "dictionary", "from", "database", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L351-L383
DallasMorningNews/django-datafreezer
datafreezer/views.py
home
def home(request): """Renders Datafreezer homepage. Includes recent uploads.""" recent_uploads = Dataset.objects.order_by('-date_uploaded')[:11] email_list = [upload.uploaded_by.strip() for upload in recent_uploads] # print all_staff emails_names = grab_names_from_emails(email_list) # print em...
python
def home(request): """Renders Datafreezer homepage. Includes recent uploads.""" recent_uploads = Dataset.objects.order_by('-date_uploaded')[:11] email_list = [upload.uploaded_by.strip() for upload in recent_uploads] # print all_staff emails_names = grab_names_from_emails(email_list) # print em...
[ "def", "home", "(", "request", ")", ":", "recent_uploads", "=", "Dataset", ".", "objects", ".", "order_by", "(", "'-date_uploaded'", ")", "[", ":", "11", "]", "email_list", "=", "[", "upload", ".", "uploaded_by", ".", "strip", "(", ")", "for", "upload", ...
Renders Datafreezer homepage. Includes recent uploads.
[ "Renders", "Datafreezer", "homepage", ".", "Includes", "recent", "uploads", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L388-L414
DallasMorningNews/django-datafreezer
datafreezer/views.py
edit_dataset_metadata
def edit_dataset_metadata(request, dataset_id=None): """Renders a template to upload or edit a Dataset. Most of the heavy lifting is done by add_dataset(...). """ if request.method == 'POST': return add_dataset(request, dataset_id) elif request.method == 'GET': # create a blank fo...
python
def edit_dataset_metadata(request, dataset_id=None): """Renders a template to upload or edit a Dataset. Most of the heavy lifting is done by add_dataset(...). """ if request.method == 'POST': return add_dataset(request, dataset_id) elif request.method == 'GET': # create a blank fo...
[ "def", "edit_dataset_metadata", "(", "request", ",", "dataset_id", "=", "None", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "return", "add_dataset", "(", "request", ",", "dataset_id", ")", "elif", "request", ".", "method", "==", "'GET'", ...
Renders a template to upload or edit a Dataset. Most of the heavy lifting is done by add_dataset(...).
[ "Renders", "a", "template", "to", "upload", "or", "edit", "a", "Dataset", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L419-L445
DallasMorningNews/django-datafreezer
datafreezer/views.py
dataset_detail
def dataset_detail(request, dataset_id): """Renders individual dataset detail page.""" active_dataset = get_object_or_404(Dataset, pk=dataset_id) datadict_id = active_dataset.data_dictionary_id datadict = DataDictionaryField.objects.filter( parent_dict=datadict_id ).order_by('columnIndex') ...
python
def dataset_detail(request, dataset_id): """Renders individual dataset detail page.""" active_dataset = get_object_or_404(Dataset, pk=dataset_id) datadict_id = active_dataset.data_dictionary_id datadict = DataDictionaryField.objects.filter( parent_dict=datadict_id ).order_by('columnIndex') ...
[ "def", "dataset_detail", "(", "request", ",", "dataset_id", ")", ":", "active_dataset", "=", "get_object_or_404", "(", "Dataset", ",", "pk", "=", "dataset_id", ")", "datadict_id", "=", "active_dataset", ".", "data_dictionary_id", "datadict", "=", "DataDictionaryFiel...
Renders individual dataset detail page.
[ "Renders", "individual", "dataset", "detail", "page", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L535-L566
DallasMorningNews/django-datafreezer
datafreezer/views.py
PaginatedBrowseAll.get
def get(self, request): """Handle HTTP GET request. Returns template and context from generate_page_title and generate_sections to populate template. """ sections_list = self.generate_sections() p = Paginator(sections_list, 25) page = request.GET.get('page') ...
python
def get(self, request): """Handle HTTP GET request. Returns template and context from generate_page_title and generate_sections to populate template. """ sections_list = self.generate_sections() p = Paginator(sections_list, 25) page = request.GET.get('page') ...
[ "def", "get", "(", "self", ",", "request", ")", ":", "sections_list", "=", "self", ".", "generate_sections", "(", ")", "p", "=", "Paginator", "(", "sections_list", ",", "25", ")", "page", "=", "request", ".", "GET", ".", "get", "(", "'page'", ")", "t...
Handle HTTP GET request. Returns template and context from generate_page_title and generate_sections to populate template.
[ "Handle", "HTTP", "GET", "request", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L628-L659
DallasMorningNews/django-datafreezer
datafreezer/views.py
BrowseBase.get
def get(self, request): """View for HTTP GET method. Returns template and context from generate_page_title and generate_sections to populate template. """ sections = self.generate_sections() if self.paginated: p = Paginator(sections, 25) page = ...
python
def get(self, request): """View for HTTP GET method. Returns template and context from generate_page_title and generate_sections to populate template. """ sections = self.generate_sections() if self.paginated: p = Paginator(sections, 25) page = ...
[ "def", "get", "(", "self", ",", "request", ")", ":", "sections", "=", "self", ".", "generate_sections", "(", ")", "if", "self", ".", "paginated", ":", "p", "=", "Paginator", "(", "sections", ",", "25", ")", "page", "=", "request", ".", "GET", ".", ...
View for HTTP GET method. Returns template and context from generate_page_title and generate_sections to populate template.
[ "View", "for", "HTTP", "GET", "method", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L690-L735
DallasMorningNews/django-datafreezer
datafreezer/views.py
BrowseHubs.generate_sections
def generate_sections(self): """Return all hubs, slugs, and upload counts.""" datasets = Dataset.objects.values( 'hub_slug' ).annotate( upload_count=Count( 'hub_slug' ) ).order_by('-upload_count') return [ { ...
python
def generate_sections(self): """Return all hubs, slugs, and upload counts.""" datasets = Dataset.objects.values( 'hub_slug' ).annotate( upload_count=Count( 'hub_slug' ) ).order_by('-upload_count') return [ { ...
[ "def", "generate_sections", "(", "self", ")", ":", "datasets", "=", "Dataset", ".", "objects", ".", "values", "(", "'hub_slug'", ")", ".", "annotate", "(", "upload_count", "=", "Count", "(", "'hub_slug'", ")", ")", ".", "order_by", "(", "'-upload_count'", ...
Return all hubs, slugs, and upload counts.
[ "Return", "all", "hubs", "slugs", "and", "upload", "counts", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L777-L794
DallasMorningNews/django-datafreezer
datafreezer/views.py
BrowseAuthors.generate_sections
def generate_sections(self): """Return all authors to which datasets have been attributed.""" authors = Dataset.objects.values( 'uploaded_by' ).annotate( upload_count=Count( 'uploaded_by' ) ).order_by('-upload_count') email_nam...
python
def generate_sections(self): """Return all authors to which datasets have been attributed.""" authors = Dataset.objects.values( 'uploaded_by' ).annotate( upload_count=Count( 'uploaded_by' ) ).order_by('-upload_count') email_nam...
[ "def", "generate_sections", "(", "self", ")", ":", "authors", "=", "Dataset", ".", "objects", ".", "values", "(", "'uploaded_by'", ")", ".", "annotate", "(", "upload_count", "=", "Count", "(", "'uploaded_by'", ")", ")", ".", "order_by", "(", "'-upload_count'...
Return all authors to which datasets have been attributed.
[ "Return", "all", "authors", "to", "which", "datasets", "have", "been", "attributed", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L813-L840
DallasMorningNews/django-datafreezer
datafreezer/views.py
BrowseSources.generate_sections
def generate_sections(self): """Return dictionary of source section slugs, name, and counts.""" sources = Dataset.objects.values( 'source', 'source_slug' ).annotate(source_count=Count('source_slug')) return sorted([ { 'slug': source['source_slug']...
python
def generate_sections(self): """Return dictionary of source section slugs, name, and counts.""" sources = Dataset.objects.values( 'source', 'source_slug' ).annotate(source_count=Count('source_slug')) return sorted([ { 'slug': source['source_slug']...
[ "def", "generate_sections", "(", "self", ")", ":", "sources", "=", "Dataset", ".", "objects", ".", "values", "(", "'source'", ",", "'source_slug'", ")", ".", "annotate", "(", "source_count", "=", "Count", "(", "'source_slug'", ")", ")", "return", "sorted", ...
Return dictionary of source section slugs, name, and counts.
[ "Return", "dictionary", "of", "source", "section", "slugs", "name", "and", "counts", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L920-L933
DallasMorningNews/django-datafreezer
datafreezer/views.py
DetailBase.get
def get(self, request, slug): """Basic functionality for GET request to view. """ matching_datasets = self.generate_matching_datasets(slug) if matching_datasets is None: raise Http404("Datasets meeting these criteria do not exist.") base_context = { 'da...
python
def get(self, request, slug): """Basic functionality for GET request to view. """ matching_datasets = self.generate_matching_datasets(slug) if matching_datasets is None: raise Http404("Datasets meeting these criteria do not exist.") base_context = { 'da...
[ "def", "get", "(", "self", ",", "request", ",", "slug", ")", ":", "matching_datasets", "=", "self", ".", "generate_matching_datasets", "(", "slug", ")", "if", "matching_datasets", "is", "None", ":", "raise", "Http404", "(", "\"Datasets meeting these criteria do no...
Basic functionality for GET request to view.
[ "Basic", "functionality", "for", "GET", "request", "to", "view", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L962-L988
DallasMorningNews/django-datafreezer
datafreezer/views.py
AuthorDetail.generate_additional_context
def generate_additional_context(self, matching_datasets): """Return additional information about matching datasets. Includes upload counts, related hubs, related tags. """ dataset_ids = [upload.id for upload in matching_datasets] tags = Tag.objects.filter( dataset__i...
python
def generate_additional_context(self, matching_datasets): """Return additional information about matching datasets. Includes upload counts, related hubs, related tags. """ dataset_ids = [upload.id for upload in matching_datasets] tags = Tag.objects.filter( dataset__i...
[ "def", "generate_additional_context", "(", "self", ",", "matching_datasets", ")", ":", "dataset_ids", "=", "[", "upload", ".", "id", "for", "upload", "in", "matching_datasets", "]", "tags", "=", "Tag", ".", "objects", ".", "filter", "(", "dataset__in", "=", ...
Return additional information about matching datasets. Includes upload counts, related hubs, related tags.
[ "Return", "additional", "information", "about", "matching", "datasets", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1012-L1039
DallasMorningNews/django-datafreezer
datafreezer/views.py
TagDetail.generate_page_title
def generate_page_title(self, data_slug): """Generates remainder of page title specific to data_slug (tag).""" tag = Tag.objects.filter(slug=data_slug) return tag[0].word
python
def generate_page_title(self, data_slug): """Generates remainder of page title specific to data_slug (tag).""" tag = Tag.objects.filter(slug=data_slug) return tag[0].word
[ "def", "generate_page_title", "(", "self", ",", "data_slug", ")", ":", "tag", "=", "Tag", ".", "objects", ".", "filter", "(", "slug", "=", "data_slug", ")", "return", "tag", "[", "0", "]", ".", "word" ]
Generates remainder of page title specific to data_slug (tag).
[ "Generates", "remainder", "of", "page", "title", "specific", "to", "data_slug", "(", "tag", ")", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1049-L1052
DallasMorningNews/django-datafreezer
datafreezer/views.py
TagDetail.generate_matching_datasets
def generate_matching_datasets(self, data_slug): """Return datasets that match data_slug (tag).""" tag = Tag.objects.filter(slug=data_slug) try: return tag[0].dataset_set.all().order_by('-uploaded_by') except IndexError: return None
python
def generate_matching_datasets(self, data_slug): """Return datasets that match data_slug (tag).""" tag = Tag.objects.filter(slug=data_slug) try: return tag[0].dataset_set.all().order_by('-uploaded_by') except IndexError: return None
[ "def", "generate_matching_datasets", "(", "self", ",", "data_slug", ")", ":", "tag", "=", "Tag", ".", "objects", ".", "filter", "(", "slug", "=", "data_slug", ")", "try", ":", "return", "tag", "[", "0", "]", ".", "dataset_set", ".", "all", "(", ")", ...
Return datasets that match data_slug (tag).
[ "Return", "datasets", "that", "match", "data_slug", "(", "tag", ")", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1054-L1060
DallasMorningNews/django-datafreezer
datafreezer/views.py
TagDetail.generate_additional_context
def generate_additional_context(self, matching_datasets): """Return context about matching datasets.""" related_tags = Tag.objects.filter( dataset__in=matching_datasets ).distinct().annotate( Count('word') ).order_by('-word__count')[:5] return { ...
python
def generate_additional_context(self, matching_datasets): """Return context about matching datasets.""" related_tags = Tag.objects.filter( dataset__in=matching_datasets ).distinct().annotate( Count('word') ).order_by('-word__count')[:5] return { ...
[ "def", "generate_additional_context", "(", "self", ",", "matching_datasets", ")", ":", "related_tags", "=", "Tag", ".", "objects", ".", "filter", "(", "dataset__in", "=", "matching_datasets", ")", ".", "distinct", "(", ")", ".", "annotate", "(", "Count", "(", ...
Return context about matching datasets.
[ "Return", "context", "about", "matching", "datasets", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1062-L1072
DallasMorningNews/django-datafreezer
datafreezer/views.py
HubDetail.generate_matching_datasets
def generate_matching_datasets(self, data_slug): """Return datasets that match data_slug (hub_slug).""" matching_datasets = Dataset.objects.filter( hub_slug=data_slug ).order_by('-date_uploaded') if len(matching_datasets) > 0: return matching_datasets els...
python
def generate_matching_datasets(self, data_slug): """Return datasets that match data_slug (hub_slug).""" matching_datasets = Dataset.objects.filter( hub_slug=data_slug ).order_by('-date_uploaded') if len(matching_datasets) > 0: return matching_datasets els...
[ "def", "generate_matching_datasets", "(", "self", ",", "data_slug", ")", ":", "matching_datasets", "=", "Dataset", ".", "objects", ".", "filter", "(", "hub_slug", "=", "data_slug", ")", ".", "order_by", "(", "'-date_uploaded'", ")", "if", "len", "(", "matching...
Return datasets that match data_slug (hub_slug).
[ "Return", "datasets", "that", "match", "data_slug", "(", "hub_slug", ")", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1086-L1095
DallasMorningNews/django-datafreezer
datafreezer/views.py
VerticalDetail.generate_matching_datasets
def generate_matching_datasets(self, data_slug): """Return datasets that belong to a vertical by querying hubs. """ matching_hubs = VERTICAL_HUB_MAP[data_slug]['hubs'] return Dataset.objects.filter(hub_slug__in=matching_hubs)
python
def generate_matching_datasets(self, data_slug): """Return datasets that belong to a vertical by querying hubs. """ matching_hubs = VERTICAL_HUB_MAP[data_slug]['hubs'] return Dataset.objects.filter(hub_slug__in=matching_hubs)
[ "def", "generate_matching_datasets", "(", "self", ",", "data_slug", ")", ":", "matching_hubs", "=", "VERTICAL_HUB_MAP", "[", "data_slug", "]", "[", "'hubs'", "]", "return", "Dataset", ".", "objects", ".", "filter", "(", "hub_slug__in", "=", "matching_hubs", ")" ...
Return datasets that belong to a vertical by querying hubs.
[ "Return", "datasets", "that", "belong", "to", "a", "vertical", "by", "querying", "hubs", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1138-L1143
DallasMorningNews/django-datafreezer
datafreezer/views.py
VerticalDetail.generate_additional_context
def generate_additional_context(self, matching_datasets): """Generate top tags and authors for a given Vertical.""" top_tags = Tag.objects.filter( dataset__in=matching_datasets ).annotate( tag_count=Count('word') ).order_by('-tag_count')[:3] top_authors =...
python
def generate_additional_context(self, matching_datasets): """Generate top tags and authors for a given Vertical.""" top_tags = Tag.objects.filter( dataset__in=matching_datasets ).annotate( tag_count=Count('word') ).order_by('-tag_count')[:3] top_authors =...
[ "def", "generate_additional_context", "(", "self", ",", "matching_datasets", ")", ":", "top_tags", "=", "Tag", ".", "objects", ".", "filter", "(", "dataset__in", "=", "matching_datasets", ")", ".", "annotate", "(", "tag_count", "=", "Count", "(", "'word'", ")"...
Generate top tags and authors for a given Vertical.
[ "Generate", "top", "tags", "and", "authors", "for", "a", "given", "Vertical", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1145-L1167
DallasMorningNews/django-datafreezer
datafreezer/views.py
SourceDetail.generate_additional_context
def generate_additional_context(self, matching_datasets): """Return top tags for a source.""" top_tags = Tag.objects.filter( dataset__in=matching_datasets ).annotate( tag_count=Count('word') ).order_by('-tag_count')[:3] return { 'top_tags': to...
python
def generate_additional_context(self, matching_datasets): """Return top tags for a source.""" top_tags = Tag.objects.filter( dataset__in=matching_datasets ).annotate( tag_count=Count('word') ).order_by('-tag_count')[:3] return { 'top_tags': to...
[ "def", "generate_additional_context", "(", "self", ",", "matching_datasets", ")", ":", "top_tags", "=", "Tag", ".", "objects", ".", "filter", "(", "dataset__in", "=", "matching_datasets", ")", ".", "annotate", "(", "tag_count", "=", "Count", "(", "'word'", ")"...
Return top tags for a source.
[ "Return", "top", "tags", "for", "a", "source", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L1186-L1196
pablorecio/Cobaya
src/cobaya/hamster_db.py
HamsterDB.get_fact_by_id
def get_fact_by_id(self, fact_id): """ Obtains fact data by it's id. As the fact is unique, it returns a tuple like: (activity_id, start_time, end_time, description). If there is no fact with id == fact_id, a NoHamsterData exception will be raise """ columns = '...
python
def get_fact_by_id(self, fact_id): """ Obtains fact data by it's id. As the fact is unique, it returns a tuple like: (activity_id, start_time, end_time, description). If there is no fact with id == fact_id, a NoHamsterData exception will be raise """ columns = '...
[ "def", "get_fact_by_id", "(", "self", ",", "fact_id", ")", ":", "columns", "=", "'activity_id, start_time, end_time, description'", "query", "=", "\"SELECT %s FROM facts WHERE id = %s\"", "result", "=", "self", ".", "_query", "(", "query", "%", "(", "columns", ",", ...
Obtains fact data by it's id. As the fact is unique, it returns a tuple like: (activity_id, start_time, end_time, description). If there is no fact with id == fact_id, a NoHamsterData exception will be raise
[ "Obtains", "fact", "data", "by", "it", "s", "id", "." ]
train
https://github.com/pablorecio/Cobaya/blob/70b107dea5f31f51e7b6738da3c2a1df5b9f3f20/src/cobaya/hamster_db.py#L55-L72
pablorecio/Cobaya
src/cobaya/hamster_db.py
HamsterDB.get_activity_by_id
def get_activity_by_id(self, activity_id): """ Obtains activity data by it's id. As the activity is unique, it returns a tuple like: (name, category_id). If there is no activity with id == activity_id, a NoHamsterData exception will be raise """ columns = 'name, categor...
python
def get_activity_by_id(self, activity_id): """ Obtains activity data by it's id. As the activity is unique, it returns a tuple like: (name, category_id). If there is no activity with id == activity_id, a NoHamsterData exception will be raise """ columns = 'name, categor...
[ "def", "get_activity_by_id", "(", "self", ",", "activity_id", ")", ":", "columns", "=", "'name, category_id'", "query", "=", "\"SELECT %s FROM activities WHERE id = %s\"", "result", "=", "self", ".", "_query", "(", "query", "%", "(", "columns", ",", "activity_id", ...
Obtains activity data by it's id. As the activity is unique, it returns a tuple like: (name, category_id). If there is no activity with id == activity_id, a NoHamsterData exception will be raise
[ "Obtains", "activity", "data", "by", "it", "s", "id", "." ]
train
https://github.com/pablorecio/Cobaya/blob/70b107dea5f31f51e7b6738da3c2a1df5b9f3f20/src/cobaya/hamster_db.py#L74-L90
pablorecio/Cobaya
src/cobaya/hamster_db.py
HamsterDB.get_tags_by_fact_id
def get_tags_by_fact_id(self, fact_id): """ Obtains the tags associated by a fact_id. This function returns a list of the tags name associated to a fact, such as ['foo', 'bar', 'eggs']. If the fact has no tags, it will return a empty list. If there are no fact with id == fact_id...
python
def get_tags_by_fact_id(self, fact_id): """ Obtains the tags associated by a fact_id. This function returns a list of the tags name associated to a fact, such as ['foo', 'bar', 'eggs']. If the fact has no tags, it will return a empty list. If there are no fact with id == fact_id...
[ "def", "get_tags_by_fact_id", "(", "self", ",", "fact_id", ")", ":", "if", "not", "fact_id", "in", "self", ".", "all_facts_id", ":", "raise", "NoHamsterData", "(", "'facts'", ",", "fact_id", ")", "query", "=", "\"SELECT tag_id FROM fact_tags WHERE fact_id = %s\"", ...
Obtains the tags associated by a fact_id. This function returns a list of the tags name associated to a fact, such as ['foo', 'bar', 'eggs']. If the fact has no tags, it will return a empty list. If there are no fact with id == fact_id, a NoHamsterData exception will be raise
[ "Obtains", "the", "tags", "associated", "by", "a", "fact_id", "." ]
train
https://github.com/pablorecio/Cobaya/blob/70b107dea5f31f51e7b6738da3c2a1df5b9f3f20/src/cobaya/hamster_db.py#L92-L105
BrainSpawnInfosphere/media_html_page_generator
media/media.py
MovieWrapper.get
def get(self,movie): """ Gets the info for a single movie in: movie name [string] out: movie info [dict] """ movie = movie.replace('.mov','') movie = movie.replace('.m4v','') movie = movie.replace('.mp4','') movie = re.sub('[_-]',' ',movie) movie = movie.lower() try: ret = [] # if there...
python
def get(self,movie): """ Gets the info for a single movie in: movie name [string] out: movie info [dict] """ movie = movie.replace('.mov','') movie = movie.replace('.m4v','') movie = movie.replace('.mp4','') movie = re.sub('[_-]',' ',movie) movie = movie.lower() try: ret = [] # if there...
[ "def", "get", "(", "self", ",", "movie", ")", ":", "movie", "=", "movie", ".", "replace", "(", "'.mov'", ",", "''", ")", "movie", "=", "movie", ".", "replace", "(", "'.m4v'", ",", "''", ")", "movie", "=", "movie", ".", "replace", "(", "'.mp4'", "...
Gets the info for a single movie in: movie name [string] out: movie info [dict]
[ "Gets", "the", "info", "for", "a", "single", "movie", "in", ":", "movie", "name", "[", "string", "]", "out", ":", "movie", "info", "[", "dict", "]" ]
train
https://github.com/BrainSpawnInfosphere/media_html_page_generator/blob/cebc6f18d6c1533eaf0acb266396bbdc5cf86292/media/media.py#L231-L282
renzon/pswdclient
src/pswdclient/facade.py
log_user_in
def log_user_in(app_id, token, ticket, response, cookie_name='user', url_detail='https://pswdless.appspot.com/rest/detail'): ''' Log the user in setting the user data dictionary in cookie Returns a command that execute the logic ''' return LogUserIn(app_id, token, ticket, response, c...
python
def log_user_in(app_id, token, ticket, response, cookie_name='user', url_detail='https://pswdless.appspot.com/rest/detail'): ''' Log the user in setting the user data dictionary in cookie Returns a command that execute the logic ''' return LogUserIn(app_id, token, ticket, response, c...
[ "def", "log_user_in", "(", "app_id", ",", "token", ",", "ticket", ",", "response", ",", "cookie_name", "=", "'user'", ",", "url_detail", "=", "'https://pswdless.appspot.com/rest/detail'", ")", ":", "return", "LogUserIn", "(", "app_id", ",", "token", ",", "ticket...
Log the user in setting the user data dictionary in cookie Returns a command that execute the logic
[ "Log", "the", "user", "in", "setting", "the", "user", "data", "dictionary", "in", "cookie", "Returns", "a", "command", "that", "execute", "the", "logic" ]
train
https://github.com/renzon/pswdclient/blob/1036b9a26da876c936e5b397046440b1b98aedbb/src/pswdclient/facade.py#L30-L36
renzon/pswdclient
src/pswdclient/facade.py
fetch_user
def fetch_user(app_id, token, ticket, url_detail='https://pswdless.appspot.com/rest/detail'): ''' Fetch the user deatil from Passwordless ''' return FetchUserWithValidation(app_id, token, ticket, url_detail)
python
def fetch_user(app_id, token, ticket, url_detail='https://pswdless.appspot.com/rest/detail'): ''' Fetch the user deatil from Passwordless ''' return FetchUserWithValidation(app_id, token, ticket, url_detail)
[ "def", "fetch_user", "(", "app_id", ",", "token", ",", "ticket", ",", "url_detail", "=", "'https://pswdless.appspot.com/rest/detail'", ")", ":", "return", "FetchUserWithValidation", "(", "app_id", ",", "token", ",", "ticket", ",", "url_detail", ")" ]
Fetch the user deatil from Passwordless
[ "Fetch", "the", "user", "deatil", "from", "Passwordless" ]
train
https://github.com/renzon/pswdclient/blob/1036b9a26da876c936e5b397046440b1b98aedbb/src/pswdclient/facade.py#L39-L43
renzon/pswdclient
src/pswdclient/facade.py
send_login_email
def send_login_email(app_id, token, hook, email=None, user_id=None, lang="en_US", url_login='https://pswdless.appspot.com/rest/login'): ''' Contact password-less server to send user a email containing the login link ''' return SendLoginEmail(app_id, token, hook, email, user_id, lang...
python
def send_login_email(app_id, token, hook, email=None, user_id=None, lang="en_US", url_login='https://pswdless.appspot.com/rest/login'): ''' Contact password-less server to send user a email containing the login link ''' return SendLoginEmail(app_id, token, hook, email, user_id, lang...
[ "def", "send_login_email", "(", "app_id", ",", "token", ",", "hook", ",", "email", "=", "None", ",", "user_id", "=", "None", ",", "lang", "=", "\"en_US\"", ",", "url_login", "=", "'https://pswdless.appspot.com/rest/login'", ")", ":", "return", "SendLoginEmail", ...
Contact password-less server to send user a email containing the login link
[ "Contact", "password", "-", "less", "server", "to", "send", "user", "a", "email", "containing", "the", "login", "link" ]
train
https://github.com/renzon/pswdclient/blob/1036b9a26da876c936e5b397046440b1b98aedbb/src/pswdclient/facade.py#L46-L51
LaoLiulaoliu/pgwrapper
pgwrapper/pgpool.py
PGPool._create_connection
def _create_connection(self): """.. :py:method:: If we hava several hosts, we can random choice one to connect """ db = psycopg2.connect(database=self.dbname, user=self.user, password=self.password, host=self.host, po...
python
def _create_connection(self): """.. :py:method:: If we hava several hosts, we can random choice one to connect """ db = psycopg2.connect(database=self.dbname, user=self.user, password=self.password, host=self.host, po...
[ "def", "_create_connection", "(", "self", ")", ":", "db", "=", "psycopg2", ".", "connect", "(", "database", "=", "self", ".", "dbname", ",", "user", "=", "self", ".", "user", ",", "password", "=", "self", ".", "password", ",", "host", "=", "self", "....
.. :py:method:: If we hava several hosts, we can random choice one to connect
[ "..", ":", "py", ":", "method", "::" ]
train
https://github.com/LaoLiulaoliu/pgwrapper/blob/063a164713b79bfadb56a01c4ae19911f508d01e/pgwrapper/pgpool.py#L63-L73
LaoLiulaoliu/pgwrapper
pgwrapper/pgpool.py
PGPool.execute
def execute(self, query, vars=None, result=False): """.. :py:method:: :param bool result: whether query return result :rtype: bool .. note:: True for `select`, False for `insert` and `update` """ with self.connection() as cur: if self.debug: ...
python
def execute(self, query, vars=None, result=False): """.. :py:method:: :param bool result: whether query return result :rtype: bool .. note:: True for `select`, False for `insert` and `update` """ with self.connection() as cur: if self.debug: ...
[ "def", "execute", "(", "self", ",", "query", ",", "vars", "=", "None", ",", "result", "=", "False", ")", ":", "with", "self", ".", "connection", "(", ")", "as", "cur", ":", "if", "self", ".", "debug", ":", "print", "(", "cur", ".", "mogrify", "("...
.. :py:method:: :param bool result: whether query return result :rtype: bool .. note:: True for `select`, False for `insert` and `update`
[ "..", ":", "py", ":", "method", "::" ]
train
https://github.com/LaoLiulaoliu/pgwrapper/blob/063a164713b79bfadb56a01c4ae19911f508d01e/pgwrapper/pgpool.py#L101-L122
LaoLiulaoliu/pgwrapper
pgwrapper/pgpool.py
PGPool.batch
def batch(self, queries): """.. :py:method:: :param tuple queries: [(sql, vars), (sql, vars), ...] .. note:: batch execute queries. only support `insert` and `update`, have more efficiency """ with self.connection() as cur: for sql, vars in q...
python
def batch(self, queries): """.. :py:method:: :param tuple queries: [(sql, vars), (sql, vars), ...] .. note:: batch execute queries. only support `insert` and `update`, have more efficiency """ with self.connection() as cur: for sql, vars in q...
[ "def", "batch", "(", "self", ",", "queries", ")", ":", "with", "self", ".", "connection", "(", ")", "as", "cur", ":", "for", "sql", ",", "vars", "in", "queries", ":", "if", "self", ".", "debug", ":", "print", "(", "cur", ".", "mogrify", "(", "que...
.. :py:method:: :param tuple queries: [(sql, vars), (sql, vars), ...] .. note:: batch execute queries. only support `insert` and `update`, have more efficiency
[ "..", ":", "py", ":", "method", "::" ]
train
https://github.com/LaoLiulaoliu/pgwrapper/blob/063a164713b79bfadb56a01c4ae19911f508d01e/pgwrapper/pgpool.py#L148-L162
universalcore/unicore.hub.client
unicore/hub/client/utils.py
same_origin
def same_origin(url1, url2): ''' Return True if the urls have the same origin, else False. Copied from Django: https://github.com/django/django/blob/master/django/utils/http.py#L255 ''' p1, p2 = urlparse(url1), urlparse(url2) try: o1 = (p1.scheme, p1.hostname, p1.port or PROTOCOL_TO_PORT...
python
def same_origin(url1, url2): ''' Return True if the urls have the same origin, else False. Copied from Django: https://github.com/django/django/blob/master/django/utils/http.py#L255 ''' p1, p2 = urlparse(url1), urlparse(url2) try: o1 = (p1.scheme, p1.hostname, p1.port or PROTOCOL_TO_PORT...
[ "def", "same_origin", "(", "url1", ",", "url2", ")", ":", "p1", ",", "p2", "=", "urlparse", "(", "url1", ")", ",", "urlparse", "(", "url2", ")", "try", ":", "o1", "=", "(", "p1", ".", "scheme", ",", "p1", ".", "hostname", ",", "p1", ".", "port"...
Return True if the urls have the same origin, else False. Copied from Django: https://github.com/django/django/blob/master/django/utils/http.py#L255
[ "Return", "True", "if", "the", "urls", "have", "the", "same", "origin", "else", "False", ".", "Copied", "from", "Django", ":", "https", ":", "//", "github", ".", "com", "/", "django", "/", "django", "/", "blob", "/", "master", "/", "django", "/", "ut...
train
https://github.com/universalcore/unicore.hub.client/blob/c706f4d31e493bd4e7ea8236780a9b271b850b8b/unicore/hub/client/utils.py#L25-L36
csaez/wishlib
wishlib/ma/wrapper.py
Wrapper.update
def update(self): """ This method should be called to ensure all cached attributes are in sync with the metadata at runtime. This happens because attributes could store mutable objects and be modified outside the scope of this class. The most common idiom that isn't autom...
python
def update(self): """ This method should be called to ensure all cached attributes are in sync with the metadata at runtime. This happens because attributes could store mutable objects and be modified outside the scope of this class. The most common idiom that isn't autom...
[ "def", "update", "(", "self", ")", ":", "for", "key", ",", "value", "in", "self", ".", "__dict__", ".", "iteritems", "(", ")", ":", "key", "=", "self", ".", "_compose", "(", "key", ")", "if", "self", ".", "_validate_key", "(", "key", ")", ":", "i...
This method should be called to ensure all cached attributes are in sync with the metadata at runtime. This happens because attributes could store mutable objects and be modified outside the scope of this class. The most common idiom that isn't automagically caught is mutating a list ...
[ "This", "method", "should", "be", "called", "to", "ensure", "all", "cached", "attributes", "are", "in", "sync", "with", "the", "metadata", "at", "runtime", ".", "This", "happens", "because", "attributes", "could", "store", "mutable", "objects", "and", "be", ...
train
https://github.com/csaez/wishlib/blob/c212fa7875006a332a4cefbf69885ced9647bc2f/wishlib/ma/wrapper.py#L92-L109
jlesquembre/jlle
jlle/releaser/vcs.py
BaseVersionControl.filefind
def filefind(self, names): """Return first found file matching name (case-insensitive). Some packages have docs/HISTORY.txt and package/name/HISTORY.txt. We make sure we only return the one in the docs directory if no other can be found. 'names' can be a string or a list of st...
python
def filefind(self, names): """Return first found file matching name (case-insensitive). Some packages have docs/HISTORY.txt and package/name/HISTORY.txt. We make sure we only return the one in the docs directory if no other can be found. 'names' can be a string or a list of st...
[ "def", "filefind", "(", "self", ",", "names", ")", ":", "if", "type", "(", "names", ")", "is", "str", ":", "names", "=", "[", "names", "]", "lower_names", "=", "[", "]", "for", "name", "in", "names", ":", "lower_names", ".", "append", "(", "name", ...
Return first found file matching name (case-insensitive). Some packages have docs/HISTORY.txt and package/name/HISTORY.txt. We make sure we only return the one in the docs directory if no other can be found. 'names' can be a string or a list of strings; if you have both a CHAN...
[ "Return", "first", "found", "file", "matching", "name", "(", "case", "-", "insensitive", ")", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/vcs.py#L83-L119
jlesquembre/jlle
jlle/releaser/vcs.py
BaseVersionControl.history_file
def history_file(self, location=None): """Return history file location. """ if location: # Hardcoded location passed from the config file. if os.path.exists(location): return location else: logger.warn("The specified history fil...
python
def history_file(self, location=None): """Return history file location. """ if location: # Hardcoded location passed from the config file. if os.path.exists(location): return location else: logger.warn("The specified history fil...
[ "def", "history_file", "(", "self", ",", "location", "=", "None", ")", ":", "if", "location", ":", "# Hardcoded location passed from the config file.", "if", "os", ".", "path", ".", "exists", "(", "location", ")", ":", "return", "location", "else", ":", "logge...
Return history file location.
[ "Return", "history", "file", "location", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/vcs.py#L121-L138
jlesquembre/jlle
jlle/releaser/vcs.py
BaseVersionControl.tag_exists
def tag_exists(self, version): """Check if a tag has already been created with the name of the version. """ for tag in self.available_tags(): if tag == version: return True return False
python
def tag_exists(self, version): """Check if a tag has already been created with the name of the version. """ for tag in self.available_tags(): if tag == version: return True return False
[ "def", "tag_exists", "(", "self", ",", "version", ")", ":", "for", "tag", "in", "self", ".", "available_tags", "(", ")", ":", "if", "tag", "==", "version", ":", "return", "True", "return", "False" ]
Check if a tag has already been created with the name of the version.
[ "Check", "if", "a", "tag", "has", "already", "been", "created", "with", "the", "name", "of", "the", "version", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/vcs.py#L140-L147
jlesquembre/jlle
jlle/releaser/vcs.py
BaseVersionControl._update_version
def _update_version(self, version): """Find out where to change the version and change it. There are three places where the version can be defined. The first one is an explicitly defined Python file with a ``__version__`` attribute. The second one is some version.txt that gets read by ...
python
def _update_version(self, version): """Find out where to change the version and change it. There are three places where the version can be defined. The first one is an explicitly defined Python file with a ``__version__`` attribute. The second one is some version.txt that gets read by ...
[ "def", "_update_version", "(", "self", ",", "version", ")", ":", "if", "self", ".", "get_python_file_version", "(", ")", ":", "setup_cfg", "=", "pypi", ".", "SetupConfig", "(", ")", "filename", "=", "setup_cfg", ".", "python_file_with_version", "(", ")", "li...
Find out where to change the version and change it. There are three places where the version can be defined. The first one is an explicitly defined Python file with a ``__version__`` attribute. The second one is some version.txt that gets read by setup.py. The third is directly in setup...
[ "Find", "out", "where", "to", "change", "the", "version", "and", "change", "it", "." ]
train
https://github.com/jlesquembre/jlle/blob/3645d8f203708355853ef911f4b887ae4d794826/jlle/releaser/vcs.py#L167-L216
boisgera/breakpoint
breakpoint.py
function
def function(on_yield=None, progress=False, dt=None): """ Transform a function with breakpoints (aka generator) into a function. The result of `function` can (and often will) be used as a decorator. Arguments --------- - `on_yield`: function handler factory. A call `handler = on_yi...
python
def function(on_yield=None, progress=False, dt=None): """ Transform a function with breakpoints (aka generator) into a function. The result of `function` can (and often will) be used as a decorator. Arguments --------- - `on_yield`: function handler factory. A call `handler = on_yi...
[ "def", "function", "(", "on_yield", "=", "None", ",", "progress", "=", "False", ",", "dt", "=", "None", ")", ":", "if", "dt", "is", "not", "None", ":", "dt", "=", "float", "(", "dt", ")", "if", "dt", "<=", "0.0", ":", "error", "=", "\"dt={0} is i...
Transform a function with breakpoints (aka generator) into a function. The result of `function` can (and often will) be used as a decorator. Arguments --------- - `on_yield`: function handler factory. A call `handler = on_yield()` is performed every time the decorated generator is ...
[ "Transform", "a", "function", "with", "breakpoints", "(", "aka", "generator", ")", "into", "a", "function", "." ]
train
https://github.com/boisgera/breakpoint/blob/597bfbc2b3573a0b0cb1a54fc49a1aec9b707fa9/breakpoint.py#L30-L145
honzamach/pydgets
pydgets/widgets.py
terminal_size
def terminal_size(): """ Detect the current size of terminal window as a numer of rows and columns. """ try: (rows, columns) = os.popen('stty size', 'r').read().split() rows = int(rows) columns = int(columns) return (columns, rows) # Currently ignore any errors an...
python
def terminal_size(): """ Detect the current size of terminal window as a numer of rows and columns. """ try: (rows, columns) = os.popen('stty size', 'r').read().split() rows = int(rows) columns = int(columns) return (columns, rows) # Currently ignore any errors an...
[ "def", "terminal_size", "(", ")", ":", "try", ":", "(", "rows", ",", "columns", ")", "=", "os", ".", "popen", "(", "'stty size'", ",", "'r'", ")", ".", "read", "(", ")", ".", "split", "(", ")", "rows", "=", "int", "(", "rows", ")", "columns", "...
Detect the current size of terminal window as a numer of rows and columns.
[ "Detect", "the", "current", "size", "of", "terminal", "window", "as", "a", "numer", "of", "rows", "and", "columns", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L291-L306
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.list_settings
def list_settings(self): """ Get list of all appropriate settings and their default values. The returned list is then used in setup() and get_setup() methods to setup the widget internal settings. """ return [ (self.SETTING_FLAG_PLAIN, False), (se...
python
def list_settings(self): """ Get list of all appropriate settings and their default values. The returned list is then used in setup() and get_setup() methods to setup the widget internal settings. """ return [ (self.SETTING_FLAG_PLAIN, False), (se...
[ "def", "list_settings", "(", "self", ")", ":", "return", "[", "(", "self", ".", "SETTING_FLAG_PLAIN", ",", "False", ")", ",", "(", "self", ".", "SETTING_FLAG_ASCII", ",", "False", ")", ",", "(", "self", ".", "SETTING_WIDTH", ",", "0", ")", ",", "(", ...
Get list of all appropriate settings and their default values. The returned list is then used in setup() and get_setup() methods to setup the widget internal settings.
[ "Get", "list", "of", "all", "appropriate", "settings", "and", "their", "default", "values", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L369-L392
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.get_setup
def get_setup(self, content = None, **kwargs): """ Get current setup by combining internal settings with the ones given. """ if content is None: content = self.content if content is None: raise Exception("No content given to be displayed") setup =...
python
def get_setup(self, content = None, **kwargs): """ Get current setup by combining internal settings with the ones given. """ if content is None: content = self.content if content is None: raise Exception("No content given to be displayed") setup =...
[ "def", "get_setup", "(", "self", ",", "content", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "content", "is", "None", ":", "content", "=", "self", ".", "content", "if", "content", "is", "None", ":", "raise", "Exception", "(", "\"No content gi...
Get current setup by combining internal settings with the ones given.
[ "Get", "current", "setup", "by", "combining", "internal", "settings", "with", "the", "ones", "given", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L404-L420
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget._es_data
def _es_data(settings): """ Extract data formating related subset of widget settings. """ return {k: settings[k] for k in (ConsoleWidget.SETTING_DATA_FORMATING, ConsoleWidget.SETTING_DATA_TYPE)}
python
def _es_data(settings): """ Extract data formating related subset of widget settings. """ return {k: settings[k] for k in (ConsoleWidget.SETTING_DATA_FORMATING, ConsoleWidget.SETTING_DATA_TYPE)}
[ "def", "_es_data", "(", "settings", ")", ":", "return", "{", "k", ":", "settings", "[", "k", "]", "for", "k", "in", "(", "ConsoleWidget", ".", "SETTING_DATA_FORMATING", ",", "ConsoleWidget", ".", "SETTING_DATA_TYPE", ")", "}" ]
Extract data formating related subset of widget settings.
[ "Extract", "data", "formating", "related", "subset", "of", "widget", "settings", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L432-L437
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget._es_content
def _es_content(settings): """ Extract content formating related subset of widget settings. """ return {k: settings[k] for k in (ConsoleWidget.SETTING_WIDTH, ConsoleWidget.SETTING_ALIGN, ConsoleWidget.SETTI...
python
def _es_content(settings): """ Extract content formating related subset of widget settings. """ return {k: settings[k] for k in (ConsoleWidget.SETTING_WIDTH, ConsoleWidget.SETTING_ALIGN, ConsoleWidget.SETTI...
[ "def", "_es_content", "(", "settings", ")", ":", "return", "{", "k", ":", "settings", "[", "k", "]", "for", "k", "in", "(", "ConsoleWidget", ".", "SETTING_WIDTH", ",", "ConsoleWidget", ".", "SETTING_ALIGN", ",", "ConsoleWidget", ".", "SETTING_PADDING", ",", ...
Extract content formating related subset of widget settings.
[ "Extract", "content", "formating", "related", "subset", "of", "widget", "settings", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L440-L449
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget._es_text
def _es_text(settings, text_formating = {}): """ Extract text formating related subset of widget settings. """ s = {k: settings[k] for k in (ConsoleWidget.SETTING_FLAG_PLAIN,)} s.update(text_formating) return s
python
def _es_text(settings, text_formating = {}): """ Extract text formating related subset of widget settings. """ s = {k: settings[k] for k in (ConsoleWidget.SETTING_FLAG_PLAIN,)} s.update(text_formating) return s
[ "def", "_es_text", "(", "settings", ",", "text_formating", "=", "{", "}", ")", ":", "s", "=", "{", "k", ":", "settings", "[", "k", "]", "for", "k", "in", "(", "ConsoleWidget", ".", "SETTING_FLAG_PLAIN", ",", ")", "}", "s", ".", "update", "(", "text...
Extract text formating related subset of widget settings.
[ "Extract", "text", "formating", "related", "subset", "of", "widget", "settings", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L452-L458
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget._es_margin
def _es_margin(settings): """ Extract margin formating related subset of widget settings. """ return {k: settings[k] for k in (ConsoleWidget.SETTING_MARGIN, ConsoleWidget.SETTING_MARGIN_LEFT, ConsoleWidget....
python
def _es_margin(settings): """ Extract margin formating related subset of widget settings. """ return {k: settings[k] for k in (ConsoleWidget.SETTING_MARGIN, ConsoleWidget.SETTING_MARGIN_LEFT, ConsoleWidget....
[ "def", "_es_margin", "(", "settings", ")", ":", "return", "{", "k", ":", "settings", "[", "k", "]", "for", "k", "in", "(", "ConsoleWidget", ".", "SETTING_MARGIN", ",", "ConsoleWidget", ".", "SETTING_MARGIN_LEFT", ",", "ConsoleWidget", ".", "SETTING_MARGIN_RIGH...
Extract margin formating related subset of widget settings.
[ "Extract", "margin", "formating", "related", "subset", "of", "widget", "settings", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L461-L468
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.calculate_width_widget
def calculate_width_widget(width, margin = None, margin_left = None, margin_right = None): """ Calculate actual widget width based on given margins. """ if margin_left is None: margin_left = margin if margin_right is None: margin_right = margin if ...
python
def calculate_width_widget(width, margin = None, margin_left = None, margin_right = None): """ Calculate actual widget width based on given margins. """ if margin_left is None: margin_left = margin if margin_right is None: margin_right = margin if ...
[ "def", "calculate_width_widget", "(", "width", ",", "margin", "=", "None", ",", "margin_left", "=", "None", ",", "margin_right", "=", "None", ")", ":", "if", "margin_left", "is", "None", ":", "margin_left", "=", "margin", "if", "margin_right", "is", "None", ...
Calculate actual widget width based on given margins.
[ "Calculate", "actual", "widget", "width", "based", "on", "given", "margins", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L473-L485
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.fmt_data
def fmt_data(text, data_formating = None, data_type = None): """ Format given text according to given data formating pattern or data type. """ if data_type: return DATA_TYPES[data_type](text) elif data_formating: return str(data_formating).format(text) ...
python
def fmt_data(text, data_formating = None, data_type = None): """ Format given text according to given data formating pattern or data type. """ if data_type: return DATA_TYPES[data_type](text) elif data_formating: return str(data_formating).format(text) ...
[ "def", "fmt_data", "(", "text", ",", "data_formating", "=", "None", ",", "data_type", "=", "None", ")", ":", "if", "data_type", ":", "return", "DATA_TYPES", "[", "data_type", "]", "(", "text", ")", "elif", "data_formating", ":", "return", "str", "(", "da...
Format given text according to given data formating pattern or data type.
[ "Format", "given", "text", "according", "to", "given", "data", "formating", "pattern", "or", "data", "type", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L511-L519
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.fmt_content
def fmt_content(text, width = 0, align = '<', padding = None, padding_left = None, padding_right = None, padding_char = ' '): """ Pad given text with given padding characters, inflate it to given width and perform horizontal aligning. """ if padding_left is None: padd...
python
def fmt_content(text, width = 0, align = '<', padding = None, padding_left = None, padding_right = None, padding_char = ' '): """ Pad given text with given padding characters, inflate it to given width and perform horizontal aligning. """ if padding_left is None: padd...
[ "def", "fmt_content", "(", "text", ",", "width", "=", "0", ",", "align", "=", "'<'", ",", "padding", "=", "None", ",", "padding_left", "=", "None", ",", "padding_right", "=", "None", ",", "padding_char", "=", "' '", ")", ":", "if", "padding_left", "is"...
Pad given text with given padding characters, inflate it to given width and perform horizontal aligning.
[ "Pad", "given", "text", "with", "given", "padding", "characters", "inflate", "it", "to", "given", "width", "and", "perform", "horizontal", "aligning", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L522-L538
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.fmt_text
def fmt_text(text, bg = None, fg = None, attr = None, plain = False): """ Apply given console formating around given text. """ if not plain: if fg is not None: text = TEXT_FORMATING['fg'][fg] + text if bg is not None: text = TEXT_FO...
python
def fmt_text(text, bg = None, fg = None, attr = None, plain = False): """ Apply given console formating around given text. """ if not plain: if fg is not None: text = TEXT_FORMATING['fg'][fg] + text if bg is not None: text = TEXT_FO...
[ "def", "fmt_text", "(", "text", ",", "bg", "=", "None", ",", "fg", "=", "None", ",", "attr", "=", "None", ",", "plain", "=", "False", ")", ":", "if", "not", "plain", ":", "if", "fg", "is", "not", "None", ":", "text", "=", "TEXT_FORMATING", "[", ...
Apply given console formating around given text.
[ "Apply", "given", "console", "formating", "around", "given", "text", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L541-L554
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.fmt_margin
def fmt_margin(text, margin = None, margin_left = None, margin_right = None, margin_char = ' '): """ Surround given text with given margin characters. """ if margin_left is None: margin_left = margin if margin_right is None: margin_right = margin i...
python
def fmt_margin(text, margin = None, margin_left = None, margin_right = None, margin_char = ' '): """ Surround given text with given margin characters. """ if margin_left is None: margin_left = margin if margin_right is None: margin_right = margin i...
[ "def", "fmt_margin", "(", "text", ",", "margin", "=", "None", ",", "margin_left", "=", "None", ",", "margin_right", "=", "None", ",", "margin_char", "=", "' '", ")", ":", "if", "margin_left", "is", "None", ":", "margin_left", "=", "margin", "if", "margin...
Surround given text with given margin characters.
[ "Surround", "given", "text", "with", "given", "margin", "characters", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L557-L569
honzamach/pydgets
pydgets/widgets.py
ConsoleWidget.render
def render(self, content = None, **settings): """ Perform widget rendering, but do not print anything. """ (content, settings) = self.get_setup(content, **settings) return self._render(content, **settings)
python
def render(self, content = None, **settings): """ Perform widget rendering, but do not print anything. """ (content, settings) = self.get_setup(content, **settings) return self._render(content, **settings)
[ "def", "render", "(", "self", ",", "content", "=", "None", ",", "*", "*", "settings", ")", ":", "(", "content", ",", "settings", ")", "=", "self", ".", "get_setup", "(", "content", ",", "*", "*", "settings", ")", "return", "self", ".", "_render", "...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L579-L584
honzamach/pydgets
pydgets/widgets.py
SingleLineWidget._render
def _render(self, content, **settings): """ Perform widget rendering, but do not print anything. """ result = self._render_content(content, **settings) s = self._es_margin(settings) result = self.fmt_margin(result, **s) return result
python
def _render(self, content, **settings): """ Perform widget rendering, but do not print anything. """ result = self._render_content(content, **settings) s = self._es_margin(settings) result = self.fmt_margin(result, **s) return result
[ "def", "_render", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "result", "=", "self", ".", "_render_content", "(", "content", ",", "*", "*", "settings", ")", "s", "=", "self", ".", "_es_margin", "(", "settings", ")", "result", "=...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L599-L608
honzamach/pydgets
pydgets/widgets.py
MultiLineWidget._render
def _render(self, content, **settings): """ Perform widget rendering, but do not print anything. """ lines = self._render_content(content, **settings) result = [] s = self._es_margin(settings) for l in lines: result.append(self.fmt_margin(l, **s)) ...
python
def _render(self, content, **settings): """ Perform widget rendering, but do not print anything. """ lines = self._render_content(content, **settings) result = [] s = self._es_margin(settings) for l in lines: result.append(self.fmt_margin(l, **s)) ...
[ "def", "_render", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "lines", "=", "self", ".", "_render_content", "(", "content", ",", "*", "*", "settings", ")", "result", "=", "[", "]", "s", "=", "self", ".", "_es_margin", "(", "se...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L629-L640
honzamach/pydgets
pydgets/widgets.py
MultiLineWidget.display
def display(self, content = None, **settings): """ Perform widget rendering and output the result. """ lines = self.render(content, **settings) for l in lines: print(l)
python
def display(self, content = None, **settings): """ Perform widget rendering and output the result. """ lines = self.render(content, **settings) for l in lines: print(l)
[ "def", "display", "(", "self", ",", "content", "=", "None", ",", "*", "*", "settings", ")", ":", "lines", "=", "self", ".", "render", "(", "content", ",", "*", "*", "settings", ")", "for", "l", "in", "lines", ":", "print", "(", "l", ")" ]
Perform widget rendering and output the result.
[ "Perform", "widget", "rendering", "and", "output", "the", "result", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L642-L648
honzamach/pydgets
pydgets/widgets.py
BorderedMultiLineWidget.list_settings
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_FLAG_BORDER, True)) result.append((self.SETTING_BORDER_FORMATING, {})) result.append((self.SETTING_BORDER_S...
python
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_FLAG_BORDER, True)) result.append((self.SETTING_BORDER_FORMATING, {})) result.append((self.SETTING_BORDER_S...
[ "def", "list_settings", "(", "self", ")", ":", "result", "=", "super", "(", ")", ".", "list_settings", "(", ")", "result", ".", "append", "(", "(", "self", ".", "SETTING_FLAG_BORDER", ",", "True", ")", ")", "result", ".", "append", "(", "(", "self", ...
Get list of all appropriate settings and their default values.
[ "Get", "list", "of", "all", "appropriate", "settings", "and", "their", "default", "values", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L661-L669
honzamach/pydgets
pydgets/widgets.py
BorderedMultiLineWidget.bchar
def bchar(posh, posv, border_style): """ Retrieve table border style for particular box border piece. """ index = '{}{}'.format(posv, posh).lower() return BORDER_STYLES[border_style][index]
python
def bchar(posh, posv, border_style): """ Retrieve table border style for particular box border piece. """ index = '{}{}'.format(posv, posh).lower() return BORDER_STYLES[border_style][index]
[ "def", "bchar", "(", "posh", ",", "posv", ",", "border_style", ")", ":", "index", "=", "'{}{}'", ".", "format", "(", "posv", ",", "posh", ")", ".", "lower", "(", ")", "return", "BORDER_STYLES", "[", "border_style", "]", "[", "index", "]" ]
Retrieve table border style for particular box border piece.
[ "Retrieve", "table", "border", "style", "for", "particular", "box", "border", "piece", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L672-L677
honzamach/pydgets
pydgets/widgets.py
BorderedMultiLineWidget.calculate_width_widget_int
def calculate_width_widget_int(width, border = False, margin = None, margin_left = None, margin_right = None): """ Calculate actual widget content width based on given margins and paddings. """ if margin_left is None: margin_left = margin if margin_right is None: ...
python
def calculate_width_widget_int(width, border = False, margin = None, margin_left = None, margin_right = None): """ Calculate actual widget content width based on given margins and paddings. """ if margin_left is None: margin_left = margin if margin_right is None: ...
[ "def", "calculate_width_widget_int", "(", "width", ",", "border", "=", "False", ",", "margin", "=", "None", ",", "margin_left", "=", "None", ",", "margin_right", "=", "None", ")", ":", "if", "margin_left", "is", "None", ":", "margin_left", "=", "margin", "...
Calculate actual widget content width based on given margins and paddings.
[ "Calculate", "actual", "widget", "content", "width", "based", "on", "given", "margins", "and", "paddings", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L682-L696
honzamach/pydgets
pydgets/widgets.py
BorderedMultiLineWidget.calculate_width_content
def calculate_width_content(width, border = False, margin = None, margin_left = None, margin_right = None, padding = None, padding_left = None, padding_right = None): """ Calculate actual widget content width based on given margins and paddings. """ if margin_left is None: ma...
python
def calculate_width_content(width, border = False, margin = None, margin_left = None, margin_right = None, padding = None, padding_left = None, padding_right = None): """ Calculate actual widget content width based on given margins and paddings. """ if margin_left is None: ma...
[ "def", "calculate_width_content", "(", "width", ",", "border", "=", "False", ",", "margin", "=", "None", ",", "margin_left", "=", "None", ",", "margin_right", "=", "None", ",", "padding", "=", "None", ",", "padding_left", "=", "None", ",", "padding_right", ...
Calculate actual widget content width based on given margins and paddings.
[ "Calculate", "actual", "widget", "content", "width", "based", "on", "given", "margins", "and", "paddings", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L699-L721
honzamach/pydgets
pydgets/widgets.py
TextWidget.list_settings
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_TEXT_HIGHLIGHT, None)) return result
python
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_TEXT_HIGHLIGHT, None)) return result
[ "def", "list_settings", "(", "self", ")", ":", "result", "=", "super", "(", ")", ".", "list_settings", "(", ")", "result", ".", "append", "(", "(", "self", ".", "SETTING_TEXT_HIGHLIGHT", ",", "None", ")", ")", "return", "result" ]
Get list of all appropriate settings and their default values.
[ "Get", "list", "of", "all", "appropriate", "settings", "and", "their", "default", "values", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L732-L738
honzamach/pydgets
pydgets/widgets.py
TextWidget._render_content
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ ocontent = content s = self._es_data(settings) content = self.fmt_data(content, **s) s = self._es_content(settings) content = self.fmt_content(co...
python
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ ocontent = content s = self._es_data(settings) content = self.fmt_data(content, **s) s = self._es_content(settings) content = self.fmt_content(co...
[ "def", "_render_content", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "ocontent", "=", "content", "s", "=", "self", ".", "_es_data", "(", "settings", ")", "content", "=", "self", ".", "fmt_data", "(", "content", ",", "*", "*", "...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L742-L763
honzamach/pydgets
pydgets/widgets.py
StatusLineWidget._render_content
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ settings[self.SETTING_WIDTH] = TERMINAL_WIDTH return super()._render_content(content, **settings)
python
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ settings[self.SETTING_WIDTH] = TERMINAL_WIDTH return super()._render_content(content, **settings)
[ "def", "_render_content", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "settings", "[", "self", ".", "SETTING_WIDTH", "]", "=", "TERMINAL_WIDTH", "return", "super", "(", ")", ".", "_render_content", "(", "content", ",", "*", "*", "se...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L772-L777
honzamach/pydgets
pydgets/widgets.py
ListWidget.list_settings
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_LIST_FORMATING, {})) result.append((self.SETTING_LIST_STYLE, 'utf8.a')) result.append((self.SETTING_LIST_TY...
python
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_LIST_FORMATING, {})) result.append((self.SETTING_LIST_STYLE, 'utf8.a')) result.append((self.SETTING_LIST_TY...
[ "def", "list_settings", "(", "self", ")", ":", "result", "=", "super", "(", ")", ".", "list_settings", "(", ")", "result", ".", "append", "(", "(", "self", ".", "SETTING_LIST_FORMATING", ",", "{", "}", ")", ")", "result", ".", "append", "(", "(", "se...
Get list of all appropriate settings and their default values.
[ "Get", "list", "of", "all", "appropriate", "settings", "and", "their", "default", "values", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L794-L802
honzamach/pydgets
pydgets/widgets.py
ListWidget._render_item
def _render_item(self, depth, key, value = None, **settings): """ Format single list item. """ strptrn = self.INDENT * depth lchar = self.lchar(settings[self.SETTING_LIST_STYLE]) s = self._es_text(settings, settings[self.SETTING_LIST_FORMATING]) lchar = self.fmt...
python
def _render_item(self, depth, key, value = None, **settings): """ Format single list item. """ strptrn = self.INDENT * depth lchar = self.lchar(settings[self.SETTING_LIST_STYLE]) s = self._es_text(settings, settings[self.SETTING_LIST_FORMATING]) lchar = self.fmt...
[ "def", "_render_item", "(", "self", ",", "depth", ",", "key", ",", "value", "=", "None", ",", "*", "*", "settings", ")", ":", "strptrn", "=", "self", ".", "INDENT", "*", "depth", "lchar", "=", "self", ".", "lchar", "(", "settings", "[", "self", "."...
Format single list item.
[ "Format", "single", "list", "item", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L813-L829
honzamach/pydgets
pydgets/widgets.py
TreeWidget.list_settings
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_TREE_FORMATING, {})) result.append((self.SETTING_TREE_STYLE, 'utf8.a')) return result
python
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_TREE_FORMATING, {})) result.append((self.SETTING_TREE_STYLE, 'utf8.a')) return result
[ "def", "list_settings", "(", "self", ")", ":", "result", "=", "super", "(", ")", ".", "list_settings", "(", ")", "result", ".", "append", "(", "(", "self", ".", "SETTING_TREE_FORMATING", ",", "{", "}", ")", ")", "result", ".", "append", "(", "(", "se...
Get list of all appropriate settings and their default values.
[ "Get", "list", "of", "all", "appropriate", "settings", "and", "their", "default", "values", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L894-L901
honzamach/pydgets
pydgets/widgets.py
TreeWidget.tchar
def tchar(tree_style, cur_level, level, item, size): """ Retrieve tree character for particular tree node. """ if (cur_level == level): i1 = '1' if level == 0 else 'x' i2 = '1' if item == 0 else 'x' i3 = 'x' if size == 1: i...
python
def tchar(tree_style, cur_level, level, item, size): """ Retrieve tree character for particular tree node. """ if (cur_level == level): i1 = '1' if level == 0 else 'x' i2 = '1' if item == 0 else 'x' i3 = 'x' if size == 1: i...
[ "def", "tchar", "(", "tree_style", ",", "cur_level", ",", "level", ",", "item", ",", "size", ")", ":", "if", "(", "cur_level", "==", "level", ")", ":", "i1", "=", "'1'", "if", "level", "==", "0", "else", "'x'", "i2", "=", "'1'", "if", "item", "==...
Retrieve tree character for particular tree node.
[ "Retrieve", "tree", "character", "for", "particular", "tree", "node", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L904-L919
honzamach/pydgets
pydgets/widgets.py
TreeWidget._render_item
def _render_item(self, dstack, key, value = None, **settings): """ Format single tree line. """ cur_depth = len(dstack) - 1 treeptrn = '' s = self._es_text(settings, settings[self.SETTING_TREE_FORMATING]) for ds in dstack: treeptrn += ' ' + self.fmt_t...
python
def _render_item(self, dstack, key, value = None, **settings): """ Format single tree line. """ cur_depth = len(dstack) - 1 treeptrn = '' s = self._es_text(settings, settings[self.SETTING_TREE_FORMATING]) for ds in dstack: treeptrn += ' ' + self.fmt_t...
[ "def", "_render_item", "(", "self", ",", "dstack", ",", "key", ",", "value", "=", "None", ",", "*", "*", "settings", ")", ":", "cur_depth", "=", "len", "(", "dstack", ")", "-", "1", "treeptrn", "=", "''", "s", "=", "self", ".", "_es_text", "(", "...
Format single tree line.
[ "Format", "single", "tree", "line", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L923-L940
honzamach/pydgets
pydgets/widgets.py
TreeWidget._render_content_list
def _render_content_list(self, content, depth, dstack, **settings): """ Render the list. """ result = [] i = 0 size = len(content) for value in content: ds = [(depth, i, size)] ds = dstack + ds if isinstance(value, dict): ...
python
def _render_content_list(self, content, depth, dstack, **settings): """ Render the list. """ result = [] i = 0 size = len(content) for value in content: ds = [(depth, i, size)] ds = dstack + ds if isinstance(value, dict): ...
[ "def", "_render_content_list", "(", "self", ",", "content", ",", "depth", ",", "dstack", ",", "*", "*", "settings", ")", ":", "result", "=", "[", "]", "i", "=", "0", "size", "=", "len", "(", "content", ")", "for", "value", "in", "content", ":", "ds...
Render the list.
[ "Render", "the", "list", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L942-L961
honzamach/pydgets
pydgets/widgets.py
TreeWidget._render_content_dict
def _render_content_dict(self, content, depth, dstack, **settings): """ Render the dict. """ result = [] i = 0 size = len(content) for key in sorted(content): ds = [(depth, i, size)] ds = dstack + ds if isinstance(content[key], ...
python
def _render_content_dict(self, content, depth, dstack, **settings): """ Render the dict. """ result = [] i = 0 size = len(content) for key in sorted(content): ds = [(depth, i, size)] ds = dstack + ds if isinstance(content[key], ...
[ "def", "_render_content_dict", "(", "self", ",", "content", ",", "depth", ",", "dstack", ",", "*", "*", "settings", ")", ":", "result", "=", "[", "]", "i", "=", "0", "size", "=", "len", "(", "content", ")", "for", "key", "in", "sorted", "(", "conte...
Render the dict.
[ "Render", "the", "dict", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L963-L982
honzamach/pydgets
pydgets/widgets.py
TreeWidget._render_content
def _render_content(self, content, **settings): """ Render the tree widget. """ if isinstance(content, dict): return self._render_content_dict(content, 0, [], **settings) elif isinstance(content, list): return self._render_content_list(content, 0, [], **se...
python
def _render_content(self, content, **settings): """ Render the tree widget. """ if isinstance(content, dict): return self._render_content_dict(content, 0, [], **settings) elif isinstance(content, list): return self._render_content_list(content, 0, [], **se...
[ "def", "_render_content", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "if", "isinstance", "(", "content", ",", "dict", ")", ":", "return", "self", ".", "_render_content_dict", "(", "content", ",", "0", ",", "[", "]", ",", "*", "...
Render the tree widget.
[ "Render", "the", "tree", "widget", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L986-L995
honzamach/pydgets
pydgets/widgets.py
BoxWidget.list_settings
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_FLAG_HEADER, True)) result.append((self.SETTING_HEADER_CONTENT, 'Notice')) result.append((self.SETTING_HEAD...
python
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_FLAG_HEADER, True)) result.append((self.SETTING_HEADER_CONTENT, 'Notice')) result.append((self.SETTING_HEAD...
[ "def", "list_settings", "(", "self", ")", ":", "result", "=", "super", "(", ")", ".", "list_settings", "(", ")", "result", ".", "append", "(", "(", "self", ".", "SETTING_FLAG_HEADER", ",", "True", ")", ")", "result", ".", "append", "(", "(", "self", ...
Get list of all appropriate settings and their default values.
[ "Get", "list", "of", "all", "appropriate", "settings", "and", "their", "default", "values", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1010-L1018
honzamach/pydgets
pydgets/widgets.py
BoxWidget.fmt_border
def fmt_border(self, width, t = 'm', border_style = 'utf8.a', border_formating = {}): """ Format box separator line. """ border = self.bchar('l', t, border_style) + (self.bchar('h', t, border_style) * (width-2)) + self.bchar('r', t, border_style) return self.fmt_text(border, **bo...
python
def fmt_border(self, width, t = 'm', border_style = 'utf8.a', border_formating = {}): """ Format box separator line. """ border = self.bchar('l', t, border_style) + (self.bchar('h', t, border_style) * (width-2)) + self.bchar('r', t, border_style) return self.fmt_text(border, **bo...
[ "def", "fmt_border", "(", "self", ",", "width", ",", "t", "=", "'m'", ",", "border_style", "=", "'utf8.a'", ",", "border_formating", "=", "{", "}", ")", ":", "border", "=", "self", ".", "bchar", "(", "'l'", ",", "t", ",", "border_style", ")", "+", ...
Format box separator line.
[ "Format", "box", "separator", "line", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1020-L1025
honzamach/pydgets
pydgets/widgets.py
BoxWidget._wrap_content
def _wrap_content(content, width): """ Wrap given content into lines of given width. """ data = [] if isinstance(content, list): data += content else: data.append(content) lines = [] for d in data: l = textwrap.wrap(d, ...
python
def _wrap_content(content, width): """ Wrap given content into lines of given width. """ data = [] if isinstance(content, list): data += content else: data.append(content) lines = [] for d in data: l = textwrap.wrap(d, ...
[ "def", "_wrap_content", "(", "content", ",", "width", ")", ":", "data", "=", "[", "]", "if", "isinstance", "(", "content", ",", "list", ")", ":", "data", "+=", "content", "else", ":", "data", ".", "append", "(", "content", ")", "lines", "=", "[", "...
Wrap given content into lines of given width.
[ "Wrap", "given", "content", "into", "lines", "of", "given", "width", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1030-L1044
honzamach/pydgets
pydgets/widgets.py
BoxWidget._render_border_line
def _render_border_line(self, t, settings): """ Render box border line. """ s = self._es(settings, self.SETTING_WIDTH, self.SETTING_MARGIN, self.SETTING_MARGIN_LEFT, self.SETTING_MARGIN_RIGHT) w = self.calculate_width_widget(**s) s = self._es(settings, self.SETTING_BORDER...
python
def _render_border_line(self, t, settings): """ Render box border line. """ s = self._es(settings, self.SETTING_WIDTH, self.SETTING_MARGIN, self.SETTING_MARGIN_LEFT, self.SETTING_MARGIN_RIGHT) w = self.calculate_width_widget(**s) s = self._es(settings, self.SETTING_BORDER...
[ "def", "_render_border_line", "(", "self", ",", "t", ",", "settings", ")", ":", "s", "=", "self", ".", "_es", "(", "settings", ",", "self", ".", "SETTING_WIDTH", ",", "self", ".", "SETTING_MARGIN", ",", "self", ".", "SETTING_MARGIN_LEFT", ",", "self", "....
Render box border line.
[ "Render", "box", "border", "line", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1048-L1058
honzamach/pydgets
pydgets/widgets.py
BoxWidget._render_line
def _render_line(self, line, settings): """ Render single box line. """ s = self._es(settings, self.SETTING_WIDTH, self.SETTING_FLAG_BORDER, self.SETTING_MARGIN, self.SETTING_MARGIN_LEFT, self.SETTING_MARGIN_RIGHT) width_content = self.calculate_width_widget_int(**s) s =...
python
def _render_line(self, line, settings): """ Render single box line. """ s = self._es(settings, self.SETTING_WIDTH, self.SETTING_FLAG_BORDER, self.SETTING_MARGIN, self.SETTING_MARGIN_LEFT, self.SETTING_MARGIN_RIGHT) width_content = self.calculate_width_widget_int(**s) s =...
[ "def", "_render_line", "(", "self", ",", "line", ",", "settings", ")", ":", "s", "=", "self", ".", "_es", "(", "settings", ",", "self", ".", "SETTING_WIDTH", ",", "self", ".", "SETTING_FLAG_BORDER", ",", "self", ".", "SETTING_MARGIN", ",", "self", ".", ...
Render single box line.
[ "Render", "single", "box", "line", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1060-L1083
honzamach/pydgets
pydgets/widgets.py
BoxWidget._render_content
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ if not self.SETTING_WIDTH in settings or not settings[self.SETTING_WIDTH]: settings[self.SETTING_WIDTH] = TERMINAL_WIDTH s = {k: settings[k] for k in (self.SE...
python
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ if not self.SETTING_WIDTH in settings or not settings[self.SETTING_WIDTH]: settings[self.SETTING_WIDTH] = TERMINAL_WIDTH s = {k: settings[k] for k in (self.SE...
[ "def", "_render_content", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "if", "not", "self", ".", "SETTING_WIDTH", "in", "settings", "or", "not", "settings", "[", "self", ".", "SETTING_WIDTH", "]", ":", "settings", "[", "self", ".", ...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1085-L1109
honzamach/pydgets
pydgets/widgets.py
TableWidget.list_settings
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_FLAG_HEADER, True)) result.append((self.SETTING_HEADER_CONTENT, 'Notice')) result.append((self.SETTING_HEAD...
python
def list_settings(self): """ Get list of all appropriate settings and their default values. """ result = super().list_settings() result.append((self.SETTING_FLAG_HEADER, True)) result.append((self.SETTING_HEADER_CONTENT, 'Notice')) result.append((self.SETTING_HEAD...
[ "def", "list_settings", "(", "self", ")", ":", "result", "=", "super", "(", ")", ".", "list_settings", "(", ")", "result", ".", "append", "(", "(", "self", ".", "SETTING_FLAG_HEADER", ",", "True", ")", ")", "result", ".", "append", "(", "(", "self", ...
Get list of all appropriate settings and their default values.
[ "Get", "list", "of", "all", "appropriate", "settings", "and", "their", "default", "values", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1127-L1138
honzamach/pydgets
pydgets/widgets.py
TableWidget.fmt_border
def fmt_border(self, dimensions, t = 'm', border_style = 'utf8.a', border_formating = {}): """ Format table separator line. """ cells = [] for column in dimensions: cells.append(self.bchar('h', t, border_style) * (dimensions[column] + 2)) border = '{}{}{}'.fo...
python
def fmt_border(self, dimensions, t = 'm', border_style = 'utf8.a', border_formating = {}): """ Format table separator line. """ cells = [] for column in dimensions: cells.append(self.bchar('h', t, border_style) * (dimensions[column] + 2)) border = '{}{}{}'.fo...
[ "def", "fmt_border", "(", "self", ",", "dimensions", ",", "t", "=", "'m'", ",", "border_style", "=", "'utf8.a'", ",", "border_formating", "=", "{", "}", ")", ":", "cells", "=", "[", "]", "for", "column", "in", "dimensions", ":", "cells", ".", "append",...
Format table separator line.
[ "Format", "table", "separator", "line", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1140-L1149
honzamach/pydgets
pydgets/widgets.py
TableWidget.fmt_cell
def fmt_cell(self, value, width, cell_formating, **text_formating): """ Format sigle table cell. """ strptrn = " {:" + '{:s}{:d}'.format(cell_formating.get('align', '<'), width) + "s} " strptrn = self.fmt_text(strptrn, **text_formating) return strptrn.format(value)
python
def fmt_cell(self, value, width, cell_formating, **text_formating): """ Format sigle table cell. """ strptrn = " {:" + '{:s}{:d}'.format(cell_formating.get('align', '<'), width) + "s} " strptrn = self.fmt_text(strptrn, **text_formating) return strptrn.format(value)
[ "def", "fmt_cell", "(", "self", ",", "value", ",", "width", ",", "cell_formating", ",", "*", "*", "text_formating", ")", ":", "strptrn", "=", "\" {:\"", "+", "'{:s}{:d}'", ".", "format", "(", "cell_formating", ".", "get", "(", "'align'", ",", "'<'", ")",...
Format sigle table cell.
[ "Format", "sigle", "table", "cell", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1151-L1157
honzamach/pydgets
pydgets/widgets.py
TableWidget.fmt_row
def fmt_row(self, columns, dimensions, row, **settings): """ Format single table row. """ cells = [] i = 0 for column in columns: cells.append(self.fmt_cell( row[i], dimensions[i], column, ...
python
def fmt_row(self, columns, dimensions, row, **settings): """ Format single table row. """ cells = [] i = 0 for column in columns: cells.append(self.fmt_cell( row[i], dimensions[i], column, ...
[ "def", "fmt_row", "(", "self", ",", "columns", ",", "dimensions", ",", "row", ",", "*", "*", "settings", ")", ":", "cells", "=", "[", "]", "i", "=", "0", "for", "column", "in", "columns", ":", "cells", ".", "append", "(", "self", ".", "fmt_cell", ...
Format single table row.
[ "Format", "single", "table", "row", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1159-L1176
honzamach/pydgets
pydgets/widgets.py
TableWidget.fmt_row_header
def fmt_row_header(self, columns, dimensions, **settings): """ Format table header row. """ row = list(map(lambda x: x['label'], columns)) return self.fmt_row(columns, dimensions, row, **settings)
python
def fmt_row_header(self, columns, dimensions, **settings): """ Format table header row. """ row = list(map(lambda x: x['label'], columns)) return self.fmt_row(columns, dimensions, row, **settings)
[ "def", "fmt_row_header", "(", "self", ",", "columns", ",", "dimensions", ",", "*", "*", "settings", ")", ":", "row", "=", "list", "(", "map", "(", "lambda", "x", ":", "x", "[", "'label'", "]", ",", "columns", ")", ")", "return", "self", ".", "fmt_r...
Format table header row.
[ "Format", "table", "header", "row", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1178-L1183
honzamach/pydgets
pydgets/widgets.py
TableWidget.table_format
def table_format(self, columns, content): """ Enumerate each table column. """ result = [] textw = TextWidget() for row in content: i = 0 result_row = [] for cell in row: result_row.append(textw.render(cell, **columns[i]...
python
def table_format(self, columns, content): """ Enumerate each table column. """ result = [] textw = TextWidget() for row in content: i = 0 result_row = [] for cell in row: result_row.append(textw.render(cell, **columns[i]...
[ "def", "table_format", "(", "self", ",", "columns", ",", "content", ")", ":", "result", "=", "[", "]", "textw", "=", "TextWidget", "(", ")", "for", "row", "in", "content", ":", "i", "=", "0", "result_row", "=", "[", "]", "for", "cell", "in", "row",...
Enumerate each table column.
[ "Enumerate", "each", "table", "column", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1187-L1200
honzamach/pydgets
pydgets/widgets.py
TableWidget.table_enumerate
def table_enumerate(self, columns, content): """ Enumerate each table column. """ columns.insert(0, { 'label': '#', 'enumerated': True }) i = 0 for row in content: i += 1 row.insert(0, '{:d}'.format(i)) return (columns, content)
python
def table_enumerate(self, columns, content): """ Enumerate each table column. """ columns.insert(0, { 'label': '#', 'enumerated': True }) i = 0 for row in content: i += 1 row.insert(0, '{:d}'.format(i)) return (columns, content)
[ "def", "table_enumerate", "(", "self", ",", "columns", ",", "content", ")", ":", "columns", ".", "insert", "(", "0", ",", "{", "'label'", ":", "'#'", ",", "'enumerated'", ":", "True", "}", ")", "i", "=", "0", "for", "row", "in", "content", ":", "i"...
Enumerate each table column.
[ "Enumerate", "each", "table", "column", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1202-L1211
honzamach/pydgets
pydgets/widgets.py
TableWidget.table_measure
def table_measure(self, columns, content): """ Measure the width of each table column. """ dimensions = {} for row in content: i = 0 for cell in row: # Calculate maximum from: dimensions[i] = max( dim...
python
def table_measure(self, columns, content): """ Measure the width of each table column. """ dimensions = {} for row in content: i = 0 for cell in row: # Calculate maximum from: dimensions[i] = max( dim...
[ "def", "table_measure", "(", "self", ",", "columns", ",", "content", ")", ":", "dimensions", "=", "{", "}", "for", "row", "in", "content", ":", "i", "=", "0", "for", "cell", "in", "row", ":", "# Calculate maximum from:", "dimensions", "[", "i", "]", "=...
Measure the width of each table column.
[ "Measure", "the", "width", "of", "each", "table", "column", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1213-L1229
honzamach/pydgets
pydgets/widgets.py
TableWidget._render_content
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ result = [] columns = settings[self.SETTING_COLUMNS] # Format each table cell into string. (columns, content) = self.table_format(columns, content) ...
python
def _render_content(self, content, **settings): """ Perform widget rendering, but do not print anything. """ result = [] columns = settings[self.SETTING_COLUMNS] # Format each table cell into string. (columns, content) = self.table_format(columns, content) ...
[ "def", "_render_content", "(", "self", ",", "content", ",", "*", "*", "settings", ")", ":", "result", "=", "[", "]", "columns", "=", "settings", "[", "self", ".", "SETTING_COLUMNS", "]", "# Format each table cell into string.", "(", "columns", ",", "content", ...
Perform widget rendering, but do not print anything.
[ "Perform", "widget", "rendering", "but", "do", "not", "print", "anything", "." ]
train
https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1233-L1267