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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
224,900 | niklasf/python-chess | chess/__init__.py | Board.uci | def uci(self, move: Move, *, chess960: Optional[bool] = None) -> str:
"""
Gets the UCI notation of the move.
*chess960* defaults to the mode of the board. Pass ``True`` to force
Chess960 mode.
"""
if chess960 is None:
chess960 = self.chess960
move = ... | python | def uci(self, move: Move, *, chess960: Optional[bool] = None) -> str:
"""
Gets the UCI notation of the move.
*chess960* defaults to the mode of the board. Pass ``True`` to force
Chess960 mode.
"""
if chess960 is None:
chess960 = self.chess960
move = ... | [
"def",
"uci",
"(",
"self",
",",
"move",
":",
"Move",
",",
"*",
",",
"chess960",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"chess960",
"is",
"None",
":",
"chess960",
"=",
"self",
".",
"chess960",
"move",
"=",
"se... | Gets the UCI notation of the move.
*chess960* defaults to the mode of the board. Pass ``True`` to force
Chess960 mode. | [
"Gets",
"the",
"UCI",
"notation",
"of",
"the",
"move",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2777-L2789 |
224,901 | niklasf/python-chess | chess/__init__.py | Board.parse_uci | def parse_uci(self, uci: str) -> Move:
"""
Parses the given move in UCI notation.
Supports both Chess960 and standard UCI notation.
The returned move is guaranteed to be either legal or a null move.
:raises: :exc:`ValueError` if the move is invalid or illegal in the
... | python | def parse_uci(self, uci: str) -> Move:
"""
Parses the given move in UCI notation.
Supports both Chess960 and standard UCI notation.
The returned move is guaranteed to be either legal or a null move.
:raises: :exc:`ValueError` if the move is invalid or illegal in the
... | [
"def",
"parse_uci",
"(",
"self",
",",
"uci",
":",
"str",
")",
"->",
"Move",
":",
"move",
"=",
"Move",
".",
"from_uci",
"(",
"uci",
")",
"if",
"not",
"move",
":",
"return",
"move",
"move",
"=",
"self",
".",
"_to_chess960",
"(",
"move",
")",
"move",
... | Parses the given move in UCI notation.
Supports both Chess960 and standard UCI notation.
The returned move is guaranteed to be either legal or a null move.
:raises: :exc:`ValueError` if the move is invalid or illegal in the
current position (but not a null move). | [
"Parses",
"the",
"given",
"move",
"in",
"UCI",
"notation",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2791-L2813 |
224,902 | niklasf/python-chess | chess/__init__.py | Board.push_uci | def push_uci(self, uci: str) -> Move:
"""
Parses a move in UCI notation and puts it on the move stack.
Returns the move.
:raises: :exc:`ValueError` if the move is invalid or illegal in the
current position (but not a null move).
"""
move = self.parse_uci(uci... | python | def push_uci(self, uci: str) -> Move:
"""
Parses a move in UCI notation and puts it on the move stack.
Returns the move.
:raises: :exc:`ValueError` if the move is invalid or illegal in the
current position (but not a null move).
"""
move = self.parse_uci(uci... | [
"def",
"push_uci",
"(",
"self",
",",
"uci",
":",
"str",
")",
"->",
"Move",
":",
"move",
"=",
"self",
".",
"parse_uci",
"(",
"uci",
")",
"self",
".",
"push",
"(",
"move",
")",
"return",
"move"
] | Parses a move in UCI notation and puts it on the move stack.
Returns the move.
:raises: :exc:`ValueError` if the move is invalid or illegal in the
current position (but not a null move). | [
"Parses",
"a",
"move",
"in",
"UCI",
"notation",
"and",
"puts",
"it",
"on",
"the",
"move",
"stack",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2815-L2826 |
224,903 | niklasf/python-chess | chess/__init__.py | Board.is_en_passant | def is_en_passant(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is an en passant capture."""
return (self.ep_square == move.to_square and
bool(self.pawns & BB_SQUARES[move.from_square]) and
abs(move.to_square - move.from_square) in [7, 9] and
... | python | def is_en_passant(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is an en passant capture."""
return (self.ep_square == move.to_square and
bool(self.pawns & BB_SQUARES[move.from_square]) and
abs(move.to_square - move.from_square) in [7, 9] and
... | [
"def",
"is_en_passant",
"(",
"self",
",",
"move",
":",
"Move",
")",
"->",
"bool",
":",
"return",
"(",
"self",
".",
"ep_square",
"==",
"move",
".",
"to_square",
"and",
"bool",
"(",
"self",
".",
"pawns",
"&",
"BB_SQUARES",
"[",
"move",
".",
"from_square"... | Checks if the given pseudo-legal move is an en passant capture. | [
"Checks",
"if",
"the",
"given",
"pseudo",
"-",
"legal",
"move",
"is",
"an",
"en",
"passant",
"capture",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2865-L2870 |
224,904 | niklasf/python-chess | chess/__init__.py | Board.is_capture | def is_capture(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is a capture."""
return bool(BB_SQUARES[move.to_square] & self.occupied_co[not self.turn]) or self.is_en_passant(move) | python | def is_capture(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is a capture."""
return bool(BB_SQUARES[move.to_square] & self.occupied_co[not self.turn]) or self.is_en_passant(move) | [
"def",
"is_capture",
"(",
"self",
",",
"move",
":",
"Move",
")",
"->",
"bool",
":",
"return",
"bool",
"(",
"BB_SQUARES",
"[",
"move",
".",
"to_square",
"]",
"&",
"self",
".",
"occupied_co",
"[",
"not",
"self",
".",
"turn",
"]",
")",
"or",
"self",
"... | Checks if the given pseudo-legal move is a capture. | [
"Checks",
"if",
"the",
"given",
"pseudo",
"-",
"legal",
"move",
"is",
"a",
"capture",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2872-L2874 |
224,905 | niklasf/python-chess | chess/__init__.py | Board.is_zeroing | def is_zeroing(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is a capture or pawn move."""
return bool(BB_SQUARES[move.from_square] & self.pawns or BB_SQUARES[move.to_square] & self.occupied_co[not self.turn]) | python | def is_zeroing(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is a capture or pawn move."""
return bool(BB_SQUARES[move.from_square] & self.pawns or BB_SQUARES[move.to_square] & self.occupied_co[not self.turn]) | [
"def",
"is_zeroing",
"(",
"self",
",",
"move",
":",
"Move",
")",
"->",
"bool",
":",
"return",
"bool",
"(",
"BB_SQUARES",
"[",
"move",
".",
"from_square",
"]",
"&",
"self",
".",
"pawns",
"or",
"BB_SQUARES",
"[",
"move",
".",
"to_square",
"]",
"&",
"se... | Checks if the given pseudo-legal move is a capture or pawn move. | [
"Checks",
"if",
"the",
"given",
"pseudo",
"-",
"legal",
"move",
"is",
"a",
"capture",
"or",
"pawn",
"move",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2876-L2878 |
224,906 | niklasf/python-chess | chess/__init__.py | Board.is_irreversible | def is_irreversible(self, move: Move) -> bool:
"""
Checks if the given pseudo-legal move is irreversible.
In standard chess, pawn moves, captures and moves that destroy castling
rights are irreversible.
"""
backrank = BB_RANK_1 if self.turn == WHITE else BB_RANK_8
... | python | def is_irreversible(self, move: Move) -> bool:
"""
Checks if the given pseudo-legal move is irreversible.
In standard chess, pawn moves, captures and moves that destroy castling
rights are irreversible.
"""
backrank = BB_RANK_1 if self.turn == WHITE else BB_RANK_8
... | [
"def",
"is_irreversible",
"(",
"self",
",",
"move",
":",
"Move",
")",
"->",
"bool",
":",
"backrank",
"=",
"BB_RANK_1",
"if",
"self",
".",
"turn",
"==",
"WHITE",
"else",
"BB_RANK_8",
"cr",
"=",
"self",
".",
"clean_castling_rights",
"(",
")",
"&",
"backran... | Checks if the given pseudo-legal move is irreversible.
In standard chess, pawn moves, captures and moves that destroy castling
rights are irreversible. | [
"Checks",
"if",
"the",
"given",
"pseudo",
"-",
"legal",
"move",
"is",
"irreversible",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2880-L2892 |
224,907 | niklasf/python-chess | chess/__init__.py | Board.is_castling | def is_castling(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is a castling move."""
if self.kings & BB_SQUARES[move.from_square]:
diff = square_file(move.from_square) - square_file(move.to_square)
return abs(diff) > 1 or bool(self.rooks & self.occupied_co[s... | python | def is_castling(self, move: Move) -> bool:
"""Checks if the given pseudo-legal move is a castling move."""
if self.kings & BB_SQUARES[move.from_square]:
diff = square_file(move.from_square) - square_file(move.to_square)
return abs(diff) > 1 or bool(self.rooks & self.occupied_co[s... | [
"def",
"is_castling",
"(",
"self",
",",
"move",
":",
"Move",
")",
"->",
"bool",
":",
"if",
"self",
".",
"kings",
"&",
"BB_SQUARES",
"[",
"move",
".",
"from_square",
"]",
":",
"diff",
"=",
"square_file",
"(",
"move",
".",
"from_square",
")",
"-",
"squ... | Checks if the given pseudo-legal move is a castling move. | [
"Checks",
"if",
"the",
"given",
"pseudo",
"-",
"legal",
"move",
"is",
"a",
"castling",
"move",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2894-L2899 |
224,908 | niklasf/python-chess | chess/__init__.py | Board.is_kingside_castling | def is_kingside_castling(self, move: Move) -> bool:
"""
Checks if the given pseudo-legal move is a kingside castling move.
"""
return self.is_castling(move) and square_file(move.to_square) > square_file(move.from_square) | python | def is_kingside_castling(self, move: Move) -> bool:
"""
Checks if the given pseudo-legal move is a kingside castling move.
"""
return self.is_castling(move) and square_file(move.to_square) > square_file(move.from_square) | [
"def",
"is_kingside_castling",
"(",
"self",
",",
"move",
":",
"Move",
")",
"->",
"bool",
":",
"return",
"self",
".",
"is_castling",
"(",
"move",
")",
"and",
"square_file",
"(",
"move",
".",
"to_square",
")",
">",
"square_file",
"(",
"move",
".",
"from_sq... | Checks if the given pseudo-legal move is a kingside castling move. | [
"Checks",
"if",
"the",
"given",
"pseudo",
"-",
"legal",
"move",
"is",
"a",
"kingside",
"castling",
"move",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2901-L2905 |
224,909 | niklasf/python-chess | chess/__init__.py | Board.has_castling_rights | def has_castling_rights(self, color: Color) -> bool:
"""Checks if the given side has castling rights."""
backrank = BB_RANK_1 if color == WHITE else BB_RANK_8
return bool(self.clean_castling_rights() & backrank) | python | def has_castling_rights(self, color: Color) -> bool:
"""Checks if the given side has castling rights."""
backrank = BB_RANK_1 if color == WHITE else BB_RANK_8
return bool(self.clean_castling_rights() & backrank) | [
"def",
"has_castling_rights",
"(",
"self",
",",
"color",
":",
"Color",
")",
"->",
"bool",
":",
"backrank",
"=",
"BB_RANK_1",
"if",
"color",
"==",
"WHITE",
"else",
"BB_RANK_8",
"return",
"bool",
"(",
"self",
".",
"clean_castling_rights",
"(",
")",
"&",
"bac... | Checks if the given side has castling rights. | [
"Checks",
"if",
"the",
"given",
"side",
"has",
"castling",
"rights",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L2969-L2972 |
224,910 | niklasf/python-chess | chess/__init__.py | Board.has_chess960_castling_rights | def has_chess960_castling_rights(self) -> bool:
"""
Checks if there are castling rights that are only possible in Chess960.
"""
# Get valid Chess960 castling rights.
chess960 = self.chess960
self.chess960 = True
castling_rights = self.clean_castling_rights()
... | python | def has_chess960_castling_rights(self) -> bool:
"""
Checks if there are castling rights that are only possible in Chess960.
"""
# Get valid Chess960 castling rights.
chess960 = self.chess960
self.chess960 = True
castling_rights = self.clean_castling_rights()
... | [
"def",
"has_chess960_castling_rights",
"(",
"self",
")",
"->",
"bool",
":",
"# Get valid Chess960 castling rights.",
"chess960",
"=",
"self",
".",
"chess960",
"self",
".",
"chess960",
"=",
"True",
"castling_rights",
"=",
"self",
".",
"clean_castling_rights",
"(",
")... | Checks if there are castling rights that are only possible in Chess960. | [
"Checks",
"if",
"there",
"are",
"castling",
"rights",
"that",
"are",
"only",
"possible",
"in",
"Chess960",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L3016-L3038 |
224,911 | niklasf/python-chess | chess/__init__.py | Board.status | def status(self) -> Status:
"""
Gets a bitmask of possible problems with the position.
Move making, generation and validation are only guaranteed to work on
a completely valid board.
:data:`~chess.STATUS_VALID` for a completely valid board.
Otherwise, bitwise combinati... | python | def status(self) -> Status:
"""
Gets a bitmask of possible problems with the position.
Move making, generation and validation are only guaranteed to work on
a completely valid board.
:data:`~chess.STATUS_VALID` for a completely valid board.
Otherwise, bitwise combinati... | [
"def",
"status",
"(",
"self",
")",
"->",
"Status",
":",
"errors",
"=",
"STATUS_VALID",
"# There must be at least one piece.",
"if",
"not",
"self",
".",
"occupied",
":",
"errors",
"|=",
"STATUS_EMPTY",
"# There must be exactly one king of each color.",
"if",
"not",
"se... | Gets a bitmask of possible problems with the position.
Move making, generation and validation are only guaranteed to work on
a completely valid board.
:data:`~chess.STATUS_VALID` for a completely valid board.
Otherwise, bitwise combinations of:
:data:`~chess.STATUS_NO_WHITE_KI... | [
"Gets",
"a",
"bitmask",
"of",
"possible",
"problems",
"with",
"the",
"position",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L3040-L3108 |
224,912 | niklasf/python-chess | chess/__init__.py | SquareSet.remove | def remove(self, square: Square) -> None:
"""
Removes a square from the set.
:raises: :exc:`KeyError` if the given square was not in the set.
"""
mask = BB_SQUARES[square]
if self.mask & mask:
self.mask ^= mask
else:
raise KeyError(square) | python | def remove(self, square: Square) -> None:
"""
Removes a square from the set.
:raises: :exc:`KeyError` if the given square was not in the set.
"""
mask = BB_SQUARES[square]
if self.mask & mask:
self.mask ^= mask
else:
raise KeyError(square) | [
"def",
"remove",
"(",
"self",
",",
"square",
":",
"Square",
")",
"->",
"None",
":",
"mask",
"=",
"BB_SQUARES",
"[",
"square",
"]",
"if",
"self",
".",
"mask",
"&",
"mask",
":",
"self",
".",
"mask",
"^=",
"mask",
"else",
":",
"raise",
"KeyError",
"("... | Removes a square from the set.
:raises: :exc:`KeyError` if the given square was not in the set. | [
"Removes",
"a",
"square",
"from",
"the",
"set",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L3695-L3705 |
224,913 | niklasf/python-chess | chess/__init__.py | SquareSet.pop | def pop(self) -> Square:
"""
Removes a square from the set and returns it.
:raises: :exc:`KeyError` on an empty set.
"""
if not self.mask:
raise KeyError("pop from empty SquareSet")
square = lsb(self.mask)
self.mask &= (self.mask - 1)
return ... | python | def pop(self) -> Square:
"""
Removes a square from the set and returns it.
:raises: :exc:`KeyError` on an empty set.
"""
if not self.mask:
raise KeyError("pop from empty SquareSet")
square = lsb(self.mask)
self.mask &= (self.mask - 1)
return ... | [
"def",
"pop",
"(",
"self",
")",
"->",
"Square",
":",
"if",
"not",
"self",
".",
"mask",
":",
"raise",
"KeyError",
"(",
"\"pop from empty SquareSet\"",
")",
"square",
"=",
"lsb",
"(",
"self",
".",
"mask",
")",
"self",
".",
"mask",
"&=",
"(",
"self",
".... | Removes a square from the set and returns it.
:raises: :exc:`KeyError` on an empty set. | [
"Removes",
"a",
"square",
"from",
"the",
"set",
"and",
"returns",
"it",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L3707-L3718 |
224,914 | niklasf/python-chess | chess/__init__.py | SquareSet.tolist | def tolist(self) -> List[bool]:
"""Convert the set to a list of 64 bools."""
result = [False] * 64
for square in self:
result[square] = True
return result | python | def tolist(self) -> List[bool]:
"""Convert the set to a list of 64 bools."""
result = [False] * 64
for square in self:
result[square] = True
return result | [
"def",
"tolist",
"(",
"self",
")",
"->",
"List",
"[",
"bool",
"]",
":",
"result",
"=",
"[",
"False",
"]",
"*",
"64",
"for",
"square",
"in",
"self",
":",
"result",
"[",
"square",
"]",
"=",
"True",
"return",
"result"
] | Convert the set to a list of 64 bools. | [
"Convert",
"the",
"set",
"to",
"a",
"list",
"of",
"64",
"bools",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/__init__.py#L3734-L3739 |
224,915 | niklasf/python-chess | chess/variant.py | find_variant | def find_variant(name: str) -> Type[chess.Board]:
"""Looks for a variant board class by variant name."""
for variant in VARIANTS:
if any(alias.lower() == name.lower() for alias in variant.aliases):
return variant
raise ValueError("unsupported variant: {}".format(name)) | python | def find_variant(name: str) -> Type[chess.Board]:
"""Looks for a variant board class by variant name."""
for variant in VARIANTS:
if any(alias.lower() == name.lower() for alias in variant.aliases):
return variant
raise ValueError("unsupported variant: {}".format(name)) | [
"def",
"find_variant",
"(",
"name",
":",
"str",
")",
"->",
"Type",
"[",
"chess",
".",
"Board",
"]",
":",
"for",
"variant",
"in",
"VARIANTS",
":",
"if",
"any",
"(",
"alias",
".",
"lower",
"(",
")",
"==",
"name",
".",
"lower",
"(",
")",
"for",
"ali... | Looks for a variant board class by variant name. | [
"Looks",
"for",
"a",
"variant",
"board",
"class",
"by",
"variant",
"name",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/variant.py#L862-L867 |
224,916 | niklasf/python-chess | chess/polyglot.py | zobrist_hash | def zobrist_hash(board: chess.Board, *, _hasher: Callable[[chess.Board], int] = ZobristHasher(POLYGLOT_RANDOM_ARRAY)) -> int:
"""
Calculates the Polyglot Zobrist hash of the position.
A Zobrist hash is an XOR of pseudo-random values picked from
an array. Which values are picked is decided by features o... | python | def zobrist_hash(board: chess.Board, *, _hasher: Callable[[chess.Board], int] = ZobristHasher(POLYGLOT_RANDOM_ARRAY)) -> int:
"""
Calculates the Polyglot Zobrist hash of the position.
A Zobrist hash is an XOR of pseudo-random values picked from
an array. Which values are picked is decided by features o... | [
"def",
"zobrist_hash",
"(",
"board",
":",
"chess",
".",
"Board",
",",
"*",
",",
"_hasher",
":",
"Callable",
"[",
"[",
"chess",
".",
"Board",
"]",
",",
"int",
"]",
"=",
"ZobristHasher",
"(",
"POLYGLOT_RANDOM_ARRAY",
")",
")",
"->",
"int",
":",
"return",... | Calculates the Polyglot Zobrist hash of the position.
A Zobrist hash is an XOR of pseudo-random values picked from
an array. Which values are picked is decided by features of the
position, such as piece positions, castling rights and en passant
squares. | [
"Calculates",
"the",
"Polyglot",
"Zobrist",
"hash",
"of",
"the",
"position",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/polyglot.py#L291-L300 |
224,917 | niklasf/python-chess | chess/polyglot.py | MemoryMappedReader.find_all | def find_all(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Iterator[Entry]:
"""Seeks a specific position and yields corresponding entries."""
try:
key = int(board) # type: ignore
context = None # type: Optional[c... | python | def find_all(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Iterator[Entry]:
"""Seeks a specific position and yields corresponding entries."""
try:
key = int(board) # type: ignore
context = None # type: Optional[c... | [
"def",
"find_all",
"(",
"self",
",",
"board",
":",
"Union",
"[",
"chess",
".",
"Board",
",",
"int",
"]",
",",
"*",
",",
"minimum_weight",
":",
"int",
"=",
"1",
",",
"exclude_moves",
":",
"Container",
"[",
"chess",
".",
"Move",
"]",
"=",
"(",
")",
... | Seeks a specific position and yields corresponding entries. | [
"Seeks",
"a",
"specific",
"position",
"and",
"yields",
"corresponding",
"entries",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/polyglot.py#L387-L419 |
224,918 | niklasf/python-chess | chess/polyglot.py | MemoryMappedReader.find | def find(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Entry:
"""
Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ... | python | def find(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Entry:
"""
Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ... | [
"def",
"find",
"(",
"self",
",",
"board",
":",
"Union",
"[",
"chess",
".",
"Board",
",",
"int",
"]",
",",
"*",
",",
"minimum_weight",
":",
"int",
"=",
"1",
",",
"exclude_moves",
":",
"Container",
"[",
"chess",
".",
"Move",
"]",
"=",
"(",
")",
")"... | Finds the main entry for the given position or Zobrist hash.
The main entry is the (first) entry with the highest weight.
By default, entries with weight ``0`` are excluded. This is a common
way to delete entries from an opening book without compacting it. Pass
*minimum_weight* ``0`` t... | [
"Finds",
"the",
"main",
"entry",
"for",
"the",
"given",
"position",
"or",
"Zobrist",
"hash",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/polyglot.py#L421-L438 |
224,919 | niklasf/python-chess | chess/polyglot.py | MemoryMappedReader.choice | def choice(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = (), random=random) -> Entry:
"""
Uniformly selects a random entry for the given position.
:raises: :exc:`IndexError` if no entries are found.
"""
chosen_entry = No... | python | def choice(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = (), random=random) -> Entry:
"""
Uniformly selects a random entry for the given position.
:raises: :exc:`IndexError` if no entries are found.
"""
chosen_entry = No... | [
"def",
"choice",
"(",
"self",
",",
"board",
":",
"Union",
"[",
"chess",
".",
"Board",
",",
"int",
"]",
",",
"*",
",",
"minimum_weight",
":",
"int",
"=",
"1",
",",
"exclude_moves",
":",
"Container",
"[",
"chess",
".",
"Move",
"]",
"=",
"(",
")",
"... | Uniformly selects a random entry for the given position.
:raises: :exc:`IndexError` if no entries are found. | [
"Uniformly",
"selects",
"a",
"random",
"entry",
"for",
"the",
"given",
"position",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/polyglot.py#L446-L461 |
224,920 | niklasf/python-chess | chess/polyglot.py | MemoryMappedReader.weighted_choice | def weighted_choice(self, board: Union[chess.Board, int], *, exclude_moves: Container[chess.Move] = (), random=random) -> Entry:
"""
Selects a random entry for the given position, distributed by the
weights of the entries.
:raises: :exc:`IndexError` if no entries are found.
"""
... | python | def weighted_choice(self, board: Union[chess.Board, int], *, exclude_moves: Container[chess.Move] = (), random=random) -> Entry:
"""
Selects a random entry for the given position, distributed by the
weights of the entries.
:raises: :exc:`IndexError` if no entries are found.
"""
... | [
"def",
"weighted_choice",
"(",
"self",
",",
"board",
":",
"Union",
"[",
"chess",
".",
"Board",
",",
"int",
"]",
",",
"*",
",",
"exclude_moves",
":",
"Container",
"[",
"chess",
".",
"Move",
"]",
"=",
"(",
")",
",",
"random",
"=",
"random",
")",
"->"... | Selects a random entry for the given position, distributed by the
weights of the entries.
:raises: :exc:`IndexError` if no entries are found. | [
"Selects",
"a",
"random",
"entry",
"for",
"the",
"given",
"position",
"distributed",
"by",
"the",
"weights",
"of",
"the",
"entries",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/polyglot.py#L463-L482 |
224,921 | niklasf/python-chess | chess/polyglot.py | MemoryMappedReader.close | def close(self) -> None:
"""Closes the reader."""
if self.mmap is not None:
self.mmap.close()
try:
os.close(self.fd)
except OSError:
pass | python | def close(self) -> None:
"""Closes the reader."""
if self.mmap is not None:
self.mmap.close()
try:
os.close(self.fd)
except OSError:
pass | [
"def",
"close",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"mmap",
"is",
"not",
"None",
":",
"self",
".",
"mmap",
".",
"close",
"(",
")",
"try",
":",
"os",
".",
"close",
"(",
"self",
".",
"fd",
")",
"except",
"OSError",
":",
"pass"... | Closes the reader. | [
"Closes",
"the",
"reader",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/polyglot.py#L484-L492 |
224,922 | mapbox/mapbox-sdk-py | mapbox/encoding.py | _geom_points | def _geom_points(geom):
"""GeoJSON geometry to a sequence of point tuples
"""
if geom['type'] == 'Point':
yield tuple(geom['coordinates'])
elif geom['type'] in ('MultiPoint', 'LineString'):
for position in geom['coordinates']:
yield tuple(position)
else:
raise Inv... | python | def _geom_points(geom):
"""GeoJSON geometry to a sequence of point tuples
"""
if geom['type'] == 'Point':
yield tuple(geom['coordinates'])
elif geom['type'] in ('MultiPoint', 'LineString'):
for position in geom['coordinates']:
yield tuple(position)
else:
raise Inv... | [
"def",
"_geom_points",
"(",
"geom",
")",
":",
"if",
"geom",
"[",
"'type'",
"]",
"==",
"'Point'",
":",
"yield",
"tuple",
"(",
"geom",
"[",
"'coordinates'",
"]",
")",
"elif",
"geom",
"[",
"'type'",
"]",
"in",
"(",
"'MultiPoint'",
",",
"'LineString'",
")"... | GeoJSON geometry to a sequence of point tuples | [
"GeoJSON",
"geometry",
"to",
"a",
"sequence",
"of",
"point",
"tuples"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/encoding.py#L7-L17 |
224,923 | mapbox/mapbox-sdk-py | mapbox/encoding.py | read_points | def read_points(features):
""" Iterable of features to a sequence of point tuples
Where "features" can be either GeoJSON mappings
or objects implementing the geo_interface
"""
for feature in features:
if isinstance(feature, (tuple, list)) and len(feature) == 2:
yield feature
... | python | def read_points(features):
""" Iterable of features to a sequence of point tuples
Where "features" can be either GeoJSON mappings
or objects implementing the geo_interface
"""
for feature in features:
if isinstance(feature, (tuple, list)) and len(feature) == 2:
yield feature
... | [
"def",
"read_points",
"(",
"features",
")",
":",
"for",
"feature",
"in",
"features",
":",
"if",
"isinstance",
"(",
"feature",
",",
"(",
"tuple",
",",
"list",
")",
")",
"and",
"len",
"(",
"feature",
")",
"==",
"2",
":",
"yield",
"feature",
"elif",
"ha... | Iterable of features to a sequence of point tuples
Where "features" can be either GeoJSON mappings
or objects implementing the geo_interface | [
"Iterable",
"of",
"features",
"to",
"a",
"sequence",
"of",
"point",
"tuples",
"Where",
"features",
"can",
"be",
"either",
"GeoJSON",
"mappings",
"or",
"objects",
"implementing",
"the",
"geo_interface"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/encoding.py#L20-L56 |
224,924 | mapbox/mapbox-sdk-py | mapbox/encoding.py | encode_polyline | def encode_polyline(features):
"""Encode and iterable of features as a polyline
"""
points = list(read_points(features))
latlon_points = [(x[1], x[0]) for x in points]
return polyline.encode(latlon_points) | python | def encode_polyline(features):
"""Encode and iterable of features as a polyline
"""
points = list(read_points(features))
latlon_points = [(x[1], x[0]) for x in points]
return polyline.encode(latlon_points) | [
"def",
"encode_polyline",
"(",
"features",
")",
":",
"points",
"=",
"list",
"(",
"read_points",
"(",
"features",
")",
")",
"latlon_points",
"=",
"[",
"(",
"x",
"[",
"1",
"]",
",",
"x",
"[",
"0",
"]",
")",
"for",
"x",
"in",
"points",
"]",
"return",
... | Encode and iterable of features as a polyline | [
"Encode",
"and",
"iterable",
"of",
"features",
"as",
"a",
"polyline"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/encoding.py#L81-L86 |
224,925 | mapbox/mapbox-sdk-py | mapbox/services/directions.py | Directions.directions | def directions(self, features, profile='mapbox/driving',
alternatives=None, geometries=None, overview=None, steps=None,
continue_straight=None, waypoint_snapping=None, annotations=None,
language=None, **kwargs):
"""Request directions for waypoints encoded... | python | def directions(self, features, profile='mapbox/driving',
alternatives=None, geometries=None, overview=None, steps=None,
continue_straight=None, waypoint_snapping=None, annotations=None,
language=None, **kwargs):
"""Request directions for waypoints encoded... | [
"def",
"directions",
"(",
"self",
",",
"features",
",",
"profile",
"=",
"'mapbox/driving'",
",",
"alternatives",
"=",
"None",
",",
"geometries",
"=",
"None",
",",
"overview",
"=",
"None",
",",
"steps",
"=",
"None",
",",
"continue_straight",
"=",
"None",
",... | Request directions for waypoints encoded as GeoJSON features.
Parameters
----------
features : iterable
An collection of GeoJSON features
profile : str
Name of a Mapbox profile such as 'mapbox.driving'
alternatives : bool
Whether to try to ret... | [
"Request",
"directions",
"for",
"waypoints",
"encoded",
"as",
"GeoJSON",
"features",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/directions.py#L143-L249 |
224,926 | mapbox/mapbox-sdk-py | mapbox/services/matrix.py | DirectionsMatrix.matrix | def matrix(self, coordinates, profile='mapbox/driving',
sources=None, destinations=None, annotations=None):
"""Request a directions matrix for trips between coordinates
In the default case, the matrix returns a symmetric matrix,
using all input coordinates as sources and destina... | python | def matrix(self, coordinates, profile='mapbox/driving',
sources=None, destinations=None, annotations=None):
"""Request a directions matrix for trips between coordinates
In the default case, the matrix returns a symmetric matrix,
using all input coordinates as sources and destina... | [
"def",
"matrix",
"(",
"self",
",",
"coordinates",
",",
"profile",
"=",
"'mapbox/driving'",
",",
"sources",
"=",
"None",
",",
"destinations",
"=",
"None",
",",
"annotations",
"=",
"None",
")",
":",
"annotations",
"=",
"self",
".",
"_validate_annotations",
"("... | Request a directions matrix for trips between coordinates
In the default case, the matrix returns a symmetric matrix,
using all input coordinates as sources and destinations. You may
also generate an asymmetric matrix, with only some coordinates
as sources or destinations:
Para... | [
"Request",
"a",
"directions",
"matrix",
"for",
"trips",
"between",
"coordinates"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/matrix.py#L65-L138 |
224,927 | mapbox/mapbox-sdk-py | mapbox/services/datasets.py | Datasets._attribs | def _attribs(self, name=None, description=None):
"""Form an attributes dictionary from keyword args."""
a = {}
if name:
a['name'] = name
if description:
a['description'] = description
return a | python | def _attribs(self, name=None, description=None):
"""Form an attributes dictionary from keyword args."""
a = {}
if name:
a['name'] = name
if description:
a['description'] = description
return a | [
"def",
"_attribs",
"(",
"self",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"a",
"=",
"{",
"}",
"if",
"name",
":",
"a",
"[",
"'name'",
"]",
"=",
"name",
"if",
"description",
":",
"a",
"[",
"'description'",
"]",
"=",
"desc... | Form an attributes dictionary from keyword args. | [
"Form",
"an",
"attributes",
"dictionary",
"from",
"keyword",
"args",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/datasets.py#L25-L32 |
224,928 | mapbox/mapbox-sdk-py | mapbox/services/datasets.py | Datasets.create | def create(self, name=None, description=None):
"""Creates a new, empty dataset.
Parameters
----------
name : str, optional
The name of the dataset.
description : str, optional
The description of the dataset.
Returns
-------
reque... | python | def create(self, name=None, description=None):
"""Creates a new, empty dataset.
Parameters
----------
name : str, optional
The name of the dataset.
description : str, optional
The description of the dataset.
Returns
-------
reque... | [
"def",
"create",
"(",
"self",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{owner}'",
")",
".",
"expand",
"(",
"owner",
"=",
"self",
".",
"username",
")",
"return... | Creates a new, empty dataset.
Parameters
----------
name : str, optional
The name of the dataset.
description : str, optional
The description of the dataset.
Returns
-------
request.Response
The response contains the properti... | [
"Creates",
"a",
"new",
"empty",
"dataset",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/datasets.py#L34-L53 |
224,929 | mapbox/mapbox-sdk-py | mapbox/services/datasets.py | Datasets.list | def list(self):
"""Lists all datasets for a particular account.
Returns
-------
request.Response
The response contains a list of JSON objects describing datasets.
"""
uri = URITemplate(self.baseuri + '/{owner}').expand(
owner=self.usernam... | python | def list(self):
"""Lists all datasets for a particular account.
Returns
-------
request.Response
The response contains a list of JSON objects describing datasets.
"""
uri = URITemplate(self.baseuri + '/{owner}').expand(
owner=self.usernam... | [
"def",
"list",
"(",
"self",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{owner}'",
")",
".",
"expand",
"(",
"owner",
"=",
"self",
".",
"username",
")",
"return",
"self",
".",
"session",
".",
"get",
"(",
"uri",
")"
] | Lists all datasets for a particular account.
Returns
-------
request.Response
The response contains a list of JSON objects describing datasets. | [
"Lists",
"all",
"datasets",
"for",
"a",
"particular",
"account",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/datasets.py#L55-L66 |
224,930 | mapbox/mapbox-sdk-py | mapbox/services/datasets.py | Datasets.update_dataset | def update_dataset(self, dataset, name=None, description=None):
"""Updates a single dataset.
Parameters
----------
dataset : str
The dataset id.
name : str, optional
The name of the dataset.
description : str, optional
The descriptio... | python | def update_dataset(self, dataset, name=None, description=None):
"""Updates a single dataset.
Parameters
----------
dataset : str
The dataset id.
name : str, optional
The name of the dataset.
description : str, optional
The descriptio... | [
"def",
"update_dataset",
"(",
"self",
",",
"dataset",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{owner}/{id}'",
")",
".",
"expand",
"(",
"owner",
"=",
"self",
".... | Updates a single dataset.
Parameters
----------
dataset : str
The dataset id.
name : str, optional
The name of the dataset.
description : str, optional
The description of the dataset.
Returns
-------
request.Response... | [
"Updates",
"a",
"single",
"dataset",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/datasets.py#L86-L108 |
224,931 | mapbox/mapbox-sdk-py | mapbox/services/datasets.py | Datasets.delete_dataset | def delete_dataset(self, dataset):
"""Deletes a single dataset, including all of the features that it contains.
Parameters
----------
dataset : str
The dataset id.
Returns
-------
HTTP status code.
"""
uri = URITemplate(self.... | python | def delete_dataset(self, dataset):
"""Deletes a single dataset, including all of the features that it contains.
Parameters
----------
dataset : str
The dataset id.
Returns
-------
HTTP status code.
"""
uri = URITemplate(self.... | [
"def",
"delete_dataset",
"(",
"self",
",",
"dataset",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{owner}/{id}'",
")",
".",
"expand",
"(",
"owner",
"=",
"self",
".",
"username",
",",
"id",
"=",
"dataset",
")",
"return",
"s... | Deletes a single dataset, including all of the features that it contains.
Parameters
----------
dataset : str
The dataset id.
Returns
-------
HTTP status code. | [
"Deletes",
"a",
"single",
"dataset",
"including",
"all",
"of",
"the",
"features",
"that",
"it",
"contains",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/datasets.py#L110-L125 |
224,932 | mapbox/mapbox-sdk-py | mapbox/services/datasets.py | Datasets.list_features | def list_features(self, dataset, reverse=False, start=None, limit=None):
"""Lists features in a dataset.
Parameters
----------
dataset : str
The dataset id.
reverse : str, optional
List features in reverse order.
Possible value ... | python | def list_features(self, dataset, reverse=False, start=None, limit=None):
"""Lists features in a dataset.
Parameters
----------
dataset : str
The dataset id.
reverse : str, optional
List features in reverse order.
Possible value ... | [
"def",
"list_features",
"(",
"self",
",",
"dataset",
",",
"reverse",
"=",
"False",
",",
"start",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{owner}/{id}/features'",
")",
".",
"expand"... | Lists features in a dataset.
Parameters
----------
dataset : str
The dataset id.
reverse : str, optional
List features in reverse order.
Possible value is "true".
start : str, optional
The id of the feature after wh... | [
"Lists",
"features",
"in",
"a",
"dataset",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/datasets.py#L127-L162 |
224,933 | mapbox/mapbox-sdk-py | mapbox/services/datasets.py | Datasets.delete_feature | def delete_feature(self, dataset, fid):
"""Removes a feature from a dataset.
Parameters
----------
dataset : str
The dataset id.
fid : str
The feature id.
Returns
-------
HTTP status code.
"""
uri = URITe... | python | def delete_feature(self, dataset, fid):
"""Removes a feature from a dataset.
Parameters
----------
dataset : str
The dataset id.
fid : str
The feature id.
Returns
-------
HTTP status code.
"""
uri = URITe... | [
"def",
"delete_feature",
"(",
"self",
",",
"dataset",
",",
"fid",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{owner}/{did}/features/{fid}'",
")",
".",
"expand",
"(",
"owner",
"=",
"self",
".",
"username",
",",
"did",
"=",
"... | Removes a feature from a dataset.
Parameters
----------
dataset : str
The dataset id.
fid : str
The feature id.
Returns
-------
HTTP status code. | [
"Removes",
"a",
"feature",
"from",
"a",
"dataset",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/datasets.py#L217-L236 |
224,934 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader._get_credentials | def _get_credentials(self):
"""Gets temporary S3 credentials to stage user-uploaded files
"""
uri = URITemplate(self.baseuri + '/{username}/credentials').expand(
username=self.username)
resp = self.session.post(uri)
self.handle_http_error(
resp,
... | python | def _get_credentials(self):
"""Gets temporary S3 credentials to stage user-uploaded files
"""
uri = URITemplate(self.baseuri + '/{username}/credentials').expand(
username=self.username)
resp = self.session.post(uri)
self.handle_http_error(
resp,
... | [
"def",
"_get_credentials",
"(",
"self",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{username}/credentials'",
")",
".",
"expand",
"(",
"username",
"=",
"self",
".",
"username",
")",
"resp",
"=",
"self",
".",
"session",
".",
... | Gets temporary S3 credentials to stage user-uploaded files | [
"Gets",
"temporary",
"S3",
"credentials",
"to",
"stage",
"user",
"-",
"uploaded",
"files"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L37-L51 |
224,935 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader._validate_tileset | def _validate_tileset(self, tileset):
"""Validate the tileset name and
ensure that it includes the username
"""
if '.' not in tileset:
tileset = "{0}.{1}".format(self.username, tileset)
pattern = '^[a-z0-9-_]{1,32}\.[a-z0-9-_]{1,32}$'
if not re.match(pattern,... | python | def _validate_tileset(self, tileset):
"""Validate the tileset name and
ensure that it includes the username
"""
if '.' not in tileset:
tileset = "{0}.{1}".format(self.username, tileset)
pattern = '^[a-z0-9-_]{1,32}\.[a-z0-9-_]{1,32}$'
if not re.match(pattern,... | [
"def",
"_validate_tileset",
"(",
"self",
",",
"tileset",
")",
":",
"if",
"'.'",
"not",
"in",
"tileset",
":",
"tileset",
"=",
"\"{0}.{1}\"",
".",
"format",
"(",
"self",
".",
"username",
",",
"tileset",
")",
"pattern",
"=",
"'^[a-z0-9-_]{1,32}\\.[a-z0-9-_]{1,32}... | Validate the tileset name and
ensure that it includes the username | [
"Validate",
"the",
"tileset",
"name",
"and",
"ensure",
"that",
"it",
"includes",
"the",
"username"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L53-L66 |
224,936 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader._resolve_username | def _resolve_username(self, account, username):
"""Resolve username and handle deprecation of account kwarg"""
if account is not None:
warnings.warn(
"Use keyword argument 'username' instead of 'account'",
DeprecationWarning)
return username or account... | python | def _resolve_username(self, account, username):
"""Resolve username and handle deprecation of account kwarg"""
if account is not None:
warnings.warn(
"Use keyword argument 'username' instead of 'account'",
DeprecationWarning)
return username or account... | [
"def",
"_resolve_username",
"(",
"self",
",",
"account",
",",
"username",
")",
":",
"if",
"account",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"\"Use keyword argument 'username' instead of 'account'\"",
",",
"DeprecationWarning",
")",
"return",
"userna... | Resolve username and handle deprecation of account kwarg | [
"Resolve",
"username",
"and",
"handle",
"deprecation",
"of",
"account",
"kwarg"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L69-L75 |
224,937 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader.stage | def stage(self, fileobj, creds=None, callback=None):
"""Stages data in a Mapbox-owned S3 bucket
If creds are not provided, temporary credentials will be
generated using the Mapbox API.
Parameters
----------
fileobj: file object or filename
A Python file obje... | python | def stage(self, fileobj, creds=None, callback=None):
"""Stages data in a Mapbox-owned S3 bucket
If creds are not provided, temporary credentials will be
generated using the Mapbox API.
Parameters
----------
fileobj: file object or filename
A Python file obje... | [
"def",
"stage",
"(",
"self",
",",
"fileobj",
",",
"creds",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"if",
"not",
"hasattr",
"(",
"fileobj",
",",
"'read'",
")",
":",
"fileobj",
"=",
"open",
"(",
"fileobj",
",",
"'rb'",
")",
"if",
"not",
... | Stages data in a Mapbox-owned S3 bucket
If creds are not provided, temporary credentials will be
generated using the Mapbox API.
Parameters
----------
fileobj: file object or filename
A Python file object opened in binary mode or a filename.
creds: dict
... | [
"Stages",
"data",
"in",
"a",
"Mapbox",
"-",
"owned",
"S3",
"bucket"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L77-L117 |
224,938 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader.create | def create(self, stage_url, tileset, name=None, patch=False, bypass=False):
"""Create a tileset
Note: this step is refered to as "upload" in the API docs;
This class's upload() method is a high-level function
which acts like the Studio upload form.
Returns a response object whe... | python | def create(self, stage_url, tileset, name=None, patch=False, bypass=False):
"""Create a tileset
Note: this step is refered to as "upload" in the API docs;
This class's upload() method is a high-level function
which acts like the Studio upload form.
Returns a response object whe... | [
"def",
"create",
"(",
"self",
",",
"stage_url",
",",
"tileset",
",",
"name",
"=",
"None",
",",
"patch",
"=",
"False",
",",
"bypass",
"=",
"False",
")",
":",
"tileset",
"=",
"self",
".",
"_validate_tileset",
"(",
"tileset",
")",
"username",
",",
"_name"... | Create a tileset
Note: this step is refered to as "upload" in the API docs;
This class's upload() method is a high-level function
which acts like the Studio upload form.
Returns a response object where the json() contents are
an upload dict. Completion of the tileset may take s... | [
"Create",
"a",
"tileset"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L119-L175 |
224,939 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader.list | def list(self, account=None, username=None):
"""List of all uploads
Returns a Response object, the json() method of which returns
a list of uploads
Parameters
----------
username : str
Account username, defaults to the service's username.
account : s... | python | def list(self, account=None, username=None):
"""List of all uploads
Returns a Response object, the json() method of which returns
a list of uploads
Parameters
----------
username : str
Account username, defaults to the service's username.
account : s... | [
"def",
"list",
"(",
"self",
",",
"account",
"=",
"None",
",",
"username",
"=",
"None",
")",
":",
"username",
"=",
"self",
".",
"_resolve_username",
"(",
"account",
",",
"username",
")",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{u... | List of all uploads
Returns a Response object, the json() method of which returns
a list of uploads
Parameters
----------
username : str
Account username, defaults to the service's username.
account : str, **deprecated**
Alias for username. Will ... | [
"List",
"of",
"all",
"uploads"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L177-L199 |
224,940 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader.status | def status(self, upload, account=None, username=None):
"""Check status of upload
Parameters
----------
upload: str
The id of the upload or a dict with key 'id'.
username : str
Account username, defaults to the service's username.
account : str, **... | python | def status(self, upload, account=None, username=None):
"""Check status of upload
Parameters
----------
upload: str
The id of the upload or a dict with key 'id'.
username : str
Account username, defaults to the service's username.
account : str, **... | [
"def",
"status",
"(",
"self",
",",
"upload",
",",
"account",
"=",
"None",
",",
"username",
"=",
"None",
")",
":",
"username",
"=",
"self",
".",
"_resolve_username",
"(",
"account",
",",
"username",
")",
"if",
"isinstance",
"(",
"upload",
",",
"dict",
"... | Check status of upload
Parameters
----------
upload: str
The id of the upload or a dict with key 'id'.
username : str
Account username, defaults to the service's username.
account : str, **deprecated**
Alias for username. Will be removed in ve... | [
"Check",
"status",
"of",
"upload"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L228-L253 |
224,941 | mapbox/mapbox-sdk-py | mapbox/services/uploads.py | Uploader.upload | def upload(self, fileobj, tileset, name=None, patch=False, callback=None, bypass=False):
"""Upload data and create a Mapbox tileset
Effectively replicates the Studio upload feature. Returns a
Response object, the json() of which returns a dict with upload
metadata.
Parameters
... | python | def upload(self, fileobj, tileset, name=None, patch=False, callback=None, bypass=False):
"""Upload data and create a Mapbox tileset
Effectively replicates the Studio upload feature. Returns a
Response object, the json() of which returns a dict with upload
metadata.
Parameters
... | [
"def",
"upload",
"(",
"self",
",",
"fileobj",
",",
"tileset",
",",
"name",
"=",
"None",
",",
"patch",
"=",
"False",
",",
"callback",
"=",
"None",
",",
"bypass",
"=",
"False",
")",
":",
"tileset",
"=",
"self",
".",
"_validate_tileset",
"(",
"tileset",
... | Upload data and create a Mapbox tileset
Effectively replicates the Studio upload feature. Returns a
Response object, the json() of which returns a dict with upload
metadata.
Parameters
----------
fileobj: file object or str
A filename or a Python file object... | [
"Upload",
"data",
"and",
"create",
"a",
"Mapbox",
"tileset"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/uploads.py#L255-L287 |
224,942 | mapbox/mapbox-sdk-py | mapbox/services/geocoding.py | Geocoder._validate_country_codes | def _validate_country_codes(self, ccs):
"""Validate country code filters for use in requests."""
for cc in ccs:
if cc not in self.country_codes:
raise InvalidCountryCodeError(cc)
return {'country': ",".join(ccs)} | python | def _validate_country_codes(self, ccs):
"""Validate country code filters for use in requests."""
for cc in ccs:
if cc not in self.country_codes:
raise InvalidCountryCodeError(cc)
return {'country': ",".join(ccs)} | [
"def",
"_validate_country_codes",
"(",
"self",
",",
"ccs",
")",
":",
"for",
"cc",
"in",
"ccs",
":",
"if",
"cc",
"not",
"in",
"self",
".",
"country_codes",
":",
"raise",
"InvalidCountryCodeError",
"(",
"cc",
")",
"return",
"{",
"'country'",
":",
"\",\"",
... | Validate country code filters for use in requests. | [
"Validate",
"country",
"code",
"filters",
"for",
"use",
"in",
"requests",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/geocoding.py#L28-L33 |
224,943 | mapbox/mapbox-sdk-py | mapbox/services/geocoding.py | Geocoder._validate_place_types | def _validate_place_types(self, types):
"""Validate place types and return a mapping for use in requests."""
for pt in types:
if pt not in self.place_types:
raise InvalidPlaceTypeError(pt)
return {'types': ",".join(types)} | python | def _validate_place_types(self, types):
"""Validate place types and return a mapping for use in requests."""
for pt in types:
if pt not in self.place_types:
raise InvalidPlaceTypeError(pt)
return {'types': ",".join(types)} | [
"def",
"_validate_place_types",
"(",
"self",
",",
"types",
")",
":",
"for",
"pt",
"in",
"types",
":",
"if",
"pt",
"not",
"in",
"self",
".",
"place_types",
":",
"raise",
"InvalidPlaceTypeError",
"(",
"pt",
")",
"return",
"{",
"'types'",
":",
"\",\"",
".",... | Validate place types and return a mapping for use in requests. | [
"Validate",
"place",
"types",
"and",
"return",
"a",
"mapping",
"for",
"use",
"in",
"requests",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/geocoding.py#L35-L40 |
224,944 | mapbox/mapbox-sdk-py | mapbox/services/geocoding.py | Geocoder.forward | def forward(self, address, types=None, lon=None, lat=None,
country=None, bbox=None, limit=None, languages=None):
"""Returns a Requests response object that contains a GeoJSON
collection of places matching the given address.
`response.geojson()` returns the geocoding result as Ge... | python | def forward(self, address, types=None, lon=None, lat=None,
country=None, bbox=None, limit=None, languages=None):
"""Returns a Requests response object that contains a GeoJSON
collection of places matching the given address.
`response.geojson()` returns the geocoding result as Ge... | [
"def",
"forward",
"(",
"self",
",",
"address",
",",
"types",
"=",
"None",
",",
"lon",
"=",
"None",
",",
"lat",
"=",
"None",
",",
"country",
"=",
"None",
",",
"bbox",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"languages",
"=",
"None",
")",
":",... | Returns a Requests response object that contains a GeoJSON
collection of places matching the given address.
`response.geojson()` returns the geocoding result as GeoJSON.
`response.status_code` returns the HTTP API status code.
Place results may be constrained to those of one or more ty... | [
"Returns",
"a",
"Requests",
"response",
"object",
"that",
"contains",
"a",
"GeoJSON",
"collection",
"of",
"places",
"matching",
"the",
"given",
"address",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/geocoding.py#L42-L79 |
224,945 | mapbox/mapbox-sdk-py | mapbox/services/geocoding.py | Geocoder.reverse | def reverse(self, lon, lat, types=None, limit=None):
"""Returns a Requests response object that contains a GeoJSON
collection of places near the given longitude and latitude.
`response.geojson()` returns the geocoding result as GeoJSON.
`response.status_code` returns the HTTP API status... | python | def reverse(self, lon, lat, types=None, limit=None):
"""Returns a Requests response object that contains a GeoJSON
collection of places near the given longitude and latitude.
`response.geojson()` returns the geocoding result as GeoJSON.
`response.status_code` returns the HTTP API status... | [
"def",
"reverse",
"(",
"self",
",",
"lon",
",",
"lat",
",",
"types",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"uri",
"=",
"URITemplate",
"(",
"self",
".",
"baseuri",
"+",
"'/{dataset}/{lon},{lat}.json'",
")",
".",
"expand",
"(",
"dataset",
"="... | Returns a Requests response object that contains a GeoJSON
collection of places near the given longitude and latitude.
`response.geojson()` returns the geocoding result as GeoJSON.
`response.status_code` returns the HTTP API status code.
See: https://www.mapbox.com/api-documentation/se... | [
"Returns",
"a",
"Requests",
"response",
"object",
"that",
"contains",
"a",
"GeoJSON",
"collection",
"of",
"places",
"near",
"the",
"given",
"longitude",
"and",
"latitude",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/geocoding.py#L81-L113 |
224,946 | mapbox/mapbox-sdk-py | mapbox/services/base.py | Session | def Session(access_token=None, env=None):
"""Create an HTTP session.
Parameters
----------
access_token : str
Mapbox access token string (optional).
env : dict, optional
A dict that subsitutes for os.environ.
Returns
-------
requests.Session
"""
if env is None:
... | python | def Session(access_token=None, env=None):
"""Create an HTTP session.
Parameters
----------
access_token : str
Mapbox access token string (optional).
env : dict, optional
A dict that subsitutes for os.environ.
Returns
-------
requests.Session
"""
if env is None:
... | [
"def",
"Session",
"(",
"access_token",
"=",
"None",
",",
"env",
"=",
"None",
")",
":",
"if",
"env",
"is",
"None",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"access_token",
"=",
"(",
"access_token",
"or",
"env",
".",
"get",
"(",
... | Create an HTTP session.
Parameters
----------
access_token : str
Mapbox access token string (optional).
env : dict, optional
A dict that subsitutes for os.environ.
Returns
-------
requests.Session | [
"Create",
"an",
"HTTP",
"session",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/base.py#L14-L39 |
224,947 | mapbox/mapbox-sdk-py | mapbox/services/base.py | Service.username | def username(self):
"""The username in the service's access token
Returns
-------
str
"""
token = self.session.params.get('access_token')
if not token:
raise errors.TokenError(
"session does not have a valid access_token param")
... | python | def username(self):
"""The username in the service's access token
Returns
-------
str
"""
token = self.session.params.get('access_token')
if not token:
raise errors.TokenError(
"session does not have a valid access_token param")
... | [
"def",
"username",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"session",
".",
"params",
".",
"get",
"(",
"'access_token'",
")",
"if",
"not",
"token",
":",
"raise",
"errors",
".",
"TokenError",
"(",
"\"session does not have a valid access_token param\"",
... | The username in the service's access token
Returns
-------
str | [
"The",
"username",
"in",
"the",
"service",
"s",
"access",
"token"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/base.py#L101-L120 |
224,948 | mapbox/mapbox-sdk-py | mapbox/services/base.py | Service.handle_http_error | def handle_http_error(self, response, custom_messages=None,
raise_for_status=False):
"""Converts service errors to Python exceptions
Parameters
----------
response : requests.Response
A service response.
custom_messages : dict, optional
... | python | def handle_http_error(self, response, custom_messages=None,
raise_for_status=False):
"""Converts service errors to Python exceptions
Parameters
----------
response : requests.Response
A service response.
custom_messages : dict, optional
... | [
"def",
"handle_http_error",
"(",
"self",
",",
"response",
",",
"custom_messages",
"=",
"None",
",",
"raise_for_status",
"=",
"False",
")",
":",
"if",
"not",
"custom_messages",
":",
"custom_messages",
"=",
"{",
"}",
"if",
"response",
".",
"status_code",
"in",
... | Converts service errors to Python exceptions
Parameters
----------
response : requests.Response
A service response.
custom_messages : dict, optional
A mapping of custom exception messages to HTTP status codes.
raise_for_status : bool, optional
... | [
"Converts",
"service",
"errors",
"to",
"Python",
"exceptions"
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/base.py#L122-L144 |
224,949 | mapbox/mapbox-sdk-py | mapbox/services/mapmatching.py | MapMatcher.match | def match(self, feature, gps_precision=None, profile='mapbox.driving'):
"""Match features to OpenStreetMap data."""
profile = self._validate_profile(profile)
feature = self._validate_feature(feature)
geojson_line_feature = json.dumps(feature)
uri = URITemplate(self.baseuri + '/... | python | def match(self, feature, gps_precision=None, profile='mapbox.driving'):
"""Match features to OpenStreetMap data."""
profile = self._validate_profile(profile)
feature = self._validate_feature(feature)
geojson_line_feature = json.dumps(feature)
uri = URITemplate(self.baseuri + '/... | [
"def",
"match",
"(",
"self",
",",
"feature",
",",
"gps_precision",
"=",
"None",
",",
"profile",
"=",
"'mapbox.driving'",
")",
":",
"profile",
"=",
"self",
".",
"_validate_profile",
"(",
"profile",
")",
"feature",
"=",
"self",
".",
"_validate_feature",
"(",
... | Match features to OpenStreetMap data. | [
"Match",
"features",
"to",
"OpenStreetMap",
"data",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/mapmatching.py#L33-L55 |
224,950 | mapbox/mapbox-sdk-py | mapbox/services/tilequery.py | Tilequery._validate_geometry | def _validate_geometry(self, geometry):
"""Validates geometry, raising error if invalid."""
if geometry is not None and geometry not in self.valid_geometries:
raise InvalidParameterError("{} is not a valid geometry".format(geometry))
return geometry | python | def _validate_geometry(self, geometry):
"""Validates geometry, raising error if invalid."""
if geometry is not None and geometry not in self.valid_geometries:
raise InvalidParameterError("{} is not a valid geometry".format(geometry))
return geometry | [
"def",
"_validate_geometry",
"(",
"self",
",",
"geometry",
")",
":",
"if",
"geometry",
"is",
"not",
"None",
"and",
"geometry",
"not",
"in",
"self",
".",
"valid_geometries",
":",
"raise",
"InvalidParameterError",
"(",
"\"{} is not a valid geometry\"",
".",
"format"... | Validates geometry, raising error if invalid. | [
"Validates",
"geometry",
"raising",
"error",
"if",
"invalid",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/tilequery.py#L72-L78 |
224,951 | mapbox/mapbox-sdk-py | mapbox/services/tilequery.py | Tilequery.tilequery | def tilequery(
self,
map_id,
lon=None,
lat=None,
radius=None,
limit=None,
dedupe=None,
geometry=None,
layers=None,
):
"""Returns data about specific features
from a vector tileset.
Parameters
----------
... | python | def tilequery(
self,
map_id,
lon=None,
lat=None,
radius=None,
limit=None,
dedupe=None,
geometry=None,
layers=None,
):
"""Returns data about specific features
from a vector tileset.
Parameters
----------
... | [
"def",
"tilequery",
"(",
"self",
",",
"map_id",
",",
"lon",
"=",
"None",
",",
"lat",
"=",
"None",
",",
"radius",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"dedupe",
"=",
"None",
",",
"geometry",
"=",
"None",
",",
"layers",
"=",
"None",
",",
")... | Returns data about specific features
from a vector tileset.
Parameters
----------
map_id : str or list
The tileset's unique identifier in the
format username.id.
map_id may be either a str with one value
or a list with multiple values.
... | [
"Returns",
"data",
"about",
"specific",
"features",
"from",
"a",
"vector",
"tileset",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/tilequery.py#L80-L209 |
224,952 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps._validate_file_format | def _validate_file_format(self, file_format):
"""Validates file format, raising error if invalid."""
if file_format not in self.valid_file_formats:
raise InvalidFileFormatError(
"{} is not a valid file format".format(file_format)
)
return file_format | python | def _validate_file_format(self, file_format):
"""Validates file format, raising error if invalid."""
if file_format not in self.valid_file_formats:
raise InvalidFileFormatError(
"{} is not a valid file format".format(file_format)
)
return file_format | [
"def",
"_validate_file_format",
"(",
"self",
",",
"file_format",
")",
":",
"if",
"file_format",
"not",
"in",
"self",
".",
"valid_file_formats",
":",
"raise",
"InvalidFileFormatError",
"(",
"\"{} is not a valid file format\"",
".",
"format",
"(",
"file_format",
")",
... | Validates file format, raising error if invalid. | [
"Validates",
"file",
"format",
"raising",
"error",
"if",
"invalid",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L122-L130 |
224,953 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps._validate_feature_format | def _validate_feature_format(self, feature_format):
"""Validates feature format, raising error if invalid."""
if feature_format not in self.valid_feature_formats:
raise InvalidFeatureFormatError(
"{} is not a valid feature format".format(feature_format)
)
... | python | def _validate_feature_format(self, feature_format):
"""Validates feature format, raising error if invalid."""
if feature_format not in self.valid_feature_formats:
raise InvalidFeatureFormatError(
"{} is not a valid feature format".format(feature_format)
)
... | [
"def",
"_validate_feature_format",
"(",
"self",
",",
"feature_format",
")",
":",
"if",
"feature_format",
"not",
"in",
"self",
".",
"valid_feature_formats",
":",
"raise",
"InvalidFeatureFormatError",
"(",
"\"{} is not a valid feature format\"",
".",
"format",
"(",
"featu... | Validates feature format, raising error if invalid. | [
"Validates",
"feature",
"format",
"raising",
"error",
"if",
"invalid",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L144-L152 |
224,954 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps._validate_marker_name | def _validate_marker_name(self, marker_name):
"""Validates marker name, raising error if invalid."""
if marker_name not in self.valid_marker_names:
raise InvalidMarkerNameError(
"{} is not a valid marker name".format(marker_name)
)
return marker_name | python | def _validate_marker_name(self, marker_name):
"""Validates marker name, raising error if invalid."""
if marker_name not in self.valid_marker_names:
raise InvalidMarkerNameError(
"{} is not a valid marker name".format(marker_name)
)
return marker_name | [
"def",
"_validate_marker_name",
"(",
"self",
",",
"marker_name",
")",
":",
"if",
"marker_name",
"not",
"in",
"self",
".",
"valid_marker_names",
":",
"raise",
"InvalidMarkerNameError",
"(",
"\"{} is not a valid marker name\"",
".",
"format",
"(",
"marker_name",
")",
... | Validates marker name, raising error if invalid. | [
"Validates",
"marker",
"name",
"raising",
"error",
"if",
"invalid",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L154-L162 |
224,955 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps._validate_label | def _validate_label(self, label):
"""Validates label, raising error if invalid."""
letter_pattern = compile("^[a-z]{1}$")
number_pattern = compile("^[0]{1}$|^[1-9]{1,2}$")
icon_pattern = compile("^[a-zA-Z ]{1,}$")
if not match(letter_pattern, label)\
and not match(n... | python | def _validate_label(self, label):
"""Validates label, raising error if invalid."""
letter_pattern = compile("^[a-z]{1}$")
number_pattern = compile("^[0]{1}$|^[1-9]{1,2}$")
icon_pattern = compile("^[a-zA-Z ]{1,}$")
if not match(letter_pattern, label)\
and not match(n... | [
"def",
"_validate_label",
"(",
"self",
",",
"label",
")",
":",
"letter_pattern",
"=",
"compile",
"(",
"\"^[a-z]{1}$\"",
")",
"number_pattern",
"=",
"compile",
"(",
"\"^[0]{1}$|^[1-9]{1,2}$\"",
")",
"icon_pattern",
"=",
"compile",
"(",
"\"^[a-zA-Z ]{1,}$\"",
")",
"... | Validates label, raising error if invalid. | [
"Validates",
"label",
"raising",
"error",
"if",
"invalid",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L164-L178 |
224,956 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps._validate_color | def _validate_color(self, color):
"""Validates color, raising error if invalid."""
three_digit_pattern = compile("^[a-f0-9]{3}$")
six_digit_pattern = compile("^[a-f0-9]{6}$")
if not match(three_digit_pattern, color)\
and not match(six_digit_pattern, color):
... | python | def _validate_color(self, color):
"""Validates color, raising error if invalid."""
three_digit_pattern = compile("^[a-f0-9]{3}$")
six_digit_pattern = compile("^[a-f0-9]{6}$")
if not match(three_digit_pattern, color)\
and not match(six_digit_pattern, color):
... | [
"def",
"_validate_color",
"(",
"self",
",",
"color",
")",
":",
"three_digit_pattern",
"=",
"compile",
"(",
"\"^[a-f0-9]{3}$\"",
")",
"six_digit_pattern",
"=",
"compile",
"(",
"\"^[a-f0-9]{6}$\"",
")",
"if",
"not",
"match",
"(",
"three_digit_pattern",
",",
"color",... | Validates color, raising error if invalid. | [
"Validates",
"color",
"raising",
"error",
"if",
"invalid",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L180-L192 |
224,957 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps.tile | def tile(self, map_id, x, y, z, retina=False,
file_format="png", style_id=None, timestamp=None):
"""Returns an image tile, vector tile, or UTFGrid
in the specified file format.
Parameters
----------
map_id : str
The tile's unique identifier in the form... | python | def tile(self, map_id, x, y, z, retina=False,
file_format="png", style_id=None, timestamp=None):
"""Returns an image tile, vector tile, or UTFGrid
in the specified file format.
Parameters
----------
map_id : str
The tile's unique identifier in the form... | [
"def",
"tile",
"(",
"self",
",",
"map_id",
",",
"x",
",",
"y",
",",
"z",
",",
"retina",
"=",
"False",
",",
"file_format",
"=",
"\"png\"",
",",
"style_id",
"=",
"None",
",",
"timestamp",
"=",
"None",
")",
":",
"# Check x, y, and z.",
"if",
"x",
"is",
... | Returns an image tile, vector tile, or UTFGrid
in the specified file format.
Parameters
----------
map_id : str
The tile's unique identifier in the format username.id.
x : int
The tile's column, where 0 is the minimum value
and ((2**z) - 1) i... | [
"Returns",
"an",
"image",
"tile",
"vector",
"tile",
"or",
"UTFGrid",
"in",
"the",
"specified",
"file",
"format",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L194-L295 |
224,958 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps.features | def features(self, map_id, feature_format="json"):
"""Returns vector features from Mapbox Editor projects
as GeoJSON or KML.
Parameters
----------
map_id : str
The map's unique identifier in the format username.id.
feature_format : str, optional
... | python | def features(self, map_id, feature_format="json"):
"""Returns vector features from Mapbox Editor projects
as GeoJSON or KML.
Parameters
----------
map_id : str
The map's unique identifier in the format username.id.
feature_format : str, optional
... | [
"def",
"features",
"(",
"self",
",",
"map_id",
",",
"feature_format",
"=",
"\"json\"",
")",
":",
"# Validate feature_format.",
"feature_format",
"=",
"self",
".",
"_validate_feature_format",
"(",
"feature_format",
")",
"# Create dict to assist in building URI resource path.... | Returns vector features from Mapbox Editor projects
as GeoJSON or KML.
Parameters
----------
map_id : str
The map's unique identifier in the format username.id.
feature_format : str, optional
The vector's feature format.
The default value is... | [
"Returns",
"vector",
"features",
"from",
"Mapbox",
"Editor",
"projects",
"as",
"GeoJSON",
"or",
"KML",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L297-L338 |
224,959 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps.metadata | def metadata(self, map_id, secure=False):
"""Returns TileJSON metadata for a tileset.
Parameters
----------
map_id : str
The map's unique identifier in the format username.id.
secure : bool, optional
The representation of the requested resources,
... | python | def metadata(self, map_id, secure=False):
"""Returns TileJSON metadata for a tileset.
Parameters
----------
map_id : str
The map's unique identifier in the format username.id.
secure : bool, optional
The representation of the requested resources,
... | [
"def",
"metadata",
"(",
"self",
",",
"map_id",
",",
"secure",
"=",
"False",
")",
":",
"# Create dict to assist in building URI resource path.",
"path_values",
"=",
"dict",
"(",
"map_id",
"=",
"map_id",
")",
"# Build URI resource path.",
"path_part",
"=",
"\"/{map_id}.... | Returns TileJSON metadata for a tileset.
Parameters
----------
map_id : str
The map's unique identifier in the format username.id.
secure : bool, optional
The representation of the requested resources,
where True indicates representation as HTTPS en... | [
"Returns",
"TileJSON",
"metadata",
"for",
"a",
"tileset",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L340-L384 |
224,960 | mapbox/mapbox-sdk-py | mapbox/services/maps.py | Maps.marker | def marker(self, marker_name=None, label=None,
color=None, retina=False):
"""Returns a single marker image without any
background map.
Parameters
----------
marker_name : str
The marker's shape and size.
label : str, optional
T... | python | def marker(self, marker_name=None, label=None,
color=None, retina=False):
"""Returns a single marker image without any
background map.
Parameters
----------
marker_name : str
The marker's shape and size.
label : str, optional
T... | [
"def",
"marker",
"(",
"self",
",",
"marker_name",
"=",
"None",
",",
"label",
"=",
"None",
",",
"color",
"=",
"None",
",",
"retina",
"=",
"False",
")",
":",
"# Check for marker_name.",
"if",
"marker_name",
"is",
"None",
":",
"raise",
"ValidationError",
"(",... | Returns a single marker image without any
background map.
Parameters
----------
marker_name : str
The marker's shape and size.
label : str, optional
The marker's alphanumeric label.
Options are a through z, 0 through 99, or the
... | [
"Returns",
"a",
"single",
"marker",
"image",
"without",
"any",
"background",
"map",
"."
] | 72d19dbcf2d254a6ea08129a726471fd21f13023 | https://github.com/mapbox/mapbox-sdk-py/blob/72d19dbcf2d254a6ea08129a726471fd21f13023/mapbox/services/maps.py#L386-L468 |
224,961 | django-extensions/django-extensions | django_extensions/management/commands/runserver_plus.py | set_werkzeug_log_color | def set_werkzeug_log_color():
"""Try to set color to the werkzeug log."""
from django.core.management.color import color_style
from werkzeug.serving import WSGIRequestHandler
from werkzeug._internal import _log
_style = color_style()
_orig_log = WSGIRequestHandler.log
def werk_log(self, ty... | python | def set_werkzeug_log_color():
"""Try to set color to the werkzeug log."""
from django.core.management.color import color_style
from werkzeug.serving import WSGIRequestHandler
from werkzeug._internal import _log
_style = color_style()
_orig_log = WSGIRequestHandler.log
def werk_log(self, ty... | [
"def",
"set_werkzeug_log_color",
"(",
")",
":",
"from",
"django",
".",
"core",
".",
"management",
".",
"color",
"import",
"color_style",
"from",
"werkzeug",
".",
"serving",
"import",
"WSGIRequestHandler",
"from",
"werkzeug",
".",
"_internal",
"import",
"_log",
"... | Try to set color to the werkzeug log. | [
"Try",
"to",
"set",
"color",
"to",
"the",
"werkzeug",
"log",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/runserver_plus.py#L423-L463 |
224,962 | django-extensions/django-extensions | django_extensions/db/fields/__init__.py | AutoSlugField._slug_strip | def _slug_strip(self, value):
"""
Clean up a slug by removing slug separator characters that occur at
the beginning or end of a slug.
If an alternate separator is used, it will also replace any instances
of the default '-' separator with the new separator.
"""
re... | python | def _slug_strip(self, value):
"""
Clean up a slug by removing slug separator characters that occur at
the beginning or end of a slug.
If an alternate separator is used, it will also replace any instances
of the default '-' separator with the new separator.
"""
re... | [
"def",
"_slug_strip",
"(",
"self",
",",
"value",
")",
":",
"re_sep",
"=",
"'(?:-|%s)'",
"%",
"re",
".",
"escape",
"(",
"self",
".",
"separator",
")",
"value",
"=",
"re",
".",
"sub",
"(",
"'%s+'",
"%",
"re_sep",
",",
"self",
".",
"separator",
",",
"... | Clean up a slug by removing slug separator characters that occur at
the beginning or end of a slug.
If an alternate separator is used, it will also replace any instances
of the default '-' separator with the new separator. | [
"Clean",
"up",
"a",
"slug",
"by",
"removing",
"slug",
"separator",
"characters",
"that",
"occur",
"at",
"the",
"beginning",
"or",
"end",
"of",
"a",
"slug",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/db/fields/__init__.py#L134-L144 |
224,963 | django-extensions/django-extensions | django_extensions/management/commands/export_emails.py | full_name | def full_name(first_name, last_name, username, **extra):
"""Return full name or username."""
name = " ".join(n for n in [first_name, last_name] if n)
if not name:
return username
return name | python | def full_name(first_name, last_name, username, **extra):
"""Return full name or username."""
name = " ".join(n for n in [first_name, last_name] if n)
if not name:
return username
return name | [
"def",
"full_name",
"(",
"first_name",
",",
"last_name",
",",
"username",
",",
"*",
"*",
"extra",
")",
":",
"name",
"=",
"\" \"",
".",
"join",
"(",
"n",
"for",
"n",
"in",
"[",
"first_name",
",",
"last_name",
"]",
"if",
"n",
")",
"if",
"not",
"name"... | Return full name or username. | [
"Return",
"full",
"name",
"or",
"username",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L23-L28 |
224,964 | django-extensions/django-extensions | django_extensions/management/commands/export_emails.py | Command.google | def google(self, qs):
"""CSV format suitable for importing into google GMail"""
csvf = writer(sys.stdout)
csvf.writerow(['Name', 'Email'])
for ent in qs:
csvf.writerow([full_name(**ent), ent['email']]) | python | def google(self, qs):
"""CSV format suitable for importing into google GMail"""
csvf = writer(sys.stdout)
csvf.writerow(['Name', 'Email'])
for ent in qs:
csvf.writerow([full_name(**ent), ent['email']]) | [
"def",
"google",
"(",
"self",
",",
"qs",
")",
":",
"csvf",
"=",
"writer",
"(",
"sys",
".",
"stdout",
")",
"csvf",
".",
"writerow",
"(",
"[",
"'Name'",
",",
"'Email'",
"]",
")",
"for",
"ent",
"in",
"qs",
":",
"csvf",
".",
"writerow",
"(",
"[",
"... | CSV format suitable for importing into google GMail | [
"CSV",
"format",
"suitable",
"for",
"importing",
"into",
"google",
"GMail"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L88-L93 |
224,965 | django-extensions/django-extensions | django_extensions/management/commands/export_emails.py | Command.linkedin | def linkedin(self, qs):
"""
CSV format suitable for importing into linkedin Groups.
perfect for pre-approving members of a linkedin group.
"""
csvf = writer(sys.stdout)
csvf.writerow(['First Name', 'Last Name', 'Email'])
for ent in qs:
csvf.writerow([e... | python | def linkedin(self, qs):
"""
CSV format suitable for importing into linkedin Groups.
perfect for pre-approving members of a linkedin group.
"""
csvf = writer(sys.stdout)
csvf.writerow(['First Name', 'Last Name', 'Email'])
for ent in qs:
csvf.writerow([e... | [
"def",
"linkedin",
"(",
"self",
",",
"qs",
")",
":",
"csvf",
"=",
"writer",
"(",
"sys",
".",
"stdout",
")",
"csvf",
".",
"writerow",
"(",
"[",
"'First Name'",
",",
"'Last Name'",
",",
"'Email'",
"]",
")",
"for",
"ent",
"in",
"qs",
":",
"csvf",
".",... | CSV format suitable for importing into linkedin Groups.
perfect for pre-approving members of a linkedin group. | [
"CSV",
"format",
"suitable",
"for",
"importing",
"into",
"linkedin",
"Groups",
".",
"perfect",
"for",
"pre",
"-",
"approving",
"members",
"of",
"a",
"linkedin",
"group",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L95-L103 |
224,966 | django-extensions/django-extensions | django_extensions/management/commands/export_emails.py | Command.outlook | def outlook(self, qs):
"""CSV format suitable for importing into outlook"""
csvf = writer(sys.stdout)
columns = ['Name', 'E-mail Address', 'Notes', 'E-mail 2 Address', 'E-mail 3 Address',
'Mobile Phone', 'Pager', 'Company', 'Job Title', 'Home Phone', 'Home Phone 2',
... | python | def outlook(self, qs):
"""CSV format suitable for importing into outlook"""
csvf = writer(sys.stdout)
columns = ['Name', 'E-mail Address', 'Notes', 'E-mail 2 Address', 'E-mail 3 Address',
'Mobile Phone', 'Pager', 'Company', 'Job Title', 'Home Phone', 'Home Phone 2',
... | [
"def",
"outlook",
"(",
"self",
",",
"qs",
")",
":",
"csvf",
"=",
"writer",
"(",
"sys",
".",
"stdout",
")",
"columns",
"=",
"[",
"'Name'",
",",
"'E-mail Address'",
",",
"'Notes'",
",",
"'E-mail 2 Address'",
",",
"'E-mail 3 Address'",
",",
"'Mobile Phone'",
... | CSV format suitable for importing into outlook | [
"CSV",
"format",
"suitable",
"for",
"importing",
"into",
"outlook"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L105-L115 |
224,967 | django-extensions/django-extensions | django_extensions/management/commands/export_emails.py | Command.vcard | def vcard(self, qs):
"""VCARD format."""
try:
import vobject
except ImportError:
print(self.style.ERROR("Please install vobject to use the vcard export format."))
sys.exit(1)
out = sys.stdout
for ent in qs:
card = vobject.vCard()
... | python | def vcard(self, qs):
"""VCARD format."""
try:
import vobject
except ImportError:
print(self.style.ERROR("Please install vobject to use the vcard export format."))
sys.exit(1)
out = sys.stdout
for ent in qs:
card = vobject.vCard()
... | [
"def",
"vcard",
"(",
"self",
",",
"qs",
")",
":",
"try",
":",
"import",
"vobject",
"except",
"ImportError",
":",
"print",
"(",
"self",
".",
"style",
".",
"ERROR",
"(",
"\"Please install vobject to use the vcard export format.\"",
")",
")",
"sys",
".",
"exit",
... | VCARD format. | [
"VCARD",
"format",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/export_emails.py#L117-L138 |
224,968 | django-extensions/django-extensions | django_extensions/management/mysql.py | parse_mysql_cnf | def parse_mysql_cnf(dbinfo):
"""
Attempt to parse mysql database config file for connection settings.
Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs
so we have to emulate the behaviour
Settings that are missing will return ''
returns (u... | python | def parse_mysql_cnf(dbinfo):
"""
Attempt to parse mysql database config file for connection settings.
Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs
so we have to emulate the behaviour
Settings that are missing will return ''
returns (u... | [
"def",
"parse_mysql_cnf",
"(",
"dbinfo",
")",
":",
"read_default_file",
"=",
"dbinfo",
".",
"get",
"(",
"'OPTIONS'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'read_default_file'",
")",
"if",
"read_default_file",
":",
"config",
"=",
"configparser",
".",
"RawConf... | Attempt to parse mysql database config file for connection settings.
Ideally we would hook into django's code to do this, but read_default_file is handled by the mysql C libs
so we have to emulate the behaviour
Settings that are missing will return ''
returns (user, password, database_name, database_ho... | [
"Attempt",
"to",
"parse",
"mysql",
"database",
"config",
"file",
"for",
"connection",
"settings",
".",
"Ideally",
"we",
"would",
"hook",
"into",
"django",
"s",
"code",
"to",
"do",
"this",
"but",
"read_default_file",
"is",
"handled",
"by",
"the",
"mysql",
"C"... | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/mysql.py#L5-L43 |
224,969 | django-extensions/django-extensions | django_extensions/management/jobs.py | get_jobs | def get_jobs(when=None, only_scheduled=False):
"""
Return a dictionary mapping of job names together with their respective
application class.
"""
# FIXME: HACK: make sure the project dir is on the path when executed as ./manage.py
try:
cpath = os.path.dirname(os.path.realpath(sys.argv[0]... | python | def get_jobs(when=None, only_scheduled=False):
"""
Return a dictionary mapping of job names together with their respective
application class.
"""
# FIXME: HACK: make sure the project dir is on the path when executed as ./manage.py
try:
cpath = os.path.dirname(os.path.realpath(sys.argv[0]... | [
"def",
"get_jobs",
"(",
"when",
"=",
"None",
",",
"only_scheduled",
"=",
"False",
")",
":",
"# FIXME: HACK: make sure the project dir is on the path when executed as ./manage.py",
"try",
":",
"cpath",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
... | Return a dictionary mapping of job names together with their respective
application class. | [
"Return",
"a",
"dictionary",
"mapping",
"of",
"job",
"names",
"together",
"with",
"their",
"respective",
"application",
"class",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/jobs.py#L102-L139 |
224,970 | django-extensions/django-extensions | django_extensions/management/commands/runjobs.py | Command.runjobs_by_signals | def runjobs_by_signals(self, when, options):
""" Run jobs from the signals """
# Thanks for Ian Holsman for the idea and code
from django_extensions.management import signals
from django.conf import settings
verbosity = options["verbosity"]
for app_name in settings.INSTA... | python | def runjobs_by_signals(self, when, options):
""" Run jobs from the signals """
# Thanks for Ian Holsman for the idea and code
from django_extensions.management import signals
from django.conf import settings
verbosity = options["verbosity"]
for app_name in settings.INSTA... | [
"def",
"runjobs_by_signals",
"(",
"self",
",",
"when",
",",
"options",
")",
":",
"# Thanks for Ian Holsman for the idea and code",
"from",
"django_extensions",
".",
"management",
"import",
"signals",
"from",
"django",
".",
"conf",
"import",
"settings",
"verbosity",
"=... | Run jobs from the signals | [
"Run",
"jobs",
"from",
"the",
"signals"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/runjobs.py#L44-L74 |
224,971 | django-extensions/django-extensions | django_extensions/__init__.py | get_version | def get_version(version):
"""Dynamically calculate the version based on VERSION tuple."""
if len(version) > 2 and version[2] is not None:
if isinstance(version[2], int):
str_version = "%s.%s.%s" % version[:3]
else:
str_version = "%s.%s_%s" % version[:3]
else:
... | python | def get_version(version):
"""Dynamically calculate the version based on VERSION tuple."""
if len(version) > 2 and version[2] is not None:
if isinstance(version[2], int):
str_version = "%s.%s.%s" % version[:3]
else:
str_version = "%s.%s_%s" % version[:3]
else:
... | [
"def",
"get_version",
"(",
"version",
")",
":",
"if",
"len",
"(",
"version",
")",
">",
"2",
"and",
"version",
"[",
"2",
"]",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"version",
"[",
"2",
"]",
",",
"int",
")",
":",
"str_version",
"=",
"\... | Dynamically calculate the version based on VERSION tuple. | [
"Dynamically",
"calculate",
"the",
"version",
"based",
"on",
"VERSION",
"tuple",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/__init__.py#L5-L15 |
224,972 | django-extensions/django-extensions | django_extensions/templatetags/indent_text.py | indentby | def indentby(parser, token):
"""
Add indentation to text between the tags by the given indentation level.
{% indentby <indent_level> [if <statement>] %}
...
{% endindentby %}
Arguments:
indent_level - Number of spaces to indent text with.
statement - Only apply indent_level if the ... | python | def indentby(parser, token):
"""
Add indentation to text between the tags by the given indentation level.
{% indentby <indent_level> [if <statement>] %}
...
{% endindentby %}
Arguments:
indent_level - Number of spaces to indent text with.
statement - Only apply indent_level if the ... | [
"def",
"indentby",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"token",
".",
"split_contents",
"(",
")",
"largs",
"=",
"len",
"(",
"args",
")",
"if",
"largs",
"not",
"in",
"(",
"2",
",",
"4",
")",
":",
"raise",
"template",
".",
"TemplateSyn... | Add indentation to text between the tags by the given indentation level.
{% indentby <indent_level> [if <statement>] %}
...
{% endindentby %}
Arguments:
indent_level - Number of spaces to indent text with.
statement - Only apply indent_level if the boolean statement evalutates to True. | [
"Add",
"indentation",
"to",
"text",
"between",
"the",
"tags",
"by",
"the",
"given",
"indentation",
"level",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/templatetags/indent_text.py#L33-L55 |
224,973 | django-extensions/django-extensions | django_extensions/management/commands/pipchecker.py | Command._urlopen_as_json | def _urlopen_as_json(self, url, headers=None):
"""Shorcut for return contents as json"""
req = Request(url, headers=headers)
return json.loads(urlopen(req).read()) | python | def _urlopen_as_json(self, url, headers=None):
"""Shorcut for return contents as json"""
req = Request(url, headers=headers)
return json.loads(urlopen(req).read()) | [
"def",
"_urlopen_as_json",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
")",
":",
"req",
"=",
"Request",
"(",
"url",
",",
"headers",
"=",
"headers",
")",
"return",
"json",
".",
"loads",
"(",
"urlopen",
"(",
"req",
")",
".",
"read",
"(",
")... | Shorcut for return contents as json | [
"Shorcut",
"for",
"return",
"contents",
"as",
"json"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L116-L119 |
224,974 | django-extensions/django-extensions | django_extensions/management/commands/pipchecker.py | Command.check_pypi | def check_pypi(self):
"""If the requirement is frozen to pypi, check for a new version."""
for dist in get_installed_distributions():
name = dist.project_name
if name in self.reqs.keys():
self.reqs[name]["dist"] = dist
pypi = ServerProxy("https://pypi.pyt... | python | def check_pypi(self):
"""If the requirement is frozen to pypi, check for a new version."""
for dist in get_installed_distributions():
name = dist.project_name
if name in self.reqs.keys():
self.reqs[name]["dist"] = dist
pypi = ServerProxy("https://pypi.pyt... | [
"def",
"check_pypi",
"(",
"self",
")",
":",
"for",
"dist",
"in",
"get_installed_distributions",
"(",
")",
":",
"name",
"=",
"dist",
".",
"project_name",
"if",
"name",
"in",
"self",
".",
"reqs",
".",
"keys",
"(",
")",
":",
"self",
".",
"reqs",
"[",
"n... | If the requirement is frozen to pypi, check for a new version. | [
"If",
"the",
"requirement",
"is",
"frozen",
"to",
"pypi",
"check",
"for",
"a",
"new",
"version",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L132-L164 |
224,975 | django-extensions/django-extensions | django_extensions/management/commands/pipchecker.py | Command.check_other | def check_other(self):
"""
If the requirement is frozen somewhere other than pypi or github, skip.
If you have a private pypi or use --extra-index-url, consider contributing
support here.
"""
if self.reqs:
self.stdout.write(self.style.ERROR("\nOnly pypi and g... | python | def check_other(self):
"""
If the requirement is frozen somewhere other than pypi or github, skip.
If you have a private pypi or use --extra-index-url, consider contributing
support here.
"""
if self.reqs:
self.stdout.write(self.style.ERROR("\nOnly pypi and g... | [
"def",
"check_other",
"(",
"self",
")",
":",
"if",
"self",
".",
"reqs",
":",
"self",
".",
"stdout",
".",
"write",
"(",
"self",
".",
"style",
".",
"ERROR",
"(",
"\"\\nOnly pypi and github based requirements are supported:\"",
")",
")",
"for",
"name",
",",
"re... | If the requirement is frozen somewhere other than pypi or github, skip.
If you have a private pypi or use --extra-index-url, consider contributing
support here. | [
"If",
"the",
"requirement",
"is",
"frozen",
"somewhere",
"other",
"than",
"pypi",
"or",
"github",
"skip",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/pipchecker.py#L297-L313 |
224,976 | django-extensions/django-extensions | django_extensions/db/fields/encrypted.py | BaseEncryptedField.get_crypt_class | def get_crypt_class(self):
"""
Get the Keyczar class to use.
The class can be customized with the ENCRYPTED_FIELD_MODE setting. By default,
this setting is DECRYPT_AND_ENCRYPT. Set this to ENCRYPT to disable decryption.
This is necessary if you are only providing public keys to ... | python | def get_crypt_class(self):
"""
Get the Keyczar class to use.
The class can be customized with the ENCRYPTED_FIELD_MODE setting. By default,
this setting is DECRYPT_AND_ENCRYPT. Set this to ENCRYPT to disable decryption.
This is necessary if you are only providing public keys to ... | [
"def",
"get_crypt_class",
"(",
"self",
")",
":",
"crypt_type",
"=",
"getattr",
"(",
"settings",
",",
"'ENCRYPTED_FIELD_MODE'",
",",
"'DECRYPT_AND_ENCRYPT'",
")",
"if",
"crypt_type",
"==",
"'ENCRYPT'",
":",
"crypt_class_name",
"=",
"'Encrypter'",
"elif",
"crypt_type"... | Get the Keyczar class to use.
The class can be customized with the ENCRYPTED_FIELD_MODE setting. By default,
this setting is DECRYPT_AND_ENCRYPT. Set this to ENCRYPT to disable decryption.
This is necessary if you are only providing public keys to Keyczar.
Returns:
keyczar.... | [
"Get",
"the",
"Keyczar",
"class",
"to",
"use",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/db/fields/encrypted.py#L46-L69 |
224,977 | django-extensions/django-extensions | django_extensions/management/commands/sqldsn.py | Command._postgresql | def _postgresql(self, dbhost, dbport, dbname, dbuser, dbpass, dsn_style=None): # noqa
"""PostgreSQL psycopg2 driver accepts two syntaxes
Plus a string for .pgpass file
"""
dsn = []
if dsn_style is None or dsn_style == 'all' or dsn_style == 'keyvalue':
dsnstr = "ho... | python | def _postgresql(self, dbhost, dbport, dbname, dbuser, dbpass, dsn_style=None): # noqa
"""PostgreSQL psycopg2 driver accepts two syntaxes
Plus a string for .pgpass file
"""
dsn = []
if dsn_style is None or dsn_style == 'all' or dsn_style == 'keyvalue':
dsnstr = "ho... | [
"def",
"_postgresql",
"(",
"self",
",",
"dbhost",
",",
"dbport",
",",
"dbname",
",",
"dbuser",
",",
"dbpass",
",",
"dsn_style",
"=",
"None",
")",
":",
"# noqa",
"dsn",
"=",
"[",
"]",
"if",
"dsn_style",
"is",
"None",
"or",
"dsn_style",
"==",
"'all'",
... | PostgreSQL psycopg2 driver accepts two syntaxes
Plus a string for .pgpass file | [
"PostgreSQL",
"psycopg2",
"driver",
"accepts",
"two",
"syntaxes"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sqldsn.py#L100-L141 |
224,978 | django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | check_dependencies | def check_dependencies(model, model_queue, avaliable_models):
""" Check that all the depenedencies for this model are already in the queue. """
# A list of allowed links: existing fields, itself and the special case ContentType
allowed_links = [m.model.__name__ for m in model_queue] + [model.__name__, 'Cont... | python | def check_dependencies(model, model_queue, avaliable_models):
""" Check that all the depenedencies for this model are already in the queue. """
# A list of allowed links: existing fields, itself and the special case ContentType
allowed_links = [m.model.__name__ for m in model_queue] + [model.__name__, 'Cont... | [
"def",
"check_dependencies",
"(",
"model",
",",
"model_queue",
",",
"avaliable_models",
")",
":",
"# A list of allowed links: existing fields, itself and the special case ContentType",
"allowed_links",
"=",
"[",
"m",
".",
"model",
".",
"__name__",
"for",
"m",
"in",
"model... | Check that all the depenedencies for this model are already in the queue. | [
"Check",
"that",
"all",
"the",
"depenedencies",
"for",
"this",
"model",
"are",
"already",
"in",
"the",
"queue",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L712-L733 |
224,979 | django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | Code.get_import_lines | def get_import_lines(self):
""" Take the stored imports and converts them to lines """
if self.imports:
return ["from %s import %s" % (value, key) for key, value in self.imports.items()]
else:
return [] | python | def get_import_lines(self):
""" Take the stored imports and converts them to lines """
if self.imports:
return ["from %s import %s" % (value, key) for key, value in self.imports.items()]
else:
return [] | [
"def",
"get_import_lines",
"(",
"self",
")",
":",
"if",
"self",
".",
"imports",
":",
"return",
"[",
"\"from %s import %s\"",
"%",
"(",
"value",
",",
"key",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"imports",
".",
"items",
"(",
")",
"]",
"e... | Take the stored imports and converts them to lines | [
"Take",
"the",
"stored",
"imports",
"and",
"converts",
"them",
"to",
"lines"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L178-L183 |
224,980 | django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | InstanceCode.skip | def skip(self):
"""
Determine whether or not this object should be skipped.
If this model instance is a parent of a single subclassed
instance, skip it. The subclassed instance will create this
parent instance for us.
TODO: Allow the user to force its creation?
"... | python | def skip(self):
"""
Determine whether or not this object should be skipped.
If this model instance is a parent of a single subclassed
instance, skip it. The subclassed instance will create this
parent instance for us.
TODO: Allow the user to force its creation?
"... | [
"def",
"skip",
"(",
"self",
")",
":",
"if",
"self",
".",
"skip_me",
"is",
"not",
"None",
":",
"return",
"self",
".",
"skip_me",
"cls",
"=",
"self",
".",
"instance",
".",
"__class__",
"using",
"=",
"router",
".",
"db_for_write",
"(",
"cls",
",",
"inst... | Determine whether or not this object should be skipped.
If this model instance is a parent of a single subclassed
instance, skip it. The subclassed instance will create this
parent instance for us.
TODO: Allow the user to force its creation? | [
"Determine",
"whether",
"or",
"not",
"this",
"object",
"should",
"be",
"skipped",
".",
"If",
"this",
"model",
"instance",
"is",
"a",
"parent",
"of",
"a",
"single",
"subclassed",
"instance",
"skip",
"it",
".",
"The",
"subclassed",
"instance",
"will",
"create"... | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L299-L327 |
224,981 | django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | InstanceCode.instantiate | def instantiate(self):
""" Write lines for instantiation """
# e.g. model_name_35 = Model()
code_lines = []
if not self.instantiated:
code_lines.append("%s = %s()" % (self.variable_name, self.model.__name__))
self.instantiated = True
# Store our vari... | python | def instantiate(self):
""" Write lines for instantiation """
# e.g. model_name_35 = Model()
code_lines = []
if not self.instantiated:
code_lines.append("%s = %s()" % (self.variable_name, self.model.__name__))
self.instantiated = True
# Store our vari... | [
"def",
"instantiate",
"(",
"self",
")",
":",
"# e.g. model_name_35 = Model()",
"code_lines",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"instantiated",
":",
"code_lines",
".",
"append",
"(",
"\"%s = %s()\"",
"%",
"(",
"self",
".",
"variable_name",
",",
"self",
... | Write lines for instantiation | [
"Write",
"lines",
"for",
"instantiation"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L329-L343 |
224,982 | django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | InstanceCode.get_waiting_list | def get_waiting_list(self, force=False):
""" Add lines for any waiting fields that can be completed now. """
code_lines = []
skip_autofield = self.options['skip_autofield']
# Process normal fields
for field in list(self.waiting_list):
try:
# Find the... | python | def get_waiting_list(self, force=False):
""" Add lines for any waiting fields that can be completed now. """
code_lines = []
skip_autofield = self.options['skip_autofield']
# Process normal fields
for field in list(self.waiting_list):
try:
# Find the... | [
"def",
"get_waiting_list",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"code_lines",
"=",
"[",
"]",
"skip_autofield",
"=",
"self",
".",
"options",
"[",
"'skip_autofield'",
"]",
"# Process normal fields",
"for",
"field",
"in",
"list",
"(",
"self",
".",... | Add lines for any waiting fields that can be completed now. | [
"Add",
"lines",
"for",
"any",
"waiting",
"fields",
"that",
"can",
"be",
"completed",
"now",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L345-L366 |
224,983 | django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | InstanceCode.get_many_to_many_lines | def get_many_to_many_lines(self, force=False):
""" Generate lines that define many to many relations for this instance. """
lines = []
for field, rel_items in self.many_to_many_waiting_list.items():
for rel_item in list(rel_items):
try:
pk_name =... | python | def get_many_to_many_lines(self, force=False):
""" Generate lines that define many to many relations for this instance. """
lines = []
for field, rel_items in self.many_to_many_waiting_list.items():
for rel_item in list(rel_items):
try:
pk_name =... | [
"def",
"get_many_to_many_lines",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"field",
",",
"rel_items",
"in",
"self",
".",
"many_to_many_waiting_list",
".",
"items",
"(",
")",
":",
"for",
"rel_item",
"in",
"list",
"(... | Generate lines that define many to many relations for this instance. | [
"Generate",
"lines",
"that",
"define",
"many",
"to",
"many",
"relations",
"for",
"this",
"instance",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L368-L391 |
224,984 | django-extensions/django-extensions | django_extensions/management/commands/dumpscript.py | Script._queue_models | def _queue_models(self, models, context):
"""
Work an an appropriate ordering for the models.
This isn't essential, but makes the script look nicer because
more instances can be defined on their first try.
"""
model_queue = []
number_remaining_models = len(models)... | python | def _queue_models(self, models, context):
"""
Work an an appropriate ordering for the models.
This isn't essential, but makes the script look nicer because
more instances can be defined on their first try.
"""
model_queue = []
number_remaining_models = len(models)... | [
"def",
"_queue_models",
"(",
"self",
",",
"models",
",",
"context",
")",
":",
"model_queue",
"=",
"[",
"]",
"number_remaining_models",
"=",
"len",
"(",
"models",
")",
"# Max number of cycles allowed before we call it an infinite loop.",
"MAX_CYCLES",
"=",
"number_remain... | Work an an appropriate ordering for the models.
This isn't essential, but makes the script look nicer because
more instances can be defined on their first try. | [
"Work",
"an",
"an",
"appropriate",
"ordering",
"for",
"the",
"models",
".",
"This",
"isn",
"t",
"essential",
"but",
"makes",
"the",
"script",
"look",
"nicer",
"because",
"more",
"instances",
"can",
"be",
"defined",
"on",
"their",
"first",
"try",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/dumpscript.py#L411-L454 |
224,985 | django-extensions/django-extensions | django_extensions/management/commands/sqldiff.py | SQLDiff.sql_to_dict | def sql_to_dict(self, query, param):
"""
Execute query and return a dict
sql_to_dict(query, param) -> list of dicts
code from snippet at http://www.djangosnippets.org/snippets/1383/
"""
cursor = connection.cursor()
cursor.execute(query, param)
fieldnames... | python | def sql_to_dict(self, query, param):
"""
Execute query and return a dict
sql_to_dict(query, param) -> list of dicts
code from snippet at http://www.djangosnippets.org/snippets/1383/
"""
cursor = connection.cursor()
cursor.execute(query, param)
fieldnames... | [
"def",
"sql_to_dict",
"(",
"self",
",",
"query",
",",
"param",
")",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"query",
",",
"param",
")",
"fieldnames",
"=",
"[",
"name",
"[",
"0",
"]",
"for",
"name",
... | Execute query and return a dict
sql_to_dict(query, param) -> list of dicts
code from snippet at http://www.djangosnippets.org/snippets/1383/ | [
"Execute",
"query",
"and",
"return",
"a",
"dict"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sqldiff.py#L257-L274 |
224,986 | django-extensions/django-extensions | django_extensions/management/commands/sqldiff.py | SQLDiff.print_diff | def print_diff(self, style=no_style()):
""" Print differences to stdout """
if self.options['sql']:
self.print_diff_sql(style)
else:
self.print_diff_text(style) | python | def print_diff(self, style=no_style()):
""" Print differences to stdout """
if self.options['sql']:
self.print_diff_sql(style)
else:
self.print_diff_text(style) | [
"def",
"print_diff",
"(",
"self",
",",
"style",
"=",
"no_style",
"(",
")",
")",
":",
"if",
"self",
".",
"options",
"[",
"'sql'",
"]",
":",
"self",
".",
"print_diff_sql",
"(",
"style",
")",
"else",
":",
"self",
".",
"print_diff_text",
"(",
"style",
")... | Print differences to stdout | [
"Print",
"differences",
"to",
"stdout"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/sqldiff.py#L676-L681 |
224,987 | django-extensions/django-extensions | django_extensions/templatetags/syntax_color.py | pygments_required | def pygments_required(func):
"""Raise ImportError if pygments is not installed."""
def wrapper(*args, **kwargs):
if not HAS_PYGMENTS: # pragma: no cover
raise ImportError(
"Please install 'pygments' library to use syntax_color.")
rv = func(*args, **kwargs)
re... | python | def pygments_required(func):
"""Raise ImportError if pygments is not installed."""
def wrapper(*args, **kwargs):
if not HAS_PYGMENTS: # pragma: no cover
raise ImportError(
"Please install 'pygments' library to use syntax_color.")
rv = func(*args, **kwargs)
re... | [
"def",
"pygments_required",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"HAS_PYGMENTS",
":",
"# pragma: no cover",
"raise",
"ImportError",
"(",
"\"Please install 'pygments' library to use syntax_color.\"... | Raise ImportError if pygments is not installed. | [
"Raise",
"ImportError",
"if",
"pygments",
"is",
"not",
"installed",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/templatetags/syntax_color.py#L54-L62 |
224,988 | django-extensions/django-extensions | django_extensions/utils/dia2django.py | addparentstofks | def addparentstofks(rels, fks):
"""
Get a list of relations, between parents and sons and a dict of
clases named in dia, and modifies the fks to add the parent as fk to get
order on the output of classes and replaces the base class of the son, to
put the class parent name.
"""
for j in rels:... | python | def addparentstofks(rels, fks):
"""
Get a list of relations, between parents and sons and a dict of
clases named in dia, and modifies the fks to add the parent as fk to get
order on the output of classes and replaces the base class of the son, to
put the class parent name.
"""
for j in rels:... | [
"def",
"addparentstofks",
"(",
"rels",
",",
"fks",
")",
":",
"for",
"j",
"in",
"rels",
":",
"son",
"=",
"index",
"(",
"fks",
",",
"j",
"[",
"1",
"]",
")",
"parent",
"=",
"index",
"(",
"fks",
",",
"j",
"[",
"0",
"]",
")",
"fks",
"[",
"son",
... | Get a list of relations, between parents and sons and a dict of
clases named in dia, and modifies the fks to add the parent as fk to get
order on the output of classes and replaces the base class of the son, to
put the class parent name. | [
"Get",
"a",
"list",
"of",
"relations",
"between",
"parents",
"and",
"sons",
"and",
"a",
"dict",
"of",
"clases",
"named",
"in",
"dia",
"and",
"modifies",
"the",
"fks",
"to",
"add",
"the",
"parent",
"as",
"fk",
"to",
"get",
"order",
"on",
"the",
"output"... | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/utils/dia2django.py#L57-L69 |
224,989 | django-extensions/django-extensions | django_extensions/management/shells.py | get_app_name | def get_app_name(mod_name):
"""
Retrieve application name from models.py module path
>>> get_app_name('testapp.models.foo')
'testapp'
'testapp' instead of 'some.testapp' for compatibility:
>>> get_app_name('some.testapp.models.foo')
'testapp'
>>> get_app_name('some.models.testapp.model... | python | def get_app_name(mod_name):
"""
Retrieve application name from models.py module path
>>> get_app_name('testapp.models.foo')
'testapp'
'testapp' instead of 'some.testapp' for compatibility:
>>> get_app_name('some.testapp.models.foo')
'testapp'
>>> get_app_name('some.models.testapp.model... | [
"def",
"get_app_name",
"(",
"mod_name",
")",
":",
"rparts",
"=",
"list",
"(",
"reversed",
"(",
"mod_name",
".",
"split",
"(",
"'.'",
")",
")",
")",
"try",
":",
"try",
":",
"return",
"rparts",
"[",
"rparts",
".",
"index",
"(",
"MODELS_MODULE_NAME",
")",... | Retrieve application name from models.py module path
>>> get_app_name('testapp.models.foo')
'testapp'
'testapp' instead of 'some.testapp' for compatibility:
>>> get_app_name('some.testapp.models.foo')
'testapp'
>>> get_app_name('some.models.testapp.models.foo')
'testapp'
>>> get_app_na... | [
"Retrieve",
"application",
"name",
"from",
"models",
".",
"py",
"module",
"path"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/shells.py#L46-L72 |
224,990 | django-extensions/django-extensions | django_extensions/management/commands/merge_model_instances.py | get_generic_fields | def get_generic_fields():
"""Return a list of all GenericForeignKeys in all models."""
generic_fields = []
for model in apps.get_models():
for field_name, field in model.__dict__.items():
if isinstance(field, GenericForeignKey):
generic_fields.append(field)
return gen... | python | def get_generic_fields():
"""Return a list of all GenericForeignKeys in all models."""
generic_fields = []
for model in apps.get_models():
for field_name, field in model.__dict__.items():
if isinstance(field, GenericForeignKey):
generic_fields.append(field)
return gen... | [
"def",
"get_generic_fields",
"(",
")",
":",
"generic_fields",
"=",
"[",
"]",
"for",
"model",
"in",
"apps",
".",
"get_models",
"(",
")",
":",
"for",
"field_name",
",",
"field",
"in",
"model",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstan... | Return a list of all GenericForeignKeys in all models. | [
"Return",
"a",
"list",
"of",
"all",
"GenericForeignKeys",
"in",
"all",
"models",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/merge_model_instances.py#L78-L85 |
224,991 | django-extensions/django-extensions | django_extensions/management/commands/merge_model_instances.py | Command.merge_model_instances | def merge_model_instances(self, primary_object, alias_objects):
"""
Merge several model instances into one, the `primary_object`.
Use this function to merge model objects and migrate all of the related
fields from the alias objects the primary object.
"""
generic_fields =... | python | def merge_model_instances(self, primary_object, alias_objects):
"""
Merge several model instances into one, the `primary_object`.
Use this function to merge model objects and migrate all of the related
fields from the alias objects the primary object.
"""
generic_fields =... | [
"def",
"merge_model_instances",
"(",
"self",
",",
"primary_object",
",",
"alias_objects",
")",
":",
"generic_fields",
"=",
"get_generic_fields",
"(",
")",
"# get related fields",
"related_fields",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"i... | Merge several model instances into one, the `primary_object`.
Use this function to merge model objects and migrate all of the related
fields from the alias objects the primary object. | [
"Merge",
"several",
"model",
"instances",
"into",
"one",
"the",
"primary_object",
".",
"Use",
"this",
"function",
"to",
"merge",
"model",
"objects",
"and",
"migrate",
"all",
"of",
"the",
"related",
"fields",
"from",
"the",
"alias",
"objects",
"the",
"primary",... | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/merge_model_instances.py#L132-L222 |
224,992 | django-extensions/django-extensions | django_extensions/management/commands/graph_models.py | Command.add_arguments | def add_arguments(self, parser):
"""Unpack self.arguments for parser.add_arguments."""
parser.add_argument('app_label', nargs='*')
for argument in self.arguments:
parser.add_argument(*argument.split(' '), **self.arguments[argument]) | python | def add_arguments(self, parser):
"""Unpack self.arguments for parser.add_arguments."""
parser.add_argument('app_label', nargs='*')
for argument in self.arguments:
parser.add_argument(*argument.split(' '), **self.arguments[argument]) | [
"def",
"add_arguments",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'app_label'",
",",
"nargs",
"=",
"'*'",
")",
"for",
"argument",
"in",
"self",
".",
"arguments",
":",
"parser",
".",
"add_argument",
"(",
"*",
"argument",
"... | Unpack self.arguments for parser.add_arguments. | [
"Unpack",
"self",
".",
"arguments",
"for",
"parser",
".",
"add_arguments",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L169-L173 |
224,993 | django-extensions/django-extensions | django_extensions/management/commands/graph_models.py | Command.render_output_json | def render_output_json(self, graph_data, output_file=None):
"""Write model data to file or stdout in JSON format."""
if output_file:
with open(output_file, 'wt') as json_output_f:
json.dump(graph_data, json_output_f)
else:
self.stdout.write(json.dumps(grap... | python | def render_output_json(self, graph_data, output_file=None):
"""Write model data to file or stdout in JSON format."""
if output_file:
with open(output_file, 'wt') as json_output_f:
json.dump(graph_data, json_output_f)
else:
self.stdout.write(json.dumps(grap... | [
"def",
"render_output_json",
"(",
"self",
",",
"graph_data",
",",
"output_file",
"=",
"None",
")",
":",
"if",
"output_file",
":",
"with",
"open",
"(",
"output_file",
",",
"'wt'",
")",
"as",
"json_output_f",
":",
"json",
".",
"dump",
"(",
"graph_data",
",",... | Write model data to file or stdout in JSON format. | [
"Write",
"model",
"data",
"to",
"file",
"or",
"stdout",
"in",
"JSON",
"format",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L246-L252 |
224,994 | django-extensions/django-extensions | django_extensions/management/commands/graph_models.py | Command.render_output_pygraphviz | def render_output_pygraphviz(self, dotdata, **kwargs):
"""Render model data as image using pygraphviz"""
if not HAS_PYGRAPHVIZ:
raise CommandError("You need to install pygraphviz python module")
version = pygraphviz.__version__.rstrip("-svn")
try:
if tuple(int(v)... | python | def render_output_pygraphviz(self, dotdata, **kwargs):
"""Render model data as image using pygraphviz"""
if not HAS_PYGRAPHVIZ:
raise CommandError("You need to install pygraphviz python module")
version = pygraphviz.__version__.rstrip("-svn")
try:
if tuple(int(v)... | [
"def",
"render_output_pygraphviz",
"(",
"self",
",",
"dotdata",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"HAS_PYGRAPHVIZ",
":",
"raise",
"CommandError",
"(",
"\"You need to install pygraphviz python module\"",
")",
"version",
"=",
"pygraphviz",
".",
"__versio... | Render model data as image using pygraphviz | [
"Render",
"model",
"data",
"as",
"image",
"using",
"pygraphviz"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L254-L272 |
224,995 | django-extensions/django-extensions | django_extensions/management/commands/graph_models.py | Command.render_output_pydot | def render_output_pydot(self, dotdata, **kwargs):
"""Render model data as image using pydot"""
if not HAS_PYDOT:
raise CommandError("You need to install pydot python module")
graph = pydot.graph_from_dot_data(dotdata)
if not graph:
raise CommandError("pydot retur... | python | def render_output_pydot(self, dotdata, **kwargs):
"""Render model data as image using pydot"""
if not HAS_PYDOT:
raise CommandError("You need to install pydot python module")
graph = pydot.graph_from_dot_data(dotdata)
if not graph:
raise CommandError("pydot retur... | [
"def",
"render_output_pydot",
"(",
"self",
",",
"dotdata",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"HAS_PYDOT",
":",
"raise",
"CommandError",
"(",
"\"You need to install pydot python module\"",
")",
"graph",
"=",
"pydot",
".",
"graph_from_dot_data",
"(",
... | Render model data as image using pydot | [
"Render",
"model",
"data",
"as",
"image",
"using",
"pydot"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/graph_models.py#L274-L297 |
224,996 | django-extensions/django-extensions | django_extensions/management/commands/show_urls.py | Command.extract_views_from_urlpatterns | def extract_views_from_urlpatterns(self, urlpatterns, base='', namespace=None):
"""
Return a list of views from a list of urlpatterns.
Each object in the returned list is a three-tuple: (view_func, regex, name)
"""
views = []
for p in urlpatterns:
if isinstan... | python | def extract_views_from_urlpatterns(self, urlpatterns, base='', namespace=None):
"""
Return a list of views from a list of urlpatterns.
Each object in the returned list is a three-tuple: (view_func, regex, name)
"""
views = []
for p in urlpatterns:
if isinstan... | [
"def",
"extract_views_from_urlpatterns",
"(",
"self",
",",
"urlpatterns",
",",
"base",
"=",
"''",
",",
"namespace",
"=",
"None",
")",
":",
"views",
"=",
"[",
"]",
"for",
"p",
"in",
"urlpatterns",
":",
"if",
"isinstance",
"(",
"p",
",",
"(",
"URLPattern",... | Return a list of views from a list of urlpatterns.
Each object in the returned list is a three-tuple: (view_func, regex, name) | [
"Return",
"a",
"list",
"of",
"views",
"from",
"a",
"list",
"of",
"urlpatterns",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/commands/show_urls.py#L196-L245 |
224,997 | django-extensions/django-extensions | django_extensions/admin/__init__.py | ForeignKeyAutocompleteAdminMixin.foreignkey_autocomplete | def foreignkey_autocomplete(self, request):
"""
Search in the fields of the given related model and returns the
result as a simple string to be used by the jQuery Autocomplete plugin
"""
query = request.GET.get('q', None)
app_label = request.GET.get('app_label', None)
... | python | def foreignkey_autocomplete(self, request):
"""
Search in the fields of the given related model and returns the
result as a simple string to be used by the jQuery Autocomplete plugin
"""
query = request.GET.get('q', None)
app_label = request.GET.get('app_label', None)
... | [
"def",
"foreignkey_autocomplete",
"(",
"self",
",",
"request",
")",
":",
"query",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'q'",
",",
"None",
")",
"app_label",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'app_label'",
",",
"None",
")",
"model_na... | Search in the fields of the given related model and returns the
result as a simple string to be used by the jQuery Autocomplete plugin | [
"Search",
"in",
"the",
"fields",
"of",
"the",
"given",
"related",
"model",
"and",
"returns",
"the",
"result",
"as",
"a",
"simple",
"string",
"to",
"be",
"used",
"by",
"the",
"jQuery",
"Autocomplete",
"plugin"
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/admin/__init__.py#L67-L126 |
224,998 | django-extensions/django-extensions | django_extensions/admin/__init__.py | ForeignKeyAutocompleteAdminMixin.formfield_for_dbfield | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Override the default widget for Foreignkey fields if they are
specified in the related_search_fields class attribute.
"""
if isinstance(db_field, models.ForeignKey) and db_field.name in self.related_search_fields:
... | python | def formfield_for_dbfield(self, db_field, **kwargs):
"""
Override the default widget for Foreignkey fields if they are
specified in the related_search_fields class attribute.
"""
if isinstance(db_field, models.ForeignKey) and db_field.name in self.related_search_fields:
... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"db_field",
",",
"models",
".",
"ForeignKey",
")",
"and",
"db_field",
".",
"name",
"in",
"self",
".",
"related_search_fields",
":",
"h... | Override the default widget for Foreignkey fields if they are
specified in the related_search_fields class attribute. | [
"Override",
"the",
"default",
"widget",
"for",
"Foreignkey",
"fields",
"if",
"they",
"are",
"specified",
"in",
"the",
"related_search_fields",
"class",
"attribute",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/admin/__init__.py#L147-L158 |
224,999 | django-extensions/django-extensions | django_extensions/management/technical_response.py | null_technical_500_response | def null_technical_500_response(request, exc_type, exc_value, tb, status_code=500):
"""
Alternative function for django.views.debug.technical_500_response.
Django's convert_exception_to_response() wrapper is called on each 'Middleware' object to avoid
leaking exceptions. If an uncaught exception is rai... | python | def null_technical_500_response(request, exc_type, exc_value, tb, status_code=500):
"""
Alternative function for django.views.debug.technical_500_response.
Django's convert_exception_to_response() wrapper is called on each 'Middleware' object to avoid
leaking exceptions. If an uncaught exception is rai... | [
"def",
"null_technical_500_response",
"(",
"request",
",",
"exc_type",
",",
"exc_value",
",",
"tb",
",",
"status_code",
"=",
"500",
")",
":",
"try",
":",
"# Store the most recent tb for WSGI requests. The class can be found in the second frame of the tb",
"if",
"isinstance",
... | Alternative function for django.views.debug.technical_500_response.
Django's convert_exception_to_response() wrapper is called on each 'Middleware' object to avoid
leaking exceptions. If an uncaught exception is raised, the wrapper calls technical_500_response()
to create a response for django's debug view... | [
"Alternative",
"function",
"for",
"django",
".",
"views",
".",
"debug",
".",
"technical_500_response",
"."
] | 7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8 | https://github.com/django-extensions/django-extensions/blob/7e0bef97ea6cb7f9eea5e2528e3a985a83a7b9b8/django_extensions/management/technical_response.py#L11-L37 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.