repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
davidmcclure/textplot
textplot/text.py
Text.term_count_buckets
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
python
def term_count_buckets(self): """ Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text. """ buckets = {} for term, count in self.term_counts().items(): if count in buckets: buckets[count...
[ "def", "term_count_buckets", "(", "self", ")", ":", "buckets", "=", "{", "}", "for", "term", ",", "count", "in", "self", ".", "term_counts", "(", ")", ".", "items", "(", ")", ":", "if", "count", "in", "buckets", ":", "buckets", "[", "count", "]", "...
Returns: dict: A dictionary that maps occurrence counts to the terms that appear that many times in the text.
[ "Returns", ":", "dict", ":", "A", "dictionary", "that", "maps", "occurrence", "counts", "to", "the", "terms", "that", "appear", "that", "many", "times", "in", "the", "text", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L112-L125
train
davidmcclure/textplot
textplot/text.py
Text.most_frequent_terms
def most_frequent_terms(self, depth): """ Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms. ...
python
def most_frequent_terms(self, depth): """ Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms. ...
[ "def", "most_frequent_terms", "(", "self", ",", "depth", ")", ":", "counts", "=", "self", ".", "term_counts", "(", ")", "# Get the top X terms and the instance count of the last word.", "top_terms", "=", "set", "(", "list", "(", "counts", ".", "keys", "(", ")", ...
Get the X most frequent terms in the text, and then probe down to get any other terms that have the same count as the last term. Args: depth (int): The number of terms. Returns: set: The set of frequent terms.
[ "Get", "the", "X", "most", "frequent", "terms", "in", "the", "text", "and", "then", "probe", "down", "to", "get", "any", "other", "terms", "that", "have", "the", "same", "count", "as", "the", "last", "term", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L128-L152
train
davidmcclure/textplot
textplot/text.py
Text.unstem
def unstem(self, term): """ Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token. """ originals = [] for i in self.terms[term]: originals.append(sel...
python
def unstem(self, term): """ Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token. """ originals = [] for i in self.terms[term]: originals.append(sel...
[ "def", "unstem", "(", "self", ",", "term", ")", ":", "originals", "=", "[", "]", "for", "i", "in", "self", ".", "terms", "[", "term", "]", ":", "originals", ".", "append", "(", "self", ".", "tokens", "[", "i", "]", "[", "'unstemmed'", "]", ")", ...
Given a stemmed term, get the most common unstemmed variant. Args: term (str): A stemmed term. Returns: str: The unstemmed token.
[ "Given", "a", "stemmed", "term", "get", "the", "most", "common", "unstemmed", "variant", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L155-L172
train
davidmcclure/textplot
textplot/text.py
Text.kde
def kde(self, term, bandwidth=2000, samples=1000, kernel='gaussian'): """ Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sa...
python
def kde(self, term, bandwidth=2000, samples=1000, kernel='gaussian'): """ Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sa...
[ "def", "kde", "(", "self", ",", "term", ",", "bandwidth", "=", "2000", ",", "samples", "=", "1000", ",", "kernel", "=", "'gaussian'", ")", ":", "# Get the offsets of the term instances.", "terms", "=", "np", ".", "array", "(", "self", ".", "terms", "[", ...
Estimate the kernel density of the instances of term in the text. Args: term (str): A stemmed term. bandwidth (int): The kernel bandwidth. samples (int): The number of evenly-spaced sample points. kernel (str): The kernel function. Returns: n...
[ "Estimate", "the", "kernel", "density", "of", "the", "instances", "of", "term", "in", "the", "text", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L176-L202
train
davidmcclure/textplot
textplot/text.py
Text.score_intersect
def score_intersect(self, term1, term2, **kwargs): """ Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kwargs) ...
python
def score_intersect(self, term1, term2, **kwargs): """ Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kwargs) ...
[ "def", "score_intersect", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", ...
Compute the geometric area of the overlap between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
[ "Compute", "the", "geometric", "area", "of", "the", "overlap", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L205-L223
train
davidmcclure/textplot
textplot/text.py
Text.score_cosine
def score_cosine(self, term1, term2, **kwargs): """ Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kw...
python
def score_cosine(self, term1, term2, **kwargs): """ Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(term1, **kw...
[ "def", "score_cosine", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", "k...
Compute a weighting score based on the cosine distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
[ "Compute", "a", "weighting", "score", "based", "on", "the", "cosine", "distance", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L226-L242
train
davidmcclure/textplot
textplot/text.py
Text.score_braycurtis
def score_braycurtis(self, term1, term2, **kwargs): """ Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(t...
python
def score_braycurtis(self, term1, term2, **kwargs): """ Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float """ t1_kde = self.kde(t...
[ "def", "score_braycurtis", "(", "self", ",", "term1", ",", "term2", ",", "*", "*", "kwargs", ")", ":", "t1_kde", "=", "self", ".", "kde", "(", "term1", ",", "*", "*", "kwargs", ")", "t2_kde", "=", "self", ".", "kde", "(", "term2", ",", "*", "*", ...
Compute a weighting score based on the "City Block" distance between the kernel density estimates of two terms. Args: term1 (str) term2 (str) Returns: float
[ "Compute", "a", "weighting", "score", "based", "on", "the", "City", "Block", "distance", "between", "the", "kernel", "density", "estimates", "of", "two", "terms", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L245-L261
train
davidmcclure/textplot
textplot/text.py
Text.plot_term_kdes
def plot_term_kdes(self, words, **kwargs): """ Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms. """ stem = PorterStemmer().stem for word in words: kde = self.kde(stem(word), **kwargs) ...
python
def plot_term_kdes(self, words, **kwargs): """ Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms. """ stem = PorterStemmer().stem for word in words: kde = self.kde(stem(word), **kwargs) ...
[ "def", "plot_term_kdes", "(", "self", ",", "words", ",", "*", "*", "kwargs", ")", ":", "stem", "=", "PorterStemmer", "(", ")", ".", "stem", "for", "word", "in", "words", ":", "kde", "=", "self", ".", "kde", "(", "stem", "(", "word", ")", ",", "*"...
Plot kernel density estimates for multiple words. Args: words (list): A list of unstemmed terms.
[ "Plot", "kernel", "density", "estimates", "for", "multiple", "words", "." ]
889b949a637d99097ecec44ed4bfee53b1964dee
https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L264-L279
train
stephrdev/django-mongoforms
mongoforms/fields.py
MongoFormFieldGenerator.generate
def generate(self, field_name, field): """Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found. """ if hasattr(self, 'generate_%s' % field.__class__.__name__.lower()): generator = get...
python
def generate(self, field_name, field): """Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found. """ if hasattr(self, 'generate_%s' % field.__class__.__name__.lower()): generator = get...
[ "def", "generate", "(", "self", ",", "field_name", ",", "field", ")", ":", "if", "hasattr", "(", "self", ",", "'generate_%s'", "%", "field", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ")", ":", "generator", "=", "getattr", "(", "self", ...
Tries to lookup a matching formfield generator (lowercase field-classname) and raises a NotImplementedError of no generator can be found.
[ "Tries", "to", "lookup", "a", "matching", "formfield", "generator", "(", "lowercase", "field", "-", "classname", ")", "and", "raises", "a", "NotImplementedError", "of", "no", "generator", "can", "be", "found", "." ]
6fa46824c438555c703f293d682ca92710938985
https://github.com/stephrdev/django-mongoforms/blob/6fa46824c438555c703f293d682ca92710938985/mongoforms/fields.py#L49-L65
train
twisted/axiom
axiom/sequence.py
List._fixIndex
def _fixIndex(self, index, truncate=False): """ @param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> l...
python
def _fixIndex(self, index, truncate=False): """ @param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> l...
[ "def", "_fixIndex", "(", "self", ",", "index", ",", "truncate", "=", "False", ")", ":", "assert", "not", "isinstance", "(", "index", ",", "slice", ")", ",", "'slices are not supported (yet)'", "if", "index", "<", "0", ":", "index", "+=", "self", ".", "le...
@param truncate: If true, negative indices which go past the beginning of the list will be evaluated as zero. For example:: >>> L = List([1,2,3,4,5]) >>> len(L) 5 >>> L....
[ "@param", "truncate", ":", "If", "true", "negative", "indices", "which", "go", "past", "the", "beginning", "of", "the", "list", "will", "be", "evaluated", "as", "zero", ".", "For", "example", "::" ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/sequence.py#L40-L60
train
twisted/axiom
axiom/queryutil.py
overlapping
def overlapping(startAttribute, # X endAttribute, # Y startValue, # A endValue, # B ): """ Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will const...
python
def overlapping(startAttribute, # X endAttribute, # Y startValue, # A endValue, # B ): """ Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will const...
[ "def", "overlapping", "(", "startAttribute", ",", "# X", "endAttribute", ",", "# Y", "startValue", ",", "# A", "endValue", ",", "# B", ")", ":", "assert", "startValue", "<=", "endValue", "return", "OR", "(", "AND", "(", "startAttribute", ">=", "startValue", ...
Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the 'comparison' argument to Store.query/.sum/.count) which will constrain a query against 2 attributes for ranges which overlap with the given arguments. For a database with Items of class O which represent values in this confi...
[ "Return", "an", "L", "{", "axiom", ".", "iaxiom", ".", "IComparison", "}", "(", "an", "object", "that", "can", "be", "passed", "as", "the", "comparison", "argument", "to", "Store", ".", "query", "/", ".", "sum", "/", ".", "count", ")", "which", "will...
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/queryutil.py#L21-L88
train
twisted/axiom
axiom/queryutil.py
_tupleCompare
def _tupleCompare(tuple1, ineq, tuple2, eq=lambda a,b: (a==b), ander=AND, orer=OR): """ Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query. """ orholder = [] for limit in range(len...
python
def _tupleCompare(tuple1, ineq, tuple2, eq=lambda a,b: (a==b), ander=AND, orer=OR): """ Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query. """ orholder = [] for limit in range(len...
[ "def", "_tupleCompare", "(", "tuple1", ",", "ineq", ",", "tuple2", ",", "eq", "=", "lambda", "a", ",", "b", ":", "(", "a", "==", "b", ")", ",", "ander", "=", "AND", ",", "orer", "=", "OR", ")", ":", "orholder", "=", "[", "]", "for", "limit", ...
Compare two 'in-database tuples'. Useful when sorting by a compound key and slicing into the middle of that query.
[ "Compare", "two", "in", "-", "database", "tuples", ".", "Useful", "when", "sorting", "by", "a", "compound", "key", "and", "slicing", "into", "the", "middle", "of", "that", "query", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/queryutil.py#L90-L105
train
ubc/ubcpi
ubcpi/ubcpi.py
truncate_rationale
def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT): """ Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value ...
python
def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT): """ Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value ...
[ "def", "truncate_rationale", "(", "rationale", ",", "max_length", "=", "MAX_RATIONALE_SIZE_IN_EVENT", ")", ":", "if", "isinstance", "(", "rationale", ",", "basestring", ")", "and", "max_length", "is", "not", "None", "and", "len", "(", "rationale", ")", ">", "m...
Truncates the rationale for analytics event emission if necessary Args: rationale (string): the string value of the rationale max_length (int): the max length for truncation Returns: truncated_value (string): the possibly truncated version of the rationale was_truncated (bool):...
[ "Truncates", "the", "rationale", "for", "analytics", "event", "emission", "if", "necessary" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L33-L49
train
ubc/ubcpi
ubcpi/ubcpi.py
validate_options
def validate_options(options): """ Validate the options that course author set up and return errors in a dict if there is any """ errors = [] if int(options['rationale_size']['min']) < 1: errors.append(_('Minimum Characters')) if int(options['rationale_size']['max']) < 0 or int(options[...
python
def validate_options(options): """ Validate the options that course author set up and return errors in a dict if there is any """ errors = [] if int(options['rationale_size']['min']) < 1: errors.append(_('Minimum Characters')) if int(options['rationale_size']['max']) < 0 or int(options[...
[ "def", "validate_options", "(", "options", ")", ":", "errors", "=", "[", "]", "if", "int", "(", "options", "[", "'rationale_size'", "]", "[", "'min'", "]", ")", "<", "1", ":", "errors", ".", "append", "(", "_", "(", "'Minimum Characters'", ")", ")", ...
Validate the options that course author set up and return errors in a dict if there is any
[ "Validate", "the", "options", "that", "course", "author", "set", "up", "and", "return", "errors", "in", "a", "dict", "if", "there", "is", "any" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L52-L74
train
ubc/ubcpi
ubcpi/ubcpi.py
MissingDataFetcherMixin.get_student_item_dict
def get_student_item_dict(self, anonymous_user_id=None): """Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The stu...
python
def get_student_item_dict(self, anonymous_user_id=None): """Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The stu...
[ "def", "get_student_item_dict", "(", "self", ",", "anonymous_user_id", "=", "None", ")", ":", "item_id", "=", "self", ".", "_serialize_opaque_key", "(", "self", ".", "scope_ids", ".", "usage_id", ")", "# This is not the real way course_ids should work, but this is a", "...
Create a student_item_dict from our surrounding context. See also: submissions.api for details. Args: anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair. Returns: (dict): The student item associated with this XBlock instance. This ...
[ "Create", "a", "student_item_dict", "from", "our", "surrounding", "context", "." ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/ubcpi.py#L87-L123
train
ubc/ubcpi
ubcpi/persistence.py
get_answers_for_student
def get_answers_for_student(student_item): """ Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the st...
python
def get_answers_for_student(student_item): """ Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the st...
[ "def", "get_answers_for_student", "(", "student_item", ")", ":", "submissions", "=", "sub_api", ".", "get_submissions", "(", "student_item", ")", "if", "not", "submissions", ":", "return", "Answers", "(", ")", "latest_submission", "=", "submissions", "[", "0", "...
Retrieve answers from backend for a student and question Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. Returns: Answers: answers for the student
[ "Retrieve", "answers", "from", "backend", "for", "a", "student", "and", "question" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L25-L42
train
ubc/ubcpi
ubcpi/persistence.py
add_answer_for_student
def add_answer_for_student(student_item, vote, rationale): """ Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student vot...
python
def add_answer_for_student(student_item, vote, rationale): """ Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student vot...
[ "def", "add_answer_for_student", "(", "student_item", ",", "vote", ",", "rationale", ")", ":", "answers", "=", "get_answers_for_student", "(", "student_item", ")", "answers", ".", "add_answer", "(", "vote", ",", "rationale", ")", "sub_api", ".", "create_submission...
Add an answer for a student to the backend Args: student_item (dict): The location of the problem this submission is associated with, as defined by a course, student, and item. vote (int): the option that student voted for rationale (str): the reason why the student vote for the...
[ "Add", "an", "answer", "for", "a", "student", "to", "the", "backend" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L45-L60
train
ubc/ubcpi
ubcpi/persistence.py
Answers._safe_get
def _safe_get(self, revision, key): """ Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or ...
python
def _safe_get(self, revision, key): """ Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or ...
[ "def", "_safe_get", "(", "self", ",", "revision", ",", "key", ")", ":", "if", "self", ".", "has_revision", "(", "revision", ")", ":", "return", "self", ".", "raw_answers", "[", "revision", "]", ".", "get", "(", "key", ")", "else", ":", "return", "Non...
Get an answer data (vote or rationale) by revision Args: revision (int): the revision number for student answer, could be 0 (original) or 1 (revised) key (str); key for retrieve answer data, could be VOTE_KEY or RATIONALE_KEY Returns: ...
[ "Get", "an", "answer", "data", "(", "vote", "or", "rationale", ")", "by", "revision" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L77-L93
train
ubc/ubcpi
ubcpi/persistence.py
Answers.add_answer
def add_answer(self, vote, rationale): """ Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option """ self.raw_answers.append({ VOTE_KEY: vote, RATIONALE_KE...
python
def add_answer(self, vote, rationale): """ Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option """ self.raw_answers.append({ VOTE_KEY: vote, RATIONALE_KE...
[ "def", "add_answer", "(", "self", ",", "vote", ",", "rationale", ")", ":", "self", ".", "raw_answers", ".", "append", "(", "{", "VOTE_KEY", ":", "vote", ",", "RATIONALE_KEY", ":", "rationale", ",", "}", ")" ]
Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option
[ "Add", "an", "answer" ]
7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L134-L145
train
swharden/PyOriginTools
documentation/PyOrigin-examples/examples.py
exceptionToString
def exceptionToString(e,silent=False): """when you "except Exception as e", give me the e and I'll give you a string.""" exc_type, exc_obj, exc_tb = sys.exc_info() s=("\n"+"="*50+"\n") s+="EXCEPTION THROWN UNEXPECTEDLY\n" s+=" FILE: %s\n"%os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] s+=...
python
def exceptionToString(e,silent=False): """when you "except Exception as e", give me the e and I'll give you a string.""" exc_type, exc_obj, exc_tb = sys.exc_info() s=("\n"+"="*50+"\n") s+="EXCEPTION THROWN UNEXPECTEDLY\n" s+=" FILE: %s\n"%os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] s+=...
[ "def", "exceptionToString", "(", "e", ",", "silent", "=", "False", ")", ":", "exc_type", ",", "exc_obj", ",", "exc_tb", "=", "sys", ".", "exc_info", "(", ")", "s", "=", "(", "\"\\n\"", "+", "\"=\"", "*", "50", "+", "\"\\n\"", ")", "s", "+=", "\"EXC...
when you "except Exception as e", give me the e and I'll give you a string.
[ "when", "you", "except", "Exception", "as", "e", "give", "me", "the", "e", "and", "I", "ll", "give", "you", "a", "string", "." ]
536fb8e11234ffdc27e26b1800e0358179ca7d26
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/documentation/PyOrigin-examples/examples.py#L38-L51
train
twisted/axiom
axiom/substore.py
SubStore.createNew
def createNew(cls, store, pathSegments): """ Create a new SubStore, allocating a new file space for it. """ if isinstance(pathSegments, basestring): raise ValueError( 'Received %r instead of a sequence' % (pathSegments,)) if store.dbdir is None: ...
python
def createNew(cls, store, pathSegments): """ Create a new SubStore, allocating a new file space for it. """ if isinstance(pathSegments, basestring): raise ValueError( 'Received %r instead of a sequence' % (pathSegments,)) if store.dbdir is None: ...
[ "def", "createNew", "(", "cls", ",", "store", ",", "pathSegments", ")", ":", "if", "isinstance", "(", "pathSegments", ",", "basestring", ")", ":", "raise", "ValueError", "(", "'Received %r instead of a sequence'", "%", "(", "pathSegments", ",", ")", ")", "if",...
Create a new SubStore, allocating a new file space for it.
[ "Create", "a", "new", "SubStore", "allocating", "a", "new", "file", "space", "for", "it", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/substore.py#L25-L39
train
twisted/axiom
axiom/substore.py
SubStore.createStore
def createStore(self, debug, journalMode=None): """ Create the actual Store this Substore represents. """ if self.storepath is None: self.store._memorySubstores.append(self) # don't fall out of cache if self.store.filesdir is None: filesdir = None ...
python
def createStore(self, debug, journalMode=None): """ Create the actual Store this Substore represents. """ if self.storepath is None: self.store._memorySubstores.append(self) # don't fall out of cache if self.store.filesdir is None: filesdir = None ...
[ "def", "createStore", "(", "self", ",", "debug", ",", "journalMode", "=", "None", ")", ":", "if", "self", ".", "storepath", "is", "None", ":", "self", ".", "store", ".", "_memorySubstores", ".", "append", "(", "self", ")", "# don't fall out of cache", "if"...
Create the actual Store this Substore represents.
[ "Create", "the", "actual", "Store", "this", "Substore", "represents", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/substore.py#L62-L84
train
twisted/axiom
axiom/tags.py
upgradeCatalog1to2
def upgradeCatalog1to2(oldCatalog): """ Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create. """ newCatalog = oldCatalog.upgradeVersion('tag_catalog', 1, 2, ...
python
def upgradeCatalog1to2(oldCatalog): """ Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create. """ newCatalog = oldCatalog.upgradeVersion('tag_catalog', 1, 2, ...
[ "def", "upgradeCatalog1to2", "(", "oldCatalog", ")", ":", "newCatalog", "=", "oldCatalog", ".", "upgradeVersion", "(", "'tag_catalog'", ",", "1", ",", "2", ",", "tagCount", "=", "oldCatalog", ".", "tagCount", ")", "tags", "=", "newCatalog", ".", "store", "."...
Create _TagName instances which version 2 of Catalog automatically creates for use in determining the tagNames result, but which version 1 of Catalog did not create.
[ "Create", "_TagName", "instances", "which", "version", "2", "of", "Catalog", "automatically", "creates", "for", "use", "in", "determining", "the", "tagNames", "result", "but", "which", "version", "1", "of", "Catalog", "did", "not", "create", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L110-L122
train
twisted/axiom
axiom/tags.py
Catalog.tagNames
def tagNames(self): """ Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog. """ return self.store.query(_TagName, _TagName.catalog == self).getColumn("name")
python
def tagNames(self): """ Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog. """ return self.store.query(_TagName, _TagName.catalog == self).getColumn("name")
[ "def", "tagNames", "(", "self", ")", ":", "return", "self", ".", "store", ".", "query", "(", "_TagName", ",", "_TagName", ".", "catalog", "==", "self", ")", ".", "getColumn", "(", "\"name\"", ")" ]
Return an iterator of unicode strings - the unique tag names which have been applied objects in this catalog.
[ "Return", "an", "iterator", "of", "unicode", "strings", "-", "the", "unique", "tag", "names", "which", "have", "been", "applied", "objects", "in", "this", "catalog", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L83-L88
train
twisted/axiom
axiom/tags.py
Catalog.tagsOf
def tagsOf(self, obj): """ Return an iterator of unicode strings - the tag names which apply to the given object. """ return self.store.query( Tag, AND(Tag.catalog == self, Tag.object == obj)).getColumn("name")
python
def tagsOf(self, obj): """ Return an iterator of unicode strings - the tag names which apply to the given object. """ return self.store.query( Tag, AND(Tag.catalog == self, Tag.object == obj)).getColumn("name")
[ "def", "tagsOf", "(", "self", ",", "obj", ")", ":", "return", "self", ".", "store", ".", "query", "(", "Tag", ",", "AND", "(", "Tag", ".", "catalog", "==", "self", ",", "Tag", ".", "object", "==", "obj", ")", ")", ".", "getColumn", "(", "\"name\"...
Return an iterator of unicode strings - the tag names which apply to the given object.
[ "Return", "an", "iterator", "of", "unicode", "strings", "-", "the", "tag", "names", "which", "apply", "to", "the", "given", "object", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/tags.py#L91-L99
train
twisted/axiom
axiom/attributes.py
SQLAttribute.loaded
def loaded(self, oself, dbval): """ This method is invoked when the item is loaded from the database, and when a transaction is reverted which restores this attribute's value. @param oself: an instance of an item which has this attribute. @param dbval: the underlying database v...
python
def loaded(self, oself, dbval): """ This method is invoked when the item is loaded from the database, and when a transaction is reverted which restores this attribute's value. @param oself: an instance of an item which has this attribute. @param dbval: the underlying database v...
[ "def", "loaded", "(", "self", ",", "oself", ",", "dbval", ")", ":", "setattr", "(", "oself", ",", "self", ".", "dbunderlying", ",", "dbval", ")", "delattr", "(", "oself", ",", "self", ".", "underlying", ")" ]
This method is invoked when the item is loaded from the database, and when a transaction is reverted which restores this attribute's value. @param oself: an instance of an item which has this attribute. @param dbval: the underlying database value which was retrieved.
[ "This", "method", "is", "invoked", "when", "the", "item", "is", "loaded", "from", "the", "database", "and", "when", "a", "transaction", "is", "reverted", "which", "restores", "this", "attribute", "s", "value", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L459-L469
train
twisted/axiom
axiom/attributes.py
SQLAttribute._convertPyval
def _convertPyval(self, oself, pyval): """ Convert a Python value to a value suitable for inserting into the database. @param oself: The object on which this descriptor is an attribute. @param pyval: The value to be converted. @return: A value legal for this column in th...
python
def _convertPyval(self, oself, pyval): """ Convert a Python value to a value suitable for inserting into the database. @param oself: The object on which this descriptor is an attribute. @param pyval: The value to be converted. @return: A value legal for this column in th...
[ "def", "_convertPyval", "(", "self", ",", "oself", ",", "pyval", ")", ":", "# convert to dbval later, I guess?", "if", "pyval", "is", "None", "and", "not", "self", ".", "allowNone", ":", "raise", "TypeError", "(", "\"attribute [%s.%s = %s()] must not be None\"", "%"...
Convert a Python value to a value suitable for inserting into the database. @param oself: The object on which this descriptor is an attribute. @param pyval: The value to be converted. @return: A value legal for this column in the database.
[ "Convert", "a", "Python", "value", "to", "a", "value", "suitable", "for", "inserting", "into", "the", "database", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L473-L487
train
twisted/axiom
axiom/attributes.py
SequenceComparison._queryContainer
def _queryContainer(self, store): """ Generate and cache the subselect SQL and its arguments. Return the subselect SQL. """ if self._subselectSQL is None: sql, args = self.container._sqlAndArgs('SELECT', self.contain...
python
def _queryContainer(self, store): """ Generate and cache the subselect SQL and its arguments. Return the subselect SQL. """ if self._subselectSQL is None: sql, args = self.container._sqlAndArgs('SELECT', self.contain...
[ "def", "_queryContainer", "(", "self", ",", "store", ")", ":", "if", "self", ".", "_subselectSQL", "is", "None", ":", "sql", ",", "args", "=", "self", ".", "container", ".", "_sqlAndArgs", "(", "'SELECT'", ",", "self", ".", "container", ".", "_queryTarge...
Generate and cache the subselect SQL and its arguments. Return the subselect SQL.
[ "Generate", "and", "cache", "the", "subselect", "SQL", "and", "its", "arguments", ".", "Return", "the", "subselect", "SQL", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L729-L738
train
twisted/axiom
axiom/attributes.py
SequenceComparison._sequenceContainer
def _sequenceContainer(self, store): """ Smash whatever we got into a list and save the result in case we are executed multiple times. This keeps us from tripping up over generators and the like. """ if self._sequence is None: self._sequence = list(self.conta...
python
def _sequenceContainer(self, store): """ Smash whatever we got into a list and save the result in case we are executed multiple times. This keeps us from tripping up over generators and the like. """ if self._sequence is None: self._sequence = list(self.conta...
[ "def", "_sequenceContainer", "(", "self", ",", "store", ")", ":", "if", "self", ".", "_sequence", "is", "None", ":", "self", ".", "_sequence", "=", "list", "(", "self", ".", "container", ")", "self", ".", "_clause", "=", "', '", ".", "join", "(", "["...
Smash whatever we got into a list and save the result in case we are executed multiple times. This keeps us from tripping up over generators and the like.
[ "Smash", "whatever", "we", "got", "into", "a", "list", "and", "save", "the", "result", "in", "case", "we", "are", "executed", "multiple", "times", ".", "This", "keeps", "us", "from", "tripping", "up", "over", "generators", "and", "the", "like", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L751-L760
train
twisted/axiom
axiom/attributes.py
SequenceComparison._sequenceArgs
def _sequenceArgs(self, store): """ Filter each element of the data using the attribute type being tested for containment and hand back the resulting list. """ self._sequenceContainer(store) # Force _sequence to be valid return [self.attribute.infilter(pyval, None, store)...
python
def _sequenceArgs(self, store): """ Filter each element of the data using the attribute type being tested for containment and hand back the resulting list. """ self._sequenceContainer(store) # Force _sequence to be valid return [self.attribute.infilter(pyval, None, store)...
[ "def", "_sequenceArgs", "(", "self", ",", "store", ")", ":", "self", ".", "_sequenceContainer", "(", "store", ")", "# Force _sequence to be valid", "return", "[", "self", ".", "attribute", ".", "infilter", "(", "pyval", ",", "None", ",", "store", ")", "for",...
Filter each element of the data using the attribute type being tested for containment and hand back the resulting list.
[ "Filter", "each", "element", "of", "the", "data", "using", "the", "attribute", "type", "being", "tested", "for", "containment", "and", "hand", "back", "the", "resulting", "list", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L763-L769
train
twisted/axiom
axiom/attributes.py
path.prepareInsert
def prepareInsert(self, oself, store): """ Prepare for insertion into the database by making the dbunderlying attribute of the item a relative pathname with respect to the store rather than an absolute pathname. """ if self.relative: fspath = self.__get__(osel...
python
def prepareInsert(self, oself, store): """ Prepare for insertion into the database by making the dbunderlying attribute of the item a relative pathname with respect to the store rather than an absolute pathname. """ if self.relative: fspath = self.__get__(osel...
[ "def", "prepareInsert", "(", "self", ",", "oself", ",", "store", ")", ":", "if", "self", ".", "relative", ":", "fspath", "=", "self", ".", "__get__", "(", "oself", ")", "oself", ".", "__dirty__", "[", "self", ".", "attrname", "]", "=", "self", ",", ...
Prepare for insertion into the database by making the dbunderlying attribute of the item a relative pathname with respect to the store rather than an absolute pathname.
[ "Prepare", "for", "insertion", "into", "the", "database", "by", "making", "the", "dbunderlying", "attribute", "of", "the", "item", "a", "relative", "pathname", "with", "respect", "to", "the", "store", "rather", "than", "an", "absolute", "pathname", "." ]
7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/attributes.py#L1021-L1029
train
upgrad/django-deletes
djangodeletes/softdeletes/models.py
SoftDeletable.restore
def restore(self, time=None): """ Undeletes the object. Returns True if undeleted, False if it was already not deleted """ if self.deleted: time = time if time else self.deleted_at if time == self.deleted_at: self.deleted = False se...
python
def restore(self, time=None): """ Undeletes the object. Returns True if undeleted, False if it was already not deleted """ if self.deleted: time = time if time else self.deleted_at if time == self.deleted_at: self.deleted = False se...
[ "def", "restore", "(", "self", ",", "time", "=", "None", ")", ":", "if", "self", ".", "deleted", ":", "time", "=", "time", "if", "time", "else", "self", ".", "deleted_at", "if", "time", "==", "self", ".", "deleted_at", ":", "self", ".", "deleted", ...
Undeletes the object. Returns True if undeleted, False if it was already not deleted
[ "Undeletes", "the", "object", ".", "Returns", "True", "if", "undeleted", "False", "if", "it", "was", "already", "not", "deleted" ]
05cebc3323840badc67b926ec1ba2640d6cd12be
https://github.com/upgrad/django-deletes/blob/05cebc3323840badc67b926ec1ba2640d6cd12be/djangodeletes/softdeletes/models.py#L97-L109
train
upgrad/django-deletes
djangodeletes/softdeletes/models.py
SoftDeletable.full_restore
def full_restore(self, using=None): using = using or router.db_for_write(self.__class__, instance=self) restore_counter = Counter() if self.deleted: time = self.deleted_at else: return restore_counter self.collector = models.deletion.Collector(using=using)...
python
def full_restore(self, using=None): using = using or router.db_for_write(self.__class__, instance=self) restore_counter = Counter() if self.deleted: time = self.deleted_at else: return restore_counter self.collector = models.deletion.Collector(using=using)...
[ "def", "full_restore", "(", "self", ",", "using", "=", "None", ")", ":", "using", "=", "using", "or", "router", ".", "db_for_write", "(", "self", ".", "__class__", ",", "instance", "=", "self", ")", "restore_counter", "=", "Counter", "(", ")", "if", "s...
Restores itself, as well as objects that might have been deleted along with it if cascade is the deletion strategy
[ "Restores", "itself", "as", "well", "as", "objects", "that", "might", "have", "been", "deleted", "along", "with", "it", "if", "cascade", "is", "the", "deletion", "strategy" ]
05cebc3323840badc67b926ec1ba2640d6cd12be
https://github.com/upgrad/django-deletes/blob/05cebc3323840badc67b926ec1ba2640d6cd12be/djangodeletes/softdeletes/models.py#L111-L144
train
skymill/automated-ebs-snapshots
automated_ebs_snapshots/connection_manager.py
connect_to_ec2
def connect_to_ec2(region='us-east-1', access_key=None, secret_key=None): """ Connect to AWS ec2 :type region: str :param region: AWS region to connect to :type access_key: str :param access_key: AWS access key id :type secret_key: str :param secret_key: AWS secret access key :returns: ...
python
def connect_to_ec2(region='us-east-1', access_key=None, secret_key=None): """ Connect to AWS ec2 :type region: str :param region: AWS region to connect to :type access_key: str :param access_key: AWS access key id :type secret_key: str :param secret_key: AWS secret access key :returns: ...
[ "def", "connect_to_ec2", "(", "region", "=", "'us-east-1'", ",", "access_key", "=", "None", ",", "secret_key", "=", "None", ")", ":", "if", "access_key", ":", "# Connect using supplied credentials", "logger", ".", "info", "(", "'Connecting to AWS EC2 in {}'", ".", ...
Connect to AWS ec2 :type region: str :param region: AWS region to connect to :type access_key: str :param access_key: AWS access key id :type secret_key: str :param secret_key: AWS secret access key :returns: boto.ec2.connection.EC2Connection -- EC2 connection
[ "Connect", "to", "AWS", "ec2" ]
9595bc49d458f6ffb93430722757d2284e878fab
https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/connection_manager.py#L11-L47
train
dmirecki/pyMorfologik
pymorfologik/parsing.py
DictParser.parse
def parse(self, output): """ Find stems for a given text. """ output = self._get_lines_with_stems(output) words = self._make_unique(output) return self._parse_for_simple_stems(words)
python
def parse(self, output): """ Find stems for a given text. """ output = self._get_lines_with_stems(output) words = self._make_unique(output) return self._parse_for_simple_stems(words)
[ "def", "parse", "(", "self", ",", "output", ")", ":", "output", "=", "self", ".", "_get_lines_with_stems", "(", "output", ")", "words", "=", "self", ".", "_make_unique", "(", "output", ")", "return", "self", ".", "_parse_for_simple_stems", "(", "words", ")...
Find stems for a given text.
[ "Find", "stems", "for", "a", "given", "text", "." ]
e4d93a82e8b4c7a108f01e0456fbeb8024df0259
https://github.com/dmirecki/pyMorfologik/blob/e4d93a82e8b4c7a108f01e0456fbeb8024df0259/pymorfologik/parsing.py#L47-L53
train
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.validlocations
def validlocations(configuration=None): # type: () -> List[Dict] """ Read valid locations from HDX Args: configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. Returns: List[Dict]: A list of valid locations ...
python
def validlocations(configuration=None): # type: () -> List[Dict] """ Read valid locations from HDX Args: configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. Returns: List[Dict]: A list of valid locations ...
[ "def", "validlocations", "(", "configuration", "=", "None", ")", ":", "# type: () -> List[Dict]", "if", "Locations", ".", "_validlocations", "is", "None", ":", "if", "configuration", "is", "None", ":", "configuration", "=", "Configuration", ".", "read", "(", ")"...
Read valid locations from HDX Args: configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. Returns: List[Dict]: A list of valid locations
[ "Read", "valid", "locations", "from", "HDX" ]
212440f54f73805826a16db77dbcb6033b18a313
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L14-L29
train
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.get_location_from_HDX_code
def get_location_from_HDX_code(code, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get location from HDX location code Args: code (str): code for which to get location name locations (Optional[List[D...
python
def get_location_from_HDX_code(code, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get location from HDX location code Args: code (str): code for which to get location name locations (Optional[List[D...
[ "def", "get_location_from_HDX_code", "(", "code", ",", "locations", "=", "None", ",", "configuration", "=", "None", ")", ":", "# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str]", "if", "locations", "is", "None", ":", "locations", "=", "Location...
Get location from HDX location code Args: code (str): code for which to get location name locations (Optional[List[Dict]]): Valid locations list. Defaults to list downloaded from HDX. configuration (Optional[Configuration]): HDX configuration. Defaults to global configuratio...
[ "Get", "location", "from", "HDX", "location", "code" ]
212440f54f73805826a16db77dbcb6033b18a313
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L46-L63
train
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.get_HDX_code_from_location
def get_HDX_code_from_location(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict...
python
def get_HDX_code_from_location(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str] """Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict...
[ "def", "get_HDX_code_from_location", "(", "location", ",", "locations", "=", "None", ",", "configuration", "=", "None", ")", ":", "# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str]", "if", "locations", "is", "None", ":", "locations", "=", "Loca...
Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict]]): Valid locations list. Defaults to list downloaded from HDX. configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. ...
[ "Get", "HDX", "code", "for", "location" ]
212440f54f73805826a16db77dbcb6033b18a313
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L66-L89
train
OCHA-DAP/hdx-python-api
src/hdx/hdx_locations.py
Locations.get_HDX_code_from_location_partial
def get_HDX_code_from_location_partial(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Tuple[Optional[str], bool] """Get HDX code for location Args: location (str): Location for which to get HDX code location...
python
def get_HDX_code_from_location_partial(location, locations=None, configuration=None): # type: (str, Optional[List[Dict]], Optional[Configuration]) -> Tuple[Optional[str], bool] """Get HDX code for location Args: location (str): Location for which to get HDX code location...
[ "def", "get_HDX_code_from_location_partial", "(", "location", ",", "locations", "=", "None", ",", "configuration", "=", "None", ")", ":", "# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Tuple[Optional[str], bool]", "hdx_code", "=", "Locations", ".", "get_HDX_co...
Get HDX code for location Args: location (str): Location for which to get HDX code locations (Optional[List[Dict]]): Valid locations list. Defaults to list downloaded from HDX. configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration. ...
[ "Get", "HDX", "code", "for", "location" ]
212440f54f73805826a16db77dbcb6033b18a313
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/hdx_locations.py#L92-L117
train
libyal/dtfabric
scripts/validate-definitions.py
Main
def Main(): """The main program function. Returns: bool: True if successful or False if not. """ argument_parser = argparse.ArgumentParser( description='Validates dtFabric format definitions.') argument_parser.add_argument( 'source', nargs='?', action='store', metavar='PATH', default=None, ...
python
def Main(): """The main program function. Returns: bool: True if successful or False if not. """ argument_parser = argparse.ArgumentParser( description='Validates dtFabric format definitions.') argument_parser.add_argument( 'source', nargs='?', action='store', metavar='PATH', default=None, ...
[ "def", "Main", "(", ")", ":", "argument_parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Validates dtFabric format definitions.'", ")", "argument_parser", ".", "add_argument", "(", "'source'", ",", "nargs", "=", "'?'", ",", "action", "="...
The main program function. Returns: bool: True if successful or False if not.
[ "The", "main", "program", "function", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/scripts/validate-definitions.py#L77-L130
train
libyal/dtfabric
scripts/validate-definitions.py
DefinitionsValidator.CheckDirectory
def CheckDirectory(self, path, extension='yaml'): """Validates definition files in a directory. Args: path (str): path of the definition file. extension (Optional[str]): extension of the filenames to read. Returns: bool: True if the directory contains valid definitions. """ resul...
python
def CheckDirectory(self, path, extension='yaml'): """Validates definition files in a directory. Args: path (str): path of the definition file. extension (Optional[str]): extension of the filenames to read. Returns: bool: True if the directory contains valid definitions. """ resul...
[ "def", "CheckDirectory", "(", "self", ",", "path", ",", "extension", "=", "'yaml'", ")", ":", "result", "=", "True", "if", "extension", ":", "glob_spec", "=", "os", ".", "path", ".", "join", "(", "path", ",", "'*.{0:s}'", ".", "format", "(", "extension...
Validates definition files in a directory. Args: path (str): path of the definition file. extension (Optional[str]): extension of the filenames to read. Returns: bool: True if the directory contains valid definitions.
[ "Validates", "definition", "files", "in", "a", "directory", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/scripts/validate-definitions.py#L22-L43
train
libyal/dtfabric
scripts/validate-definitions.py
DefinitionsValidator.CheckFile
def CheckFile(self, path): """Validates the definition in a file. Args: path (str): path of the definition file. Returns: bool: True if the file contains valid definitions. """ print('Checking: {0:s}'.format(path)) definitions_registry = registry.DataTypeDefinitionsRegistry() ...
python
def CheckFile(self, path): """Validates the definition in a file. Args: path (str): path of the definition file. Returns: bool: True if the file contains valid definitions. """ print('Checking: {0:s}'.format(path)) definitions_registry = registry.DataTypeDefinitionsRegistry() ...
[ "def", "CheckFile", "(", "self", ",", "path", ")", ":", "print", "(", "'Checking: {0:s}'", ".", "format", "(", "path", ")", ")", "definitions_registry", "=", "registry", ".", "DataTypeDefinitionsRegistry", "(", ")", "definitions_reader", "=", "reader", ".", "Y...
Validates the definition in a file. Args: path (str): path of the definition file. Returns: bool: True if the file contains valid definitions.
[ "Validates", "the", "definition", "in", "a", "file", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/scripts/validate-definitions.py#L45-L74
train
dlanger/inlinestyler
inlinestyler/converter.py
Conversion.styleattribute
def styleattribute(self, element): """ returns css.CSSStyleDeclaration of inline styles, for html: @style """ css_text = element.get('style') if css_text: return cssutils.css.CSSStyleDeclaration(cssText=css_text) else: return None
python
def styleattribute(self, element): """ returns css.CSSStyleDeclaration of inline styles, for html: @style """ css_text = element.get('style') if css_text: return cssutils.css.CSSStyleDeclaration(cssText=css_text) else: return None
[ "def", "styleattribute", "(", "self", ",", "element", ")", ":", "css_text", "=", "element", ".", "get", "(", "'style'", ")", "if", "css_text", ":", "return", "cssutils", ".", "css", ".", "CSSStyleDeclaration", "(", "cssText", "=", "css_text", ")", "else", ...
returns css.CSSStyleDeclaration of inline styles, for html: @style
[ "returns", "css", ".", "CSSStyleDeclaration", "of", "inline", "styles", "for", "html", ":" ]
335c4fbab892f0ed67466a6beaea6a91f395ad12
https://github.com/dlanger/inlinestyler/blob/335c4fbab892f0ed67466a6beaea6a91f395ad12/inlinestyler/converter.py#L66-L74
train
skymill/automated-ebs-snapshots
automated_ebs_snapshots/config_file_parser.py
get_configuration
def get_configuration(filename): """ Read configuration file :type filename: str :param filename: Path to the configuration file """ logger.debug('Reading configuration from {}'.format(filename)) conf = SafeConfigParser() conf.read(filename) if not conf: logger.error('Configura...
python
def get_configuration(filename): """ Read configuration file :type filename: str :param filename: Path to the configuration file """ logger.debug('Reading configuration from {}'.format(filename)) conf = SafeConfigParser() conf.read(filename) if not conf: logger.error('Configura...
[ "def", "get_configuration", "(", "filename", ")", ":", "logger", ".", "debug", "(", "'Reading configuration from {}'", ".", "format", "(", "filename", ")", ")", "conf", "=", "SafeConfigParser", "(", ")", "conf", ".", "read", "(", "filename", ")", "if", "not"...
Read configuration file :type filename: str :param filename: Path to the configuration file
[ "Read", "configuration", "file" ]
9595bc49d458f6ffb93430722757d2284e878fab
https://github.com/skymill/automated-ebs-snapshots/blob/9595bc49d458f6ffb93430722757d2284e878fab/automated_ebs_snapshots/config_file_parser.py#L9-L37
train
dlanger/inlinestyler
inlinestyler/utils.py
inline_css
def inline_css(html_message, encoding='unicode'): """ Inlines all CSS in an HTML string Given an HTML document with CSS declared in the HEAD, inlines it into the applicable elements. Used primarily in the preparation of styled emails. Arguments: html_message -- a string of HTML, including ...
python
def inline_css(html_message, encoding='unicode'): """ Inlines all CSS in an HTML string Given an HTML document with CSS declared in the HEAD, inlines it into the applicable elements. Used primarily in the preparation of styled emails. Arguments: html_message -- a string of HTML, including ...
[ "def", "inline_css", "(", "html_message", ",", "encoding", "=", "'unicode'", ")", ":", "document", "=", "etree", ".", "HTML", "(", "html_message", ")", "converter", "=", "Conversion", "(", ")", "converter", ".", "perform", "(", "document", ",", "html_message...
Inlines all CSS in an HTML string Given an HTML document with CSS declared in the HEAD, inlines it into the applicable elements. Used primarily in the preparation of styled emails. Arguments: html_message -- a string of HTML, including CSS
[ "Inlines", "all", "CSS", "in", "an", "HTML", "string" ]
335c4fbab892f0ed67466a6beaea6a91f395ad12
https://github.com/dlanger/inlinestyler/blob/335c4fbab892f0ed67466a6beaea6a91f395ad12/inlinestyler/utils.py#L4-L18
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StorageDataTypeMap._CheckByteStreamSize
def _CheckByteStreamSize(self, byte_stream, byte_offset, data_type_size): """Checks if the byte stream is large enough for the data type. Args: byte_stream (bytes): byte stream. byte_offset (int): offset into the byte stream where to start. data_type_size (int): data type size. Raises: ...
python
def _CheckByteStreamSize(self, byte_stream, byte_offset, data_type_size): """Checks if the byte stream is large enough for the data type. Args: byte_stream (bytes): byte stream. byte_offset (int): offset into the byte stream where to start. data_type_size (int): data type size. Raises: ...
[ "def", "_CheckByteStreamSize", "(", "self", ",", "byte_stream", ",", "byte_offset", ",", "data_type_size", ")", ":", "try", ":", "byte_stream_size", "=", "len", "(", "byte_stream", ")", "except", "Exception", "as", "exception", ":", "raise", "errors", ".", "Ma...
Checks if the byte stream is large enough for the data type. Args: byte_stream (bytes): byte stream. byte_offset (int): offset into the byte stream where to start. data_type_size (int): data type size. Raises: ByteStreamTooSmallError: if the byte stream is too small. MappingError...
[ "Checks", "if", "the", "byte", "stream", "is", "large", "enough", "for", "the", "data", "type", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L149-L170
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StorageDataTypeMap._GetByteStreamOperation
def _GetByteStreamOperation(self): """Retrieves the byte stream operation. Returns: ByteStreamOperation: byte stream operation or None if unable to determine. """ byte_order_string = self.GetStructByteOrderString() format_string = self.GetStructFormatString() # pylint: disable=assignment-fro...
python
def _GetByteStreamOperation(self): """Retrieves the byte stream operation. Returns: ByteStreamOperation: byte stream operation or None if unable to determine. """ byte_order_string = self.GetStructByteOrderString() format_string = self.GetStructFormatString() # pylint: disable=assignment-fro...
[ "def", "_GetByteStreamOperation", "(", "self", ")", ":", "byte_order_string", "=", "self", ".", "GetStructByteOrderString", "(", ")", "format_string", "=", "self", ".", "GetStructFormatString", "(", ")", "# pylint: disable=assignment-from-none", "if", "not", "format_str...
Retrieves the byte stream operation. Returns: ByteStreamOperation: byte stream operation or None if unable to determine.
[ "Retrieves", "the", "byte", "stream", "operation", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L172-L184
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StorageDataTypeMap.GetStructByteOrderString
def GetStructByteOrderString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._data_type_definition: return None return self._BYTE_ORDER_STRINGS.get( ...
python
def GetStructByteOrderString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._data_type_definition: return None return self._BYTE_ORDER_STRINGS.get( ...
[ "def", "GetStructByteOrderString", "(", "self", ")", ":", "if", "not", "self", ".", "_data_type_definition", ":", "return", "None", "return", "self", ".", "_BYTE_ORDER_STRINGS", ".", "get", "(", "self", ".", "_data_type_definition", ".", "byte_order", ",", "None...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L186-L197
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
PrimitiveDataTypeMap.FoldByteStream
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
python
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "try", ":", "value", "=", "self", ".", "FoldValue", "(", "mapped_value", ")", "return", "self", ".", "_operation", ".", "WriteTo", "(", "tuple", "(", "["...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L253-L274
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
PrimitiveDataTypeMap.MapByteStream
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
python
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "data_type_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", "self", ...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: object: mapped value. Raises: MappingError: if the da...
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L290-L323
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
BooleanMap.FoldValue
def FoldValue(self, value): """Folds the data type into a value. Args: value (object): value. Returns: object: folded value. Raises: ValueError: if the data type definition cannot be folded into the value. """ if value is False and self._data_type_definition.false_value is n...
python
def FoldValue(self, value): """Folds the data type into a value. Args: value (object): value. Returns: object: folded value. Raises: ValueError: if the data type definition cannot be folded into the value. """ if value is False and self._data_type_definition.false_value is n...
[ "def", "FoldValue", "(", "self", ",", "value", ")", ":", "if", "value", "is", "False", "and", "self", ".", "_data_type_definition", ".", "false_value", "is", "not", "None", ":", "return", "self", ".", "_data_type_definition", ".", "false_value", "if", "value...
Folds the data type into a value. Args: value (object): value. Returns: object: folded value. Raises: ValueError: if the data type definition cannot be folded into the value.
[ "Folds", "the", "data", "type", "into", "a", "value", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L378-L396
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
IntegerMap.GetStructFormatString
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._data_type_definition.format == definitions.FORMAT_UNSIGNED: return self._FORMAT_STRINGS_U...
python
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._data_type_definition.format == definitions.FORMAT_UNSIGNED: return self._FORMAT_STRINGS_U...
[ "def", "GetStructFormatString", "(", "self", ")", ":", "if", "self", ".", "_data_type_definition", ".", "format", "==", "definitions", ".", "FORMAT_UNSIGNED", ":", "return", "self", ".", "_FORMAT_STRINGS_UNSIGNED", ".", "get", "(", "self", ".", "_data_type_definit...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L515-L527
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
UUIDMap.FoldByteStream
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
python
def FoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ ...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "value", "=", "None", "try", ":", "if", "self", ".", "_byte_order", "==", "definitions", ".", "BYTE_ORDER_BIG_ENDIAN", ":", "value", "=", "mapped_value", "."...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L544-L571
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
UUIDMap.MapByteStream
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
python
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "data_type_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", "self", ...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: uuid.UUID: mapped value. Raises: MappingError: if the...
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L573-L610
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._CalculateElementsDataSize
def _CalculateElementsDataSize(self, context): """Calculates the elements data size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: the elements data size or None if not available. """ elements_data_size = N...
python
def _CalculateElementsDataSize(self, context): """Calculates the elements data size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: the elements data size or None if not available. """ elements_data_size = N...
[ "def", "_CalculateElementsDataSize", "(", "self", ",", "context", ")", ":", "elements_data_size", "=", "None", "if", "self", ".", "_HasElementsDataSize", "(", ")", ":", "elements_data_size", "=", "self", ".", "_EvaluateElementsDataSize", "(", "context", ")", "elif...
Calculates the elements data size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: the elements data size or None if not available.
[ "Calculates", "the", "elements", "data", "size", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L636-L657
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._EvaluateElementsDataSize
def _EvaluateElementsDataSize(self, context): """Evaluates elements data size. Args: context (DataTypeMapContext): data type map context. Returns: int: elements data size. Raises: MappingError: if the elements data size cannot be determined. """ elements_data_size = None ...
python
def _EvaluateElementsDataSize(self, context): """Evaluates elements data size. Args: context (DataTypeMapContext): data type map context. Returns: int: elements data size. Raises: MappingError: if the elements data size cannot be determined. """ elements_data_size = None ...
[ "def", "_EvaluateElementsDataSize", "(", "self", ",", "context", ")", ":", "elements_data_size", "=", "None", "if", "self", ".", "_data_type_definition", ".", "elements_data_size", ":", "elements_data_size", "=", "self", ".", "_data_type_definition", ".", "elements_da...
Evaluates elements data size. Args: context (DataTypeMapContext): data type map context. Returns: int: elements data size. Raises: MappingError: if the elements data size cannot be determined.
[ "Evaluates", "elements", "data", "size", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L659-L694
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._EvaluateNumberOfElements
def _EvaluateNumberOfElements(self, context): """Evaluates number of elements. Args: context (DataTypeMapContext): data type map context. Returns: int: number of elements. Raises: MappingError: if the number of elements cannot be determined. """ number_of_elements = None ...
python
def _EvaluateNumberOfElements(self, context): """Evaluates number of elements. Args: context (DataTypeMapContext): data type map context. Returns: int: number of elements. Raises: MappingError: if the number of elements cannot be determined. """ number_of_elements = None ...
[ "def", "_EvaluateNumberOfElements", "(", "self", ",", "context", ")", ":", "number_of_elements", "=", "None", "if", "self", ".", "_data_type_definition", ".", "number_of_elements", ":", "number_of_elements", "=", "self", ".", "_data_type_definition", ".", "number_of_e...
Evaluates number of elements. Args: context (DataTypeMapContext): data type map context. Returns: int: number of elements. Raises: MappingError: if the number of elements cannot be determined.
[ "Evaluates", "number", "of", "elements", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L696-L731
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap._GetElementDataTypeDefinition
def _GetElementDataTypeDefinition(self, data_type_definition): """Retrieves the element data type definition. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeDefinition: element data type definition. Raises: FormatError: if the element data ty...
python
def _GetElementDataTypeDefinition(self, data_type_definition): """Retrieves the element data type definition. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeDefinition: element data type definition. Raises: FormatError: if the element data ty...
[ "def", "_GetElementDataTypeDefinition", "(", "self", ",", "data_type_definition", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "element_data_type_definition", "=", "getattr", "(", ...
Retrieves the element data type definition. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeDefinition: element data type definition. Raises: FormatError: if the element data type cannot be determined from the data type definition.
[ "Retrieves", "the", "element", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L733-L755
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
ElementSequenceDataTypeMap.GetSizeHint
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
python
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
[ "def", "GetSizeHint", "(", "self", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "elements_data_size", "=", "self", ".", "GetByteSize", "(", ")"...
Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None.
[ "Retrieves", "a", "hint", "about", "the", "size", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L800-L833
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap._CompositeMapByteStream
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
python
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
[ "def", "_CompositeMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "elements_data_size", "=", "None", "elements_terminator", "=", "None", "number_of_elements", "...
Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: tuple[object, ...]: mapped values. Rai...
[ "Maps", "a", "sequence", "of", "composite", "data", "types", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L909-L1031
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap._LinearFoldByteStream
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
python
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
[ "def", "_LinearFoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "try", ":", "return", "self", ".", "_operation", ".", "WriteTo", "(", "mapped_value", ")", "except", "Exception", "as", "exception", ":", "error_string"...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1033-L1053
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap._LinearMapByteStream
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
python
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
[ "def", "_LinearMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "elements_data_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", ...
Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: tuple[object, ...]: mapped values. Raises: Map...
[ "Maps", "a", "data", "type", "sequence", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1055-L1088
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
SequenceMap.GetStructFormatString
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._element_data_type_map: return None number_of_elements = None if self._data_t...
python
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if not self._element_data_type_map: return None number_of_elements = None if self._data_t...
[ "def", "GetStructFormatString", "(", "self", ")", ":", "if", "not", "self", ".", "_element_data_type_map", ":", "return", "None", "number_of_elements", "=", "None", "if", "self", ".", "_data_type_definition", ".", "elements_data_size", ":", "element_byte_size", "=",...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1105-L1131
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StreamMap.FoldByteStream
def FoldByteStream(self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the...
python
def FoldByteStream(self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "elements_data_size", "=", "self", ".", "_CalculateElementsDataSize", "(", "context", ")", "if", "elements_data_size", "is", "not", ...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1175-L1204
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StreamMap.MapByteStream
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
python
def MapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "size_hints...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: tuple[object, ...]: mapped values. Raises: MappingErr...
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1219-L1289
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
PaddingMap.MapByteStream
def MapByteStream(self, byte_stream, byte_offset=0, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: object: mapped value. Raises: MappingError: i...
python
def MapByteStream(self, byte_stream, byte_offset=0, **unused_kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: object: mapped value. Raises: MappingError: i...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "*", "*", "unused_kwargs", ")", ":", "return", "byte_stream", "[", "byte_offset", ":", "byte_offset", "+", "self", ".", "byte_size", "]" ]
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: object: mapped value. Raises: MappingError: if the data type definition cannot be mapped on the byte stream.
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1355-L1369
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StringMap.FoldByteStream
def FoldByteStream(self, mapped_value, **kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ try: ...
python
def FoldByteStream(self, mapped_value, **kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. """ try: ...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "kwargs", ")", ":", "try", ":", "byte_stream", "=", "mapped_value", ".", "encode", "(", "self", ".", "_data_type_definition", ".", "encoding", ")", "except", "Exception", "as", "except...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1391-L1413
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StringMap.MapByteStream
def MapByteStream(self, byte_stream, byte_offset=0, **kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: str: mapped values. Raises: MappingError: if the dat...
python
def MapByteStream(self, byte_stream, byte_offset=0, **kwargs): """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: str: mapped values. Raises: MappingError: if the dat...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "*", "*", "kwargs", ")", ":", "byte_stream", "=", "super", "(", "StringMap", ",", "self", ")", ".", "MapByteStream", "(", "byte_stream", ",", "byte_offset", "=", ...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. Returns: str: mapped values. Raises: MappingError: if the data type definition cannot be mapped on the byte stream.
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1415-L1458
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._CheckCompositeMap
def _CheckCompositeMap(self, data_type_definition): """Determines if the data type definition needs a composite map. Args: data_type_definition (DataTypeDefinition): structure data type definition. Returns: bool: True if a composite map is needed, False otherwise. Raises: FormatErro...
python
def _CheckCompositeMap(self, data_type_definition): """Determines if the data type definition needs a composite map. Args: data_type_definition (DataTypeDefinition): structure data type definition. Returns: bool: True if a composite map is needed, False otherwise. Raises: FormatErro...
[ "def", "_CheckCompositeMap", "(", "self", ",", "data_type_definition", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "members", "=", "getattr", "(", "data_type_definition", ",", ...
Determines if the data type definition needs a composite map. Args: data_type_definition (DataTypeDefinition): structure data type definition. Returns: bool: True if a composite map is needed, False otherwise. Raises: FormatError: if a composite map is needed cannot be determined from t...
[ "Determines", "if", "the", "data", "type", "definition", "needs", "a", "composite", "map", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1498-L1536
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._CompositeFoldByteStream
def _CompositeFoldByteStream( self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: Fol...
python
def _CompositeFoldByteStream( self, mapped_value, context=None, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: Fol...
[ "def", "_CompositeFoldByteStream", "(", "self", ",", "mapped_value", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "attribute_index", "=", "context_...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. context (Optional[DataTypeMapContext]): data type map context. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1538-L1582
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._CompositeMapByteStream
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
python
def _CompositeMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[...
[ "def", "_CompositeMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "...
Maps a sequence of composite data types on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: object: mapped value. Raises: Ma...
[ "Maps", "a", "sequence", "of", "composite", "data", "types", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1584-L1686
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._GetAttributeNames
def _GetAttributeNames(self, data_type_definition): """Determines the attribute (or field) names of the members. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: list[str]: attribute names. Raises: FormatError: if the attribute names cannot be determin...
python
def _GetAttributeNames(self, data_type_definition): """Determines the attribute (or field) names of the members. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: list[str]: attribute names. Raises: FormatError: if the attribute names cannot be determin...
[ "def", "_GetAttributeNames", "(", "self", ",", "data_type_definition", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "attribute_names", "=", "[", "]", "for", "member_definition", ...
Determines the attribute (or field) names of the members. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: list[str]: attribute names. Raises: FormatError: if the attribute names cannot be determined from the data type definition.
[ "Determines", "the", "attribute", "(", "or", "field", ")", "names", "of", "the", "members", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1688-L1708
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._GetMemberDataTypeMaps
def _GetMemberDataTypeMaps(self, data_type_definition, data_type_map_cache): """Retrieves the member data type maps. Args: data_type_definition (DataTypeDefinition): data type definition. data_type_map_cache (dict[str, DataTypeMap]): cached data type maps. Returns: list[DataTypeMap]: mem...
python
def _GetMemberDataTypeMaps(self, data_type_definition, data_type_map_cache): """Retrieves the member data type maps. Args: data_type_definition (DataTypeDefinition): data type definition. data_type_map_cache (dict[str, DataTypeMap]): cached data type maps. Returns: list[DataTypeMap]: mem...
[ "def", "_GetMemberDataTypeMaps", "(", "self", ",", "data_type_definition", ",", "data_type_map_cache", ")", ":", "if", "not", "data_type_definition", ":", "raise", "errors", ".", "FormatError", "(", "'Missing data type definition'", ")", "members", "=", "getattr", "("...
Retrieves the member data type maps. Args: data_type_definition (DataTypeDefinition): data type definition. data_type_map_cache (dict[str, DataTypeMap]): cached data type maps. Returns: list[DataTypeMap]: member data type maps. Raises: FormatError: if the data type maps cannot be ...
[ "Retrieves", "the", "member", "data", "type", "maps", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1710-L1771
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._LinearFoldByteStream
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
python
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs): """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream. "...
[ "def", "_LinearFoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "try", ":", "attribute_values", "=", "[", "getattr", "(", "mapped_value", ",", "attribute_name", ",", "None", ")", "for", "attribute_name", "in", "self"...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1773-L1798
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap._LinearMapByteStream
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
python
def _LinearMapByteStream( self, byte_stream, byte_offset=0, context=None, **unused_kwargs): """Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContex...
[ "def", "_LinearMapByteStream", "(", "self", ",", "byte_stream", ",", "byte_offset", "=", "0", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "members_data_size", "=", "self", ".", "_data_type_definition", ".", "GetByteSize", "(", ")", ...
Maps a data type sequence on a byte stream. Args: byte_stream (bytes): byte stream. byte_offset (Optional[int]): offset into the byte stream where to start. context (Optional[DataTypeMapContext]): data type map context. Returns: object: mapped value. Raises: MappingError: if...
[ "Maps", "a", "data", "type", "sequence", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1800-L1849
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap.GetSizeHint
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
python
def GetSizeHint(self, context=None, **unused_kwargs): """Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None. """ c...
[ "def", "GetSizeHint", "(", "self", ",", "context", "=", "None", ",", "*", "*", "unused_kwargs", ")", ":", "context_state", "=", "getattr", "(", "context", ",", "'state'", ",", "{", "}", ")", "subcontext", "=", "context_state", ".", "get", "(", "'context'...
Retrieves a hint about the size. Args: context (Optional[DataTypeMapContext]): data type map context, used to determine the size hint. Returns: int: hint of the number of bytes needed from the byte stream or None.
[ "Retrieves", "a", "hint", "about", "the", "size", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1874-L1900
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
StructureMap.GetStructFormatString
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._format_string is None and self._data_type_maps: format_strings = [] for member_data...
python
def GetStructFormatString(self): """Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined. """ if self._format_string is None and self._data_type_maps: format_strings = [] for member_data...
[ "def", "GetStructFormatString", "(", "self", ")", ":", "if", "self", ".", "_format_string", "is", "None", "and", "self", ".", "_data_type_maps", ":", "format_strings", "=", "[", "]", "for", "member_data_type_map", "in", "self", ".", "_data_type_maps", ":", "if...
Retrieves the Python struct format string. Returns: str: format string as used by Python struct or None if format string cannot be determined.
[ "Retrieves", "the", "Python", "struct", "format", "string", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1902-L1923
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
SemanticDataTypeMap.FoldByteStream
def FoldByteStream(self, mapped_value, **unused_kwargs): # pylint: disable=redundant-returns-doc """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded int...
python
def FoldByteStream(self, mapped_value, **unused_kwargs): # pylint: disable=redundant-returns-doc """Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded int...
[ "def", "FoldByteStream", "(", "self", ",", "mapped_value", ",", "*", "*", "unused_kwargs", ")", ":", "# pylint: disable=redundant-returns-doc", "raise", "errors", ".", "FoldingError", "(", "'Unable to fold {0:s} data type into byte stream'", ".", "format", "(", "self", ...
Folds the data type into a byte stream. Args: mapped_value (object): mapped value. Returns: bytes: byte stream. Raises: FoldingError: if the data type definition cannot be folded into the byte stream.
[ "Folds", "the", "data", "type", "into", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1944-L1959
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
SemanticDataTypeMap.MapByteStream
def MapByteStream(self, byte_stream, **unused_kwargs): # pylint: disable=redundant-returns-doc """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. Returns: object: mapped value. Raises: MappingError: if the data type definition cannot be mapped on ...
python
def MapByteStream(self, byte_stream, **unused_kwargs): # pylint: disable=redundant-returns-doc """Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. Returns: object: mapped value. Raises: MappingError: if the data type definition cannot be mapped on ...
[ "def", "MapByteStream", "(", "self", ",", "byte_stream", ",", "*", "*", "unused_kwargs", ")", ":", "# pylint: disable=redundant-returns-doc", "raise", "errors", ".", "MappingError", "(", "'Unable to map {0:s} data type to byte stream'", ".", "format", "(", "self", ".", ...
Maps the data type on a byte stream. Args: byte_stream (bytes): byte stream. Returns: object: mapped value. Raises: MappingError: if the data type definition cannot be mapped on the byte stream.
[ "Maps", "the", "data", "type", "on", "a", "byte", "stream", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1961-L1976
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
EnumerationMap.GetName
def GetName(self, number): """Retrieves the name of an enumeration value by number. Args: number (int): number. Returns: str: name of the enumeration value or None if no corresponding enumeration value was found. """ value = self._data_type_definition.values_per_number.get(nu...
python
def GetName(self, number): """Retrieves the name of an enumeration value by number. Args: number (int): number. Returns: str: name of the enumeration value or None if no corresponding enumeration value was found. """ value = self._data_type_definition.values_per_number.get(nu...
[ "def", "GetName", "(", "self", ",", "number", ")", ":", "value", "=", "self", ".", "_data_type_definition", ".", "values_per_number", ".", "get", "(", "number", ",", "None", ")", "if", "not", "value", ":", "return", "None", "return", "value", ".", "name"...
Retrieves the name of an enumeration value by number. Args: number (int): number. Returns: str: name of the enumeration value or None if no corresponding enumeration value was found.
[ "Retrieves", "the", "name", "of", "an", "enumeration", "value", "by", "number", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L1986-L2000
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
DataTypeMapFactory.CreateDataTypeMap
def CreateDataTypeMap(self, definition_name): """Creates a specific data type map by name. Args: definition_name (str): name of the data type definition. Returns: DataTypeMap: data type map or None if the date type definition is not available. """ data_type_definition = self....
python
def CreateDataTypeMap(self, definition_name): """Creates a specific data type map by name. Args: definition_name (str): name of the data type definition. Returns: DataTypeMap: data type map or None if the date type definition is not available. """ data_type_definition = self....
[ "def", "CreateDataTypeMap", "(", "self", ",", "definition_name", ")", ":", "data_type_definition", "=", "self", ".", "_definitions_registry", ".", "GetDefinitionByName", "(", "definition_name", ")", "if", "not", "data_type_definition", ":", "return", "None", "return",...
Creates a specific data type map by name. Args: definition_name (str): name of the data type definition. Returns: DataTypeMap: data type map or None if the date type definition is not available.
[ "Creates", "a", "specific", "data", "type", "map", "by", "name", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L2032-L2047
train
libyal/dtfabric
dtfabric/runtime/data_maps.py
DataTypeMapFactory.CreateDataTypeMapByType
def CreateDataTypeMapByType(cls, data_type_definition): """Creates a specific data type map by type indicator. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeMap: data type map or None if the date type definition is not available. """ ...
python
def CreateDataTypeMapByType(cls, data_type_definition): """Creates a specific data type map by type indicator. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeMap: data type map or None if the date type definition is not available. """ ...
[ "def", "CreateDataTypeMapByType", "(", "cls", ",", "data_type_definition", ")", ":", "data_type_map_class", "=", "cls", ".", "_MAP_PER_DEFINITION", ".", "get", "(", "data_type_definition", ".", "TYPE_INDICATOR", ",", "None", ")", "if", "not", "data_type_map_class", ...
Creates a specific data type map by type indicator. Args: data_type_definition (DataTypeDefinition): data type definition. Returns: DataTypeMap: data type map or None if the date type definition is not available.
[ "Creates", "a", "specific", "data", "type", "map", "by", "type", "indicator", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/runtime/data_maps.py#L2050-L2065
train
libyal/dtfabric
dtfabric/data_types.py
FixedSizeDataTypeDefinition.GetByteSize
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if self.size == definitions.SIZE_NATIVE or self.units != 'bytes': return None return self.size
python
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if self.size == definitions.SIZE_NATIVE or self.units != 'bytes': return None return self.size
[ "def", "GetByteSize", "(", "self", ")", ":", "if", "self", ".", "size", "==", "definitions", ".", "SIZE_NATIVE", "or", "self", ".", "units", "!=", "'bytes'", ":", "return", "None", "return", "self", ".", "size" ]
Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined.
[ "Retrieves", "the", "byte", "size", "of", "the", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L119-L128
train
libyal/dtfabric
dtfabric/data_types.py
ElementSequenceDataTypeDefinition.GetByteSize
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if not self.element_data_type_definition: return None if self.elements_data_size: return self.elements_data_size if ...
python
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if not self.element_data_type_definition: return None if self.elements_data_size: return self.elements_data_size if ...
[ "def", "GetByteSize", "(", "self", ")", ":", "if", "not", "self", ".", "element_data_type_definition", ":", "return", "None", "if", "self", ".", "elements_data_size", ":", "return", "self", ".", "elements_data_size", "if", "not", "self", ".", "number_of_elements...
Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined.
[ "Retrieves", "the", "byte", "size", "of", "the", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L306-L325
train
libyal/dtfabric
dtfabric/data_types.py
DataTypeDefinitionWithMembers.AddMemberDefinition
def AddMemberDefinition(self, member_definition): """Adds a member definition. Args: member_definition (DataTypeDefinition): member data type definition. """ self._byte_size = None self.members.append(member_definition) if self.sections: section_definition = self.sections[-1] ...
python
def AddMemberDefinition(self, member_definition): """Adds a member definition. Args: member_definition (DataTypeDefinition): member data type definition. """ self._byte_size = None self.members.append(member_definition) if self.sections: section_definition = self.sections[-1] ...
[ "def", "AddMemberDefinition", "(", "self", ",", "member_definition", ")", ":", "self", ".", "_byte_size", "=", "None", "self", ".", "members", ".", "append", "(", "member_definition", ")", "if", "self", ".", "sections", ":", "section_definition", "=", "self", ...
Adds a member definition. Args: member_definition (DataTypeDefinition): member data type definition.
[ "Adds", "a", "member", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L398-L409
train
libyal/dtfabric
dtfabric/data_types.py
MemberDataTypeDefinition.IsComposite
def IsComposite(self): """Determines if the data type is composite. A composite data type consists of other data types. Returns: bool: True if the data type is composite, False otherwise. """ return bool(self.condition) or ( self.member_data_type_definition and self.member_da...
python
def IsComposite(self): """Determines if the data type is composite. A composite data type consists of other data types. Returns: bool: True if the data type is composite, False otherwise. """ return bool(self.condition) or ( self.member_data_type_definition and self.member_da...
[ "def", "IsComposite", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "condition", ")", "or", "(", "self", ".", "member_data_type_definition", "and", "self", ".", "member_data_type_definition", ".", "IsComposite", "(", ")", ")" ]
Determines if the data type is composite. A composite data type consists of other data types. Returns: bool: True if the data type is composite, False otherwise.
[ "Determines", "if", "the", "data", "type", "is", "composite", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L476-L486
train
libyal/dtfabric
dtfabric/data_types.py
StructureDefinition.GetByteSize
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if self._byte_size is None and self.members: self._byte_size = 0 for member_definition in self.members: if isinstance(...
python
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if self._byte_size is None and self.members: self._byte_size = 0 for member_definition in self.members: if isinstance(...
[ "def", "GetByteSize", "(", "self", ")", ":", "if", "self", ".", "_byte_size", "is", "None", "and", "self", ".", "members", ":", "self", ".", "_byte_size", "=", "0", "for", "member_definition", "in", "self", ".", "members", ":", "if", "isinstance", "(", ...
Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined.
[ "Retrieves", "the", "byte", "size", "of", "the", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L531-L554
train
libyal/dtfabric
dtfabric/data_types.py
UnionDefinition.GetByteSize
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if self._byte_size is None and self.members: self._byte_size = 0 for member_definition in self.members: byte_size = me...
python
def GetByteSize(self): """Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined. """ if self._byte_size is None and self.members: self._byte_size = 0 for member_definition in self.members: byte_size = me...
[ "def", "GetByteSize", "(", "self", ")", ":", "if", "self", ".", "_byte_size", "is", "None", "and", "self", ".", "members", ":", "self", ".", "_byte_size", "=", "0", "for", "member_definition", "in", "self", ".", "members", ":", "byte_size", "=", "member_...
Retrieves the byte size of the data type definition. Returns: int: data type size in bytes or None if size cannot be determined.
[ "Retrieves", "the", "byte", "size", "of", "the", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L562-L578
train
libyal/dtfabric
dtfabric/data_types.py
EnumerationDefinition.AddValue
def AddValue(self, name, number, aliases=None, description=None): """Adds an enumeration value. Args: name (str): name. number (int): number. aliases (Optional[list[str]]): aliases. description (Optional[str]): description. Raises: KeyError: if the enumeration value already e...
python
def AddValue(self, name, number, aliases=None, description=None): """Adds an enumeration value. Args: name (str): name. number (int): number. aliases (Optional[list[str]]): aliases. description (Optional[str]): description. Raises: KeyError: if the enumeration value already e...
[ "def", "AddValue", "(", "self", ",", "name", ",", "number", ",", "aliases", "=", "None", ",", "description", "=", "None", ")", ":", "if", "name", "in", "self", ".", "values_per_name", ":", "raise", "KeyError", "(", "'Value with name: {0:s} already exists.'", ...
Adds an enumeration value. Args: name (str): name. number (int): number. aliases (Optional[list[str]]): aliases. description (Optional[str]): description. Raises: KeyError: if the enumeration value already exists.
[ "Adds", "an", "enumeration", "value", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L677-L707
train
libyal/dtfabric
dtfabric/data_types.py
StructureFamilyDefinition.AddMemberDefinition
def AddMemberDefinition(self, member_definition): """Adds a member definition. Args: member_definition (DataTypeDefinition): member data type definition. """ self.members.append(member_definition) member_definition.family_definition = self
python
def AddMemberDefinition(self, member_definition): """Adds a member definition. Args: member_definition (DataTypeDefinition): member data type definition. """ self.members.append(member_definition) member_definition.family_definition = self
[ "def", "AddMemberDefinition", "(", "self", ",", "member_definition", ")", ":", "self", ".", "members", ".", "append", "(", "member_definition", ")", "member_definition", ".", "family_definition", "=", "self" ]
Adds a member definition. Args: member_definition (DataTypeDefinition): member data type definition.
[ "Adds", "a", "member", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/data_types.py#L771-L778
train
dlanger/inlinestyler
inlinestyler/cssselect.py
parse_series
def parse_series(s): """ Parses things like '1n+2', or 'an+b' generally, returning (a, b) """ if isinstance(s, Element): s = s._format_element() if not s or s == '*': # Happens when there's nothing, which the CSS parser thinks of as * return (0, 0) if isinstance(s, int): ...
python
def parse_series(s): """ Parses things like '1n+2', or 'an+b' generally, returning (a, b) """ if isinstance(s, Element): s = s._format_element() if not s or s == '*': # Happens when there's nothing, which the CSS parser thinks of as * return (0, 0) if isinstance(s, int): ...
[ "def", "parse_series", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "Element", ")", ":", "s", "=", "s", ".", "_format_element", "(", ")", "if", "not", "s", "or", "s", "==", "'*'", ":", "# Happens when there's nothing, which the CSS parser thinks of...
Parses things like '1n+2', or 'an+b' generally, returning (a, b)
[ "Parses", "things", "like", "1n", "+", "2", "or", "an", "+", "b", "generally", "returning", "(", "a", "b", ")" ]
335c4fbab892f0ed67466a6beaea6a91f395ad12
https://github.com/dlanger/inlinestyler/blob/335c4fbab892f0ed67466a6beaea6a91f395ad12/inlinestyler/cssselect.py#L776-L810
train
dlanger/inlinestyler
inlinestyler/cssselect.py
XPathExpr.add_star_prefix
def add_star_prefix(self): """ Adds a /* prefix if there is no prefix. This is when you need to keep context's constrained to a single parent. """ if self.path: self.path += '*/' else: self.path = '*/' self.star_prefix = True
python
def add_star_prefix(self): """ Adds a /* prefix if there is no prefix. This is when you need to keep context's constrained to a single parent. """ if self.path: self.path += '*/' else: self.path = '*/' self.star_prefix = True
[ "def", "add_star_prefix", "(", "self", ")", ":", "if", "self", ".", "path", ":", "self", ".", "path", "+=", "'*/'", "else", ":", "self", ".", "path", "=", "'*/'", "self", ".", "star_prefix", "=", "True" ]
Adds a /* prefix if there is no prefix. This is when you need to keep context's constrained to a single parent.
[ "Adds", "a", "/", "*", "prefix", "if", "there", "is", "no", "prefix", ".", "This", "is", "when", "you", "need", "to", "keep", "context", "s", "constrained", "to", "a", "single", "parent", "." ]
335c4fbab892f0ed67466a6beaea6a91f395ad12
https://github.com/dlanger/inlinestyler/blob/335c4fbab892f0ed67466a6beaea6a91f395ad12/inlinestyler/cssselect.py#L580-L589
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadBooleanDataTypeDefinition
def _ReadBooleanDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads a boolean data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str,...
python
def _ReadBooleanDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads a boolean data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str,...
[ "def", "_ReadBooleanDataTypeDefinition", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "definition_name", ",", "is_member", "=", "False", ")", ":", "return", "self", ".", "_ReadFixedSizeDataTypeDefinition", "(", "definitions_registry", ",", "d...
Reads a boolean data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. definition_name (str): name of the definition. is_member (Optional[bool]): True if the data typ...
[ "Reads", "a", "boolean", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L102-L122
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadCharacterDataTypeDefinition
def _ReadCharacterDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads a character data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[...
python
def _ReadCharacterDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads a character data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[...
[ "def", "_ReadCharacterDataTypeDefinition", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "definition_name", ",", "is_member", "=", "False", ")", ":", "return", "self", ".", "_ReadFixedSizeDataTypeDefinition", "(", "definitions_registry", ",", ...
Reads a character data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. definition_name (str): name of the definition. is_member (Optional[bool]): True if the data t...
[ "Reads", "a", "character", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L124-L144
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadConstantDataTypeDefinition
def _ReadConstantDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads a constant data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[st...
python
def _ReadConstantDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads a constant data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[st...
[ "def", "_ReadConstantDataTypeDefinition", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "definition_name", ",", "is_member", "=", "False", ")", ":", "if", "is_member", ":", "error_message", "=", "'data type not supported as member'", "raise", ...
Reads a constant data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. definition_name (str): name of the definition. is_member (Optional[bool]): True if the data ty...
[ "Reads", "a", "constant", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L146-L180
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadDataTypeDefinition
def _ReadDataTypeDefinition( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supported_definition_values): """Reads a data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. def...
python
def _ReadDataTypeDefinition( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supported_definition_values): """Reads a data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. def...
[ "def", "_ReadDataTypeDefinition", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "data_type_definition_class", ",", "definition_name", ",", "supported_definition_values", ")", ":", "aliases", "=", "definition_values", ".", "get", "(", "'aliases'"...
Reads a data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. data_type_definition_class (str): data type definition class. definition_name (str): name of the defini...
[ "Reads", "a", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L184-L217
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadDataTypeDefinitionWithMembers
def _ReadDataTypeDefinitionWithMembers( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supports_conditions=False): """Reads a data type definition with members. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions ...
python
def _ReadDataTypeDefinitionWithMembers( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supports_conditions=False): """Reads a data type definition with members. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions ...
[ "def", "_ReadDataTypeDefinitionWithMembers", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "data_type_definition_class", ",", "definition_name", ",", "supports_conditions", "=", "False", ")", ":", "members", "=", "definition_values", ".", "get",...
Reads a data type definition with members. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. data_type_definition_class (str): data type definition class. definition_name (str): name ...
[ "Reads", "a", "data", "type", "definition", "with", "members", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L219-L279
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadEnumerationDataTypeDefinition
def _ReadEnumerationDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads an enumeration data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (...
python
def _ReadEnumerationDataTypeDefinition( self, definitions_registry, definition_values, definition_name, is_member=False): """Reads an enumeration data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (...
[ "def", "_ReadEnumerationDataTypeDefinition", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "definition_name", ",", "is_member", "=", "False", ")", ":", "if", "is_member", ":", "error_message", "=", "'data type not supported as member'", "raise",...
Reads an enumeration data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. definition_name (str): name of the definition. is_member (Optional[bool]): True if the dat...
[ "Reads", "an", "enumeration", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L281-L341
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadElementSequenceDataTypeDefinition
def _ReadElementSequenceDataTypeDefinition( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supported_definition_values): """Reads an element sequence data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definiti...
python
def _ReadElementSequenceDataTypeDefinition( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supported_definition_values): """Reads an element sequence data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definiti...
[ "def", "_ReadElementSequenceDataTypeDefinition", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "data_type_definition_class", ",", "definition_name", ",", "supported_definition_values", ")", ":", "unsupported_definition_values", "=", "set", "(", "def...
Reads an element sequence data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. data_type_definition_class (str): data type definition class. definition_name (str): ...
[ "Reads", "an", "element", "sequence", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L343-L437
train
libyal/dtfabric
dtfabric/reader.py
DataTypeDefinitionsReader._ReadFixedSizeDataTypeDefinition
def _ReadFixedSizeDataTypeDefinition( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supported_attributes, default_size=definitions.SIZE_NATIVE, default_units='bytes', is_member=False, supported_size_values=None): """Reads a fixed-size data type d...
python
def _ReadFixedSizeDataTypeDefinition( self, definitions_registry, definition_values, data_type_definition_class, definition_name, supported_attributes, default_size=definitions.SIZE_NATIVE, default_units='bytes', is_member=False, supported_size_values=None): """Reads a fixed-size data type d...
[ "def", "_ReadFixedSizeDataTypeDefinition", "(", "self", ",", "definitions_registry", ",", "definition_values", ",", "data_type_definition_class", ",", "definition_name", ",", "supported_attributes", ",", "default_size", "=", "definitions", ".", "SIZE_NATIVE", ",", "default_...
Reads a fixed-size data type definition. Args: definitions_registry (DataTypeDefinitionsRegistry): data type definitions registry. definition_values (dict[str, object]): definition values. data_type_definition_class (str): data type definition class. definition_name (str): name of...
[ "Reads", "a", "fixed", "-", "size", "data", "type", "definition", "." ]
0d2b5719fa257f6e5c661a406737ebcf8c8db266
https://github.com/libyal/dtfabric/blob/0d2b5719fa257f6e5c661a406737ebcf8c8db266/dtfabric/reader.py#L439-L488
train