partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | normalize_unicode | Normalize any unicode characters to ascii equivalent
https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize | hashedindex/textparser.py | def normalize_unicode(text):
"""
Normalize any unicode characters to ascii equivalent
https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize
"""
if isinstance(text, six.text_type):
return unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf8')
else:... | def normalize_unicode(text):
"""
Normalize any unicode characters to ascii equivalent
https://docs.python.org/2/library/unicodedata.html#unicodedata.normalize
"""
if isinstance(text, six.text_type):
return unicodedata.normalize('NFKD', text).encode('ascii', 'ignore').decode('utf8')
else:... | [
"Normalize",
"any",
"unicode",
"characters",
"to",
"ascii",
"equivalent",
"https",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"2",
"/",
"library",
"/",
"unicodedata",
".",
"html#unicodedata",
".",
"normalize"
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/textparser.py#L51-L59 | [
"def",
"normalize_unicode",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"six",
".",
"text_type",
")",
":",
"return",
"unicodedata",
".",
"normalize",
"(",
"'NFKD'",
",",
"text",
")",
".",
"encode",
"(",
"'ascii'",
",",
"'ignore'",
")",
... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | word_tokenize | Parses the given text and yields tokens which represent words within
the given text. Tokens are assumed to be divided by any form of
whitespace character. | hashedindex/textparser.py | def word_tokenize(text, stopwords=_stopwords, ngrams=None, min_length=0, ignore_numeric=True):
"""
Parses the given text and yields tokens which represent words within
the given text. Tokens are assumed to be divided by any form of
whitespace character.
"""
if ngrams is None:
ngrams = 1
... | def word_tokenize(text, stopwords=_stopwords, ngrams=None, min_length=0, ignore_numeric=True):
"""
Parses the given text and yields tokens which represent words within
the given text. Tokens are assumed to be divided by any form of
whitespace character.
"""
if ngrams is None:
ngrams = 1
... | [
"Parses",
"the",
"given",
"text",
"and",
"yields",
"tokens",
"which",
"represent",
"words",
"within",
"the",
"given",
"text",
".",
"Tokens",
"are",
"assumed",
"to",
"be",
"divided",
"by",
"any",
"form",
"of",
"whitespace",
"character",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/textparser.py#L67-L89 | [
"def",
"word_tokenize",
"(",
"text",
",",
"stopwords",
"=",
"_stopwords",
",",
"ngrams",
"=",
"None",
",",
"min_length",
"=",
"0",
",",
"ignore_numeric",
"=",
"True",
")",
":",
"if",
"ngrams",
"is",
"None",
":",
"ngrams",
"=",
"1",
"text",
"=",
"re",
... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | cmake_setup | attempt to build using CMake >= 3 | msise00/build.py | def cmake_setup():
"""
attempt to build using CMake >= 3
"""
cmake_exe = shutil.which('cmake')
if not cmake_exe:
raise FileNotFoundError('CMake not available')
wopts = ['-G', 'MinGW Makefiles', '-DCMAKE_SH="CMAKE_SH-NOTFOUND'] if os.name == 'nt' else []
subprocess.check_call([cmake... | def cmake_setup():
"""
attempt to build using CMake >= 3
"""
cmake_exe = shutil.which('cmake')
if not cmake_exe:
raise FileNotFoundError('CMake not available')
wopts = ['-G', 'MinGW Makefiles', '-DCMAKE_SH="CMAKE_SH-NOTFOUND'] if os.name == 'nt' else []
subprocess.check_call([cmake... | [
"attempt",
"to",
"build",
"using",
"CMake",
">",
"=",
"3"
] | scivision/msise00 | python | https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/build.py#L27-L44 | [
"def",
"cmake_setup",
"(",
")",
":",
"cmake_exe",
"=",
"shutil",
".",
"which",
"(",
"'cmake'",
")",
"if",
"not",
"cmake_exe",
":",
"raise",
"FileNotFoundError",
"(",
"'CMake not available'",
")",
"wopts",
"=",
"[",
"'-G'",
",",
"'MinGW Makefiles'",
",",
"'-D... | 13a283ec02679ab74672f284ba68a7a8f896dc6f |
train | meson_setup | attempt to build with Meson + Ninja | msise00/build.py | def meson_setup():
"""
attempt to build with Meson + Ninja
"""
meson_exe = shutil.which('meson')
ninja_exe = shutil.which('ninja')
if not meson_exe or not ninja_exe:
raise FileNotFoundError('Meson or Ninja not available')
if not (BINDIR / 'build.ninja').is_file():
subproces... | def meson_setup():
"""
attempt to build with Meson + Ninja
"""
meson_exe = shutil.which('meson')
ninja_exe = shutil.which('ninja')
if not meson_exe or not ninja_exe:
raise FileNotFoundError('Meson or Ninja not available')
if not (BINDIR / 'build.ninja').is_file():
subproces... | [
"attempt",
"to",
"build",
"with",
"Meson",
"+",
"Ninja"
] | scivision/msise00 | python | https://github.com/scivision/msise00/blob/13a283ec02679ab74672f284ba68a7a8f896dc6f/msise00/build.py#L47-L63 | [
"def",
"meson_setup",
"(",
")",
":",
"meson_exe",
"=",
"shutil",
".",
"which",
"(",
"'meson'",
")",
"ninja_exe",
"=",
"shutil",
".",
"which",
"(",
"'ninja'",
")",
"if",
"not",
"meson_exe",
"or",
"not",
"ninja_exe",
":",
"raise",
"FileNotFoundError",
"(",
... | 13a283ec02679ab74672f284ba68a7a8f896dc6f |
train | HashedIndex.add_term_occurrence | Adds an occurrence of the term in the specified document. | hashedindex/__init__.py | def add_term_occurrence(self, term, document):
"""
Adds an occurrence of the term in the specified document.
"""
if document not in self._documents:
self._documents[document] = 0
if term not in self._terms:
if self._freeze:
return
... | def add_term_occurrence(self, term, document):
"""
Adds an occurrence of the term in the specified document.
"""
if document not in self._documents:
self._documents[document] = 0
if term not in self._terms:
if self._freeze:
return
... | [
"Adds",
"an",
"occurrence",
"of",
"the",
"term",
"in",
"the",
"specified",
"document",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L69-L86 | [
"def",
"add_term_occurrence",
"(",
"self",
",",
"term",
",",
"document",
")",
":",
"if",
"document",
"not",
"in",
"self",
".",
"_documents",
":",
"self",
".",
"_documents",
"[",
"document",
"]",
"=",
"0",
"if",
"term",
"not",
"in",
"self",
".",
"_terms... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.get_total_term_frequency | Gets the frequency of the specified term in the entire corpus
added to the HashedIndex. | hashedindex/__init__.py | def get_total_term_frequency(self, term):
"""
Gets the frequency of the specified term in the entire corpus
added to the HashedIndex.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
return sum(self._terms[term].values()) | def get_total_term_frequency(self, term):
"""
Gets the frequency of the specified term in the entire corpus
added to the HashedIndex.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
return sum(self._terms[term].values()) | [
"Gets",
"the",
"frequency",
"of",
"the",
"specified",
"term",
"in",
"the",
"entire",
"corpus",
"added",
"to",
"the",
"HashedIndex",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L88-L96 | [
"def",
"get_total_term_frequency",
"(",
"self",
",",
"term",
")",
":",
"if",
"term",
"not",
"in",
"self",
".",
"_terms",
":",
"raise",
"IndexError",
"(",
"TERM_DOES_NOT_EXIST",
")",
"return",
"sum",
"(",
"self",
".",
"_terms",
"[",
"term",
"]",
".",
"val... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.get_term_frequency | Returns the frequency of the term specified in the document. | hashedindex/__init__.py | def get_term_frequency(self, term, document, normalized=False):
"""
Returns the frequency of the term specified in the document.
"""
if document not in self._documents:
raise IndexError(DOCUMENT_DOES_NOT_EXIST)
if term not in self._terms:
raise IndexError... | def get_term_frequency(self, term, document, normalized=False):
"""
Returns the frequency of the term specified in the document.
"""
if document not in self._documents:
raise IndexError(DOCUMENT_DOES_NOT_EXIST)
if term not in self._terms:
raise IndexError... | [
"Returns",
"the",
"frequency",
"of",
"the",
"term",
"specified",
"in",
"the",
"document",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L98-L112 | [
"def",
"get_term_frequency",
"(",
"self",
",",
"term",
",",
"document",
",",
"normalized",
"=",
"False",
")",
":",
"if",
"document",
"not",
"in",
"self",
".",
"_documents",
":",
"raise",
"IndexError",
"(",
"DOCUMENT_DOES_NOT_EXIST",
")",
"if",
"term",
"not",... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.get_document_frequency | Returns the number of documents the specified term appears in. | hashedindex/__init__.py | def get_document_frequency(self, term):
"""
Returns the number of documents the specified term appears in.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return len(self._terms[term]) | def get_document_frequency(self, term):
"""
Returns the number of documents the specified term appears in.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return len(self._terms[term]) | [
"Returns",
"the",
"number",
"of",
"documents",
"the",
"specified",
"term",
"appears",
"in",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L114-L121 | [
"def",
"get_document_frequency",
"(",
"self",
",",
"term",
")",
":",
"if",
"term",
"not",
"in",
"self",
".",
"_terms",
":",
"raise",
"IndexError",
"(",
"TERM_DOES_NOT_EXIST",
")",
"else",
":",
"return",
"len",
"(",
"self",
".",
"_terms",
"[",
"term",
"]"... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.get_document_length | Returns the number of terms found within the specified document. | hashedindex/__init__.py | def get_document_length(self, document):
"""
Returns the number of terms found within the specified document.
"""
if document in self._documents:
return self._documents[document]
else:
raise IndexError(DOCUMENT_DOES_NOT_EXIST) | def get_document_length(self, document):
"""
Returns the number of terms found within the specified document.
"""
if document in self._documents:
return self._documents[document]
else:
raise IndexError(DOCUMENT_DOES_NOT_EXIST) | [
"Returns",
"the",
"number",
"of",
"terms",
"found",
"within",
"the",
"specified",
"document",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L123-L130 | [
"def",
"get_document_length",
"(",
"self",
",",
"document",
")",
":",
"if",
"document",
"in",
"self",
".",
"_documents",
":",
"return",
"self",
".",
"_documents",
"[",
"document",
"]",
"else",
":",
"raise",
"IndexError",
"(",
"DOCUMENT_DOES_NOT_EXIST",
")"
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.get_documents | Returns all documents related to the specified term in the
form of a Counter object. | hashedindex/__init__.py | def get_documents(self, term):
"""
Returns all documents related to the specified term in the
form of a Counter object.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return self._terms[term] | def get_documents(self, term):
"""
Returns all documents related to the specified term in the
form of a Counter object.
"""
if term not in self._terms:
raise IndexError(TERM_DOES_NOT_EXIST)
else:
return self._terms[term] | [
"Returns",
"all",
"documents",
"related",
"to",
"the",
"specified",
"term",
"in",
"the",
"form",
"of",
"a",
"Counter",
"object",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L132-L140 | [
"def",
"get_documents",
"(",
"self",
",",
"term",
")",
":",
"if",
"term",
"not",
"in",
"self",
".",
"_terms",
":",
"raise",
"IndexError",
"(",
"TERM_DOES_NOT_EXIST",
")",
"else",
":",
"return",
"self",
".",
"_terms",
"[",
"term",
"]"
] | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.get_tfidf | Returns the Term-Frequency Inverse-Document-Frequency value for the given
term in the specified document. If normalized is True, term frequency will
be divided by the document length. | hashedindex/__init__.py | def get_tfidf(self, term, document, normalized=False):
"""
Returns the Term-Frequency Inverse-Document-Frequency value for the given
term in the specified document. If normalized is True, term frequency will
be divided by the document length.
"""
tf = self.get_term_freque... | def get_tfidf(self, term, document, normalized=False):
"""
Returns the Term-Frequency Inverse-Document-Frequency value for the given
term in the specified document. If normalized is True, term frequency will
be divided by the document length.
"""
tf = self.get_term_freque... | [
"Returns",
"the",
"Term",
"-",
"Frequency",
"Inverse",
"-",
"Document",
"-",
"Frequency",
"value",
"for",
"the",
"given",
"term",
"in",
"the",
"specified",
"document",
".",
"If",
"normalized",
"is",
"True",
"term",
"frequency",
"will",
"be",
"divided",
"by",... | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L151-L171 | [
"def",
"get_tfidf",
"(",
"self",
",",
"term",
",",
"document",
",",
"normalized",
"=",
"False",
")",
":",
"tf",
"=",
"self",
".",
"get_term_frequency",
"(",
"term",
",",
"document",
")",
"# Speeds up performance by avoiding extra calculations",
"if",
"tf",
"!=",... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.generate_document_vector | Returns a representation of the specified document as a feature vector
weighted according the mode specified (by default tf-dif).
A custom weighting function can also be passed which receives the hashedindex
instance, the selected term and document as parameters.
The result will be ret... | hashedindex/__init__.py | def generate_document_vector(self, doc, mode='tfidf'):
"""
Returns a representation of the specified document as a feature vector
weighted according the mode specified (by default tf-dif).
A custom weighting function can also be passed which receives the hashedindex
instance, th... | def generate_document_vector(self, doc, mode='tfidf'):
"""
Returns a representation of the specified document as a feature vector
weighted according the mode specified (by default tf-dif).
A custom weighting function can also be passed which receives the hashedindex
instance, th... | [
"Returns",
"a",
"representation",
"of",
"the",
"specified",
"document",
"as",
"a",
"feature",
"vector",
"weighted",
"according",
"the",
"mode",
"specified",
"(",
"by",
"default",
"tf",
"-",
"dif",
")",
"."
] | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L179-L212 | [
"def",
"generate_document_vector",
"(",
"self",
",",
"doc",
",",
"mode",
"=",
"'tfidf'",
")",
":",
"if",
"mode",
"==",
"'tfidf'",
":",
"selected_function",
"=",
"HashedIndex",
".",
"get_tfidf",
"elif",
"mode",
"==",
"'ntfidf'",
":",
"selected_function",
"=",
... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | HashedIndex.generate_feature_matrix | Returns a feature matrix in the form of a list of lists which
represents the terms and documents in this Inverted Index using
the tf-idf weighting by default. The term counts in each
document can alternatively be used by specifying scheme='count'.
A custom weighting function can also be... | hashedindex/__init__.py | def generate_feature_matrix(self, mode='tfidf'):
"""
Returns a feature matrix in the form of a list of lists which
represents the terms and documents in this Inverted Index using
the tf-idf weighting by default. The term counts in each
document can alternatively be used by specif... | def generate_feature_matrix(self, mode='tfidf'):
"""
Returns a feature matrix in the form of a list of lists which
represents the terms and documents in this Inverted Index using
the tf-idf weighting by default. The term counts in each
document can alternatively be used by specif... | [
"Returns",
"a",
"feature",
"matrix",
"in",
"the",
"form",
"of",
"a",
"list",
"of",
"lists",
"which",
"represents",
"the",
"terms",
"and",
"documents",
"in",
"this",
"Inverted",
"Index",
"using",
"the",
"tf",
"-",
"idf",
"weighting",
"by",
"default",
".",
... | MichaelAquilina/hashedindex | python | https://github.com/MichaelAquilina/hashedindex/blob/5a84dcd6c697ea04162cf7b2683fa2723845b51c/hashedindex/__init__.py#L214-L236 | [
"def",
"generate_feature_matrix",
"(",
"self",
",",
"mode",
"=",
"'tfidf'",
")",
":",
"result",
"=",
"[",
"]",
"for",
"doc",
"in",
"self",
".",
"_documents",
":",
"result",
".",
"append",
"(",
"self",
".",
"generate_document_vector",
"(",
"doc",
",",
"mo... | 5a84dcd6c697ea04162cf7b2683fa2723845b51c |
train | find_class_in_list | Returns the first occurrence of an instance of type `klass` in
the given list, or None if no such instance is present. | payflowpro/client.py | def find_class_in_list(klass, lst):
"""
Returns the first occurrence of an instance of type `klass` in
the given list, or None if no such instance is present.
"""
filtered = list(filter(lambda x: x.__class__ == klass, lst))
if filtered:
return filtered[0]
return None | def find_class_in_list(klass, lst):
"""
Returns the first occurrence of an instance of type `klass` in
the given list, or None if no such instance is present.
"""
filtered = list(filter(lambda x: x.__class__ == klass, lst))
if filtered:
return filtered[0]
return None | [
"Returns",
"the",
"first",
"occurrence",
"of",
"an",
"instance",
"of",
"type",
"klass",
"in",
"the",
"given",
"list",
"or",
"None",
"if",
"no",
"such",
"instance",
"is",
"present",
"."
] | bkeating/python-payflowpro | python | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L400-L408 | [
"def",
"find_class_in_list",
"(",
"klass",
",",
"lst",
")",
":",
"filtered",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"__class__",
"==",
"klass",
",",
"lst",
")",
")",
"if",
"filtered",
":",
"return",
"filtered",
"[",
"0",
"]",
... | e74fc85135f171caa28277196fdcf7c7481ff298 |
train | find_classes_in_list | Returns a tuple containing an entry corresponding to each of
the requested class types, where the entry is either the first
object instance of that type or None of no such instances are
available.
Example Usage:
find_classes_in_list(
[Address, Response],
[<classes.Response.... | payflowpro/client.py | def find_classes_in_list(klasses, lst):
"""
Returns a tuple containing an entry corresponding to each of
the requested class types, where the entry is either the first
object instance of that type or None of no such instances are
available.
Example Usage:
find_classes_in_list(
... | def find_classes_in_list(klasses, lst):
"""
Returns a tuple containing an entry corresponding to each of
the requested class types, where the entry is either the first
object instance of that type or None of no such instances are
available.
Example Usage:
find_classes_in_list(
... | [
"Returns",
"a",
"tuple",
"containing",
"an",
"entry",
"corresponding",
"to",
"each",
"of",
"the",
"requested",
"class",
"types",
"where",
"the",
"entry",
"is",
"either",
"the",
"first",
"object",
"instance",
"of",
"that",
"type",
"or",
"None",
"of",
"no",
... | bkeating/python-payflowpro | python | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L410-L427 | [
"def",
"find_classes_in_list",
"(",
"klasses",
",",
"lst",
")",
":",
"if",
"not",
"isinstance",
"(",
"klasses",
",",
"list",
")",
":",
"klasses",
"=",
"[",
"klasses",
"]",
"return",
"tuple",
"(",
"map",
"(",
"lambda",
"klass",
":",
"find_class_in_list",
... | e74fc85135f171caa28277196fdcf7c7481ff298 |
train | PayflowProClient._build_parmlist | Converts a dictionary of name and value pairs into a
PARMLIST string value acceptable to the Payflow Pro API. | payflowpro/client.py | def _build_parmlist(self, parameters):
"""
Converts a dictionary of name and value pairs into a
PARMLIST string value acceptable to the Payflow Pro API.
"""
args = []
for key, value in parameters.items():
if not value is None:
# We always us... | def _build_parmlist(self, parameters):
"""
Converts a dictionary of name and value pairs into a
PARMLIST string value acceptable to the Payflow Pro API.
"""
args = []
for key, value in parameters.items():
if not value is None:
# We always us... | [
"Converts",
"a",
"dictionary",
"of",
"name",
"and",
"value",
"pairs",
"into",
"a",
"PARMLIST",
"string",
"value",
"acceptable",
"to",
"the",
"Payflow",
"Pro",
"API",
"."
] | bkeating/python-payflowpro | python | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L106-L131 | [
"def",
"_build_parmlist",
"(",
"self",
",",
"parameters",
")",
":",
"args",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"parameters",
".",
"items",
"(",
")",
":",
"if",
"not",
"value",
"is",
"None",
":",
"# We always use the explicit-length keyname form... | e74fc85135f171caa28277196fdcf7c7481ff298 |
train | PayflowProClient._parse_parmlist | Parses a PARMLIST string into a dictionary of name and value
pairs. The parsing is complicated by the following:
- parameter keynames may or may not include a length
specification
- delimiter characters (=, &) may appear inside parameter
values, provided the pa... | payflowpro/client.py | def _parse_parmlist(self, parmlist):
"""
Parses a PARMLIST string into a dictionary of name and value
pairs. The parsing is complicated by the following:
- parameter keynames may or may not include a length
specification
- delimiter characters (=, &) may a... | def _parse_parmlist(self, parmlist):
"""
Parses a PARMLIST string into a dictionary of name and value
pairs. The parsing is complicated by the following:
- parameter keynames may or may not include a length
specification
- delimiter characters (=, &) may a... | [
"Parses",
"a",
"PARMLIST",
"string",
"into",
"a",
"dictionary",
"of",
"name",
"and",
"value",
"pairs",
".",
"The",
"parsing",
"is",
"complicated",
"by",
"the",
"following",
":",
"-",
"parameter",
"keynames",
"may",
"or",
"may",
"not",
"include",
"a",
"leng... | bkeating/python-payflowpro | python | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/client.py#L133-L174 | [
"def",
"_parse_parmlist",
"(",
"self",
",",
"parmlist",
")",
":",
"parmlist",
"=",
"\"&\"",
"+",
"parmlist",
"name_re",
"=",
"re",
".",
"compile",
"(",
"r'\\&([A-Z0-9_]+)(\\[\\d+\\])?='",
")",
"results",
"=",
"{",
"}",
"offset",
"=",
"0",
"match",
"=",
"na... | e74fc85135f171caa28277196fdcf7c7481ff298 |
train | NominatimRequest.request | Send a http request to the given *url*, try to decode
the reply assuming it's JSON in UTF-8, and return the result
:returns: Decoded result, or None in case of an error
:rtype: mixed | nominatim/nominatim.py | def request(self, url):
"""
Send a http request to the given *url*, try to decode
the reply assuming it's JSON in UTF-8, and return the result
:returns: Decoded result, or None in case of an error
:rtype: mixed
"""
self.logger.debug('url:\n' + url)
try:
... | def request(self, url):
"""
Send a http request to the given *url*, try to decode
the reply assuming it's JSON in UTF-8, and return the result
:returns: Decoded result, or None in case of an error
:rtype: mixed
"""
self.logger.debug('url:\n' + url)
try:
... | [
"Send",
"a",
"http",
"request",
"to",
"the",
"given",
"*",
"url",
"*",
"try",
"to",
"decode",
"the",
"reply",
"assuming",
"it",
"s",
"JSON",
"in",
"UTF",
"-",
"8",
"and",
"return",
"the",
"result"
] | damianbraun/nominatim | python | https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L58-L73 | [
"def",
"request",
"(",
"self",
",",
"url",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'url:\\n'",
"+",
"url",
")",
"try",
":",
"response",
"=",
"urlopen",
"(",
"url",
")",
"return",
"json",
".",
"loads",
"(",
"response",
".",
"read",
"(",... | d3cc40e1d31755aabf7302a617ab6e982eeb9b4f |
train | Nominatim.query | Issue a geocoding query for *address* to the
Nominatim instance and return the decoded results
:param address: a query string with an address
or presumed parts of an address
:type address: str or (if python2) unicode
:param acceptlanguage: rfc2616 language code
... | nominatim/nominatim.py | def query(self, address, acceptlanguage=None, limit=20,
countrycodes=None):
"""
Issue a geocoding query for *address* to the
Nominatim instance and return the decoded results
:param address: a query string with an address
or presumed parts of an add... | def query(self, address, acceptlanguage=None, limit=20,
countrycodes=None):
"""
Issue a geocoding query for *address* to the
Nominatim instance and return the decoded results
:param address: a query string with an address
or presumed parts of an add... | [
"Issue",
"a",
"geocoding",
"query",
"for",
"*",
"address",
"*",
"to",
"the",
"Nominatim",
"instance",
"and",
"return",
"the",
"decoded",
"results"
] | damianbraun/nominatim | python | https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L92-L119 | [
"def",
"query",
"(",
"self",
",",
"address",
",",
"acceptlanguage",
"=",
"None",
",",
"limit",
"=",
"20",
",",
"countrycodes",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"url",
"+",
"'&q='",
"+",
"quote_plus",
"(",
"address",
")",
"if",
"acceptl... | d3cc40e1d31755aabf7302a617ab6e982eeb9b4f |
train | NominatimReverse.query | Issue a reverse geocoding query for a place given
by *lat* and *lon*, or by *osm_id* and *osm_type*
to the Nominatim instance and return the decoded results
:param lat: the geograpical latitude of the place
:param lon: the geograpical longitude of the place
:param osm_id: openst... | nominatim/nominatim.py | def query(self, lat=None, lon=None, osm_id=None, osm_type=None,
acceptlanguage='', zoom=18):
"""
Issue a reverse geocoding query for a place given
by *lat* and *lon*, or by *osm_id* and *osm_type*
to the Nominatim instance and return the decoded results
:param lat:... | def query(self, lat=None, lon=None, osm_id=None, osm_type=None,
acceptlanguage='', zoom=18):
"""
Issue a reverse geocoding query for a place given
by *lat* and *lon*, or by *osm_id* and *osm_type*
to the Nominatim instance and return the decoded results
:param lat:... | [
"Issue",
"a",
"reverse",
"geocoding",
"query",
"for",
"a",
"place",
"given",
"by",
"*",
"lat",
"*",
"and",
"*",
"lon",
"*",
"or",
"by",
"*",
"osm_id",
"*",
"and",
"*",
"osm_type",
"*",
"to",
"the",
"Nominatim",
"instance",
"and",
"return",
"the",
"de... | damianbraun/nominatim | python | https://github.com/damianbraun/nominatim/blob/d3cc40e1d31755aabf7302a617ab6e982eeb9b4f/nominatim/nominatim.py#L139-L180 | [
"def",
"query",
"(",
"self",
",",
"lat",
"=",
"None",
",",
"lon",
"=",
"None",
",",
"osm_id",
"=",
"None",
",",
"osm_type",
"=",
"None",
",",
"acceptlanguage",
"=",
"''",
",",
"zoom",
"=",
"18",
")",
":",
"url",
"=",
"self",
".",
"url",
"if",
"... | d3cc40e1d31755aabf7302a617ab6e982eeb9b4f |
train | CTMGrid.from_model | Define a grid using the specifications of a given model.
Parameters
----------
model_name : string
Name the model (see :func:`get_supported_models` for available
model names).
Supports multiple formats (e.g., 'GEOS5', 'GEOS-5' or 'GEOS_5').
**kwargs :... | xbpch/grid.py | def from_model(cls, model_name, **kwargs):
"""
Define a grid using the specifications of a given model.
Parameters
----------
model_name : string
Name the model (see :func:`get_supported_models` for available
model names).
Supports multiple fo... | def from_model(cls, model_name, **kwargs):
"""
Define a grid using the specifications of a given model.
Parameters
----------
model_name : string
Name the model (see :func:`get_supported_models` for available
model names).
Supports multiple fo... | [
"Define",
"a",
"grid",
"using",
"the",
"specifications",
"of",
"a",
"given",
"model",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L143-L180 | [
"def",
"from_model",
"(",
"cls",
",",
"model_name",
",",
"*",
"*",
"kwargs",
")",
":",
"settings",
"=",
"_get_model_info",
"(",
"model_name",
")",
"model",
"=",
"settings",
".",
"pop",
"(",
"'model_name'",
")",
"for",
"k",
",",
"v",
"in",
"list",
"(",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | CTMGrid.copy_from_model | Set-up a user-defined grid using specifications of a reference
grid model.
Parameters
----------
model_name : string
name of the user-defined grid model.
reference : string or :class:`CTMGrid` instance
Name of the reference model (see :func:`get_supported... | xbpch/grid.py | def copy_from_model(cls, model_name, reference, **kwargs):
"""
Set-up a user-defined grid using specifications of a reference
grid model.
Parameters
----------
model_name : string
name of the user-defined grid model.
reference : string or :class:`CTMG... | def copy_from_model(cls, model_name, reference, **kwargs):
"""
Set-up a user-defined grid using specifications of a reference
grid model.
Parameters
----------
model_name : string
name of the user-defined grid model.
reference : string or :class:`CTMG... | [
"Set",
"-",
"up",
"a",
"user",
"-",
"defined",
"grid",
"using",
"specifications",
"of",
"a",
"reference",
"grid",
"model",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L183-L214 | [
"def",
"copy_from_model",
"(",
"cls",
",",
"model_name",
",",
"reference",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"reference",
",",
"cls",
")",
":",
"settings",
"=",
"reference",
".",
"__dict__",
".",
"copy",
"(",
")",
"settings",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | CTMGrid.get_layers | Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a given model coordinate system.
Returns
-------
dicti... | xbpch/grid.py | def get_layers(self, Psurf=1013.25, Ptop=0.01, **kwargs):
"""
Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a... | def get_layers(self, Psurf=1013.25, Ptop=0.01, **kwargs):
"""
Compute scalars or coordinates associated to the vertical layers.
Parameters
----------
grid_spec : CTMGrid object
CTMGrid containing the information necessary to re-construct grid
levels for a... | [
"Compute",
"scalars",
"or",
"coordinates",
"associated",
"to",
"the",
"vertical",
"layers",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L217-L324 | [
"def",
"get_layers",
"(",
"self",
",",
"Psurf",
"=",
"1013.25",
",",
"Ptop",
"=",
"0.01",
",",
"*",
"*",
"kwargs",
")",
":",
"Psurf",
"=",
"np",
".",
"asarray",
"(",
"Psurf",
")",
"output_ndims",
"=",
"Psurf",
".",
"ndim",
"+",
"1",
"if",
"output_n... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | CTMGrid.get_lonlat | Calculate longitude-latitude grid for a specified resolution and
configuration / ordering.
Parameters
----------
rlon, rlat : float
Resolution (in degrees) of longitude and latitude grids.
halfpolar : bool (default=True)
Polar grid boxes span half of rlat... | xbpch/grid.py | def get_lonlat(self):
"""
Calculate longitude-latitude grid for a specified resolution and
configuration / ordering.
Parameters
----------
rlon, rlat : float
Resolution (in degrees) of longitude and latitude grids.
halfpolar : bool (default=True)
... | def get_lonlat(self):
"""
Calculate longitude-latitude grid for a specified resolution and
configuration / ordering.
Parameters
----------
rlon, rlat : float
Resolution (in degrees) of longitude and latitude grids.
halfpolar : bool (default=True)
... | [
"Calculate",
"longitude",
"-",
"latitude",
"grid",
"for",
"a",
"specified",
"resolution",
"and",
"configuration",
"/",
"ordering",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/grid.py#L327-L371 | [
"def",
"get_lonlat",
"(",
"self",
")",
":",
"rlon",
",",
"rlat",
"=",
"self",
".",
"resolution",
"# Compute number of grid cells in each direction",
"Nlon",
"=",
"int",
"(",
"360.",
"/",
"rlon",
")",
"Nlat",
"=",
"int",
"(",
"180.",
"/",
"rlat",
")",
"+",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | _get_template_dirs | existing directories where to search for jinja2 templates. The order
is important. The first found template from the first found dir wins! | py2pack/__init__.py | def _get_template_dirs():
"""existing directories where to search for jinja2 templates. The order
is important. The first found template from the first found dir wins!"""
return filter(lambda x: os.path.exists(x), [
# user dir
os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'),
... | def _get_template_dirs():
"""existing directories where to search for jinja2 templates. The order
is important. The first found template from the first found dir wins!"""
return filter(lambda x: os.path.exists(x), [
# user dir
os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'),
... | [
"existing",
"directories",
"where",
"to",
"search",
"for",
"jinja2",
"templates",
".",
"The",
"order",
"is",
"important",
".",
"The",
"first",
"found",
"template",
"from",
"the",
"first",
"found",
"dir",
"wins!"
] | openSUSE/py2pack | python | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L53-L63 | [
"def",
"_get_template_dirs",
"(",
")",
":",
"return",
"filter",
"(",
"lambda",
"x",
":",
"os",
".",
"path",
".",
"exists",
"(",
"x",
")",
",",
"[",
"# user dir",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",... | 4ff689900dd2c1a390b5359ce1037c188b75fc65 |
train | _license_from_classifiers | try to get a license from the classifiers | py2pack/__init__.py | def _license_from_classifiers(data):
"""try to get a license from the classifiers"""
classifiers = data.get('classifiers', [])
found_license = None
for c in classifiers:
if c.startswith("License :: OSI Approved :: "):
found_license = c.replace("License :: OSI Approved :: ", "")
r... | def _license_from_classifiers(data):
"""try to get a license from the classifiers"""
classifiers = data.get('classifiers', [])
found_license = None
for c in classifiers:
if c.startswith("License :: OSI Approved :: "):
found_license = c.replace("License :: OSI Approved :: ", "")
r... | [
"try",
"to",
"get",
"a",
"license",
"from",
"the",
"classifiers"
] | openSUSE/py2pack | python | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L177-L184 | [
"def",
"_license_from_classifiers",
"(",
"data",
")",
":",
"classifiers",
"=",
"data",
".",
"get",
"(",
"'classifiers'",
",",
"[",
"]",
")",
"found_license",
"=",
"None",
"for",
"c",
"in",
"classifiers",
":",
"if",
"c",
".",
"startswith",
"(",
"\"License :... | 4ff689900dd2c1a390b5359ce1037c188b75fc65 |
train | _normalize_license | try to get SDPX license | py2pack/__init__.py | def _normalize_license(data):
"""try to get SDPX license"""
license = data.get('license', None)
if not license:
# try to get license from classifiers
license = _license_from_classifiers(data)
if license:
if license in SDPX_LICENSES.keys():
data['license'] = SDPX_LICEN... | def _normalize_license(data):
"""try to get SDPX license"""
license = data.get('license', None)
if not license:
# try to get license from classifiers
license = _license_from_classifiers(data)
if license:
if license in SDPX_LICENSES.keys():
data['license'] = SDPX_LICEN... | [
"try",
"to",
"get",
"SDPX",
"license"
] | openSUSE/py2pack | python | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/__init__.py#L187-L199 | [
"def",
"_normalize_license",
"(",
"data",
")",
":",
"license",
"=",
"data",
".",
"get",
"(",
"'license'",
",",
"None",
")",
"if",
"not",
"license",
":",
"# try to get license from classifiers",
"license",
"=",
"_license_from_classifiers",
"(",
"data",
")",
"if",... | 4ff689900dd2c1a390b5359ce1037c188b75fc65 |
train | wrap_prompts_class | Wrap an IPython's Prompt class
This is needed in order for Prompt to inject the correct escape sequences
at the right positions for shell integrations. | iterm2_tools/ipython.py | def wrap_prompts_class(Klass):
"""
Wrap an IPython's Prompt class
This is needed in order for Prompt to inject the correct escape sequences
at the right positions for shell integrations.
"""
try:
from prompt_toolkit.token import ZeroWidthEscape
except ImportError:
return K... | def wrap_prompts_class(Klass):
"""
Wrap an IPython's Prompt class
This is needed in order for Prompt to inject the correct escape sequences
at the right positions for shell integrations.
"""
try:
from prompt_toolkit.token import ZeroWidthEscape
except ImportError:
return K... | [
"Wrap",
"an",
"IPython",
"s",
"Prompt",
"class"
] | asmeurer/iterm2-tools | python | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/ipython.py#L113-L137 | [
"def",
"wrap_prompts_class",
"(",
"Klass",
")",
":",
"try",
":",
"from",
"prompt_toolkit",
".",
"token",
"import",
"ZeroWidthEscape",
"except",
"ImportError",
":",
"return",
"Klass",
"class",
"ITerm2IPythonPrompt",
"(",
"Klass",
")",
":",
"def",
"in_prompt_tokens"... | 97b1b593bb02884521c2c05ed414f178de0b934e |
train | BTreeDB5.get_all_keys | A generator which yields a list of all valid keys starting at the
given `start` offset. If `start` is `None`, we will start from
the root of the tree. | starbound/btreedb5.py | def get_all_keys(self, start=None):
"""
A generator which yields a list of all valid keys starting at the
given `start` offset. If `start` is `None`, we will start from
the root of the tree.
"""
s = self.stream
if not start:
start = HEADER_SIZE + self... | def get_all_keys(self, start=None):
"""
A generator which yields a list of all valid keys starting at the
given `start` offset. If `start` is `None`, we will start from
the root of the tree.
"""
s = self.stream
if not start:
start = HEADER_SIZE + self... | [
"A",
"generator",
"which",
"yields",
"a",
"list",
"of",
"all",
"valid",
"keys",
"starting",
"at",
"the",
"given",
"start",
"offset",
".",
"If",
"start",
"is",
"None",
"we",
"will",
"start",
"from",
"the",
"root",
"of",
"the",
"tree",
"."
] | blixt/py-starbound | python | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/btreedb5.py#L69-L107 | [
"def",
"get_all_keys",
"(",
"self",
",",
"start",
"=",
"None",
")",
":",
"s",
"=",
"self",
".",
"stream",
"if",
"not",
"start",
":",
"start",
"=",
"HEADER_SIZE",
"+",
"self",
".",
"block_size",
"*",
"self",
".",
"root_block",
"s",
".",
"seek",
"(",
... | 68a2f6bfef73d8803191f937c69005a64eeae017 |
train | _replace_star | Replace the `*` placeholder in a format string (fmt), so that
struct.calcsize(fmt) is equal to the given `size` using the format
following the placeholder.
Raises `ValueError` if number of `*` is larger than 1. If no `*`
in `fmt`, returns `fmt` without checking its size!
Examples
--------
... | xbpch/uff.py | def _replace_star(fmt, size):
"""
Replace the `*` placeholder in a format string (fmt), so that
struct.calcsize(fmt) is equal to the given `size` using the format
following the placeholder.
Raises `ValueError` if number of `*` is larger than 1. If no `*`
in `fmt`, returns `fmt` without checking... | def _replace_star(fmt, size):
"""
Replace the `*` placeholder in a format string (fmt), so that
struct.calcsize(fmt) is equal to the given `size` using the format
following the placeholder.
Raises `ValueError` if number of `*` is larger than 1. If no `*`
in `fmt`, returns `fmt` without checking... | [
"Replace",
"the",
"*",
"placeholder",
"in",
"a",
"format",
"string",
"(",
"fmt",
")",
"so",
"that",
"struct",
".",
"calcsize",
"(",
"fmt",
")",
"is",
"equal",
"to",
"the",
"given",
"size",
"using",
"the",
"format",
"following",
"the",
"placeholder",
"."
... | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L160-L186 | [
"def",
"_replace_star",
"(",
"fmt",
",",
"size",
")",
":",
"n_stars",
"=",
"fmt",
".",
"count",
"(",
"'*'",
")",
"if",
"n_stars",
">",
"1",
":",
"raise",
"ValueError",
"(",
"\"More than one `*` in format (%s).\"",
"%",
"fmt",
")",
"if",
"n_stars",
":",
"... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | FortranFile._fix | Read pre- or suffix of line at current position with given
format `fmt` (default 'i'). | xbpch/uff.py | def _fix(self, fmt='i'):
"""
Read pre- or suffix of line at current position with given
format `fmt` (default 'i').
"""
fmt = self.endian + fmt
fix = self.read(struct.calcsize(fmt))
if fix:
return struct.unpack(fmt, fix)[0]
else:
ra... | def _fix(self, fmt='i'):
"""
Read pre- or suffix of line at current position with given
format `fmt` (default 'i').
"""
fmt = self.endian + fmt
fix = self.read(struct.calcsize(fmt))
if fix:
return struct.unpack(fmt, fix)[0]
else:
ra... | [
"Read",
"pre",
"-",
"or",
"suffix",
"of",
"line",
"at",
"current",
"position",
"with",
"given",
"format",
"fmt",
"(",
"default",
"i",
")",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L67-L77 | [
"def",
"_fix",
"(",
"self",
",",
"fmt",
"=",
"'i'",
")",
":",
"fmt",
"=",
"self",
".",
"endian",
"+",
"fmt",
"fix",
"=",
"self",
".",
"read",
"(",
"struct",
".",
"calcsize",
"(",
"fmt",
")",
")",
"if",
"fix",
":",
"return",
"struct",
".",
"unpa... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | FortranFile.readline | Return next unformatted "line". If format is given, unpack content,
otherwise return byte string. | xbpch/uff.py | def readline(self, fmt=None):
"""
Return next unformatted "line". If format is given, unpack content,
otherwise return byte string.
"""
prefix_size = self._fix()
if fmt is None:
content = self.read(prefix_size)
else:
fmt = self.endian + fm... | def readline(self, fmt=None):
"""
Return next unformatted "line". If format is given, unpack content,
otherwise return byte string.
"""
prefix_size = self._fix()
if fmt is None:
content = self.read(prefix_size)
else:
fmt = self.endian + fm... | [
"Return",
"next",
"unformatted",
"line",
".",
"If",
"format",
"is",
"given",
"unpack",
"content",
"otherwise",
"return",
"byte",
"string",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L79-L102 | [
"def",
"readline",
"(",
"self",
",",
"fmt",
"=",
"None",
")",
":",
"prefix_size",
"=",
"self",
".",
"_fix",
"(",
")",
"if",
"fmt",
"is",
"None",
":",
"content",
"=",
"self",
".",
"read",
"(",
"prefix_size",
")",
"else",
":",
"fmt",
"=",
"self",
"... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | FortranFile.skipline | Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match. | xbpch/uff.py | def skipline(self):
"""
Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match.
"""
position = self.tell()
prefix = self._fix()
self.seek(prefix, 1) # skip content
suffix = self._fix()
if ... | def skipline(self):
"""
Skip the next line and returns position and size of line.
Raises IOError if pre- and suffix of line do not match.
"""
position = self.tell()
prefix = self._fix()
self.seek(prefix, 1) # skip content
suffix = self._fix()
if ... | [
"Skip",
"the",
"next",
"line",
"and",
"returns",
"position",
"and",
"size",
"of",
"line",
".",
"Raises",
"IOError",
"if",
"pre",
"-",
"and",
"suffix",
"of",
"line",
"do",
"not",
"match",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L110-L123 | [
"def",
"skipline",
"(",
"self",
")",
":",
"position",
"=",
"self",
".",
"tell",
"(",
")",
"prefix",
"=",
"self",
".",
"_fix",
"(",
")",
"self",
".",
"seek",
"(",
"prefix",
",",
"1",
")",
"# skip content",
"suffix",
"=",
"self",
".",
"_fix",
"(",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | FortranFile.writeline | Write `line` (list of objects) with given `fmt` to file. The
`line` will be chained if object is iterable (except for
basestrings). | xbpch/uff.py | def writeline(self, fmt, *args):
"""
Write `line` (list of objects) with given `fmt` to file. The
`line` will be chained if object is iterable (except for
basestrings).
"""
fmt = self.endian + fmt
size = struct.calcsize(fmt)
fix = struct.pack(self.endian ... | def writeline(self, fmt, *args):
"""
Write `line` (list of objects) with given `fmt` to file. The
`line` will be chained if object is iterable (except for
basestrings).
"""
fmt = self.endian + fmt
size = struct.calcsize(fmt)
fix = struct.pack(self.endian ... | [
"Write",
"line",
"(",
"list",
"of",
"objects",
")",
"with",
"given",
"fmt",
"to",
"file",
".",
"The",
"line",
"will",
"be",
"chained",
"if",
"object",
"is",
"iterable",
"(",
"except",
"for",
"basestrings",
")",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L125-L139 | [
"def",
"writeline",
"(",
"self",
",",
"fmt",
",",
"*",
"args",
")",
":",
"fmt",
"=",
"self",
".",
"endian",
"+",
"fmt",
"size",
"=",
"struct",
".",
"calcsize",
"(",
"fmt",
")",
"fix",
"=",
"struct",
".",
"pack",
"(",
"self",
".",
"endian",
"+",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | FortranFile.writelines | Write `lines` with given `format`. | xbpch/uff.py | def writelines(self, lines, fmt):
"""
Write `lines` with given `format`.
"""
if isinstance(fmt, basestring):
fmt = [fmt] * len(lines)
for f, line in zip(fmt, lines):
self.writeline(f, line, self.endian) | def writelines(self, lines, fmt):
"""
Write `lines` with given `format`.
"""
if isinstance(fmt, basestring):
fmt = [fmt] * len(lines)
for f, line in zip(fmt, lines):
self.writeline(f, line, self.endian) | [
"Write",
"lines",
"with",
"given",
"format",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L141-L148 | [
"def",
"writelines",
"(",
"self",
",",
"lines",
",",
"fmt",
")",
":",
"if",
"isinstance",
"(",
"fmt",
",",
"basestring",
")",
":",
"fmt",
"=",
"[",
"fmt",
"]",
"*",
"len",
"(",
"lines",
")",
"for",
"f",
",",
"line",
"in",
"zip",
"(",
"fmt",
","... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | read_varint | Read while the most significant bit is set, then put the 7 least
significant bits of all read bytes together to create a number. | starbound/sbon.py | def read_varint(stream):
"""Read while the most significant bit is set, then put the 7 least
significant bits of all read bytes together to create a number.
"""
value = 0
while True:
byte = ord(stream.read(1))
if not byte & 0b10000000:
return value << 7 | byte
va... | def read_varint(stream):
"""Read while the most significant bit is set, then put the 7 least
significant bits of all read bytes together to create a number.
"""
value = 0
while True:
byte = ord(stream.read(1))
if not byte & 0b10000000:
return value << 7 | byte
va... | [
"Read",
"while",
"the",
"most",
"significant",
"bit",
"is",
"set",
"then",
"put",
"the",
"7",
"least",
"significant",
"bits",
"of",
"all",
"read",
"bytes",
"together",
"to",
"create",
"a",
"number",
"."
] | blixt/py-starbound | python | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/sbon.py#L70-L80 | [
"def",
"read_varint",
"(",
"stream",
")",
":",
"value",
"=",
"0",
"while",
"True",
":",
"byte",
"=",
"ord",
"(",
"stream",
".",
"read",
"(",
"1",
")",
")",
"if",
"not",
"byte",
"&",
"0b10000000",
":",
"return",
"value",
"<<",
"7",
"|",
"byte",
"v... | 68a2f6bfef73d8803191f937c69005a64eeae017 |
train | open_bpchdataset | Open a GEOS-Chem BPCH file output as an xarray Dataset.
Parameters
----------
filename : string
Path to the output file to read in.
{tracerinfo,diaginfo}_file : string, optional
Path to the metadata "info" .dat files which are used to decipher
the metadata corresponding to each ... | xbpch/core.py | def open_bpchdataset(filename, fields=[], categories=[],
tracerinfo_file='tracerinfo.dat',
diaginfo_file='diaginfo.dat',
endian=">", decode_cf=True,
memmap=True, dask=True, return_store=False):
""" Open a GEOS-Chem BPCH file output ... | def open_bpchdataset(filename, fields=[], categories=[],
tracerinfo_file='tracerinfo.dat',
diaginfo_file='diaginfo.dat',
endian=">", decode_cf=True,
memmap=True, dask=True, return_store=False):
""" Open a GEOS-Chem BPCH file output ... | [
"Open",
"a",
"GEOS",
"-",
"Chem",
"BPCH",
"file",
"output",
"as",
"an",
"xarray",
"Dataset",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/core.py#L26-L126 | [
"def",
"open_bpchdataset",
"(",
"filename",
",",
"fields",
"=",
"[",
"]",
",",
"categories",
"=",
"[",
"]",
",",
"tracerinfo_file",
"=",
"'tracerinfo.dat'",
",",
"diaginfo_file",
"=",
"'diaginfo.dat'",
",",
"endian",
"=",
"\">\"",
",",
"decode_cf",
"=",
"Tru... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | open_mfbpchdataset | Open multiple bpch files as a single dataset.
You must have dask installed for this to work, as this greatly
simplifies issues relating to multi-file I/O.
Also, please note that this is not a very performant routine. I/O is still
limited by the fact that we need to manually scan/read through each bpch... | xbpch/core.py | def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts',
preprocess=None, lock=None, **kwargs):
""" Open multiple bpch files as a single dataset.
You must have dask installed for this to work, as this greatly
simplifies issues relating to multi-file I/O.
Also, ple... | def open_mfbpchdataset(paths, concat_dim='time', compat='no_conflicts',
preprocess=None, lock=None, **kwargs):
""" Open multiple bpch files as a single dataset.
You must have dask installed for this to work, as this greatly
simplifies issues relating to multi-file I/O.
Also, ple... | [
"Open",
"multiple",
"bpch",
"files",
"as",
"a",
"single",
"dataset",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/core.py#L129-L215 | [
"def",
"open_mfbpchdataset",
"(",
"paths",
",",
"concat_dim",
"=",
"'time'",
",",
"compat",
"=",
"'no_conflicts'",
",",
"preprocess",
"=",
"None",
",",
"lock",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"xarray",
".",
"backends",
".",
"api",... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | Migration.forwards | Write your forwards methods here. | multilingual_news/south_migrations/0006_migrate_placeholder_fields.py | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry in orm['multilingual_news.NewsEntry'].objects.all():
self.migrate_placeholder(
orm, entry, 'excerpt', 'multilin... | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry in orm['multilingual_news.NewsEntry'].objects.all():
self.migrate_placeholder(
orm, entry, 'excerpt', 'multilin... | [
"Write",
"your",
"forwards",
"methods",
"here",
"."
] | bitlabstudio/django-multilingual-news | python | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/south_migrations/0006_migrate_placeholder_fields.py#L35-L42 | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"",
"for",
"entry",
"in",
"orm",
"[",
"'multilingual_news.NewsEntry'",
"]",
".",
"objects",
".",
"all",
"(",
")",
":",
"self",
... | 2ddc076ce2002a9fa462dbba701441879b49a54d |
train | image_bytes | Return a bytes string that displays image given by bytes b in the terminal
If filename=None, the filename defaults to "Unnamed file"
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width or height.
'auto... | iterm2_tools/images.py | def image_bytes(b, filename=None, inline=1, width='auto', height='auto',
preserve_aspect_ratio=None):
"""
Return a bytes string that displays image given by bytes b in the terminal
If filename=None, the filename defaults to "Unnamed file"
width and height are strings, following the format
... | def image_bytes(b, filename=None, inline=1, width='auto', height='auto',
preserve_aspect_ratio=None):
"""
Return a bytes string that displays image given by bytes b in the terminal
If filename=None, the filename defaults to "Unnamed file"
width and height are strings, following the format
... | [
"Return",
"a",
"bytes",
"string",
"that",
"displays",
"image",
"given",
"by",
"bytes",
"b",
"in",
"the",
"terminal"
] | asmeurer/iterm2-tools | python | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L15-L54 | [
"def",
"image_bytes",
"(",
"b",
",",
"filename",
"=",
"None",
",",
"inline",
"=",
"1",
",",
"width",
"=",
"'auto'",
",",
"height",
"=",
"'auto'",
",",
"preserve_aspect_ratio",
"=",
"None",
")",
":",
"if",
"preserve_aspect_ratio",
"is",
"None",
":",
"if",... | 97b1b593bb02884521c2c05ed414f178de0b934e |
train | display_image_bytes | Display the image given by the bytes b in the terminal.
If filename=None the filename defaults to "Unnamed file".
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width or height.
'auto': The image's inhe... | iterm2_tools/images.py | def display_image_bytes(b, filename=None, inline=1, width='auto',
height='auto', preserve_aspect_ratio=None):
"""
Display the image given by the bytes b in the terminal.
If filename=None the filename defaults to "Unnamed file".
width and height are strings, following the format
N: N chara... | def display_image_bytes(b, filename=None, inline=1, width='auto',
height='auto', preserve_aspect_ratio=None):
"""
Display the image given by the bytes b in the terminal.
If filename=None the filename defaults to "Unnamed file".
width and height are strings, following the format
N: N chara... | [
"Display",
"the",
"image",
"given",
"by",
"the",
"bytes",
"b",
"in",
"the",
"terminal",
"."
] | asmeurer/iterm2-tools | python | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L56-L83 | [
"def",
"display_image_bytes",
"(",
"b",
",",
"filename",
"=",
"None",
",",
"inline",
"=",
"1",
",",
"width",
"=",
"'auto'",
",",
"height",
"=",
"'auto'",
",",
"preserve_aspect_ratio",
"=",
"None",
")",
":",
"sys",
".",
"stdout",
".",
"buffer",
".",
"wr... | 97b1b593bb02884521c2c05ed414f178de0b934e |
train | display_image_file | Display an image in the terminal.
A newline is not printed.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width or height.
'auto': The image's inherent size will be used to determine an appropriate
... | iterm2_tools/images.py | def display_image_file(fn, width='auto', height='auto', preserve_aspect_ratio=None):
"""
Display an image in the terminal.
A newline is not printed.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width o... | def display_image_file(fn, width='auto', height='auto', preserve_aspect_ratio=None):
"""
Display an image in the terminal.
A newline is not printed.
width and height are strings, following the format
N: N character cells.
Npx: N pixels.
N%: N percent of the session's width o... | [
"Display",
"an",
"image",
"in",
"the",
"terminal",
"."
] | asmeurer/iterm2-tools | python | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/images.py#L85-L112 | [
"def",
"display_image_file",
"(",
"fn",
",",
"width",
"=",
"'auto'",
",",
"height",
"=",
"'auto'",
",",
"preserve_aspect_ratio",
"=",
"None",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"expanduser",
... | 97b1b593bb02884521c2c05ed414f178de0b934e |
train | get_requirements | Get requirements from pip requirement files. | setup.py | def get_requirements(*args):
"""Get requirements from pip requirement files."""
requirements = set()
contents = get_contents(*args)
for line in contents.splitlines():
# Strip comments.
line = re.sub(r'^#.*|\s#.*', '', line)
# Ignore empty lines
if line and not line.isspac... | def get_requirements(*args):
"""Get requirements from pip requirement files."""
requirements = set()
contents = get_contents(*args)
for line in contents.splitlines():
# Strip comments.
line = re.sub(r'^#.*|\s#.*', '', line)
# Ignore empty lines
if line and not line.isspac... | [
"Get",
"requirements",
"from",
"pip",
"requirement",
"files",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/setup.py#L44-L54 | [
"def",
"get_requirements",
"(",
"*",
"args",
")",
":",
"requirements",
"=",
"set",
"(",
")",
"contents",
"=",
"get_contents",
"(",
"*",
"args",
")",
"for",
"line",
"in",
"contents",
".",
"splitlines",
"(",
")",
":",
"# Strip comments.",
"line",
"=",
"re"... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | BankHolidays.get_holidays | Gets a list of all known bank holidays, optionally filtered by division and/or year
:param division: see division constants; defaults to common holidays
:param year: defaults to all available years
:return: list of dicts with titles, dates, etc | govuk_bank_holidays/bank_holidays.py | def get_holidays(self, division=None, year=None):
"""
Gets a list of all known bank holidays, optionally filtered by division and/or year
:param division: see division constants; defaults to common holidays
:param year: defaults to all available years
:return: list of dicts with ... | def get_holidays(self, division=None, year=None):
"""
Gets a list of all known bank holidays, optionally filtered by division and/or year
:param division: see division constants; defaults to common holidays
:param year: defaults to all available years
:return: list of dicts with ... | [
"Gets",
"a",
"list",
"of",
"all",
"known",
"bank",
"holidays",
"optionally",
"filtered",
"by",
"division",
"and",
"/",
"or",
"year",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"param",
"... | ministryofjustice/govuk-bank-holidays | python | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L87-L106 | [
"def",
"get_holidays",
"(",
"self",
",",
"division",
"=",
"None",
",",
"year",
"=",
"None",
")",
":",
"if",
"division",
":",
"holidays",
"=",
"self",
".",
"data",
"[",
"division",
"]",
"else",
":",
"holidays",
"=",
"self",
".",
"data",
"[",
"self",
... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 |
train | BankHolidays.get_next_holiday | Returns the next known bank holiday
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: dict | govuk_bank_holidays/bank_holidays.py | def get_next_holiday(self, division=None, date=None):
"""
Returns the next known bank holiday
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: dict
"""
date = date or datet... | def get_next_holiday(self, division=None, date=None):
"""
Returns the next known bank holiday
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: dict
"""
date = date or datet... | [
"Returns",
"the",
"next",
"known",
"bank",
"holiday",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"param",
"date",
":",
"search",
"starting",
"from",
"this",
"date",
";",
"defaults",
"to",
... | ministryofjustice/govuk-bank-holidays | python | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L108-L118 | [
"def",
"get_next_holiday",
"(",
"self",
",",
"division",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"date",
"=",
"date",
"or",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"for",
"holiday",
"in",
"self",
".",
"get_holidays",
"(",
"division",
... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 |
train | BankHolidays.is_holiday | True if the date is a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool | govuk_bank_holidays/bank_holidays.py | def is_holiday(self, date, division=None):
"""
True if the date is a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date in (holiday['date'] for holiday in self.get_ho... | def is_holiday(self, date, division=None):
"""
True if the date is a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date in (holiday['date'] for holiday in self.get_ho... | [
"True",
"if",
"the",
"date",
"is",
"a",
"known",
"bank",
"holiday",
":",
"param",
"date",
":",
"the",
"date",
"to",
"check",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"return",
":",
... | ministryofjustice/govuk-bank-holidays | python | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L120-L127 | [
"def",
"is_holiday",
"(",
"self",
",",
"date",
",",
"division",
"=",
"None",
")",
":",
"return",
"date",
"in",
"(",
"holiday",
"[",
"'date'",
"]",
"for",
"holiday",
"in",
"self",
".",
"get_holidays",
"(",
"division",
"=",
"division",
")",
")"
] | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 |
train | BankHolidays.get_next_work_day | Returns the next work day, skipping weekends and bank holidays
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: datetime.date; NB: get_next_holiday returns a dict | govuk_bank_holidays/bank_holidays.py | def get_next_work_day(self, division=None, date=None):
"""
Returns the next work day, skipping weekends and bank holidays
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: datetime.date; NB... | def get_next_work_day(self, division=None, date=None):
"""
Returns the next work day, skipping weekends and bank holidays
:param division: see division constants; defaults to common holidays
:param date: search starting from this date; defaults to today
:return: datetime.date; NB... | [
"Returns",
"the",
"next",
"work",
"day",
"skipping",
"weekends",
"and",
"bank",
"holidays",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"holidays",
":",
"param",
"date",
":",
"search",
"starting",
"from",
"... | ministryofjustice/govuk-bank-holidays | python | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L129-L142 | [
"def",
"get_next_work_day",
"(",
"self",
",",
"division",
"=",
"None",
",",
"date",
"=",
"None",
")",
":",
"date",
"=",
"date",
"or",
"datetime",
".",
"date",
".",
"today",
"(",
")",
"one_day",
"=",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1"... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 |
train | BankHolidays.is_work_day | True if the date is not a weekend or a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool | govuk_bank_holidays/bank_holidays.py | def is_work_day(self, date, division=None):
"""
True if the date is not a weekend or a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date.weekday() not in self.weeken... | def is_work_day(self, date, division=None):
"""
True if the date is not a weekend or a known bank holiday
:param date: the date to check
:param division: see division constants; defaults to common holidays
:return: bool
"""
return date.weekday() not in self.weeken... | [
"True",
"if",
"the",
"date",
"is",
"not",
"a",
"weekend",
"or",
"a",
"known",
"bank",
"holiday",
":",
"param",
"date",
":",
"the",
"date",
"to",
"check",
":",
"param",
"division",
":",
"see",
"division",
"constants",
";",
"defaults",
"to",
"common",
"h... | ministryofjustice/govuk-bank-holidays | python | https://github.com/ministryofjustice/govuk-bank-holidays/blob/76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67/govuk_bank_holidays/bank_holidays.py#L144-L153 | [
"def",
"is_work_day",
"(",
"self",
",",
"date",
",",
"division",
"=",
"None",
")",
":",
"return",
"date",
".",
"weekday",
"(",
")",
"not",
"in",
"self",
".",
"weekend",
"and",
"date",
"not",
"in",
"(",
"holiday",
"[",
"'date'",
"]",
"for",
"holiday",... | 76c2f0e29890cee71f0ab99fe1a89cc92c7c4a67 |
train | World.get_all_regions_with_tiles | Generator which yields a set of (rx, ry) tuples which describe
all regions for which the world has tile data | starbound/__init__.py | def get_all_regions_with_tiles(self):
"""
Generator which yields a set of (rx, ry) tuples which describe
all regions for which the world has tile data
"""
for key in self.get_all_keys():
(layer, rx, ry) = struct.unpack('>BHH', key)
if layer == 1:
... | def get_all_regions_with_tiles(self):
"""
Generator which yields a set of (rx, ry) tuples which describe
all regions for which the world has tile data
"""
for key in self.get_all_keys():
(layer, rx, ry) = struct.unpack('>BHH', key)
if layer == 1:
... | [
"Generator",
"which",
"yields",
"a",
"set",
"of",
"(",
"rx",
"ry",
")",
"tuples",
"which",
"describe",
"all",
"regions",
"for",
"which",
"the",
"world",
"has",
"tile",
"data"
] | blixt/py-starbound | python | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L95-L103 | [
"def",
"get_all_regions_with_tiles",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
".",
"get_all_keys",
"(",
")",
":",
"(",
"layer",
",",
"rx",
",",
"ry",
")",
"=",
"struct",
".",
"unpack",
"(",
"'>BHH'",
",",
"key",
")",
"if",
"layer",
"==",
... | 68a2f6bfef73d8803191f937c69005a64eeae017 |
train | World.get_entity_uuid_coords | Returns the coordinates of the given entity UUID inside this world, or
`None` if the UUID is not found. | starbound/__init__.py | def get_entity_uuid_coords(self, uuid):
"""
Returns the coordinates of the given entity UUID inside this world, or
`None` if the UUID is not found.
"""
if uuid in self._entity_to_region_map:
coords = self._entity_to_region_map[uuid]
entities = self.get_ent... | def get_entity_uuid_coords(self, uuid):
"""
Returns the coordinates of the given entity UUID inside this world, or
`None` if the UUID is not found.
"""
if uuid in self._entity_to_region_map:
coords = self._entity_to_region_map[uuid]
entities = self.get_ent... | [
"Returns",
"the",
"coordinates",
"of",
"the",
"given",
"entity",
"UUID",
"inside",
"this",
"world",
"or",
"None",
"if",
"the",
"UUID",
"is",
"not",
"found",
"."
] | blixt/py-starbound | python | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L110-L121 | [
"def",
"get_entity_uuid_coords",
"(",
"self",
",",
"uuid",
")",
":",
"if",
"uuid",
"in",
"self",
".",
"_entity_to_region_map",
":",
"coords",
"=",
"self",
".",
"_entity_to_region_map",
"[",
"uuid",
"]",
"entities",
"=",
"self",
".",
"get_entities",
"(",
"*",... | 68a2f6bfef73d8803191f937c69005a64eeae017 |
train | World._entity_to_region_map | A dict whose keys are the UUIDs (or just IDs, in some cases) of
entities, and whose values are the `(rx, ry)` coordinates in which that
entity can be found. This can be used to easily locate particular
entities inside the world. | starbound/__init__.py | def _entity_to_region_map(self):
"""
A dict whose keys are the UUIDs (or just IDs, in some cases) of
entities, and whose values are the `(rx, ry)` coordinates in which that
entity can be found. This can be used to easily locate particular
entities inside the world.
"""
... | def _entity_to_region_map(self):
"""
A dict whose keys are the UUIDs (or just IDs, in some cases) of
entities, and whose values are the `(rx, ry)` coordinates in which that
entity can be found. This can be used to easily locate particular
entities inside the world.
"""
... | [
"A",
"dict",
"whose",
"keys",
"are",
"the",
"UUIDs",
"(",
"or",
"just",
"IDs",
"in",
"some",
"cases",
")",
"of",
"entities",
"and",
"whose",
"values",
"are",
"the",
"(",
"rx",
"ry",
")",
"coordinates",
"in",
"which",
"that",
"entity",
"can",
"be",
"f... | blixt/py-starbound | python | https://github.com/blixt/py-starbound/blob/68a2f6bfef73d8803191f937c69005a64eeae017/starbound/__init__.py#L149-L168 | [
"def",
"_entity_to_region_map",
"(",
"self",
")",
":",
"entity_to_region",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"get_all_keys",
"(",
")",
":",
"layer",
",",
"rx",
",",
"ry",
"=",
"struct",
".",
"unpack",
"(",
"'>BHH'",
",",
"key",
")",
"if... | 68a2f6bfef73d8803191f937c69005a64eeae017 |
train | create_fuzzy_pattern | Convert a string into a fuzzy regular expression pattern.
:param pattern: The input pattern (a string).
:returns: A compiled regular expression object.
This function works by adding ``.*`` between each of the characters in the
input pattern and compiling the resulting expression into a case
insens... | qpass/__init__.py | def create_fuzzy_pattern(pattern):
"""
Convert a string into a fuzzy regular expression pattern.
:param pattern: The input pattern (a string).
:returns: A compiled regular expression object.
This function works by adding ``.*`` between each of the characters in the
input pattern and compiling ... | def create_fuzzy_pattern(pattern):
"""
Convert a string into a fuzzy regular expression pattern.
:param pattern: The input pattern (a string).
:returns: A compiled regular expression object.
This function works by adding ``.*`` between each of the characters in the
input pattern and compiling ... | [
"Convert",
"a",
"string",
"into",
"a",
"fuzzy",
"regular",
"expression",
"pattern",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L431-L442 | [
"def",
"create_fuzzy_pattern",
"(",
"pattern",
")",
":",
"return",
"re",
".",
"compile",
"(",
"\".*\"",
".",
"join",
"(",
"map",
"(",
"re",
".",
"escape",
",",
"pattern",
")",
")",
",",
"re",
".",
"IGNORECASE",
")"
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | AbstractPasswordStore.filtered_entries | A list of :class:`PasswordEntry` objects that don't match the exclude list. | qpass/__init__.py | def filtered_entries(self):
"""A list of :class:`PasswordEntry` objects that don't match the exclude list."""
return [
e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list)
] | def filtered_entries(self):
"""A list of :class:`PasswordEntry` objects that don't match the exclude list."""
return [
e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list)
] | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"that",
"don",
"t",
"match",
"the",
"exclude",
"list",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L104-L108 | [
"def",
"filtered_entries",
"(",
"self",
")",
":",
"return",
"[",
"e",
"for",
"e",
"in",
"self",
".",
"entries",
"if",
"not",
"any",
"(",
"fnmatch",
".",
"fnmatch",
"(",
"e",
".",
"name",
".",
"lower",
"(",
")",
",",
"p",
".",
"lower",
"(",
")",
... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | AbstractPasswordStore.fuzzy_search | Perform a "fuzzy" search that matches the given characters in the given order.
:param filters: The pattern(s) to search for.
:returns: The matched password names (a list of strings). | qpass/__init__.py | def fuzzy_search(self, *filters):
"""
Perform a "fuzzy" search that matches the given characters in the given order.
:param filters: The pattern(s) to search for.
:returns: The matched password names (a list of strings).
"""
matches = []
logger.verbose(
... | def fuzzy_search(self, *filters):
"""
Perform a "fuzzy" search that matches the given characters in the given order.
:param filters: The pattern(s) to search for.
:returns: The matched password names (a list of strings).
"""
matches = []
logger.verbose(
... | [
"Perform",
"a",
"fuzzy",
"search",
"that",
"matches",
"the",
"given",
"characters",
"in",
"the",
"given",
"order",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L110-L130 | [
"def",
"fuzzy_search",
"(",
"self",
",",
"*",
"filters",
")",
":",
"matches",
"=",
"[",
"]",
"logger",
".",
"verbose",
"(",
"\"Performing fuzzy search on %s (%s) ..\"",
",",
"pluralize",
"(",
"len",
"(",
"filters",
")",
",",
"\"pattern\"",
")",
",",
"concate... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | AbstractPasswordStore.select_entry | Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`). | qpass/__init__.py | def select_entry(self, *arguments):
"""
Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`).
"""
ma... | def select_entry(self, *arguments):
"""
Select a password from the available choices.
:param arguments: Refer to :func:`smart_search()`.
:returns: The name of a password (a string) or :data:`None`
(when no password matched the given `arguments`).
"""
ma... | [
"Select",
"a",
"password",
"from",
"the",
"available",
"choices",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L132-L147 | [
"def",
"select_entry",
"(",
"self",
",",
"*",
"arguments",
")",
":",
"matches",
"=",
"self",
".",
"smart_search",
"(",
"*",
"arguments",
")",
"if",
"len",
"(",
"matches",
")",
">",
"1",
":",
"logger",
".",
"info",
"(",
"\"More than one match, prompting for... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | AbstractPasswordStore.simple_search | Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords are
returned. | qpass/__init__.py | def simple_search(self, *keywords):
"""
Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords a... | def simple_search(self, *keywords):
"""
Perform a simple search for case insensitive substring matches.
:param keywords: The string(s) to search for.
:returns: The matched password names (a generator of strings).
Only passwords whose names matches *all* of the given keywords a... | [
"Perform",
"a",
"simple",
"search",
"for",
"case",
"insensitive",
"substring",
"matches",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L149-L175 | [
"def",
"simple_search",
"(",
"self",
",",
"*",
"keywords",
")",
":",
"matches",
"=",
"[",
"]",
"keywords",
"=",
"[",
"kw",
".",
"lower",
"(",
")",
"for",
"kw",
"in",
"keywords",
"]",
"logger",
".",
"verbose",
"(",
"\"Performing simple search on %s (%s) ..\... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | AbstractPasswordStore.smart_search | Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
- :exc:`.NoMatchingPasswordError` when no matching pas... | qpass/__init__.py | def smart_search(self, *arguments):
"""
Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
... | def smart_search(self, *arguments):
"""
Perform a smart search on the given keywords or patterns.
:param arguments: The keywords or patterns to search for.
:returns: The matched password names (a list of strings).
:raises: The following exceptions can be raised:
... | [
"Perform",
"a",
"smart",
"search",
"on",
"the",
"given",
"keywords",
"or",
"patterns",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L177-L204 | [
"def",
"smart_search",
"(",
"self",
",",
"*",
"arguments",
")",
":",
"matches",
"=",
"self",
".",
"simple_search",
"(",
"*",
"arguments",
")",
"if",
"not",
"matches",
":",
"logger",
".",
"verbose",
"(",
"\"Falling back from substring search to fuzzy search ..\"",
... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | QuickPass.entries | A list of :class:`PasswordEntry` objects. | qpass/__init__.py | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
passwords = []
for store in self.stores:
passwords.extend(store.entries)
return natsort(passwords, key=lambda e: e.name) | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
passwords = []
for store in self.stores:
passwords.extend(store.entries)
return natsort(passwords, key=lambda e: e.name) | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L219-L224 | [
"def",
"entries",
"(",
"self",
")",
":",
"passwords",
"=",
"[",
"]",
"for",
"store",
"in",
"self",
".",
"stores",
":",
"passwords",
".",
"extend",
"(",
"store",
".",
"entries",
")",
"return",
"natsort",
"(",
"passwords",
",",
"key",
"=",
"lambda",
"e... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | PasswordStore.context | An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to the
value of :attr:`directory... | qpass/__init__.py | def context(self):
"""
An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to ... | def context(self):
"""
An execution context created using :mod:`executor.contexts`.
The value of :attr:`context` defaults to a
:class:`~executor.contexts.LocalContext` object with the following
characteristics:
- The working directory of the execution context is set to ... | [
"An",
"execution",
"context",
"created",
"using",
":",
"mod",
":",
"executor",
".",
"contexts",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L244-L272 | [
"def",
"context",
"(",
"self",
")",
":",
"# Make sure the directory exists.",
"self",
".",
"ensure_directory_exists",
"(",
")",
"# Prepare the environment variables.",
"environment",
"=",
"{",
"DIRECTORY_VARIABLE",
":",
"self",
".",
"directory",
"}",
"try",
":",
"# Tr... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | PasswordStore.directory | Normalize the value of :attr:`directory` when it's set. | qpass/__init__.py | def directory(self, value):
"""Normalize the value of :attr:`directory` when it's set."""
# Normalize the value of `directory'.
set_property(self, "directory", parse_path(value))
# Clear the computed values of `context' and `entries'.
clear_property(self, "context")
clear... | def directory(self, value):
"""Normalize the value of :attr:`directory` when it's set."""
# Normalize the value of `directory'.
set_property(self, "directory", parse_path(value))
# Clear the computed values of `context' and `entries'.
clear_property(self, "context")
clear... | [
"Normalize",
"the",
"value",
"of",
":",
"attr",
":",
"directory",
"when",
"it",
"s",
"set",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L292-L298 | [
"def",
"directory",
"(",
"self",
",",
"value",
")",
":",
"# Normalize the value of `directory'.",
"set_property",
"(",
"self",
",",
"\"directory\"",
",",
"parse_path",
"(",
"value",
")",
")",
"# Clear the computed values of `context' and `entries'.",
"clear_property",
"("... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | PasswordStore.entries | A list of :class:`PasswordEntry` objects. | qpass/__init__.py | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
timer = Timer()
passwords = []
logger.info("Scanning %s ..", format_path(self.directory))
listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
for filename in split(listing, "\... | def entries(self):
"""A list of :class:`PasswordEntry` objects."""
timer = Timer()
passwords = []
logger.info("Scanning %s ..", format_path(self.directory))
listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
for filename in split(listing, "\... | [
"A",
"list",
"of",
":",
"class",
":",
"PasswordEntry",
"objects",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L301-L314 | [
"def",
"entries",
"(",
"self",
")",
":",
"timer",
"=",
"Timer",
"(",
")",
"passwords",
"=",
"[",
"]",
"logger",
".",
"info",
"(",
"\"Scanning %s ..\"",
",",
"format_path",
"(",
"self",
".",
"directory",
")",
")",
"listing",
"=",
"self",
".",
"context",... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | PasswordStore.ensure_directory_exists | Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist. | qpass/__init__.py | def ensure_directory_exists(self):
"""
Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist.
"""
if not os.path.isdir(self.directory):
msg = "The password storage directory d... | def ensure_directory_exists(self):
"""
Make sure :attr:`directory` exists.
:raises: :exc:`.MissingPasswordStoreError` when the password storage
directory doesn't exist.
"""
if not os.path.isdir(self.directory):
msg = "The password storage directory d... | [
"Make",
"sure",
":",
"attr",
":",
"directory",
"exists",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L316-L325 | [
"def",
"ensure_directory_exists",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"directory",
")",
":",
"msg",
"=",
"\"The password storage directory doesn't exist! (%s)\"",
"raise",
"MissingPasswordStoreError",
"(",
"msg",
... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | PasswordEntry.format_text | Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
password from the formatted text.
:param use_colors: :data:`True` to use ANS... | qpass/__init__.py | def format_text(self, include_password=True, use_colors=None, padding=True, filters=()):
"""
Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
... | def format_text(self, include_password=True, use_colors=None, padding=True, filters=()):
"""
Format :attr:`text` for viewing on a terminal.
:param include_password: :data:`True` to include the password in the
formatted text, :data:`False` to exclude the
... | [
"Format",
":",
"attr",
":",
"text",
"for",
"viewing",
"on",
"a",
"terminal",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/__init__.py#L362-L428 | [
"def",
"format_text",
"(",
"self",
",",
"include_password",
"=",
"True",
",",
"use_colors",
"=",
"None",
",",
"padding",
"=",
"True",
",",
"filters",
"=",
"(",
")",
")",
":",
"# Determine whether we can use ANSI escape sequences.",
"if",
"use_colors",
"is",
"Non... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | get_diaginfo | Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information. | xbpch/util/diaginfo.py | def get_diaginfo(diaginfo_file):
"""
Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information.
... | def get_diaginfo(diaginfo_file):
"""
Read an output's diaginfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
diaginfo_file : str
Path to diaginfo.dat
Returns
-------
DataFrame containing the category information.
... | [
"Read",
"an",
"output",
"s",
"diaginfo",
".",
"dat",
"file",
"and",
"parse",
"into",
"a",
"DataFrame",
"for",
"use",
"in",
"selecting",
"and",
"parsing",
"categories",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/diaginfo.py#L39-L66 | [
"def",
"get_diaginfo",
"(",
"diaginfo_file",
")",
":",
"widths",
"=",
"[",
"rec",
".",
"width",
"for",
"rec",
"in",
"diag_recs",
"]",
"col_names",
"=",
"[",
"rec",
".",
"name",
"for",
"rec",
"in",
"diag_recs",
"]",
"dtypes",
"=",
"[",
"rec",
".",
"ty... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | get_tracerinfo | Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer information. | xbpch/util/diaginfo.py | def get_tracerinfo(tracerinfo_file):
"""
Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer informati... | def get_tracerinfo(tracerinfo_file):
"""
Read an output's tracerinfo.dat file and parse into a DataFrame for
use in selecting and parsing categories.
Parameters
----------
tracerinfo_file : str
Path to tracerinfo.dat
Returns
-------
DataFrame containing the tracer informati... | [
"Read",
"an",
"output",
"s",
"tracerinfo",
".",
"dat",
"file",
"and",
"parse",
"into",
"a",
"DataFrame",
"for",
"use",
"in",
"selecting",
"and",
"parsing",
"categories",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/diaginfo.py#L69-L125 | [
"def",
"get_tracerinfo",
"(",
"tracerinfo_file",
")",
":",
"widths",
"=",
"[",
"rec",
".",
"width",
"for",
"rec",
"in",
"tracer_recs",
"]",
"col_names",
"=",
"[",
"rec",
".",
"name",
"for",
"rec",
"in",
"tracer_recs",
"]",
"dtypes",
"=",
"[",
"rec",
".... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | read_from_bpch | Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired data chunk begins
shape : tuple of ints
Resultant (n-dimensional) shape of requested data; the chun... | xbpch/bpch.py | def read_from_bpch(filename, file_position, shape, dtype, endian,
use_mmap=False):
""" Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired d... | def read_from_bpch(filename, file_position, shape, dtype, endian,
use_mmap=False):
""" Read a chunk of data from a bpch output file.
Parameters
----------
filename : str
Path to file on disk containing the data
file_position : int
Position (bytes) where desired d... | [
"Read",
"a",
"chunk",
"of",
"data",
"from",
"a",
"bpch",
"output",
"file",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L353-L398 | [
"def",
"read_from_bpch",
"(",
"filename",
",",
"file_position",
",",
"shape",
",",
"dtype",
",",
"endian",
",",
"use_mmap",
"=",
"False",
")",
":",
"offset",
"=",
"file_position",
"+",
"4",
"if",
"use_mmap",
":",
"d",
"=",
"np",
".",
"memmap",
"(",
"fi... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | BPCHDataBundle._read | Helper function to load the data referenced by this bundle. | xbpch/bpch.py | def _read(self):
""" Helper function to load the data referenced by this bundle. """
if self._dask:
d = da.from_delayed(
delayed(read_from_bpch, )(
self.filename, self.file_position, self.shape,
self.dtype, self.endian, use_mmap=self._m... | def _read(self):
""" Helper function to load the data referenced by this bundle. """
if self._dask:
d = da.from_delayed(
delayed(read_from_bpch, )(
self.filename, self.file_position, self.shape,
self.dtype, self.endian, use_mmap=self._m... | [
"Helper",
"function",
"to",
"load",
"the",
"data",
"referenced",
"by",
"this",
"bundle",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L68-L84 | [
"def",
"_read",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dask",
":",
"d",
"=",
"da",
".",
"from_delayed",
"(",
"delayed",
"(",
"read_from_bpch",
",",
")",
"(",
"self",
".",
"filename",
",",
"self",
".",
"file_position",
",",
"self",
".",
"shape",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | BPCHFile.close | Close this bpch file. | xbpch/bpch.py | def close(self):
""" Close this bpch file.
"""
if not self.fp.closed:
for v in list(self.var_data):
del self.var_data[v]
self.fp.close() | def close(self):
""" Close this bpch file.
"""
if not self.fp.closed:
for v in list(self.var_data):
del self.var_data[v]
self.fp.close() | [
"Close",
"this",
"bpch",
"file",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L176-L185 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"fp",
".",
"closed",
":",
"for",
"v",
"in",
"list",
"(",
"self",
".",
"var_data",
")",
":",
"del",
"self",
".",
"var_data",
"[",
"v",
"]",
"self",
".",
"fp",
".",
"close",
"(",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | BPCHFile._read_metadata | Read the main metadata packaged within a bpch file, indicating
the output filetype and its title. | xbpch/bpch.py | def _read_metadata(self):
""" Read the main metadata packaged within a bpch file, indicating
the output filetype and its title.
"""
filetype = self.fp.readline().strip()
filetitle = self.fp.readline().strip()
# Decode to UTF string, if possible
try:
... | def _read_metadata(self):
""" Read the main metadata packaged within a bpch file, indicating
the output filetype and its title.
"""
filetype = self.fp.readline().strip()
filetitle = self.fp.readline().strip()
# Decode to UTF string, if possible
try:
... | [
"Read",
"the",
"main",
"metadata",
"packaged",
"within",
"a",
"bpch",
"file",
"indicating",
"the",
"output",
"filetype",
"and",
"its",
"title",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L203-L220 | [
"def",
"_read_metadata",
"(",
"self",
")",
":",
"filetype",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"filetitle",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"# Decode to UTF string, if p... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | BPCHFile._read_header | Process the header information (data model / grid spec) | xbpch/bpch.py | def _read_header(self):
""" Process the header information (data model / grid spec) """
self._header_pos = self.fp.tell()
line = self.fp.readline('20sffii')
modelname, res0, res1, halfpolar, center180 = line
self._attributes.update({
"modelname": str(modelname, 'utf... | def _read_header(self):
""" Process the header information (data model / grid spec) """
self._header_pos = self.fp.tell()
line = self.fp.readline('20sffii')
modelname, res0, res1, halfpolar, center180 = line
self._attributes.update({
"modelname": str(modelname, 'utf... | [
"Process",
"the",
"header",
"information",
"(",
"data",
"model",
"/",
"grid",
"spec",
")"
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L222-L241 | [
"def",
"_read_header",
"(",
"self",
")",
":",
"self",
".",
"_header_pos",
"=",
"self",
".",
"fp",
".",
"tell",
"(",
")",
"line",
"=",
"self",
".",
"fp",
".",
"readline",
"(",
"'20sffii'",
")",
"modelname",
",",
"res0",
",",
"res1",
",",
"halfpolar",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | BPCHFile._read_var_data | Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein. | xbpch/bpch.py | def _read_var_data(self):
""" Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein.
"""
var_bundles = OrderedDict()
var_attrs = OrderedDict()
n_vars = 0
while self.fp.tel... | def _read_var_data(self):
""" Iterate over the block of this bpch file and return handlers
in the form of `BPCHDataBundle`s for access to the data contained
therein.
"""
var_bundles = OrderedDict()
var_attrs = OrderedDict()
n_vars = 0
while self.fp.tel... | [
"Iterate",
"over",
"the",
"block",
"of",
"this",
"bpch",
"file",
"and",
"return",
"handlers",
"in",
"the",
"form",
"of",
"BPCHDataBundle",
"s",
"for",
"access",
"to",
"the",
"data",
"contained",
"therein",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/bpch.py#L244-L350 | [
"def",
"_read_var_data",
"(",
"self",
")",
":",
"var_bundles",
"=",
"OrderedDict",
"(",
")",
"var_attrs",
"=",
"OrderedDict",
"(",
")",
"n_vars",
"=",
"0",
"while",
"self",
".",
"fp",
".",
"tell",
"(",
")",
"<",
"self",
".",
"fsize",
":",
"var_attr",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | broadcast_1d_array | Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid. | xbpch/common.py | def broadcast_1d_array(arr, ndim, axis=1):
"""
Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid.
"""
ext_arr = arr
... | def broadcast_1d_array(arr, ndim, axis=1):
"""
Broadcast 1-d array `arr` to `ndim` dimensions on the first axis
(`axis`=0) or on the last axis (`axis`=1).
Useful for 'outer' calculations involving 1-d arrays that are related to
different axes on a multidimensional grid.
"""
ext_arr = arr
... | [
"Broadcast",
"1",
"-",
"d",
"array",
"arr",
"to",
"ndim",
"dimensions",
"on",
"the",
"first",
"axis",
"(",
"axis",
"=",
"0",
")",
"or",
"on",
"the",
"last",
"axis",
"(",
"axis",
"=",
"1",
")",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L9-L20 | [
"def",
"broadcast_1d_array",
"(",
"arr",
",",
"ndim",
",",
"axis",
"=",
"1",
")",
":",
"ext_arr",
"=",
"arr",
"for",
"i",
"in",
"range",
"(",
"ndim",
"-",
"1",
")",
":",
"ext_arr",
"=",
"np",
".",
"expand_dims",
"(",
"ext_arr",
",",
"axis",
"=",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | get_timestamp | Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the time/date choice and use as
the format string passe... | xbpch/common.py | def get_timestamp(time=True, date=True, fmt=None):
""" Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the ... | def get_timestamp(time=True, date=True, fmt=None):
""" Return the current timestamp in machine local time.
Parameters:
-----------
time, date : Boolean
Flag to include the time or date components, respectively,
in the output.
fmt : str, optional
If passed, will override the ... | [
"Return",
"the",
"current",
"timestamp",
"in",
"machine",
"local",
"time",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L23-L49 | [
"def",
"get_timestamp",
"(",
"time",
"=",
"True",
",",
"date",
"=",
"True",
",",
"fmt",
"=",
"None",
")",
":",
"time_format",
"=",
"\"%H:%M:%S\"",
"date_format",
"=",
"\"%m-%d-%Y\"",
"if",
"fmt",
"is",
"None",
":",
"if",
"time",
"and",
"date",
":",
"fm... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | fix_attr_encoding | This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer instead of a
boolean, and removes ... | xbpch/common.py | def fix_attr_encoding(ds):
""" This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer ins... | def fix_attr_encoding(ds):
""" This is a temporary hot-fix to handle the way metadata is encoded
when we read data directly from bpch files. It removes the 'scale_factor'
and 'units' attributes we encode with the data we ingest, converts the
'hydrocarbon' and 'chemical' attribute to a binary integer ins... | [
"This",
"is",
"a",
"temporary",
"hot",
"-",
"fix",
"to",
"handle",
"the",
"way",
"metadata",
"is",
"encoded",
"when",
"we",
"read",
"data",
"directly",
"from",
"bpch",
"files",
".",
"It",
"removes",
"the",
"scale_factor",
"and",
"units",
"attributes",
"we"... | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/common.py#L52-L92 | [
"def",
"fix_attr_encoding",
"(",
"ds",
")",
":",
"def",
"_maybe_del_attr",
"(",
"da",
",",
"attr",
")",
":",
"\"\"\" Possibly delete an attribute on a DataArray if it's present \"\"\"",
"if",
"attr",
"in",
"da",
".",
"attrs",
":",
"del",
"da",
".",
"attrs",
"[",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | after_output | Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255. | iterm2_tools/shell_integration.py | def after_output(command_status):
"""
Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255.
"""
if command_status not in range(256):
raise ValueError("command_status must be an integer in the range 0-255")
sys.stdout.write(AFTER_OUTPUT.f... | def after_output(command_status):
"""
Shell sequence to be run after the command output.
The ``command_status`` should be in the range 0-255.
"""
if command_status not in range(256):
raise ValueError("command_status must be an integer in the range 0-255")
sys.stdout.write(AFTER_OUTPUT.f... | [
"Shell",
"sequence",
"to",
"be",
"run",
"after",
"the",
"command",
"output",
"."
] | asmeurer/iterm2-tools | python | https://github.com/asmeurer/iterm2-tools/blob/97b1b593bb02884521c2c05ed414f178de0b934e/iterm2_tools/shell_integration.py#L153-L164 | [
"def",
"after_output",
"(",
"command_status",
")",
":",
"if",
"command_status",
"not",
"in",
"range",
"(",
"256",
")",
":",
"raise",
"ValueError",
"(",
"\"command_status must be an integer in the range 0-255\"",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"AFTER... | 97b1b593bb02884521c2c05ed414f178de0b934e |
train | Migration.forwards | Write your forwards methods here. | multilingual_news/south_migrations/0009_migrate_i18n_fields.py | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry_title in orm.NewsEntryTitle.objects.all():
entry = NewsEntry.objects.get(pk=entry_title.entry.pk)
entry.translate(e... | def forwards(self, orm):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for entry_title in orm.NewsEntryTitle.objects.all():
entry = NewsEntry.objects.get(pk=entry_title.entry.pk)
entry.translate(e... | [
"Write",
"your",
"forwards",
"methods",
"here",
"."
] | bitlabstudio/django-multilingual-news | python | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/south_migrations/0009_migrate_i18n_fields.py#L11-L20 | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"# Note: Remember to use orm['appname.ModelName'] rather than \"from appname.models...\"",
"for",
"entry_title",
"in",
"orm",
".",
"NewsEntryTitle",
".",
"objects",
".",
"all",
"(",
")",
":",
"entry",
"=",
"NewsEnt... | 2ddc076ce2002a9fa462dbba701441879b49a54d |
train | get_cfcompliant_units | Get equivalent units that are compatible with the udunits2 library
(thus CF-compliant).
Parameters
----------
units : string
A string representation of the units.
prefix : string
Will be added at the beginning of the returned string
(must be a valid udunits2 expression).
... | xbpch/util/cf.py | def get_cfcompliant_units(units, prefix='', suffix=''):
"""
Get equivalent units that are compatible with the udunits2 library
(thus CF-compliant).
Parameters
----------
units : string
A string representation of the units.
prefix : string
Will be added at the beginning of th... | def get_cfcompliant_units(units, prefix='', suffix=''):
"""
Get equivalent units that are compatible with the udunits2 library
(thus CF-compliant).
Parameters
----------
units : string
A string representation of the units.
prefix : string
Will be added at the beginning of th... | [
"Get",
"equivalent",
"units",
"that",
"are",
"compatible",
"with",
"the",
"udunits2",
"library",
"(",
"thus",
"CF",
"-",
"compliant",
")",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/cf.py#L67-L112 | [
"def",
"get_cfcompliant_units",
"(",
"units",
",",
"prefix",
"=",
"''",
",",
"suffix",
"=",
"''",
")",
":",
"compliant_units",
"=",
"units",
"for",
"gcunits",
",",
"udunits",
"in",
"UNITS_MAP_CTM2CF",
":",
"compliant_units",
"=",
"str",
".",
"replace",
"(",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | get_valid_varname | Replace characters (e.g., ':', '$', '=', '-') of a variable name, which
may cause problems when using with (CF-)netCDF based packages.
Parameters
----------
varname : string
variable name.
Notes
-----
Characters replacement is based on the table stored in
:attr:`VARNAME_MAP_CHA... | xbpch/util/cf.py | def get_valid_varname(varname):
"""
Replace characters (e.g., ':', '$', '=', '-') of a variable name, which
may cause problems when using with (CF-)netCDF based packages.
Parameters
----------
varname : string
variable name.
Notes
-----
Characters replacement is based on th... | def get_valid_varname(varname):
"""
Replace characters (e.g., ':', '$', '=', '-') of a variable name, which
may cause problems when using with (CF-)netCDF based packages.
Parameters
----------
varname : string
variable name.
Notes
-----
Characters replacement is based on th... | [
"Replace",
"characters",
"(",
"e",
".",
"g",
".",
":",
"$",
"=",
"-",
")",
"of",
"a",
"variable",
"name",
"which",
"may",
"cause",
"problems",
"when",
"using",
"with",
"(",
"CF",
"-",
")",
"netCDF",
"based",
"packages",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/cf.py#L123-L143 | [
"def",
"get_valid_varname",
"(",
"varname",
")",
":",
"vname",
"=",
"varname",
"for",
"s",
",",
"r",
"in",
"VARNAME_MAP_CHAR",
":",
"vname",
"=",
"vname",
".",
"replace",
"(",
"s",
",",
"r",
")",
"return",
"vname"
] | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | enforce_cf_variable | Given a Variable constructed from GEOS-Chem output, enforce
CF-compliant metadata and formatting.
Until a bug with lazily-loaded data and masking/scaling is resolved in
xarray, you have the option to manually mask and scale the data here.
Parameters
----------
var : xarray.Variable
A v... | xbpch/util/cf.py | def enforce_cf_variable(var, mask_and_scale=True):
""" Given a Variable constructed from GEOS-Chem output, enforce
CF-compliant metadata and formatting.
Until a bug with lazily-loaded data and masking/scaling is resolved in
xarray, you have the option to manually mask and scale the data here.
Para... | def enforce_cf_variable(var, mask_and_scale=True):
""" Given a Variable constructed from GEOS-Chem output, enforce
CF-compliant metadata and formatting.
Until a bug with lazily-loaded data and masking/scaling is resolved in
xarray, you have the option to manually mask and scale the data here.
Para... | [
"Given",
"a",
"Variable",
"constructed",
"from",
"GEOS",
"-",
"Chem",
"output",
"enforce",
"CF",
"-",
"compliant",
"metadata",
"and",
"formatting",
"."
] | darothen/xbpch | python | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/util/cf.py#L146-L202 | [
"def",
"enforce_cf_variable",
"(",
"var",
",",
"mask_and_scale",
"=",
"True",
")",
":",
"var",
"=",
"as_variable",
"(",
"var",
")",
"data",
"=",
"var",
".",
"_data",
"# avoid loading by accessing _data instead of data",
"dims",
"=",
"var",
".",
"dims",
"attrs",
... | 31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5 |
train | NewsEntryManager.published | Returns all entries, which publication date has been hit or which have
no date and which language matches the current language. | multilingual_news/models.py | def published(self, check_language=True, language=None, kwargs=None,
exclude_kwargs=None):
"""
Returns all entries, which publication date has been hit or which have
no date and which language matches the current language.
"""
if check_language:
qs ... | def published(self, check_language=True, language=None, kwargs=None,
exclude_kwargs=None):
"""
Returns all entries, which publication date has been hit or which have
no date and which language matches the current language.
"""
if check_language:
qs ... | [
"Returns",
"all",
"entries",
"which",
"publication",
"date",
"has",
"been",
"hit",
"or",
"which",
"have",
"no",
"date",
"and",
"which",
"language",
"matches",
"the",
"current",
"language",
"."
] | bitlabstudio/django-multilingual-news | python | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/models.py#L100-L119 | [
"def",
"published",
"(",
"self",
",",
"check_language",
"=",
"True",
",",
"language",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"exclude_kwargs",
"=",
"None",
")",
":",
"if",
"check_language",
":",
"qs",
"=",
"NewsEntry",
".",
"objects",
".",
"langua... | 2ddc076ce2002a9fa462dbba701441879b49a54d |
train | NewsEntryManager.recent | Returns recently published new entries. | multilingual_news/models.py | def recent(self, check_language=True, language=None, limit=3, exclude=None,
kwargs=None, category=None):
"""
Returns recently published new entries.
"""
if category:
if not kwargs:
kwargs = {}
kwargs['categories__in'] = [category]
... | def recent(self, check_language=True, language=None, limit=3, exclude=None,
kwargs=None, category=None):
"""
Returns recently published new entries.
"""
if category:
if not kwargs:
kwargs = {}
kwargs['categories__in'] = [category]
... | [
"Returns",
"recently",
"published",
"new",
"entries",
"."
] | bitlabstudio/django-multilingual-news | python | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/models.py#L121-L135 | [
"def",
"recent",
"(",
"self",
",",
"check_language",
"=",
"True",
",",
"language",
"=",
"None",
",",
"limit",
"=",
"3",
",",
"exclude",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"category",
"=",
"None",
")",
":",
"if",
"category",
":",
"if",
"n... | 2ddc076ce2002a9fa462dbba701441879b49a54d |
train | get_newsentry_meta_description | Returns the meta description for the given entry. | multilingual_news/templatetags/multilingual_news_tags.py | def get_newsentry_meta_description(newsentry):
"""Returns the meta description for the given entry."""
if newsentry.meta_description:
return newsentry.meta_description
# If there is no seo addon found, take the info from the placeholders
text = newsentry.get_description()
if len(text) > 16... | def get_newsentry_meta_description(newsentry):
"""Returns the meta description for the given entry."""
if newsentry.meta_description:
return newsentry.meta_description
# If there is no seo addon found, take the info from the placeholders
text = newsentry.get_description()
if len(text) > 16... | [
"Returns",
"the",
"meta",
"description",
"for",
"the",
"given",
"entry",
"."
] | bitlabstudio/django-multilingual-news | python | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/templatetags/multilingual_news_tags.py#L19-L29 | [
"def",
"get_newsentry_meta_description",
"(",
"newsentry",
")",
":",
"if",
"newsentry",
".",
"meta_description",
":",
"return",
"newsentry",
".",
"meta_description",
"# If there is no seo addon found, take the info from the placeholders",
"text",
"=",
"newsentry",
".",
"get_d... | 2ddc076ce2002a9fa462dbba701441879b49a54d |
train | render_news_placeholder | DEPRECATED: Template tag to render a placeholder from an NewsEntry object
We don't need this any more because we don't have a placeholders M2M field
on the model any more. Just use the default ``render_placeholder`` tag. | multilingual_news/templatetags/multilingual_news_tags.py | def render_news_placeholder(context, obj, name=False, truncate=False): # pragma: nocover # NOQA
"""
DEPRECATED: Template tag to render a placeholder from an NewsEntry object
We don't need this any more because we don't have a placeholders M2M field
on the model any more. Just use the default ``render... | def render_news_placeholder(context, obj, name=False, truncate=False): # pragma: nocover # NOQA
"""
DEPRECATED: Template tag to render a placeholder from an NewsEntry object
We don't need this any more because we don't have a placeholders M2M field
on the model any more. Just use the default ``render... | [
"DEPRECATED",
":",
"Template",
"tag",
"to",
"render",
"a",
"placeholder",
"from",
"an",
"NewsEntry",
"object"
] | bitlabstudio/django-multilingual-news | python | https://github.com/bitlabstudio/django-multilingual-news/blob/2ddc076ce2002a9fa462dbba701441879b49a54d/multilingual_news/templatetags/multilingual_news_tags.py#L55-L93 | [
"def",
"render_news_placeholder",
"(",
"context",
",",
"obj",
",",
"name",
"=",
"False",
",",
"truncate",
"=",
"False",
")",
":",
"# pragma: nocover # NOQA",
"warnings",
".",
"warn",
"(",
"\"render_news_placeholder is deprecated. Use render_placeholder\"",
"\" instead\""... | 2ddc076ce2002a9fa462dbba701441879b49a54d |
train | _requirement_filter_by_marker | Check if the requirement is satisfied by the marker.
This function checks for a given Requirement whether its environment marker
is satisfied on the current platform. Currently only the python version and
system platform are checked. | py2pack/requires.py | def _requirement_filter_by_marker(req):
# type: (pkg_resources.Requirement) -> bool
"""Check if the requirement is satisfied by the marker.
This function checks for a given Requirement whether its environment marker
is satisfied on the current platform. Currently only the python version and
system ... | def _requirement_filter_by_marker(req):
# type: (pkg_resources.Requirement) -> bool
"""Check if the requirement is satisfied by the marker.
This function checks for a given Requirement whether its environment marker
is satisfied on the current platform. Currently only the python version and
system ... | [
"Check",
"if",
"the",
"requirement",
"is",
"satisfied",
"by",
"the",
"marker",
"."
] | openSUSE/py2pack | python | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/requires.py#L37-L52 | [
"def",
"_requirement_filter_by_marker",
"(",
"req",
")",
":",
"# type: (pkg_resources.Requirement) -> bool",
"if",
"hasattr",
"(",
"req",
",",
"'marker'",
")",
"and",
"req",
".",
"marker",
":",
"marker_env",
"=",
"{",
"'python_version'",
":",
"'.'",
".",
"join",
... | 4ff689900dd2c1a390b5359ce1037c188b75fc65 |
train | _requirement_find_lowest_possible | Find lowest required version.
Given a single Requirement, this function calculates the lowest required
version to satisfy it. If the requirement excludes a specific version, then
this version will not be used as the minimal supported version.
Examples
--------
>>> req = pkg_resources.Requirem... | py2pack/requires.py | def _requirement_find_lowest_possible(req):
# type: (pkg_resources.Requirement) -> List[str]
"""Find lowest required version.
Given a single Requirement, this function calculates the lowest required
version to satisfy it. If the requirement excludes a specific version, then
this version will not be... | def _requirement_find_lowest_possible(req):
# type: (pkg_resources.Requirement) -> List[str]
"""Find lowest required version.
Given a single Requirement, this function calculates the lowest required
version to satisfy it. If the requirement excludes a specific version, then
this version will not be... | [
"Find",
"lowest",
"required",
"version",
"."
] | openSUSE/py2pack | python | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/requires.py#L55-L93 | [
"def",
"_requirement_find_lowest_possible",
"(",
"req",
")",
":",
"# type: (pkg_resources.Requirement) -> List[str]",
"version_dep",
"=",
"None",
"# type: Optional[str]",
"version_comp",
"=",
"None",
"# type: Optional[str]",
"for",
"dep",
"in",
"req",
".",
"specs",
":",
"... | 4ff689900dd2c1a390b5359ce1037c188b75fc65 |
train | _requirements_sanitize | Cleanup a list of requirement strings (e.g. from requirements.txt) to only
contain entries valid for this platform and with the lowest required version
only.
Example
-------
>>> from sys import version_info
>>> _requirements_sanitize([
... 'foo>=3.0',
... "monotonic>=1.0,>0.1;p... | py2pack/requires.py | def _requirements_sanitize(req_list):
# type: (List[str]) -> List[str]
"""
Cleanup a list of requirement strings (e.g. from requirements.txt) to only
contain entries valid for this platform and with the lowest required version
only.
Example
-------
>>> from sys import version_info
... | def _requirements_sanitize(req_list):
# type: (List[str]) -> List[str]
"""
Cleanup a list of requirement strings (e.g. from requirements.txt) to only
contain entries valid for this platform and with the lowest required version
only.
Example
-------
>>> from sys import version_info
... | [
"Cleanup",
"a",
"list",
"of",
"requirement",
"strings",
"(",
"e",
".",
"g",
".",
"from",
"requirements",
".",
"txt",
")",
"to",
"only",
"contain",
"entries",
"valid",
"for",
"this",
"platform",
"and",
"with",
"the",
"lowest",
"required",
"version",
"only",... | openSUSE/py2pack | python | https://github.com/openSUSE/py2pack/blob/4ff689900dd2c1a390b5359ce1037c188b75fc65/py2pack/requires.py#L96-L119 | [
"def",
"_requirements_sanitize",
"(",
"req_list",
")",
":",
"# type: (List[str]) -> List[str]",
"filtered_req_list",
"=",
"(",
"_requirement_find_lowest_possible",
"(",
"req",
")",
"for",
"req",
"in",
"(",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"(",
"s",
... | 4ff689900dd2c1a390b5359ce1037c188b75fc65 |
train | _ensure_coroutine_function | Return a coroutine function.
func: either a coroutine function or a regular function
Note a coroutine function is not a coroutine! | atomicpuppy/atomicpuppy.py | def _ensure_coroutine_function(func):
"""Return a coroutine function.
func: either a coroutine function or a regular function
Note a coroutine function is not a coroutine!
"""
if asyncio.iscoroutinefunction(func):
return func
else:
@asyncio.coroutine
def coroutine_funct... | def _ensure_coroutine_function(func):
"""Return a coroutine function.
func: either a coroutine function or a regular function
Note a coroutine function is not a coroutine!
"""
if asyncio.iscoroutinefunction(func):
return func
else:
@asyncio.coroutine
def coroutine_funct... | [
"Return",
"a",
"coroutine",
"function",
"."
] | madedotcom/atomicpuppy | python | https://github.com/madedotcom/atomicpuppy/blob/3c262c26e74bcfc25199984b425a5dccac0911ac/atomicpuppy/atomicpuppy.py#L481-L495 | [
"def",
"_ensure_coroutine_function",
"(",
"func",
")",
":",
"if",
"asyncio",
".",
"iscoroutinefunction",
"(",
"func",
")",
":",
"return",
"func",
"else",
":",
"@",
"asyncio",
".",
"coroutine",
"def",
"coroutine_function",
"(",
"evt",
")",
":",
"func",
"(",
... | 3c262c26e74bcfc25199984b425a5dccac0911ac |
train | Event.location | Return a string uniquely identifying the event.
This string can be used to find the event in the event store UI (cf. id
attribute, which is the UUID that at time of writing doesn't let you
easily find the event). | atomicpuppy/atomicpuppy.py | def location(self):
"""Return a string uniquely identifying the event.
This string can be used to find the event in the event store UI (cf. id
attribute, which is the UUID that at time of writing doesn't let you
easily find the event).
"""
if self._location is None:
... | def location(self):
"""Return a string uniquely identifying the event.
This string can be used to find the event in the event store UI (cf. id
attribute, which is the UUID that at time of writing doesn't let you
easily find the event).
"""
if self._location is None:
... | [
"Return",
"a",
"string",
"uniquely",
"identifying",
"the",
"event",
"."
] | madedotcom/atomicpuppy | python | https://github.com/madedotcom/atomicpuppy/blob/3c262c26e74bcfc25199984b425a5dccac0911ac/atomicpuppy/atomicpuppy.py#L74-L87 | [
"def",
"location",
"(",
"self",
")",
":",
"if",
"self",
".",
"_location",
"is",
"None",
":",
"self",
".",
"_location",
"=",
"\"{}/{}-{}\"",
".",
"format",
"(",
"self",
".",
"stream",
",",
"self",
".",
"type",
",",
"self",
".",
"sequence",
",",
")",
... | 3c262c26e74bcfc25199984b425a5dccac0911ac |
train | EventFinder.find_backwards | Return first event matching predicate, or None if none exists.
Note: 'backwards', both here and in Event Store, means 'towards the
event emitted furthest in the past'. | atomicpuppy/atomicpuppy.py | async def find_backwards(self, stream_name, predicate, predicate_label='predicate'):
"""Return first event matching predicate, or None if none exists.
Note: 'backwards', both here and in Event Store, means 'towards the
event emitted furthest in the past'.
"""
logger = self._logg... | async def find_backwards(self, stream_name, predicate, predicate_label='predicate'):
"""Return first event matching predicate, or None if none exists.
Note: 'backwards', both here and in Event Store, means 'towards the
event emitted furthest in the past'.
"""
logger = self._logg... | [
"Return",
"first",
"event",
"matching",
"predicate",
"or",
"None",
"if",
"none",
"exists",
"."
] | madedotcom/atomicpuppy | python | https://github.com/madedotcom/atomicpuppy/blob/3c262c26e74bcfc25199984b425a5dccac0911ac/atomicpuppy/atomicpuppy.py#L349-L372 | [
"async",
"def",
"find_backwards",
"(",
"self",
",",
"stream_name",
",",
"predicate",
",",
"predicate_label",
"=",
"'predicate'",
")",
":",
"logger",
"=",
"self",
".",
"_logger",
".",
"getChild",
"(",
"predicate_label",
")",
"logger",
".",
"info",
"(",
"'Fetc... | 3c262c26e74bcfc25199984b425a5dccac0911ac |
train | main | Command line interface for the ``qpass`` program. | qpass/cli.py | def main():
"""Command line interface for the ``qpass`` program."""
# Initialize logging to the terminal.
coloredlogs.install()
# Prepare for command line argument parsing.
action = show_matching_entry
program_opts = dict(exclude_list=[])
show_opts = dict(filters=[], use_clipboard=is_clipboa... | def main():
"""Command line interface for the ``qpass`` program."""
# Initialize logging to the terminal.
coloredlogs.install()
# Prepare for command line argument parsing.
action = show_matching_entry
program_opts = dict(exclude_list=[])
show_opts = dict(filters=[], use_clipboard=is_clipboa... | [
"Command",
"line",
"interface",
"for",
"the",
"qpass",
"program",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L101-L160 | [
"def",
"main",
"(",
")",
":",
"# Initialize logging to the terminal.",
"coloredlogs",
".",
"install",
"(",
")",
"# Prepare for command line argument parsing.",
"action",
"=",
"show_matching_entry",
"program_opts",
"=",
"dict",
"(",
"exclude_list",
"=",
"[",
"]",
")",
... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | edit_matching_entry | Edit the matching entry. | qpass/cli.py | def edit_matching_entry(program, arguments):
"""Edit the matching entry."""
entry = program.select_entry(*arguments)
entry.context.execute("pass", "edit", entry.name) | def edit_matching_entry(program, arguments):
"""Edit the matching entry."""
entry = program.select_entry(*arguments)
entry.context.execute("pass", "edit", entry.name) | [
"Edit",
"the",
"matching",
"entry",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L163-L166 | [
"def",
"edit_matching_entry",
"(",
"program",
",",
"arguments",
")",
":",
"entry",
"=",
"program",
".",
"select_entry",
"(",
"*",
"arguments",
")",
"entry",
".",
"context",
".",
"execute",
"(",
"\"pass\"",
",",
"\"edit\"",
",",
"entry",
".",
"name",
")"
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | list_matching_entries | List the entries matching the given keywords/patterns. | qpass/cli.py | def list_matching_entries(program, arguments):
"""List the entries matching the given keywords/patterns."""
output("\n".join(entry.name for entry in program.smart_search(*arguments))) | def list_matching_entries(program, arguments):
"""List the entries matching the given keywords/patterns."""
output("\n".join(entry.name for entry in program.smart_search(*arguments))) | [
"List",
"the",
"entries",
"matching",
"the",
"given",
"keywords",
"/",
"patterns",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L169-L171 | [
"def",
"list_matching_entries",
"(",
"program",
",",
"arguments",
")",
":",
"output",
"(",
"\"\\n\"",
".",
"join",
"(",
"entry",
".",
"name",
"for",
"entry",
"in",
"program",
".",
"smart_search",
"(",
"*",
"arguments",
")",
")",
")"
] | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | show_matching_entry | Show the matching entry on the terminal (and copy the password to the clipboard). | qpass/cli.py | def show_matching_entry(program, arguments, use_clipboard=True, quiet=False, filters=()):
"""Show the matching entry on the terminal (and copy the password to the clipboard)."""
entry = program.select_entry(*arguments)
if not quiet:
formatted_entry = entry.format_text(include_password=not use_clipbo... | def show_matching_entry(program, arguments, use_clipboard=True, quiet=False, filters=()):
"""Show the matching entry on the terminal (and copy the password to the clipboard)."""
entry = program.select_entry(*arguments)
if not quiet:
formatted_entry = entry.format_text(include_password=not use_clipbo... | [
"Show",
"the",
"matching",
"entry",
"on",
"the",
"terminal",
"(",
"and",
"copy",
"the",
"password",
"to",
"the",
"clipboard",
")",
"."
] | xolox/python-qpass | python | https://github.com/xolox/python-qpass/blob/43ce447b0904ff42a54b8f1dd4d2479f950f258f/qpass/cli.py#L174-L182 | [
"def",
"show_matching_entry",
"(",
"program",
",",
"arguments",
",",
"use_clipboard",
"=",
"True",
",",
"quiet",
"=",
"False",
",",
"filters",
"=",
"(",
")",
")",
":",
"entry",
"=",
"program",
".",
"select_entry",
"(",
"*",
"arguments",
")",
"if",
"not",... | 43ce447b0904ff42a54b8f1dd4d2479f950f258f |
train | parse_parameters | Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will always be the Response object, and
the RecurringPayments obj... | payflowpro/classes.py | def parse_parameters(payflowpro_response_data):
"""
Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will alwa... | def parse_parameters(payflowpro_response_data):
"""
Parses a set of Payflow Pro response parameter name and value pairs into
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data.
The first item in the object list will alwa... | [
"Parses",
"a",
"set",
"of",
"Payflow",
"Pro",
"response",
"parameter",
"name",
"and",
"value",
"pairs",
"into",
"a",
"list",
"of",
"PayflowProObjects",
"and",
"returns",
"a",
"tuple",
"containing",
"the",
"object",
"list",
"and",
"a",
"dictionary",
"containing... | bkeating/python-payflowpro | python | https://github.com/bkeating/python-payflowpro/blob/e74fc85135f171caa28277196fdcf7c7481ff298/payflowpro/classes.py#L359-L409 | [
"def",
"parse_parameters",
"(",
"payflowpro_response_data",
")",
":",
"def",
"build_class",
"(",
"klass",
",",
"unconsumed_data",
")",
":",
"known_att_names_set",
"=",
"set",
"(",
"klass",
".",
"base_fields",
".",
"keys",
"(",
")",
")",
"available_atts_set",
"="... | e74fc85135f171caa28277196fdcf7c7481ff298 |
train | convert | Convert 'items' stored in 'canvas' to SVG 'document'.
If 'items' is None, then all items are convered.
tounicode is a function that get text and returns
it's unicode representation. It should be used when
national characters are used on canvas.
Return list of XML elements | canvasvg.py | def convert(document, canvas, items=None, tounicode=None):
"""
Convert 'items' stored in 'canvas' to SVG 'document'.
If 'items' is None, then all items are convered.
tounicode is a function that get text and returns
it's unicode representation. It should be used when
national characters are used on canvas.
Ret... | def convert(document, canvas, items=None, tounicode=None):
"""
Convert 'items' stored in 'canvas' to SVG 'document'.
If 'items' is None, then all items are convered.
tounicode is a function that get text and returns
it's unicode representation. It should be used when
national characters are used on canvas.
Ret... | [
"Convert",
"items",
"stored",
"in",
"canvas",
"to",
"SVG",
"document",
".",
"If",
"items",
"is",
"None",
"then",
"all",
"items",
"are",
"convered",
"."
] | WojciechMula/canvas2svg | python | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L73-L315 | [
"def",
"convert",
"(",
"document",
",",
"canvas",
",",
"items",
"=",
"None",
",",
"tounicode",
"=",
"None",
")",
":",
"tk",
"=",
"canvas",
".",
"tk",
"global",
"segment",
"if",
"items",
"is",
"None",
":",
"# default: all items",
"items",
"=",
"canvas",
... | c05d73d88499e5c565386a1765f79d9417a14dac |
train | SVGdocument | Create default SVG document | canvasvg.py | def SVGdocument():
"Create default SVG document"
import xml.dom.minidom
implementation = xml.dom.minidom.getDOMImplementation()
doctype = implementation.createDocumentType(
"svg", "-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
)
document= implementation.createDocument(None, "sv... | def SVGdocument():
"Create default SVG document"
import xml.dom.minidom
implementation = xml.dom.minidom.getDOMImplementation()
doctype = implementation.createDocumentType(
"svg", "-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
)
document= implementation.createDocument(None, "sv... | [
"Create",
"default",
"SVG",
"document"
] | WojciechMula/canvas2svg | python | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L318-L331 | [
"def",
"SVGdocument",
"(",
")",
":",
"import",
"xml",
".",
"dom",
".",
"minidom",
"implementation",
"=",
"xml",
".",
"dom",
".",
"minidom",
".",
"getDOMImplementation",
"(",
")",
"doctype",
"=",
"implementation",
".",
"createDocumentType",
"(",
"\"svg\"",
",... | c05d73d88499e5c565386a1765f79d9417a14dac |
train | segment_to_line | polyline with 2 vertices using <line> tag | canvasvg.py | def segment_to_line(document, coords):
"polyline with 2 vertices using <line> tag"
return setattribs(
document.createElement('line'),
x1 = coords[0],
y1 = coords[1],
x2 = coords[2],
y2 = coords[3],
) | def segment_to_line(document, coords):
"polyline with 2 vertices using <line> tag"
return setattribs(
document.createElement('line'),
x1 = coords[0],
y1 = coords[1],
x2 = coords[2],
y2 = coords[3],
) | [
"polyline",
"with",
"2",
"vertices",
"using",
"<line",
">",
"tag"
] | WojciechMula/canvas2svg | python | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L384-L392 | [
"def",
"segment_to_line",
"(",
"document",
",",
"coords",
")",
":",
"return",
"setattribs",
"(",
"document",
".",
"createElement",
"(",
"'line'",
")",
",",
"x1",
"=",
"coords",
"[",
"0",
"]",
",",
"y1",
"=",
"coords",
"[",
"1",
"]",
",",
"x2",
"=",
... | c05d73d88499e5c565386a1765f79d9417a14dac |
train | polyline | polyline with more then 2 vertices | canvasvg.py | def polyline(document, coords):
"polyline with more then 2 vertices"
points = []
for i in range(0, len(coords), 2):
points.append("%s,%s" % (coords[i], coords[i+1]))
return setattribs(
document.createElement('polyline'),
points = ' '.join(points),
) | def polyline(document, coords):
"polyline with more then 2 vertices"
points = []
for i in range(0, len(coords), 2):
points.append("%s,%s" % (coords[i], coords[i+1]))
return setattribs(
document.createElement('polyline'),
points = ' '.join(points),
) | [
"polyline",
"with",
"more",
"then",
"2",
"vertices"
] | WojciechMula/canvas2svg | python | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L403-L412 | [
"def",
"polyline",
"(",
"document",
",",
"coords",
")",
":",
"points",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"coords",
")",
",",
"2",
")",
":",
"points",
".",
"append",
"(",
"\"%s,%s\"",
"%",
"(",
"coords",
"[",
"... | c05d73d88499e5c565386a1765f79d9417a14dac |
train | smoothline | smoothed polyline | canvasvg.py | def smoothline(document, coords):
"smoothed polyline"
element = document.createElement('path')
path = []
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
def pt(points):
x0, y0 = points[0]
x1, y1 = points[1]
p0 = (2*x0-x1, 2*y0-y1)
x0, y0 = points[-1]
x1, y1 = points[-2]
... | def smoothline(document, coords):
"smoothed polyline"
element = document.createElement('path')
path = []
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
def pt(points):
x0, y0 = points[0]
x1, y1 = points[1]
p0 = (2*x0-x1, 2*y0-y1)
x0, y0 = points[-1]
x1, y1 = points[-2]
... | [
"smoothed",
"polyline"
] | WojciechMula/canvas2svg | python | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L415-L447 | [
"def",
"smoothline",
"(",
"document",
",",
"coords",
")",
":",
"element",
"=",
"document",
".",
"createElement",
"(",
"'path'",
")",
"path",
"=",
"[",
"]",
"points",
"=",
"[",
"(",
"coords",
"[",
"i",
"]",
",",
"coords",
"[",
"i",
"+",
"1",
"]",
... | c05d73d88499e5c565386a1765f79d9417a14dac |
train | cubic_bezier | cubic bezier polyline | canvasvg.py | def cubic_bezier(document, coords):
"cubic bezier polyline"
element = document.createElement('path')
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
path = ["M%s %s" %points[0]]
for n in xrange(1, len(points), 3):
A, B, C = points[n:n+3]
path.append("C%s,%s %s,%s %s,%s" % (A[0], A[1]... | def cubic_bezier(document, coords):
"cubic bezier polyline"
element = document.createElement('path')
points = [(coords[i], coords[i+1]) for i in range(0, len(coords), 2)]
path = ["M%s %s" %points[0]]
for n in xrange(1, len(points), 3):
A, B, C = points[n:n+3]
path.append("C%s,%s %s,%s %s,%s" % (A[0], A[1]... | [
"cubic",
"bezier",
"polyline"
] | WojciechMula/canvas2svg | python | https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L449-L458 | [
"def",
"cubic_bezier",
"(",
"document",
",",
"coords",
")",
":",
"element",
"=",
"document",
".",
"createElement",
"(",
"'path'",
")",
"points",
"=",
"[",
"(",
"coords",
"[",
"i",
"]",
",",
"coords",
"[",
"i",
"+",
"1",
"]",
")",
"for",
"i",
"in",
... | c05d73d88499e5c565386a1765f79d9417a14dac |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.