repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
alefnula/tea
tea/shell/__init__.py
__rmfile
def __rmfile(path): """Delete a file. Args: path (str): Path to the file that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise. """ logger.info("rmfile: %s" % path) try: os.remove(path) return True except Exception as ...
python
def __rmfile(path): """Delete a file. Args: path (str): Path to the file that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise. """ logger.info("rmfile: %s" % path) try: os.remove(path) return True except Exception as ...
[ "def", "__rmfile", "(", "path", ")", ":", "logger", ".", "info", "(", "\"rmfile: %s\"", "%", "path", ")", "try", ":", "os", ".", "remove", "(", "path", ")", "return", "True", "except", "Exception", "as", "e", ":", "logger", ".", "error", "(", "\"rmfi...
Delete a file. Args: path (str): Path to the file that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise.
[ "Delete", "a", "file", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L316-L331
train
alefnula/tea
tea/shell/__init__.py
__rmtree
def __rmtree(path): """Recursively delete a directory tree. Args: path (str): Path to the directory that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise. """ logger.info("rmtree: %s" % path) try: shutil.rmtree(path) retur...
python
def __rmtree(path): """Recursively delete a directory tree. Args: path (str): Path to the directory that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise. """ logger.info("rmtree: %s" % path) try: shutil.rmtree(path) retur...
[ "def", "__rmtree", "(", "path", ")", ":", "logger", ".", "info", "(", "\"rmtree: %s\"", "%", "path", ")", "try", ":", "shutil", ".", "rmtree", "(", "path", ")", "return", "True", "except", "Exception", "as", "e", ":", "logger", ".", "error", "(", "\"...
Recursively delete a directory tree. Args: path (str): Path to the directory that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise.
[ "Recursively", "delete", "a", "directory", "tree", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L334-L349
train
alefnula/tea
tea/shell/__init__.py
remove
def remove(path): """Delete a file or directory. Args: path (str): Path to the file or directory that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise. """ if os.path.isdir(path): return __rmtree(path) else: return __rmfil...
python
def remove(path): """Delete a file or directory. Args: path (str): Path to the file or directory that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise. """ if os.path.isdir(path): return __rmtree(path) else: return __rmfil...
[ "def", "remove", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "return", "__rmtree", "(", "path", ")", "else", ":", "return", "__rmfile", "(", "path", ")" ]
Delete a file or directory. Args: path (str): Path to the file or directory that needs to be deleted. Returns: bool: True if the operation is successful, False otherwise.
[ "Delete", "a", "file", "or", "directory", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L352-L364
train
alefnula/tea
tea/shell/__init__.py
gremove
def gremove(pattern): """Remove all file found by glob.glob(pattern). Args: pattern (str): Pattern of files to remove Returns: bool: True if the operation is successful, False otherwise. """ for item in glob.glob(pattern): if not remove(item): return False re...
python
def gremove(pattern): """Remove all file found by glob.glob(pattern). Args: pattern (str): Pattern of files to remove Returns: bool: True if the operation is successful, False otherwise. """ for item in glob.glob(pattern): if not remove(item): return False re...
[ "def", "gremove", "(", "pattern", ")", ":", "for", "item", "in", "glob", ".", "glob", "(", "pattern", ")", ":", "if", "not", "remove", "(", "item", ")", ":", "return", "False", "return", "True" ]
Remove all file found by glob.glob(pattern). Args: pattern (str): Pattern of files to remove Returns: bool: True if the operation is successful, False otherwise.
[ "Remove", "all", "file", "found", "by", "glob", ".", "glob", "(", "pattern", ")", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L367-L378
train
alefnula/tea
tea/shell/__init__.py
read
def read(path, encoding="utf-8"): """Read the content of the file. Args: path (str): Path to the file encoding (str): File encoding. Default: utf-8 Returns: str: File content or empty string if there was an error """ try: with io.open(path, encoding=encoding) as f: ...
python
def read(path, encoding="utf-8"): """Read the content of the file. Args: path (str): Path to the file encoding (str): File encoding. Default: utf-8 Returns: str: File content or empty string if there was an error """ try: with io.open(path, encoding=encoding) as f: ...
[ "def", "read", "(", "path", ",", "encoding", "=", "\"utf-8\"", ")", ":", "try", ":", "with", "io", ".", "open", "(", "path", ",", "encoding", "=", "encoding", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")", "except", "Exception", "as", ...
Read the content of the file. Args: path (str): Path to the file encoding (str): File encoding. Default: utf-8 Returns: str: File content or empty string if there was an error
[ "Read", "the", "content", "of", "the", "file", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L381-L396
train
alefnula/tea
tea/shell/__init__.py
touch
def touch(path, content="", encoding="utf-8", overwrite=False): """Create a file at the given path if it does not already exists. Args: path (str): Path to the file. content (str): Optional content that will be written in the file. encoding (str): Encoding in which to write the content....
python
def touch(path, content="", encoding="utf-8", overwrite=False): """Create a file at the given path if it does not already exists. Args: path (str): Path to the file. content (str): Optional content that will be written in the file. encoding (str): Encoding in which to write the content....
[ "def", "touch", "(", "path", ",", "content", "=", "\"\"", ",", "encoding", "=", "\"utf-8\"", ",", "overwrite", "=", "False", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "not", "overwrite", "and", "os", ".", "pa...
Create a file at the given path if it does not already exists. Args: path (str): Path to the file. content (str): Optional content that will be written in the file. encoding (str): Encoding in which to write the content. Default: ``utf-8`` overwrite (bool): Overwrite the...
[ "Create", "a", "file", "at", "the", "given", "path", "if", "it", "does", "not", "already", "exists", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L399-L425
train
alefnula/tea
tea/utils/__init__.py
get_object
def get_object(path="", obj=None): """Return an object from a dot path. Path can either be a full path, in which case the `get_object` function will try to import the modules in the path and follow it to the final object. Or it can be a path relative to the object passed in as the second argument. ...
python
def get_object(path="", obj=None): """Return an object from a dot path. Path can either be a full path, in which case the `get_object` function will try to import the modules in the path and follow it to the final object. Or it can be a path relative to the object passed in as the second argument. ...
[ "def", "get_object", "(", "path", "=", "\"\"", ",", "obj", "=", "None", ")", ":", "if", "not", "path", ":", "return", "obj", "path", "=", "path", ".", "split", "(", "\".\"", ")", "if", "obj", "is", "None", ":", "obj", "=", "importlib", ".", "impo...
Return an object from a dot path. Path can either be a full path, in which case the `get_object` function will try to import the modules in the path and follow it to the final object. Or it can be a path relative to the object passed in as the second argument. Args: path (str): Full or rel...
[ "Return", "an", "object", "from", "a", "dot", "path", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/__init__.py#L30-L102
train
alefnula/tea
tea/utils/__init__.py
load_subclasses
def load_subclasses(klass, modules=None): """Load recursively all all subclasses from a module. Args: klass (str or list of str): Class whose subclasses we want to load. modules: List of additional modules or module names that should be recursively imported in order to find all the ...
python
def load_subclasses(klass, modules=None): """Load recursively all all subclasses from a module. Args: klass (str or list of str): Class whose subclasses we want to load. modules: List of additional modules or module names that should be recursively imported in order to find all the ...
[ "def", "load_subclasses", "(", "klass", ",", "modules", "=", "None", ")", ":", "if", "modules", ":", "if", "isinstance", "(", "modules", ",", "six", ".", "string_types", ")", ":", "modules", "=", "[", "modules", "]", "loader", "=", "Loader", "(", ")", ...
Load recursively all all subclasses from a module. Args: klass (str or list of str): Class whose subclasses we want to load. modules: List of additional modules or module names that should be recursively imported in order to find all the subclasses of the desired class. Defa...
[ "Load", "recursively", "all", "all", "subclasses", "from", "a", "module", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/__init__.py#L156-L174
train
alefnula/tea
tea/utils/__init__.py
get_exception
def get_exception(): """Return full formatted traceback as a string.""" trace = "" exception = "" exc_list = traceback.format_exception_only( sys.exc_info()[0], sys.exc_info()[1] ) for entry in exc_list: exception += entry tb_list = traceback.format_tb(sys.exc_info()[2]) ...
python
def get_exception(): """Return full formatted traceback as a string.""" trace = "" exception = "" exc_list = traceback.format_exception_only( sys.exc_info()[0], sys.exc_info()[1] ) for entry in exc_list: exception += entry tb_list = traceback.format_tb(sys.exc_info()[2]) ...
[ "def", "get_exception", "(", ")", ":", "trace", "=", "\"\"", "exception", "=", "\"\"", "exc_list", "=", "traceback", ".", "format_exception_only", "(", "sys", ".", "exc_info", "(", ")", "[", "0", "]", ",", "sys", ".", "exc_info", "(", ")", "[", "1", ...
Return full formatted traceback as a string.
[ "Return", "full", "formatted", "traceback", "as", "a", "string", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/__init__.py#L177-L189
train
alefnula/tea
tea/utils/__init__.py
Loader.load
def load(self, *modules): """Load one or more modules. Args: modules: Either a string full path to a module or an actual module object. """ for module in modules: if isinstance(module, six.string_types): try: mo...
python
def load(self, *modules): """Load one or more modules. Args: modules: Either a string full path to a module or an actual module object. """ for module in modules: if isinstance(module, six.string_types): try: mo...
[ "def", "load", "(", "self", ",", "*", "modules", ")", ":", "for", "module", "in", "modules", ":", "if", "isinstance", "(", "module", ",", "six", ".", "string_types", ")", ":", "try", ":", "module", "=", "get_object", "(", "module", ")", "except", "Ex...
Load one or more modules. Args: modules: Either a string full path to a module or an actual module object.
[ "Load", "one", "or", "more", "modules", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/__init__.py#L129-L153
train
cgtobi/PyRMVtransport
RMVtransport/rmvtransport.py
_product_filter
def _product_filter(products) -> str: """Calculate the product filter.""" _filter = 0 for product in {PRODUCTS[p] for p in products}: _filter += product return format(_filter, "b")[::-1]
python
def _product_filter(products) -> str: """Calculate the product filter.""" _filter = 0 for product in {PRODUCTS[p] for p in products}: _filter += product return format(_filter, "b")[::-1]
[ "def", "_product_filter", "(", "products", ")", "->", "str", ":", "_filter", "=", "0", "for", "product", "in", "{", "PRODUCTS", "[", "p", "]", "for", "p", "in", "products", "}", ":", "_filter", "+=", "product", "return", "format", "(", "_filter", ",", ...
Calculate the product filter.
[ "Calculate", "the", "product", "filter", "." ]
20a0d68ecfdedceb32e8ca96c381fdec7e2069c7
https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvtransport.py#L172-L177
train
cgtobi/PyRMVtransport
RMVtransport/rmvtransport.py
_base_url
def _base_url() -> str: """Build base url.""" _lang: str = "d" _type: str = "n" _with_suggestions: str = "?" return BASE_URI + STBOARD_PATH + _lang + _type + _with_suggestions
python
def _base_url() -> str: """Build base url.""" _lang: str = "d" _type: str = "n" _with_suggestions: str = "?" return BASE_URI + STBOARD_PATH + _lang + _type + _with_suggestions
[ "def", "_base_url", "(", ")", "->", "str", ":", "_lang", ":", "str", "=", "\"d\"", "_type", ":", "str", "=", "\"n\"", "_with_suggestions", ":", "str", "=", "\"?\"", "return", "BASE_URI", "+", "STBOARD_PATH", "+", "_lang", "+", "_type", "+", "_with_sugges...
Build base url.
[ "Build", "base", "url", "." ]
20a0d68ecfdedceb32e8ca96c381fdec7e2069c7
https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvtransport.py#L180-L185
train
cgtobi/PyRMVtransport
RMVtransport/rmvtransport.py
RMVtransport.get_departures
async def get_departures( self, station_id: str, direction_id: Optional[str] = None, max_journeys: int = 20, products: Optional[List[str]] = None, ) -> Dict[str, Any]: """Fetch data from rmv.de.""" self.station_id: str = station_id self.direction_id: s...
python
async def get_departures( self, station_id: str, direction_id: Optional[str] = None, max_journeys: int = 20, products: Optional[List[str]] = None, ) -> Dict[str, Any]: """Fetch data from rmv.de.""" self.station_id: str = station_id self.direction_id: s...
[ "async", "def", "get_departures", "(", "self", ",", "station_id", ":", "str", ",", "direction_id", ":", "Optional", "[", "str", "]", "=", "None", ",", "max_journeys", ":", "int", "=", "20", ",", "products", ":", "Optional", "[", "List", "[", "str", "]"...
Fetch data from rmv.de.
[ "Fetch", "data", "from", "rmv", ".", "de", "." ]
20a0d68ecfdedceb32e8ca96c381fdec7e2069c7
https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvtransport.py#L44-L111
train
cgtobi/PyRMVtransport
RMVtransport/rmvtransport.py
RMVtransport.data
def data(self) -> Dict[str, Any]: """Return travel data.""" data: Dict[str, Any] = {} data["station"] = self.station data["stationId"] = self.station_id data["filter"] = self.products_filter journeys = [] for j in sorted(self.journeys, key=lambda k: k.real_depart...
python
def data(self) -> Dict[str, Any]: """Return travel data.""" data: Dict[str, Any] = {} data["station"] = self.station data["stationId"] = self.station_id data["filter"] = self.products_filter journeys = [] for j in sorted(self.journeys, key=lambda k: k.real_depart...
[ "def", "data", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "data", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "data", "[", "\"station\"", "]", "=", "self", ".", "station", "data", "[", "\"stationId\"", "]", "...
Return travel data.
[ "Return", "travel", "data", "." ]
20a0d68ecfdedceb32e8ca96c381fdec7e2069c7
https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvtransport.py#L113-L140
train
cgtobi/PyRMVtransport
RMVtransport/rmvtransport.py
RMVtransport._station
def _station(self) -> str: """Extract station name.""" return str(self.obj.SBRes.SBReq.Start.Station.HafasName.Text.pyval)
python
def _station(self) -> str: """Extract station name.""" return str(self.obj.SBRes.SBReq.Start.Station.HafasName.Text.pyval)
[ "def", "_station", "(", "self", ")", "->", "str", ":", "return", "str", "(", "self", ".", "obj", ".", "SBRes", ".", "SBReq", ".", "Start", ".", "Station", ".", "HafasName", ".", "Text", ".", "pyval", ")" ]
Extract station name.
[ "Extract", "station", "name", "." ]
20a0d68ecfdedceb32e8ca96c381fdec7e2069c7
https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvtransport.py#L142-L144
train
cgtobi/PyRMVtransport
RMVtransport/rmvtransport.py
RMVtransport.current_time
def current_time(self) -> datetime: """Extract current time.""" _date = datetime.strptime(self.obj.SBRes.SBReq.StartT.get("date"), "%Y%m%d") _time = datetime.strptime(self.obj.SBRes.SBReq.StartT.get("time"), "%H:%M") return datetime.combine(_date.date(), _time.time())
python
def current_time(self) -> datetime: """Extract current time.""" _date = datetime.strptime(self.obj.SBRes.SBReq.StartT.get("date"), "%Y%m%d") _time = datetime.strptime(self.obj.SBRes.SBReq.StartT.get("time"), "%H:%M") return datetime.combine(_date.date(), _time.time())
[ "def", "current_time", "(", "self", ")", "->", "datetime", ":", "_date", "=", "datetime", ".", "strptime", "(", "self", ".", "obj", ".", "SBRes", ".", "SBReq", ".", "StartT", ".", "get", "(", "\"date\"", ")", ",", "\"%Y%m%d\"", ")", "_time", "=", "da...
Extract current time.
[ "Extract", "current", "time", "." ]
20a0d68ecfdedceb32e8ca96c381fdec7e2069c7
https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvtransport.py#L146-L150
train
cgtobi/PyRMVtransport
RMVtransport/rmvtransport.py
RMVtransport.output
def output(self) -> None: """Pretty print travel times.""" print("%s - %s" % (self.station, self.now)) print(self.products_filter) for j in sorted(self.journeys, key=lambda k: k.real_departure)[ : self.max_journeys ]: print("-------------") pr...
python
def output(self) -> None: """Pretty print travel times.""" print("%s - %s" % (self.station, self.now)) print(self.products_filter) for j in sorted(self.journeys, key=lambda k: k.real_departure)[ : self.max_journeys ]: print("-------------") pr...
[ "def", "output", "(", "self", ")", "->", "None", ":", "print", "(", "\"%s - %s\"", "%", "(", "self", ".", "station", ",", "self", ".", "now", ")", ")", "print", "(", "self", ".", "products_filter", ")", "for", "j", "in", "sorted", "(", "self", ".",...
Pretty print travel times.
[ "Pretty", "print", "travel", "times", "." ]
20a0d68ecfdedceb32e8ca96c381fdec7e2069c7
https://github.com/cgtobi/PyRMVtransport/blob/20a0d68ecfdedceb32e8ca96c381fdec7e2069c7/RMVtransport/rmvtransport.py#L152-L169
train
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/mpt_redis_parser.py
MPTRedisParser.get
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ :param variable_path: a delimiter-separated path to a nested value :para...
python
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ :param variable_path: a delimiter-separated path to a nested value :para...
[ "def", "get", "(", "self", ",", "variable_path", ":", "str", ",", "default", ":", "t", ".", "Optional", "[", "t", ".", "Any", "]", "=", "None", ",", "coerce_type", ":", "t", ".", "Optional", "[", "t", ".", "Type", "]", "=", "None", ",", "coercer"...
:param variable_path: a delimiter-separated path to a nested value :param default: default value if there's no object by specified path :param coerce_type: cast a type of a value to a specified one :param coercer: perform a type casting with specified callback :param kwargs: additional a...
[ ":", "param", "variable_path", ":", "a", "delimiter", "-", "separated", "path", "to", "a", "nested", "value", ":", "param", "default", ":", "default", "value", "if", "there", "s", "no", "object", "by", "specified", "path", ":", "param", "coerce_type", ":",...
b64f8009101a8eb61d3841124ba19e3ab881aa2f
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/mpt_redis_parser.py#L75-L112
train
letuananh/chirptext
chirptext/chio.py
process_file
def process_file(path, processor, encoding='utf-8', mode='rt', *args, **kwargs): ''' Process a text file's content. If the file name ends with .gz, read it as gzip file ''' if mode not in ('rU', 'rt', 'rb', 'r'): raise Exception("Invalid file reading mode") with open(path, encoding=encoding, mode=mo...
python
def process_file(path, processor, encoding='utf-8', mode='rt', *args, **kwargs): ''' Process a text file's content. If the file name ends with .gz, read it as gzip file ''' if mode not in ('rU', 'rt', 'rb', 'r'): raise Exception("Invalid file reading mode") with open(path, encoding=encoding, mode=mo...
[ "def", "process_file", "(", "path", ",", "processor", ",", "encoding", "=", "'utf-8'", ",", "mode", "=", "'rt'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "mode", "not", "in", "(", "'rU'", ",", "'rt'", ",", "'rb'", ",", "'r'", ")...
Process a text file's content. If the file name ends with .gz, read it as gzip file
[ "Process", "a", "text", "file", "s", "content", ".", "If", "the", "file", "name", "ends", "with", ".", "gz", "read", "it", "as", "gzip", "file" ]
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L75-L80
train
letuananh/chirptext
chirptext/chio.py
read_file
def read_file(path, encoding='utf-8', *args, **kwargs): ''' Read text file content. If the file name ends with .gz, read it as gzip file. If mode argument is provided as 'rb', content will be read as byte stream. By default, content is read as string. ''' if 'mode' in kwargs and kwargs['mode'] == 'r...
python
def read_file(path, encoding='utf-8', *args, **kwargs): ''' Read text file content. If the file name ends with .gz, read it as gzip file. If mode argument is provided as 'rb', content will be read as byte stream. By default, content is read as string. ''' if 'mode' in kwargs and kwargs['mode'] == 'r...
[ "def", "read_file", "(", "path", ",", "encoding", "=", "'utf-8'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'mode'", "in", "kwargs", "and", "kwargs", "[", "'mode'", "]", "==", "'rb'", ":", "return", "process_file", "(", "path", ",",...
Read text file content. If the file name ends with .gz, read it as gzip file. If mode argument is provided as 'rb', content will be read as byte stream. By default, content is read as string.
[ "Read", "text", "file", "content", ".", "If", "the", "file", "name", "ends", "with", ".", "gz", "read", "it", "as", "gzip", "file", ".", "If", "mode", "argument", "is", "provided", "as", "rb", "content", "will", "be", "read", "as", "byte", "stream", ...
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L83-L93
train
letuananh/chirptext
chirptext/chio.py
write_file
def write_file(path, content, mode=None, encoding='utf-8'): ''' Write content to a file. If the path ends with .gz, gzip will be used. ''' if not mode: if isinstance(content, bytes): mode = 'wb' else: mode = 'wt' if not path: raise ValueError("Output path is i...
python
def write_file(path, content, mode=None, encoding='utf-8'): ''' Write content to a file. If the path ends with .gz, gzip will be used. ''' if not mode: if isinstance(content, bytes): mode = 'wb' else: mode = 'wt' if not path: raise ValueError("Output path is i...
[ "def", "write_file", "(", "path", ",", "content", ",", "mode", "=", "None", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "not", "mode", ":", "if", "isinstance", "(", "content", ",", "bytes", ")", ":", "mode", "=", "'wb'", "else", ":", "mode", "...
Write content to a file. If the path ends with .gz, gzip will be used.
[ "Write", "content", "to", "a", "file", ".", "If", "the", "path", "ends", "with", ".", "gz", "gzip", "will", "be", "used", "." ]
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L96-L121
train
letuananh/chirptext
chirptext/chio.py
iter_csv_stream
def iter_csv_stream(input_stream, fieldnames=None, sniff=False, *args, **kwargs): ''' Read CSV content as a table (list of lists) from an input stream ''' if 'dialect' not in kwargs and sniff: kwargs['dialect'] = csv.Sniffer().sniff(input_stream.read(1024)) input_stream.seek(0) if 'quoting' ...
python
def iter_csv_stream(input_stream, fieldnames=None, sniff=False, *args, **kwargs): ''' Read CSV content as a table (list of lists) from an input stream ''' if 'dialect' not in kwargs and sniff: kwargs['dialect'] = csv.Sniffer().sniff(input_stream.read(1024)) input_stream.seek(0) if 'quoting' ...
[ "def", "iter_csv_stream", "(", "input_stream", ",", "fieldnames", "=", "None", ",", "sniff", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'dialect'", "not", "in", "kwargs", "and", "sniff", ":", "kwargs", "[", "'dialect'", "...
Read CSV content as a table (list of lists) from an input stream
[ "Read", "CSV", "content", "as", "a", "table", "(", "list", "of", "lists", ")", "from", "an", "input", "stream" ]
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L124-L142
train
letuananh/chirptext
chirptext/chio.py
read_csv_iter
def read_csv_iter(path, fieldnames=None, sniff=True, mode='rt', encoding='utf-8', *args, **kwargs): ''' Iterate through CSV rows in a file. By default, csv.reader() will be used any output will be a list of lists. If fieldnames is provided, DictReader will be used and output will be list of OrderedDict inst...
python
def read_csv_iter(path, fieldnames=None, sniff=True, mode='rt', encoding='utf-8', *args, **kwargs): ''' Iterate through CSV rows in a file. By default, csv.reader() will be used any output will be a list of lists. If fieldnames is provided, DictReader will be used and output will be list of OrderedDict inst...
[ "def", "read_csv_iter", "(", "path", ",", "fieldnames", "=", "None", ",", "sniff", "=", "True", ",", "mode", "=", "'rt'", ",", "encoding", "=", "'utf-8'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "open", "(", "path", ",", "mode"...
Iterate through CSV rows in a file. By default, csv.reader() will be used any output will be a list of lists. If fieldnames is provided, DictReader will be used and output will be list of OrderedDict instead. CSV sniffing (dialect detection) is enabled by default, set sniff=False to switch it off.
[ "Iterate", "through", "CSV", "rows", "in", "a", "file", ".", "By", "default", "csv", ".", "reader", "()", "will", "be", "used", "any", "output", "will", "be", "a", "list", "of", "lists", ".", "If", "fieldnames", "is", "provided", "DictReader", "will", ...
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L149-L157
train
letuananh/chirptext
chirptext/chio.py
read_csv
def read_csv(path, fieldnames=None, sniff=True, encoding='utf-8', *args, **kwargs): ''' Read CSV rows as table from a file. By default, csv.reader() will be used any output will be a list of lists. If fieldnames is provided, DictReader will be used and output will be list of OrderedDict instead. CSV sni...
python
def read_csv(path, fieldnames=None, sniff=True, encoding='utf-8', *args, **kwargs): ''' Read CSV rows as table from a file. By default, csv.reader() will be used any output will be a list of lists. If fieldnames is provided, DictReader will be used and output will be list of OrderedDict instead. CSV sni...
[ "def", "read_csv", "(", "path", ",", "fieldnames", "=", "None", ",", "sniff", "=", "True", ",", "encoding", "=", "'utf-8'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "list", "(", "r", "for", "r", "in", "read_csv_iter", "(", "pa...
Read CSV rows as table from a file. By default, csv.reader() will be used any output will be a list of lists. If fieldnames is provided, DictReader will be used and output will be list of OrderedDict instead. CSV sniffing (dialect detection) is enabled by default, set sniff=False to switch it off.
[ "Read", "CSV", "rows", "as", "table", "from", "a", "file", ".", "By", "default", "csv", ".", "reader", "()", "will", "be", "used", "any", "output", "will", "be", "a", "list", "of", "lists", ".", "If", "fieldnames", "is", "provided", "DictReader", "will...
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L164-L170
train
letuananh/chirptext
chirptext/chio.py
write_csv
def write_csv(path, rows, dialect='excel', fieldnames=None, quoting=csv.QUOTE_ALL, extrasaction='ignore', *args, **kwargs): ''' Write rows data to a CSV file (with or without fieldnames) ''' if not quoting: quoting = csv.QUOTE_MINIMAL if 'lineterminator' not in kwargs: kw...
python
def write_csv(path, rows, dialect='excel', fieldnames=None, quoting=csv.QUOTE_ALL, extrasaction='ignore', *args, **kwargs): ''' Write rows data to a CSV file (with or without fieldnames) ''' if not quoting: quoting = csv.QUOTE_MINIMAL if 'lineterminator' not in kwargs: kw...
[ "def", "write_csv", "(", "path", ",", "rows", ",", "dialect", "=", "'excel'", ",", "fieldnames", "=", "None", ",", "quoting", "=", "csv", ".", "QUOTE_ALL", ",", "extrasaction", "=", "'ignore'", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if...
Write rows data to a CSV file (with or without fieldnames)
[ "Write", "rows", "data", "to", "a", "CSV", "file", "(", "with", "or", "without", "fieldnames", ")" ]
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L177-L192
train
letuananh/chirptext
chirptext/chio.py
CSV.write
def write(file_name, rows, header=None, *args, **kwargs): ''' Write rows data to a CSV file (with or without header) ''' warnings.warn("chirptext.io.CSV is deprecated and will be removed in near future.", DeprecationWarning) write_csv(file_name, rows, fieldnames=header, *args, **kwargs)
python
def write(file_name, rows, header=None, *args, **kwargs): ''' Write rows data to a CSV file (with or without header) ''' warnings.warn("chirptext.io.CSV is deprecated and will be removed in near future.", DeprecationWarning) write_csv(file_name, rows, fieldnames=header, *args, **kwargs)
[ "def", "write", "(", "file_name", ",", "rows", ",", "header", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "\"chirptext.io.CSV is deprecated and will be removed in near future.\"", ",", "DeprecationWarning", ")", ...
Write rows data to a CSV file (with or without header)
[ "Write", "rows", "data", "to", "a", "CSV", "file", "(", "with", "or", "without", "header", ")" ]
ce60b47257b272a587c8703ea1f86cd1a45553a7
https://github.com/letuananh/chirptext/blob/ce60b47257b272a587c8703ea1f86cd1a45553a7/chirptext/chio.py#L216-L219
train
alefnula/tea
tea/msg/mail.py
make_msgid
def make_msgid(idstring=None, utc=False): """Return a string suitable for RFC 2822 compliant Message-ID. E.g: <20020201195627.33539.96671@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id. """ if utc: timesta...
python
def make_msgid(idstring=None, utc=False): """Return a string suitable for RFC 2822 compliant Message-ID. E.g: <20020201195627.33539.96671@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id. """ if utc: timesta...
[ "def", "make_msgid", "(", "idstring", "=", "None", ",", "utc", "=", "False", ")", ":", "if", "utc", ":", "timestamp", "=", "time", ".", "gmtime", "(", ")", "else", ":", "timestamp", "=", "time", ".", "localtime", "(", ")", "utcdate", "=", "time", "...
Return a string suitable for RFC 2822 compliant Message-ID. E.g: <20020201195627.33539.96671@nightshade.la.mastaler.com> Optional idstring if given is a string used to strengthen the uniqueness of the message id.
[ "Return", "a", "string", "suitable", "for", "RFC", "2822", "compliant", "Message", "-", "ID", ".", "E", ".", "g", ":", "<20020201195627", ".", "33539", ".", "96671" ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L75-L100
train
alefnula/tea
tea/msg/mail.py
forbid_multi_line_headers
def forbid_multi_line_headers(name, val): """Forbid multi-line headers, to prevent header injection.""" val = smart_text(val) if "\n" in val or "\r" in val: raise BadHeaderError( "Header values can't contain newlines " "(got %r for header %r)" % (val, name) ) ...
python
def forbid_multi_line_headers(name, val): """Forbid multi-line headers, to prevent header injection.""" val = smart_text(val) if "\n" in val or "\r" in val: raise BadHeaderError( "Header values can't contain newlines " "(got %r for header %r)" % (val, name) ) ...
[ "def", "forbid_multi_line_headers", "(", "name", ",", "val", ")", ":", "val", "=", "smart_text", "(", "val", ")", "if", "\"\\n\"", "in", "val", "or", "\"\\r\"", "in", "val", ":", "raise", "BadHeaderError", "(", "\"Header values can't contain newlines \"", "\"(go...
Forbid multi-line headers, to prevent header injection.
[ "Forbid", "multi", "-", "line", "headers", "to", "prevent", "header", "injection", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L107-L130
train
alefnula/tea
tea/msg/mail.py
send_mail
def send_mail( subject, sender, to, message, html_message=None, cc=None, bcc=None, attachments=None, host=None, port=None, auth_user=None, auth_password=None, use_tls=False, fail_silently=False, ): """Send a single email to a recipient list. ...
python
def send_mail( subject, sender, to, message, html_message=None, cc=None, bcc=None, attachments=None, host=None, port=None, auth_user=None, auth_password=None, use_tls=False, fail_silently=False, ): """Send a single email to a recipient list. ...
[ "def", "send_mail", "(", "subject", ",", "sender", ",", "to", ",", "message", ",", "html_message", "=", "None", ",", "cc", "=", "None", ",", "bcc", "=", "None", ",", "attachments", "=", "None", ",", "host", "=", "None", ",", "port", "=", "None", ",...
Send a single email to a recipient list. All members of the recipient list will see the other recipients in the 'To' field. Note: The API for this method is frozen. New code wanting to extend the functionality should use the EmailMessage class directly.
[ "Send", "a", "single", "email", "to", "a", "recipient", "list", ".", "All", "members", "of", "the", "recipient", "list", "will", "see", "the", "other", "recipients", "in", "the", "To", "field", ".", "Note", ":", "The", "API", "for", "this", "method", "...
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L432-L494
train
alefnula/tea
tea/msg/mail.py
send_mass_mail
def send_mass_mail( datatuple, fail_silently=False, auth_user=None, auth_password=None ): """Send multiple emails to multiple recipients. Given a datatuple of (subject, message, sender, recipient_list), sends each message to each recipient list. Returns the number of e-mails sent. If auth_...
python
def send_mass_mail( datatuple, fail_silently=False, auth_user=None, auth_password=None ): """Send multiple emails to multiple recipients. Given a datatuple of (subject, message, sender, recipient_list), sends each message to each recipient list. Returns the number of e-mails sent. If auth_...
[ "def", "send_mass_mail", "(", "datatuple", ",", "fail_silently", "=", "False", ",", "auth_user", "=", "None", ",", "auth_password", "=", "None", ")", ":", "connection", "=", "SMTPConnection", "(", "username", "=", "auth_user", ",", "password", "=", "auth_passw...
Send multiple emails to multiple recipients. Given a datatuple of (subject, message, sender, recipient_list), sends each message to each recipient list. Returns the number of e-mails sent. If auth_user and auth_password are set, they're used to log in. Note: The API for this method is frozen. ...
[ "Send", "multiple", "emails", "to", "multiple", "recipients", ".", "Given", "a", "datatuple", "of", "(", "subject", "message", "sender", "recipient_list", ")", "sends", "each", "message", "to", "each", "recipient", "list", ".", "Returns", "the", "number", "of"...
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L497-L517
train
alefnula/tea
tea/msg/mail.py
SMTPConnection.open
def open(self): """Ensure we have a connection to the email server. Returns whether or not a new connection was required (True or False). """ if self.connection: # Nothing to do if the connection is already open. return False try: # I...
python
def open(self): """Ensure we have a connection to the email server. Returns whether or not a new connection was required (True or False). """ if self.connection: # Nothing to do if the connection is already open. return False try: # I...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "connection", ":", "# Nothing to do if the connection is already open.\r", "return", "False", "try", ":", "# If local_hostname is not specified, socket.getfqdn() gets used.\r", "# For performance, we use the cached FQDN for l...
Ensure we have a connection to the email server. Returns whether or not a new connection was required (True or False).
[ "Ensure", "we", "have", "a", "connection", "to", "the", "email", "server", ".", "Returns", "whether", "or", "not", "a", "new", "connection", "was", "required", "(", "True", "or", "False", ")", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L165-L194
train
alefnula/tea
tea/msg/mail.py
SMTPConnection.close
def close(self): """Close the connection to the email server.""" try: try: self.connection.quit() except socket.sslerror: # This happens when calling quit() on a TLS connection # sometimes. self.connection.cl...
python
def close(self): """Close the connection to the email server.""" try: try: self.connection.quit() except socket.sslerror: # This happens when calling quit() on a TLS connection # sometimes. self.connection.cl...
[ "def", "close", "(", "self", ")", ":", "try", ":", "try", ":", "self", ".", "connection", ".", "quit", "(", ")", "except", "socket", ".", "sslerror", ":", "# This happens when calling quit() on a TLS connection\r", "# sometimes.\r", "self", ".", "connection", "....
Close the connection to the email server.
[ "Close", "the", "connection", "to", "the", "email", "server", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L196-L216
train
alefnula/tea
tea/msg/mail.py
SMTPConnection.send_messages
def send_messages(self, messages): """Send one or more EmailMessage objects. Returns: int: Number of email messages sent. """ if not messages: return new_conn_created = self.open() if not self.connection: # We failed silentl...
python
def send_messages(self, messages): """Send one or more EmailMessage objects. Returns: int: Number of email messages sent. """ if not messages: return new_conn_created = self.open() if not self.connection: # We failed silentl...
[ "def", "send_messages", "(", "self", ",", "messages", ")", ":", "if", "not", "messages", ":", "return", "new_conn_created", "=", "self", ".", "open", "(", ")", "if", "not", "self", ".", "connection", ":", "# We failed silently on open(). Trying to send would be po...
Send one or more EmailMessage objects. Returns: int: Number of email messages sent.
[ "Send", "one", "or", "more", "EmailMessage", "objects", ".", "Returns", ":", "int", ":", "Number", "of", "email", "messages", "sent", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L218-L237
train
alefnula/tea
tea/msg/mail.py
SMTPConnection._send
def _send(self, message): """Send an email. Helper method that does the actual sending. """ if not message.recipients(): return False try: self.connection.sendmail( message.sender, message.recipients(), ...
python
def _send(self, message): """Send an email. Helper method that does the actual sending. """ if not message.recipients(): return False try: self.connection.sendmail( message.sender, message.recipients(), ...
[ "def", "_send", "(", "self", ",", "message", ")", ":", "if", "not", "message", ".", "recipients", "(", ")", ":", "return", "False", "try", ":", "self", ".", "connection", ".", "sendmail", "(", "message", ".", "sender", ",", "message", ".", "recipients"...
Send an email. Helper method that does the actual sending.
[ "Send", "an", "email", ".", "Helper", "method", "that", "does", "the", "actual", "sending", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L239-L262
train
alefnula/tea
tea/msg/mail.py
EmailMessage.attach
def attach(self, filename=None, content=None, mimetype=None): """Attache a file with the given filename and content. The filename can be omitted (useful for multipart/alternative messages) and the mimetype is guessed, if not provided. If the first parameter is a MIMEBase subclass...
python
def attach(self, filename=None, content=None, mimetype=None): """Attache a file with the given filename and content. The filename can be omitted (useful for multipart/alternative messages) and the mimetype is guessed, if not provided. If the first parameter is a MIMEBase subclass...
[ "def", "attach", "(", "self", ",", "filename", "=", "None", ",", "content", "=", "None", ",", "mimetype", "=", "None", ")", ":", "if", "isinstance", "(", "filename", ",", "MIMEBase", ")", ":", "assert", "content", "is", "None", "and", "mimetype", "is",...
Attache a file with the given filename and content. The filename can be omitted (useful for multipart/alternative messages) and the mimetype is guessed, if not provided. If the first parameter is a MIMEBase subclass it is inserted directly into the resulting message attachments.
[ "Attache", "a", "file", "with", "the", "given", "filename", "and", "content", ".", "The", "filename", "can", "be", "omitted", "(", "useful", "for", "multipart", "/", "alternative", "messages", ")", "and", "the", "mimetype", "is", "guessed", "if", "not", "p...
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L370-L386
train
alefnula/tea
tea/msg/mail.py
EmailMessage.attach_file
def attach_file(self, path, mimetype=None): """Attache a file from the filesystem.""" filename = os.path.basename(path) content = open(path, "rb").read() self.attach(filename, content, mimetype)
python
def attach_file(self, path, mimetype=None): """Attache a file from the filesystem.""" filename = os.path.basename(path) content = open(path, "rb").read() self.attach(filename, content, mimetype)
[ "def", "attach_file", "(", "self", ",", "path", ",", "mimetype", "=", "None", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "path", ")", "content", "=", "open", "(", "path", ",", "\"rb\"", ")", ".", "read", "(", ")", "self", ...
Attache a file from the filesystem.
[ "Attache", "a", "file", "from", "the", "filesystem", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L388-L392
train
alefnula/tea
tea/msg/mail.py
EmailMessage._create_attachment
def _create_attachment(self, filename, content, mimetype=None): """Convert the filename, content, mimetype triple to attachment.""" if mimetype is None: mimetype, _ = mimetypes.guess_type(filename) if mimetype is None: mimetype = DEFAULT_ATTACHMENT_MIME_TYPE ...
python
def _create_attachment(self, filename, content, mimetype=None): """Convert the filename, content, mimetype triple to attachment.""" if mimetype is None: mimetype, _ = mimetypes.guess_type(filename) if mimetype is None: mimetype = DEFAULT_ATTACHMENT_MIME_TYPE ...
[ "def", "_create_attachment", "(", "self", ",", "filename", ",", "content", ",", "mimetype", "=", "None", ")", ":", "if", "mimetype", "is", "None", ":", "mimetype", ",", "_", "=", "mimetypes", ".", "guess_type", "(", "filename", ")", "if", "mimetype", "is...
Convert the filename, content, mimetype triple to attachment.
[ "Convert", "the", "filename", "content", "mimetype", "triple", "to", "attachment", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L394-L414
train
alefnula/tea
tea/msg/mail.py
EmailMultiAlternatives.attach_alternative
def attach_alternative(self, content, mimetype=None): """Attach an alternative content representation.""" self.attach(content=content, mimetype=mimetype)
python
def attach_alternative(self, content, mimetype=None): """Attach an alternative content representation.""" self.attach(content=content, mimetype=mimetype)
[ "def", "attach_alternative", "(", "self", ",", "content", ",", "mimetype", "=", "None", ")", ":", "self", ".", "attach", "(", "content", "=", "content", ",", "mimetype", "=", "mimetype", ")" ]
Attach an alternative content representation.
[ "Attach", "an", "alternative", "content", "representation", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/msg/mail.py#L427-L429
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
setup_logging
def setup_logging(verbose=False, logger=None): """Setup console logging. Info and below go to stdout, others go to stderr. :param bool verbose: Print debug statements. :param str logger: Which logger to set handlers to. Used for testing. """ if not verbose: logging.getLogger('requests').set...
python
def setup_logging(verbose=False, logger=None): """Setup console logging. Info and below go to stdout, others go to stderr. :param bool verbose: Print debug statements. :param str logger: Which logger to set handlers to. Used for testing. """ if not verbose: logging.getLogger('requests').set...
[ "def", "setup_logging", "(", "verbose", "=", "False", ",", "logger", "=", "None", ")", ":", "if", "not", "verbose", ":", "logging", ".", "getLogger", "(", "'requests'", ")", ".", "setLevel", "(", "logging", ".", "WARNING", ")", "format_", "=", "'%(asctim...
Setup console logging. Info and below go to stdout, others go to stderr. :param bool verbose: Print debug statements. :param str logger: Which logger to set handlers to. Used for testing.
[ "Setup", "console", "logging", ".", "Info", "and", "below", "go", "to", "stdout", "others", "go", "to", "stderr", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L92-L116
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
with_log
def with_log(func): """Automatically adds a named logger to a function upon function call. :param func: Function to decorate. :return: Decorated function. :rtype: function """ @functools.wraps(func) def wrapper(*args, **kwargs): """Inject `log` argument into wrapped function. ...
python
def with_log(func): """Automatically adds a named logger to a function upon function call. :param func: Function to decorate. :return: Decorated function. :rtype: function """ @functools.wraps(func) def wrapper(*args, **kwargs): """Inject `log` argument into wrapped function. ...
[ "def", "with_log", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Inject `log` argument into wrapped function.\n\n :param list args: Pass through all positio...
Automatically adds a named logger to a function upon function call. :param func: Function to decorate. :return: Decorated function. :rtype: function
[ "Automatically", "adds", "a", "named", "logger", "to", "a", "function", "upon", "function", "call", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L119-L142
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
get_arguments
def get_arguments(argv=None, environ=None): """Get command line arguments or values from environment variables. :param list argv: Command line argument list to process. For testing. :param dict environ: Environment variables. For testing. :return: Parsed options. :rtype: dict """ name = 'a...
python
def get_arguments(argv=None, environ=None): """Get command line arguments or values from environment variables. :param list argv: Command line argument list to process. For testing. :param dict environ: Environment variables. For testing. :return: Parsed options. :rtype: dict """ name = 'a...
[ "def", "get_arguments", "(", "argv", "=", "None", ",", "environ", "=", "None", ")", ":", "name", "=", "'appveyor-artifacts'", "environ", "=", "environ", "or", "os", ".", "environ", "require", "=", "getattr", "(", "pkg_resources", ",", "'require'", ")", "# ...
Get command line arguments or values from environment variables. :param list argv: Command line argument list to process. For testing. :param dict environ: Environment variables. For testing. :return: Parsed options. :rtype: dict
[ "Get", "command", "line", "arguments", "or", "values", "from", "environment", "variables", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L145-L198
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
query_api
def query_api(endpoint, log): """Query the AppVeyor API. :raise HandledError: On non HTTP200 responses or invalid JSON response. :param str endpoint: API endpoint to query (e.g. '/projects/Robpol86/appveyor-artifacts'). :param logging.Logger log: Logger for this function. Populated by with_log() decor...
python
def query_api(endpoint, log): """Query the AppVeyor API. :raise HandledError: On non HTTP200 responses or invalid JSON response. :param str endpoint: API endpoint to query (e.g. '/projects/Robpol86/appveyor-artifacts'). :param logging.Logger log: Logger for this function. Populated by with_log() decor...
[ "def", "query_api", "(", "endpoint", ",", "log", ")", ":", "url", "=", "API_PREFIX", "+", "endpoint", "headers", "=", "{", "'content-type'", ":", "'application/json'", "}", "response", "=", "None", "log", ".", "debug", "(", "'Querying %s with headers %s.'", ",...
Query the AppVeyor API. :raise HandledError: On non HTTP200 responses or invalid JSON response. :param str endpoint: API endpoint to query (e.g. '/projects/Robpol86/appveyor-artifacts'). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: Parsed JSON respo...
[ "Query", "the", "AppVeyor", "API", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L202-L250
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
validate
def validate(config, log): """Validate config values. :raise HandledError: On invalid config values. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. """ if config['always_job_dirs'] and config['no_job_...
python
def validate(config, log): """Validate config values. :raise HandledError: On invalid config values. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. """ if config['always_job_dirs'] and config['no_job_...
[ "def", "validate", "(", "config", ",", "log", ")", ":", "if", "config", "[", "'always_job_dirs'", "]", "and", "config", "[", "'no_job_dirs'", "]", ":", "log", ".", "error", "(", "'Contradiction: --always-job-dirs and --no-job-dirs used.'", ")", "raise", "HandledEr...
Validate config values. :raise HandledError: On invalid config values. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator.
[ "Validate", "config", "values", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L254-L285
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
query_build_version
def query_build_version(config, log): """Find the build version we're looking for. AppVeyor calls build IDs "versions" which is confusing but whatever. Job IDs aren't available in the history query, only on latest, specific version, and deployment queries. Hence we need two queries to get a one-time status...
python
def query_build_version(config, log): """Find the build version we're looking for. AppVeyor calls build IDs "versions" which is confusing but whatever. Job IDs aren't available in the history query, only on latest, specific version, and deployment queries. Hence we need two queries to get a one-time status...
[ "def", "query_build_version", "(", "config", ",", "log", ")", ":", "url", "=", "'/projects/{0}/{1}/history?recordsNumber=10'", ".", "format", "(", "config", "[", "'owner'", "]", ",", "config", "[", "'repo'", "]", ")", "# Query history.", "log", ".", "debug", "...
Find the build version we're looking for. AppVeyor calls build IDs "versions" which is confusing but whatever. Job IDs aren't available in the history query, only on latest, specific version, and deployment queries. Hence we need two queries to get a one-time status update. Returns None if the job isn't q...
[ "Find", "the", "build", "version", "we", "re", "looking", "for", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L289-L326
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
query_job_ids
def query_job_ids(build_version, config, log): """Get one or more job IDs and their status associated with a build version. Filters jobs by name if --job-name is specified. :raise HandledError: On invalid JSON data or bad job name. :param str build_version: AppVeyor build version from query_build_ver...
python
def query_job_ids(build_version, config, log): """Get one or more job IDs and their status associated with a build version. Filters jobs by name if --job-name is specified. :raise HandledError: On invalid JSON data or bad job name. :param str build_version: AppVeyor build version from query_build_ver...
[ "def", "query_job_ids", "(", "build_version", ",", "config", ",", "log", ")", ":", "url", "=", "'/projects/{0}/{1}/build/{2}'", ".", "format", "(", "config", "[", "'owner'", "]", ",", "config", "[", "'repo'", "]", ",", "build_version", ")", "# Query version.",...
Get one or more job IDs and their status associated with a build version. Filters jobs by name if --job-name is specified. :raise HandledError: On invalid JSON data or bad job name. :param str build_version: AppVeyor build version from query_build_version(). :param dict config: Dictionary from get_ar...
[ "Get", "one", "or", "more", "job", "IDs", "and", "their", "status", "associated", "with", "a", "build", "version", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L330-L366
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
query_artifacts
def query_artifacts(job_ids, log): """Query API again for artifacts. :param iter job_ids: List of AppVeyor jobIDs. :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: List of tuples: (job ID, artifact file name, artifact file size). :rtype: list """...
python
def query_artifacts(job_ids, log): """Query API again for artifacts. :param iter job_ids: List of AppVeyor jobIDs. :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: List of tuples: (job ID, artifact file name, artifact file size). :rtype: list """...
[ "def", "query_artifacts", "(", "job_ids", ",", "log", ")", ":", "jobs_artifacts", "=", "list", "(", ")", "for", "job", "in", "job_ids", ":", "url", "=", "'/buildjobs/{0}/artifacts'", ".", "format", "(", "job", ")", "log", ".", "debug", "(", "'Querying AppV...
Query API again for artifacts. :param iter job_ids: List of AppVeyor jobIDs. :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: List of tuples: (job ID, artifact file name, artifact file size). :rtype: list
[ "Query", "API", "again", "for", "artifacts", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L370-L386
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
artifacts_urls
def artifacts_urls(config, jobs_artifacts, log): """Determine destination file paths for job artifacts. :param dict config: Dictionary from get_arguments(). :param iter jobs_artifacts: List of job artifacts from query_artifacts(). :param logging.Logger log: Logger for this function. Populated by with_l...
python
def artifacts_urls(config, jobs_artifacts, log): """Determine destination file paths for job artifacts. :param dict config: Dictionary from get_arguments(). :param iter jobs_artifacts: List of job artifacts from query_artifacts(). :param logging.Logger log: Logger for this function. Populated by with_l...
[ "def", "artifacts_urls", "(", "config", ",", "jobs_artifacts", ",", "log", ")", ":", "artifacts", "=", "dict", "(", ")", "# Determine if we should create job ID directories.", "if", "config", "[", "'always_job_dirs'", "]", ":", "job_dirs", "=", "True", "elif", "co...
Determine destination file paths for job artifacts. :param dict config: Dictionary from get_arguments(). :param iter jobs_artifacts: List of job artifacts from query_artifacts(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: Destination file paths (ke...
[ "Determine", "destination", "file", "paths", "for", "job", "artifacts", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L390-L440
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
get_urls
def get_urls(config, log): """Wait for AppVeyor job to finish and get all artifacts' URLs. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: Paths and URLs from artifacts_urls. :rtype: dict """ ...
python
def get_urls(config, log): """Wait for AppVeyor job to finish and get all artifacts' URLs. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: Paths and URLs from artifacts_urls. :rtype: dict """ ...
[ "def", "get_urls", "(", "config", ",", "log", ")", ":", "# Wait for job to be queued. Once it is we'll have the \"version\".", "build_version", "=", "None", "for", "_", "in", "range", "(", "3", ")", ":", "build_version", "=", "query_build_version", "(", "config", ")...
Wait for AppVeyor job to finish and get all artifacts' URLs. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. :return: Paths and URLs from artifacts_urls. :rtype: dict
[ "Wait", "for", "AppVeyor", "job", "to", "finish", "and", "get", "all", "artifacts", "URLs", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L444-L491
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
download_file
def download_file(config, local_path, url, expected_size, chunk_size, log): """Download a file. :param dict config: Dictionary from get_arguments(). :param str local_path: Destination path to save file to. :param str url: URL of the file to download. :param int expected_size: Expected file size in ...
python
def download_file(config, local_path, url, expected_size, chunk_size, log): """Download a file. :param dict config: Dictionary from get_arguments(). :param str local_path: Destination path to save file to. :param str url: URL of the file to download. :param int expected_size: Expected file size in ...
[ "def", "download_file", "(", "config", ",", "local_path", ",", "url", ",", "expected_size", ",", "chunk_size", ",", "log", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "dirname", "(", "local_path", ")", ")", "...
Download a file. :param dict config: Dictionary from get_arguments(). :param str local_path: Destination path to save file to. :param str url: URL of the file to download. :param int expected_size: Expected file size in bytes. :param int chunk_size: Number of bytes to read in memory before writing ...
[ "Download", "a", "file", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L495-L526
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
mangle_coverage
def mangle_coverage(local_path, log): """Edit .coverage file substituting Windows file paths to Linux paths. :param str local_path: Destination path to save file to. :param logging.Logger log: Logger for this function. Populated by with_log() decorator. """ # Read the file, or return if not a .cove...
python
def mangle_coverage(local_path, log): """Edit .coverage file substituting Windows file paths to Linux paths. :param str local_path: Destination path to save file to. :param logging.Logger log: Logger for this function. Populated by with_log() decorator. """ # Read the file, or return if not a .cove...
[ "def", "mangle_coverage", "(", "local_path", ",", "log", ")", ":", "# Read the file, or return if not a .coverage file.", "with", "open", "(", "local_path", ",", "mode", "=", "'rb'", ")", "as", "handle", ":", "if", "handle", ".", "read", "(", "13", ")", "!=", ...
Edit .coverage file substituting Windows file paths to Linux paths. :param str local_path: Destination path to save file to. :param logging.Logger log: Logger for this function. Populated by with_log() decorator.
[ "Edit", ".", "coverage", "file", "substituting", "Windows", "file", "paths", "to", "Linux", "paths", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L530-L559
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
main
def main(config, log): """Main function. Runs the program. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. """ validate(config) paths_and_urls = get_urls(config) if not paths_and_urls: log.w...
python
def main(config, log): """Main function. Runs the program. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator. """ validate(config) paths_and_urls = get_urls(config) if not paths_and_urls: log.w...
[ "def", "main", "(", "config", ",", "log", ")", ":", "validate", "(", "config", ")", "paths_and_urls", "=", "get_urls", "(", "config", ")", "if", "not", "paths_and_urls", ":", "log", ".", "warning", "(", "'No artifacts; nothing to download.'", ")", "return", ...
Main function. Runs the program. :param dict config: Dictionary from get_arguments(). :param logging.Logger log: Logger for this function. Populated by with_log() decorator.
[ "Main", "function", ".", "Runs", "the", "program", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L563-L585
train
Robpol86/appveyor-artifacts
appveyor_artifacts.py
entry_point
def entry_point(): """Entry-point from setuptools.""" signal.signal(signal.SIGINT, lambda *_: getattr(os, '_exit')(0)) # Properly handle Control+C config = get_arguments() setup_logging(config['verbose']) try: main(config) except HandledError: if config['raise']: rai...
python
def entry_point(): """Entry-point from setuptools.""" signal.signal(signal.SIGINT, lambda *_: getattr(os, '_exit')(0)) # Properly handle Control+C config = get_arguments() setup_logging(config['verbose']) try: main(config) except HandledError: if config['raise']: rai...
[ "def", "entry_point", "(", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "lambda", "*", "_", ":", "getattr", "(", "os", ",", "'_exit'", ")", "(", "0", ")", ")", "# Properly handle Control+C", "config", "=", "get_arguments", "(", ...
Entry-point from setuptools.
[ "Entry", "-", "point", "from", "setuptools", "." ]
20bc2963b09f4142fd4c0b1f5da04f1105379e36
https://github.com/Robpol86/appveyor-artifacts/blob/20bc2963b09f4142fd4c0b1f5da04f1105379e36/appveyor_artifacts.py#L588-L599
train
mmEissen/airpixel
airpixel/client.py
ConnectionSupervisor.incoming_messages
def incoming_messages(self) -> t.List[t.Tuple[float, bytes]]: """Consume the receive buffer and return the messages. If there are new messages added to the queue while this funciton is being processed, they will not be returned. This ensures that this terminates in a timely manner. ...
python
def incoming_messages(self) -> t.List[t.Tuple[float, bytes]]: """Consume the receive buffer and return the messages. If there are new messages added to the queue while this funciton is being processed, they will not be returned. This ensures that this terminates in a timely manner. ...
[ "def", "incoming_messages", "(", "self", ")", "->", "t", ".", "List", "[", "t", ".", "Tuple", "[", "float", ",", "bytes", "]", "]", ":", "approximate_messages", "=", "self", ".", "_receive_buffer", ".", "qsize", "(", ")", "messages", "=", "[", "]", "...
Consume the receive buffer and return the messages. If there are new messages added to the queue while this funciton is being processed, they will not be returned. This ensures that this terminates in a timely manner.
[ "Consume", "the", "receive", "buffer", "and", "return", "the", "messages", "." ]
23385776eaa1a8a573fa94200eea051fa7c6c120
https://github.com/mmEissen/airpixel/blob/23385776eaa1a8a573fa94200eea051fa7c6c120/airpixel/client.py#L278-L292
train
pyout/pyout
pyout/common.py
_safe_get
def _safe_get(mapping, key, default=None): """Helper for accessing style values. It exists to avoid checking whether `mapping` is indeed a mapping before trying to get a key. In the context of style dicts, this eliminates "is this a mapping" checks in two common situations: 1) a style argument is ...
python
def _safe_get(mapping, key, default=None): """Helper for accessing style values. It exists to avoid checking whether `mapping` is indeed a mapping before trying to get a key. In the context of style dicts, this eliminates "is this a mapping" checks in two common situations: 1) a style argument is ...
[ "def", "_safe_get", "(", "mapping", ",", "key", ",", "default", "=", "None", ")", ":", "try", ":", "return", "mapping", ".", "get", "(", "key", ",", "default", ")", "except", "AttributeError", ":", "return", "default" ]
Helper for accessing style values. It exists to avoid checking whether `mapping` is indeed a mapping before trying to get a key. In the context of style dicts, this eliminates "is this a mapping" checks in two common situations: 1) a style argument is None, and 2) a style key's value (e.g., width) can...
[ "Helper", "for", "accessing", "style", "values", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L214-L226
train
pyout/pyout
pyout/common.py
RowNormalizer.strip_callables
def strip_callables(row): """Extract callable values from `row`. Replace the callable values with the initial value (if specified) or an empty string. Parameters ---------- row : mapping A data row. The keys are either a single column name or a tuple of ...
python
def strip_callables(row): """Extract callable values from `row`. Replace the callable values with the initial value (if specified) or an empty string. Parameters ---------- row : mapping A data row. The keys are either a single column name or a tuple of ...
[ "def", "strip_callables", "(", "row", ")", ":", "callables", "=", "[", "]", "to_delete", "=", "[", "]", "to_add", "=", "[", "]", "for", "columns", ",", "value", "in", "row", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "tuple...
Extract callable values from `row`. Replace the callable values with the initial value (if specified) or an empty string. Parameters ---------- row : mapping A data row. The keys are either a single column name or a tuple of column names. The values ta...
[ "Extract", "callable", "values", "from", "row", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L150-L198
train
pyout/pyout
pyout/common.py
StyleFields.build
def build(self, columns): """Build the style and fields. Parameters ---------- columns : list of str Column names. """ self.columns = columns default = dict(elements.default("default_"), **_safe_get(self.init_style, "default_", ...
python
def build(self, columns): """Build the style and fields. Parameters ---------- columns : list of str Column names. """ self.columns = columns default = dict(elements.default("default_"), **_safe_get(self.init_style, "default_", ...
[ "def", "build", "(", "self", ",", "columns", ")", ":", "self", ".", "columns", "=", "columns", "default", "=", "dict", "(", "elements", ".", "default", "(", "\"default_\"", ")", ",", "*", "*", "_safe_get", "(", "self", ".", "init_style", ",", "\"defaul...
Build the style and fields. Parameters ---------- columns : list of str Column names.
[ "Build", "the", "style", "and", "fields", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L252-L281
train
pyout/pyout
pyout/common.py
StyleFields._compose
def _compose(self, name, attributes): """Construct a style taking `attributes` from the column styles. Parameters ---------- name : str Name of main style (e.g., "header_"). attributes : set of str Adopt these elements from the column styles. Ret...
python
def _compose(self, name, attributes): """Construct a style taking `attributes` from the column styles. Parameters ---------- name : str Name of main style (e.g., "header_"). attributes : set of str Adopt these elements from the column styles. Ret...
[ "def", "_compose", "(", "self", ",", "name", ",", "attributes", ")", ":", "name_style", "=", "_safe_get", "(", "self", ".", "init_style", ",", "name", ",", "elements", ".", "default", "(", "name", ")", ")", "if", "self", ".", "init_style", "is", "not",...
Construct a style taking `attributes` from the column styles. Parameters ---------- name : str Name of main style (e.g., "header_"). attributes : set of str Adopt these elements from the column styles. Returns ------- The composite style ...
[ "Construct", "a", "style", "taking", "attributes", "from", "the", "column", "styles", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L283-L304
train
pyout/pyout
pyout/common.py
StyleFields._set_widths
def _set_widths(self, row, proc_group): """Update auto-width Fields based on `row`. Parameters ---------- row : dict proc_group : {'default', 'override'} Whether to consider 'default' or 'override' key for pre- and post-format processors. Returns...
python
def _set_widths(self, row, proc_group): """Update auto-width Fields based on `row`. Parameters ---------- row : dict proc_group : {'default', 'override'} Whether to consider 'default' or 'override' key for pre- and post-format processors. Returns...
[ "def", "_set_widths", "(", "self", ",", "row", ",", "proc_group", ")", ":", "width_free", "=", "self", ".", "style", "[", "\"width_\"", "]", "-", "sum", "(", "[", "sum", "(", "self", ".", "fields", "[", "c", "]", ".", "width", "for", "c", "in", "...
Update auto-width Fields based on `row`. Parameters ---------- row : dict proc_group : {'default', 'override'} Whether to consider 'default' or 'override' key for pre- and post-format processors. Returns ------- True if any widths require...
[ "Update", "auto", "-", "width", "Fields", "based", "on", "row", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L361-L434
train
pyout/pyout
pyout/common.py
StyleFields._proc_group
def _proc_group(self, style, adopt=True): """Return whether group is "default" or "override". In the case of "override", the self.fields pre-format and post-format processors will be set under the "override" key. Parameters ---------- style : dict A style th...
python
def _proc_group(self, style, adopt=True): """Return whether group is "default" or "override". In the case of "override", the self.fields pre-format and post-format processors will be set under the "override" key. Parameters ---------- style : dict A style th...
[ "def", "_proc_group", "(", "self", ",", "style", ",", "adopt", "=", "True", ")", ":", "fields", "=", "self", ".", "fields", "if", "style", "is", "not", "None", ":", "if", "adopt", ":", "style", "=", "elements", ".", "adopt", "(", "self", ".", "styl...
Return whether group is "default" or "override". In the case of "override", the self.fields pre-format and post-format processors will be set under the "override" key. Parameters ---------- style : dict A style that follows the schema defined in pyout.elements. ...
[ "Return", "whether", "group", "is", "default", "or", "override", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L436-L466
train
pyout/pyout
pyout/common.py
StyleFields.render
def render(self, row, style=None, adopt=True): """Render fields with values from `row`. Parameters ---------- row : dict A normalized row. style : dict, optional A style that follows the schema defined in pyout.elements. If None, `self.style`...
python
def render(self, row, style=None, adopt=True): """Render fields with values from `row`. Parameters ---------- row : dict A normalized row. style : dict, optional A style that follows the schema defined in pyout.elements. If None, `self.style`...
[ "def", "render", "(", "self", ",", "row", ",", "style", "=", "None", ",", "adopt", "=", "True", ")", ":", "group", "=", "self", ".", "_proc_group", "(", "style", ",", "adopt", "=", "adopt", ")", "if", "group", "==", "\"override\"", ":", "# Override t...
Render fields with values from `row`. Parameters ---------- row : dict A normalized row. style : dict, optional A style that follows the schema defined in pyout.elements. If None, `self.style` is used. adopt : bool, optional Merge...
[ "Render", "fields", "with", "values", "from", "row", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/common.py#L468-L499
train
HubbleHQ/heroku-kafka
heroku_kafka.py
HerokuKafka.get_config
def get_config(self): """ Sets up the basic config from the variables passed in all of these are from what Heroku gives you. """ self.create_ssl_certs() config = { "bootstrap_servers": self.get_brokers(), "security_protocol": 'SSL', "s...
python
def get_config(self): """ Sets up the basic config from the variables passed in all of these are from what Heroku gives you. """ self.create_ssl_certs() config = { "bootstrap_servers": self.get_brokers(), "security_protocol": 'SSL', "s...
[ "def", "get_config", "(", "self", ")", ":", "self", ".", "create_ssl_certs", "(", ")", "config", "=", "{", "\"bootstrap_servers\"", ":", "self", ".", "get_brokers", "(", ")", ",", "\"security_protocol\"", ":", "'SSL'", ",", "\"ssl_cafile\"", ":", "self", "."...
Sets up the basic config from the variables passed in all of these are from what Heroku gives you.
[ "Sets", "up", "the", "basic", "config", "from", "the", "variables", "passed", "in", "all", "of", "these", "are", "from", "what", "Heroku", "gives", "you", "." ]
2c28b79e0ba130e13e91d9458826d4930eee2c52
https://github.com/HubbleHQ/heroku-kafka/blob/2c28b79e0ba130e13e91d9458826d4930eee2c52/heroku_kafka.py#L27-L43
train
HubbleHQ/heroku-kafka
heroku_kafka.py
HerokuKafka.get_brokers
def get_brokers(self): """ Parses the KAKFA_URL and returns a list of hostname:port pairs in the format that kafka-python expects. """ return ['{}:{}'.format(parsedUrl.hostname, parsedUrl.port) for parsedUrl in [urlparse(url) for url in self.kafka_url.split(',')]]
python
def get_brokers(self): """ Parses the KAKFA_URL and returns a list of hostname:port pairs in the format that kafka-python expects. """ return ['{}:{}'.format(parsedUrl.hostname, parsedUrl.port) for parsedUrl in [urlparse(url) for url in self.kafka_url.split(',')]]
[ "def", "get_brokers", "(", "self", ")", ":", "return", "[", "'{}:{}'", ".", "format", "(", "parsedUrl", ".", "hostname", ",", "parsedUrl", ".", "port", ")", "for", "parsedUrl", "in", "[", "urlparse", "(", "url", ")", "for", "url", "in", "self", ".", ...
Parses the KAKFA_URL and returns a list of hostname:port pairs in the format that kafka-python expects.
[ "Parses", "the", "KAKFA_URL", "and", "returns", "a", "list", "of", "hostname", ":", "port", "pairs", "in", "the", "format", "that", "kafka", "-", "python", "expects", "." ]
2c28b79e0ba130e13e91d9458826d4930eee2c52
https://github.com/HubbleHQ/heroku-kafka/blob/2c28b79e0ba130e13e91d9458826d4930eee2c52/heroku_kafka.py#L45-L51
train
HubbleHQ/heroku-kafka
heroku_kafka.py
HerokuKafka.create_ssl_certs
def create_ssl_certs(self): """ Creates SSL cert files """ for key, file in self.ssl.items(): file["file"] = self.create_temp_file(file["suffix"], file["content"])
python
def create_ssl_certs(self): """ Creates SSL cert files """ for key, file in self.ssl.items(): file["file"] = self.create_temp_file(file["suffix"], file["content"])
[ "def", "create_ssl_certs", "(", "self", ")", ":", "for", "key", ",", "file", "in", "self", ".", "ssl", ".", "items", "(", ")", ":", "file", "[", "\"file\"", "]", "=", "self", ".", "create_temp_file", "(", "file", "[", "\"suffix\"", "]", ",", "file", ...
Creates SSL cert files
[ "Creates", "SSL", "cert", "files" ]
2c28b79e0ba130e13e91d9458826d4930eee2c52
https://github.com/HubbleHQ/heroku-kafka/blob/2c28b79e0ba130e13e91d9458826d4930eee2c52/heroku_kafka.py#L53-L58
train
HubbleHQ/heroku-kafka
heroku_kafka.py
HerokuKafka.create_temp_file
def create_temp_file(self, suffix, content): """ Creates file, because environment variables are by default escaped it encodes and then decodes them before write so \n etc. work correctly. """ temp = tempfile.NamedTemporaryFile(suffix=suffix) temp.write(content.encode('l...
python
def create_temp_file(self, suffix, content): """ Creates file, because environment variables are by default escaped it encodes and then decodes them before write so \n etc. work correctly. """ temp = tempfile.NamedTemporaryFile(suffix=suffix) temp.write(content.encode('l...
[ "def", "create_temp_file", "(", "self", ",", "suffix", ",", "content", ")", ":", "temp", "=", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "suffix", ")", "temp", ".", "write", "(", "content", ".", "encode", "(", "'latin1'", ")", ".", "decod...
Creates file, because environment variables are by default escaped it encodes and then decodes them before write so \n etc. work correctly.
[ "Creates", "file", "because", "environment", "variables", "are", "by", "default", "escaped", "it", "encodes", "and", "then", "decodes", "them", "before", "write", "so", "\\", "n", "etc", ".", "work", "correctly", "." ]
2c28b79e0ba130e13e91d9458826d4930eee2c52
https://github.com/HubbleHQ/heroku-kafka/blob/2c28b79e0ba130e13e91d9458826d4930eee2c52/heroku_kafka.py#L61-L69
train
HubbleHQ/heroku-kafka
heroku_kafka.py
HerokuKafka.prefix_topic
def prefix_topic(self, topics): """ Adds the topic_prefix to topic(s) supplied """ if not self.topic_prefix or not topics: return topics if not isinstance(topics, str) and isinstance(topics, collections.Iterable): return [self.topic_prefix + topic for top...
python
def prefix_topic(self, topics): """ Adds the topic_prefix to topic(s) supplied """ if not self.topic_prefix or not topics: return topics if not isinstance(topics, str) and isinstance(topics, collections.Iterable): return [self.topic_prefix + topic for top...
[ "def", "prefix_topic", "(", "self", ",", "topics", ")", ":", "if", "not", "self", ".", "topic_prefix", "or", "not", "topics", ":", "return", "topics", "if", "not", "isinstance", "(", "topics", ",", "str", ")", "and", "isinstance", "(", "topics", ",", "...
Adds the topic_prefix to topic(s) supplied
[ "Adds", "the", "topic_prefix", "to", "topic", "(", "s", ")", "supplied" ]
2c28b79e0ba130e13e91d9458826d4930eee2c52
https://github.com/HubbleHQ/heroku-kafka/blob/2c28b79e0ba130e13e91d9458826d4930eee2c52/heroku_kafka.py#L71-L81
train
HubbleHQ/heroku-kafka
heroku_kafka.py
HerokuKafkaProducer.send
def send(self, topic, *args, **kwargs): """ Appends the prefix to the topic before sendingf """ prefix_topic = self.heroku_kafka.prefix_topic(topic) return super(HerokuKafkaProducer, self).send(prefix_topic, *args, **kwargs)
python
def send(self, topic, *args, **kwargs): """ Appends the prefix to the topic before sendingf """ prefix_topic = self.heroku_kafka.prefix_topic(topic) return super(HerokuKafkaProducer, self).send(prefix_topic, *args, **kwargs)
[ "def", "send", "(", "self", ",", "topic", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "prefix_topic", "=", "self", ".", "heroku_kafka", ".", "prefix_topic", "(", "topic", ")", "return", "super", "(", "HerokuKafkaProducer", ",", "self", ")", "....
Appends the prefix to the topic before sendingf
[ "Appends", "the", "prefix", "to", "the", "topic", "before", "sendingf" ]
2c28b79e0ba130e13e91d9458826d4930eee2c52
https://github.com/HubbleHQ/heroku-kafka/blob/2c28b79e0ba130e13e91d9458826d4930eee2c52/heroku_kafka.py#L98-L103
train
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/base.py
BaseParser.get
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ Inherited method should take all specified arguments. :param variable_p...
python
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ Inherited method should take all specified arguments. :param variable_p...
[ "def", "get", "(", "self", ",", "variable_path", ":", "str", ",", "default", ":", "t", ".", "Optional", "[", "t", ".", "Any", "]", "=", "None", ",", "coerce_type", ":", "t", ".", "Optional", "[", "t", ".", "Type", "]", "=", "None", ",", "coercer"...
Inherited method should take all specified arguments. :param variable_path: a delimiter-separated path to a nested value :param default: default value if there's no object by specified path :param coerce_type: cast a type of a value to a specified one :param coercer: perform a type cast...
[ "Inherited", "method", "should", "take", "all", "specified", "arguments", "." ]
b64f8009101a8eb61d3841124ba19e3ab881aa2f
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/base.py#L47-L63
train
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/base.py
BaseParser.coerce
def coerce(val: t.Any, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None) -> t.Any: """ Casts a type of ``val`` to ``coerce_type`` with ``coercer``. If ``coerce_type`` is bool and no ``coercer`` specified it uses :func:`~django_...
python
def coerce(val: t.Any, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None) -> t.Any: """ Casts a type of ``val`` to ``coerce_type`` with ``coercer``. If ``coerce_type`` is bool and no ``coercer`` specified it uses :func:`~django_...
[ "def", "coerce", "(", "val", ":", "t", ".", "Any", ",", "coerce_type", ":", "t", ".", "Optional", "[", "t", ".", "Type", "]", "=", "None", ",", "coercer", ":", "t", ".", "Optional", "[", "t", ".", "Callable", "]", "=", "None", ")", "->", "t", ...
Casts a type of ``val`` to ``coerce_type`` with ``coercer``. If ``coerce_type`` is bool and no ``coercer`` specified it uses :func:`~django_docker_helpers.utils.coerce_str_to_bool` by default. :param val: a value of any type :param coerce_type: any type :param coercer: provide ...
[ "Casts", "a", "type", "of", "val", "to", "coerce_type", "with", "coercer", "." ]
b64f8009101a8eb61d3841124ba19e3ab881aa2f
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/base.py#L66-L92
train
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/base.py
BaseParser.client
def client(self): """ Helper property to lazy initialize and cache client. Runs :meth:`~django_docker_helpers.config.backends.base.BaseParser.get_client`. :return: an instance of backend-specific client """ if self._client is not None: return self._client ...
python
def client(self): """ Helper property to lazy initialize and cache client. Runs :meth:`~django_docker_helpers.config.backends.base.BaseParser.get_client`. :return: an instance of backend-specific client """ if self._client is not None: return self._client ...
[ "def", "client", "(", "self", ")", ":", "if", "self", ".", "_client", "is", "not", "None", ":", "return", "self", ".", "_client", "self", ".", "_client", "=", "self", ".", "get_client", "(", ")", "return", "self", ".", "_client" ]
Helper property to lazy initialize and cache client. Runs :meth:`~django_docker_helpers.config.backends.base.BaseParser.get_client`. :return: an instance of backend-specific client
[ "Helper", "property", "to", "lazy", "initialize", "and", "cache", "client", ".", "Runs", ":", "meth", ":", "~django_docker_helpers", ".", "config", ".", "backends", ".", "base", ".", "BaseParser", ".", "get_client", "." ]
b64f8009101a8eb61d3841124ba19e3ab881aa2f
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/base.py#L95-L106
train
pyout/pyout
pyout/truncate.py
_splice
def _splice(value, n): """Splice `value` at its center, retaining a total of `n` characters. Parameters ---------- value : str n : int The total length of the returned ends will not be greater than this value. Characters will be dropped from the center to reach this limit. Ret...
python
def _splice(value, n): """Splice `value` at its center, retaining a total of `n` characters. Parameters ---------- value : str n : int The total length of the returned ends will not be greater than this value. Characters will be dropped from the center to reach this limit. Ret...
[ "def", "_splice", "(", "value", ",", "n", ")", ":", "if", "n", "<=", "0", ":", "raise", "ValueError", "(", "\"n must be positive\"", ")", "value_len", "=", "len", "(", "value", ")", "center", "=", "value_len", "//", "2", "left", ",", "right", "=", "v...
Splice `value` at its center, retaining a total of `n` characters. Parameters ---------- value : str n : int The total length of the returned ends will not be greater than this value. Characters will be dropped from the center to reach this limit. Returns ------- A tuple o...
[ "Splice", "value", "at", "its", "center", "retaining", "a", "total", "of", "n", "characters", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/truncate.py#L27-L54
train
night-crawler/django-docker-helpers
django_docker_helpers/cli/django/management/commands/run_configured_uwsgi.py
write_uwsgi_ini_cfg
def write_uwsgi_ini_cfg(fp: t.IO, cfg: dict): """ Writes into IO stream the uwsgi.ini file content (actually it does smth strange, just look below). uWSGI configs are likely to break INI (YAML, etc) specification (double key definition) so it writes `cfg` object (dict) in "uWSGI Style". >>> import...
python
def write_uwsgi_ini_cfg(fp: t.IO, cfg: dict): """ Writes into IO stream the uwsgi.ini file content (actually it does smth strange, just look below). uWSGI configs are likely to break INI (YAML, etc) specification (double key definition) so it writes `cfg` object (dict) in "uWSGI Style". >>> import...
[ "def", "write_uwsgi_ini_cfg", "(", "fp", ":", "t", ".", "IO", ",", "cfg", ":", "dict", ")", ":", "fp", ".", "write", "(", "f'[uwsgi]\\n'", ")", "for", "key", ",", "val", "in", "cfg", ".", "items", "(", ")", ":", "if", "isinstance", "(", "val", ",...
Writes into IO stream the uwsgi.ini file content (actually it does smth strange, just look below). uWSGI configs are likely to break INI (YAML, etc) specification (double key definition) so it writes `cfg` object (dict) in "uWSGI Style". >>> import sys >>> cfg = { ... 'static-map': [ ... '/sta...
[ "Writes", "into", "IO", "stream", "the", "uwsgi", ".", "ini", "file", "content", "(", "actually", "it", "does", "smth", "strange", "just", "look", "below", ")", "." ]
b64f8009101a8eb61d3841124ba19e3ab881aa2f
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/cli/django/management/commands/run_configured_uwsgi.py#L9-L40
train
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/mpt_consul_parser.py
MPTConsulParser.get
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ :param variable_path: a delimiter-separated path to a nested value :para...
python
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ :param variable_path: a delimiter-separated path to a nested value :para...
[ "def", "get", "(", "self", ",", "variable_path", ":", "str", ",", "default", ":", "t", ".", "Optional", "[", "t", ".", "Any", "]", "=", "None", ",", "coerce_type", ":", "t", ".", "Optional", "[", "t", ".", "Type", "]", "=", "None", ",", "coercer"...
:param variable_path: a delimiter-separated path to a nested value :param default: default value if there's no object by specified path :param coerce_type: cast a type of a value to a specified one :param coercer: perform a type casting with specified callback :param kwargs: additional a...
[ ":", "param", "variable_path", ":", "a", "delimiter", "-", "separated", "path", "to", "a", "nested", "value", ":", "param", "default", ":", "default", "value", "if", "there", "s", "no", "object", "by", "specified", "path", ":", "param", "coerce_type", ":",...
b64f8009101a8eb61d3841124ba19e3ab881aa2f
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/mpt_consul_parser.py#L76-L119
train
meng89/ipodshuffle
ipodshuffle/db/itunessd.py
itunessd_to_dics
def itunessd_to_dics(itunessd): """ :param itunessd: the whole iTunesSD bytes data :return: translate to tree object, see doc of dics_to_itunessd """ # header header_size = get_table_size(header_table) header_chunk = itunessd[0:header_size] header_dic = chunk_to_dic(header_chunk, header...
python
def itunessd_to_dics(itunessd): """ :param itunessd: the whole iTunesSD bytes data :return: translate to tree object, see doc of dics_to_itunessd """ # header header_size = get_table_size(header_table) header_chunk = itunessd[0:header_size] header_dic = chunk_to_dic(header_chunk, header...
[ "def", "itunessd_to_dics", "(", "itunessd", ")", ":", "# header", "header_size", "=", "get_table_size", "(", "header_table", ")", "header_chunk", "=", "itunessd", "[", "0", ":", "header_size", "]", "header_dic", "=", "chunk_to_dic", "(", "header_chunk", ",", "he...
:param itunessd: the whole iTunesSD bytes data :return: translate to tree object, see doc of dics_to_itunessd
[ ":", "param", "itunessd", ":", "the", "whole", "iTunesSD", "bytes", "data", ":", "return", ":", "translate", "to", "tree", "object", "see", "doc", "of", "dics_to_itunessd" ]
c9093dbb5cdac609376ebd3b4ef1b0fc58107d96
https://github.com/meng89/ipodshuffle/blob/c9093dbb5cdac609376ebd3b4ef1b0fc58107d96/ipodshuffle/db/itunessd.py#L372-L402
train
meng89/ipodshuffle
ipodshuffle/db/itunessd.py
dics_to_itunessd
def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes): """ :param header_dic: dic of header_table :param tracks_dics: list of all track_table's dics :param playlists_dics_and_indexes: list of all playlists and all their track's indexes :return: the whole iTunesSD bytes data "...
python
def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes): """ :param header_dic: dic of header_table :param tracks_dics: list of all track_table's dics :param playlists_dics_and_indexes: list of all playlists and all their track's indexes :return: the whole iTunesSD bytes data "...
[ "def", "dics_to_itunessd", "(", "header_dic", ",", "tracks_dics", ",", "playlists_dics_and_indexes", ")", ":", "############################################", "# header", "######", "header_dic", "[", "'length'", "]", "=", "get_table_size", "(", "header_table", ")", "heade...
:param header_dic: dic of header_table :param tracks_dics: list of all track_table's dics :param playlists_dics_and_indexes: list of all playlists and all their track's indexes :return: the whole iTunesSD bytes data
[ ":", "param", "header_dic", ":", "dic", "of", "header_table", ":", "param", "tracks_dics", ":", "list", "of", "all", "track_table", "s", "dics", ":", "param", "playlists_dics_and_indexes", ":", "list", "of", "all", "playlists", "and", "all", "their", "track", ...
c9093dbb5cdac609376ebd3b4ef1b0fc58107d96
https://github.com/meng89/ipodshuffle/blob/c9093dbb5cdac609376ebd3b4ef1b0fc58107d96/ipodshuffle/db/itunessd.py#L418-L516
train
pyout/pyout
pyout/field.py
Field.add
def add(self, kind, key, *values): """Add processor functions. Any previous list of processors for `kind` and `key` will be overwritten. Parameters ---------- kind : {"pre", "post"} key : str A registered key. Add the functions (in order) to this ke...
python
def add(self, kind, key, *values): """Add processor functions. Any previous list of processors for `kind` and `key` will be overwritten. Parameters ---------- kind : {"pre", "post"} key : str A registered key. Add the functions (in order) to this ke...
[ "def", "add", "(", "self", ",", "kind", ",", "key", ",", "*", "values", ")", ":", "if", "kind", "==", "\"pre\"", ":", "procs", "=", "self", ".", "pre", "elif", "kind", "==", "\"post\"", ":", "procs", "=", "self", ".", "post", "else", ":", "raise"...
Add processor functions. Any previous list of processors for `kind` and `key` will be overwritten. Parameters ---------- kind : {"pre", "post"} key : str A registered key. Add the functions (in order) to this key's list of processors. *v...
[ "Add", "processor", "functions", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L84-L106
train
pyout/pyout
pyout/field.py
Field._format
def _format(self, _, result): """Wrap format call as a two-argument processor function. """ return self._fmt.format(six.text_type(result))
python
def _format(self, _, result): """Wrap format call as a two-argument processor function. """ return self._fmt.format(six.text_type(result))
[ "def", "_format", "(", "self", ",", "_", ",", "result", ")", ":", "return", "self", ".", "_fmt", ".", "format", "(", "six", ".", "text_type", "(", "result", ")", ")" ]
Wrap format call as a two-argument processor function.
[ "Wrap", "format", "call", "as", "a", "two", "-", "argument", "processor", "function", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L121-L124
train
pyout/pyout
pyout/field.py
StyleProcessors.transform
def transform(function): """Return a processor for a style's "transform" function. """ def transform_fn(_, result): if isinstance(result, Nothing): return result lgr.debug("Transforming %r with %r", result, function) try: retur...
python
def transform(function): """Return a processor for a style's "transform" function. """ def transform_fn(_, result): if isinstance(result, Nothing): return result lgr.debug("Transforming %r with %r", result, function) try: retur...
[ "def", "transform", "(", "function", ")", ":", "def", "transform_fn", "(", "_", ",", "result", ")", ":", "if", "isinstance", "(", "result", ",", "Nothing", ")", ":", "return", "result", "lgr", ".", "debug", "(", "\"Transforming %r with %r\"", ",", "result"...
Return a processor for a style's "transform" function.
[ "Return", "a", "processor", "for", "a", "style", "s", "transform", "function", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L240-L262
train
pyout/pyout
pyout/field.py
StyleProcessors.by_key
def by_key(self, style_key, style_value): """Return a processor for a "simple" style value. Parameters ---------- style_key : str A style key. style_value : bool or str A "simple" style value that is either a style attribute (str) and a boolea...
python
def by_key(self, style_key, style_value): """Return a processor for a "simple" style value. Parameters ---------- style_key : str A style key. style_value : bool or str A "simple" style value that is either a style attribute (str) and a boolea...
[ "def", "by_key", "(", "self", ",", "style_key", ",", "style_value", ")", ":", "if", "self", ".", "style_types", "[", "style_key", "]", "is", "bool", ":", "style_attr", "=", "style_key", "else", ":", "style_attr", "=", "style_value", "def", "proc", "(", "...
Return a processor for a "simple" style value. Parameters ---------- style_key : str A style key. style_value : bool or str A "simple" style value that is either a style attribute (str) and a boolean flag indicating to use the style attribute named by...
[ "Return", "a", "processor", "for", "a", "simple", "style", "value", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L264-L287
train
pyout/pyout
pyout/field.py
StyleProcessors.by_lookup
def by_lookup(self, style_key, style_value): """Return a processor that extracts the style from `mapping`. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with a "lookup" key whose value is a "mapping" style ...
python
def by_lookup(self, style_key, style_value): """Return a processor that extracts the style from `mapping`. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with a "lookup" key whose value is a "mapping" style ...
[ "def", "by_lookup", "(", "self", ",", "style_key", ",", "style_value", ")", ":", "style_attr", "=", "style_key", "if", "self", ".", "style_types", "[", "style_key", "]", "is", "bool", "else", "None", "mapping", "=", "style_value", "[", "\"lookup\"", "]", "...
Return a processor that extracts the style from `mapping`. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with a "lookup" key whose value is a "mapping" style value that maps a field value to either a style attribut...
[ "Return", "a", "processor", "that", "extracts", "the", "style", "from", "mapping", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L289-L320
train
pyout/pyout
pyout/field.py
StyleProcessors.by_re_lookup
def by_re_lookup(self, style_key, style_value, re_flags=0): """Return a processor for a "re_lookup" style value. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with a "re_lookup" style value that consists of a ...
python
def by_re_lookup(self, style_key, style_value, re_flags=0): """Return a processor for a "re_lookup" style value. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with a "re_lookup" style value that consists of a ...
[ "def", "by_re_lookup", "(", "self", ",", "style_key", ",", "style_value", ",", "re_flags", "=", "0", ")", ":", "style_attr", "=", "style_key", "if", "self", ".", "style_types", "[", "style_key", "]", "is", "bool", "else", "None", "regexps", "=", "[", "("...
Return a processor for a "re_lookup" style value. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with a "re_lookup" style value that consists of a sequence of items where each item should have the form `(regexp, ...
[ "Return", "a", "processor", "for", "a", "re_lookup", "style", "value", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L322-L355
train
pyout/pyout
pyout/field.py
StyleProcessors.by_interval_lookup
def by_interval_lookup(self, style_key, style_value): """Return a processor for an "interval" style value. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with an "interval" key whose value consists of a sequ...
python
def by_interval_lookup(self, style_key, style_value): """Return a processor for an "interval" style value. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with an "interval" key whose value consists of a sequ...
[ "def", "by_interval_lookup", "(", "self", ",", "style_key", ",", "style_value", ")", ":", "style_attr", "=", "style_key", "if", "self", ".", "style_types", "[", "style_key", "]", "is", "bool", "else", "None", "intervals", "=", "style_value", "[", "\"interval\"...
Return a processor for an "interval" style value. Parameters ---------- style_key : str A style key. style_value : dict A dictionary with an "interval" key whose value consists of a sequence of tuples where each tuple should have the form `(start, ...
[ "Return", "a", "processor", "for", "an", "interval", "style", "value", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L357-L396
train
pyout/pyout
pyout/field.py
StyleProcessors.post_from_style
def post_from_style(self, column_style): """Yield post-format processors based on `column_style`. Parameters ---------- column_style : dict A style where the top-level keys correspond to style attributes such as "bold" or "color". Returns -------...
python
def post_from_style(self, column_style): """Yield post-format processors based on `column_style`. Parameters ---------- column_style : dict A style where the top-level keys correspond to style attributes such as "bold" or "color". Returns -------...
[ "def", "post_from_style", "(", "self", ",", "column_style", ")", ":", "flanks", "=", "Flanks", "(", ")", "yield", "flanks", ".", "split_flanks", "fns", "=", "{", "\"simple\"", ":", "self", ".", "by_key", ",", "\"lookup\"", ":", "self", ".", "by_lookup", ...
Yield post-format processors based on `column_style`. Parameters ---------- column_style : dict A style where the top-level keys correspond to style attributes such as "bold" or "color". Returns ------- A generator object.
[ "Yield", "post", "-", "format", "processors", "based", "on", "column_style", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L414-L447
train
pyout/pyout
pyout/field.py
Flanks.split_flanks
def split_flanks(self, _, result): """Return `result` without flanking whitespace. """ if not result.strip(): self.left, self.right = "", "" return result match = self.flank_re.match(result) assert match, "This regexp should always match" self.lef...
python
def split_flanks(self, _, result): """Return `result` without flanking whitespace. """ if not result.strip(): self.left, self.right = "", "" return result match = self.flank_re.match(result) assert match, "This regexp should always match" self.lef...
[ "def", "split_flanks", "(", "self", ",", "_", ",", "result", ")", ":", "if", "not", "result", ".", "strip", "(", ")", ":", "self", ".", "left", ",", "self", ".", "right", "=", "\"\"", ",", "\"\"", "return", "result", "match", "=", "self", ".", "f...
Return `result` without flanking whitespace.
[ "Return", "result", "without", "flanking", "whitespace", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L459-L469
train
pyout/pyout
pyout/field.py
TermProcessors.render
def render(self, style_attr, value): """Prepend terminal code for `key` to `value`. Parameters ---------- style_attr : str A style attribute (e.g., "bold" or "blue"). value : str The value to render. Returns ------- The code for `...
python
def render(self, style_attr, value): """Prepend terminal code for `key` to `value`. Parameters ---------- style_attr : str A style attribute (e.g., "bold" or "blue"). value : str The value to render. Returns ------- The code for `...
[ "def", "render", "(", "self", ",", "style_attr", ",", "value", ")", ":", "if", "not", "value", ".", "strip", "(", ")", ":", "# We've got an empty string. Don't bother adding any", "# codes.", "return", "value", "return", "six", ".", "text_type", "(", "getattr",...
Prepend terminal code for `key` to `value`. Parameters ---------- style_attr : str A style attribute (e.g., "bold" or "blue"). value : str The value to render. Returns ------- The code for `key` (e.g., "\x1b[1m" for bold) plus the ...
[ "Prepend", "terminal", "code", "for", "key", "to", "value", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L495-L514
train
pyout/pyout
pyout/field.py
TermProcessors.post_from_style
def post_from_style(self, column_style): """A Terminal-specific reset to StyleProcessors.post_from_style. """ for proc in super(TermProcessors, self).post_from_style(column_style): if proc.__name__ == "join_flanks": # Reset any codes before adding back whitespace. ...
python
def post_from_style(self, column_style): """A Terminal-specific reset to StyleProcessors.post_from_style. """ for proc in super(TermProcessors, self).post_from_style(column_style): if proc.__name__ == "join_flanks": # Reset any codes before adding back whitespace. ...
[ "def", "post_from_style", "(", "self", ",", "column_style", ")", ":", "for", "proc", "in", "super", "(", "TermProcessors", ",", "self", ")", ".", "post_from_style", "(", "column_style", ")", ":", "if", "proc", ".", "__name__", "==", "\"join_flanks\"", ":", ...
A Terminal-specific reset to StyleProcessors.post_from_style.
[ "A", "Terminal", "-", "specific", "reset", "to", "StyleProcessors", ".", "post_from_style", "." ]
d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0
https://github.com/pyout/pyout/blob/d9ff954bdedb6fc70f21f4fe77ad4bf926b201b0/pyout/field.py#L523-L530
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
InstanceProxy.connect
def connect(self, cback): "See signal" return self.signal.connect(cback, subscribers=self.subscribers, instance=self.instance)
python
def connect(self, cback): "See signal" return self.signal.connect(cback, subscribers=self.subscribers, instance=self.instance)
[ "def", "connect", "(", "self", ",", "cback", ")", ":", "return", "self", ".", "signal", ".", "connect", "(", "cback", ",", "subscribers", "=", "self", ".", "subscribers", ",", "instance", "=", "self", ".", "instance", ")" ]
See signal
[ "See", "signal" ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L56-L60
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
InstanceProxy.disconnect
def disconnect(self, cback): "See signal" return self.signal.disconnect(cback, subscribers=self.subscribers, instance=self.instance)
python
def disconnect(self, cback): "See signal" return self.signal.disconnect(cback, subscribers=self.subscribers, instance=self.instance)
[ "def", "disconnect", "(", "self", ",", "cback", ")", ":", "return", "self", ".", "signal", ".", "disconnect", "(", "cback", ",", "subscribers", "=", "self", ".", "subscribers", ",", "instance", "=", "self", ".", "instance", ")" ]
See signal
[ "See", "signal" ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L62-L66
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
InstanceProxy.get_subscribers
def get_subscribers(self): """Get per-instance subscribers from the signal. """ data = self.signal.instance_subscribers if self.instance not in data: data[self.instance] = MethodAwareWeakList() return data[self.instance]
python
def get_subscribers(self): """Get per-instance subscribers from the signal. """ data = self.signal.instance_subscribers if self.instance not in data: data[self.instance] = MethodAwareWeakList() return data[self.instance]
[ "def", "get_subscribers", "(", "self", ")", ":", "data", "=", "self", ".", "signal", ".", "instance_subscribers", "if", "self", ".", "instance", "not", "in", "data", ":", "data", "[", "self", ".", "instance", "]", "=", "MethodAwareWeakList", "(", ")", "r...
Get per-instance subscribers from the signal.
[ "Get", "per", "-", "instance", "subscribers", "from", "the", "signal", "." ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L68-L74
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
InstanceProxy.notify
def notify(self, *args, **kwargs): "See signal" loop = kwargs.pop('loop', self.loop) return self.signal.prepare_notification( subscribers=self.subscribers, instance=self.instance, loop=loop).run(*args, **kwargs)
python
def notify(self, *args, **kwargs): "See signal" loop = kwargs.pop('loop', self.loop) return self.signal.prepare_notification( subscribers=self.subscribers, instance=self.instance, loop=loop).run(*args, **kwargs)
[ "def", "notify", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "loop", "=", "kwargs", ".", "pop", "(", "'loop'", ",", "self", ".", "loop", ")", "return", "self", ".", "signal", ".", "prepare_notification", "(", "subscribers", "=",...
See signal
[ "See", "signal" ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L80-L85
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
InstanceProxy.notify_prepared
def notify_prepared(self, args=None, kwargs=None, **opts): """Like notify allows to pass more options to the underlying `Signal.prepare_notification()` method. The allowed options are: notify_external : bool a flag indicating if the notification should also include the ...
python
def notify_prepared(self, args=None, kwargs=None, **opts): """Like notify allows to pass more options to the underlying `Signal.prepare_notification()` method. The allowed options are: notify_external : bool a flag indicating if the notification should also include the ...
[ "def", "notify_prepared", "(", "self", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "*", "*", "opts", ")", ":", "if", "args", "is", "None", ":", "args", "=", "(", ")", "if", "kwargs", "is", "None", ":", "kwargs", "=", "{", "}", "l...
Like notify allows to pass more options to the underlying `Signal.prepare_notification()` method. The allowed options are: notify_external : bool a flag indicating if the notification should also include the registered `~.external.ExternalSignaller` in the notification. It'...
[ "Like", "notify", "allows", "to", "pass", "more", "options", "to", "the", "underlying", "Signal", ".", "prepare_notification", "()", "method", "." ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L89-L108
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
Signal.connect
def connect(self, cback, subscribers=None, instance=None): """Add a function or a method as an handler of this signal. Any handler added can be a coroutine. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wr...
python
def connect(self, cback, subscribers=None, instance=None): """Add a function or a method as an handler of this signal. Any handler added can be a coroutine. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wr...
[ "def", "connect", "(", "self", ",", "cback", ",", "subscribers", "=", "None", ",", "instance", "=", "None", ")", ":", "if", "subscribers", "is", "None", ":", "subscribers", "=", "self", ".", "subscribers", "# wrapper", "if", "self", ".", "_fconnect", "is...
Add a function or a method as an handler of this signal. Any handler added can be a coroutine. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wrapper
[ "Add", "a", "function", "or", "a", "method", "as", "an", "handler", "of", "this", "signal", ".", "Any", "handler", "added", "can", "be", "a", "coroutine", "." ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L233-L258
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
Signal.disconnect
def disconnect(self, cback, subscribers=None, instance=None): """Remove a previously added function or method from the set of the signal's handlers. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wrapper ...
python
def disconnect(self, cback, subscribers=None, instance=None): """Remove a previously added function or method from the set of the signal's handlers. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wrapper ...
[ "def", "disconnect", "(", "self", ",", "cback", ",", "subscribers", "=", "None", ",", "instance", "=", "None", ")", ":", "if", "subscribers", "is", "None", ":", "subscribers", "=", "self", ".", "subscribers", "# wrapper", "if", "self", ".", "_fdisconnect",...
Remove a previously added function or method from the set of the signal's handlers. :param cback: the callback (or *handler*) to be added to the set :returns: ``None`` or the value returned by the corresponding wrapper
[ "Remove", "a", "previously", "added", "function", "or", "method", "from", "the", "set", "of", "the", "signal", "s", "handlers", "." ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L264-L290
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
Signal.ext_publish
def ext_publish(self, instance, loop, *args, **kwargs): """If 'external_signaller' is defined, calls it's publish method to notify external event systems. This is for internal usage only, but it's doumented because it's part of the interface with external notification systems. "...
python
def ext_publish(self, instance, loop, *args, **kwargs): """If 'external_signaller' is defined, calls it's publish method to notify external event systems. This is for internal usage only, but it's doumented because it's part of the interface with external notification systems. "...
[ "def", "ext_publish", "(", "self", ",", "instance", ",", "loop", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "external_signaller", "is", "not", "None", ":", "# Assumes that the loop is managed by the external handler", "return", "self...
If 'external_signaller' is defined, calls it's publish method to notify external event systems. This is for internal usage only, but it's doumented because it's part of the interface with external notification systems.
[ "If", "external_signaller", "is", "defined", "calls", "it", "s", "publish", "method", "to", "notify", "external", "event", "systems", "." ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L292-L302
train
metapensiero/metapensiero.signal
src/metapensiero/signal/core.py
Signal.prepare_notification
def prepare_notification(self, *, subscribers=None, instance=None, loop=None, notify_external=True): """Sets up a and configures an `~.utils.Executor`:class: instance.""" # merge callbacks added to the class level with those added to the # instance, giving the former...
python
def prepare_notification(self, *, subscribers=None, instance=None, loop=None, notify_external=True): """Sets up a and configures an `~.utils.Executor`:class: instance.""" # merge callbacks added to the class level with those added to the # instance, giving the former...
[ "def", "prepare_notification", "(", "self", ",", "*", ",", "subscribers", "=", "None", ",", "instance", "=", "None", ",", "loop", "=", "None", ",", "notify_external", "=", "True", ")", ":", "# merge callbacks added to the class level with those added to the", "# ins...
Sets up a and configures an `~.utils.Executor`:class: instance.
[ "Sets", "up", "a", "and", "configures", "an", "~", ".", "utils", ".", "Executor", ":", "class", ":", "instance", "." ]
1cbbb2e4bff00bf4887163b08b70d278e472bfe3
https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/core.py#L339-L383
train
alefnula/tea
tea/logger/log.py
configure_logging
def configure_logging( filename=None, filemode="a", datefmt=FMT_DATE, fmt=FMT, stdout_fmt=FMT_STDOUT, level=logging.DEBUG, stdout_level=logging.WARNING, initial_file_message="", max_size=1048576, rotations_number=5, remove_handlers=True, ): """Configure logging module. ...
python
def configure_logging( filename=None, filemode="a", datefmt=FMT_DATE, fmt=FMT, stdout_fmt=FMT_STDOUT, level=logging.DEBUG, stdout_level=logging.WARNING, initial_file_message="", max_size=1048576, rotations_number=5, remove_handlers=True, ): """Configure logging module. ...
[ "def", "configure_logging", "(", "filename", "=", "None", ",", "filemode", "=", "\"a\"", ",", "datefmt", "=", "FMT_DATE", ",", "fmt", "=", "FMT", ",", "stdout_fmt", "=", "FMT_STDOUT", ",", "level", "=", "logging", ".", "DEBUG", ",", "stdout_level", "=", ...
Configure logging module. Args: filename (str): Specifies a filename to log to. filemode (str): Specifies the mode to open the log file. Values: ``'a'``, ``'w'``. *Default:* ``a``. datefmt (str): Use the specified date/time format. fmt (str): Format string for the file h...
[ "Configure", "logging", "module", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/logger/log.py#L31-L98
train
jonhadfield/creds
lib/creds/plan.py
create_plan
def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=None, manage_home=True, manage_keys=True): """Determine what changes are required. args: existing_users (Users): List of discovered users proposed_users (Use...
python
def create_plan(existing_users=None, proposed_users=None, purge_undefined=None, protected_users=None, allow_non_unique_id=None, manage_home=True, manage_keys=True): """Determine what changes are required. args: existing_users (Users): List of discovered users proposed_users (Use...
[ "def", "create_plan", "(", "existing_users", "=", "None", ",", "proposed_users", "=", "None", ",", "purge_undefined", "=", "None", ",", "protected_users", "=", "None", ",", "allow_non_unique_id", "=", "None", ",", "manage_home", "=", "True", ",", "manage_keys", ...
Determine what changes are required. args: existing_users (Users): List of discovered users proposed_users (Users): List of proposed users purge_undefined (bool): Remove discovered users that have not been defined in proposed users list protected_users (list): List of users' names t...
[ "Determine", "what", "changes", "are", "required", "." ]
b2053b43516cf742c6e4c2b79713bc625592f47c
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/plan.py#L13-L70
train
jonhadfield/creds
lib/creds/plan.py
execute_plan
def execute_plan(plan=None): """Create, Modify or Delete, depending on plan item.""" execution_result = list() for task in plan: action = task['action'] if action == 'delete': command = generate_delete_user_command(username=task.get('username'), manage_home=task['manage_home']) ...
python
def execute_plan(plan=None): """Create, Modify or Delete, depending on plan item.""" execution_result = list() for task in plan: action = task['action'] if action == 'delete': command = generate_delete_user_command(username=task.get('username'), manage_home=task['manage_home']) ...
[ "def", "execute_plan", "(", "plan", "=", "None", ")", ":", "execution_result", "=", "list", "(", ")", "for", "task", "in", "plan", ":", "action", "=", "task", "[", "'action'", "]", "if", "action", "==", "'delete'", ":", "command", "=", "generate_delete_u...
Create, Modify or Delete, depending on plan item.
[ "Create", "Modify", "or", "Delete", "depending", "on", "plan", "item", "." ]
b2053b43516cf742c6e4c2b79713bc625592f47c
https://github.com/jonhadfield/creds/blob/b2053b43516cf742c6e4c2b79713bc625592f47c/lib/creds/plan.py#L73-L113
train
night-crawler/django-docker-helpers
django_docker_helpers/config/backends/environment_parser.py
EnvironmentParser.get
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ Reads a value of ``variable_path`` from environment. If ``coerce_type``...
python
def get(self, variable_path: str, default: t.Optional[t.Any] = None, coerce_type: t.Optional[t.Type] = None, coercer: t.Optional[t.Callable] = None, **kwargs): """ Reads a value of ``variable_path`` from environment. If ``coerce_type``...
[ "def", "get", "(", "self", ",", "variable_path", ":", "str", ",", "default", ":", "t", ".", "Optional", "[", "t", ".", "Any", "]", "=", "None", ",", "coerce_type", ":", "t", ".", "Optional", "[", "t", ".", "Type", "]", "=", "None", ",", "coercer"...
Reads a value of ``variable_path`` from environment. If ``coerce_type`` is ``bool`` and no ``coercer`` specified, ``coerces`` forced to be :func:`~django_docker_helpers.utils.coerce_str_to_bool` :param variable_path: a delimiter-separated path to a nested value :param default: default ...
[ "Reads", "a", "value", "of", "variable_path", "from", "environment", "." ]
b64f8009101a8eb61d3841124ba19e3ab881aa2f
https://github.com/night-crawler/django-docker-helpers/blob/b64f8009101a8eb61d3841124ba19e3ab881aa2f/django_docker_helpers/config/backends/environment_parser.py#L69-L98
train
alefnula/tea
tea/utils/compress.py
unzip
def unzip(archive, destination, filenames=None): """Unzip a zip archive into destination directory. It unzips either the whole archive or specific file(s) from the archive. Usage: >>> output = os.path.join(os.getcwd(), 'output') >>> # Archive can be an instance of a ZipFile class >...
python
def unzip(archive, destination, filenames=None): """Unzip a zip archive into destination directory. It unzips either the whole archive or specific file(s) from the archive. Usage: >>> output = os.path.join(os.getcwd(), 'output') >>> # Archive can be an instance of a ZipFile class >...
[ "def", "unzip", "(", "archive", ",", "destination", ",", "filenames", "=", "None", ")", ":", "close", "=", "False", "try", ":", "if", "not", "isinstance", "(", "archive", ",", "zipfile", ".", "ZipFile", ")", ":", "archive", "=", "zipfile", ".", "ZipFil...
Unzip a zip archive into destination directory. It unzips either the whole archive or specific file(s) from the archive. Usage: >>> output = os.path.join(os.getcwd(), 'output') >>> # Archive can be an instance of a ZipFile class >>> archive = zipfile.ZipFile('test.zip', 'r') >>...
[ "Unzip", "a", "zip", "archive", "into", "destination", "directory", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/compress.py#L40-L89
train
alefnula/tea
tea/utils/compress.py
mkzip
def mkzip(archive, items, mode="w", save_full_paths=False): """Recursively zip a directory. Args: archive (zipfile.ZipFile or str): ZipFile object add to or path to the output zip archive. items (str or list of str): Single item or list of items (files and directories) t...
python
def mkzip(archive, items, mode="w", save_full_paths=False): """Recursively zip a directory. Args: archive (zipfile.ZipFile or str): ZipFile object add to or path to the output zip archive. items (str or list of str): Single item or list of items (files and directories) t...
[ "def", "mkzip", "(", "archive", ",", "items", ",", "mode", "=", "\"w\"", ",", "save_full_paths", "=", "False", ")", ":", "close", "=", "False", "try", ":", "if", "not", "isinstance", "(", "archive", ",", "zipfile", ".", "ZipFile", ")", ":", "archive", ...
Recursively zip a directory. Args: archive (zipfile.ZipFile or str): ZipFile object add to or path to the output zip archive. items (str or list of str): Single item or list of items (files and directories) to be added to zipfile. mode (str): w for create new and wri...
[ "Recursively", "zip", "a", "directory", "." ]
f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/compress.py#L92-L137
train