id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
52,800
HacKanCuBa/passphrase-py
passphrase/calc.py
entropy_bits_nrange
def entropy_bits_nrange( minimum: Union[int, float], maximum: Union[int, float] ) -> float: """Calculate the number of entropy bits in a range of numbers.""" # Shannon: # d = fabs(maximum - minimum) # ent = -(1/d) * log(1/d, 2) * d # Aprox form: log10(digits) * log2(10) if not isinstance...
python
def entropy_bits_nrange( minimum: Union[int, float], maximum: Union[int, float] ) -> float: """Calculate the number of entropy bits in a range of numbers.""" # Shannon: # d = fabs(maximum - minimum) # ent = -(1/d) * log(1/d, 2) * d # Aprox form: log10(digits) * log2(10) if not isinstance...
[ "def", "entropy_bits_nrange", "(", "minimum", ":", "Union", "[", "int", ",", "float", "]", ",", "maximum", ":", "Union", "[", "int", ",", "float", "]", ")", "->", "float", ":", "# Shannon:", "# d = fabs(maximum - minimum)", "# ent = -(1/d) * log(1/d, 2) * d", "#...
Calculate the number of entropy bits in a range of numbers.
[ "Calculate", "the", "number", "of", "entropy", "bits", "in", "a", "range", "of", "numbers", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/calc.py#L62-L84
52,801
HacKanCuBa/passphrase-py
passphrase/calc.py
password_length_needed
def password_length_needed(entropybits: Union[int, float], chars: str) -> int: """Calculate the length of a password for a given entropy and chars.""" if not isinstance(entropybits, (int, float)): raise TypeError('entropybits can only be int or float') if entropybits < 0: raise ValueError('e...
python
def password_length_needed(entropybits: Union[int, float], chars: str) -> int: """Calculate the length of a password for a given entropy and chars.""" if not isinstance(entropybits, (int, float)): raise TypeError('entropybits can only be int or float') if entropybits < 0: raise ValueError('e...
[ "def", "password_length_needed", "(", "entropybits", ":", "Union", "[", "int", ",", "float", "]", ",", "chars", ":", "str", ")", "->", "int", ":", "if", "not", "isinstance", "(", "entropybits", ",", "(", "int", ",", "float", ")", ")", ":", "raise", "...
Calculate the length of a password for a given entropy and chars.
[ "Calculate", "the", "length", "of", "a", "password", "for", "a", "given", "entropy", "and", "chars", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/calc.py#L87-L100
52,802
HacKanCuBa/passphrase-py
passphrase/calc.py
words_amount_needed
def words_amount_needed(entropybits: Union[int, float], entropy_w: Union[int, float], entropy_n: Union[int, float], amount_n: int) -> int: """Calculate words needed for a passphrase based on entropy.""" # Thanks to @julianor for this tip to...
python
def words_amount_needed(entropybits: Union[int, float], entropy_w: Union[int, float], entropy_n: Union[int, float], amount_n: int) -> int: """Calculate words needed for a passphrase based on entropy.""" # Thanks to @julianor for this tip to...
[ "def", "words_amount_needed", "(", "entropybits", ":", "Union", "[", "int", ",", "float", "]", ",", "entropy_w", ":", "Union", "[", "int", ",", "float", "]", ",", "entropy_n", ":", "Union", "[", "int", ",", "float", "]", ",", "amount_n", ":", "int", ...
Calculate words needed for a passphrase based on entropy.
[ "Calculate", "words", "needed", "for", "a", "passphrase", "based", "on", "entropy", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/calc.py#L103-L136
52,803
HacKanCuBa/passphrase-py
passphrase/calc.py
password_entropy
def password_entropy(length: int, chars: str) -> float: """Calculate the entropy of a password with given length and chars.""" if not isinstance(length, int): raise TypeError('length can only be int') if length < 0: raise ValueError('length should be greater than 0') if not isinstance(ch...
python
def password_entropy(length: int, chars: str) -> float: """Calculate the entropy of a password with given length and chars.""" if not isinstance(length, int): raise TypeError('length can only be int') if length < 0: raise ValueError('length should be greater than 0') if not isinstance(ch...
[ "def", "password_entropy", "(", "length", ":", "int", ",", "chars", ":", "str", ")", "->", "float", ":", "if", "not", "isinstance", "(", "length", ",", "int", ")", ":", "raise", "TypeError", "(", "'length can only be int'", ")", "if", "length", "<", "0",...
Calculate the entropy of a password with given length and chars.
[ "Calculate", "the", "entropy", "of", "a", "password", "with", "given", "length", "and", "chars", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/calc.py#L139-L154
52,804
HacKanCuBa/passphrase-py
passphrase/calc.py
passphrase_entropy
def passphrase_entropy(amount_w: int, entropy_w: Union[int, float], entropy_n: Union[int, float], amount_n: int) -> float: """Calculate the entropy of a passphrase with given words and numbers.""" if not isinstance(amount_w, int): rais...
python
def passphrase_entropy(amount_w: int, entropy_w: Union[int, float], entropy_n: Union[int, float], amount_n: int) -> float: """Calculate the entropy of a passphrase with given words and numbers.""" if not isinstance(amount_w, int): rais...
[ "def", "passphrase_entropy", "(", "amount_w", ":", "int", ",", "entropy_w", ":", "Union", "[", "int", ",", "float", "]", ",", "entropy_n", ":", "Union", "[", "int", ",", "float", "]", ",", "amount_n", ":", "int", ")", "->", "float", ":", "if", "not",...
Calculate the entropy of a passphrase with given words and numbers.
[ "Calculate", "the", "entropy", "of", "a", "passphrase", "with", "given", "words", "and", "numbers", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/calc.py#L157-L179
52,805
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.entropy_bits
def entropy_bits( lst: Union[ List[Union[int, str, float, complex]], Tuple[Union[int, str, float, complex]] ] ) -> float: """Calculate the entropy of a wordlist or a numerical range. Keyword arguments: lst -- A wordlist as list or tupl...
python
def entropy_bits( lst: Union[ List[Union[int, str, float, complex]], Tuple[Union[int, str, float, complex]] ] ) -> float: """Calculate the entropy of a wordlist or a numerical range. Keyword arguments: lst -- A wordlist as list or tupl...
[ "def", "entropy_bits", "(", "lst", ":", "Union", "[", "List", "[", "Union", "[", "int", ",", "str", ",", "float", ",", "complex", "]", "]", ",", "Tuple", "[", "Union", "[", "int", ",", "str", ",", "float", ",", "complex", "]", "]", "]", ")", "-...
Calculate the entropy of a wordlist or a numerical range. Keyword arguments: lst -- A wordlist as list or tuple, or a numerical range as a list: (minimum, maximum)
[ "Calculate", "the", "entropy", "of", "a", "wordlist", "or", "a", "numerical", "range", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L269-L293
52,806
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.import_words_from_file
def import_words_from_file(self, inputfile: str, is_diceware: bool) -> None: """Import words for the wordlist from a given file. The file can have a single column with words or be diceware-like (two columns). Keyword argumen...
python
def import_words_from_file(self, inputfile: str, is_diceware: bool) -> None: """Import words for the wordlist from a given file. The file can have a single column with words or be diceware-like (two columns). Keyword argumen...
[ "def", "import_words_from_file", "(", "self", ",", "inputfile", ":", "str", ",", "is_diceware", ":", "bool", ")", "->", "None", ":", "if", "not", "Aux", ".", "isfile_notempty", "(", "inputfile", ")", ":", "raise", "FileNotFoundError", "(", "'Input file does no...
Import words for the wordlist from a given file. The file can have a single column with words or be diceware-like (two columns). Keyword arguments: inputfile -- A string with the path to the wordlist file to load, or the value 'internal' to load the internal one. is_dic...
[ "Import", "words", "for", "the", "wordlist", "from", "a", "given", "file", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L300-L322
52,807
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.password_length_needed
def password_length_needed(self) -> int: """Calculate the needed password length to satisfy the entropy number. This is for the given character set. """ characters = self._get_password_characters() if ( self.entropy_bits_req is None or not charac...
python
def password_length_needed(self) -> int: """Calculate the needed password length to satisfy the entropy number. This is for the given character set. """ characters = self._get_password_characters() if ( self.entropy_bits_req is None or not charac...
[ "def", "password_length_needed", "(", "self", ")", "->", "int", ":", "characters", "=", "self", ".", "_get_password_characters", "(", ")", "if", "(", "self", ".", "entropy_bits_req", "is", "None", "or", "not", "characters", ")", ":", "raise", "ValueError", "...
Calculate the needed password length to satisfy the entropy number. This is for the given character set.
[ "Calculate", "the", "needed", "password", "length", "to", "satisfy", "the", "entropy", "number", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L324-L342
52,808
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.words_amount_needed
def words_amount_needed(self) -> int: """Calculate the needed amount of words to satisfy the entropy number. This is for the given wordlist. """ if ( self.entropy_bits_req is None or self.amount_n is None or not self.wordlist ): ...
python
def words_amount_needed(self) -> int: """Calculate the needed amount of words to satisfy the entropy number. This is for the given wordlist. """ if ( self.entropy_bits_req is None or self.amount_n is None or not self.wordlist ): ...
[ "def", "words_amount_needed", "(", "self", ")", "->", "int", ":", "if", "(", "self", ".", "entropy_bits_req", "is", "None", "or", "self", ".", "amount_n", "is", "None", "or", "not", "self", ".", "wordlist", ")", ":", "raise", "ValueError", "(", "\"Can't ...
Calculate the needed amount of words to satisfy the entropy number. This is for the given wordlist.
[ "Calculate", "the", "needed", "amount", "of", "words", "to", "satisfy", "the", "entropy", "number", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L344-L376
52,809
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.generated_password_entropy
def generated_password_entropy(self) -> float: """Calculate the entropy of a password that would be generated.""" characters = self._get_password_characters() if ( self.passwordlen is None or not characters ): raise ValueError("Can't calculate ...
python
def generated_password_entropy(self) -> float: """Calculate the entropy of a password that would be generated.""" characters = self._get_password_characters() if ( self.passwordlen is None or not characters ): raise ValueError("Can't calculate ...
[ "def", "generated_password_entropy", "(", "self", ")", "->", "float", ":", "characters", "=", "self", ".", "_get_password_characters", "(", ")", "if", "(", "self", ".", "passwordlen", "is", "None", "or", "not", "characters", ")", ":", "raise", "ValueError", ...
Calculate the entropy of a password that would be generated.
[ "Calculate", "the", "entropy", "of", "a", "password", "that", "would", "be", "generated", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L378-L391
52,810
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.generated_passphrase_entropy
def generated_passphrase_entropy(self) -> float: """Calculate the entropy of a passphrase that would be generated.""" if ( self.amount_w is None or self.amount_n is None or not self.wordlist ): raise ValueError("Can't calculate the pass...
python
def generated_passphrase_entropy(self) -> float: """Calculate the entropy of a passphrase that would be generated.""" if ( self.amount_w is None or self.amount_n is None or not self.wordlist ): raise ValueError("Can't calculate the pass...
[ "def", "generated_passphrase_entropy", "(", "self", ")", "->", "float", ":", "if", "(", "self", ".", "amount_w", "is", "None", "or", "self", ".", "amount_n", "is", "None", "or", "not", "self", ".", "wordlist", ")", ":", "raise", "ValueError", "(", "\"Can...
Calculate the entropy of a passphrase that would be generated.
[ "Calculate", "the", "entropy", "of", "a", "passphrase", "that", "would", "be", "generated", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L393-L419
52,811
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.generate
def generate(self, uppercase: int = None) -> list: """Generate a list of words randomly chosen from a wordlist. Keyword arguments: uppercase -- An integer number indicating how many uppercase characters are wanted: bigger than zero means that many characters and lower than zero ...
python
def generate(self, uppercase: int = None) -> list: """Generate a list of words randomly chosen from a wordlist. Keyword arguments: uppercase -- An integer number indicating how many uppercase characters are wanted: bigger than zero means that many characters and lower than zero ...
[ "def", "generate", "(", "self", ",", "uppercase", ":", "int", "=", "None", ")", "->", "list", ":", "if", "(", "self", ".", "amount_n", "is", "None", "or", "self", ".", "amount_w", "is", "None", "or", "not", "self", ".", "wordlist", ")", ":", "raise...
Generate a list of words randomly chosen from a wordlist. Keyword arguments: uppercase -- An integer number indicating how many uppercase characters are wanted: bigger than zero means that many characters and lower than zero means all uppercase except that many. Use 0 to make th...
[ "Generate", "a", "list", "of", "words", "randomly", "chosen", "from", "a", "wordlist", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L421-L471
52,812
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.generate_password
def generate_password(self) -> list: """Generate a list of random characters.""" characterset = self._get_password_characters() if ( self.passwordlen is None or not characterset ): raise ValueError("Can't generate password: character set is " ...
python
def generate_password(self) -> list: """Generate a list of random characters.""" characterset = self._get_password_characters() if ( self.passwordlen is None or not characterset ): raise ValueError("Can't generate password: character set is " ...
[ "def", "generate_password", "(", "self", ")", "->", "list", ":", "characterset", "=", "self", ".", "_get_password_characters", "(", ")", "if", "(", "self", ".", "passwordlen", "is", "None", "or", "not", "characterset", ")", ":", "raise", "ValueError", "(", ...
Generate a list of random characters.
[ "Generate", "a", "list", "of", "random", "characters", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L473-L488
52,813
HacKanCuBa/passphrase-py
passphrase/passphrase.py
Passphrase.generate_uuid4
def generate_uuid4(self) -> list: """Generate a list of parts of a UUID version 4 string. Usually, these parts are concatenated together using dashes. """ # uuid4: 8-4-4-4-12: xxxxxxxx-xxxx-4xxx-{8,9,a,b}xxx-xxxxxxxxxxxx # instead of requesting small amounts of bytes, it's bett...
python
def generate_uuid4(self) -> list: """Generate a list of parts of a UUID version 4 string. Usually, these parts are concatenated together using dashes. """ # uuid4: 8-4-4-4-12: xxxxxxxx-xxxx-4xxx-{8,9,a,b}xxx-xxxxxxxxxxxx # instead of requesting small amounts of bytes, it's bett...
[ "def", "generate_uuid4", "(", "self", ")", "->", "list", ":", "# uuid4: 8-4-4-4-12: xxxxxxxx-xxxx-4xxx-{8,9,a,b}xxx-xxxxxxxxxxxx", "# instead of requesting small amounts of bytes, it's better to do it", "# for the full amount of them.", "hexstr", "=", "randhex", "(", "30", ")", "uu...
Generate a list of parts of a UUID version 4 string. Usually, these parts are concatenated together using dashes.
[ "Generate", "a", "list", "of", "parts", "of", "a", "UUID", "version", "4", "string", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/passphrase.py#L490-L509
52,814
fdiskyou/kcshell
kcshell/assembler.py
Assembler.default
def default(self, line): ''' if no other commands was invoked ''' try: encoding, count = self._ks.asm(line) machine_code = "" for opcode in encoding: machine_code += "\\x" + hexlify(pack("B", opcode)).decode() print("\"" + machine_code + "\...
python
def default(self, line): ''' if no other commands was invoked ''' try: encoding, count = self._ks.asm(line) machine_code = "" for opcode in encoding: machine_code += "\\x" + hexlify(pack("B", opcode)).decode() print("\"" + machine_code + "\...
[ "def", "default", "(", "self", ",", "line", ")", ":", "try", ":", "encoding", ",", "count", "=", "self", ".", "_ks", ".", "asm", "(", "line", ")", "machine_code", "=", "\"\"", "for", "opcode", "in", "encoding", ":", "machine_code", "+=", "\"\\\\x\"", ...
if no other commands was invoked
[ "if", "no", "other", "commands", "was", "invoked" ]
f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f
https://github.com/fdiskyou/kcshell/blob/f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f/kcshell/assembler.py#L55-L64
52,815
HacKanCuBa/passphrase-py
passphrase/__main__.py
_bigger_than_zero
def _bigger_than_zero(value: str) -> int: """Type evaluator for argparse.""" ivalue = int(value) if ivalue < 0: raise ArgumentTypeError( '{} should be bigger than 0'.format(ivalue) ) return ivalue
python
def _bigger_than_zero(value: str) -> int: """Type evaluator for argparse.""" ivalue = int(value) if ivalue < 0: raise ArgumentTypeError( '{} should be bigger than 0'.format(ivalue) ) return ivalue
[ "def", "_bigger_than_zero", "(", "value", ":", "str", ")", "->", "int", ":", "ivalue", "=", "int", "(", "value", ")", "if", "ivalue", "<", "0", ":", "raise", "ArgumentTypeError", "(", "'{} should be bigger than 0'", ".", "format", "(", "ivalue", ")", ")", ...
Type evaluator for argparse.
[ "Type", "evaluator", "for", "argparse", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/__main__.py#L51-L58
52,816
yinkh/django-popup-field
popup_field/views.py
PopupCRUDViewSet.get_fk_popup_field
def get_fk_popup_field(cls, *args, **kwargs): """ generate fk field related to class wait popup crud """ kwargs['popup_name'] = cls.get_class_verbose_name() kwargs['permissions_required'] = cls.permissions_required if cls.template_name_fk is not None: kwargs['...
python
def get_fk_popup_field(cls, *args, **kwargs): """ generate fk field related to class wait popup crud """ kwargs['popup_name'] = cls.get_class_verbose_name() kwargs['permissions_required'] = cls.permissions_required if cls.template_name_fk is not None: kwargs['...
[ "def", "get_fk_popup_field", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'popup_name'", "]", "=", "cls", ".", "get_class_verbose_name", "(", ")", "kwargs", "[", "'permissions_required'", "]", "=", "cls", ".", "permissio...
generate fk field related to class wait popup crud
[ "generate", "fk", "field", "related", "to", "class", "wait", "popup", "crud" ]
0b9284c039a7c6453a3e0bb877010d67cc3d83dd
https://github.com/yinkh/django-popup-field/blob/0b9284c039a7c6453a3e0bb877010d67cc3d83dd/popup_field/views.py#L209-L217
52,817
yinkh/django-popup-field
popup_field/views.py
PopupCRUDViewSet.get_m2m_popup_field
def get_m2m_popup_field(cls, *args, **kwargs): """ generate m2m field related to class wait popup crud """ kwargs['popup_name'] = cls.get_class_verbose_name() kwargs['permissions_required'] = cls.permissions_required if cls.template_name_m2m is not None: kwarg...
python
def get_m2m_popup_field(cls, *args, **kwargs): """ generate m2m field related to class wait popup crud """ kwargs['popup_name'] = cls.get_class_verbose_name() kwargs['permissions_required'] = cls.permissions_required if cls.template_name_m2m is not None: kwarg...
[ "def", "get_m2m_popup_field", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'popup_name'", "]", "=", "cls", ".", "get_class_verbose_name", "(", ")", "kwargs", "[", "'permissions_required'", "]", "=", "cls", ".", "permissi...
generate m2m field related to class wait popup crud
[ "generate", "m2m", "field", "related", "to", "class", "wait", "popup", "crud" ]
0b9284c039a7c6453a3e0bb877010d67cc3d83dd
https://github.com/yinkh/django-popup-field/blob/0b9284c039a7c6453a3e0bb877010d67cc3d83dd/popup_field/views.py#L220-L228
52,818
HacKanCuBa/passphrase-py
passphrase/aux.py
Aux.make_all_uppercase
def make_all_uppercase( lst: Union[list, tuple, str, set] ) -> Union[list, tuple, str, set]: """Make all characters uppercase. It supports characters in a (mix of) list, tuple, set or string. The return value is of the same type of the input value. """ if not is...
python
def make_all_uppercase( lst: Union[list, tuple, str, set] ) -> Union[list, tuple, str, set]: """Make all characters uppercase. It supports characters in a (mix of) list, tuple, set or string. The return value is of the same type of the input value. """ if not is...
[ "def", "make_all_uppercase", "(", "lst", ":", "Union", "[", "list", ",", "tuple", ",", "str", ",", "set", "]", ")", "->", "Union", "[", "list", ",", "tuple", ",", "str", ",", "set", "]", ":", "if", "not", "isinstance", "(", "lst", ",", "(", "list...
Make all characters uppercase. It supports characters in a (mix of) list, tuple, set or string. The return value is of the same type of the input value.
[ "Make", "all", "characters", "uppercase", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/aux.py#L68-L100
52,819
HacKanCuBa/passphrase-py
passphrase/aux.py
Aux._make_one_char_uppercase
def _make_one_char_uppercase(string: str) -> str: """Make a single char from the string uppercase.""" if not isinstance(string, str): raise TypeError('string must be a string') if Aux.lowercase_count(string) > 0: while True: cindex = randbelow(len(string)...
python
def _make_one_char_uppercase(string: str) -> str: """Make a single char from the string uppercase.""" if not isinstance(string, str): raise TypeError('string must be a string') if Aux.lowercase_count(string) > 0: while True: cindex = randbelow(len(string)...
[ "def", "_make_one_char_uppercase", "(", "string", ":", "str", ")", "->", "str", ":", "if", "not", "isinstance", "(", "string", ",", "str", ")", ":", "raise", "TypeError", "(", "'string must be a string'", ")", "if", "Aux", ".", "lowercase_count", "(", "strin...
Make a single char from the string uppercase.
[ "Make", "a", "single", "char", "from", "the", "string", "uppercase", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/aux.py#L103-L117
52,820
HacKanCuBa/passphrase-py
passphrase/aux.py
Aux.make_chars_uppercase
def make_chars_uppercase( lst: Union[list, tuple, str, set], uppercase: int ) -> Union[list, tuple, str, set]: """Make uppercase some randomly selected characters. The characters can be in a (mix of) string, list, tuple or set. Keyword arguments: lst -- the ...
python
def make_chars_uppercase( lst: Union[list, tuple, str, set], uppercase: int ) -> Union[list, tuple, str, set]: """Make uppercase some randomly selected characters. The characters can be in a (mix of) string, list, tuple or set. Keyword arguments: lst -- the ...
[ "def", "make_chars_uppercase", "(", "lst", ":", "Union", "[", "list", ",", "tuple", ",", "str", ",", "set", "]", ",", "uppercase", ":", "int", ")", "->", "Union", "[", "list", ",", "tuple", ",", "str", ",", "set", "]", ":", "if", "not", "isinstance...
Make uppercase some randomly selected characters. The characters can be in a (mix of) string, list, tuple or set. Keyword arguments: lst -- the object to make all chars uppercase, which can be a (mix of) list, tuple, string or set. uppercase -- Number of characters to be set as...
[ "Make", "uppercase", "some", "randomly", "selected", "characters", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/aux.py#L120-L183
52,821
HacKanCuBa/passphrase-py
passphrase/aux.py
Aux.isfile_notempty
def isfile_notempty(inputfile: str) -> bool: """Check if the input filename with path is a file and is not empty.""" try: return isfile(inputfile) and getsize(inputfile) > 0 except TypeError: raise TypeError('inputfile is not a valid type')
python
def isfile_notempty(inputfile: str) -> bool: """Check if the input filename with path is a file and is not empty.""" try: return isfile(inputfile) and getsize(inputfile) > 0 except TypeError: raise TypeError('inputfile is not a valid type')
[ "def", "isfile_notempty", "(", "inputfile", ":", "str", ")", "->", "bool", ":", "try", ":", "return", "isfile", "(", "inputfile", ")", "and", "getsize", "(", "inputfile", ")", ">", "0", "except", "TypeError", ":", "raise", "TypeError", "(", "'inputfile is ...
Check if the input filename with path is a file and is not empty.
[ "Check", "if", "the", "input", "filename", "with", "path", "is", "a", "file", "and", "is", "not", "empty", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/aux.py#L186-L191
52,822
HacKanCuBa/passphrase-py
passphrase/aux.py
Aux.system_entropy
def system_entropy(): """Return the system's entropy bit count, or -1 if unknown.""" arg = ['cat', '/proc/sys/kernel/random/entropy_avail'] proc = Popen(arg, stdout=PIPE, stderr=DEVNULL) response = proc.communicate()[0] return int(response) if response else -1
python
def system_entropy(): """Return the system's entropy bit count, or -1 if unknown.""" arg = ['cat', '/proc/sys/kernel/random/entropy_avail'] proc = Popen(arg, stdout=PIPE, stderr=DEVNULL) response = proc.communicate()[0] return int(response) if response else -1
[ "def", "system_entropy", "(", ")", ":", "arg", "=", "[", "'cat'", ",", "'/proc/sys/kernel/random/entropy_avail'", "]", "proc", "=", "Popen", "(", "arg", ",", "stdout", "=", "PIPE", ",", "stderr", "=", "DEVNULL", ")", "response", "=", "proc", ".", "communic...
Return the system's entropy bit count, or -1 if unknown.
[ "Return", "the", "system", "s", "entropy", "bit", "count", "or", "-", "1", "if", "unknown", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/aux.py#L199-L204
52,823
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder.issue
def issue(self, issuance_spec, metadata, fees): """ Creates a transaction for issuing an asset. :param TransferParameters issuance_spec: The parameters of the issuance. :param bytes metadata: The metadata to be embedded in the transaction. :param int fees: The fees to include in...
python
def issue(self, issuance_spec, metadata, fees): """ Creates a transaction for issuing an asset. :param TransferParameters issuance_spec: The parameters of the issuance. :param bytes metadata: The metadata to be embedded in the transaction. :param int fees: The fees to include in...
[ "def", "issue", "(", "self", ",", "issuance_spec", ",", "metadata", ",", "fees", ")", ":", "inputs", ",", "total_amount", "=", "self", ".", "_collect_uncolored_outputs", "(", "issuance_spec", ".", "unspent_outputs", ",", "2", "*", "self", ".", "_dust_amount", ...
Creates a transaction for issuing an asset. :param TransferParameters issuance_spec: The parameters of the issuance. :param bytes metadata: The metadata to be embedded in the transaction. :param int fees: The fees to include in the transaction. :return: An unsigned transaction for issui...
[ "Creates", "a", "transaction", "for", "issuing", "an", "asset", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L44-L64
52,824
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder.transfer
def transfer(self, asset_transfer_specs, btc_transfer_spec, fees): """ Creates a transaction for sending assets and bitcoins. :param list[(bytes, TransferParameters)] asset_transfer_specs: A list of tuples. In each tuple: - The first element is the ID of an asset. - The ...
python
def transfer(self, asset_transfer_specs, btc_transfer_spec, fees): """ Creates a transaction for sending assets and bitcoins. :param list[(bytes, TransferParameters)] asset_transfer_specs: A list of tuples. In each tuple: - The first element is the ID of an asset. - The ...
[ "def", "transfer", "(", "self", ",", "asset_transfer_specs", ",", "btc_transfer_spec", ",", "fees", ")", ":", "inputs", "=", "[", "]", "outputs", "=", "[", "]", "asset_quantities", "=", "[", "]", "for", "asset_id", ",", "transfer_spec", "in", "asset_transfer...
Creates a transaction for sending assets and bitcoins. :param list[(bytes, TransferParameters)] asset_transfer_specs: A list of tuples. In each tuple: - The first element is the ID of an asset. - The second element is the parameters of the transfer. :param TransferParameters btc...
[ "Creates", "a", "transaction", "for", "sending", "assets", "and", "bitcoins", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L66-L115
52,825
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder.transfer_assets
def transfer_assets(self, asset_id, transfer_spec, btc_change_script, fees): """ Creates a transaction for sending an asset. :param bytes asset_id: The ID of the asset being sent. :param TransferParameters transfer_spec: The parameters of the asset being transferred. :param byte...
python
def transfer_assets(self, asset_id, transfer_spec, btc_change_script, fees): """ Creates a transaction for sending an asset. :param bytes asset_id: The ID of the asset being sent. :param TransferParameters transfer_spec: The parameters of the asset being transferred. :param byte...
[ "def", "transfer_assets", "(", "self", ",", "asset_id", ",", "transfer_spec", ",", "btc_change_script", ",", "fees", ")", ":", "return", "self", ".", "transfer", "(", "[", "(", "asset_id", ",", "transfer_spec", ")", "]", ",", "TransferParameters", "(", "tran...
Creates a transaction for sending an asset. :param bytes asset_id: The ID of the asset being sent. :param TransferParameters transfer_spec: The parameters of the asset being transferred. :param bytes btc_change_script: The script where to send bitcoin change, if any. :param int fees: Th...
[ "Creates", "a", "transaction", "for", "sending", "an", "asset", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L128-L142
52,826
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder.btc_asset_swap
def btc_asset_swap(self, btc_transfer_spec, asset_id, asset_transfer_spec, fees): """ Creates a transaction for swapping assets for bitcoins. :param TransferParameters btc_transfer_spec: The parameters of the bitcoins being transferred. :param bytes asset_id: The ID of the asset being s...
python
def btc_asset_swap(self, btc_transfer_spec, asset_id, asset_transfer_spec, fees): """ Creates a transaction for swapping assets for bitcoins. :param TransferParameters btc_transfer_spec: The parameters of the bitcoins being transferred. :param bytes asset_id: The ID of the asset being s...
[ "def", "btc_asset_swap", "(", "self", ",", "btc_transfer_spec", ",", "asset_id", ",", "asset_transfer_spec", ",", "fees", ")", ":", "return", "self", ".", "transfer", "(", "[", "(", "asset_id", ",", "asset_transfer_spec", ")", "]", ",", "btc_transfer_spec", ",...
Creates a transaction for swapping assets for bitcoins. :param TransferParameters btc_transfer_spec: The parameters of the bitcoins being transferred. :param bytes asset_id: The ID of the asset being sent. :param TransferParameters asset_transfer_spec: The parameters of the asset being transfer...
[ "Creates", "a", "transaction", "for", "swapping", "assets", "for", "bitcoins", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L144-L155
52,827
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder.asset_asset_swap
def asset_asset_swap( self, asset1_id, asset1_transfer_spec, asset2_id, asset2_transfer_spec, fees): """ Creates a transaction for swapping an asset for another asset. :param bytes asset1_id: The ID of the first asset. :param TransferParameters asset1_transfer_spec: The para...
python
def asset_asset_swap( self, asset1_id, asset1_transfer_spec, asset2_id, asset2_transfer_spec, fees): """ Creates a transaction for swapping an asset for another asset. :param bytes asset1_id: The ID of the first asset. :param TransferParameters asset1_transfer_spec: The para...
[ "def", "asset_asset_swap", "(", "self", ",", "asset1_id", ",", "asset1_transfer_spec", ",", "asset2_id", ",", "asset2_transfer_spec", ",", "fees", ")", ":", "btc_transfer_spec", "=", "TransferParameters", "(", "asset1_transfer_spec", ".", "unspent_outputs", ",", "asse...
Creates a transaction for swapping an asset for another asset. :param bytes asset1_id: The ID of the first asset. :param TransferParameters asset1_transfer_spec: The parameters of the first asset being transferred. It is also used for paying fees and/or receiving change if any. :par...
[ "Creates", "a", "transaction", "for", "swapping", "an", "asset", "for", "another", "asset", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L157-L175
52,828
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder._collect_uncolored_outputs
def _collect_uncolored_outputs(unspent_outputs, amount): """ Returns a list of uncolored outputs for the specified amount. :param list[SpendableOutput] unspent_outputs: The list of available outputs. :param int amount: The amount to collect. :return: A list of outputs, and the t...
python
def _collect_uncolored_outputs(unspent_outputs, amount): """ Returns a list of uncolored outputs for the specified amount. :param list[SpendableOutput] unspent_outputs: The list of available outputs. :param int amount: The amount to collect. :return: A list of outputs, and the t...
[ "def", "_collect_uncolored_outputs", "(", "unspent_outputs", ",", "amount", ")", ":", "total_amount", "=", "0", "result", "=", "[", "]", "for", "output", "in", "unspent_outputs", ":", "if", "output", ".", "output", ".", "asset_id", "is", "None", ":", "result...
Returns a list of uncolored outputs for the specified amount. :param list[SpendableOutput] unspent_outputs: The list of available outputs. :param int amount: The amount to collect. :return: A list of outputs, and the total amount collected. :rtype: (list[SpendableOutput], int)
[ "Returns", "a", "list", "of", "uncolored", "outputs", "for", "the", "specified", "amount", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L178-L197
52,829
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder._collect_colored_outputs
def _collect_colored_outputs(unspent_outputs, asset_id, asset_quantity): """ Returns a list of colored outputs for the specified quantity. :param list[SpendableOutput] unspent_outputs: The list of available outputs. :param bytes asset_id: The ID of the asset to collect. :param i...
python
def _collect_colored_outputs(unspent_outputs, asset_id, asset_quantity): """ Returns a list of colored outputs for the specified quantity. :param list[SpendableOutput] unspent_outputs: The list of available outputs. :param bytes asset_id: The ID of the asset to collect. :param i...
[ "def", "_collect_colored_outputs", "(", "unspent_outputs", ",", "asset_id", ",", "asset_quantity", ")", ":", "total_amount", "=", "0", "result", "=", "[", "]", "for", "output", "in", "unspent_outputs", ":", "if", "output", ".", "output", ".", "asset_id", "==",...
Returns a list of colored outputs for the specified quantity. :param list[SpendableOutput] unspent_outputs: The list of available outputs. :param bytes asset_id: The ID of the asset to collect. :param int asset_quantity: The asset quantity to collect. :return: A list of outputs, and the...
[ "Returns", "a", "list", "of", "colored", "outputs", "for", "the", "specified", "quantity", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L200-L220
52,830
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder._get_uncolored_output
def _get_uncolored_output(self, script, value): """ Creates an uncolored output. :param bytes script: The output script. :param int value: The satoshi value of the output. :return: An object representing the uncolored output. :rtype: TransactionOutput """ ...
python
def _get_uncolored_output(self, script, value): """ Creates an uncolored output. :param bytes script: The output script. :param int value: The satoshi value of the output. :return: An object representing the uncolored output. :rtype: TransactionOutput """ ...
[ "def", "_get_uncolored_output", "(", "self", ",", "script", ",", "value", ")", ":", "if", "value", "<", "self", ".", "_dust_amount", ":", "raise", "DustOutputError", "return", "bitcoin", ".", "core", ".", "CTxOut", "(", "value", ",", "bitcoin", ".", "core"...
Creates an uncolored output. :param bytes script: The output script. :param int value: The satoshi value of the output. :return: An object representing the uncolored output. :rtype: TransactionOutput
[ "Creates", "an", "uncolored", "output", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L222-L234
52,831
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder._get_colored_output
def _get_colored_output(self, script): """ Creates a colored output. :param bytes script: The output script. :return: An object representing the colored output. :rtype: TransactionOutput """ return bitcoin.core.CTxOut(self._dust_amount, bitcoin.core.CScript(scrip...
python
def _get_colored_output(self, script): """ Creates a colored output. :param bytes script: The output script. :return: An object representing the colored output. :rtype: TransactionOutput """ return bitcoin.core.CTxOut(self._dust_amount, bitcoin.core.CScript(scrip...
[ "def", "_get_colored_output", "(", "self", ",", "script", ")", ":", "return", "bitcoin", ".", "core", ".", "CTxOut", "(", "self", ".", "_dust_amount", ",", "bitcoin", ".", "core", ".", "CScript", "(", "script", ")", ")" ]
Creates a colored output. :param bytes script: The output script. :return: An object representing the colored output. :rtype: TransactionOutput
[ "Creates", "a", "colored", "output", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L236-L244
52,832
OpenAssets/openassets
openassets/transactions.py
TransactionBuilder._get_marker_output
def _get_marker_output(self, asset_quantities, metadata): """ Creates a marker output. :param list[int] asset_quantities: The asset quantity list. :param bytes metadata: The metadata contained in the output. :return: An object representing the marker output. :rtype: Tran...
python
def _get_marker_output(self, asset_quantities, metadata): """ Creates a marker output. :param list[int] asset_quantities: The asset quantity list. :param bytes metadata: The metadata contained in the output. :return: An object representing the marker output. :rtype: Tran...
[ "def", "_get_marker_output", "(", "self", ",", "asset_quantities", ",", "metadata", ")", ":", "payload", "=", "openassets", ".", "protocol", ".", "MarkerOutput", "(", "asset_quantities", ",", "metadata", ")", ".", "serialize_payload", "(", ")", "script", "=", ...
Creates a marker output. :param list[int] asset_quantities: The asset quantity list. :param bytes metadata: The metadata contained in the output. :return: An object representing the marker output. :rtype: TransactionOutput
[ "Creates", "a", "marker", "output", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/transactions.py#L246-L257
52,833
ib-lundgren/flask-oauthprovider
flask_oauthprovider.py
OAuthProvider.init_app
def init_app(self, app): """Setup the 4 default routes.""" app.add_url_rule(self.request_token_url, view_func=self.request_token, methods=[u'POST']) app.add_url_rule(self.access_token_url, view_func=self.access_token, methods=[u'POST']) a...
python
def init_app(self, app): """Setup the 4 default routes.""" app.add_url_rule(self.request_token_url, view_func=self.request_token, methods=[u'POST']) app.add_url_rule(self.access_token_url, view_func=self.access_token, methods=[u'POST']) a...
[ "def", "init_app", "(", "self", ",", "app", ")", ":", "app", ".", "add_url_rule", "(", "self", ".", "request_token_url", ",", "view_func", "=", "self", ".", "request_token", ",", "methods", "=", "[", "u'POST'", "]", ")", "app", ".", "add_url_rule", "(", ...
Setup the 4 default routes.
[ "Setup", "the", "4", "default", "routes", "." ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/flask_oauthprovider.py#L208-L217
52,834
ib-lundgren/flask-oauthprovider
flask_oauthprovider.py
OAuthProvider.authorized
def authorized(self, request_token): """Create a verifier for an user authorized client""" verifier = generate_token(length=self.verifier_length[1]) self.save_verifier(request_token, verifier) response = [ (u'oauth_token', request_token), (u'oauth_verifier', verif...
python
def authorized(self, request_token): """Create a verifier for an user authorized client""" verifier = generate_token(length=self.verifier_length[1]) self.save_verifier(request_token, verifier) response = [ (u'oauth_token', request_token), (u'oauth_verifier', verif...
[ "def", "authorized", "(", "self", ",", "request_token", ")", ":", "verifier", "=", "generate_token", "(", "length", "=", "self", ".", "verifier_length", "[", "1", "]", ")", "self", ".", "save_verifier", "(", "request_token", ",", "verifier", ")", "response",...
Create a verifier for an user authorized client
[ "Create", "a", "verifier", "for", "an", "user", "authorized", "client" ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/flask_oauthprovider.py#L219-L228
52,835
ib-lundgren/flask-oauthprovider
flask_oauthprovider.py
OAuthProvider.request_token
def request_token(self): """Create an OAuth request token for a valid client request. Defaults to /request_token. Invoked by client applications. """ client_key = request.oauth.client_key realm = request.oauth.realm # TODO: fallback on default realm? callback = r...
python
def request_token(self): """Create an OAuth request token for a valid client request. Defaults to /request_token. Invoked by client applications. """ client_key = request.oauth.client_key realm = request.oauth.realm # TODO: fallback on default realm? callback = r...
[ "def", "request_token", "(", "self", ")", ":", "client_key", "=", "request", ".", "oauth", ".", "client_key", "realm", "=", "request", ".", "oauth", ".", "realm", "# TODO: fallback on default realm?", "callback", "=", "request", ".", "oauth", ".", "callback_uri"...
Create an OAuth request token for a valid client request. Defaults to /request_token. Invoked by client applications.
[ "Create", "an", "OAuth", "request", "token", "for", "a", "valid", "client", "request", "." ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/flask_oauthprovider.py#L230-L245
52,836
ib-lundgren/flask-oauthprovider
flask_oauthprovider.py
OAuthProvider.access_token
def access_token(self): """Create an OAuth access token for an authorized client. Defaults to /access_token. Invoked by client applications. """ access_token = generate_token(length=self.access_token_length[1]) token_secret = generate_token(self.secret_length) client_key...
python
def access_token(self): """Create an OAuth access token for an authorized client. Defaults to /access_token. Invoked by client applications. """ access_token = generate_token(length=self.access_token_length[1]) token_secret = generate_token(self.secret_length) client_key...
[ "def", "access_token", "(", "self", ")", ":", "access_token", "=", "generate_token", "(", "length", "=", "self", ".", "access_token_length", "[", "1", "]", ")", "token_secret", "=", "generate_token", "(", "self", ".", "secret_length", ")", "client_key", "=", ...
Create an OAuth access token for an authorized client. Defaults to /access_token. Invoked by client applications.
[ "Create", "an", "OAuth", "access", "token", "for", "an", "authorized", "client", "." ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/flask_oauthprovider.py#L247-L258
52,837
ib-lundgren/flask-oauthprovider
flask_oauthprovider.py
OAuthProvider.require_oauth
def require_oauth(self, realm=None, require_resource_owner=True, require_verifier=False, require_realm=False): """Mark the view function f as a protected resource""" def decorator(f): @wraps(f) def verify_request(*args, **kwargs): """Verify OAuth para...
python
def require_oauth(self, realm=None, require_resource_owner=True, require_verifier=False, require_realm=False): """Mark the view function f as a protected resource""" def decorator(f): @wraps(f) def verify_request(*args, **kwargs): """Verify OAuth para...
[ "def", "require_oauth", "(", "self", ",", "realm", "=", "None", ",", "require_resource_owner", "=", "True", ",", "require_verifier", "=", "False", ",", "require_realm", "=", "False", ")", ":", "def", "decorator", "(", "f", ")", ":", "@", "wraps", "(", "f...
Mark the view function f as a protected resource
[ "Mark", "the", "view", "function", "f", "as", "a", "protected", "resource" ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/flask_oauthprovider.py#L266-L316
52,838
ib-lundgren/flask-oauthprovider
flask_oauthprovider.py
OAuthProvider.collect_request_parameters
def collect_request_parameters(self, request): """Collect parameters in an object for convenient access""" class OAuthParameters(object): """Used as a parameter container since plain object()s can't""" pass # Collect parameters query = urlparse(request.url.decod...
python
def collect_request_parameters(self, request): """Collect parameters in an object for convenient access""" class OAuthParameters(object): """Used as a parameter container since plain object()s can't""" pass # Collect parameters query = urlparse(request.url.decod...
[ "def", "collect_request_parameters", "(", "self", ",", "request", ")", ":", "class", "OAuthParameters", "(", "object", ")", ":", "\"\"\"Used as a parameter container since plain object()s can't\"\"\"", "pass", "# Collect parameters", "query", "=", "urlparse", "(", "request"...
Collect parameters in an object for convenient access
[ "Collect", "parameters", "in", "an", "object", "for", "convenient", "access" ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/flask_oauthprovider.py#L318-L346
52,839
zeldamods/rstb
rstb/rstb.py
ResourceSizeTable.get_size
def get_size(self, name: str) -> int: """Get a resource size from the RSTB.""" crc32 = binascii.crc32(name.encode()) if crc32 in self.crc32_map: return self.crc32_map[crc32] if name in self.name_map: return self.name_map[name] return 0
python
def get_size(self, name: str) -> int: """Get a resource size from the RSTB.""" crc32 = binascii.crc32(name.encode()) if crc32 in self.crc32_map: return self.crc32_map[crc32] if name in self.name_map: return self.name_map[name] return 0
[ "def", "get_size", "(", "self", ",", "name", ":", "str", ")", "->", "int", ":", "crc32", "=", "binascii", ".", "crc32", "(", "name", ".", "encode", "(", ")", ")", "if", "crc32", "in", "self", ".", "crc32_map", ":", "return", "self", ".", "crc32_map...
Get a resource size from the RSTB.
[ "Get", "a", "resource", "size", "from", "the", "RSTB", "." ]
01017de269b218fef6d14d79ea7278a6e7e26a23
https://github.com/zeldamods/rstb/blob/01017de269b218fef6d14d79ea7278a6e7e26a23/rstb/rstb.py#L59-L68
52,840
zeldamods/rstb
rstb/rstb.py
ResourceSizeTable.set_size
def set_size(self, name: str, size: int): """Set the size of a resource in the RSTB.""" if self._needs_to_be_in_name_map(name): if len(name) >= 128: raise ValueError("Name is too long") self.name_map[name] = size else: crc32 = binascii.crc32(na...
python
def set_size(self, name: str, size: int): """Set the size of a resource in the RSTB.""" if self._needs_to_be_in_name_map(name): if len(name) >= 128: raise ValueError("Name is too long") self.name_map[name] = size else: crc32 = binascii.crc32(na...
[ "def", "set_size", "(", "self", ",", "name", ":", "str", ",", "size", ":", "int", ")", ":", "if", "self", ".", "_needs_to_be_in_name_map", "(", "name", ")", ":", "if", "len", "(", "name", ")", ">=", "128", ":", "raise", "ValueError", "(", "\"Name is ...
Set the size of a resource in the RSTB.
[ "Set", "the", "size", "of", "a", "resource", "in", "the", "RSTB", "." ]
01017de269b218fef6d14d79ea7278a6e7e26a23
https://github.com/zeldamods/rstb/blob/01017de269b218fef6d14d79ea7278a6e7e26a23/rstb/rstb.py#L70-L78
52,841
zeldamods/rstb
rstb/rstb.py
ResourceSizeTable.write
def write(self, stream: typing.BinaryIO, be: bool) -> None: """Write the RSTB to the specified stream.""" stream.write(b'RSTB') stream.write(_to_u32(len(self.crc32_map), be)) stream.write(_to_u32(len(self.name_map), be)) # The CRC32 hashmap *must* be sorted because the game perf...
python
def write(self, stream: typing.BinaryIO, be: bool) -> None: """Write the RSTB to the specified stream.""" stream.write(b'RSTB') stream.write(_to_u32(len(self.crc32_map), be)) stream.write(_to_u32(len(self.name_map), be)) # The CRC32 hashmap *must* be sorted because the game perf...
[ "def", "write", "(", "self", ",", "stream", ":", "typing", ".", "BinaryIO", ",", "be", ":", "bool", ")", "->", "None", ":", "stream", ".", "write", "(", "b'RSTB'", ")", "stream", ".", "write", "(", "_to_u32", "(", "len", "(", "self", ".", "crc32_ma...
Write the RSTB to the specified stream.
[ "Write", "the", "RSTB", "to", "the", "specified", "stream", "." ]
01017de269b218fef6d14d79ea7278a6e7e26a23
https://github.com/zeldamods/rstb/blob/01017de269b218fef6d14d79ea7278a6e7e26a23/rstb/rstb.py#L87-L101
52,842
HacKanCuBa/passphrase-py
passphrase/random.py
randint
def randint(nbits: int) -> int: """Generate an int with nbits random bits. Raises ValueError if nbits <= 0, and TypeError if it's not an integer. >>> randint(16) #doctest:+SKIP 1871 """ if not isinstance(nbits, int): raise TypeError('number of bits should be an integer') if nbits...
python
def randint(nbits: int) -> int: """Generate an int with nbits random bits. Raises ValueError if nbits <= 0, and TypeError if it's not an integer. >>> randint(16) #doctest:+SKIP 1871 """ if not isinstance(nbits, int): raise TypeError('number of bits should be an integer') if nbits...
[ "def", "randint", "(", "nbits", ":", "int", ")", "->", "int", ":", "if", "not", "isinstance", "(", "nbits", ",", "int", ")", ":", "raise", "TypeError", "(", "'number of bits should be an integer'", ")", "if", "nbits", "<=", "0", ":", "raise", "ValueError",...
Generate an int with nbits random bits. Raises ValueError if nbits <= 0, and TypeError if it's not an integer. >>> randint(16) #doctest:+SKIP 1871
[ "Generate", "an", "int", "with", "nbits", "random", "bits", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/random.py#L52-L69
52,843
HacKanCuBa/passphrase-py
passphrase/secrets.py
randchoice
def randchoice(seq: Union[str, list, tuple, dict, set]) -> any: """Return a randomly chosen element from the given sequence. Raises TypeError if *seq* is not str, list, tuple, dict, set and an IndexError if it is empty. >>> randchoice((1, 2, 'a', 'b')) #doctest:+SKIP 'a' """ if not isins...
python
def randchoice(seq: Union[str, list, tuple, dict, set]) -> any: """Return a randomly chosen element from the given sequence. Raises TypeError if *seq* is not str, list, tuple, dict, set and an IndexError if it is empty. >>> randchoice((1, 2, 'a', 'b')) #doctest:+SKIP 'a' """ if not isins...
[ "def", "randchoice", "(", "seq", ":", "Union", "[", "str", ",", "list", ",", "tuple", ",", "dict", ",", "set", "]", ")", "->", "any", ":", "if", "not", "isinstance", "(", "seq", ",", "(", "str", ",", "list", ",", "tuple", ",", "dict", ",", "set...
Return a randomly chosen element from the given sequence. Raises TypeError if *seq* is not str, list, tuple, dict, set and an IndexError if it is empty. >>> randchoice((1, 2, 'a', 'b')) #doctest:+SKIP 'a'
[ "Return", "a", "randomly", "chosen", "element", "from", "the", "given", "sequence", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/secrets.py#L36-L60
52,844
HacKanCuBa/passphrase-py
passphrase/secrets.py
randbelow
def randbelow(num: int) -> int: """Return a random int in the range [0,num). Raises ValueError if num <= 0, and TypeError if it's not an integer. >>> randbelow(16) #doctest:+SKIP 13 """ if not isinstance(num, int): raise TypeError('number must be an integer') if num <= 0: ...
python
def randbelow(num: int) -> int: """Return a random int in the range [0,num). Raises ValueError if num <= 0, and TypeError if it's not an integer. >>> randbelow(16) #doctest:+SKIP 13 """ if not isinstance(num, int): raise TypeError('number must be an integer') if num <= 0: ...
[ "def", "randbelow", "(", "num", ":", "int", ")", "->", "int", ":", "if", "not", "isinstance", "(", "num", ",", "int", ")", ":", "raise", "TypeError", "(", "'number must be an integer'", ")", "if", "num", "<=", "0", ":", "raise", "ValueError", "(", "'nu...
Return a random int in the range [0,num). Raises ValueError if num <= 0, and TypeError if it's not an integer. >>> randbelow(16) #doctest:+SKIP 13
[ "Return", "a", "random", "int", "in", "the", "range", "[", "0", "num", ")", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/secrets.py#L63-L84
52,845
HacKanCuBa/passphrase-py
passphrase/secrets.py
randhex
def randhex(ndigits: int) -> str: """Return a random text string of hexadecimal characters. The string has *ndigits* random digits. Raises ValueError if ndigits <= 0, and TypeError if it's not an integer. >>> randhex(16) #doctest:+SKIP '56054d728fc56f63' """ if not isinstance(ndigits, in...
python
def randhex(ndigits: int) -> str: """Return a random text string of hexadecimal characters. The string has *ndigits* random digits. Raises ValueError if ndigits <= 0, and TypeError if it's not an integer. >>> randhex(16) #doctest:+SKIP '56054d728fc56f63' """ if not isinstance(ndigits, in...
[ "def", "randhex", "(", "ndigits", ":", "int", ")", "->", "str", ":", "if", "not", "isinstance", "(", "ndigits", ",", "int", ")", ":", "raise", "TypeError", "(", "'number of digits must be an integer'", ")", "if", "ndigits", "<=", "0", ":", "raise", "ValueE...
Return a random text string of hexadecimal characters. The string has *ndigits* random digits. Raises ValueError if ndigits <= 0, and TypeError if it's not an integer. >>> randhex(16) #doctest:+SKIP '56054d728fc56f63'
[ "Return", "a", "random", "text", "string", "of", "hexadecimal", "characters", "." ]
219d6374338ed9a1475b4f09b0d85212376f11e0
https://github.com/HacKanCuBa/passphrase-py/blob/219d6374338ed9a1475b4f09b0d85212376f11e0/passphrase/secrets.py#L102-L121
52,846
fdiskyou/kcshell
kcshell/disassembler.py
Disassembler.default
def default(self, user_input): ''' if no other command was invoked ''' try: for i in self._cs.disasm(unhexlify(self.cleanup(user_input)), self.base_address): print("0x%08x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str)) except CsError as e: print("Error: %s"...
python
def default(self, user_input): ''' if no other command was invoked ''' try: for i in self._cs.disasm(unhexlify(self.cleanup(user_input)), self.base_address): print("0x%08x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str)) except CsError as e: print("Error: %s"...
[ "def", "default", "(", "self", ",", "user_input", ")", ":", "try", ":", "for", "i", "in", "self", ".", "_cs", ".", "disasm", "(", "unhexlify", "(", "self", ".", "cleanup", "(", "user_input", ")", ")", ",", "self", ".", "base_address", ")", ":", "pr...
if no other command was invoked
[ "if", "no", "other", "command", "was", "invoked" ]
f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f
https://github.com/fdiskyou/kcshell/blob/f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f/kcshell/disassembler.py#L54-L60
52,847
parkouss/pyewmh
ewmh/ewmh.py
EWMH.setMoveResizeWindow
def setMoveResizeWindow(self, win, gravity=0, x=None, y=None, w=None, h=None): """ Set the property _NET_MOVERESIZE_WINDOW to move or resize the given window. Flags are automatically calculated if x, y, w or h are defined. :param win: the window object ...
python
def setMoveResizeWindow(self, win, gravity=0, x=None, y=None, w=None, h=None): """ Set the property _NET_MOVERESIZE_WINDOW to move or resize the given window. Flags are automatically calculated if x, y, w or h are defined. :param win: the window object ...
[ "def", "setMoveResizeWindow", "(", "self", ",", "win", ",", "gravity", "=", "0", ",", "x", "=", "None", ",", "y", "=", "None", ",", "w", "=", "None", ",", "h", "=", "None", ")", ":", "# indicate source (application)", "gravity_flags", "=", "gravity", "...
Set the property _NET_MOVERESIZE_WINDOW to move or resize the given window. Flags are automatically calculated if x, y, w or h are defined. :param win: the window object :param gravity: gravity (one of the Xlib.X.*Gravity constant or 0) :param x: int or None :param y: int or Non...
[ "Set", "the", "property", "_NET_MOVERESIZE_WINDOW", "to", "move", "or", "resize", "the", "given", "window", ".", "Flags", "are", "automatically", "calculated", "if", "x", "y", "w", "or", "h", "are", "defined", "." ]
8209e9d942b4f39e32f14e2684d94bb5e6269aac
https://github.com/parkouss/pyewmh/blob/8209e9d942b4f39e32f14e2684d94bb5e6269aac/ewmh/ewmh.py#L187-L219
52,848
parkouss/pyewmh
ewmh/ewmh.py
EWMH._setProperty
def _setProperty(self, _type, data, win=None, mask=None): """ Send a ClientMessage event to the root window """ if not win: win = self.root if type(data) is str: dataSize = 8 else: data = (data+[0]*(5-len(data)))[:5] dataSiz...
python
def _setProperty(self, _type, data, win=None, mask=None): """ Send a ClientMessage event to the root window """ if not win: win = self.root if type(data) is str: dataSize = 8 else: data = (data+[0]*(5-len(data)))[:5] dataSiz...
[ "def", "_setProperty", "(", "self", ",", "_type", ",", "data", ",", "win", "=", "None", ",", "mask", "=", "None", ")", ":", "if", "not", "win", ":", "win", "=", "self", ".", "root", "if", "type", "(", "data", ")", "is", "str", ":", "dataSize", ...
Send a ClientMessage event to the root window
[ "Send", "a", "ClientMessage", "event", "to", "the", "root", "window" ]
8209e9d942b4f39e32f14e2684d94bb5e6269aac
https://github.com/parkouss/pyewmh/blob/8209e9d942b4f39e32f14e2684d94bb5e6269aac/ewmh/ewmh.py#L412-L430
52,849
gersolar/solar_radiation_model
models/stats.py
scoreatpercentile
def scoreatpercentile(a, per, limit=(), interpolation_method='fraction', axis=None): """ Calculate the score at a given percentile of the input sequence. For example, the score at `per=50` is the median. If the desired quantile lies between two data points, we interpolate between them, accordin...
python
def scoreatpercentile(a, per, limit=(), interpolation_method='fraction', axis=None): """ Calculate the score at a given percentile of the input sequence. For example, the score at `per=50` is the median. If the desired quantile lies between two data points, we interpolate between them, accordin...
[ "def", "scoreatpercentile", "(", "a", ",", "per", ",", "limit", "=", "(", ")", ",", "interpolation_method", "=", "'fraction'", ",", "axis", "=", "None", ")", ":", "# adapted from NumPy's percentile function", "a", "=", "np", ".", "asarray", "(", "a", ")", ...
Calculate the score at a given percentile of the input sequence. For example, the score at `per=50` is the median. If the desired quantile lies between two data points, we interpolate between them, according to the value of `interpolation`. If the parameter `limit` is provided, it should be a tuple (lo...
[ "Calculate", "the", "score", "at", "a", "given", "percentile", "of", "the", "input", "sequence", "." ]
e61e5954ed4b07b1884e2636b5da66dcc027fbdc
https://github.com/gersolar/solar_radiation_model/blob/e61e5954ed4b07b1884e2636b5da66dcc027fbdc/models/stats.py#L9-L75
52,850
maxhollmann/lium-diarization-editor
lium_diarization_editor/diarization.py
Diarization.merge_equal_neighbors
def merge_equal_neighbors(self): """ Merge neighbors with same speaker. """ IDX_LENGTH = 3 merged = self.segs.copy() current_start = 0 j = 0 seg = self.segs.iloc[0] for i in range(1, self.num_segments): seg = self.segs.iloc[i] last = self....
python
def merge_equal_neighbors(self): """ Merge neighbors with same speaker. """ IDX_LENGTH = 3 merged = self.segs.copy() current_start = 0 j = 0 seg = self.segs.iloc[0] for i in range(1, self.num_segments): seg = self.segs.iloc[i] last = self....
[ "def", "merge_equal_neighbors", "(", "self", ")", ":", "IDX_LENGTH", "=", "3", "merged", "=", "self", ".", "segs", ".", "copy", "(", ")", "current_start", "=", "0", "j", "=", "0", "seg", "=", "self", ".", "segs", ".", "iloc", "[", "0", "]", "for", ...
Merge neighbors with same speaker.
[ "Merge", "neighbors", "with", "same", "speaker", "." ]
c9fe124e684ec0967bfd1f071b07a6454c1a9b83
https://github.com/maxhollmann/lium-diarization-editor/blob/c9fe124e684ec0967bfd1f071b07a6454c1a9b83/lium_diarization_editor/diarization.py#L38-L58
52,851
gaqzi/gocd-cli
gocd_cli/utils.py
format_arguments
def format_arguments(*args): """ Converts a list of arguments from the command line into a list of positional arguments and a dictionary of keyword arguments. Handled formats for keyword arguments are: * --argument=value * --argument value Args: *args (list): a list of arguments ...
python
def format_arguments(*args): """ Converts a list of arguments from the command line into a list of positional arguments and a dictionary of keyword arguments. Handled formats for keyword arguments are: * --argument=value * --argument value Args: *args (list): a list of arguments ...
[ "def", "format_arguments", "(", "*", "args", ")", ":", "positional_args", "=", "[", "]", "kwargs", "=", "{", "}", "split_key", "=", "None", "for", "arg", "in", "args", ":", "if", "arg", ".", "startswith", "(", "'--'", ")", ":", "arg", "=", "arg", "...
Converts a list of arguments from the command line into a list of positional arguments and a dictionary of keyword arguments. Handled formats for keyword arguments are: * --argument=value * --argument value Args: *args (list): a list of arguments Returns: ([positional_args], {kwar...
[ "Converts", "a", "list", "of", "arguments", "from", "the", "command", "line", "into", "a", "list", "of", "positional", "arguments", "and", "a", "dictionary", "of", "keyword", "arguments", "." ]
ca8df8ec2274fdc69bce0619aa3794463c4f5a6f
https://github.com/gaqzi/gocd-cli/blob/ca8df8ec2274fdc69bce0619aa3794463c4f5a6f/gocd_cli/utils.py#L62-L96
52,852
gaqzi/gocd-cli
gocd_cli/utils.py
get_settings
def get_settings(section='gocd', settings_paths=('~/.gocd/gocd-cli.cfg', '/etc/go/gocd-cli.cfg')): """Returns a `gocd_cli.settings.Settings` configured for settings file The settings will be read from environment variables first, then it'll be read from the first config file found (if any). Environmen...
python
def get_settings(section='gocd', settings_paths=('~/.gocd/gocd-cli.cfg', '/etc/go/gocd-cli.cfg')): """Returns a `gocd_cli.settings.Settings` configured for settings file The settings will be read from environment variables first, then it'll be read from the first config file found (if any). Environmen...
[ "def", "get_settings", "(", "section", "=", "'gocd'", ",", "settings_paths", "=", "(", "'~/.gocd/gocd-cli.cfg'", ",", "'/etc/go/gocd-cli.cfg'", ")", ")", ":", "if", "isinstance", "(", "settings_paths", ",", "basestring", ")", ":", "settings_paths", "=", "(", "se...
Returns a `gocd_cli.settings.Settings` configured for settings file The settings will be read from environment variables first, then it'll be read from the first config file found (if any). Environment variables are expected to be in UPPERCASE and to be prefixed with `GOCD_`. Args: section:...
[ "Returns", "a", "gocd_cli", ".", "settings", ".", "Settings", "configured", "for", "settings", "file" ]
ca8df8ec2274fdc69bce0619aa3794463c4f5a6f
https://github.com/gaqzi/gocd-cli/blob/ca8df8ec2274fdc69bce0619aa3794463c4f5a6f/gocd_cli/utils.py#L126-L151
52,853
gaqzi/gocd-cli
gocd_cli/utils.py
get_go_server
def get_go_server(settings=None): """Returns a `gocd.Server` configured by the `settings` object. Args: settings: a `gocd_cli.settings.Settings` object. Default: if falsey calls `get_settings`. Returns: gocd.Server: a configured gocd.Server instance """ if not settings: ...
python
def get_go_server(settings=None): """Returns a `gocd.Server` configured by the `settings` object. Args: settings: a `gocd_cli.settings.Settings` object. Default: if falsey calls `get_settings`. Returns: gocd.Server: a configured gocd.Server instance """ if not settings: ...
[ "def", "get_go_server", "(", "settings", "=", "None", ")", ":", "if", "not", "settings", ":", "settings", "=", "get_settings", "(", ")", "return", "gocd", ".", "Server", "(", "settings", ".", "get", "(", "'server'", ")", ",", "user", "=", "settings", "...
Returns a `gocd.Server` configured by the `settings` object. Args: settings: a `gocd_cli.settings.Settings` object. Default: if falsey calls `get_settings`. Returns: gocd.Server: a configured gocd.Server instance
[ "Returns", "a", "gocd", ".", "Server", "configured", "by", "the", "settings", "object", "." ]
ca8df8ec2274fdc69bce0619aa3794463c4f5a6f
https://github.com/gaqzi/gocd-cli/blob/ca8df8ec2274fdc69bce0619aa3794463c4f5a6f/gocd_cli/utils.py#L154-L172
52,854
toejough/pimento
pimento/__init__.py
_get_standard_tc_matches
def _get_standard_tc_matches(text, full_text, options): ''' get the standard tab completions. These are the options which could complete the full_text. ''' final_matches = [o for o in options if o.startswith(full_text)] return final_matches
python
def _get_standard_tc_matches(text, full_text, options): ''' get the standard tab completions. These are the options which could complete the full_text. ''' final_matches = [o for o in options if o.startswith(full_text)] return final_matches
[ "def", "_get_standard_tc_matches", "(", "text", ",", "full_text", ",", "options", ")", ":", "final_matches", "=", "[", "o", "for", "o", "in", "options", "if", "o", ".", "startswith", "(", "full_text", ")", "]", "return", "final_matches" ]
get the standard tab completions. These are the options which could complete the full_text.
[ "get", "the", "standard", "tab", "completions", ".", "These", "are", "the", "options", "which", "could", "complete", "the", "full_text", "." ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L33-L39
52,855
toejough/pimento
pimento/__init__.py
_get_fuzzy_tc_matches
def _get_fuzzy_tc_matches(text, full_text, options): ''' Get the options that match the full text, then from each option return only the individual words which have not yet been matched which also match the text being tab-completed. ''' print("text: {}, full: {}, options: {}".format(text, full_t...
python
def _get_fuzzy_tc_matches(text, full_text, options): ''' Get the options that match the full text, then from each option return only the individual words which have not yet been matched which also match the text being tab-completed. ''' print("text: {}, full: {}, options: {}".format(text, full_t...
[ "def", "_get_fuzzy_tc_matches", "(", "text", ",", "full_text", ",", "options", ")", ":", "print", "(", "\"text: {}, full: {}, options: {}\"", ".", "format", "(", "text", ",", "full_text", ",", "options", ")", ")", "# get the options which match the full text", "matchi...
Get the options that match the full text, then from each option return only the individual words which have not yet been matched which also match the text being tab-completed.
[ "Get", "the", "options", "that", "match", "the", "full", "text", "then", "from", "each", "option", "return", "only", "the", "individual", "words", "which", "have", "not", "yet", "been", "matched", "which", "also", "match", "the", "text", "being", "tab", "-...
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L42-L86
52,856
toejough/pimento
pimento/__init__.py
_tab_complete_init
def _tab_complete_init(items, post_prompt, insensitive, fuzzy, stream): '''Create and use a tab-completer object''' # using some sort of nested-scope construct is # required because readline doesn't pass the necessary args to # its callback functions def _get_matches(text, state): ''' ...
python
def _tab_complete_init(items, post_prompt, insensitive, fuzzy, stream): '''Create and use a tab-completer object''' # using some sort of nested-scope construct is # required because readline doesn't pass the necessary args to # its callback functions def _get_matches(text, state): ''' ...
[ "def", "_tab_complete_init", "(", "items", ",", "post_prompt", ",", "insensitive", ",", "fuzzy", ",", "stream", ")", ":", "# using some sort of nested-scope construct is", "# required because readline doesn't pass the necessary args to", "# its callback functions", "def", "_get_m...
Create and use a tab-completer object
[ "Create", "and", "use", "a", "tab", "-", "completer", "object" ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L89-L185
52,857
toejough/pimento
pimento/__init__.py
_fuzzily_matches
def _fuzzily_matches(response, candidate): '''return True if response fuzzily matches candidate''' r_words = response.split() c_words = candidate.split() # match whole words first for word in r_words: if word in c_words: r_words.remove(word) c_words.remove(word) #...
python
def _fuzzily_matches(response, candidate): '''return True if response fuzzily matches candidate''' r_words = response.split() c_words = candidate.split() # match whole words first for word in r_words: if word in c_words: r_words.remove(word) c_words.remove(word) #...
[ "def", "_fuzzily_matches", "(", "response", ",", "candidate", ")", ":", "r_words", "=", "response", ".", "split", "(", ")", "c_words", "=", "candidate", ".", "split", "(", ")", "# match whole words first", "for", "word", "in", "r_words", ":", "if", "word", ...
return True if response fuzzily matches candidate
[ "return", "True", "if", "response", "fuzzily", "matches", "candidate" ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L234-L268
52,858
toejough/pimento
pimento/__init__.py
_exact_fuzzy_match
def _exact_fuzzy_match(response, match, insensitive): ''' Return True if the response matches fuzzily exactly. Insensitivity is taken into account. ''' if insensitive: response = response.lower() match = match.lower() r_words = response.split() m_words = match.split() # m...
python
def _exact_fuzzy_match(response, match, insensitive): ''' Return True if the response matches fuzzily exactly. Insensitivity is taken into account. ''' if insensitive: response = response.lower() match = match.lower() r_words = response.split() m_words = match.split() # m...
[ "def", "_exact_fuzzy_match", "(", "response", ",", "match", ",", "insensitive", ")", ":", "if", "insensitive", ":", "response", "=", "response", ".", "lower", "(", ")", "match", "=", "match", ".", "lower", "(", ")", "r_words", "=", "response", ".", "spli...
Return True if the response matches fuzzily exactly. Insensitivity is taken into account.
[ "Return", "True", "if", "the", "response", "matches", "fuzzily", "exactly", ".", "Insensitivity", "is", "taken", "into", "account", "." ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L276-L295
52,859
toejough/pimento
pimento/__init__.py
_exact_match
def _exact_match(response, matches, insensitive, fuzzy): ''' returns an exact match, if it exists, given parameters for the match ''' for match in matches: if response == match: return match elif insensitive and response.lower() == match.lower(): return match ...
python
def _exact_match(response, matches, insensitive, fuzzy): ''' returns an exact match, if it exists, given parameters for the match ''' for match in matches: if response == match: return match elif insensitive and response.lower() == match.lower(): return match ...
[ "def", "_exact_match", "(", "response", ",", "matches", ",", "insensitive", ",", "fuzzy", ")", ":", "for", "match", "in", "matches", ":", "if", "response", "==", "match", ":", "return", "match", "elif", "insensitive", "and", "response", ".", "lower", "(", ...
returns an exact match, if it exists, given parameters for the match
[ "returns", "an", "exact", "match", "if", "it", "exists", "given", "parameters", "for", "the", "match" ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L298-L311
52,860
toejough/pimento
pimento/__init__.py
_check_response
def _check_response(response, items, default, indexed, stream, insensitive, fuzzy): '''Check the response against the items''' # Set selection selection = None # if indexed, check for index if indexed: if response.isdigit(): index_response = int(response) if index_res...
python
def _check_response(response, items, default, indexed, stream, insensitive, fuzzy): '''Check the response against the items''' # Set selection selection = None # if indexed, check for index if indexed: if response.isdigit(): index_response = int(response) if index_res...
[ "def", "_check_response", "(", "response", ",", "items", ",", "default", ",", "indexed", ",", "stream", ",", "insensitive", ",", "fuzzy", ")", ":", "# Set selection", "selection", "=", "None", "# if indexed, check for index", "if", "indexed", ":", "if", "respons...
Check the response against the items
[ "Check", "the", "response", "against", "the", "items" ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L314-L371
52,861
toejough/pimento
pimento/__init__.py
_check_prompts
def _check_prompts(pre_prompt, post_prompt): '''Check that the prompts are strings''' if not isinstance(pre_prompt, str): raise TypeError("The pre_prompt was not a string!") if post_prompt is not _NO_ARG and not isinstance(post_prompt, str): raise TypeError("The post_prompt was given and was...
python
def _check_prompts(pre_prompt, post_prompt): '''Check that the prompts are strings''' if not isinstance(pre_prompt, str): raise TypeError("The pre_prompt was not a string!") if post_prompt is not _NO_ARG and not isinstance(post_prompt, str): raise TypeError("The post_prompt was given and was...
[ "def", "_check_prompts", "(", "pre_prompt", ",", "post_prompt", ")", ":", "if", "not", "isinstance", "(", "pre_prompt", ",", "str", ")", ":", "raise", "TypeError", "(", "\"The pre_prompt was not a string!\"", ")", "if", "post_prompt", "is", "not", "_NO_ARG", "an...
Check that the prompts are strings
[ "Check", "that", "the", "prompts", "are", "strings" ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L374-L379
52,862
toejough/pimento
pimento/__init__.py
_check_default_index
def _check_default_index(items, default_index): '''Check that the default is in the list, and not empty''' num_items = len(items) if default_index is not None and not isinstance(default_index, int): raise TypeError("The default index ({}) is not an integer".format(default_index)) if default_inde...
python
def _check_default_index(items, default_index): '''Check that the default is in the list, and not empty''' num_items = len(items) if default_index is not None and not isinstance(default_index, int): raise TypeError("The default index ({}) is not an integer".format(default_index)) if default_inde...
[ "def", "_check_default_index", "(", "items", ",", "default_index", ")", ":", "num_items", "=", "len", "(", "items", ")", "if", "default_index", "is", "not", "None", "and", "not", "isinstance", "(", "default_index", ",", "int", ")", ":", "raise", "TypeError",...
Check that the default is in the list, and not empty
[ "Check", "that", "the", "default", "is", "in", "the", "list", "and", "not", "empty" ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L399-L409
52,863
toejough/pimento
pimento/__init__.py
_check_stream
def _check_stream(stream): '''Check that the stream is a file''' if not isinstance(stream, type(_sys.stderr)): raise TypeError("The stream given ({}) is not a file object.".format(stream))
python
def _check_stream(stream): '''Check that the stream is a file''' if not isinstance(stream, type(_sys.stderr)): raise TypeError("The stream given ({}) is not a file object.".format(stream))
[ "def", "_check_stream", "(", "stream", ")", ":", "if", "not", "isinstance", "(", "stream", ",", "type", "(", "_sys", ".", "stderr", ")", ")", ":", "raise", "TypeError", "(", "\"The stream given ({}) is not a file object.\"", ".", "format", "(", "stream", ")", ...
Check that the stream is a file
[ "Check", "that", "the", "stream", "is", "a", "file" ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L412-L415
52,864
toejough/pimento
pimento/__init__.py
_dedup
def _dedup(items, insensitive): ''' Deduplicate an item list, and preserve order. For case-insensitive lists, drop items if they case-insensitively match a prior item. ''' deduped = [] if insensitive: i_deduped = [] for item in items: lowered = item.lower() ...
python
def _dedup(items, insensitive): ''' Deduplicate an item list, and preserve order. For case-insensitive lists, drop items if they case-insensitively match a prior item. ''' deduped = [] if insensitive: i_deduped = [] for item in items: lowered = item.lower() ...
[ "def", "_dedup", "(", "items", ",", "insensitive", ")", ":", "deduped", "=", "[", "]", "if", "insensitive", ":", "i_deduped", "=", "[", "]", "for", "item", "in", "items", ":", "lowered", "=", "item", ".", "lower", "(", ")", "if", "lowered", "not", ...
Deduplicate an item list, and preserve order. For case-insensitive lists, drop items if they case-insensitively match a prior item.
[ "Deduplicate", "an", "item", "list", "and", "preserve", "order", "." ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L528-L547
52,865
toejough/pimento
pimento/__init__.py
menu
def menu(items, pre_prompt="Options:", post_prompt=_NO_ARG, default_index=None, indexed=False, stream=_sys.stderr, insensitive=False, fuzzy=False, quiet=False): ''' Prompt with a menu. Arguments: pre_prompt - Text to print before the option list. items - The items to print as opt...
python
def menu(items, pre_prompt="Options:", post_prompt=_NO_ARG, default_index=None, indexed=False, stream=_sys.stderr, insensitive=False, fuzzy=False, quiet=False): ''' Prompt with a menu. Arguments: pre_prompt - Text to print before the option list. items - The items to print as opt...
[ "def", "menu", "(", "items", ",", "pre_prompt", "=", "\"Options:\"", ",", "post_prompt", "=", "_NO_ARG", ",", "default_index", "=", "None", ",", "indexed", "=", "False", ",", "stream", "=", "_sys", ".", "stderr", ",", "insensitive", "=", "False", ",", "f...
Prompt with a menu. Arguments: pre_prompt - Text to print before the option list. items - The items to print as options. post_prompt - Text to print after the option list. default_index - The index of the item which should be default, if any. indexed - Boolean. True if...
[ "Prompt", "with", "a", "menu", "." ]
cdb00a93976733aa5521f8504152cedeedfc711a
https://github.com/toejough/pimento/blob/cdb00a93976733aa5521f8504152cedeedfc711a/pimento/__init__.py#L551-L654
52,866
ib-lundgren/flask-oauthprovider
examples/mongo_demoprovider/utils.py
require_openid
def require_openid(f): """Require user to be logged in.""" @wraps(f) def decorator(*args, **kwargs): if g.user is None: next_url = url_for("login") + "?next=" + request.url return redirect(next_url) else: return f(*args, **kwargs) return decorator
python
def require_openid(f): """Require user to be logged in.""" @wraps(f) def decorator(*args, **kwargs): if g.user is None: next_url = url_for("login") + "?next=" + request.url return redirect(next_url) else: return f(*args, **kwargs) return decorator
[ "def", "require_openid", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "decorator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "g", ".", "user", "is", "None", ":", "next_url", "=", "url_for", "(", "\"login\"", ")", "+", ...
Require user to be logged in.
[ "Require", "user", "to", "be", "logged", "in", "." ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/examples/mongo_demoprovider/utils.py#L5-L14
52,867
ib-lundgren/flask-oauthprovider
examples/demoprovider/login.py
login
def login(): """Does the login via OpenID. Has to call into `oid.try_login` to start the OpenID machinery. """ # if we are already logged in, go back to were we came from if g.user is not None: return redirect(oid.get_next_url()) if request.method == 'POST': openid = request.for...
python
def login(): """Does the login via OpenID. Has to call into `oid.try_login` to start the OpenID machinery. """ # if we are already logged in, go back to were we came from if g.user is not None: return redirect(oid.get_next_url()) if request.method == 'POST': openid = request.for...
[ "def", "login", "(", ")", ":", "# if we are already logged in, go back to were we came from", "if", "g", ".", "user", "is", "not", "None", ":", "return", "redirect", "(", "oid", ".", "get_next_url", "(", ")", ")", "if", "request", ".", "method", "==", "'POST'"...
Does the login via OpenID. Has to call into `oid.try_login` to start the OpenID machinery.
[ "Does", "the", "login", "via", "OpenID", ".", "Has", "to", "call", "into", "oid", ".", "try_login", "to", "start", "the", "OpenID", "machinery", "." ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/examples/demoprovider/login.py#L33-L46
52,868
OpenAssets/openassets
openassets/protocol.py
ColoringEngine.get_output
def get_output(self, transaction_hash, output_index): """ Gets an output and information about its asset ID and asset quantity. :param bytes transaction_hash: The hash of the transaction containing the output. :param int output_index: The index of the output. :return: An object ...
python
def get_output(self, transaction_hash, output_index): """ Gets an output and information about its asset ID and asset quantity. :param bytes transaction_hash: The hash of the transaction containing the output. :param int output_index: The index of the output. :return: An object ...
[ "def", "get_output", "(", "self", ",", "transaction_hash", ",", "output_index", ")", ":", "cached_output", "=", "yield", "from", "self", ".", "_cache", ".", "get", "(", "transaction_hash", ",", "output_index", ")", "if", "cached_output", "is", "not", "None", ...
Gets an output and information about its asset ID and asset quantity. :param bytes transaction_hash: The hash of the transaction containing the output. :param int output_index: The index of the output. :return: An object containing the output as well as its asset ID and asset quantity. ...
[ "Gets", "an", "output", "and", "information", "about", "its", "asset", "ID", "and", "asset", "quantity", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L54-L78
52,869
OpenAssets/openassets
openassets/protocol.py
ColoringEngine.color_transaction
def color_transaction(self, transaction): """ Computes the asset ID and asset quantity of every output in the transaction. :param CTransaction transaction: The transaction to color. :return: A list containing all the colored outputs of the transaction. :rtype: Future[list[Transa...
python
def color_transaction(self, transaction): """ Computes the asset ID and asset quantity of every output in the transaction. :param CTransaction transaction: The transaction to color. :return: A list containing all the colored outputs of the transaction. :rtype: Future[list[Transa...
[ "def", "color_transaction", "(", "self", ",", "transaction", ")", ":", "# If the transaction is a coinbase transaction, the marker output is always invalid", "if", "not", "transaction", ".", "is_coinbase", "(", ")", ":", "for", "i", ",", "output", "in", "enumerate", "("...
Computes the asset ID and asset quantity of every output in the transaction. :param CTransaction transaction: The transaction to color. :return: A list containing all the colored outputs of the transaction. :rtype: Future[list[TransactionOutput]]
[ "Computes", "the", "asset", "ID", "and", "asset", "quantity", "of", "every", "output", "in", "the", "transaction", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L81-L118
52,870
OpenAssets/openassets
openassets/protocol.py
ColoringEngine._compute_asset_ids
def _compute_asset_ids(cls, inputs, marker_output_index, outputs, asset_quantities): """ Computes the asset IDs of every output in a transaction. :param list[TransactionOutput] inputs: The outputs referenced by the inputs of the transaction. :param int marker_output_index: The position ...
python
def _compute_asset_ids(cls, inputs, marker_output_index, outputs, asset_quantities): """ Computes the asset IDs of every output in a transaction. :param list[TransactionOutput] inputs: The outputs referenced by the inputs of the transaction. :param int marker_output_index: The position ...
[ "def", "_compute_asset_ids", "(", "cls", ",", "inputs", ",", "marker_output_index", ",", "outputs", ",", "asset_quantities", ")", ":", "# If there are more items in the asset quantities list than outputs in the transaction (excluding the", "# marker output), the marker output is deemed...
Computes the asset IDs of every output in a transaction. :param list[TransactionOutput] inputs: The outputs referenced by the inputs of the transaction. :param int marker_output_index: The position of the marker output in the transaction. :param list[CTxOut] outputs: The outputs of the transact...
[ "Computes", "the", "asset", "IDs", "of", "every", "output", "in", "a", "transaction", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L121-L201
52,871
OpenAssets/openassets
openassets/protocol.py
ColoringEngine.hash_script
def hash_script(data): """ Hashes a script into an asset ID using SHA256 followed by RIPEMD160. :param bytes data: The data to hash. """ sha256 = hashlib.sha256() ripemd = hashlib.new('ripemd160') sha256.update(data) ripemd.update(sha256.digest()) ...
python
def hash_script(data): """ Hashes a script into an asset ID using SHA256 followed by RIPEMD160. :param bytes data: The data to hash. """ sha256 = hashlib.sha256() ripemd = hashlib.new('ripemd160') sha256.update(data) ripemd.update(sha256.digest()) ...
[ "def", "hash_script", "(", "data", ")", ":", "sha256", "=", "hashlib", ".", "sha256", "(", ")", "ripemd", "=", "hashlib", ".", "new", "(", "'ripemd160'", ")", "sha256", ".", "update", "(", "data", ")", "ripemd", ".", "update", "(", "sha256", ".", "di...
Hashes a script into an asset ID using SHA256 followed by RIPEMD160. :param bytes data: The data to hash.
[ "Hashes", "a", "script", "into", "an", "asset", "ID", "using", "SHA256", "followed", "by", "RIPEMD160", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L204-L215
52,872
OpenAssets/openassets
openassets/protocol.py
MarkerOutput.deserialize_payload
def deserialize_payload(cls, payload): """ Deserializes the marker output payload. :param bytes payload: A buffer containing the marker output payload. :return: The marker output object. :rtype: MarkerOutput """ with io.BytesIO(payload) as stream: # ...
python
def deserialize_payload(cls, payload): """ Deserializes the marker output payload. :param bytes payload: A buffer containing the marker output payload. :return: The marker output object. :rtype: MarkerOutput """ with io.BytesIO(payload) as stream: # ...
[ "def", "deserialize_payload", "(", "cls", ",", "payload", ")", ":", "with", "io", ".", "BytesIO", "(", "payload", ")", "as", "stream", ":", "# The OAP marker and protocol version", "oa_version", "=", "stream", ".", "read", "(", "4", ")", "if", "oa_version", ...
Deserializes the marker output payload. :param bytes payload: A buffer containing the marker output payload. :return: The marker output object. :rtype: MarkerOutput
[ "Deserializes", "the", "marker", "output", "payload", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L372-L421
52,873
OpenAssets/openassets
openassets/protocol.py
MarkerOutput.serialize_payload
def serialize_payload(self): """ Serializes the marker output data into a payload buffer. :return: The serialized payload. :rtype: bytes """ with io.BytesIO() as stream: stream.write(self.OPEN_ASSETS_TAG) bitcoin.core.VarIntSerializer.stream_seri...
python
def serialize_payload(self): """ Serializes the marker output data into a payload buffer. :return: The serialized payload. :rtype: bytes """ with io.BytesIO() as stream: stream.write(self.OPEN_ASSETS_TAG) bitcoin.core.VarIntSerializer.stream_seri...
[ "def", "serialize_payload", "(", "self", ")", ":", "with", "io", ".", "BytesIO", "(", ")", "as", "stream", ":", "stream", ".", "write", "(", "self", ".", "OPEN_ASSETS_TAG", ")", "bitcoin", ".", "core", ".", "VarIntSerializer", ".", "stream_serialize", "(",...
Serializes the marker output data into a payload buffer. :return: The serialized payload. :rtype: bytes
[ "Serializes", "the", "marker", "output", "data", "into", "a", "payload", "buffer", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L423-L441
52,874
OpenAssets/openassets
openassets/protocol.py
MarkerOutput.parse_script
def parse_script(output_script): """ Parses an output and returns the payload if the output matches the right pattern for a marker output, or None otherwise. :param CScript output_script: The output script to be parsed. :return: The marker output payload if the output fits the p...
python
def parse_script(output_script): """ Parses an output and returns the payload if the output matches the right pattern for a marker output, or None otherwise. :param CScript output_script: The output script to be parsed. :return: The marker output payload if the output fits the p...
[ "def", "parse_script", "(", "output_script", ")", ":", "script_iterator", "=", "output_script", ".", "raw_iter", "(", ")", "try", ":", "first_opcode", ",", "_", ",", "_", "=", "next", "(", "script_iterator", ",", "(", "None", ",", "None", ",", "None", ")...
Parses an output and returns the payload if the output matches the right pattern for a marker output, or None otherwise. :param CScript output_script: The output script to be parsed. :return: The marker output payload if the output fits the pattern, None otherwise. :rtype: bytes
[ "Parses", "an", "output", "and", "returns", "the", "payload", "if", "the", "output", "matches", "the", "right", "pattern", "for", "a", "marker", "output", "or", "None", "otherwise", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L444-L467
52,875
OpenAssets/openassets
openassets/protocol.py
MarkerOutput.build_script
def build_script(data): """ Creates an output script containing an OP_RETURN and a PUSHDATA. :param bytes data: The content of the PUSHDATA. :return: The final script. :rtype: CScript """ return bitcoin.core.script.CScript( bytes([bitcoin.core.script....
python
def build_script(data): """ Creates an output script containing an OP_RETURN and a PUSHDATA. :param bytes data: The content of the PUSHDATA. :return: The final script. :rtype: CScript """ return bitcoin.core.script.CScript( bytes([bitcoin.core.script....
[ "def", "build_script", "(", "data", ")", ":", "return", "bitcoin", ".", "core", ".", "script", ".", "CScript", "(", "bytes", "(", "[", "bitcoin", ".", "core", ".", "script", ".", "OP_RETURN", "]", ")", "+", "bitcoin", ".", "core", ".", "script", ".",...
Creates an output script containing an OP_RETURN and a PUSHDATA. :param bytes data: The content of the PUSHDATA. :return: The final script. :rtype: CScript
[ "Creates", "an", "output", "script", "containing", "an", "OP_RETURN", "and", "a", "PUSHDATA", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L470-L479
52,876
OpenAssets/openassets
openassets/protocol.py
MarkerOutput.leb128_decode
def leb128_decode(data): """ Decodes a LEB128-encoded unsigned integer. :param BufferedIOBase data: The buffer containing the LEB128-encoded integer to decode. :return: The decoded integer. :rtype: int """ result = 0 shift = 0 while True: ...
python
def leb128_decode(data): """ Decodes a LEB128-encoded unsigned integer. :param BufferedIOBase data: The buffer containing the LEB128-encoded integer to decode. :return: The decoded integer. :rtype: int """ result = 0 shift = 0 while True: ...
[ "def", "leb128_decode", "(", "data", ")", ":", "result", "=", "0", "shift", "=", "0", "while", "True", ":", "character", "=", "data", ".", "read", "(", "1", ")", "if", "len", "(", "character", ")", "==", "0", ":", "raise", "bitcoin", ".", "core", ...
Decodes a LEB128-encoded unsigned integer. :param BufferedIOBase data: The buffer containing the LEB128-encoded integer to decode. :return: The decoded integer. :rtype: int
[ "Decodes", "a", "LEB128", "-", "encoded", "unsigned", "integer", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L482-L503
52,877
OpenAssets/openassets
openassets/protocol.py
MarkerOutput.leb128_encode
def leb128_encode(value): """ Encodes an integer using LEB128. :param int value: The value to encode. :return: The LEB128-encoded integer. :rtype: bytes """ if value == 0: return b'\x00' result = [] while value != 0: byte ...
python
def leb128_encode(value): """ Encodes an integer using LEB128. :param int value: The value to encode. :return: The LEB128-encoded integer. :rtype: bytes """ if value == 0: return b'\x00' result = [] while value != 0: byte ...
[ "def", "leb128_encode", "(", "value", ")", ":", "if", "value", "==", "0", ":", "return", "b'\\x00'", "result", "=", "[", "]", "while", "value", "!=", "0", ":", "byte", "=", "value", "&", "0x7f", "value", ">>=", "7", "if", "value", "!=", "0", ":", ...
Encodes an integer using LEB128. :param int value: The value to encode. :return: The LEB128-encoded integer. :rtype: bytes
[ "Encodes", "an", "integer", "using", "LEB128", "." ]
e8eb5b80b9703c80980cb275dd85f17d50e39c60
https://github.com/OpenAssets/openassets/blob/e8eb5b80b9703c80980cb275dd85f17d50e39c60/openassets/protocol.py#L506-L525
52,878
gkbrk/hackchat
hackchat.py
HackChat.run
def run(self): """Sends data to the callback functions.""" while True: result = json.loads(self.ws.recv()) if result["cmd"] == "chat" and not result["nick"] == self.nick: for handler in list(self.on_message): handler(self, result["text"], resul...
python
def run(self): """Sends data to the callback functions.""" while True: result = json.loads(self.ws.recv()) if result["cmd"] == "chat" and not result["nick"] == self.nick: for handler in list(self.on_message): handler(self, result["text"], resul...
[ "def", "run", "(", "self", ")", ":", "while", "True", ":", "result", "=", "json", ".", "loads", "(", "self", ".", "ws", ".", "recv", "(", ")", ")", "if", "result", "[", "\"cmd\"", "]", "==", "\"chat\"", "and", "not", "result", "[", "\"nick\"", "]...
Sends data to the callback functions.
[ "Sends", "data", "to", "the", "callback", "functions", "." ]
f8c96dc1ce528ba7800130e43848127f0db3e057
https://github.com/gkbrk/hackchat/blob/f8c96dc1ce528ba7800130e43848127f0db3e057/hackchat.py#L43-L60
52,879
ib-lundgren/flask-oauthprovider
examples/mongo_demoprovider/login.py
create_profile
def create_profile(): """If this is the user's first login, the create_or_login function will redirect here so that the user can set up his profile. """ if g.user is not None or 'openid' not in session: return redirect(url_for('index')) if request.method == 'POST': name = request.for...
python
def create_profile(): """If this is the user's first login, the create_or_login function will redirect here so that the user can set up his profile. """ if g.user is not None or 'openid' not in session: return redirect(url_for('index')) if request.method == 'POST': name = request.for...
[ "def", "create_profile", "(", ")", ":", "if", "g", ".", "user", "is", "not", "None", "or", "'openid'", "not", "in", "session", ":", "return", "redirect", "(", "url_for", "(", "'index'", ")", ")", "if", "request", ".", "method", "==", "'POST'", ":", "...
If this is the user's first login, the create_or_login function will redirect here so that the user can set up his profile.
[ "If", "this", "is", "the", "user", "s", "first", "login", "the", "create_or_login", "function", "will", "redirect", "here", "so", "that", "the", "user", "can", "set", "up", "his", "profile", "." ]
6c91e8c11fc3cee410cb755d52d9d2c5331ee324
https://github.com/ib-lundgren/flask-oauthprovider/blob/6c91e8c11fc3cee410cb755d52d9d2c5331ee324/examples/mongo_demoprovider/login.py#L65-L82
52,880
fdiskyou/kcshell
kcshell/kcshell.py
Kcshell.do_setmode
def do_setmode(self, arg): ''' shift from ASM to DISASM ''' op_modes = config.get_op_modes() if arg in op_modes: op_mode = op_modes[arg] op_mode.cmdloop() else: print("Error: unknown operational mode, please use 'help setmode'.")
python
def do_setmode(self, arg): ''' shift from ASM to DISASM ''' op_modes = config.get_op_modes() if arg in op_modes: op_mode = op_modes[arg] op_mode.cmdloop() else: print("Error: unknown operational mode, please use 'help setmode'.")
[ "def", "do_setmode", "(", "self", ",", "arg", ")", ":", "op_modes", "=", "config", ".", "get_op_modes", "(", ")", "if", "arg", "in", "op_modes", ":", "op_mode", "=", "op_modes", "[", "arg", "]", "op_mode", ".", "cmdloop", "(", ")", "else", ":", "prin...
shift from ASM to DISASM
[ "shift", "from", "ASM", "to", "DISASM" ]
f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f
https://github.com/fdiskyou/kcshell/blob/f8ea1111a4fcad1c0e31c4b7a9cb91b79bb0b32f/kcshell/kcshell.py#L44-L51
52,881
razor-x/scipy-data_fitting
scipy_data_fitting/model.py
Model.replace
def replace(self, expression, replacements): """ All purpose method to reduce an expression by applying successive replacement rules. `expression` is either a SymPy expression or a key in `scipy_data_fitting.Model.expressions`. `replacements` can be any of the following...
python
def replace(self, expression, replacements): """ All purpose method to reduce an expression by applying successive replacement rules. `expression` is either a SymPy expression or a key in `scipy_data_fitting.Model.expressions`. `replacements` can be any of the following...
[ "def", "replace", "(", "self", ",", "expression", ",", "replacements", ")", ":", "# When expression is a string,", "# get the expressions from self.expressions.", "if", "isinstance", "(", "expression", ",", "str", ")", ":", "expression", "=", "self", ".", "expressions...
All purpose method to reduce an expression by applying successive replacement rules. `expression` is either a SymPy expression or a key in `scipy_data_fitting.Model.expressions`. `replacements` can be any of the following, or a list of any combination of the following: ...
[ "All", "purpose", "method", "to", "reduce", "an", "expression", "by", "applying", "successive", "replacement", "rules", "." ]
c756a645da8629699b3f22244bfb7d5d4d88b179
https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/model.py#L135-L184
52,882
rbarrois/tdparser
tdparser/topdown.py
Parser._forward
def _forward(self): """Advance to the next token. Internal methods, updates: - self.current_token - self.current_pos Raises: MissingTokensError: when trying to advance beyond the end of the token flow. """ try: self.curren...
python
def _forward(self): """Advance to the next token. Internal methods, updates: - self.current_token - self.current_pos Raises: MissingTokensError: when trying to advance beyond the end of the token flow. """ try: self.curren...
[ "def", "_forward", "(", "self", ")", ":", "try", ":", "self", ".", "current_token", "=", "next", "(", "self", ".", "tokens", ")", "except", "StopIteration", ":", "raise", "MissingTokensError", "(", "\"Unexpected end of token stream at %d.\"", "%", "self", ".", ...
Advance to the next token. Internal methods, updates: - self.current_token - self.current_pos Raises: MissingTokensError: when trying to advance beyond the end of the token flow.
[ "Advance", "to", "the", "next", "token", "." ]
31225aa5149f2ab507ccce15a020fbb37d0acb56
https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/topdown.py#L144-L160
52,883
rbarrois/tdparser
tdparser/topdown.py
Parser.consume
def consume(self, expect_class=None): """Retrieve the current token, then advance the parser. If an expected class is provided, it will assert that the current token matches that class (is an instance). Note that when calling a token's nud() or led() functions, the "current" to...
python
def consume(self, expect_class=None): """Retrieve the current token, then advance the parser. If an expected class is provided, it will assert that the current token matches that class (is an instance). Note that when calling a token's nud() or led() functions, the "current" to...
[ "def", "consume", "(", "self", ",", "expect_class", "=", "None", ")", ":", "if", "expect_class", "and", "not", "isinstance", "(", "self", ".", "current_token", ",", "expect_class", ")", ":", "raise", "InvalidTokenError", "(", "\"Unexpected token at %d: got %r, exp...
Retrieve the current token, then advance the parser. If an expected class is provided, it will assert that the current token matches that class (is an instance). Note that when calling a token's nud() or led() functions, the "current" token is the token following the token whose method...
[ "Retrieve", "the", "current", "token", "then", "advance", "the", "parser", "." ]
31225aa5149f2ab507ccce15a020fbb37d0acb56
https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/topdown.py#L162-L184
52,884
rbarrois/tdparser
tdparser/topdown.py
Parser.expression
def expression(self, rbp=0): """Extract an expression from the flow of tokens. Args: rbp (int): the "right binding power" of the previous token. This represents the (right) precedence of the previous token, and will be compared to the (left) precedence of nex...
python
def expression(self, rbp=0): """Extract an expression from the flow of tokens. Args: rbp (int): the "right binding power" of the previous token. This represents the (right) precedence of the previous token, and will be compared to the (left) precedence of nex...
[ "def", "expression", "(", "self", ",", "rbp", "=", "0", ")", ":", "prev_token", "=", "self", ".", "consume", "(", ")", "# Retrieve the value from the previous token situated at the", "# leftmost point in the expression", "left", "=", "prev_token", ".", "nud", "(", "...
Extract an expression from the flow of tokens. Args: rbp (int): the "right binding power" of the previous token. This represents the (right) precedence of the previous token, and will be compared to the (left) precedence of next tokens. Returns: ...
[ "Extract", "an", "expression", "from", "the", "flow", "of", "tokens", "." ]
31225aa5149f2ab507ccce15a020fbb37d0acb56
https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/topdown.py#L186-L210
52,885
rbarrois/tdparser
tdparser/topdown.py
Parser.parse
def parse(self): """Parse the flow of tokens, and return their evaluation.""" expr = self.expression() if not isinstance(self.current_token, EndToken): raise InvalidTokenError("Unconsumed trailing tokens.") return expr
python
def parse(self): """Parse the flow of tokens, and return their evaluation.""" expr = self.expression() if not isinstance(self.current_token, EndToken): raise InvalidTokenError("Unconsumed trailing tokens.") return expr
[ "def", "parse", "(", "self", ")", ":", "expr", "=", "self", ".", "expression", "(", ")", "if", "not", "isinstance", "(", "self", ".", "current_token", ",", "EndToken", ")", ":", "raise", "InvalidTokenError", "(", "\"Unconsumed trailing tokens.\"", ")", "retu...
Parse the flow of tokens, and return their evaluation.
[ "Parse", "the", "flow", "of", "tokens", "and", "return", "their", "evaluation", "." ]
31225aa5149f2ab507ccce15a020fbb37d0acb56
https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/topdown.py#L212-L217
52,886
dimagi/quickcache
quickcache/quickcache_helper.py
QuickCacheHelper.set_cached_value
def set_cached_value(self, *args, **kwargs): """ Sets the cached value """ key = self.get_cache_key(*args, **kwargs) logger.debug(key) return namedtuple('Settable', ['to'])(lambda value: self.cache.set(key, value))
python
def set_cached_value(self, *args, **kwargs): """ Sets the cached value """ key = self.get_cache_key(*args, **kwargs) logger.debug(key) return namedtuple('Settable', ['to'])(lambda value: self.cache.set(key, value))
[ "def", "set_cached_value", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "key", "=", "self", ".", "get_cache_key", "(", "*", "args", ",", "*", "*", "kwargs", ")", "logger", ".", "debug", "(", "key", ")", "return", "namedtuple", ...
Sets the cached value
[ "Sets", "the", "cached", "value" ]
fe62e2c6b9690859c57534058637fc6fcd4f4e0e
https://github.com/dimagi/quickcache/blob/fe62e2c6b9690859c57534058637fc6fcd4f4e0e/quickcache/quickcache_helper.py#L86-L92
52,887
getnikola/coil
coil/__main__.py
devserver
def devserver(arguments): """Run a development server.""" import coil.web if coil.web.app: port = int(arguments['--port']) url = 'http://localhost:{0}/'.format(port) coil.web.configure_url(url) coil.web.app.config['DEBUG'] = True if arguments['--browser']: ...
python
def devserver(arguments): """Run a development server.""" import coil.web if coil.web.app: port = int(arguments['--port']) url = 'http://localhost:{0}/'.format(port) coil.web.configure_url(url) coil.web.app.config['DEBUG'] = True if arguments['--browser']: ...
[ "def", "devserver", "(", "arguments", ")", ":", "import", "coil", ".", "web", "if", "coil", ".", "web", ".", "app", ":", "port", "=", "int", "(", "arguments", "[", "'--port'", "]", ")", "url", "=", "'http://localhost:{0}/'", ".", "format", "(", "port",...
Run a development server.
[ "Run", "a", "development", "server", "." ]
80ef1827460b0691cf2c98351a14d88e235c9899
https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/__main__.py#L81-L98
52,888
getnikola/coil
coil/__main__.py
unlock
def unlock(arguments): """Unlock the database.""" import redis u = coil.utils.ask("Redis URL", "redis://localhost:6379/0") db = redis.StrictRedis.from_url(u) db.set('site:lock', 0) print("Database unlocked.") return 0
python
def unlock(arguments): """Unlock the database.""" import redis u = coil.utils.ask("Redis URL", "redis://localhost:6379/0") db = redis.StrictRedis.from_url(u) db.set('site:lock', 0) print("Database unlocked.") return 0
[ "def", "unlock", "(", "arguments", ")", ":", "import", "redis", "u", "=", "coil", ".", "utils", ".", "ask", "(", "\"Redis URL\"", ",", "\"redis://localhost:6379/0\"", ")", "db", "=", "redis", ".", "StrictRedis", ".", "from_url", "(", "u", ")", "db", ".",...
Unlock the database.
[ "Unlock", "the", "database", "." ]
80ef1827460b0691cf2c98351a14d88e235c9899
https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/__main__.py#L101-L108
52,889
chigby/mtg
mtglib/gatherer_request.py
ConditionParser.expr
def expr(self, token_stream, token): """Top level parsing function. An expression is <keyword> <OR> <expr> or <keyword> <SEP> <expr> or <keyword> """ lval = self.keyword(token_stream, token, {}) token = next(token_stream) if t...
python
def expr(self, token_stream, token): """Top level parsing function. An expression is <keyword> <OR> <expr> or <keyword> <SEP> <expr> or <keyword> """ lval = self.keyword(token_stream, token, {}) token = next(token_stream) if t...
[ "def", "expr", "(", "self", ",", "token_stream", ",", "token", ")", ":", "lval", "=", "self", ".", "keyword", "(", "token_stream", ",", "token", ",", "{", "}", ")", "token", "=", "next", "(", "token_stream", ")", "if", "token", "[", "0", "]", "==",...
Top level parsing function. An expression is <keyword> <OR> <expr> or <keyword> <SEP> <expr> or <keyword>
[ "Top", "level", "parsing", "function", "." ]
c12976d6c7e13d6859a0fbac4c057dc9529de473
https://github.com/chigby/mtg/blob/c12976d6c7e13d6859a0fbac4c057dc9529de473/mtglib/gatherer_request.py#L197-L218
52,890
chigby/mtg
mtglib/gatherer_request.py
ConditionParser.keyword
def keyword(self, token_stream, token, operators): """Lowest level parsing function. A keyword consists of zero or more prefix operators (NOT, or COMPARISON) followed by a TEXT, COLOR, or NUMBER block. """ if token[0] == 'TEXT' or token[0] == 'COLOR': return SearchK...
python
def keyword(self, token_stream, token, operators): """Lowest level parsing function. A keyword consists of zero or more prefix operators (NOT, or COMPARISON) followed by a TEXT, COLOR, or NUMBER block. """ if token[0] == 'TEXT' or token[0] == 'COLOR': return SearchK...
[ "def", "keyword", "(", "self", ",", "token_stream", ",", "token", ",", "operators", ")", ":", "if", "token", "[", "0", "]", "==", "'TEXT'", "or", "token", "[", "0", "]", "==", "'COLOR'", ":", "return", "SearchKeyword", "(", "token", "[", "1", "]", ...
Lowest level parsing function. A keyword consists of zero or more prefix operators (NOT, or COMPARISON) followed by a TEXT, COLOR, or NUMBER block.
[ "Lowest", "level", "parsing", "function", "." ]
c12976d6c7e13d6859a0fbac4c057dc9529de473
https://github.com/chigby/mtg/blob/c12976d6c7e13d6859a0fbac4c057dc9529de473/mtglib/gatherer_request.py#L220-L240
52,891
chigby/mtg
mtglib/gatherer_request.py
ConditionParser.parse
def parse(self, text): """Parse the given text, return a list of Keywords.""" token_stream = self.lexer.tokenize(text) return self.expr(token_stream, next(token_stream))
python
def parse(self, text): """Parse the given text, return a list of Keywords.""" token_stream = self.lexer.tokenize(text) return self.expr(token_stream, next(token_stream))
[ "def", "parse", "(", "self", ",", "text", ")", ":", "token_stream", "=", "self", ".", "lexer", ".", "tokenize", "(", "text", ")", "return", "self", ".", "expr", "(", "token_stream", ",", "next", "(", "token_stream", ")", ")" ]
Parse the given text, return a list of Keywords.
[ "Parse", "the", "given", "text", "return", "a", "list", "of", "Keywords", "." ]
c12976d6c7e13d6859a0fbac4c057dc9529de473
https://github.com/chigby/mtg/blob/c12976d6c7e13d6859a0fbac4c057dc9529de473/mtglib/gatherer_request.py#L242-L245
52,892
glenfant/openxmllib
openxmllib/document.py
Document.customProperties
def customProperties(self): """Document custom properties added by the document author. We canot convert the properties as indicated with the http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes namespace :return: mapping of metadata """ rval = {...
python
def customProperties(self): """Document custom properties added by the document author. We canot convert the properties as indicated with the http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes namespace :return: mapping of metadata """ rval = {...
[ "def", "customProperties", "(", "self", ")", ":", "rval", "=", "{", "}", "if", "len", "(", "self", ".", "content_types", ".", "getPathsForContentType", "(", "contenttypes", ".", "CT_CUSTOM_PROPS", ")", ")", "==", "0", ":", "# We may have no custom properties at ...
Document custom properties added by the document author. We canot convert the properties as indicated with the http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes namespace :return: mapping of metadata
[ "Document", "custom", "properties", "added", "by", "the", "document", "author", "." ]
c8208f8ecd9fc3ef1e73c1db68081a65361afb3f
https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/document.py#L142-L162
52,893
glenfant/openxmllib
openxmllib/document.py
Document.allProperties
def allProperties(self): """Helper that merges core, extended and custom properties :return: mapping of all properties """ rval = {} rval.update(self.coreProperties) rval.update(self.extendedProperties) rval.update(self.customProperties) return rval
python
def allProperties(self): """Helper that merges core, extended and custom properties :return: mapping of all properties """ rval = {} rval.update(self.coreProperties) rval.update(self.extendedProperties) rval.update(self.customProperties) return rval
[ "def", "allProperties", "(", "self", ")", ":", "rval", "=", "{", "}", "rval", ".", "update", "(", "self", ".", "coreProperties", ")", "rval", ".", "update", "(", "self", ".", "extendedProperties", ")", "rval", ".", "update", "(", "self", ".", "customPr...
Helper that merges core, extended and custom properties :return: mapping of all properties
[ "Helper", "that", "merges", "core", "extended", "and", "custom", "properties" ]
c8208f8ecd9fc3ef1e73c1db68081a65361afb3f
https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/document.py#L166-L175
52,894
glenfant/openxmllib
openxmllib/document.py
Document.documentCover
def documentCover(self): """Cover page image :return: (file extension, file object) tuple. """ rels_pth = os.path.join(self._cache_dir, "_rels", ".rels") rels_xml = lxml.etree.parse(xmlFile(rels_pth, 'rb')) thumb_ns = ns_map["thumbnails"] thumb_elm_xpr = "relatio...
python
def documentCover(self): """Cover page image :return: (file extension, file object) tuple. """ rels_pth = os.path.join(self._cache_dir, "_rels", ".rels") rels_xml = lxml.etree.parse(xmlFile(rels_pth, 'rb')) thumb_ns = ns_map["thumbnails"] thumb_elm_xpr = "relatio...
[ "def", "documentCover", "(", "self", ")", ":", "rels_pth", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_cache_dir", ",", "\"_rels\"", ",", "\".rels\"", ")", "rels_xml", "=", "lxml", ".", "etree", ".", "parse", "(", "xmlFile", "(", "rels_pth...
Cover page image :return: (file extension, file object) tuple.
[ "Cover", "page", "image" ]
c8208f8ecd9fc3ef1e73c1db68081a65361afb3f
https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/document.py#L178-L201
52,895
glenfant/openxmllib
openxmllib/document.py
Document.indexableText
def indexableText(self, include_properties=True): """Words found in the various texts of the document. :param include_properties: Adds words from properties :return: Space separated words of the document. """ text = set() for extractor in self._text_extractors: ...
python
def indexableText(self, include_properties=True): """Words found in the various texts of the document. :param include_properties: Adds words from properties :return: Space separated words of the document. """ text = set() for extractor in self._text_extractors: ...
[ "def", "indexableText", "(", "self", ",", "include_properties", "=", "True", ")", ":", "text", "=", "set", "(", ")", "for", "extractor", "in", "self", ".", "_text_extractors", ":", "if", "extractor", ".", "content_type", "in", "self", ".", "content_types", ...
Words found in the various texts of the document. :param include_properties: Adds words from properties :return: Space separated words of the document.
[ "Words", "found", "in", "the", "various", "texts", "of", "the", "document", "." ]
c8208f8ecd9fc3ef1e73c1db68081a65361afb3f
https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/document.py#L204-L221
52,896
glenfant/openxmllib
openxmllib/document.py
Document.canProcessFilename
def canProcessFilename(cls, filename): """Check if we can process such file based on name :param filename: File name as 'mydoc.docx' :return: True if we can process such file """ supported_patterns = cls._extpattern_to_mime.keys() for pattern in supported_patterns: ...
python
def canProcessFilename(cls, filename): """Check if we can process such file based on name :param filename: File name as 'mydoc.docx' :return: True if we can process such file """ supported_patterns = cls._extpattern_to_mime.keys() for pattern in supported_patterns: ...
[ "def", "canProcessFilename", "(", "cls", ",", "filename", ")", ":", "supported_patterns", "=", "cls", ".", "_extpattern_to_mime", ".", "keys", "(", ")", "for", "pattern", "in", "supported_patterns", ":", "if", "fnmatch", ".", "fnmatch", "(", "filename", ",", ...
Check if we can process such file based on name :param filename: File name as 'mydoc.docx' :return: True if we can process such file
[ "Check", "if", "we", "can", "process", "such", "file", "based", "on", "name" ]
c8208f8ecd9fc3ef1e73c1db68081a65361afb3f
https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/document.py#L246-L256
52,897
rbarrois/tdparser
tdparser/lexer.py
TokenRegistry.register
def register(self, token, regexp): """Register a token. Args: token (Token): the token class to register regexp (str): the regexp for that token """ self._tokens.append((token, re.compile(regexp)))
python
def register(self, token, regexp): """Register a token. Args: token (Token): the token class to register regexp (str): the regexp for that token """ self._tokens.append((token, re.compile(regexp)))
[ "def", "register", "(", "self", ",", "token", ",", "regexp", ")", ":", "self", ".", "_tokens", ".", "append", "(", "(", "token", ",", "re", ".", "compile", "(", "regexp", ")", ")", ")" ]
Register a token. Args: token (Token): the token class to register regexp (str): the regexp for that token
[ "Register", "a", "token", "." ]
31225aa5149f2ab507ccce15a020fbb37d0acb56
https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/lexer.py#L29-L36
52,898
rbarrois/tdparser
tdparser/lexer.py
TokenRegistry.matching_tokens
def matching_tokens(self, text, start=0): """Retrieve all token definitions matching the beginning of a text. Args: text (str): the text to test start (int): the position where matches should be searched in the string (see re.match(rx, txt, pos)) Yields:...
python
def matching_tokens(self, text, start=0): """Retrieve all token definitions matching the beginning of a text. Args: text (str): the text to test start (int): the position where matches should be searched in the string (see re.match(rx, txt, pos)) Yields:...
[ "def", "matching_tokens", "(", "self", ",", "text", ",", "start", "=", "0", ")", ":", "for", "token_class", ",", "regexp", "in", "self", ".", "_tokens", ":", "match", "=", "regexp", ".", "match", "(", "text", ",", "pos", "=", "start", ")", "if", "m...
Retrieve all token definitions matching the beginning of a text. Args: text (str): the text to test start (int): the position where matches should be searched in the string (see re.match(rx, txt, pos)) Yields: (token_class, re.Match): all token class...
[ "Retrieve", "all", "token", "definitions", "matching", "the", "beginning", "of", "a", "text", "." ]
31225aa5149f2ab507ccce15a020fbb37d0acb56
https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/lexer.py#L38-L53
52,899
rbarrois/tdparser
tdparser/lexer.py
TokenRegistry.get_token
def get_token(self, text, start=0): """Retrieve the next token from some text. Args: text (str): the text from which tokens should be extracted Returns: (token_kind, token_text): the token kind and its content. """ best_class = best_match = None ...
python
def get_token(self, text, start=0): """Retrieve the next token from some text. Args: text (str): the text from which tokens should be extracted Returns: (token_kind, token_text): the token kind and its content. """ best_class = best_match = None ...
[ "def", "get_token", "(", "self", ",", "text", ",", "start", "=", "0", ")", ":", "best_class", "=", "best_match", "=", "None", "for", "token_class", ",", "match", "in", "self", ".", "matching_tokens", "(", "text", ")", ":", "if", "best_match", "and", "b...
Retrieve the next token from some text. Args: text (str): the text from which tokens should be extracted Returns: (token_kind, token_text): the token kind and its content.
[ "Retrieve", "the", "next", "token", "from", "some", "text", "." ]
31225aa5149f2ab507ccce15a020fbb37d0acb56
https://github.com/rbarrois/tdparser/blob/31225aa5149f2ab507ccce15a020fbb37d0acb56/tdparser/lexer.py#L55-L72