repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
thoas/django-backward
backward/decorators.py
login_required
def login_required(function=None, message=None, login_url=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ actual_decorator = user_passes_test( lambda u: u.is_authenticated(), message=message, login_url=lo...
python
def login_required(function=None, message=None, login_url=None): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary. """ actual_decorator = user_passes_test( lambda u: u.is_authenticated(), message=message, login_url=lo...
[ "def", "login_required", "(", "function", "=", "None", ",", "message", "=", "None", ",", "login_url", "=", "None", ")", ":", "actual_decorator", "=", "user_passes_test", "(", "lambda", "u", ":", "u", ".", "is_authenticated", "(", ")", ",", "message", "=", ...
Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.
[ "Decorator", "for", "views", "that", "checks", "that", "the", "user", "is", "logged", "in", "redirecting", "to", "the", "log", "-", "in", "page", "if", "necessary", "." ]
train
https://github.com/thoas/django-backward/blob/8a544d450bce040877d86776ef696e0f76960692/backward/decorators.py#L48-L61
salimm/pylods
pylods/serialize.py
DataFormatGenerator._write_object
def _write_object(self, val, outstream): ''' Write object into the stream :param val: :param outstream: ''' # first attempt using an existing custom serializer serializer = self.__lookup_serializer(getattr(val, '__class__')) if serializer is not None: ...
python
def _write_object(self, val, outstream): ''' Write object into the stream :param val: :param outstream: ''' # first attempt using an existing custom serializer serializer = self.__lookup_serializer(getattr(val, '__class__')) if serializer is not None: ...
[ "def", "_write_object", "(", "self", ",", "val", ",", "outstream", ")", ":", "# first attempt using an existing custom serializer", "serializer", "=", "self", ".", "__lookup_serializer", "(", "getattr", "(", "val", ",", "'__class__'", ")", ")", "if", "serializer", ...
Write object into the stream :param val: :param outstream:
[ "Write", "object", "into", "the", "stream", ":", "param", "val", ":", ":", "param", "outstream", ":" ]
train
https://github.com/salimm/pylods/blob/d089e2a9afb1fa8cb6c754933fc574b512757c40/pylods/serialize.py#L84-L124
salimm/pylods
pylods/serialize.py
DataFormatGenerator._write_dict
def _write_dict(self, val, outstream): ''' write a dictionary :param val: :param outstream: ''' fields = val.keys() length = len(fields) self.write_dict_start(length, outstream) if length > 0: self.write_dict_field(fields[0], val[fields...
python
def _write_dict(self, val, outstream): ''' write a dictionary :param val: :param outstream: ''' fields = val.keys() length = len(fields) self.write_dict_start(length, outstream) if length > 0: self.write_dict_field(fields[0], val[fields...
[ "def", "_write_dict", "(", "self", ",", "val", ",", "outstream", ")", ":", "fields", "=", "val", ".", "keys", "(", ")", "length", "=", "len", "(", "fields", ")", "self", ".", "write_dict_start", "(", "length", ",", "outstream", ")", "if", "length", "...
write a dictionary :param val: :param outstream:
[ "write", "a", "dictionary", ":", "param", "val", ":", ":", "param", "outstream", ":" ]
train
https://github.com/salimm/pylods/blob/d089e2a9afb1fa8cb6c754933fc574b512757c40/pylods/serialize.py#L132-L150
za-creature/gulpless
gulpless/proxy.py
Proxy.on_any_event
def on_any_event(self, event): """Called whenever a FS event occurs.""" self.updated = True if self._changed: self._changed()
python
def on_any_event(self, event): """Called whenever a FS event occurs.""" self.updated = True if self._changed: self._changed()
[ "def", "on_any_event", "(", "self", ",", "event", ")", ":", "self", ".", "updated", "=", "True", "if", "self", ".", "_changed", ":", "self", ".", "_changed", "(", ")" ]
Called whenever a FS event occurs.
[ "Called", "whenever", "a", "FS", "event", "occurs", "." ]
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/proxy.py#L19-L23
za-creature/gulpless
gulpless/proxy.py
Proxy.changes
def changes(self): """Collects all changes that have been performed on the monitored path, returning them as a (created, deleted) tuple.""" deleted = [] for path in list(self.files): isdir = path.endswith(os.sep) abspath = os.path.join(self.path, path) ...
python
def changes(self): """Collects all changes that have been performed on the monitored path, returning them as a (created, deleted) tuple.""" deleted = [] for path in list(self.files): isdir = path.endswith(os.sep) abspath = os.path.join(self.path, path) ...
[ "def", "changes", "(", "self", ")", ":", "deleted", "=", "[", "]", "for", "path", "in", "list", "(", "self", ".", "files", ")", ":", "isdir", "=", "path", ".", "endswith", "(", "os", ".", "sep", ")", "abspath", "=", "os", ".", "path", ".", "joi...
Collects all changes that have been performed on the monitored path, returning them as a (created, deleted) tuple.
[ "Collects", "all", "changes", "that", "have", "been", "performed", "on", "the", "monitored", "path", "returning", "them", "as", "a", "(", "created", "deleted", ")", "tuple", "." ]
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/proxy.py#L25-L80
racker/torment
torment/decorators.py
log
def log(prefix = ''): '''Add start and stop logging messages to the function. Parameters ---------- :``prefix``: a prefix for the function name (optional) ''' function = None if inspect.isfunction(prefix): prefix, function = '', prefix def _(function): @functools.wr...
python
def log(prefix = ''): '''Add start and stop logging messages to the function. Parameters ---------- :``prefix``: a prefix for the function name (optional) ''' function = None if inspect.isfunction(prefix): prefix, function = '', prefix def _(function): @functools.wr...
[ "def", "log", "(", "prefix", "=", "''", ")", ":", "function", "=", "None", "if", "inspect", ".", "isfunction", "(", "prefix", ")", ":", "prefix", ",", "function", "=", "''", ",", "prefix", "def", "_", "(", "function", ")", ":", "@", "functools", "....
Add start and stop logging messages to the function. Parameters ---------- :``prefix``: a prefix for the function name (optional)
[ "Add", "start", "and", "stop", "logging", "messages", "to", "the", "function", "." ]
train
https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/decorators.py#L28-L77
racker/torment
torment/decorators.py
mock
def mock(name: str) -> Callable[[Any], None]: '''Setup properties indicating status of name mock. This is designed to decorate ``torment.TestContext`` methods and is used to provide a consistent interface for determining if name is mocked once and only once. Parameters ---------- :``name`...
python
def mock(name: str) -> Callable[[Any], None]: '''Setup properties indicating status of name mock. This is designed to decorate ``torment.TestContext`` methods and is used to provide a consistent interface for determining if name is mocked once and only once. Parameters ---------- :``name`...
[ "def", "mock", "(", "name", ":", "str", ")", "->", "Callable", "[", "[", "Any", "]", ",", "None", "]", ":", "def", "_", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ...
Setup properties indicating status of name mock. This is designed to decorate ``torment.TestContext`` methods and is used to provide a consistent interface for determining if name is mocked once and only once. Parameters ---------- :``name``: symbol in context's module to mock Return Val...
[ "Setup", "properties", "indicating", "status", "of", "name", "mock", "." ]
train
https://github.com/racker/torment/blob/bd5d2f978324bf9b7360edfae76d853b226c63e1/torment/decorators.py#L80-L128
Metatab/tableintuit
tableintuit/rows.py
RowIntuiter.spec
def spec(self): """Return a dict with values that can be fed directly into SelectiveRowGenerator""" return dict( headers=self.header_lines, start=self.start_line, comments=self.comment_lines, end=self.end_line )
python
def spec(self): """Return a dict with values that can be fed directly into SelectiveRowGenerator""" return dict( headers=self.header_lines, start=self.start_line, comments=self.comment_lines, end=self.end_line )
[ "def", "spec", "(", "self", ")", ":", "return", "dict", "(", "headers", "=", "self", ".", "header_lines", ",", "start", "=", "self", ".", "start_line", ",", "comments", "=", "self", ".", "comment_lines", ",", "end", "=", "self", ".", "end_line", ")" ]
Return a dict with values that can be fed directly into SelectiveRowGenerator
[ "Return", "a", "dict", "with", "values", "that", "can", "be", "fed", "directly", "into", "SelectiveRowGenerator" ]
train
https://github.com/Metatab/tableintuit/blob/9a3d500d5d90e44e6637dd17ca4c8dae474d6d4c/tableintuit/rows.py#L70-L77
Metatab/tableintuit
tableintuit/rows.py
RowIntuiter.picture
def picture(self, row): """Create a simplified character representation of the data row, which can be pattern matched with a regex """ template = '_Xn' types = (type(None), binary_type, int) def guess_type(v): try: v = text_type(v).strip() ...
python
def picture(self, row): """Create a simplified character representation of the data row, which can be pattern matched with a regex """ template = '_Xn' types = (type(None), binary_type, int) def guess_type(v): try: v = text_type(v).strip() ...
[ "def", "picture", "(", "self", ",", "row", ")", ":", "template", "=", "'_Xn'", "types", "=", "(", "type", "(", "None", ")", ",", "binary_type", ",", "int", ")", "def", "guess_type", "(", "v", ")", ":", "try", ":", "v", "=", "text_type", "(", "v",...
Create a simplified character representation of the data row, which can be pattern matched with a regex
[ "Create", "a", "simplified", "character", "representation", "of", "the", "data", "row", "which", "can", "be", "pattern", "matched", "with", "a", "regex" ]
train
https://github.com/Metatab/tableintuit/blob/9a3d500d5d90e44e6637dd17ca4c8dae474d6d4c/tableintuit/rows.py#L79-L113
Metatab/tableintuit
tableintuit/rows.py
RowIntuiter.run
def run(self, head_rows, tail_rows=None, n_rows=None): """ Run the intuition process :param head_rows: A list of rows from the start of the file. Should have at least 30 rows :param tail_rows: A list of rows from the end of the file. Optional, but should have at least 30 rows :pa...
python
def run(self, head_rows, tail_rows=None, n_rows=None): """ Run the intuition process :param head_rows: A list of rows from the start of the file. Should have at least 30 rows :param tail_rows: A list of rows from the end of the file. Optional, but should have at least 30 rows :pa...
[ "def", "run", "(", "self", ",", "head_rows", ",", "tail_rows", "=", "None", ",", "n_rows", "=", "None", ")", ":", "from", ".", "exceptions", "import", "RowIntuitError", "header_rows", "=", "[", "]", "found_header", "=", "False", "MIN_SKIP_ROWS", "=", "30",...
Run the intuition process :param head_rows: A list of rows from the start of the file. Should have at least 30 rows :param tail_rows: A list of rows from the end of the file. Optional, but should have at least 30 rows :param n_rows: Total number of rows, if a subset was provided in head_rows ...
[ "Run", "the", "intuition", "process", ":", "param", "head_rows", ":", "A", "list", "of", "rows", "from", "the", "start", "of", "the", "file", ".", "Should", "have", "at", "least", "30", "rows", ":", "param", "tail_rows", ":", "A", "list", "of", "rows",...
train
https://github.com/Metatab/tableintuit/blob/9a3d500d5d90e44e6637dd17ca4c8dae474d6d4c/tableintuit/rows.py#L189-L288
Metatab/tableintuit
tableintuit/rows.py
RowIntuiter.coalesce_headers
def coalesce_headers(cls, header_lines): """Collects headers that are spread across multiple lines into a single row""" header_lines = [list(hl) for hl in header_lines if bool(hl)] if len(header_lines) == 0: return [] if len(header_lines) == 1: return header_li...
python
def coalesce_headers(cls, header_lines): """Collects headers that are spread across multiple lines into a single row""" header_lines = [list(hl) for hl in header_lines if bool(hl)] if len(header_lines) == 0: return [] if len(header_lines) == 1: return header_li...
[ "def", "coalesce_headers", "(", "cls", ",", "header_lines", ")", ":", "header_lines", "=", "[", "list", "(", "hl", ")", "for", "hl", "in", "header_lines", "if", "bool", "(", "hl", ")", "]", "if", "len", "(", "header_lines", ")", "==", "0", ":", "retu...
Collects headers that are spread across multiple lines into a single row
[ "Collects", "headers", "that", "are", "spread", "across", "multiple", "lines", "into", "a", "single", "row" ]
train
https://github.com/Metatab/tableintuit/blob/9a3d500d5d90e44e6637dd17ca4c8dae474d6d4c/tableintuit/rows.py#L291-L318
csaez/wishlib
wishlib/utils.py
map_recursive
def map_recursive(function, iterable): """ Apply function recursively to every item or value of iterable and returns a new iterable object with the results. """ if isiterable(iterable): dataOut = iterable.__class__() for i in iterable: if isinstance(dataOut, dict): ...
python
def map_recursive(function, iterable): """ Apply function recursively to every item or value of iterable and returns a new iterable object with the results. """ if isiterable(iterable): dataOut = iterable.__class__() for i in iterable: if isinstance(dataOut, dict): ...
[ "def", "map_recursive", "(", "function", ",", "iterable", ")", ":", "if", "isiterable", "(", "iterable", ")", ":", "dataOut", "=", "iterable", ".", "__class__", "(", ")", "for", "i", "in", "iterable", ":", "if", "isinstance", "(", "dataOut", ",", "dict",...
Apply function recursively to every item or value of iterable and returns a new iterable object with the results.
[ "Apply", "function", "recursively", "to", "every", "item", "or", "value", "of", "iterable", "and", "returns", "a", "new", "iterable", "object", "with", "the", "results", "." ]
train
https://github.com/csaez/wishlib/blob/c212fa7875006a332a4cefbf69885ced9647bc2f/wishlib/utils.py#L58-L74
zeromake/aiko
aiko/cookies.py
Cookies.get
def get(self, key: Any, default: Any = None) -> Any: """ 获取 cookie 中的 value """ if key in self: return self[key].value return default
python
def get(self, key: Any, default: Any = None) -> Any: """ 获取 cookie 中的 value """ if key in self: return self[key].value return default
[ "def", "get", "(", "self", ",", "key", ":", "Any", ",", "default", ":", "Any", "=", "None", ")", "->", "Any", ":", "if", "key", "in", "self", ":", "return", "self", "[", "key", "]", ".", "value", "return", "default" ]
获取 cookie 中的 value
[ "获取", "cookie", "中的", "value" ]
train
https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/cookies.py#L30-L36
zeromake/aiko
aiko/cookies.py
Cookies.set
def set(self, key: str, value: str, opt: dict = None) -> None: """ 设置 cookie.value 并设置属性 """ self[key] = value if opt is not None: self[key].update(opt)
python
def set(self, key: str, value: str, opt: dict = None) -> None: """ 设置 cookie.value 并设置属性 """ self[key] = value if opt is not None: self[key].update(opt)
[ "def", "set", "(", "self", ",", "key", ":", "str", ",", "value", ":", "str", ",", "opt", ":", "dict", "=", "None", ")", "->", "None", ":", "self", "[", "key", "]", "=", "value", "if", "opt", "is", "not", "None", ":", "self", "[", "key", "]", ...
设置 cookie.value 并设置属性
[ "设置", "cookie", ".", "value", "并设置属性" ]
train
https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/cookies.py#L38-L44
zeromake/aiko
aiko/cookies.py
Cookies.headers
def headers(self) -> Optional[List[str]]: """ 生成 headers """ if len(self) == 0: return None headers = cast(List[str], []) for cookie in self.values(): headers.append(cookie.OutputString()) return headers
python
def headers(self) -> Optional[List[str]]: """ 生成 headers """ if len(self) == 0: return None headers = cast(List[str], []) for cookie in self.values(): headers.append(cookie.OutputString()) return headers
[ "def", "headers", "(", "self", ")", "->", "Optional", "[", "List", "[", "str", "]", "]", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "None", "headers", "=", "cast", "(", "List", "[", "str", "]", ",", "[", "]", ")", "for", "c...
生成 headers
[ "生成", "headers" ]
train
https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/cookies.py#L58-L67
limix/chiscore
chiscore/_liu.py
mod_liu
def mod_liu(q, w): r"""Joint significance of statistics derived from chi2-squared distributions. Parameters ---------- q : float Test statistics. w : array_like Weights of the linear combination. Returns ------- float Estimated p-value. """ q = asarray(...
python
def mod_liu(q, w): r"""Joint significance of statistics derived from chi2-squared distributions. Parameters ---------- q : float Test statistics. w : array_like Weights of the linear combination. Returns ------- float Estimated p-value. """ q = asarray(...
[ "def", "mod_liu", "(", "q", ",", "w", ")", ":", "q", "=", "asarray", "(", "q", ",", "float", ")", "if", "not", "all", "(", "isfinite", "(", "atleast_1d", "(", "q", ")", ")", ")", ":", "raise", "ValueError", "(", "\"There are non-finite values in `q`.\"...
r"""Joint significance of statistics derived from chi2-squared distributions. Parameters ---------- q : float Test statistics. w : array_like Weights of the linear combination. Returns ------- float Estimated p-value.
[ "r", "Joint", "significance", "of", "statistics", "derived", "from", "chi2", "-", "squared", "distributions", "." ]
train
https://github.com/limix/chiscore/blob/c3e774648b8166a5161df86e6bcad34af3cec95c/chiscore/_liu.py#L5-L68
Nekroze/librarian
librarian/deck.py
Deck.get_card
def get_card(self, index=-1, cache=True, remove=True): """ Retrieve a card any number of cards from the top. Returns a ``Card`` object loaded from a library if one is specified otherwise just it will simply return its code. If `index` is not set then the top card will be retrie...
python
def get_card(self, index=-1, cache=True, remove=True): """ Retrieve a card any number of cards from the top. Returns a ``Card`` object loaded from a library if one is specified otherwise just it will simply return its code. If `index` is not set then the top card will be retrie...
[ "def", "get_card", "(", "self", ",", "index", "=", "-", "1", ",", "cache", "=", "True", ",", "remove", "=", "True", ")", ":", "if", "len", "(", "self", ".", "cards", ")", "<", "index", ":", "return", "None", "retriever", "=", "self", ".", "cards"...
Retrieve a card any number of cards from the top. Returns a ``Card`` object loaded from a library if one is specified otherwise just it will simply return its code. If `index` is not set then the top card will be retrieved. If cache is set to True (the default) it will tell the librar...
[ "Retrieve", "a", "card", "any", "number", "of", "cards", "from", "the", "top", ".", "Returns", "a", "Card", "object", "loaded", "from", "a", "library", "if", "one", "is", "specified", "otherwise", "just", "it", "will", "simply", "return", "its", "code", ...
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/deck.py#L22-L45
Nekroze/librarian
librarian/deck.py
Deck.top_cards
def top_cards(self, number=1, cache=True, remove=True): """ Retrieve the top number of cards as ``Librarian.Card`` objects in a list in order of top to bottom most card. Uses the decks ``.get_card`` and passes along the cache and remove arguments. """ getter = partial(sel...
python
def top_cards(self, number=1, cache=True, remove=True): """ Retrieve the top number of cards as ``Librarian.Card`` objects in a list in order of top to bottom most card. Uses the decks ``.get_card`` and passes along the cache and remove arguments. """ getter = partial(sel...
[ "def", "top_cards", "(", "self", ",", "number", "=", "1", ",", "cache", "=", "True", ",", "remove", "=", "True", ")", ":", "getter", "=", "partial", "(", "self", ".", "get_card", "(", "cache", "=", "cache", ",", "remove", "=", "remove", ")", ")", ...
Retrieve the top number of cards as ``Librarian.Card`` objects in a list in order of top to bottom most card. Uses the decks ``.get_card`` and passes along the cache and remove arguments.
[ "Retrieve", "the", "top", "number", "of", "cards", "as", "Librarian", ".", "Card", "objects", "in", "a", "list", "in", "order", "of", "top", "to", "bottom", "most", "card", ".", "Uses", "the", "decks", ".", "get_card", "and", "passes", "along", "the", ...
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/deck.py#L47-L54
Nekroze/librarian
librarian/deck.py
Deck.move_top_cards
def move_top_cards(self, other, number=1): """ Move the top `number` of cards to the top of some `other` deck. By default only one card will be moved if `number` is not specified. """ other.cards.append(reversed(self.cards[-number:]))
python
def move_top_cards(self, other, number=1): """ Move the top `number` of cards to the top of some `other` deck. By default only one card will be moved if `number` is not specified. """ other.cards.append(reversed(self.cards[-number:]))
[ "def", "move_top_cards", "(", "self", ",", "other", ",", "number", "=", "1", ")", ":", "other", ".", "cards", ".", "append", "(", "reversed", "(", "self", ".", "cards", "[", "-", "number", ":", "]", ")", ")" ]
Move the top `number` of cards to the top of some `other` deck. By default only one card will be moved if `number` is not specified.
[ "Move", "the", "top", "number", "of", "cards", "to", "the", "top", "of", "some", "other", "deck", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/deck.py#L56-L62
Nekroze/librarian
librarian/deck.py
Deck.contians_attribute
def contians_attribute(self, attribute): """ Returns how many cards in the deck have the specified attribute. This method requires a library to be stored in the deck instance and will return `None` if there is no library. """ if self.library is None: return 0...
python
def contians_attribute(self, attribute): """ Returns how many cards in the deck have the specified attribute. This method requires a library to be stored in the deck instance and will return `None` if there is no library. """ if self.library is None: return 0...
[ "def", "contians_attribute", "(", "self", ",", "attribute", ")", ":", "if", "self", ".", "library", "is", "None", ":", "return", "0", "load", "=", "self", ".", "library", ".", "load_card", "matches", "=", "0", "for", "code", "in", "self", ".", "cards",...
Returns how many cards in the deck have the specified attribute. This method requires a library to be stored in the deck instance and will return `None` if there is no library.
[ "Returns", "how", "many", "cards", "in", "the", "deck", "have", "the", "specified", "attribute", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/deck.py#L68-L84
Nekroze/librarian
librarian/deck.py
Deck.contains_info
def contains_info(self, key, value): """ Returns how many cards in the deck have the specified value under the specified key in their info data. This method requires a library to be stored in the deck instance and will return `None` if there is no library. """ if...
python
def contains_info(self, key, value): """ Returns how many cards in the deck have the specified value under the specified key in their info data. This method requires a library to be stored in the deck instance and will return `None` if there is no library. """ if...
[ "def", "contains_info", "(", "self", ",", "key", ",", "value", ")", ":", "if", "self", ".", "library", "is", "None", ":", "return", "0", "load", "=", "self", ".", "library", ".", "load_card", "matches", "=", "0", "for", "code", "in", "self", ".", "...
Returns how many cards in the deck have the specified value under the specified key in their info data. This method requires a library to be stored in the deck instance and will return `None` if there is no library.
[ "Returns", "how", "many", "cards", "in", "the", "deck", "have", "the", "specified", "value", "under", "the", "specified", "key", "in", "their", "info", "data", "." ]
train
https://github.com/Nekroze/librarian/blob/5d3da2980d91a637f80ad7164fbf204a2dd2bd58/librarian/deck.py#L86-L103
mgk/thingamon
thingamon/client.py
Client.connect
def connect(self): """Connect to MQTT server and wait for server to acknowledge""" if not self.connect_attempted: self.connect_attempted = True self.client.connect(self.host, port=self.port) self.client.loop_start() while not self.connected: ...
python
def connect(self): """Connect to MQTT server and wait for server to acknowledge""" if not self.connect_attempted: self.connect_attempted = True self.client.connect(self.host, port=self.port) self.client.loop_start() while not self.connected: ...
[ "def", "connect", "(", "self", ")", ":", "if", "not", "self", ".", "connect_attempted", ":", "self", ".", "connect_attempted", "=", "True", "self", ".", "client", ".", "connect", "(", "self", ".", "host", ",", "port", "=", "self", ".", "port", ")", "...
Connect to MQTT server and wait for server to acknowledge
[ "Connect", "to", "MQTT", "server", "and", "wait", "for", "server", "to", "acknowledge" ]
train
https://github.com/mgk/thingamon/blob/3f7d68dc2131c347473af15cd5f7d4b669407c6b/thingamon/client.py#L81-L90
mgk/thingamon
thingamon/client.py
Client.publish
def publish(self, topic, message): """Publish an MQTT message to a topic.""" self.connect() log.info('publish {}'.format(message)) self.client.publish(topic, message)
python
def publish(self, topic, message): """Publish an MQTT message to a topic.""" self.connect() log.info('publish {}'.format(message)) self.client.publish(topic, message)
[ "def", "publish", "(", "self", ",", "topic", ",", "message", ")", ":", "self", ".", "connect", "(", ")", "log", ".", "info", "(", "'publish {}'", ".", "format", "(", "message", ")", ")", "self", ".", "client", ".", "publish", "(", "topic", ",", "me...
Publish an MQTT message to a topic.
[ "Publish", "an", "MQTT", "message", "to", "a", "topic", "." ]
train
https://github.com/mgk/thingamon/blob/3f7d68dc2131c347473af15cd5f7d4b669407c6b/thingamon/client.py#L95-L99
B2W-BIT/asgard-api-sdk
asgard/sdk/options/__init__.py
get_option
def get_option(namespace, option_name): """ Gets an options based on an namespace and an option name. All option are read from Environ variables. The formation name is: HOLLOWMAN_<NAMESPACE>_<OPTIONNAME> If OPTIONNAME is a multi-value (list) option a numver suffix can be used, eg: HOLLOWMAN_...
python
def get_option(namespace, option_name): """ Gets an options based on an namespace and an option name. All option are read from Environ variables. The formation name is: HOLLOWMAN_<NAMESPACE>_<OPTIONNAME> If OPTIONNAME is a multi-value (list) option a numver suffix can be used, eg: HOLLOWMAN_...
[ "def", "get_option", "(", "namespace", ",", "option_name", ")", ":", "envvalue", "=", "_get_env_value", "(", "namespace", ",", "option_name", ")", "idx", "=", "0", "final_value", "=", "[", "]", "if", "envvalue", ":", "final_value", ".", "append", "(", "env...
Gets an options based on an namespace and an option name. All option are read from Environ variables. The formation name is: HOLLOWMAN_<NAMESPACE>_<OPTIONNAME> If OPTIONNAME is a multi-value (list) option a numver suffix can be used, eg: HOLLOWMAN_<NAMESPACE>_<OPTIONNAME>_<INDEX> :name: Name o...
[ "Gets", "an", "options", "based", "on", "an", "namespace", "and", "an", "option", "name", ".", "All", "option", "are", "read", "from", "Environ", "variables", ".", "The", "formation", "name", "is", ":", "HOLLOWMAN_<NAMESPACE", ">", "_<OPTIONNAME", ">", "If",...
train
https://github.com/B2W-BIT/asgard-api-sdk/blob/bf5ea95b8597d70235f6b0bf798fe6f2983aa31c/asgard/sdk/options/__init__.py#L8-L34
webadmin87/midnight
midnight_main/mailer.py
send_templated_mail
def send_templated_mail(tpl, subject, context, to=getattr(settings, 'MIDNIGHT_MAIN_ADMIN_EMAIL', 'admin@example.com')): """ Отправляет письмо на основе шаблона :param tpl: шаблон :param subject: тема письма :param context: контекст для рендеринга шаблона :param to: кому слать письмо :return:...
python
def send_templated_mail(tpl, subject, context, to=getattr(settings, 'MIDNIGHT_MAIN_ADMIN_EMAIL', 'admin@example.com')): """ Отправляет письмо на основе шаблона :param tpl: шаблон :param subject: тема письма :param context: контекст для рендеринга шаблона :param to: кому слать письмо :return:...
[ "def", "send_templated_mail", "(", "tpl", ",", "subject", ",", "context", ",", "to", "=", "getattr", "(", "settings", ",", "'MIDNIGHT_MAIN_ADMIN_EMAIL'", ",", "'admin@example.com'", ")", ")", ":", "msg_html", "=", "render_to_string", "(", "tpl", ",", "{", "'co...
Отправляет письмо на основе шаблона :param tpl: шаблон :param subject: тема письма :param context: контекст для рендеринга шаблона :param to: кому слать письмо :return:
[ "Отправляет", "письмо", "на", "основе", "шаблона", ":", "param", "tpl", ":", "шаблон", ":", "param", "subject", ":", "тема", "письма", ":", "param", "context", ":", "контекст", "для", "рендеринга", "шаблона", ":", "param", "to", ":", "кому", "слать", "пись...
train
https://github.com/webadmin87/midnight/blob/b60b3b257b4d633550b82a692f3ea3756c62a0a9/midnight_main/mailer.py#L6-L17
shi-cong/PYSTUDY
PYSTUDY/api/gpsspg.py
geo
def geo(*params): """ 根据经纬度后去地址 :param params: 经纬度 :return: 地址字符串 """ api = 'http://www.gpsspg.com/apis/maps/geo/' headers = { 'Accept':'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01', 'Accept-Encoding':'gzip, deflate',...
python
def geo(*params): """ 根据经纬度后去地址 :param params: 经纬度 :return: 地址字符串 """ api = 'http://www.gpsspg.com/apis/maps/geo/' headers = { 'Accept':'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01', 'Accept-Encoding':'gzip, deflate',...
[ "def", "geo", "(", "*", "params", ")", ":", "api", "=", "'http://www.gpsspg.com/apis/maps/geo/'", "headers", "=", "{", "'Accept'", ":", "'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01'", ",", "'Accept-Encoding'", ":", "'g...
根据经纬度后去地址 :param params: 经纬度 :return: 地址字符串
[ "根据经纬度后去地址", ":", "param", "params", ":", "经纬度", ":", "return", ":", "地址字符串" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/api/gpsspg.py#L10-L39
JonLiuFYI/pkdx
pkdx/pkdx/scrape_abilities.py
get_abilities
def get_abilities(): """Visit Bulbapedia and pull names and descriptions from the table, 'list of Abilities.' Save as JSON.""" page = requests.get('http://bulbapedia.bulbagarden.net/wiki/Ability') soup = bs4.BeautifulSoup(page.text) table = soup.find("table", {"class": "sortable"}) tablerows = [tr f...
python
def get_abilities(): """Visit Bulbapedia and pull names and descriptions from the table, 'list of Abilities.' Save as JSON.""" page = requests.get('http://bulbapedia.bulbagarden.net/wiki/Ability') soup = bs4.BeautifulSoup(page.text) table = soup.find("table", {"class": "sortable"}) tablerows = [tr f...
[ "def", "get_abilities", "(", ")", ":", "page", "=", "requests", ".", "get", "(", "'http://bulbapedia.bulbagarden.net/wiki/Ability'", ")", "soup", "=", "bs4", ".", "BeautifulSoup", "(", "page", ".", "text", ")", "table", "=", "soup", ".", "find", "(", "\"tabl...
Visit Bulbapedia and pull names and descriptions from the table, 'list of Abilities.' Save as JSON.
[ "Visit", "Bulbapedia", "and", "pull", "names", "and", "descriptions", "from", "the", "table", "list", "of", "Abilities", ".", "Save", "as", "JSON", "." ]
train
https://github.com/JonLiuFYI/pkdx/blob/269e9814df074e0df25972fad04539a644d73a3c/pkdx/pkdx/scrape_abilities.py#L12-L28
openp2pdesign/makerlabs
makerlabs/techshop_ws.py
data_from_techshop_ws
def data_from_techshop_ws(tws_url): """Scrapes data from techshop.ws.""" r = requests.get(tws_url) if r.status_code == 200: data = BeautifulSoup(r.text, "lxml") else: data = "There was an error while accessing data on techshop.ws." return data
python
def data_from_techshop_ws(tws_url): """Scrapes data from techshop.ws.""" r = requests.get(tws_url) if r.status_code == 200: data = BeautifulSoup(r.text, "lxml") else: data = "There was an error while accessing data on techshop.ws." return data
[ "def", "data_from_techshop_ws", "(", "tws_url", ")", ":", "r", "=", "requests", ".", "get", "(", "tws_url", ")", "if", "r", ".", "status_code", "==", "200", ":", "data", "=", "BeautifulSoup", "(", "r", ".", "text", ",", "\"lxml\"", ")", "else", ":", ...
Scrapes data from techshop.ws.
[ "Scrapes", "data", "from", "techshop", ".", "ws", "." ]
train
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/techshop_ws.py#L38-L47
openp2pdesign/makerlabs
makerlabs/techshop_ws.py
get_labs
def get_labs(format): """Gets Techshop data from techshop.ws.""" techshops_soup = data_from_techshop_ws(techshop_us_url) techshops = {} # Load all the TechShops # By first parsing the html data = techshops_soup.findAll('div', attrs={'id': 'main-content'}) for element in data: link...
python
def get_labs(format): """Gets Techshop data from techshop.ws.""" techshops_soup = data_from_techshop_ws(techshop_us_url) techshops = {} # Load all the TechShops # By first parsing the html data = techshops_soup.findAll('div', attrs={'id': 'main-content'}) for element in data: link...
[ "def", "get_labs", "(", "format", ")", ":", "techshops_soup", "=", "data_from_techshop_ws", "(", "techshop_us_url", ")", "techshops", "=", "{", "}", "# Load all the TechShops", "# By first parsing the html", "data", "=", "techshops_soup", ".", "findAll", "(", "'div'",...
Gets Techshop data from techshop.ws.
[ "Gets", "Techshop", "data", "from", "techshop", ".", "ws", "." ]
train
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/techshop_ws.py#L50-L191
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.clients
def clients(self, protocol=None, groups=None): """Returns a list of :py:class:`.Client` for the specific query by the user. Keyword Parameters: protocol Ignored. groups The groups (types) to which the clients belong either from ('Genuine', 'Impostor') Note that 'eval' is an alias fo...
python
def clients(self, protocol=None, groups=None): """Returns a list of :py:class:`.Client` for the specific query by the user. Keyword Parameters: protocol Ignored. groups The groups (types) to which the clients belong either from ('Genuine', 'Impostor') Note that 'eval' is an alias fo...
[ "def", "clients", "(", "self", ",", "protocol", "=", "None", ",", "groups", "=", "None", ")", ":", "groups", "=", "self", ".", "__group_replace_eval_by_genuine__", "(", "groups", ")", "groups", "=", "self", ".", "check_parameters_for_validity", "(", "groups", ...
Returns a list of :py:class:`.Client` for the specific query by the user. Keyword Parameters: protocol Ignored. groups The groups (types) to which the clients belong either from ('Genuine', 'Impostor') Note that 'eval' is an alias for 'Genuine'. If no groups are specified, then bo...
[ "Returns", "a", "list", "of", ":", "py", ":", "class", ":", ".", "Client", "for", "the", "specific", "query", "by", "the", "user", "." ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L68-L91
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.model_ids
def model_ids(self, protocol=None, groups=None): """Returns a list of model ids for the specific query by the user. Models correspond to Clients for the XM2VTS database (At most one model per identity). Keyword Parameters: protocol Ignored. groups The groups to which the subjects a...
python
def model_ids(self, protocol=None, groups=None): """Returns a list of model ids for the specific query by the user. Models correspond to Clients for the XM2VTS database (At most one model per identity). Keyword Parameters: protocol Ignored. groups The groups to which the subjects a...
[ "def", "model_ids", "(", "self", ",", "protocol", "=", "None", ",", "groups", "=", "None", ")", ":", "return", "[", "client", ".", "subid", "for", "client", "in", "self", ".", "models", "(", "protocol", ",", "groups", ")", "]" ]
Returns a list of model ids for the specific query by the user. Models correspond to Clients for the XM2VTS database (At most one model per identity). Keyword Parameters: protocol Ignored. groups The groups to which the subjects attached to the models belong ('dev', 'eval', 'world') ...
[ "Returns", "a", "list", "of", "model", "ids", "for", "the", "specific", "query", "by", "the", "user", ".", "Models", "correspond", "to", "Clients", "for", "the", "XM2VTS", "database", "(", "At", "most", "one", "model", "per", "identity", ")", "." ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L122-L140
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.has_client_id
def has_client_id(self, id): """Returns True if we have a client with a certain integer identifier""" return self.query(Client).filter(Client.id==id).count() != 0
python
def has_client_id(self, id): """Returns True if we have a client with a certain integer identifier""" return self.query(Client).filter(Client.id==id).count() != 0
[ "def", "has_client_id", "(", "self", ",", "id", ")", ":", "return", "self", ".", "query", "(", "Client", ")", ".", "filter", "(", "Client", ".", "id", "==", "id", ")", ".", "count", "(", ")", "!=", "0" ]
Returns True if we have a client with a certain integer identifier
[ "Returns", "True", "if", "we", "have", "a", "client", "with", "a", "certain", "integer", "identifier" ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L142-L145
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.client
def client(self, id): """Returns the client object in the database given a certain id. Raises an error if that does not exist.""" return self.query(Client).filter(Client.id==id).one()
python
def client(self, id): """Returns the client object in the database given a certain id. Raises an error if that does not exist.""" return self.query(Client).filter(Client.id==id).one()
[ "def", "client", "(", "self", ",", "id", ")", ":", "return", "self", ".", "query", "(", "Client", ")", ".", "filter", "(", "Client", ".", "id", "==", "id", ")", ".", "one", "(", ")" ]
Returns the client object in the database given a certain id. Raises an error if that does not exist.
[ "Returns", "the", "client", "object", "in", "the", "database", "given", "a", "certain", "id", ".", "Raises", "an", "error", "if", "that", "does", "not", "exist", "." ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L147-L151
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.objects
def objects(self, protocol=None, purposes=None, model_ids=None, groups=None, classes=None): """Returns a list of :py:class:`.File` for the specific query by the user. Keyword Parameters: protocol One of the Biosecurid protocols ('A'). purposes The purposes required to be ret...
python
def objects(self, protocol=None, purposes=None, model_ids=None, groups=None, classes=None): """Returns a list of :py:class:`.File` for the specific query by the user. Keyword Parameters: protocol One of the Biosecurid protocols ('A'). purposes The purposes required to be ret...
[ "def", "objects", "(", "self", ",", "protocol", "=", "None", ",", "purposes", "=", "None", ",", "model_ids", "=", "None", ",", "groups", "=", "None", ",", "classes", "=", "None", ")", ":", "#groups = self.__group_replace_alias_clients__(groups)", "protocol", "...
Returns a list of :py:class:`.File` for the specific query by the user. Keyword Parameters: protocol One of the Biosecurid protocols ('A'). purposes The purposes required to be retrieved ('enrol', 'probe') or a tuple with several of them. If 'None' is given (this is the default), it is ...
[ "Returns", "a", "list", "of", ":", "py", ":", "class", ":", ".", "File", "for", "the", "specific", "query", "by", "the", "user", "." ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L153-L230
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.protocol_names
def protocol_names(self): """Returns all registered protocol names""" l = self.protocols() retval = [str(k.name) for k in l] return retval
python
def protocol_names(self): """Returns all registered protocol names""" l = self.protocols() retval = [str(k.name) for k in l] return retval
[ "def", "protocol_names", "(", "self", ")", ":", "l", "=", "self", ".", "protocols", "(", ")", "retval", "=", "[", "str", "(", "k", ".", "name", ")", "for", "k", "in", "l", "]", "return", "retval" ]
Returns all registered protocol names
[ "Returns", "all", "registered", "protocol", "names" ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L232-L237
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.has_protocol
def has_protocol(self, name): """Tells if a certain protocol is available""" return self.query(Protocol).filter(Protocol.name==name).count() != 0
python
def has_protocol(self, name): """Tells if a certain protocol is available""" return self.query(Protocol).filter(Protocol.name==name).count() != 0
[ "def", "has_protocol", "(", "self", ",", "name", ")", ":", "return", "self", ".", "query", "(", "Protocol", ")", ".", "filter", "(", "Protocol", ".", "name", "==", "name", ")", ".", "count", "(", ")", "!=", "0" ]
Tells if a certain protocol is available
[ "Tells", "if", "a", "certain", "protocol", "is", "available" ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L244-L247
mgbarrero/xbob.db.atvskeystroke
xbob/db/atvskeystroke/query.py
Database.protocol
def protocol(self, name): """Returns the protocol object in the database given a certain name. Raises an error if that does not exist.""" return self.query(Protocol).filter(Protocol.name==name).one()
python
def protocol(self, name): """Returns the protocol object in the database given a certain name. Raises an error if that does not exist.""" return self.query(Protocol).filter(Protocol.name==name).one()
[ "def", "protocol", "(", "self", ",", "name", ")", ":", "return", "self", ".", "query", "(", "Protocol", ")", ".", "filter", "(", "Protocol", ".", "name", "==", "name", ")", ".", "one", "(", ")" ]
Returns the protocol object in the database given a certain name. Raises an error if that does not exist.
[ "Returns", "the", "protocol", "object", "in", "the", "database", "given", "a", "certain", "name", ".", "Raises", "an", "error", "if", "that", "does", "not", "exist", "." ]
train
https://github.com/mgbarrero/xbob.db.atvskeystroke/blob/b7358a73e21757b43334df7c89ba057b377ca704/xbob/db/atvskeystroke/query.py#L249-L253
JNRowe/jnrbase
jnrbase/i18n.py
setup
def setup(__pkg: ModuleType) -> Tuple[Callable[[str], str], Callable[[str, str, int], str]]: """Configure ``gettext`` for given package. Args: __pkg: Package to use as location for :program:`gettext` files Returns: :program:`gettext` functions for singu...
python
def setup(__pkg: ModuleType) -> Tuple[Callable[[str], str], Callable[[str, str, int], str]]: """Configure ``gettext`` for given package. Args: __pkg: Package to use as location for :program:`gettext` files Returns: :program:`gettext` functions for singu...
[ "def", "setup", "(", "__pkg", ":", "ModuleType", ")", "->", "Tuple", "[", "Callable", "[", "[", "str", "]", ",", "str", "]", ",", "Callable", "[", "[", "str", ",", "str", ",", "int", "]", ",", "str", "]", "]", ":", "package_locale", "=", "path", ...
Configure ``gettext`` for given package. Args: __pkg: Package to use as location for :program:`gettext` files Returns: :program:`gettext` functions for singular and plural translations
[ "Configure", "gettext", "for", "given", "package", "." ]
train
https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/i18n.py#L27-L40
jalanb/pysyte
pysyte/bash/git.py
run
def run(sub_command, quiet=False, no_edit=False, no_verify=False): """Run a git command Prefix that sub_command with "git " then run the command in shell If quiet if True then do not log results If no_edit is True then prefix the git command with "GIT_EDITOR=true" (which does not wait ...
python
def run(sub_command, quiet=False, no_edit=False, no_verify=False): """Run a git command Prefix that sub_command with "git " then run the command in shell If quiet if True then do not log results If no_edit is True then prefix the git command with "GIT_EDITOR=true" (which does not wait ...
[ "def", "run", "(", "sub_command", ",", "quiet", "=", "False", ",", "no_edit", "=", "False", ",", "no_verify", "=", "False", ")", ":", "if", "_working_dirs", "[", "0", "]", "!=", "'.'", ":", "git_command", "=", "'git -C \"%s\"'", "%", "_working_dirs", "["...
Run a git command Prefix that sub_command with "git " then run the command in shell If quiet if True then do not log results If no_edit is True then prefix the git command with "GIT_EDITOR=true" (which does not wait on user's editor) If the command gives a non-zero status, raise a Git...
[ "Run", "a", "git", "command" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L173-L214
jalanb/pysyte
pysyte/bash/git.py
log
def log(args, number=None, oneline=False, quiet=False): """Run a "git log ..." command, and return stdout args is anything which can be added after a normal "git log ..." it can be blank number, if true-ish, will be added as a "-n" option oneline, if true-ish, will add the "--oneline" option ...
python
def log(args, number=None, oneline=False, quiet=False): """Run a "git log ..." command, and return stdout args is anything which can be added after a normal "git log ..." it can be blank number, if true-ish, will be added as a "-n" option oneline, if true-ish, will add the "--oneline" option ...
[ "def", "log", "(", "args", ",", "number", "=", "None", ",", "oneline", "=", "False", ",", "quiet", "=", "False", ")", ":", "options", "=", "' '", ".", "join", "(", "[", "number", "and", "str", "(", "'-n %s'", "%", "number", ")", "or", "''", ",", ...
Run a "git log ..." command, and return stdout args is anything which can be added after a normal "git log ..." it can be blank number, if true-ish, will be added as a "-n" option oneline, if true-ish, will add the "--oneline" option
[ "Run", "a", "git", "log", "...", "command", "and", "return", "stdout" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L217-L232
jalanb/pysyte
pysyte/bash/git.py
branch
def branch(options=False, *args, **kwargs): """Run "$ git branch" with those options If not options then return name of the branch currently checked out """ return (options and run('branch %s' % options, *args, **kwargs) or rev_parse('--abbrev-ref HEAD', *args, **kwargs))
python
def branch(options=False, *args, **kwargs): """Run "$ git branch" with those options If not options then return name of the branch currently checked out """ return (options and run('branch %s' % options, *args, **kwargs) or rev_parse('--abbrev-ref HEAD', *args, **kwargs))
[ "def", "branch", "(", "options", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "(", "options", "and", "run", "(", "'branch %s'", "%", "options", ",", "*", "args", ",", "*", "*", "kwargs", ")", "or", "rev_parse", "(", ...
Run "$ git branch" with those options If not options then return name of the branch currently checked out
[ "Run", "$", "git", "branch", "with", "those", "options" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L248-L255
jalanb/pysyte
pysyte/bash/git.py
branches
def branches(remotes=False): """Return a list of all local branches in the repo If remotes is true then also include remote branches Note: the normal '*' indicator for current branch is removed this method just gives a list of branch names Use branch() method to determine the current branch ...
python
def branches(remotes=False): """Return a list of all local branches in the repo If remotes is true then also include remote branches Note: the normal '*' indicator for current branch is removed this method just gives a list of branch names Use branch() method to determine the current branch ...
[ "def", "branches", "(", "remotes", "=", "False", ")", ":", "stdout", "=", "branch", "(", "'--list %s'", "%", "(", "remotes", "and", "'-a'", "or", "''", ")", ",", "quiet", "=", "True", ")", "return", "[", "_", ".", "lstrip", "(", "'*'", ")", ".", ...
Return a list of all local branches in the repo If remotes is true then also include remote branches Note: the normal '*' indicator for current branch is removed this method just gives a list of branch names Use branch() method to determine the current branch
[ "Return", "a", "list", "of", "all", "local", "branches", "in", "the", "repo" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L258-L268
jalanb/pysyte
pysyte/bash/git.py
branches_containing
def branches_containing(commit): """Return a list of branches conatining that commit""" lines = run('branch --contains %s' % commit).splitlines() return [l.lstrip('* ') for l in lines]
python
def branches_containing(commit): """Return a list of branches conatining that commit""" lines = run('branch --contains %s' % commit).splitlines() return [l.lstrip('* ') for l in lines]
[ "def", "branches_containing", "(", "commit", ")", ":", "lines", "=", "run", "(", "'branch --contains %s'", "%", "commit", ")", ".", "splitlines", "(", ")", "return", "[", "l", ".", "lstrip", "(", "'* '", ")", "for", "l", "in", "lines", "]" ]
Return a list of branches conatining that commit
[ "Return", "a", "list", "of", "branches", "conatining", "that", "commit" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L271-L274
jalanb/pysyte
pysyte/bash/git.py
conflicted
def conflicted(path_to_file): """Whether there are any conflict markers in that file""" for line in open(path_to_file, 'r'): for marker in '>="<': if line.startswith(marker * 8): return True return False
python
def conflicted(path_to_file): """Whether there are any conflict markers in that file""" for line in open(path_to_file, 'r'): for marker in '>="<': if line.startswith(marker * 8): return True return False
[ "def", "conflicted", "(", "path_to_file", ")", ":", "for", "line", "in", "open", "(", "path_to_file", ",", "'r'", ")", ":", "for", "marker", "in", "'>=\"<'", ":", "if", "line", ".", "startswith", "(", "marker", "*", "8", ")", ":", "return", "True", "...
Whether there are any conflict markers in that file
[ "Whether", "there", "are", "any", "conflict", "markers", "in", "that", "file" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L290-L296
jalanb/pysyte
pysyte/bash/git.py
add
def add(path=None, force=False, quiet=False): """Add that path to git's staging area (default current dir) so that it will be included in next commit """ option = '-f' if force else '' return run('add %s %s' % (option, path) or '.', quiet=quiet)
python
def add(path=None, force=False, quiet=False): """Add that path to git's staging area (default current dir) so that it will be included in next commit """ option = '-f' if force else '' return run('add %s %s' % (option, path) or '.', quiet=quiet)
[ "def", "add", "(", "path", "=", "None", ",", "force", "=", "False", ",", "quiet", "=", "False", ")", ":", "option", "=", "'-f'", "if", "force", "else", "''", "return", "run", "(", "'add %s %s'", "%", "(", "option", ",", "path", ")", "or", "'.'", ...
Add that path to git's staging area (default current dir) so that it will be included in next commit
[ "Add", "that", "path", "to", "git", "s", "staging", "area", "(", "default", "current", "dir", ")" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L299-L305
jalanb/pysyte
pysyte/bash/git.py
config
def config(key, value, local=True): """Set that config key to that value Unless local is set to False: only change local config """ option = local and '--local' or '' run('config %s "%s" "%s"' % (option, key, value))
python
def config(key, value, local=True): """Set that config key to that value Unless local is set to False: only change local config """ option = local and '--local' or '' run('config %s "%s" "%s"' % (option, key, value))
[ "def", "config", "(", "key", ",", "value", ",", "local", "=", "True", ")", ":", "option", "=", "local", "and", "'--local'", "or", "''", "run", "(", "'config %s \"%s\" \"%s\"'", "%", "(", "option", ",", "key", ",", "value", ")", ")" ]
Set that config key to that value Unless local is set to False: only change local config
[ "Set", "that", "config", "key", "to", "that", "value" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L330-L336
jalanb/pysyte
pysyte/bash/git.py
clone
def clone(url, path=None, remove=True): """Clone a local repo from that URL to that path If path is not given, then use the git default: same as repo name If path is given and remove is True then the path is removed before cloning Because this is run from a script it is assumed that user shoul...
python
def clone(url, path=None, remove=True): """Clone a local repo from that URL to that path If path is not given, then use the git default: same as repo name If path is given and remove is True then the path is removed before cloning Because this is run from a script it is assumed that user shoul...
[ "def", "clone", "(", "url", ",", "path", "=", "None", ",", "remove", "=", "True", ")", ":", "clean", "=", "True", "if", "path", "and", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "if", "not", "remove", ":", "clean", "=", "False", "e...
Clone a local repo from that URL to that path If path is not given, then use the git default: same as repo name If path is given and remove is True then the path is removed before cloning Because this is run from a script it is assumed that user should be Admin so set config user values fo...
[ "Clone", "a", "local", "repo", "from", "that", "URL", "to", "that", "path" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L347-L374
jalanb/pysyte
pysyte/bash/git.py
needs_abort
def needs_abort(): """A command to abort an operation in progress For example a merge, cherry-pick or rebase If one of these operations has left the repo conflicted then give a command to abandon the operation """ for line in status().splitlines(): if '--abort' in line: ...
python
def needs_abort(): """A command to abort an operation in progress For example a merge, cherry-pick or rebase If one of these operations has left the repo conflicted then give a command to abandon the operation """ for line in status().splitlines(): if '--abort' in line: ...
[ "def", "needs_abort", "(", ")", ":", "for", "line", "in", "status", "(", ")", ".", "splitlines", "(", ")", ":", "if", "'--abort'", "in", "line", ":", "for", "part", "in", "line", ".", "split", "(", "'\"'", ")", ":", "if", "'--abort'", "in", "part",...
A command to abort an operation in progress For example a merge, cherry-pick or rebase If one of these operations has left the repo conflicted then give a command to abandon the operation
[ "A", "command", "to", "abort", "an", "operation", "in", "progress" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L386-L404
jalanb/pysyte
pysyte/bash/git.py
show_branches
def show_branches(branch1, branch2): """Runs git show-branch between the 2 branches, parse result""" def find_column(string): """Find first non space line in the prefix""" result = 0 for c in string: if c == ' ': result += 1 return result def par...
python
def show_branches(branch1, branch2): """Runs git show-branch between the 2 branches, parse result""" def find_column(string): """Find first non space line in the prefix""" result = 0 for c in string: if c == ' ': result += 1 return result def par...
[ "def", "show_branches", "(", "branch1", ",", "branch2", ")", ":", "def", "find_column", "(", "string", ")", ":", "\"\"\"Find first non space line in the prefix\"\"\"", "result", "=", "0", "for", "c", "in", "string", ":", "if", "c", "==", "' '", ":", "result", ...
Runs git show-branch between the 2 branches, parse result
[ "Runs", "git", "show", "-", "branch", "between", "the", "2", "branches", "parse", "result" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L429-L465
jalanb/pysyte
pysyte/bash/git.py
commits_with_message
def commits_with_message(message): """All commits with that message (in current branch)""" output = log("--grep '%s'" % message, oneline=True, quiet=True) lines = output.splitlines() return [l.split(' ', 1)[0] for l in lines]
python
def commits_with_message(message): """All commits with that message (in current branch)""" output = log("--grep '%s'" % message, oneline=True, quiet=True) lines = output.splitlines() return [l.split(' ', 1)[0] for l in lines]
[ "def", "commits_with_message", "(", "message", ")", ":", "output", "=", "log", "(", "\"--grep '%s'\"", "%", "message", ",", "oneline", "=", "True", ",", "quiet", "=", "True", ")", "lines", "=", "output", ".", "splitlines", "(", ")", "return", "[", "l", ...
All commits with that message (in current branch)
[ "All", "commits", "with", "that", "message", "(", "in", "current", "branch", ")" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L494-L498
jalanb/pysyte
pysyte/bash/git.py
checkout
def checkout(branch, quiet=False, as_path=False): """Check out that branch Defaults to a quiet checkout, giving no stdout if stdout it wanted, call with quiet = False Defaults to checking out branches If as_path is true, then treat "branch" like a file, i.e. $ git checkout -- branc...
python
def checkout(branch, quiet=False, as_path=False): """Check out that branch Defaults to a quiet checkout, giving no stdout if stdout it wanted, call with quiet = False Defaults to checking out branches If as_path is true, then treat "branch" like a file, i.e. $ git checkout -- branc...
[ "def", "checkout", "(", "branch", ",", "quiet", "=", "False", ",", "as_path", "=", "False", ")", ":", "try", ":", "if", "as_path", ":", "branch", "=", "'-- %s'", "%", "branch", "run", "(", "'checkout %s %s'", "%", "(", "quiet", "and", "'-q'", "or", "...
Check out that branch Defaults to a quiet checkout, giving no stdout if stdout it wanted, call with quiet = False Defaults to checking out branches If as_path is true, then treat "branch" like a file, i.e. $ git checkout -- branch All errors will pass silently, just returning Fals...
[ "Check", "out", "that", "branch" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L509-L534
jalanb/pysyte
pysyte/bash/git.py
same_diffs
def same_diffs(commit1, commit2): """Whether those 2 commits have the same change Run "git range-diff" against 2 commit ranges: 1. parent of commit1 to commit1 1. parent of commit2 to commit2 If the two produce the same diff then git will only show header lines Header lines are pre...
python
def same_diffs(commit1, commit2): """Whether those 2 commits have the same change Run "git range-diff" against 2 commit ranges: 1. parent of commit1 to commit1 1. parent of commit2 to commit2 If the two produce the same diff then git will only show header lines Header lines are pre...
[ "def", "same_diffs", "(", "commit1", ",", "commit2", ")", ":", "def", "range_one", "(", "commit", ")", ":", "\"\"\"A git commit \"range\" to include only one commit\"\"\"", "return", "'%s^..%s'", "%", "(", "commit", ",", "commit", ")", "output", "=", "run", "(", ...
Whether those 2 commits have the same change Run "git range-diff" against 2 commit ranges: 1. parent of commit1 to commit1 1. parent of commit2 to commit2 If the two produce the same diff then git will only show header lines Header lines are prefixed like "1: ...." Otherwise there ...
[ "Whether", "those", "2", "commits", "have", "the", "same", "change" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L545-L566
jalanb/pysyte
pysyte/bash/git.py
renew_local_branch
def renew_local_branch(branch, start_point, remote=False): """Make a new local branch from that start_point start_point is a git "commit-ish", e.g branch, tag, commit If a local branch already exists it is removed If remote is true then push the new branch to origin """ if branch in branches()...
python
def renew_local_branch(branch, start_point, remote=False): """Make a new local branch from that start_point start_point is a git "commit-ish", e.g branch, tag, commit If a local branch already exists it is removed If remote is true then push the new branch to origin """ if branch in branches()...
[ "def", "renew_local_branch", "(", "branch", ",", "start_point", ",", "remote", "=", "False", ")", ":", "if", "branch", "in", "branches", "(", ")", ":", "checkout", "(", "start_point", ")", "delete", "(", "branch", ",", "force", "=", "True", ",", "remote"...
Make a new local branch from that start_point start_point is a git "commit-ish", e.g branch, tag, commit If a local branch already exists it is removed If remote is true then push the new branch to origin
[ "Make", "a", "new", "local", "branch", "from", "that", "start_point" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L582-L596
jalanb/pysyte
pysyte/bash/git.py
publish
def publish(branch, full_force=False): """Publish that branch, i.e. push it to origin""" checkout(branch) try: push('--force --set-upstream origin', branch) except ExistingReference: if full_force: push('origin --delete', branch) push('--force --set-upstream origi...
python
def publish(branch, full_force=False): """Publish that branch, i.e. push it to origin""" checkout(branch) try: push('--force --set-upstream origin', branch) except ExistingReference: if full_force: push('origin --delete', branch) push('--force --set-upstream origi...
[ "def", "publish", "(", "branch", ",", "full_force", "=", "False", ")", ":", "checkout", "(", "branch", ")", "try", ":", "push", "(", "'--force --set-upstream origin'", ",", "branch", ")", "except", "ExistingReference", ":", "if", "full_force", ":", "push", "...
Publish that branch, i.e. push it to origin
[ "Publish", "that", "branch", "i", ".", "e", ".", "push", "it", "to", "origin" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L615-L623
jalanb/pysyte
pysyte/bash/git.py
commit
def commit(message, add=False, quiet=False): """Commit with that message and return the SHA1 of the commit If add is truish then "$ git add ." first """ if add: run('add .') try: stdout = run('commit -m %r' % str(message), quiet=quiet) except GitError as e: s = str(e) ...
python
def commit(message, add=False, quiet=False): """Commit with that message and return the SHA1 of the commit If add is truish then "$ git add ." first """ if add: run('add .') try: stdout = run('commit -m %r' % str(message), quiet=quiet) except GitError as e: s = str(e) ...
[ "def", "commit", "(", "message", ",", "add", "=", "False", ",", "quiet", "=", "False", ")", ":", "if", "add", ":", "run", "(", "'add .'", ")", "try", ":", "stdout", "=", "run", "(", "'commit -m %r'", "%", "str", "(", "message", ")", ",", "quiet", ...
Commit with that message and return the SHA1 of the commit If add is truish then "$ git add ." first
[ "Commit", "with", "that", "message", "and", "return", "the", "SHA1", "of", "the", "commit" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L646-L660
jalanb/pysyte
pysyte/bash/git.py
pull
def pull(rebase=True, refspec=None): """Pull refspec from remote repository to local If refspec is left as None, then pull current branch The '--rebase' option is used unless rebase is set to false """ options = rebase and '--rebase' or '' output = run('pull %s %s' % (options, refspec or '')) ...
python
def pull(rebase=True, refspec=None): """Pull refspec from remote repository to local If refspec is left as None, then pull current branch The '--rebase' option is used unless rebase is set to false """ options = rebase and '--rebase' or '' output = run('pull %s %s' % (options, refspec or '')) ...
[ "def", "pull", "(", "rebase", "=", "True", ",", "refspec", "=", "None", ")", ":", "options", "=", "rebase", "and", "'--rebase'", "or", "''", "output", "=", "run", "(", "'pull %s %s'", "%", "(", "options", ",", "refspec", "or", "''", ")", ")", "return...
Pull refspec from remote repository to local If refspec is left as None, then pull current branch The '--rebase' option is used unless rebase is set to false
[ "Pull", "refspec", "from", "remote", "repository", "to", "local" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L663-L671
jalanb/pysyte
pysyte/bash/git.py
tag
def tag(name, remote=False, commit=None): """Add a local tag with that name at that commit If no commit is given, at current commit on cuurent branch If remote is true, also push the tag to origin """ command = 'tag %s %s' % (name, commit or '') result = run(command) if remote: push...
python
def tag(name, remote=False, commit=None): """Add a local tag with that name at that commit If no commit is given, at current commit on cuurent branch If remote is true, also push the tag to origin """ command = 'tag %s %s' % (name, commit or '') result = run(command) if remote: push...
[ "def", "tag", "(", "name", ",", "remote", "=", "False", ",", "commit", "=", "None", ")", ":", "command", "=", "'tag %s %s'", "%", "(", "name", ",", "commit", "or", "''", ")", "result", "=", "run", "(", "command", ")", "if", "remote", ":", "push", ...
Add a local tag with that name at that commit If no commit is given, at current commit on cuurent branch If remote is true, also push the tag to origin
[ "Add", "a", "local", "tag", "with", "that", "name", "at", "that", "commit" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L674-L684
jalanb/pysyte
pysyte/bash/git.py
re_tag
def re_tag(name, remote=False, commit=None): """Add a local tag with that name at that commit If no commit is given, at current commit on cuurent branch If remote is true, also push the tag to origin If tag already exists, delete it, then re-make it """ if remote: tags = run('ls-remote...
python
def re_tag(name, remote=False, commit=None): """Add a local tag with that name at that commit If no commit is given, at current commit on cuurent branch If remote is true, also push the tag to origin If tag already exists, delete it, then re-make it """ if remote: tags = run('ls-remote...
[ "def", "re_tag", "(", "name", ",", "remote", "=", "False", ",", "commit", "=", "None", ")", ":", "if", "remote", ":", "tags", "=", "run", "(", "'ls-remote --tags'", ",", "quiet", "=", "True", ")", ".", "splitlines", "(", ")", "if", "name", "in", "t...
Add a local tag with that name at that commit If no commit is given, at current commit on cuurent branch If remote is true, also push the tag to origin If tag already exists, delete it, then re-make it
[ "Add", "a", "local", "tag", "with", "that", "name", "at", "that", "commit" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L702-L716
jalanb/pysyte
pysyte/bash/git.py
merge
def merge(branch, fast_forward=False, commit=True, options=None): """Merge that branch into current branch fast_forward and commit add the eponymous options to the command """ more_options = [ fast_forward and '--ff' or '--no-ff', commit and '--commit' or '--no-commit', ] + (options...
python
def merge(branch, fast_forward=False, commit=True, options=None): """Merge that branch into current branch fast_forward and commit add the eponymous options to the command """ more_options = [ fast_forward and '--ff' or '--no-ff', commit and '--commit' or '--no-commit', ] + (options...
[ "def", "merge", "(", "branch", ",", "fast_forward", "=", "False", ",", "commit", "=", "True", ",", "options", "=", "None", ")", ":", "more_options", "=", "[", "fast_forward", "and", "'--ff'", "or", "'--no-ff'", ",", "commit", "and", "'--commit'", "or", "...
Merge that branch into current branch fast_forward and commit add the eponymous options to the command
[ "Merge", "that", "branch", "into", "current", "branch" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L719-L732
jalanb/pysyte
pysyte/bash/git.py
rebase
def rebase(upstream, branch=None): """Rebase branch onto upstream If branch is empty, use current branch """ rebase_branch = branch and branch or current_branch() with git_continuer(run, 'rebase --continue', no_edit=True): stdout = run('rebase %s %s' % (upstream, rebase_branch)) re...
python
def rebase(upstream, branch=None): """Rebase branch onto upstream If branch is empty, use current branch """ rebase_branch = branch and branch or current_branch() with git_continuer(run, 'rebase --continue', no_edit=True): stdout = run('rebase %s %s' % (upstream, rebase_branch)) re...
[ "def", "rebase", "(", "upstream", ",", "branch", "=", "None", ")", ":", "rebase_branch", "=", "branch", "and", "branch", "or", "current_branch", "(", ")", "with", "git_continuer", "(", "run", ",", "'rebase --continue'", ",", "no_edit", "=", "True", ")", ":...
Rebase branch onto upstream If branch is empty, use current branch
[ "Rebase", "branch", "onto", "upstream" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L762-L771
jalanb/pysyte
pysyte/bash/git.py
merge_resolve
def merge_resolve(branch, fast_forward=False, commit=True, options=None): """Merge that branch into current branch If git raises an error, and the error is for conflicts then read the error message looking for any resolved conflicts Remove the resolved conflicts from the error message If al...
python
def merge_resolve(branch, fast_forward=False, commit=True, options=None): """Merge that branch into current branch If git raises an error, and the error is for conflicts then read the error message looking for any resolved conflicts Remove the resolved conflicts from the error message If al...
[ "def", "merge_resolve", "(", "branch", ",", "fast_forward", "=", "False", ",", "commit", "=", "True", ",", "options", "=", "None", ")", ":", "def", "get_resolution", "(", "resolved", "=", "None", ")", ":", "return", "resolved", "with", "git_continuer", "("...
Merge that branch into current branch If git raises an error, and the error is for conflicts then read the error message looking for any resolved conflicts Remove the resolved conflicts from the error message If all conflicts were resolved then remove the error
[ "Merge", "that", "branch", "into", "current", "branch" ]
train
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/bash/git.py#L774-L790
pydron/twistit
twistit/_errorhandling.py
on_error_close
def on_error_close(logger): """ Decorator for callback methods that implement `IProtocol`. Any uncaught exception is logged and the connection is closed forcefully. Usage:: import logger logger = logging.getLogger(__name__) class MyProtocol(Protocol): ...
python
def on_error_close(logger): """ Decorator for callback methods that implement `IProtocol`. Any uncaught exception is logged and the connection is closed forcefully. Usage:: import logger logger = logging.getLogger(__name__) class MyProtocol(Protocol): ...
[ "def", "on_error_close", "(", "logger", ")", ":", "def", "make_wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "d", "=", "defer",...
Decorator for callback methods that implement `IProtocol`. Any uncaught exception is logged and the connection is closed forcefully. Usage:: import logger logger = logging.getLogger(__name__) class MyProtocol(Protocol): @on_error_close(logger.error) ...
[ "Decorator", "for", "callback", "methods", "that", "implement", "IProtocol", ".", "Any", "uncaught", "exception", "is", "logged", "and", "the", "connection", "is", "closed", "forcefully", ".", "Usage", "::", "import", "logger", "logger", "=", "logging", ".", "...
train
https://github.com/pydron/twistit/blob/23ac43b830083fd32c400fcdfa5300e302769c74/twistit/_errorhandling.py#L7-L65
larsks/thecache
thecache/cache.py
tempfile_writer
def tempfile_writer(target): '''write cache data to a temporary location. when writing is complete, rename the file to the actual location. delete the temporary file on any error''' tmp = target.parent / ('_%s' % target.name) try: with tmp.open('wb') as fd: yield fd except:...
python
def tempfile_writer(target): '''write cache data to a temporary location. when writing is complete, rename the file to the actual location. delete the temporary file on any error''' tmp = target.parent / ('_%s' % target.name) try: with tmp.open('wb') as fd: yield fd except:...
[ "def", "tempfile_writer", "(", "target", ")", ":", "tmp", "=", "target", ".", "parent", "/", "(", "'_%s'", "%", "target", ".", "name", ")", "try", ":", "with", "tmp", ".", "open", "(", "'wb'", ")", "as", "fd", ":", "yield", "fd", "except", ":", "...
write cache data to a temporary location. when writing is complete, rename the file to the actual location. delete the temporary file on any error
[ "write", "cache", "data", "to", "a", "temporary", "location", ".", "when", "writing", "is", "complete", "rename", "the", "file", "to", "the", "actual", "location", ".", "delete", "the", "temporary", "file", "on", "any", "error" ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L46-L58
larsks/thecache
thecache/cache.py
Cache.xform_key
def xform_key(self, key): '''we transform cache keys by taking their sha1 hash so that we don't need to worry about cache keys containing invalid characters''' newkey = hashlib.sha1(key.encode('utf-8')) return newkey.hexdigest()
python
def xform_key(self, key): '''we transform cache keys by taking their sha1 hash so that we don't need to worry about cache keys containing invalid characters''' newkey = hashlib.sha1(key.encode('utf-8')) return newkey.hexdigest()
[ "def", "xform_key", "(", "self", ",", "key", ")", ":", "newkey", "=", "hashlib", ".", "sha1", "(", "key", ".", "encode", "(", "'utf-8'", ")", ")", "return", "newkey", ".", "hexdigest", "(", ")" ]
we transform cache keys by taking their sha1 hash so that we don't need to worry about cache keys containing invalid characters
[ "we", "transform", "cache", "keys", "by", "taking", "their", "sha1", "hash", "so", "that", "we", "don", "t", "need", "to", "worry", "about", "cache", "keys", "containing", "invalid", "characters" ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L104-L110
larsks/thecache
thecache/cache.py
Cache.invalidate
def invalidate(self, key): '''Clear an item from the cache''' path = self.path(self.xform_key(key)) try: LOG.debug('invalidate %s (%s)', key, path) path.unlink() except OSError: pass
python
def invalidate(self, key): '''Clear an item from the cache''' path = self.path(self.xform_key(key)) try: LOG.debug('invalidate %s (%s)', key, path) path.unlink() except OSError: pass
[ "def", "invalidate", "(", "self", ",", "key", ")", ":", "path", "=", "self", ".", "path", "(", "self", ".", "xform_key", "(", "key", ")", ")", "try", ":", "LOG", ".", "debug", "(", "'invalidate %s (%s)'", ",", "key", ",", "path", ")", "path", ".", ...
Clear an item from the cache
[ "Clear", "an", "item", "from", "the", "cache" ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L112-L119
larsks/thecache
thecache/cache.py
Cache.invalidate_all
def invalidate_all(self): '''Clear all items from the cache''' LOG.debug('clearing cache') appcache = str(self.get_app_cache()) for dirpath, dirnames, filenames in os.walk(appcache): for name in filenames: try: pathlib.Path(dirpath, name)....
python
def invalidate_all(self): '''Clear all items from the cache''' LOG.debug('clearing cache') appcache = str(self.get_app_cache()) for dirpath, dirnames, filenames in os.walk(appcache): for name in filenames: try: pathlib.Path(dirpath, name)....
[ "def", "invalidate_all", "(", "self", ")", ":", "LOG", ".", "debug", "(", "'clearing cache'", ")", "appcache", "=", "str", "(", "self", ".", "get_app_cache", "(", ")", ")", "for", "dirpath", ",", "dirnames", ",", "filenames", "in", "os", ".", "walk", "...
Clear all items from the cache
[ "Clear", "all", "items", "from", "the", "cache" ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L121-L131
larsks/thecache
thecache/cache.py
Cache.store_iter
def store_iter(self, key, content): '''stores content in the cache by iterating over content''' cachekey = self.xform_key(key) path = self.path(cachekey) with tempfile_writer(path) as fd: for data in content: LOG.debug('writing chunk of %d bytes for %...
python
def store_iter(self, key, content): '''stores content in the cache by iterating over content''' cachekey = self.xform_key(key) path = self.path(cachekey) with tempfile_writer(path) as fd: for data in content: LOG.debug('writing chunk of %d bytes for %...
[ "def", "store_iter", "(", "self", ",", "key", ",", "content", ")", ":", "cachekey", "=", "self", ".", "xform_key", "(", "key", ")", "path", "=", "self", ".", "path", "(", "cachekey", ")", "with", "tempfile_writer", "(", "path", ")", "as", "fd", ":", ...
stores content in the cache by iterating over content
[ "stores", "content", "in", "the", "cache", "by", "iterating", "over", "content" ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L133-L144
larsks/thecache
thecache/cache.py
Cache.store_lines
def store_lines(self, key, content): '''like store_iter, but appends a newline to each chunk of content''' return self.store_iter( key, (data + '\n'.encode('utf-8') for data in content))
python
def store_lines(self, key, content): '''like store_iter, but appends a newline to each chunk of content''' return self.store_iter( key, (data + '\n'.encode('utf-8') for data in content))
[ "def", "store_lines", "(", "self", ",", "key", ",", "content", ")", ":", "return", "self", ".", "store_iter", "(", "key", ",", "(", "data", "+", "'\\n'", ".", "encode", "(", "'utf-8'", ")", "for", "data", "in", "content", ")", ")" ]
like store_iter, but appends a newline to each chunk of content
[ "like", "store_iter", "but", "appends", "a", "newline", "to", "each", "chunk", "of", "content" ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L146-L151
larsks/thecache
thecache/cache.py
Cache.load_fd
def load_fd(self, key, noexpire=False): '''Look up an item in the cache and return an open file descriptor for the object. It is the caller's responsibility to close the file descriptor.''' cachekey = self.xform_key(key) path = self.path(cachekey) try: stat...
python
def load_fd(self, key, noexpire=False): '''Look up an item in the cache and return an open file descriptor for the object. It is the caller's responsibility to close the file descriptor.''' cachekey = self.xform_key(key) path = self.path(cachekey) try: stat...
[ "def", "load_fd", "(", "self", ",", "key", ",", "noexpire", "=", "False", ")", ":", "cachekey", "=", "self", ".", "xform_key", "(", "key", ")", "path", "=", "self", ".", "path", "(", "cachekey", ")", "try", ":", "stat", "=", "path", ".", "stat", ...
Look up an item in the cache and return an open file descriptor for the object. It is the caller's responsibility to close the file descriptor.
[ "Look", "up", "an", "item", "in", "the", "cache", "and", "return", "an", "open", "file", "descriptor", "for", "the", "object", ".", "It", "is", "the", "caller", "s", "responsibility", "to", "close", "the", "file", "descriptor", "." ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L174-L193
larsks/thecache
thecache/cache.py
Cache.load_lines
def load_lines(self, key, noexpire=None): '''Look up up an item in the cache and return a line iterator. The underlying file will be closed once all lines have been consumed.''' return line_iterator(self.load_fd(key, noexpire=noexpire))
python
def load_lines(self, key, noexpire=None): '''Look up up an item in the cache and return a line iterator. The underlying file will be closed once all lines have been consumed.''' return line_iterator(self.load_fd(key, noexpire=noexpire))
[ "def", "load_lines", "(", "self", ",", "key", ",", "noexpire", "=", "None", ")", ":", "return", "line_iterator", "(", "self", ".", "load_fd", "(", "key", ",", "noexpire", "=", "noexpire", ")", ")" ]
Look up up an item in the cache and return a line iterator. The underlying file will be closed once all lines have been consumed.
[ "Look", "up", "up", "an", "item", "in", "the", "cache", "and", "return", "a", "line", "iterator", ".", "The", "underlying", "file", "will", "be", "closed", "once", "all", "lines", "have", "been", "consumed", "." ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L195-L199
larsks/thecache
thecache/cache.py
Cache.load_iter
def load_iter(self, key, chunksize=None, noexpire=None): '''Lookup an item in the cache and return an iterator that reads chunksize bytes of data at a time. The underlying file will be closed when all data has been read''' return chunk_iterator(self.load_fd(key, noexpire=noexpire), ...
python
def load_iter(self, key, chunksize=None, noexpire=None): '''Lookup an item in the cache and return an iterator that reads chunksize bytes of data at a time. The underlying file will be closed when all data has been read''' return chunk_iterator(self.load_fd(key, noexpire=noexpire), ...
[ "def", "load_iter", "(", "self", ",", "key", ",", "chunksize", "=", "None", ",", "noexpire", "=", "None", ")", ":", "return", "chunk_iterator", "(", "self", ".", "load_fd", "(", "key", ",", "noexpire", "=", "noexpire", ")", ",", "chunksize", "=", "chun...
Lookup an item in the cache and return an iterator that reads chunksize bytes of data at a time. The underlying file will be closed when all data has been read
[ "Lookup", "an", "item", "in", "the", "cache", "and", "return", "an", "iterator", "that", "reads", "chunksize", "bytes", "of", "data", "at", "a", "time", ".", "The", "underlying", "file", "will", "be", "closed", "when", "all", "data", "has", "been", "read...
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L201-L206
larsks/thecache
thecache/cache.py
Cache.load
def load(self, key, noexpire=None): '''Lookup an item in the cache and return the raw content of the file as a string.''' with self.load_fd(key, noexpire=noexpire) as fd: return fd.read()
python
def load(self, key, noexpire=None): '''Lookup an item in the cache and return the raw content of the file as a string.''' with self.load_fd(key, noexpire=noexpire) as fd: return fd.read()
[ "def", "load", "(", "self", ",", "key", ",", "noexpire", "=", "None", ")", ":", "with", "self", ".", "load_fd", "(", "key", ",", "noexpire", "=", "noexpire", ")", "as", "fd", ":", "return", "fd", ".", "read", "(", ")" ]
Lookup an item in the cache and return the raw content of the file as a string.
[ "Lookup", "an", "item", "in", "the", "cache", "and", "return", "the", "raw", "content", "of", "the", "file", "as", "a", "string", "." ]
train
https://github.com/larsks/thecache/blob/e535f91031a7f92f19b5ff6fe2a1a03c7680e9e0/thecache/cache.py#L208-L212
jerith/txTwitter
txtwitter/twitter.py
set_bool_param
def set_bool_param(params, name, value): """ Set a boolean parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param bool value: The value of the parameter. If ``None``, the field will not be set. If ...
python
def set_bool_param(params, name, value): """ Set a boolean parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param bool value: The value of the parameter. If ``None``, the field will not be set. If ...
[ "def", "set_bool_param", "(", "params", ",", "name", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "if", "value", "is", "True", ":", "params", "[", "name", "]", "=", "'true'", "elif", "value", "is", "False", ":", "params", "[", ...
Set a boolean parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param bool value: The value of the parameter. If ``None``, the field will not be set. If ``True`` or ``False``, the relevant field in ``par...
[ "Set", "a", "boolean", "parameter", "if", "applicable", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L34-L58
jerith/txTwitter
txtwitter/twitter.py
set_str_param
def set_str_param(params, name, value): """ Set a string parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param value: The value of the parameter. If ``None``, the field will not be set. If an i...
python
def set_str_param(params, name, value): """ Set a string parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param value: The value of the parameter. If ``None``, the field will not be set. If an i...
[ "def", "set_str_param", "(", "params", ",", "name", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "if", "isinstance", "(", "value", ",", "str", ")", ":", "params", "[", "name", "]", "=", "value", "elif", "isinstance", "(", "valu...
Set a string parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param value: The value of the parameter. If ``None``, the field will not be set. If an instance of ``str``, the relevant field will be set. ...
[ "Set", "a", "string", "parameter", "if", "applicable", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L61-L86
jerith/txTwitter
txtwitter/twitter.py
set_float_param
def set_float_param(params, name, value, min=None, max=None): """ Set a float parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param float value: The value of the parameter. If ``None``, the field will ...
python
def set_float_param(params, name, value, min=None, max=None): """ Set a float parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param float value: The value of the parameter. If ``None``, the field will ...
[ "def", "set_float_param", "(", "params", ",", "name", ",", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "if", "value", "is", "None", ":", "return", "try", ":", "value", "=", "float", "(", "str", "(", "value", ")", ")", "ex...
Set a float parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param float value: The value of the parameter. If ``None``, the field will not be set. If an instance of a numeric type or a string that can ...
[ "Set", "a", "float", "parameter", "if", "applicable", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L89-L129
jerith/txTwitter
txtwitter/twitter.py
set_int_param
def set_int_param(params, name, value, min=None, max=None): """ Set a int parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param int value: The value of the parameter. If ``None``, the field will not be...
python
def set_int_param(params, name, value, min=None, max=None): """ Set a int parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param int value: The value of the parameter. If ``None``, the field will not be...
[ "def", "set_int_param", "(", "params", ",", "name", ",", "value", ",", "min", "=", "None", ",", "max", "=", "None", ")", ":", "if", "value", "is", "None", ":", "return", "try", ":", "value", "=", "int", "(", "str", "(", "value", ")", ")", "except...
Set a int parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param int value: The value of the parameter. If ``None``, the field will not be set. If an instance of a numeric type or a string that can be t...
[ "Set", "a", "int", "parameter", "if", "applicable", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L132-L172
jerith/txTwitter
txtwitter/twitter.py
set_list_param
def set_list_param(params, name, value, min_len=None, max_len=None): """ Set a list parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param list value: The value of the parameter. If ``None``, the field ...
python
def set_list_param(params, name, value, min_len=None, max_len=None): """ Set a list parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param list value: The value of the parameter. If ``None``, the field ...
[ "def", "set_list_param", "(", "params", ",", "name", ",", "value", ",", "min_len", "=", "None", ",", "max_len", "=", "None", ")", ":", "if", "value", "is", "None", ":", "return", "if", "type", "(", "value", ")", "is", "dict", ":", "raise", "ValueErro...
Set a list parameter if applicable. :param dict params: A dict containing API call parameters. :param str name: The name of the parameter to set. :param list value: The value of the parameter. If ``None``, the field will not be set. If an instance of ``set``, ``tuple``, or type that can b...
[ "Set", "a", "list", "parameter", "if", "applicable", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L175-L221
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.statuses_user_timeline
def statuses_user_timeline(self, user_id=None, screen_name=None, since_id=None, count=None, max_id=None, trim_user=None, exclude_replies=None, contributor_details=None, include_rts=None): ...
python
def statuses_user_timeline(self, user_id=None, screen_name=None, since_id=None, count=None, max_id=None, trim_user=None, exclude_replies=None, contributor_details=None, include_rts=None): ...
[ "def", "statuses_user_timeline", "(", "self", ",", "user_id", "=", "None", ",", "screen_name", "=", "None", ",", "since_id", "=", "None", ",", "count", "=", "None", ",", "max_id", "=", "None", ",", "trim_user", "=", "None", ",", "exclude_replies", "=", "...
Returns a list of the most recent tweets posted by the specified user. https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline Either ``user_id`` or ``screen_name`` must be provided. :param str user_id: The ID of the user to return tweets for. :param str screen_na...
[ "Returns", "a", "list", "of", "the", "most", "recent", "tweets", "posted", "by", "the", "specified", "user", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L393-L451
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.statuses_home_timeline
def statuses_home_timeline(self, count=None, since_id=None, max_id=None, trim_user=None, exclude_replies=None, contributor_details=None, include_entities=None): """ Returns a collection of the most recent Tweets...
python
def statuses_home_timeline(self, count=None, since_id=None, max_id=None, trim_user=None, exclude_replies=None, contributor_details=None, include_entities=None): """ Returns a collection of the most recent Tweets...
[ "def", "statuses_home_timeline", "(", "self", ",", "count", "=", "None", ",", "since_id", "=", "None", ",", "max_id", "=", "None", ",", "trim_user", "=", "None", ",", "exclude_replies", "=", "None", ",", "contributor_details", "=", "None", ",", "include_enti...
Returns a collection of the most recent Tweets and retweets posted by the authenticating user and the users they follow. https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline :param int count: Specifies the number of tweets to try and retrieve, up to a maximum ...
[ "Returns", "a", "collection", "of", "the", "most", "recent", "Tweets", "and", "retweets", "posted", "by", "the", "authenticating", "user", "and", "the", "users", "they", "follow", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L453-L501
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.statuses_retweets
def statuses_retweets(self, id, count=None, trim_user=None): """ Returns a list of the most recent retweets of the Tweet specified by the id parameter. https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid :param str id: (*required*) The numerical ID of t...
python
def statuses_retweets(self, id, count=None, trim_user=None): """ Returns a list of the most recent retweets of the Tweet specified by the id parameter. https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid :param str id: (*required*) The numerical ID of t...
[ "def", "statuses_retweets", "(", "self", ",", "id", ",", "count", "=", "None", ",", "trim_user", "=", "None", ")", ":", "params", "=", "{", "'id'", ":", "id", "}", "set_int_param", "(", "params", ",", "'count'", ",", "count", ")", "set_bool_param", "("...
Returns a list of the most recent retweets of the Tweet specified by the id parameter. https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param int count: The maximum number of re...
[ "Returns", "a", "list", "of", "the", "most", "recent", "retweets", "of", "the", "Tweet", "specified", "by", "the", "id", "parameter", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L507-L529
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.statuses_show
def statuses_show(self, id, trim_user=None, include_my_retweet=None, include_entities=None): """ Returns a single Tweet, specified by the id parameter. https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid :param str id: (*required*) The numeric...
python
def statuses_show(self, id, trim_user=None, include_my_retweet=None, include_entities=None): """ Returns a single Tweet, specified by the id parameter. https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid :param str id: (*required*) The numeric...
[ "def", "statuses_show", "(", "self", ",", "id", ",", "trim_user", "=", "None", ",", "include_my_retweet", "=", "None", ",", "include_entities", "=", "None", ")", ":", "params", "=", "{", "'id'", ":", "id", "}", "set_bool_param", "(", "params", ",", "'tri...
Returns a single Tweet, specified by the id parameter. https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param bool trim_user: When set to ``True``, the tweet's user object includes only the...
[ "Returns", "a", "single", "Tweet", "specified", "by", "the", "id", "parameter", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L531-L560
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.statuses_destroy
def statuses_destroy(self, id, trim_user=None): """ Destroys the status specified by the ID parameter. https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param bool trim_user: ...
python
def statuses_destroy(self, id, trim_user=None): """ Destroys the status specified by the ID parameter. https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param bool trim_user: ...
[ "def", "statuses_destroy", "(", "self", ",", "id", ",", "trim_user", "=", "None", ")", ":", "params", "=", "{", "'id'", ":", "id", "}", "set_bool_param", "(", "params", ",", "'trim_user'", ",", "trim_user", ")", "return", "self", ".", "_post_api", "(", ...
Destroys the status specified by the ID parameter. https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param bool trim_user: When set to ``True``, the return value's user object includes o...
[ "Destroys", "the", "status", "specified", "by", "the", "ID", "parameter", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L562-L580
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.statuses_update
def statuses_update(self, status, in_reply_to_status_id=None, lat=None, long=None, place_id=None, display_coordinates=None, trim_user=None, media_ids=None): """ Posts a tweet. https://dev.twitter.com/docs/api/1.1/post/statuses/update :par...
python
def statuses_update(self, status, in_reply_to_status_id=None, lat=None, long=None, place_id=None, display_coordinates=None, trim_user=None, media_ids=None): """ Posts a tweet. https://dev.twitter.com/docs/api/1.1/post/statuses/update :par...
[ "def", "statuses_update", "(", "self", ",", "status", ",", "in_reply_to_status_id", "=", "None", ",", "lat", "=", "None", ",", "long", "=", "None", ",", "place_id", "=", "None", ",", "display_coordinates", "=", "None", ",", "trim_user", "=", "None", ",", ...
Posts a tweet. https://dev.twitter.com/docs/api/1.1/post/statuses/update :param str status: (*required*) The text of your tweet, typically up to 140 characters. URL encode as necessary. t.co link wrapping may affect character counts. There are some spec...
[ "Posts", "a", "tweet", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L582-L650
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.statuses_retweet
def statuses_retweet(self, id, trim_user=None): """ Retweets the status specified by the ID parameter. https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param bool trim_user: ...
python
def statuses_retweet(self, id, trim_user=None): """ Retweets the status specified by the ID parameter. https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param bool trim_user: ...
[ "def", "statuses_retweet", "(", "self", ",", "id", ",", "trim_user", "=", "None", ")", ":", "params", "=", "{", "'id'", ":", "id", "}", "set_bool_param", "(", "params", ",", "'trim_user'", ",", "trim_user", ")", "return", "self", ".", "_post_api", "(", ...
Retweets the status specified by the ID parameter. https://dev.twitter.com/docs/api/1.1/post/statuses/retweet/%3Aid :param str id: (*required*) The numerical ID of the desired tweet. :param bool trim_user: When set to ``True``, the return value's user object includes o...
[ "Retweets", "the", "status", "specified", "by", "the", "ID", "parameter", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L652-L671
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.media_upload
def media_upload(self, media, additional_owners=None): """ Uploads an image to Twitter for later embedding in tweets. https://dev.twitter.com/rest/reference/post/media/upload :param file media: The image file to upload (see the API docs for limitations). :param lis...
python
def media_upload(self, media, additional_owners=None): """ Uploads an image to Twitter for later embedding in tweets. https://dev.twitter.com/rest/reference/post/media/upload :param file media: The image file to upload (see the API docs for limitations). :param lis...
[ "def", "media_upload", "(", "self", ",", "media", ",", "additional_owners", "=", "None", ")", ":", "params", "=", "{", "}", "set_list_param", "(", "params", ",", "'additional_owners'", ",", "additional_owners", ",", "max_len", "=", "100", ")", "return", "sel...
Uploads an image to Twitter for later embedding in tweets. https://dev.twitter.com/rest/reference/post/media/upload :param file media: The image file to upload (see the API docs for limitations). :param list additional_owners: A list of Twitter users that will be able ...
[ "Uploads", "an", "image", "to", "Twitter", "for", "later", "embedding", "in", "tweets", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L673-L693
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.stream_filter
def stream_filter(self, delegate, follow=None, track=None, locations=None, stall_warnings=None): """ Streams public messages filtered by various parameters. https://dev.twitter.com/docs/api/1.1/post/statuses/filter At least one of ``follow``, ``track``, or ``locat...
python
def stream_filter(self, delegate, follow=None, track=None, locations=None, stall_warnings=None): """ Streams public messages filtered by various parameters. https://dev.twitter.com/docs/api/1.1/post/statuses/filter At least one of ``follow``, ``track``, or ``locat...
[ "def", "stream_filter", "(", "self", ",", "delegate", ",", "follow", "=", "None", ",", "track", "=", "None", ",", "locations", "=", "None", ",", "stall_warnings", "=", "None", ")", ":", "params", "=", "{", "}", "if", "follow", "is", "not", "None", ":...
Streams public messages filtered by various parameters. https://dev.twitter.com/docs/api/1.1/post/statuses/filter At least one of ``follow``, ``track``, or ``locations`` must be provided. See the API documentation linked above for details on these parameters and the various limits on t...
[ "Streams", "public", "messages", "filtered", "by", "various", "parameters", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L705-L752
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.userstream_user
def userstream_user(self, delegate, stall_warnings=None, with_='followings', replies=None): """ Streams messages for a single user. https://dev.twitter.com/docs/api/1.1/get/user The ``stringify_friend_ids`` parameter is always set to ``'true'`` for consi...
python
def userstream_user(self, delegate, stall_warnings=None, with_='followings', replies=None): """ Streams messages for a single user. https://dev.twitter.com/docs/api/1.1/get/user The ``stringify_friend_ids`` parameter is always set to ``'true'`` for consi...
[ "def", "userstream_user", "(", "self", ",", "delegate", ",", "stall_warnings", "=", "None", ",", "with_", "=", "'followings'", ",", "replies", "=", "None", ")", ":", "params", "=", "{", "'stringify_friend_ids'", ":", "'true'", "}", "set_bool_param", "(", "pa...
Streams messages for a single user. https://dev.twitter.com/docs/api/1.1/get/user The ``stringify_friend_ids`` parameter is always set to ``'true'`` for consistency with the use of string identifiers elsewhere. :param delegate: A delegate function that will be called for e...
[ "Streams", "messages", "for", "a", "single", "user", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L757-L799
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.direct_messages
def direct_messages(self, since_id=None, max_id=None, count=None, include_entities=None, skip_status=None): """ Gets the 20 most recent direct messages received by the authenticating user. https://dev.twitter.com/docs/api/1.1/get/direct_messages :param s...
python
def direct_messages(self, since_id=None, max_id=None, count=None, include_entities=None, skip_status=None): """ Gets the 20 most recent direct messages received by the authenticating user. https://dev.twitter.com/docs/api/1.1/get/direct_messages :param s...
[ "def", "direct_messages", "(", "self", ",", "since_id", "=", "None", ",", "max_id", "=", "None", ",", "count", "=", "None", ",", "include_entities", "=", "None", ",", "skip_status", "=", "None", ")", ":", "params", "=", "{", "}", "set_str_param", "(", ...
Gets the 20 most recent direct messages received by the authenticating user. https://dev.twitter.com/docs/api/1.1/get/direct_messages :param str since_id: Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the numbe...
[ "Gets", "the", "20", "most", "recent", "direct", "messages", "received", "by", "the", "authenticating", "user", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L803-L844
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.direct_messages_sent
def direct_messages_sent(self, since_id=None, max_id=None, count=None, include_entities=None, page=None): """ Gets the 20 most recent direct messages sent by the authenticating user. https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent :par...
python
def direct_messages_sent(self, since_id=None, max_id=None, count=None, include_entities=None, page=None): """ Gets the 20 most recent direct messages sent by the authenticating user. https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent :par...
[ "def", "direct_messages_sent", "(", "self", ",", "since_id", "=", "None", ",", "max_id", "=", "None", ",", "count", "=", "None", ",", "include_entities", "=", "None", ",", "page", "=", "None", ")", ":", "params", "=", "{", "}", "set_str_param", "(", "p...
Gets the 20 most recent direct messages sent by the authenticating user. https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent :param str since_id: Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the numb...
[ "Gets", "the", "20", "most", "recent", "direct", "messages", "sent", "by", "the", "authenticating", "user", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L846-L884
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.direct_messages_show
def direct_messages_show(self, id): """ Gets the direct message with the given id. https://dev.twitter.com/docs/api/1.1/get/direct_messages/show :param str id: (*required*) The ID of the direct message. :returns: A direct message dict. """ ...
python
def direct_messages_show(self, id): """ Gets the direct message with the given id. https://dev.twitter.com/docs/api/1.1/get/direct_messages/show :param str id: (*required*) The ID of the direct message. :returns: A direct message dict. """ ...
[ "def", "direct_messages_show", "(", "self", ",", "id", ")", ":", "params", "=", "{", "}", "set_str_param", "(", "params", ",", "'id'", ",", "id", ")", "d", "=", "self", ".", "_get_api", "(", "'direct_messages/show.json'", ",", "params", ")", "d", ".", ...
Gets the direct message with the given id. https://dev.twitter.com/docs/api/1.1/get/direct_messages/show :param str id: (*required*) The ID of the direct message. :returns: A direct message dict.
[ "Gets", "the", "direct", "message", "with", "the", "given", "id", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L886-L902
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.direct_messages_destroy
def direct_messages_destroy(self, id, include_entities=None): """ Destroys the direct message with the given id. https://dev.twitter.com/docs/api/1.1/post/direct_messages/destroy :param str id: (*required*) The ID of the direct message. :param bool include_entities:...
python
def direct_messages_destroy(self, id, include_entities=None): """ Destroys the direct message with the given id. https://dev.twitter.com/docs/api/1.1/post/direct_messages/destroy :param str id: (*required*) The ID of the direct message. :param bool include_entities:...
[ "def", "direct_messages_destroy", "(", "self", ",", "id", ",", "include_entities", "=", "None", ")", ":", "params", "=", "{", "}", "set_str_param", "(", "params", ",", "'id'", ",", "id", ")", "set_bool_param", "(", "params", ",", "'include_entities'", ",", ...
Destroys the direct message with the given id. https://dev.twitter.com/docs/api/1.1/post/direct_messages/destroy :param str id: (*required*) The ID of the direct message. :param bool include_entities: The entities node will not be included when set to ``False``. ...
[ "Destroys", "the", "direct", "message", "with", "the", "given", "id", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L904-L921
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.direct_messages_new
def direct_messages_new(self, text, user_id=None, screen_name=None): """ Sends a new direct message to the given user from the authenticating user. https://dev.twitter.com/docs/api/1.1/post/direct_messages/new :param str text: (*required*) The text of your direct me...
python
def direct_messages_new(self, text, user_id=None, screen_name=None): """ Sends a new direct message to the given user from the authenticating user. https://dev.twitter.com/docs/api/1.1/post/direct_messages/new :param str text: (*required*) The text of your direct me...
[ "def", "direct_messages_new", "(", "self", ",", "text", ",", "user_id", "=", "None", ",", "screen_name", "=", "None", ")", ":", "params", "=", "{", "}", "set_str_param", "(", "params", ",", "'text'", ",", "text", ")", "set_str_param", "(", "params", ",",...
Sends a new direct message to the given user from the authenticating user. https://dev.twitter.com/docs/api/1.1/post/direct_messages/new :param str text: (*required*) The text of your direct message. :param str user_id: The ID of the user who should receive the ...
[ "Sends", "a", "new", "direct", "message", "to", "the", "given", "user", "from", "the", "authenticating", "user", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L923-L946
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.friendships_create
def friendships_create(self, user_id=None, screen_name=None, follow=None): """ Allows the authenticating users to follow the specified user. https://dev.twitter.com/docs/api/1.1/post/friendships/create :param str user_id: The screen name of the us...
python
def friendships_create(self, user_id=None, screen_name=None, follow=None): """ Allows the authenticating users to follow the specified user. https://dev.twitter.com/docs/api/1.1/post/friendships/create :param str user_id: The screen name of the us...
[ "def", "friendships_create", "(", "self", ",", "user_id", "=", "None", ",", "screen_name", "=", "None", ",", "follow", "=", "None", ")", ":", "params", "=", "{", "}", "set_str_param", "(", "params", ",", "'user_id'", ",", "user_id", ")", "set_str_param", ...
Allows the authenticating users to follow the specified user. https://dev.twitter.com/docs/api/1.1/post/friendships/create :param str user_id: The screen name of the user for whom to befriend. Required if ``screen_name`` isn't given. :param str screen_name: ...
[ "Allows", "the", "authenticating", "users", "to", "follow", "the", "specified", "user", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L961-L984
jerith/txTwitter
txtwitter/twitter.py
TwitterClient.friendships_destroy
def friendships_destroy(self, user_id=None, screen_name=None): """ Allows the authenticating user to unfollow the specified user. https://dev.twitter.com/docs/api/1.1/post/friendships/destroy :param str user_id: The screen name of the user for whom to unfollow. Required if ...
python
def friendships_destroy(self, user_id=None, screen_name=None): """ Allows the authenticating user to unfollow the specified user. https://dev.twitter.com/docs/api/1.1/post/friendships/destroy :param str user_id: The screen name of the user for whom to unfollow. Required if ...
[ "def", "friendships_destroy", "(", "self", ",", "user_id", "=", "None", ",", "screen_name", "=", "None", ")", ":", "params", "=", "{", "}", "set_str_param", "(", "params", ",", "'user_id'", ",", "user_id", ")", "set_str_param", "(", "params", ",", "'screen...
Allows the authenticating user to unfollow the specified user. https://dev.twitter.com/docs/api/1.1/post/friendships/destroy :param str user_id: The screen name of the user for whom to unfollow. Required if ``screen_name`` isn't given. :param str screen_name: ...
[ "Allows", "the", "authenticating", "user", "to", "unfollow", "the", "specified", "user", "." ]
train
https://github.com/jerith/txTwitter/blob/f07afd21184cd1bee697737bf98fd143378dbdff/txtwitter/twitter.py#L986-L1005
pwyliu/clancy
clancy/redoctober.py
api_call
def api_call(endpoint, args, payload): """ Generic function to call the RO API """ headers = {'content-type': 'application/json; ; charset=utf-8'} url = 'https://{}/{}'.format(args['--server'], endpoint) attempt = 0 resp = None while True: try: attempt += 1 ...
python
def api_call(endpoint, args, payload): """ Generic function to call the RO API """ headers = {'content-type': 'application/json; ; charset=utf-8'} url = 'https://{}/{}'.format(args['--server'], endpoint) attempt = 0 resp = None while True: try: attempt += 1 ...
[ "def", "api_call", "(", "endpoint", ",", "args", ",", "payload", ")", ":", "headers", "=", "{", "'content-type'", ":", "'application/json; ; charset=utf-8'", "}", "url", "=", "'https://{}/{}'", ".", "format", "(", "args", "[", "'--server'", "]", ",", "endpoint...
Generic function to call the RO API
[ "Generic", "function", "to", "call", "the", "RO", "API" ]
train
https://github.com/pwyliu/clancy/blob/cb15a5e2bb735ffce7a84b8413b04faa78c5039c/clancy/redoctober.py#L9-L40
lvh/axiombench
axiombench/update.py
benchmark
def benchmark(store, n=10000): """ Increments an integer count n times. """ x = UpdatableItem(store=store, count=0) for _ in xrange(n): x.count += 1
python
def benchmark(store, n=10000): """ Increments an integer count n times. """ x = UpdatableItem(store=store, count=0) for _ in xrange(n): x.count += 1
[ "def", "benchmark", "(", "store", ",", "n", "=", "10000", ")", ":", "x", "=", "UpdatableItem", "(", "store", "=", "store", ",", "count", "=", "0", ")", "for", "_", "in", "xrange", "(", "n", ")", ":", "x", ".", "count", "+=", "1" ]
Increments an integer count n times.
[ "Increments", "an", "integer", "count", "n", "times", "." ]
train
https://github.com/lvh/axiombench/blob/dd783abfde23b0c67d7a74152d372c4c51e112aa/axiombench/update.py#L8-L14
mayfield/shellish
shellish/layout/progress.py
progressbar
def progressbar(stream, prefix='Loading: ', width=0.5, **options): """ Generator filter to print a progress bar. """ size = len(stream) if not size: return stream if 'width' not in options: if width <= 1: width = round(shutil.get_terminal_size()[0] * width) options['w...
python
def progressbar(stream, prefix='Loading: ', width=0.5, **options): """ Generator filter to print a progress bar. """ size = len(stream) if not size: return stream if 'width' not in options: if width <= 1: width = round(shutil.get_terminal_size()[0] * width) options['w...
[ "def", "progressbar", "(", "stream", ",", "prefix", "=", "'Loading: '", ",", "width", "=", "0.5", ",", "*", "*", "options", ")", ":", "size", "=", "len", "(", "stream", ")", "if", "not", "size", ":", "return", "stream", "if", "'width'", "not", "in", ...
Generator filter to print a progress bar.
[ "Generator", "filter", "to", "print", "a", "progress", "bar", "." ]
train
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/progress.py#L79-L92
inveniosoftware-contrib/record-recommender
record_recommender/utils.py
get_week_dates
def get_week_dates(year, week, as_timestamp=False): """ Get the dates or timestamp of a week in a year. param year: The year. param week: The week. param as_timestamp: Return values as timestamps. returns: The begin and end of the week as datetime.date or as timestamp. """ year = int(ye...
python
def get_week_dates(year, week, as_timestamp=False): """ Get the dates or timestamp of a week in a year. param year: The year. param week: The week. param as_timestamp: Return values as timestamps. returns: The begin and end of the week as datetime.date or as timestamp. """ year = int(ye...
[ "def", "get_week_dates", "(", "year", ",", "week", ",", "as_timestamp", "=", "False", ")", ":", "year", "=", "int", "(", "year", ")", "week", "=", "int", "(", "week", ")", "start_date", "=", "date", "(", "year", ",", "1", ",", "1", ")", "if", "st...
Get the dates or timestamp of a week in a year. param year: The year. param week: The week. param as_timestamp: Return values as timestamps. returns: The begin and end of the week as datetime.date or as timestamp.
[ "Get", "the", "dates", "or", "timestamp", "of", "a", "week", "in", "a", "year", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/utils.py#L33-L57
inveniosoftware-contrib/record-recommender
record_recommender/utils.py
get_year_week
def get_year_week(timestamp): """Get the year and week for a given timestamp.""" time_ = datetime.fromtimestamp(timestamp) year = time_.isocalendar()[0] week = time_.isocalendar()[1] return year, week
python
def get_year_week(timestamp): """Get the year and week for a given timestamp.""" time_ = datetime.fromtimestamp(timestamp) year = time_.isocalendar()[0] week = time_.isocalendar()[1] return year, week
[ "def", "get_year_week", "(", "timestamp", ")", ":", "time_", "=", "datetime", ".", "fromtimestamp", "(", "timestamp", ")", "year", "=", "time_", ".", "isocalendar", "(", ")", "[", "0", "]", "week", "=", "time_", ".", "isocalendar", "(", ")", "[", "1", ...
Get the year and week for a given timestamp.
[ "Get", "the", "year", "and", "week", "for", "a", "given", "timestamp", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/utils.py#L60-L65
inveniosoftware-contrib/record-recommender
record_recommender/utils.py
get_last_weeks
def get_last_weeks(number_of_weeks): """Get the last weeks.""" time_now = datetime.now() year = time_now.isocalendar()[0] week = time_now.isocalendar()[1] weeks = [] for i in range(0, number_of_weeks): start = get_week_dates(year, week - i, as_timestamp=True)[0] n_year, n_week = ...
python
def get_last_weeks(number_of_weeks): """Get the last weeks.""" time_now = datetime.now() year = time_now.isocalendar()[0] week = time_now.isocalendar()[1] weeks = [] for i in range(0, number_of_weeks): start = get_week_dates(year, week - i, as_timestamp=True)[0] n_year, n_week = ...
[ "def", "get_last_weeks", "(", "number_of_weeks", ")", ":", "time_now", "=", "datetime", ".", "now", "(", ")", "year", "=", "time_now", ".", "isocalendar", "(", ")", "[", "0", "]", "week", "=", "time_now", ".", "isocalendar", "(", ")", "[", "1", "]", ...
Get the last weeks.
[ "Get", "the", "last", "weeks", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/utils.py#L68-L79