repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
RudolfCardinal/pythonlib
cardinal_pythonlib/sqlalchemy/alembic_ops.py
ReversibleOp._get_object_from_version
def _get_object_from_version(cls, operations, ident): """ Returns a Python object from an Alembic migration module (script). Args: operations: instance of ``alembic.operations.base.Operations`` ident: string of the format ``version.objname`` Returns: ...
python
def _get_object_from_version(cls, operations, ident): """ Returns a Python object from an Alembic migration module (script). Args: operations: instance of ``alembic.operations.base.Operations`` ident: string of the format ``version.objname`` Returns: ...
[ "def", "_get_object_from_version", "(", "cls", ",", "operations", ",", "ident", ")", ":", "version", ",", "objname", "=", "ident", ".", "split", "(", "\".\"", ")", "module_", "=", "operations", ".", "get_context", "(", ")", ".", "script", ".", "get_revisio...
Returns a Python object from an Alembic migration module (script). Args: operations: instance of ``alembic.operations.base.Operations`` ident: string of the format ``version.objname`` Returns: the object whose name is ``objname`` within the Alembic migration ...
[ "Returns", "a", "Python", "object", "from", "an", "Alembic", "migration", "module", "(", "script", ")", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sqlalchemy/alembic_ops.py#L110-L126
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
iso_string_to_python_datetime
def iso_string_to_python_datetime( isostring: str) -> Optional[datetime.datetime]: """ Takes an ISO-8601 string and returns a ``datetime``. """ if not isostring: return None # if you parse() an empty string, you get today's date return dateutil.parser.parse(isostring)
python
def iso_string_to_python_datetime( isostring: str) -> Optional[datetime.datetime]: """ Takes an ISO-8601 string and returns a ``datetime``. """ if not isostring: return None # if you parse() an empty string, you get today's date return dateutil.parser.parse(isostring)
[ "def", "iso_string_to_python_datetime", "(", "isostring", ":", "str", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "if", "not", "isostring", ":", "return", "None", "# if you parse() an empty string, you get today's date", "return", "dateutil", "....
Takes an ISO-8601 string and returns a ``datetime``.
[ "Takes", "an", "ISO", "-", "8601", "string", "and", "returns", "a", "datetime", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L52-L59
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
python_utc_datetime_to_sqlite_strftime_string
def python_utc_datetime_to_sqlite_strftime_string( value: datetime.datetime) -> str: """ Converts a Python datetime to a string literal compatible with SQLite, including the millisecond field. """ millisec_str = str(round(value.microsecond / 1000)).zfill(3) return value.strftime("%Y-%m-%...
python
def python_utc_datetime_to_sqlite_strftime_string( value: datetime.datetime) -> str: """ Converts a Python datetime to a string literal compatible with SQLite, including the millisecond field. """ millisec_str = str(round(value.microsecond / 1000)).zfill(3) return value.strftime("%Y-%m-%...
[ "def", "python_utc_datetime_to_sqlite_strftime_string", "(", "value", ":", "datetime", ".", "datetime", ")", "->", "str", ":", "millisec_str", "=", "str", "(", "round", "(", "value", ".", "microsecond", "/", "1000", ")", ")", ".", "zfill", "(", "3", ")", "...
Converts a Python datetime to a string literal compatible with SQLite, including the millisecond field.
[ "Converts", "a", "Python", "datetime", "to", "a", "string", "literal", "compatible", "with", "SQLite", "including", "the", "millisecond", "field", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L62-L69
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
python_localized_datetime_to_human_iso
def python_localized_datetime_to_human_iso(value: datetime.datetime) -> str: """ Converts a Python ``datetime`` that has a timezone to an ISO-8601 string with ``:`` between the hours and minutes of the timezone. Example: >>> import datetime >>> import pytz >>> x = datetime.datet...
python
def python_localized_datetime_to_human_iso(value: datetime.datetime) -> str: """ Converts a Python ``datetime`` that has a timezone to an ISO-8601 string with ``:`` between the hours and minutes of the timezone. Example: >>> import datetime >>> import pytz >>> x = datetime.datet...
[ "def", "python_localized_datetime_to_human_iso", "(", "value", ":", "datetime", ".", "datetime", ")", "->", "str", ":", "s", "=", "value", ".", "strftime", "(", "\"%Y-%m-%dT%H:%M:%S.%f%z\"", ")", "return", "s", "[", ":", "29", "]", "+", "\":\"", "+", "s", ...
Converts a Python ``datetime`` that has a timezone to an ISO-8601 string with ``:`` between the hours and minutes of the timezone. Example: >>> import datetime >>> import pytz >>> x = datetime.datetime.now(pytz.utc) >>> python_localized_datetime_to_human_iso(x) '2017-08-...
[ "Converts", "a", "Python", "datetime", "that", "has", "a", "timezone", "to", "an", "ISO", "-", "8601", "string", "with", ":", "between", "the", "hours", "and", "minutes", "of", "the", "timezone", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L72-L85
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
isodt_lookup_mysql
def isodt_lookup_mysql(lookup, compiler, connection, operator) -> Tuple[str, Any]: """ For a comparison "LHS *op* RHS", transforms the LHS from a column containing an ISO-8601 date/time into an SQL ``DATETIME``, for MySQL. """ lhs, lhs_params = compiler.compile(lookup.lhs)...
python
def isodt_lookup_mysql(lookup, compiler, connection, operator) -> Tuple[str, Any]: """ For a comparison "LHS *op* RHS", transforms the LHS from a column containing an ISO-8601 date/time into an SQL ``DATETIME``, for MySQL. """ lhs, lhs_params = compiler.compile(lookup.lhs)...
[ "def", "isodt_lookup_mysql", "(", "lookup", ",", "compiler", ",", "connection", ",", "operator", ")", "->", "Tuple", "[", "str", ",", "Any", "]", ":", "lhs", ",", "lhs_params", "=", "compiler", ".", "compile", "(", "lookup", ".", "lhs", ")", "rhs", ","...
For a comparison "LHS *op* RHS", transforms the LHS from a column containing an ISO-8601 date/time into an SQL ``DATETIME``, for MySQL.
[ "For", "a", "comparison", "LHS", "*", "op", "*", "RHS", "transforms", "the", "LHS", "from", "a", "column", "containing", "an", "ISO", "-", "8601", "date", "/", "time", "into", "an", "SQL", "DATETIME", "for", "MySQL", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L409-L423
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
IsoDateTimeTzField.deconstruct
def deconstruct(self) -> Tuple[str, str, List[Any], Dict[str, Any]]: """ Takes an instance and calculates the arguments to pass to ``__init__`` to reconstruct it. """ name, path, args, kwargs = super().deconstruct() del kwargs['max_length'] return name, path, args...
python
def deconstruct(self) -> Tuple[str, str, List[Any], Dict[str, Any]]: """ Takes an instance and calculates the arguments to pass to ``__init__`` to reconstruct it. """ name, path, args, kwargs = super().deconstruct() del kwargs['max_length'] return name, path, args...
[ "def", "deconstruct", "(", "self", ")", "->", "Tuple", "[", "str", ",", "str", ",", "List", "[", "Any", "]", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "name", ",", "path", ",", "args", ",", "kwargs", "=", "super", "(", ")", ".", "de...
Takes an instance and calculates the arguments to pass to ``__init__`` to reconstruct it.
[ "Takes", "an", "instance", "and", "calculates", "the", "arguments", "to", "pass", "to", "__init__", "to", "reconstruct", "it", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L196-L203
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
IsoDateTimeTzField.from_db_value
def from_db_value(self, value, expression, connection, context): """ Convert database value to Python value. Called when data is loaded from the database. """ # log.debug("from_db_value: {}, {}", value, type(value)) if value is None: return value if va...
python
def from_db_value(self, value, expression, connection, context): """ Convert database value to Python value. Called when data is loaded from the database. """ # log.debug("from_db_value: {}, {}", value, type(value)) if value is None: return value if va...
[ "def", "from_db_value", "(", "self", ",", "value", ",", "expression", ",", "connection", ",", "context", ")", ":", "# log.debug(\"from_db_value: {}, {}\", value, type(value))", "if", "value", "is", "None", ":", "return", "value", "if", "value", "==", "''", ":", ...
Convert database value to Python value. Called when data is loaded from the database.
[ "Convert", "database", "value", "to", "Python", "value", ".", "Called", "when", "data", "is", "loaded", "from", "the", "database", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L206-L216
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
IsoDateTimeTzField.to_python
def to_python(self, value: Optional[str]) -> Optional[Any]: """ Called during deserialization and during form ``clean()`` calls. Must deal with an instance of the correct type; a string; or ``None`` (if the field allows ``null=True``). Should raise ``ValidationError`` if problems...
python
def to_python(self, value: Optional[str]) -> Optional[Any]: """ Called during deserialization and during form ``clean()`` calls. Must deal with an instance of the correct type; a string; or ``None`` (if the field allows ``null=True``). Should raise ``ValidationError`` if problems...
[ "def", "to_python", "(", "self", ",", "value", ":", "Optional", "[", "str", "]", ")", "->", "Optional", "[", "Any", "]", ":", "# https://docs.djangoproject.com/en/1.8/howto/custom-model-fields/", "# log.debug(\"to_python: {}, {}\", value, type(value))", "if", "isinstance", ...
Called during deserialization and during form ``clean()`` calls. Must deal with an instance of the correct type; a string; or ``None`` (if the field allows ``null=True``). Should raise ``ValidationError`` if problems.
[ "Called", "during", "deserialization", "and", "during", "form", "clean", "()", "calls", ".", "Must", "deal", "with", "an", "instance", "of", "the", "correct", "type", ";", "a", "string", ";", "or", "None", "(", "if", "the", "field", "allows", "null", "="...
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L218-L233
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
IsoDateTimeTzField.get_prep_value
def get_prep_value(self, value): """ Convert Python value to database value for QUERYING. We query with UTC, so this function converts datetime values to UTC. Calls to this function are followed by calls to ``get_db_prep_value()``, which is for backend-specific conversions. ...
python
def get_prep_value(self, value): """ Convert Python value to database value for QUERYING. We query with UTC, so this function converts datetime values to UTC. Calls to this function are followed by calls to ``get_db_prep_value()``, which is for backend-specific conversions. ...
[ "def", "get_prep_value", "(", "self", ",", "value", ")", ":", "log", ".", "debug", "(", "\"get_prep_value: {}, {}\"", ",", "value", ",", "type", "(", "value", ")", ")", "if", "not", "value", ":", "return", "''", "# For underlying (database) string types, e.g. VA...
Convert Python value to database value for QUERYING. We query with UTC, so this function converts datetime values to UTC. Calls to this function are followed by calls to ``get_db_prep_value()``, which is for backend-specific conversions.
[ "Convert", "Python", "value", "to", "database", "value", "for", "QUERYING", ".", "We", "query", "with", "UTC", "so", "this", "function", "converts", "datetime", "values", "to", "UTC", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L235-L250
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
IsoDateTimeTzField.get_db_prep_value
def get_db_prep_value(self, value, connection, prepared=False): """ Further conversion of Python value to database value for QUERYING. This follows ``get_prep_value()``, and is for backend-specific stuff. See notes above. """ log.debug("get_db_prep_value: {}, {}", value, ...
python
def get_db_prep_value(self, value, connection, prepared=False): """ Further conversion of Python value to database value for QUERYING. This follows ``get_prep_value()``, and is for backend-specific stuff. See notes above. """ log.debug("get_db_prep_value: {}, {}", value, ...
[ "def", "get_db_prep_value", "(", "self", ",", "value", ",", "connection", ",", "prepared", "=", "False", ")", ":", "log", ".", "debug", "(", "\"get_db_prep_value: {}, {}\"", ",", "value", ",", "type", "(", "value", ")", ")", "value", "=", "super", "(", "...
Further conversion of Python value to database value for QUERYING. This follows ``get_prep_value()``, and is for backend-specific stuff. See notes above.
[ "Further", "conversion", "of", "Python", "value", "to", "database", "value", "for", "QUERYING", ".", "This", "follows", "get_prep_value", "()", "and", "is", "for", "backend", "-", "specific", "stuff", ".", "See", "notes", "above", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L252-L266
RudolfCardinal/pythonlib
cardinal_pythonlib/django/fields/isodatetimetz.py
IsoDateTimeTzField.get_db_prep_save
def get_db_prep_save(self, value, connection, prepared=False): """ Convert Python value to database value for SAVING. We save with full timezone information. """ log.debug("get_db_prep_save: {}, {}", value, type(value)) if not value: return '' # Fo...
python
def get_db_prep_save(self, value, connection, prepared=False): """ Convert Python value to database value for SAVING. We save with full timezone information. """ log.debug("get_db_prep_save: {}, {}", value, type(value)) if not value: return '' # Fo...
[ "def", "get_db_prep_save", "(", "self", ",", "value", ",", "connection", ",", "prepared", "=", "False", ")", ":", "log", ".", "debug", "(", "\"get_db_prep_save: {}, {}\"", ",", "value", ",", "type", "(", "value", ")", ")", "if", "not", "value", ":", "ret...
Convert Python value to database value for SAVING. We save with full timezone information.
[ "Convert", "Python", "value", "to", "database", "value", "for", "SAVING", ".", "We", "save", "with", "full", "timezone", "information", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/django/fields/isodatetimetz.py#L268-L279
RudolfCardinal/pythonlib
cardinal_pythonlib/tools/list_all_file_extensions.py
list_file_extensions
def list_file_extensions(path: str, reportevery: int = 1) -> List[str]: """ Returns a sorted list of every file extension found in a directory and its subdirectories. Args: path: path to scan reportevery: report directory progress after every *n* steps Returns: sorted list ...
python
def list_file_extensions(path: str, reportevery: int = 1) -> List[str]: """ Returns a sorted list of every file extension found in a directory and its subdirectories. Args: path: path to scan reportevery: report directory progress after every *n* steps Returns: sorted list ...
[ "def", "list_file_extensions", "(", "path", ":", "str", ",", "reportevery", ":", "int", "=", "1", ")", "->", "List", "[", "str", "]", ":", "extensions", "=", "set", "(", ")", "count", "=", "0", "for", "root", ",", "dirs", ",", "files", "in", "os", ...
Returns a sorted list of every file extension found in a directory and its subdirectories. Args: path: path to scan reportevery: report directory progress after every *n* steps Returns: sorted list of every file extension found
[ "Returns", "a", "sorted", "list", "of", "every", "file", "extension", "found", "in", "a", "directory", "and", "its", "subdirectories", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/tools/list_all_file_extensions.py#L43-L65
RudolfCardinal/pythonlib
cardinal_pythonlib/tools/list_all_file_extensions.py
main
def main() -> None: """ Command-line processor. See ``--help`` for details. """ main_only_quicksetup_rootlogger(level=logging.DEBUG) parser = argparse.ArgumentParser() parser.add_argument("directory", nargs="?", default=os.getcwd()) parser.add_argument("--reportevery", default=10000) arg...
python
def main() -> None: """ Command-line processor. See ``--help`` for details. """ main_only_quicksetup_rootlogger(level=logging.DEBUG) parser = argparse.ArgumentParser() parser.add_argument("directory", nargs="?", default=os.getcwd()) parser.add_argument("--reportevery", default=10000) arg...
[ "def", "main", "(", ")", "->", "None", ":", "main_only_quicksetup_rootlogger", "(", "level", "=", "logging", ".", "DEBUG", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"directory\"", ",", "nargs", "="...
Command-line processor. See ``--help`` for details.
[ "Command", "-", "line", "processor", ".", "See", "--", "help", "for", "details", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/tools/list_all_file_extensions.py#L68-L80
RudolfCardinal/pythonlib
cardinal_pythonlib/platformfunc.py
are_debian_packages_installed
def are_debian_packages_installed(packages: List[str]) -> Dict[str, bool]: """ Check which of a list of Debian packages are installed, via ``dpkg-query``. Args: packages: list of Debian package names Returns: dict: mapping from package name to boolean ("present?") """ assert l...
python
def are_debian_packages_installed(packages: List[str]) -> Dict[str, bool]: """ Check which of a list of Debian packages are installed, via ``dpkg-query``. Args: packages: list of Debian package names Returns: dict: mapping from package name to boolean ("present?") """ assert l...
[ "def", "are_debian_packages_installed", "(", "packages", ":", "List", "[", "str", "]", ")", "->", "Dict", "[", "str", ",", "bool", "]", ":", "assert", "len", "(", "packages", ")", ">=", "1", "require_executable", "(", "DPKG_QUERY", ")", "args", "=", "[",...
Check which of a list of Debian packages are installed, via ``dpkg-query``. Args: packages: list of Debian package names Returns: dict: mapping from package name to boolean ("present?")
[ "Check", "which", "of", "a", "list", "of", "Debian", "packages", "are", "installed", "via", "dpkg", "-", "query", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/platformfunc.py#L104-L144
RudolfCardinal/pythonlib
cardinal_pythonlib/platformfunc.py
require_debian_packages
def require_debian_packages(packages: List[str]) -> None: """ Ensure specific packages are installed under Debian. Args: packages: list of packages Raises: ValueError: if any are missing """ present = are_debian_packages_installed(packages) missing_packages = [k for k, v i...
python
def require_debian_packages(packages: List[str]) -> None: """ Ensure specific packages are installed under Debian. Args: packages: list of packages Raises: ValueError: if any are missing """ present = are_debian_packages_installed(packages) missing_packages = [k for k, v i...
[ "def", "require_debian_packages", "(", "packages", ":", "List", "[", "str", "]", ")", "->", "None", ":", "present", "=", "are_debian_packages_installed", "(", "packages", ")", "missing_packages", "=", "[", "k", "for", "k", ",", "v", "in", "present", ".", "...
Ensure specific packages are installed under Debian. Args: packages: list of packages Raises: ValueError: if any are missing
[ "Ensure", "specific", "packages", "are", "installed", "under", "Debian", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/platformfunc.py#L147-L167
RudolfCardinal/pythonlib
cardinal_pythonlib/platformfunc.py
validate_pair
def validate_pair(ob: Any) -> bool: """ Does the object have length 2? """ try: if len(ob) != 2: log.warning("Unexpected result: {!r}", ob) raise ValueError() except ValueError: return False return True
python
def validate_pair(ob: Any) -> bool: """ Does the object have length 2? """ try: if len(ob) != 2: log.warning("Unexpected result: {!r}", ob) raise ValueError() except ValueError: return False return True
[ "def", "validate_pair", "(", "ob", ":", "Any", ")", "->", "bool", ":", "try", ":", "if", "len", "(", "ob", ")", "!=", "2", ":", "log", ".", "warning", "(", "\"Unexpected result: {!r}\"", ",", "ob", ")", "raise", "ValueError", "(", ")", "except", "Val...
Does the object have length 2?
[ "Does", "the", "object", "have", "length", "2?" ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/platformfunc.py#L174-L184
RudolfCardinal/pythonlib
cardinal_pythonlib/platformfunc.py
windows_get_environment_from_batch_command
def windows_get_environment_from_batch_command( env_cmd: Union[str, List[str]], initial_env: Dict[str, str] = None) -> Dict[str, str]: """ Take a command (either a single command or list of arguments) and return the environment created after running that command. Note that the command mu...
python
def windows_get_environment_from_batch_command( env_cmd: Union[str, List[str]], initial_env: Dict[str, str] = None) -> Dict[str, str]: """ Take a command (either a single command or list of arguments) and return the environment created after running that command. Note that the command mu...
[ "def", "windows_get_environment_from_batch_command", "(", "env_cmd", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", ",", "initial_env", ":", "Dict", "[", "str", ",", "str", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "str", "]",...
Take a command (either a single command or list of arguments) and return the environment created after running that command. Note that the command must be a batch (``.bat``) file or ``.cmd`` file, or the changes to the environment will not be captured. If ``initial_env`` is supplied, it is used as the ...
[ "Take", "a", "command", "(", "either", "a", "single", "command", "or", "list", "of", "arguments", ")", "and", "return", "the", "environment", "created", "after", "running", "that", "command", ".", "Note", "that", "the", "command", "must", "be", "a", "batch...
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/platformfunc.py#L201-L286
RudolfCardinal/pythonlib
cardinal_pythonlib/platformfunc.py
contains_unquoted_target
def contains_unquoted_target(x: str, quote: str = '"', target: str = '&') -> bool: """ Checks if ``target`` exists in ``x`` outside quotes (as defined by ``quote``). Principal use: from :func:`contains_unquoted_ampersand_dangerous_to_windows`. """ in_quote = False ...
python
def contains_unquoted_target(x: str, quote: str = '"', target: str = '&') -> bool: """ Checks if ``target`` exists in ``x`` outside quotes (as defined by ``quote``). Principal use: from :func:`contains_unquoted_ampersand_dangerous_to_windows`. """ in_quote = False ...
[ "def", "contains_unquoted_target", "(", "x", ":", "str", ",", "quote", ":", "str", "=", "'\"'", ",", "target", ":", "str", "=", "'&'", ")", "->", "bool", ":", "in_quote", "=", "False", "for", "c", "in", "x", ":", "if", "c", "==", "quote", ":", "i...
Checks if ``target`` exists in ``x`` outside quotes (as defined by ``quote``). Principal use: from :func:`contains_unquoted_ampersand_dangerous_to_windows`.
[ "Checks", "if", "target", "exists", "in", "x", "outside", "quotes", "(", "as", "defined", "by", "quote", ")", ".", "Principal", "use", ":", "from", ":", "func", ":", "contains_unquoted_ampersand_dangerous_to_windows", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/platformfunc.py#L293-L307
RudolfCardinal/pythonlib
cardinal_pythonlib/email/mailboxpurge.py
gut_message
def gut_message(message: Message) -> Message: """ Remove body from a message, and wrap in a message/external-body. """ wrapper = Message() wrapper.add_header('Content-Type', 'message/external-body', access_type='x-spam-deleted', expiration=time.strftime(...
python
def gut_message(message: Message) -> Message: """ Remove body from a message, and wrap in a message/external-body. """ wrapper = Message() wrapper.add_header('Content-Type', 'message/external-body', access_type='x-spam-deleted', expiration=time.strftime(...
[ "def", "gut_message", "(", "message", ":", "Message", ")", "->", "Message", ":", "wrapper", "=", "Message", "(", ")", "wrapper", ".", "add_header", "(", "'Content-Type'", ",", "'message/external-body'", ",", "access_type", "=", "'x-spam-deleted'", ",", "expirati...
Remove body from a message, and wrap in a message/external-body.
[ "Remove", "body", "from", "a", "message", "and", "wrap", "in", "a", "message", "/", "external", "-", "body", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/email/mailboxpurge.py#L57-L70
RudolfCardinal/pythonlib
cardinal_pythonlib/email/mailboxpurge.py
clean_message
def clean_message(message: Message, topmost: bool = False) -> Message: """ Clean a message of all its binary parts. This guts all binary attachments, and returns the message itself for convenience. """ if message.is_multipart(): # Don't recurse in already-deleted attachments if...
python
def clean_message(message: Message, topmost: bool = False) -> Message: """ Clean a message of all its binary parts. This guts all binary attachments, and returns the message itself for convenience. """ if message.is_multipart(): # Don't recurse in already-deleted attachments if...
[ "def", "clean_message", "(", "message", ":", "Message", ",", "topmost", ":", "bool", "=", "False", ")", "->", "Message", ":", "if", "message", ".", "is_multipart", "(", ")", ":", "# Don't recurse in already-deleted attachments", "if", "message", ".", "get_conten...
Clean a message of all its binary parts. This guts all binary attachments, and returns the message itself for convenience.
[ "Clean", "a", "message", "of", "all", "its", "binary", "parts", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/email/mailboxpurge.py#L80-L98
RudolfCardinal/pythonlib
cardinal_pythonlib/crypto.py
hash_password
def hash_password(plaintextpw: str, log_rounds: int = BCRYPT_DEFAULT_LOG_ROUNDS) -> str: """ Makes a hashed password (using a new salt) using ``bcrypt``. The hashed password includes the salt at its start, so no need to store a separate salt. """ salt = bcrypt.gensalt(log_roun...
python
def hash_password(plaintextpw: str, log_rounds: int = BCRYPT_DEFAULT_LOG_ROUNDS) -> str: """ Makes a hashed password (using a new salt) using ``bcrypt``. The hashed password includes the salt at its start, so no need to store a separate salt. """ salt = bcrypt.gensalt(log_roun...
[ "def", "hash_password", "(", "plaintextpw", ":", "str", ",", "log_rounds", ":", "int", "=", "BCRYPT_DEFAULT_LOG_ROUNDS", ")", "->", "str", ":", "salt", "=", "bcrypt", ".", "gensalt", "(", "log_rounds", ")", "# optional parameter governs complexity", "hashedpw", "=...
Makes a hashed password (using a new salt) using ``bcrypt``. The hashed password includes the salt at its start, so no need to store a separate salt.
[ "Makes", "a", "hashed", "password", "(", "using", "a", "new", "salt", ")", "using", "bcrypt", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/crypto.py#L43-L53
RudolfCardinal/pythonlib
cardinal_pythonlib/crypto.py
is_password_valid
def is_password_valid(plaintextpw: str, storedhash: str) -> bool: """ Checks if a plaintext password matches a stored hash. Uses ``bcrypt``. The stored hash includes its own incorporated salt. """ # Upon CamCOPS from MySQL 5.5.34 (Ubuntu) to 5.1.71 (CentOS 6.5), the # VARCHAR was retrieved as U...
python
def is_password_valid(plaintextpw: str, storedhash: str) -> bool: """ Checks if a plaintext password matches a stored hash. Uses ``bcrypt``. The stored hash includes its own incorporated salt. """ # Upon CamCOPS from MySQL 5.5.34 (Ubuntu) to 5.1.71 (CentOS 6.5), the # VARCHAR was retrieved as U...
[ "def", "is_password_valid", "(", "plaintextpw", ":", "str", ",", "storedhash", ":", "str", ")", "->", "bool", ":", "# Upon CamCOPS from MySQL 5.5.34 (Ubuntu) to 5.1.71 (CentOS 6.5), the", "# VARCHAR was retrieved as Unicode. We needed to convert that to a str.", "# For Python 3 compa...
Checks if a plaintext password matches a stored hash. Uses ``bcrypt``. The stored hash includes its own incorporated salt.
[ "Checks", "if", "a", "plaintext", "password", "matches", "a", "stored", "hash", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/crypto.py#L56-L76
RudolfCardinal/pythonlib
cardinal_pythonlib/register_db_with_odbc.py
create_sys_dsn
def create_sys_dsn(driver: str, **kw) -> bool: """ (Windows only.) Create a system ODBC data source name (DSN). Args: driver: ODBC driver name kw: Driver attributes Returns: bool: was the DSN created? """ attributes = [] # type: List[str] for attr in kw.keys():...
python
def create_sys_dsn(driver: str, **kw) -> bool: """ (Windows only.) Create a system ODBC data source name (DSN). Args: driver: ODBC driver name kw: Driver attributes Returns: bool: was the DSN created? """ attributes = [] # type: List[str] for attr in kw.keys():...
[ "def", "create_sys_dsn", "(", "driver", ":", "str", ",", "*", "*", "kw", ")", "->", "bool", ":", "attributes", "=", "[", "]", "# type: List[str]", "for", "attr", "in", "kw", ".", "keys", "(", ")", ":", "attributes", ".", "append", "(", "\"%s=%s\"", "...
(Windows only.) Create a system ODBC data source name (DSN). Args: driver: ODBC driver name kw: Driver attributes Returns: bool: was the DSN created?
[ "(", "Windows", "only", ".", ")", "Create", "a", "system", "ODBC", "data", "source", "name", "(", "DSN", ")", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/register_db_with_odbc.py#L79-L98
RudolfCardinal/pythonlib
cardinal_pythonlib/register_db_with_odbc.py
create_user_dsn
def create_user_dsn(driver: str, **kw) -> bool: """ (Windows only.) Create a user ODBC data source name (DSN). Args: driver: ODBC driver name kw: Driver attributes Returns: bool: was the DSN created? """ attributes = [] # type: List[str] for attr in kw.keys(): ...
python
def create_user_dsn(driver: str, **kw) -> bool: """ (Windows only.) Create a user ODBC data source name (DSN). Args: driver: ODBC driver name kw: Driver attributes Returns: bool: was the DSN created? """ attributes = [] # type: List[str] for attr in kw.keys(): ...
[ "def", "create_user_dsn", "(", "driver", ":", "str", ",", "*", "*", "kw", ")", "->", "bool", ":", "attributes", "=", "[", "]", "# type: List[str]", "for", "attr", "in", "kw", ".", "keys", "(", ")", ":", "attributes", ".", "append", "(", "\"%s=%s\"", ...
(Windows only.) Create a user ODBC data source name (DSN). Args: driver: ODBC driver name kw: Driver attributes Returns: bool: was the DSN created?
[ "(", "Windows", "only", ".", ")", "Create", "a", "user", "ODBC", "data", "source", "name", "(", "DSN", ")", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/register_db_with_odbc.py#L101-L119
RudolfCardinal/pythonlib
cardinal_pythonlib/register_db_with_odbc.py
register_access_db
def register_access_db(fullfilename: str, dsn: str, description: str) -> bool: """ (Windows only.) Registers a Microsoft Access database with ODBC. Args: fullfilename: filename of the existing database dsn: ODBC data source name to create description: description of the database...
python
def register_access_db(fullfilename: str, dsn: str, description: str) -> bool: """ (Windows only.) Registers a Microsoft Access database with ODBC. Args: fullfilename: filename of the existing database dsn: ODBC data source name to create description: description of the database...
[ "def", "register_access_db", "(", "fullfilename", ":", "str", ",", "dsn", ":", "str", ",", "description", ":", "str", ")", "->", "bool", ":", "directory", "=", "os", ".", "path", ".", "dirname", "(", "fullfilename", ")", "return", "create_sys_dsn", "(", ...
(Windows only.) Registers a Microsoft Access database with ODBC. Args: fullfilename: filename of the existing database dsn: ODBC data source name to create description: description of the database Returns: bool: was the DSN created?
[ "(", "Windows", "only", ".", ")", "Registers", "a", "Microsoft", "Access", "database", "with", "ODBC", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/register_db_with_odbc.py#L122-L144
RudolfCardinal/pythonlib
cardinal_pythonlib/register_db_with_odbc.py
create_and_register_access97_db
def create_and_register_access97_db(filename: str, dsn: str, description: str) -> bool: """ (Windows only.) Creates a Microsoft Access 97 database and registers it with ODBC. Args: filename: filename of the database to crea...
python
def create_and_register_access97_db(filename: str, dsn: str, description: str) -> bool: """ (Windows only.) Creates a Microsoft Access 97 database and registers it with ODBC. Args: filename: filename of the database to crea...
[ "def", "create_and_register_access97_db", "(", "filename", ":", "str", ",", "dsn", ":", "str", ",", "description", ":", "str", ")", "->", "bool", ":", "fullfilename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "create_string", "=", "full...
(Windows only.) Creates a Microsoft Access 97 database and registers it with ODBC. Args: filename: filename of the database to create dsn: ODBC data source name to create description: description of the database Returns: bool: was the DSN created?
[ "(", "Windows", "only", ".", ")", "Creates", "a", "Microsoft", "Access", "97", "database", "and", "registers", "it", "with", "ODBC", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/register_db_with_odbc.py#L147-L166
RudolfCardinal/pythonlib
cardinal_pythonlib/register_db_with_odbc.py
create_and_register_access2000_db
def create_and_register_access2000_db(filename: str, dsn: str, description: str) -> bool: """ (Windows only.) Creates a Microsoft Access 2000 database and registers it with ODBC. Args: filename: filename of the database...
python
def create_and_register_access2000_db(filename: str, dsn: str, description: str) -> bool: """ (Windows only.) Creates a Microsoft Access 2000 database and registers it with ODBC. Args: filename: filename of the database...
[ "def", "create_and_register_access2000_db", "(", "filename", ":", "str", ",", "dsn", ":", "str", ",", "description", ":", "str", ")", "->", "bool", ":", "fullfilename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "create_string", "=", "fu...
(Windows only.) Creates a Microsoft Access 2000 database and registers it with ODBC. Args: filename: filename of the database to create dsn: ODBC data source name to create description: description of the database Returns: bool: was the DSN created?
[ "(", "Windows", "only", ".", ")", "Creates", "a", "Microsoft", "Access", "2000", "database", "and", "registers", "it", "with", "ODBC", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/register_db_with_odbc.py#L169-L188
RudolfCardinal/pythonlib
cardinal_pythonlib/register_db_with_odbc.py
create_and_register_access_db
def create_and_register_access_db(filename: str, dsn: str, description: str) -> bool: """ (Windows only.) Creates a Microsoft Access database and registers it with ODBC. Args: filename: filename of the database to create ...
python
def create_and_register_access_db(filename: str, dsn: str, description: str) -> bool: """ (Windows only.) Creates a Microsoft Access database and registers it with ODBC. Args: filename: filename of the database to create ...
[ "def", "create_and_register_access_db", "(", "filename", ":", "str", ",", "dsn", ":", "str", ",", "description", ":", "str", ")", "->", "bool", ":", "fullfilename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "create_string", "=", "fullfi...
(Windows only.) Creates a Microsoft Access database and registers it with ODBC. Args: filename: filename of the database to create dsn: ODBC data source name to create description: description of the database Returns: bool: was the DSN created?
[ "(", "Windows", "only", ".", ")", "Creates", "a", "Microsoft", "Access", "database", "and", "registers", "it", "with", "ODBC", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/register_db_with_odbc.py#L191-L210
JohnVinyard/featureflow
featureflow/extractor.py
Node._finalized
def _finalized(self): """ Return true if all dependencies have informed this node that they'll be sending no more data (by calling _finalize()), and that they have sent at least one batch of data (by calling enqueue()) """ return \ len(self._finalized_dependen...
python
def _finalized(self): """ Return true if all dependencies have informed this node that they'll be sending no more data (by calling _finalize()), and that they have sent at least one batch of data (by calling enqueue()) """ return \ len(self._finalized_dependen...
[ "def", "_finalized", "(", "self", ")", ":", "return", "len", "(", "self", ".", "_finalized_dependencies", ")", ">=", "self", ".", "dependency_count", "and", "len", "(", "self", ".", "_enqueued_dependencies", ")", ">=", "self", ".", "dependency_count" ]
Return true if all dependencies have informed this node that they'll be sending no more data (by calling _finalize()), and that they have sent at least one batch of data (by calling enqueue())
[ "Return", "true", "if", "all", "dependencies", "have", "informed", "this", "node", "that", "they", "ll", "be", "sending", "no", "more", "data", "(", "by", "calling", "_finalize", "()", ")", "and", "that", "they", "have", "sent", "at", "least", "one", "ba...
train
https://github.com/JohnVinyard/featureflow/blob/7731487b00e38fa4f58c88b7881870fda2d69fdb/featureflow/extractor.py#L118-L126
JohnVinyard/featureflow
featureflow/extractor.py
FunctionalNode.version
def version(self): """ Compute the version identifier for this functional node using the func code and local names. Optionally, also allow closed-over variable values to affect the version number when closure_fingerprint is specified """ try: f = self...
python
def version(self): """ Compute the version identifier for this functional node using the func code and local names. Optionally, also allow closed-over variable values to affect the version number when closure_fingerprint is specified """ try: f = self...
[ "def", "version", "(", "self", ")", ":", "try", ":", "f", "=", "self", ".", "func", ".", "__call__", ".", "__code__", "except", "AttributeError", ":", "f", "=", "self", ".", "func", ".", "__code__", "h", "=", "md5", "(", ")", "h", ".", "update", ...
Compute the version identifier for this functional node using the func code and local names. Optionally, also allow closed-over variable values to affect the version number when closure_fingerprint is specified
[ "Compute", "the", "version", "identifier", "for", "this", "functional", "node", "using", "the", "func", "code", "and", "local", "names", ".", "Optionally", "also", "allow", "closed", "-", "over", "variable", "values", "to", "affect", "the", "version", "number"...
train
https://github.com/JohnVinyard/featureflow/blob/7731487b00e38fa4f58c88b7881870fda2d69fdb/featureflow/extractor.py#L189-L218
RudolfCardinal/pythonlib
cardinal_pythonlib/sqlalchemy/orm_schema.py
create_table_from_orm_class
def create_table_from_orm_class(engine: Engine, ormclass: DeclarativeMeta, without_constraints: bool = False) -> None: """ From an SQLAlchemy ORM class, creates the database table via the specified engine, using a ``CREATE TABLE`` SQL (DDL) sta...
python
def create_table_from_orm_class(engine: Engine, ormclass: DeclarativeMeta, without_constraints: bool = False) -> None: """ From an SQLAlchemy ORM class, creates the database table via the specified engine, using a ``CREATE TABLE`` SQL (DDL) sta...
[ "def", "create_table_from_orm_class", "(", "engine", ":", "Engine", ",", "ormclass", ":", "DeclarativeMeta", ",", "without_constraints", ":", "bool", "=", "False", ")", "->", "None", ":", "table", "=", "ormclass", ".", "__table__", "# type: Table", "log", ".", ...
From an SQLAlchemy ORM class, creates the database table via the specified engine, using a ``CREATE TABLE`` SQL (DDL) statement. Args: engine: SQLAlchemy :class:`Engine` object ormclass: SQLAlchemy ORM class without_constraints: don't add foreign key constraints
[ "From", "an", "SQLAlchemy", "ORM", "class", "creates", "the", "database", "table", "via", "the", "specified", "engine", "using", "a", "CREATE", "TABLE", "SQL", "(", "DDL", ")", "statement", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sqlalchemy/orm_schema.py#L47-L73
meyersj/geotweet
geotweet/mapreduce/state_county_wordcount.py
StateCountyWordCountJob.mapper_init
def mapper_init(self): """ Download counties geojson from S3 and build spatial index and cache """ self.counties = CachedCountyLookup(precision=GEOHASH_PRECISION) self.extractor = WordExtractor()
python
def mapper_init(self): """ Download counties geojson from S3 and build spatial index and cache """ self.counties = CachedCountyLookup(precision=GEOHASH_PRECISION) self.extractor = WordExtractor()
[ "def", "mapper_init", "(", "self", ")", ":", "self", ".", "counties", "=", "CachedCountyLookup", "(", "precision", "=", "GEOHASH_PRECISION", ")", "self", ".", "extractor", "=", "WordExtractor", "(", ")" ]
Download counties geojson from S3 and build spatial index and cache
[ "Download", "counties", "geojson", "from", "S3", "and", "build", "spatial", "index", "and", "cache" ]
train
https://github.com/meyersj/geotweet/blob/1a6b55f98adf34d1b91f172d9187d599616412d9/geotweet/mapreduce/state_county_wordcount.py#L60-L63
meyersj/geotweet
geotweet/geomongo/__init__.py
GeoMongo.run
def run(self): """ Top level runner to load State and County GeoJSON files into Mongo DB """ logging.info("Starting GeoJSON MongoDB loading process.") mongo = dict(uri=self.mongo, db=self.db, collection=self.collection) self.load(self.source, **mongo) logging.info("Finished load...
python
def run(self): """ Top level runner to load State and County GeoJSON files into Mongo DB """ logging.info("Starting GeoJSON MongoDB loading process.") mongo = dict(uri=self.mongo, db=self.db, collection=self.collection) self.load(self.source, **mongo) logging.info("Finished load...
[ "def", "run", "(", "self", ")", ":", "logging", ".", "info", "(", "\"Starting GeoJSON MongoDB loading process.\"", ")", "mongo", "=", "dict", "(", "uri", "=", "self", ".", "mongo", ",", "db", "=", "self", ".", "db", ",", "collection", "=", "self", ".", ...
Top level runner to load State and County GeoJSON files into Mongo DB
[ "Top", "level", "runner", "to", "load", "State", "and", "County", "GeoJSON", "files", "into", "Mongo", "DB" ]
train
https://github.com/meyersj/geotweet/blob/1a6b55f98adf34d1b91f172d9187d599616412d9/geotweet/geomongo/__init__.py#L19-L24
meyersj/geotweet
geotweet/geomongo/__init__.py
GeoMongo.load
def load(self, geojson, uri=None, db=None, collection=None): """ Load geojson file into mongodb instance """ logging.info("Mongo URI: {0}".format(uri)) logging.info("Mongo DB: {0}".format(db)) logging.info("Mongo Collection: {0}".format(collection)) logging.info("Geojson File to ...
python
def load(self, geojson, uri=None, db=None, collection=None): """ Load geojson file into mongodb instance """ logging.info("Mongo URI: {0}".format(uri)) logging.info("Mongo DB: {0}".format(db)) logging.info("Mongo Collection: {0}".format(collection)) logging.info("Geojson File to ...
[ "def", "load", "(", "self", ",", "geojson", ",", "uri", "=", "None", ",", "db", "=", "None", ",", "collection", "=", "None", ")", ":", "logging", ".", "info", "(", "\"Mongo URI: {0}\"", ".", "format", "(", "uri", ")", ")", "logging", ".", "info", "...
Load geojson file into mongodb instance
[ "Load", "geojson", "file", "into", "mongodb", "instance" ]
train
https://github.com/meyersj/geotweet/blob/1a6b55f98adf34d1b91f172d9187d599616412d9/geotweet/geomongo/__init__.py#L26-L33
DCOD-OpenSource/django-project-version
djversion/utils.py
get_version
def get_version(): """ Return formatted version string. Returns: str: string with project version or empty string. """ if all([VERSION, UPDATED, any([isinstance(UPDATED, date), isinstance(UPDATED, datetime), ]), ]): return FORMAT_STRING.format(**{"version": VERSION, "updated": UPD...
python
def get_version(): """ Return formatted version string. Returns: str: string with project version or empty string. """ if all([VERSION, UPDATED, any([isinstance(UPDATED, date), isinstance(UPDATED, datetime), ]), ]): return FORMAT_STRING.format(**{"version": VERSION, "updated": UPD...
[ "def", "get_version", "(", ")", ":", "if", "all", "(", "[", "VERSION", ",", "UPDATED", ",", "any", "(", "[", "isinstance", "(", "UPDATED", ",", "date", ")", ",", "isinstance", "(", "UPDATED", ",", "datetime", ")", ",", "]", ")", ",", "]", ")", ":...
Return formatted version string. Returns: str: string with project version or empty string.
[ "Return", "formatted", "version", "string", "." ]
train
https://github.com/DCOD-OpenSource/django-project-version/blob/5fc63609cdf0cb2777f9e9155aa88f443e252b71/djversion/utils.py#L25-L44
RudolfCardinal/pythonlib
cardinal_pythonlib/openxml/find_recovered_openxml.py
process_file
def process_file(filename: str, filetypes: List[str], move_to: str, delete_if_not_specified_file_type: bool, show_zip_output: bool) -> None: """ Deals with an OpenXML, including if it is potentially corrupted. Args: filename: filen...
python
def process_file(filename: str, filetypes: List[str], move_to: str, delete_if_not_specified_file_type: bool, show_zip_output: bool) -> None: """ Deals with an OpenXML, including if it is potentially corrupted. Args: filename: filen...
[ "def", "process_file", "(", "filename", ":", "str", ",", "filetypes", ":", "List", "[", "str", "]", ",", "move_to", ":", "str", ",", "delete_if_not_specified_file_type", ":", "bool", ",", "show_zip_output", ":", "bool", ")", "->", "None", ":", "# log.critica...
Deals with an OpenXML, including if it is potentially corrupted. Args: filename: filename to process filetypes: list of filetypes that we care about, e.g. ``['docx', 'pptx', 'xlsx']``. move_to: move matching files to this directory delete_if_not_specified_file_type: if `...
[ "Deals", "with", "an", "OpenXML", "including", "if", "it", "is", "potentially", "corrupted", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/openxml/find_recovered_openxml.py#L294-L333
RudolfCardinal/pythonlib
cardinal_pythonlib/openxml/find_recovered_openxml.py
main
def main() -> None: """ Command-line handler for the ``find_recovered_openxml`` tool. Use the ``--help`` option for help. """ parser = ArgumentParser( formatter_class=RawDescriptionHelpFormatter, description=""" Tool to recognize and rescue Microsoft Office OpenXML files, even if the...
python
def main() -> None: """ Command-line handler for the ``find_recovered_openxml`` tool. Use the ``--help`` option for help. """ parser = ArgumentParser( formatter_class=RawDescriptionHelpFormatter, description=""" Tool to recognize and rescue Microsoft Office OpenXML files, even if the...
[ "def", "main", "(", ")", "->", "None", ":", "parser", "=", "ArgumentParser", "(", "formatter_class", "=", "RawDescriptionHelpFormatter", ",", "description", "=", "\"\"\"\nTool to recognize and rescue Microsoft Office OpenXML files, even if they have\ngarbage appended to them. ...
Command-line handler for the ``find_recovered_openxml`` tool. Use the ``--help`` option for help.
[ "Command", "-", "line", "handler", "for", "the", "find_recovered_openxml", "tool", ".", "Use", "the", "--", "help", "option", "for", "help", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/openxml/find_recovered_openxml.py#L340-L527
RudolfCardinal/pythonlib
cardinal_pythonlib/openxml/find_recovered_openxml.py
CorruptedZipReader.move_to
def move_to(self, destination_filename: str, alter_if_clash: bool = True) -> None: """ Move the file to which this class refers to a new location. The function will not overwrite existing files (but offers the option to rename files slightly to avoid a clash). Ar...
python
def move_to(self, destination_filename: str, alter_if_clash: bool = True) -> None: """ Move the file to which this class refers to a new location. The function will not overwrite existing files (but offers the option to rename files slightly to avoid a clash). Ar...
[ "def", "move_to", "(", "self", ",", "destination_filename", ":", "str", ",", "alter_if_clash", ":", "bool", "=", "True", ")", "->", "None", ":", "if", "not", "self", ".", "src_filename", ":", "return", "if", "alter_if_clash", ":", "counter", "=", "0", "w...
Move the file to which this class refers to a new location. The function will not overwrite existing files (but offers the option to rename files slightly to avoid a clash). Args: destination_filename: filename to move to alter_if_clash: if ``True`` (the default), append...
[ "Move", "the", "file", "to", "which", "this", "class", "refers", "to", "a", "new", "location", ".", "The", "function", "will", "not", "overwrite", "existing", "files", "(", "but", "offers", "the", "option", "to", "rename", "files", "slightly", "to", "avoid...
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/openxml/find_recovered_openxml.py#L200-L243
oxalorg/Stab
stab/watchman.py
Watchman.should_build
def should_build(self, fpath, meta): """ Checks if the file should be built or not Only skips layouts which are tagged as INCREMENTAL Rebuilds only those files with mtime changed since previous build """ if meta.get('layout', self.default_template) in self.inc_layout: ...
python
def should_build(self, fpath, meta): """ Checks if the file should be built or not Only skips layouts which are tagged as INCREMENTAL Rebuilds only those files with mtime changed since previous build """ if meta.get('layout', self.default_template) in self.inc_layout: ...
[ "def", "should_build", "(", "self", ",", "fpath", ",", "meta", ")", ":", "if", "meta", ".", "get", "(", "'layout'", ",", "self", ".", "default_template", ")", "in", "self", ".", "inc_layout", ":", "if", "self", ".", "prev_mtime", ".", "get", "(", "fp...
Checks if the file should be built or not Only skips layouts which are tagged as INCREMENTAL Rebuilds only those files with mtime changed since previous build
[ "Checks", "if", "the", "file", "should", "be", "built", "or", "not", "Only", "skips", "layouts", "which", "are", "tagged", "as", "INCREMENTAL", "Rebuilds", "only", "those", "files", "with", "mtime", "changed", "since", "previous", "build" ]
train
https://github.com/oxalorg/Stab/blob/8f0ded780fd7a53a674835c9cb1b7ca08b98f562/stab/watchman.py#L24-L35
calston/rhumba
rhumba/backends/redis.py
Backend.clusterQueues
def clusterQueues(self): """ Return a dict of queues in cluster and servers running them """ servers = yield self.getClusterServers() queues = {} for sname in servers: qs = yield self.get('rhumba.server.%s.queues' % sname) uuid = yield self.get('rhumba.s...
python
def clusterQueues(self): """ Return a dict of queues in cluster and servers running them """ servers = yield self.getClusterServers() queues = {} for sname in servers: qs = yield self.get('rhumba.server.%s.queues' % sname) uuid = yield self.get('rhumba.s...
[ "def", "clusterQueues", "(", "self", ")", ":", "servers", "=", "yield", "self", ".", "getClusterServers", "(", ")", "queues", "=", "{", "}", "for", "sname", "in", "servers", ":", "qs", "=", "yield", "self", ".", "get", "(", "'rhumba.server.%s.queues'", "...
Return a dict of queues in cluster and servers running them
[ "Return", "a", "dict", "of", "queues", "in", "cluster", "and", "servers", "running", "them" ]
train
https://github.com/calston/rhumba/blob/05e3cbf4e531cc51b4777912eb98a4f006893f5e/rhumba/backends/redis.py#L207-L226
calston/rhumba
rhumba/backends/redis.py
Backend.clusterStatus
def clusterStatus(self): """ Returns a dict of cluster nodes and their status information """ servers = yield self.getClusterServers() d = { 'workers': {}, 'crons': {}, 'queues': {} } now = time.time() reverse_map = {...
python
def clusterStatus(self): """ Returns a dict of cluster nodes and their status information """ servers = yield self.getClusterServers() d = { 'workers': {}, 'crons': {}, 'queues': {} } now = time.time() reverse_map = {...
[ "def", "clusterStatus", "(", "self", ")", ":", "servers", "=", "yield", "self", ".", "getClusterServers", "(", ")", "d", "=", "{", "'workers'", ":", "{", "}", ",", "'crons'", ":", "{", "}", ",", "'queues'", ":", "{", "}", "}", "now", "=", "time", ...
Returns a dict of cluster nodes and their status information
[ "Returns", "a", "dict", "of", "cluster", "nodes", "and", "their", "status", "information" ]
train
https://github.com/calston/rhumba/blob/05e3cbf4e531cc51b4777912eb98a4f006893f5e/rhumba/backends/redis.py#L229-L301
avihad/twistes
twistes/client.py
Elasticsearch.get
def get(self, index, id, fields=None, doc_type=EsConst.ALL_VALUES, **query_params): """ Retrieve specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name to query :param id: the id of the record :...
python
def get(self, index, id, fields=None, doc_type=EsConst.ALL_VALUES, **query_params): """ Retrieve specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name to query :param id: the id of the record :...
[ "def", "get", "(", "self", ",", "index", ",", "id", ",", "fields", "=", "None", ",", "doc_type", "=", "EsConst", ".", "ALL_VALUES", ",", "*", "*", "query_params", ")", ":", "if", "fields", ":", "query_params", "[", "EsConst", ".", "FIELDS", "]", "=",...
Retrieve specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name to query :param id: the id of the record :param fields: the fields you what to fetch from the record (str separated by comma's) :param doc...
[ "Retrieve", "specific", "record", "by", "id", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "docs", "-", "get", ".", "html", ">", "_", ":", "param", "index"...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L63-L79
avihad/twistes
twistes/client.py
Elasticsearch.exists
def exists(self, index, doc_type, id, **query_params): """ Check if the doc exist in the elastic search `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name :param doc_type: the document type :param id: the id of t...
python
def exists(self, index, doc_type, id, **query_params): """ Check if the doc exist in the elastic search `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name :param doc_type: the document type :param id: the id of t...
[ "def", "exists", "(", "self", ",", "index", ",", "doc_type", ",", "id", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "index", ",", "doc_type", ",", "id", ")", "path", "=", "self", ".", "_es_parser...
Check if the doc exist in the elastic search `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name :param doc_type: the document type :param id: the id of the doc type :arg parent: The ID of the parent document :arg...
[ "Check", "if", "the", "doc", "exist", "in", "the", "elastic", "search", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "docs", "-", "get", ".", "html", ">", ...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L82-L103
avihad/twistes
twistes/client.py
Elasticsearch.get_source
def get_source(self, index, doc_type, id, **query_params): """ Get the _source of the document `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name :param doc_type: the document type :param id: the id of the doc ty...
python
def get_source(self, index, doc_type, id, **query_params): """ Get the _source of the document `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name :param doc_type: the document type :param id: the id of the doc ty...
[ "def", "get_source", "(", "self", ",", "index", ",", "doc_type", ",", "id", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "index", ",", "doc_type", ",", "id", ")", "path", "=", "self", ".", "_es_pa...
Get the _source of the document `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html>`_ :param index: the index name :param doc_type: the document type :param id: the id of the doc type :arg _source: True or false to return the _source field or not, or a...
[ "Get", "the", "_source", "of", "the", "document", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "docs", "-", "get", ".", "html", ">", "_", ":", "param", "...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L106-L136
avihad/twistes
twistes/client.py
Elasticsearch.mget
def mget(self, body, index=None, doc_type=None, **query_params): """ Get multiple document from the same index and doc_type (optionally) by ids `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>` :param body: list of docs with or without the index and ...
python
def mget(self, body, index=None, doc_type=None, **query_params): """ Get multiple document from the same index and doc_type (optionally) by ids `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>` :param body: list of docs with or without the index and ...
[ "def", "mget", "(", "self", ",", "body", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "body", ")", "path", "=", "self", ".", "_es_parser", ...
Get multiple document from the same index and doc_type (optionally) by ids `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>` :param body: list of docs with or without the index and type parameters or list of ids :param index: the name of the index ...
[ "Get", "multiple", "document", "from", "the", "same", "index", "and", "doc_type", "(", "optionally", ")", "by", "ids", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", ...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L139-L172
avihad/twistes
twistes/client.py
Elasticsearch.update
def update(self, index, doc_type, id, body=None, **query_params): """ Update a document with the body param or list of ids `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>`_ :param index: the name of the index :param doc_type: the document type ...
python
def update(self, index, doc_type, id, body=None, **query_params): """ Update a document with the body param or list of ids `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>`_ :param index: the name of the index :param doc_type: the document type ...
[ "def", "update", "(", "self", ",", "index", ",", "doc_type", ",", "id", ",", "body", "=", "None", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "index", ",", "doc_type", ",", "id", ")", "path", "...
Update a document with the body param or list of ids `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>`_ :param index: the name of the index :param doc_type: the document type :param id: the id of the doc type :param body: the data to update in t...
[ "Update", "a", "document", "with", "the", "body", "param", "or", "list", "of", "ids", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "docs", "-", "update", "...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L175-L209
avihad/twistes
twistes/client.py
Elasticsearch.search
def search(self, index=None, doc_type=None, body=None, **query_params): """ Make a search query on the elastic search `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_ :param index: the index name to query :param doc_type: he doc type to sear...
python
def search(self, index=None, doc_type=None, body=None, **query_params): """ Make a search query on the elastic search `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_ :param index: the index name to query :param doc_type: he doc type to sear...
[ "def", "search", "(", "self", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "body", "=", "None", ",", "*", "*", "query_params", ")", ":", "path", "=", "self", ".", "_es_parser", ".", "make_path", "(", "index", ",", "doc_type", ",", ...
Make a search query on the elastic search `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_ :param index: the index name to query :param doc_type: he doc type to search in :param body: the query :param query_params: params :arg _sourc...
[ "Make", "a", "search", "query", "on", "the", "elastic", "search", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "search", "-", "search", ".", "html", ">", "...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L212-L283
avihad/twistes
twistes/client.py
Elasticsearch.explain
def explain(self, index, doc_type, id, body=None, **query_params): """ The explain api computes a score explanation for a query and a specific document. This can give useful feedback whether a document matches or didn't match a specific query. `<http://www.elastic.co/guide/en/ela...
python
def explain(self, index, doc_type, id, body=None, **query_params): """ The explain api computes a score explanation for a query and a specific document. This can give useful feedback whether a document matches or didn't match a specific query. `<http://www.elastic.co/guide/en/ela...
[ "def", "explain", "(", "self", ",", "index", ",", "doc_type", ",", "id", ",", "body", "=", "None", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "index", ",", "doc_type", ",", "id", ")", "path", ...
The explain api computes a score explanation for a query and a specific document. This can give useful feedback whether a document matches or didn't match a specific query. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html>`_ :param index: The name of t...
[ "The", "explain", "api", "computes", "a", "score", "explanation", "for", "a", "query", "and", "a", "specific", "document", ".", "This", "can", "give", "useful", "feedback", "whether", "a", "document", "matches", "or", "didn", "t", "match", "a", "specific", ...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L286-L330
avihad/twistes
twistes/client.py
Elasticsearch.delete
def delete(self, index, doc_type, id, **query_params): """ Delete specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html>`_ :param index: the index name to delete from :param doc_type: the doc type to delete from :param id:...
python
def delete(self, index, doc_type, id, **query_params): """ Delete specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html>`_ :param index: the index name to delete from :param doc_type: the doc type to delete from :param id:...
[ "def", "delete", "(", "self", ",", "index", ",", "doc_type", ",", "id", ",", "*", "*", "query_params", ")", ":", "path", "=", "self", ".", "_es_parser", ".", "make_path", "(", "index", ",", "doc_type", ",", "id", ")", "result", "=", "yield", "self", ...
Delete specific record by id `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html>`_ :param index: the index name to delete from :param doc_type: the doc type to delete from :param id: the id of the record :param query_params: params :return:
[ "Delete", "specific", "record", "by", "id", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "docs", "-", "delete", ".", "html", ">", "_", ":", "param", "index...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L333-L345
avihad/twistes
twistes/client.py
Elasticsearch.index
def index(self, index, doc_type, body, id=None, **query_params): """ Adds or updates a typed JSON document in a specific index, making it searchable. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`_ :param index: The name of the index :param d...
python
def index(self, index, doc_type, body, id=None, **query_params): """ Adds or updates a typed JSON document in a specific index, making it searchable. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`_ :param index: The name of the index :param d...
[ "def", "index", "(", "self", ",", "index", ",", "doc_type", ",", "body", ",", "id", "=", "None", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "index", ",", "doc_type", ",", "body", ")", "method", ...
Adds or updates a typed JSON document in a specific index, making it searchable. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`_ :param index: The name of the index :param doc_type: The type of the document :param body: The document :param id...
[ "Adds", "or", "updates", "a", "typed", "JSON", "document", "in", "a", "specific", "index", "making", "it", "searchable", ".", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "c...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L348-L377
avihad/twistes
twistes/client.py
Elasticsearch.create
def create(self, index, doc_type, body, id=None, **query_params): """ Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type='create') `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`...
python
def create(self, index, doc_type, body, id=None, **query_params): """ Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type='create') `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`...
[ "def", "create", "(", "self", ",", "index", ",", "doc_type", ",", "body", ",", "id", "=", "None", ",", "*", "*", "query_params", ")", ":", "query_params", "[", "'op_type'", "]", "=", "'create'", "result", "=", "yield", "self", ".", "index", "(", "ind...
Adds a typed JSON document in a specific index, making it searchable. Behind the scenes this method calls index(..., op_type='create') `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`_ :param index: The name of the index :param doc_type: The type of the...
[ "Adds", "a", "typed", "JSON", "document", "in", "a", "specific", "index", "making", "it", "searchable", ".", "Behind", "the", "scenes", "this", "method", "calls", "index", "(", "...", "op_type", "=", "create", ")", "<http", ":", "//", "www", ".", "elasti...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L380-L405
avihad/twistes
twistes/client.py
Elasticsearch.clear_scroll
def clear_scroll(self, scroll_id=None, body=None, **query_params): """ Clear the scroll request created by specifying the scroll parameter to search. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_ :param scroll_id: A comma-separated...
python
def clear_scroll(self, scroll_id=None, body=None, **query_params): """ Clear the scroll request created by specifying the scroll parameter to search. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_ :param scroll_id: A comma-separated...
[ "def", "clear_scroll", "(", "self", ",", "scroll_id", "=", "None", ",", "body", "=", "None", ",", "*", "*", "query_params", ")", ":", "if", "scroll_id", "in", "NULL_VALUES", "and", "body", "in", "NULL_VALUES", ":", "raise", "ValueError", "(", "\"You need t...
Clear the scroll request created by specifying the scroll parameter to search. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_ :param scroll_id: A comma-separated list of scroll IDs to clear :param body: A comma-separated list of scroll IDs ...
[ "Clear", "the", "scroll", "request", "created", "by", "specifying", "the", "scroll", "parameter", "to", "search", ".", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", ...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L430-L448
avihad/twistes
twistes/client.py
Elasticsearch.scan
def scan(self, index, doc_type, query=None, scroll='5m', preserve_order=False, size=10, **kwargs): """ Simple abstraction on top of the :meth:`~elasticsearch.Elasticsearch.scroll` api - a simple iterator that yields all hits as returned by underlining scroll requests. By default...
python
def scan(self, index, doc_type, query=None, scroll='5m', preserve_order=False, size=10, **kwargs): """ Simple abstraction on top of the :meth:`~elasticsearch.Elasticsearch.scroll` api - a simple iterator that yields all hits as returned by underlining scroll requests. By default...
[ "def", "scan", "(", "self", ",", "index", ",", "doc_type", ",", "query", "=", "None", ",", "scroll", "=", "'5m'", ",", "preserve_order", "=", "False", ",", "size", "=", "10", ",", "*", "*", "kwargs", ")", ":", "if", "not", "preserve_order", ":", "k...
Simple abstraction on top of the :meth:`~elasticsearch.Elasticsearch.scroll` api - a simple iterator that yields all hits as returned by underlining scroll requests. By default scan does not return results in any pre-determined order. To have a standard order in the returned documents (...
[ "Simple", "abstraction", "on", "top", "of", "the", ":", "meth", ":", "~elasticsearch", ".", "Elasticsearch", ".", "scroll", "api", "-", "a", "simple", "iterator", "that", "yields", "all", "hits", "as", "returned", "by", "underlining", "scroll", "requests", "...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L451-L494
avihad/twistes
twistes/client.py
Elasticsearch.count
def count(self, index=None, doc_type=None, body=None, **query_params): """ Execute a query and get the number of matches for that query. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html>`_ :param index: A comma-separated list of indices to restrict the r...
python
def count(self, index=None, doc_type=None, body=None, **query_params): """ Execute a query and get the number of matches for that query. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html>`_ :param index: A comma-separated list of indices to restrict the r...
[ "def", "count", "(", "self", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "body", "=", "None", ",", "*", "*", "query_params", ")", ":", "if", "doc_type", "and", "not", "index", ":", "index", "=", "EsConst", ".", "ALL_VALUES", "path",...
Execute a query and get the number of matches for that query. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-count.html>`_ :param index: A comma-separated list of indices to restrict the results :param doc_type: A comma-separated list of types to restrict the results ...
[ "Execute", "a", "query", "and", "get", "the", "number", "of", "matches", "for", "that", "query", ".", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "search", ...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L497-L536
avihad/twistes
twistes/client.py
Elasticsearch.bulk
def bulk(self, body, index=None, doc_type=None, **query_params): """ Perform many index/delete operations in a single API call. See the :func:`~elasticsearch.helpers.bulk` helper function for a more friendly API. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/do...
python
def bulk(self, body, index=None, doc_type=None, **query_params): """ Perform many index/delete operations in a single API call. See the :func:`~elasticsearch.helpers.bulk` helper function for a more friendly API. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/do...
[ "def", "bulk", "(", "self", ",", "body", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "body", ")", "path", "=", "self", ".", "_es_parser", ...
Perform many index/delete operations in a single API call. See the :func:`~elasticsearch.helpers.bulk` helper function for a more friendly API. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html>`_ :param body: The operation definition and data (action-data p...
[ "Perform", "many", "index", "/", "delete", "operations", "in", "a", "single", "API", "call", ".", "See", "the", ":", "func", ":", "~elasticsearch", ".", "helpers", ".", "bulk", "helper", "function", "for", "a", "more", "friendly", "API", ".", "<http", ":...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L539-L564
avihad/twistes
twistes/client.py
Elasticsearch.msearch
def msearch(self, body, index=None, doc_type=None, **query_params): """ Execute several search requests within the same API. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>`_ :arg body: The request definitions (metadata-search request definition...
python
def msearch(self, body, index=None, doc_type=None, **query_params): """ Execute several search requests within the same API. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>`_ :arg body: The request definitions (metadata-search request definition...
[ "def", "msearch", "(", "self", ",", "body", ",", "index", "=", "None", ",", "doc_type", "=", "None", ",", "*", "*", "query_params", ")", ":", "self", ".", "_es_parser", ".", "is_not_empty_params", "(", "body", ")", "path", "=", "self", ".", "_es_parser...
Execute several search requests within the same API. `<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html>`_ :arg body: The request definitions (metadata-search request definition pairs), separated by newlines :arg index: A comma-separated list of...
[ "Execute", "several", "search", "requests", "within", "the", "same", "API", ".", "<http", ":", "//", "www", ".", "elastic", ".", "co", "/", "guide", "/", "en", "/", "elasticsearch", "/", "reference", "/", "current", "/", "search", "-", "multi", "-", "s...
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L567-L589
avihad/twistes
twistes/client.py
Elasticsearch.close
def close(self): """ close all http connections. returns a deferred that fires once they're all closed. """ def validate_client(client): """ Validate that the connection is for the current client :param client: :return: ...
python
def close(self): """ close all http connections. returns a deferred that fires once they're all closed. """ def validate_client(client): """ Validate that the connection is for the current client :param client: :return: ...
[ "def", "close", "(", "self", ")", ":", "def", "validate_client", "(", "client", ")", ":", "\"\"\"\n Validate that the connection is for the current client\n :param client:\n :return:\n \"\"\"", "host", ",", "port", "=", "client", ".", ...
close all http connections. returns a deferred that fires once they're all closed.
[ "close", "all", "http", "connections", ".", "returns", "a", "deferred", "that", "fires", "once", "they", "re", "all", "closed", "." ]
train
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L666-L692
davenquinn/Attitude
attitude/helpers/dem.py
clean_coordinates
def clean_coordinates(coords, silent=False): """ Removes invalid coordinates (this is generally caused by importing coordinates outside of the DEM) """ l1 = len(coords) coords = coords[~N.isnan(coords).any(axis=1)] # remove NaN values l2 = len(coords) if not silent: msg = "{0} co...
python
def clean_coordinates(coords, silent=False): """ Removes invalid coordinates (this is generally caused by importing coordinates outside of the DEM) """ l1 = len(coords) coords = coords[~N.isnan(coords).any(axis=1)] # remove NaN values l2 = len(coords) if not silent: msg = "{0} co...
[ "def", "clean_coordinates", "(", "coords", ",", "silent", "=", "False", ")", ":", "l1", "=", "len", "(", "coords", ")", "coords", "=", "coords", "[", "~", "N", ".", "isnan", "(", "coords", ")", ".", "any", "(", "axis", "=", "1", ")", "]", "# remo...
Removes invalid coordinates (this is generally caused by importing coordinates outside of the DEM)
[ "Removes", "invalid", "coordinates", "(", "this", "is", "generally", "caused", "by", "importing", "coordinates", "outside", "of", "the", "DEM", ")" ]
train
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/helpers/dem.py#L14-L27
davenquinn/Attitude
attitude/helpers/dem.py
offset_mask
def offset_mask(mask): """ Returns a mask shrunk to the 'minimum bounding rectangle' of the nonzero portion of the previous mask, and its offset from the original. Useful to find the smallest rectangular section of the image that can be extracted to include the entire geometry. Conforms to t...
python
def offset_mask(mask): """ Returns a mask shrunk to the 'minimum bounding rectangle' of the nonzero portion of the previous mask, and its offset from the original. Useful to find the smallest rectangular section of the image that can be extracted to include the entire geometry. Conforms to t...
[ "def", "offset_mask", "(", "mask", ")", ":", "def", "axis_data", "(", "axis", ")", ":", "\"\"\"Gets the bounds of a masked area along a certain axis\"\"\"", "x", "=", "mask", ".", "sum", "(", "axis", ")", "trimmed_front", "=", "N", ".", "trim_zeros", "(", "x", ...
Returns a mask shrunk to the 'minimum bounding rectangle' of the nonzero portion of the previous mask, and its offset from the original. Useful to find the smallest rectangular section of the image that can be extracted to include the entire geometry. Conforms to the y-first expectations...
[ "Returns", "a", "mask", "shrunk", "to", "the", "minimum", "bounding", "rectangle", "of", "the", "nonzero", "portion", "of", "the", "previous", "mask", "and", "its", "offset", "from", "the", "original", ".", "Useful", "to", "find", "the", "smallest", "rectang...
train
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/helpers/dem.py#L29-L49
davenquinn/Attitude
attitude/helpers/dem.py
extract_line
def extract_line(geom, dem, **kwargs): """ Extract a linear feature from a `rasterio` geospatial dataset. """ kwargs.setdefault('masked', True) coords_in = coords_array(geom) # Transform geometry into pixels f = lambda *x: ~dem.transform * x px = transform(f,geom) # Subdivide geom...
python
def extract_line(geom, dem, **kwargs): """ Extract a linear feature from a `rasterio` geospatial dataset. """ kwargs.setdefault('masked', True) coords_in = coords_array(geom) # Transform geometry into pixels f = lambda *x: ~dem.transform * x px = transform(f,geom) # Subdivide geom...
[ "def", "extract_line", "(", "geom", ",", "dem", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'masked'", ",", "True", ")", "coords_in", "=", "coords_array", "(", "geom", ")", "# Transform geometry into pixels", "f", "=", "lambda", "...
Extract a linear feature from a `rasterio` geospatial dataset.
[ "Extract", "a", "linear", "feature", "from", "a", "rasterio", "geospatial", "dataset", "." ]
train
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/helpers/dem.py#L58-L101
calston/rhumba
rhumba/utils.py
fork
def fork(executable, args=(), env={}, path=None, timeout=3600): """fork Provides a deferred wrapper function with a timeout function :param executable: Executable :type executable: str. :param args: Tupple of arguments :type args: tupple. :param env: Environment dictionary :type env: di...
python
def fork(executable, args=(), env={}, path=None, timeout=3600): """fork Provides a deferred wrapper function with a timeout function :param executable: Executable :type executable: str. :param args: Tupple of arguments :type args: tupple. :param env: Environment dictionary :type env: di...
[ "def", "fork", "(", "executable", ",", "args", "=", "(", ")", ",", "env", "=", "{", "}", ",", "path", "=", "None", ",", "timeout", "=", "3600", ")", ":", "d", "=", "defer", ".", "Deferred", "(", ")", "p", "=", "ProcessProtocol", "(", "d", ",", ...
fork Provides a deferred wrapper function with a timeout function :param executable: Executable :type executable: str. :param args: Tupple of arguments :type args: tupple. :param env: Environment dictionary :type env: dict. :param timeout: Kill the child process if timeout is exceeded ...
[ "fork", "Provides", "a", "deferred", "wrapper", "function", "with", "a", "timeout", "function" ]
train
https://github.com/calston/rhumba/blob/05e3cbf4e531cc51b4777912eb98a4f006893f5e/rhumba/utils.py#L52-L68
RudolfCardinal/pythonlib
cardinal_pythonlib/sql/sql_grammar_factory.py
make_grammar
def make_grammar(dialect: str) -> SqlGrammar: """ Factory to make an :class:`.SqlGrammar` from the name of an SQL dialect, where the name is one of the members of :class:`.SqlaDialectName`. """ if dialect == SqlaDialectName.MYSQL: return mysql_grammar elif dialect == SqlaDialectName.MSSQ...
python
def make_grammar(dialect: str) -> SqlGrammar: """ Factory to make an :class:`.SqlGrammar` from the name of an SQL dialect, where the name is one of the members of :class:`.SqlaDialectName`. """ if dialect == SqlaDialectName.MYSQL: return mysql_grammar elif dialect == SqlaDialectName.MSSQ...
[ "def", "make_grammar", "(", "dialect", ":", "str", ")", "->", "SqlGrammar", ":", "if", "dialect", "==", "SqlaDialectName", ".", "MYSQL", ":", "return", "mysql_grammar", "elif", "dialect", "==", "SqlaDialectName", ".", "MSSQL", ":", "return", "mssql_grammar", "...
Factory to make an :class:`.SqlGrammar` from the name of an SQL dialect, where the name is one of the members of :class:`.SqlaDialectName`.
[ "Factory", "to", "make", "an", ":", "class", ":", ".", "SqlGrammar", "from", "the", "name", "of", "an", "SQL", "dialect", "where", "the", "name", "is", "one", "of", "the", "members", "of", ":", "class", ":", ".", "SqlaDialectName", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sql/sql_grammar_factory.py#L50-L60
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
number_to_dp
def number_to_dp(number: Optional[float], dp: int, default: Optional[str] = "", en_dash_for_minus: bool = True) -> str: """ Format number to ``dp`` decimal places, optionally using a UTF-8 en dash for minus signs. """ if number is None: retu...
python
def number_to_dp(number: Optional[float], dp: int, default: Optional[str] = "", en_dash_for_minus: bool = True) -> str: """ Format number to ``dp`` decimal places, optionally using a UTF-8 en dash for minus signs. """ if number is None: retu...
[ "def", "number_to_dp", "(", "number", ":", "Optional", "[", "float", "]", ",", "dp", ":", "int", ",", "default", ":", "Optional", "[", "str", "]", "=", "\"\"", ",", "en_dash_for_minus", ":", "bool", "=", "True", ")", "->", "str", ":", "if", "number",...
Format number to ``dp`` decimal places, optionally using a UTF-8 en dash for minus signs.
[ "Format", "number", "to", "dp", "decimal", "places", "optionally", "using", "a", "UTF", "-", "8", "en", "dash", "for", "minus", "signs", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L109-L127
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
debug_form_contents
def debug_form_contents(form: cgi.FieldStorage, to_stderr: bool = True, to_logger: bool = False) -> None: """ Writes the keys and values of a CGI form to ``stderr``. """ for k in form.keys(): text = "{0} = {1}".format(k, form.getvalue(k)) i...
python
def debug_form_contents(form: cgi.FieldStorage, to_stderr: bool = True, to_logger: bool = False) -> None: """ Writes the keys and values of a CGI form to ``stderr``. """ for k in form.keys(): text = "{0} = {1}".format(k, form.getvalue(k)) i...
[ "def", "debug_form_contents", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "to_stderr", ":", "bool", "=", "True", ",", "to_logger", ":", "bool", "=", "False", ")", "->", "None", ":", "for", "k", "in", "form", ".", "keys", "(", ")", ":", "text",...
Writes the keys and values of a CGI form to ``stderr``.
[ "Writes", "the", "keys", "and", "values", "of", "a", "CGI", "form", "to", "stderr", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L134-L145
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
cgi_method_is_post
def cgi_method_is_post(environ: Dict[str, str]) -> bool: """ Determines if the CGI method was ``POST``, given the CGI environment. """ method = environ.get("REQUEST_METHOD", None) if not method: return False return method.upper() == "POST"
python
def cgi_method_is_post(environ: Dict[str, str]) -> bool: """ Determines if the CGI method was ``POST``, given the CGI environment. """ method = environ.get("REQUEST_METHOD", None) if not method: return False return method.upper() == "POST"
[ "def", "cgi_method_is_post", "(", "environ", ":", "Dict", "[", "str", ",", "str", "]", ")", "->", "bool", ":", "method", "=", "environ", ".", "get", "(", "\"REQUEST_METHOD\"", ",", "None", ")", "if", "not", "method", ":", "return", "False", "return", "...
Determines if the CGI method was ``POST``, given the CGI environment.
[ "Determines", "if", "the", "CGI", "method", "was", "POST", "given", "the", "CGI", "environment", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L149-L156
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_str
def get_cgi_parameter_str(form: cgi.FieldStorage, key: str, default: str = None) -> str: """ Extracts a string parameter from a CGI form. Note: ``key`` is CASE-SENSITIVE. """ paramlist = form.getlist(key) if len(paramlist) == 0: return ...
python
def get_cgi_parameter_str(form: cgi.FieldStorage, key: str, default: str = None) -> str: """ Extracts a string parameter from a CGI form. Note: ``key`` is CASE-SENSITIVE. """ paramlist = form.getlist(key) if len(paramlist) == 0: return ...
[ "def", "get_cgi_parameter_str", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ",", "default", ":", "str", "=", "None", ")", "->", "str", ":", "paramlist", "=", "form", ".", "getlist", "(", "key", ")", "if", "len", "(", "paraml...
Extracts a string parameter from a CGI form. Note: ``key`` is CASE-SENSITIVE.
[ "Extracts", "a", "string", "parameter", "from", "a", "CGI", "form", ".", "Note", ":", "key", "is", "CASE", "-", "SENSITIVE", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L159-L169
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_str_or_none
def get_cgi_parameter_str_or_none(form: cgi.FieldStorage, key: str) -> Optional[str]: """ Extracts a string parameter from a CGI form, or ``None`` if the key doesn't exist or the string is zero-length. """ s = get_cgi_parameter_str(form, key) if s is None or len...
python
def get_cgi_parameter_str_or_none(form: cgi.FieldStorage, key: str) -> Optional[str]: """ Extracts a string parameter from a CGI form, or ``None`` if the key doesn't exist or the string is zero-length. """ s = get_cgi_parameter_str(form, key) if s is None or len...
[ "def", "get_cgi_parameter_str_or_none", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "s", "=", "get_cgi_parameter_str", "(", "form", ",", "key", ")", "if", "s", "is", "None", "or", "...
Extracts a string parameter from a CGI form, or ``None`` if the key doesn't exist or the string is zero-length.
[ "Extracts", "a", "string", "parameter", "from", "a", "CGI", "form", "or", "None", "if", "the", "key", "doesn", "t", "exist", "or", "the", "string", "is", "zero", "-", "length", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L172-L181
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_list
def get_cgi_parameter_list(form: cgi.FieldStorage, key: str) -> List[str]: """ Extracts a list of values, all with the same key, from a CGI form. """ return form.getlist(key)
python
def get_cgi_parameter_list(form: cgi.FieldStorage, key: str) -> List[str]: """ Extracts a list of values, all with the same key, from a CGI form. """ return form.getlist(key)
[ "def", "get_cgi_parameter_list", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "List", "[", "str", "]", ":", "return", "form", ".", "getlist", "(", "key", ")" ]
Extracts a list of values, all with the same key, from a CGI form.
[ "Extracts", "a", "list", "of", "values", "all", "with", "the", "same", "key", "from", "a", "CGI", "form", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L184-L188
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_bool
def get_cgi_parameter_bool(form: cgi.FieldStorage, key: str) -> bool: """ Extracts a boolean parameter from a CGI form, on the assumption that ``"1"`` is ``True`` and everything else is ``False``. """ return is_1(get_cgi_parameter_str(form, key))
python
def get_cgi_parameter_bool(form: cgi.FieldStorage, key: str) -> bool: """ Extracts a boolean parameter from a CGI form, on the assumption that ``"1"`` is ``True`` and everything else is ``False``. """ return is_1(get_cgi_parameter_str(form, key))
[ "def", "get_cgi_parameter_bool", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "bool", ":", "return", "is_1", "(", "get_cgi_parameter_str", "(", "form", ",", "key", ")", ")" ]
Extracts a boolean parameter from a CGI form, on the assumption that ``"1"`` is ``True`` and everything else is ``False``.
[ "Extracts", "a", "boolean", "parameter", "from", "a", "CGI", "form", "on", "the", "assumption", "that", "1", "is", "True", "and", "everything", "else", "is", "False", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L191-L196
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_bool_or_default
def get_cgi_parameter_bool_or_default(form: cgi.FieldStorage, key: str, default: bool = None) -> Optional[bool]: """ Extracts a boolean parameter from a CGI form (``"1"`` = ``True``, other string = ``False``, absent/zero-length stri...
python
def get_cgi_parameter_bool_or_default(form: cgi.FieldStorage, key: str, default: bool = None) -> Optional[bool]: """ Extracts a boolean parameter from a CGI form (``"1"`` = ``True``, other string = ``False``, absent/zero-length stri...
[ "def", "get_cgi_parameter_bool_or_default", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ",", "default", ":", "bool", "=", "None", ")", "->", "Optional", "[", "bool", "]", ":", "s", "=", "get_cgi_parameter_str", "(", "form", ",", ...
Extracts a boolean parameter from a CGI form (``"1"`` = ``True``, other string = ``False``, absent/zero-length string = default value).
[ "Extracts", "a", "boolean", "parameter", "from", "a", "CGI", "form", "(", "1", "=", "True", "other", "string", "=", "False", "absent", "/", "zero", "-", "length", "string", "=", "default", "value", ")", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L199-L209
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_bool_or_none
def get_cgi_parameter_bool_or_none(form: cgi.FieldStorage, key: str) -> Optional[bool]: """ Extracts a boolean parameter from a CGI form (``"1"`` = ``True``, other string = False, absent/zero-length string = ``None``). """ return get_cgi_parameter_bool_or_default(f...
python
def get_cgi_parameter_bool_or_none(form: cgi.FieldStorage, key: str) -> Optional[bool]: """ Extracts a boolean parameter from a CGI form (``"1"`` = ``True``, other string = False, absent/zero-length string = ``None``). """ return get_cgi_parameter_bool_or_default(f...
[ "def", "get_cgi_parameter_bool_or_none", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "Optional", "[", "bool", "]", ":", "return", "get_cgi_parameter_bool_or_default", "(", "form", ",", "key", ",", "default", "=", "None", ...
Extracts a boolean parameter from a CGI form (``"1"`` = ``True``, other string = False, absent/zero-length string = ``None``).
[ "Extracts", "a", "boolean", "parameter", "from", "a", "CGI", "form", "(", "1", "=", "True", "other", "string", "=", "False", "absent", "/", "zero", "-", "length", "string", "=", "None", ")", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L212-L218
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_int
def get_cgi_parameter_int(form: cgi.FieldStorage, key: str) -> Optional[int]: """ Extracts an integer parameter from a CGI form, or ``None`` if the key is absent or the string value is not convertible to ``int``. """ return get_int_or_none(get_cgi_parameter_str(form, key))
python
def get_cgi_parameter_int(form: cgi.FieldStorage, key: str) -> Optional[int]: """ Extracts an integer parameter from a CGI form, or ``None`` if the key is absent or the string value is not convertible to ``int``. """ return get_int_or_none(get_cgi_parameter_str(form, key))
[ "def", "get_cgi_parameter_int", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "Optional", "[", "int", "]", ":", "return", "get_int_or_none", "(", "get_cgi_parameter_str", "(", "form", ",", "key", ")", ")" ]
Extracts an integer parameter from a CGI form, or ``None`` if the key is absent or the string value is not convertible to ``int``.
[ "Extracts", "an", "integer", "parameter", "from", "a", "CGI", "form", "or", "None", "if", "the", "key", "is", "absent", "or", "the", "string", "value", "is", "not", "convertible", "to", "int", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L221-L226
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_float
def get_cgi_parameter_float(form: cgi.FieldStorage, key: str) -> Optional[float]: """ Extracts a float parameter from a CGI form, or None if the key is absent or the string value is not convertible to ``float``. """ return get_float_or_none(get_cgi_parameter_str(form, key...
python
def get_cgi_parameter_float(form: cgi.FieldStorage, key: str) -> Optional[float]: """ Extracts a float parameter from a CGI form, or None if the key is absent or the string value is not convertible to ``float``. """ return get_float_or_none(get_cgi_parameter_str(form, key...
[ "def", "get_cgi_parameter_float", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "Optional", "[", "float", "]", ":", "return", "get_float_or_none", "(", "get_cgi_parameter_str", "(", "form", ",", "key", ")", ")" ]
Extracts a float parameter from a CGI form, or None if the key is absent or the string value is not convertible to ``float``.
[ "Extracts", "a", "float", "parameter", "from", "a", "CGI", "form", "or", "None", "if", "the", "key", "is", "absent", "or", "the", "string", "value", "is", "not", "convertible", "to", "float", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L229-L235
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_datetime
def get_cgi_parameter_datetime(form: cgi.FieldStorage, key: str) -> Optional[datetime.datetime]: """ Extracts a date/time parameter from a CGI form. Applies the LOCAL timezone if none specified. """ try: s = get_cgi_parameter_str(form, key) if not s: ...
python
def get_cgi_parameter_datetime(form: cgi.FieldStorage, key: str) -> Optional[datetime.datetime]: """ Extracts a date/time parameter from a CGI form. Applies the LOCAL timezone if none specified. """ try: s = get_cgi_parameter_str(form, key) if not s: ...
[ "def", "get_cgi_parameter_datetime", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "try", ":", "s", "=", "get_cgi_parameter_str", "(", "form", ",", "key", ")", "if...
Extracts a date/time parameter from a CGI form. Applies the LOCAL timezone if none specified.
[ "Extracts", "a", "date", "/", "time", "parameter", "from", "a", "CGI", "form", ".", "Applies", "the", "LOCAL", "timezone", "if", "none", "specified", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L238-L255
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_file
def get_cgi_parameter_file(form: cgi.FieldStorage, key: str) -> Optional[bytes]: """ Extracts a file's contents from a "file" input in a CGI form, or None if no such file was uploaded. """ (filename, filecontents) = get_cgi_parameter_filename_and_file(form, key) return...
python
def get_cgi_parameter_file(form: cgi.FieldStorage, key: str) -> Optional[bytes]: """ Extracts a file's contents from a "file" input in a CGI form, or None if no such file was uploaded. """ (filename, filecontents) = get_cgi_parameter_filename_and_file(form, key) return...
[ "def", "get_cgi_parameter_file", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "Optional", "[", "bytes", "]", ":", "(", "filename", ",", "filecontents", ")", "=", "get_cgi_parameter_filename_and_file", "(", "form", ",", "ke...
Extracts a file's contents from a "file" input in a CGI form, or None if no such file was uploaded.
[ "Extracts", "a", "file", "s", "contents", "from", "a", "file", "input", "in", "a", "CGI", "form", "or", "None", "if", "no", "such", "file", "was", "uploaded", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L258-L265
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_parameter_filename_and_file
def get_cgi_parameter_filename_and_file(form: cgi.FieldStorage, key: str) \ -> Tuple[Optional[str], Optional[bytes]]: """ Extracts a file's name and contents from a "file" input in a CGI form. Returns ``(name, contents)``, or ``(None, None)`` if no such file was uploaded. """ if not (key...
python
def get_cgi_parameter_filename_and_file(form: cgi.FieldStorage, key: str) \ -> Tuple[Optional[str], Optional[bytes]]: """ Extracts a file's name and contents from a "file" input in a CGI form. Returns ``(name, contents)``, or ``(None, None)`` if no such file was uploaded. """ if not (key...
[ "def", "get_cgi_parameter_filename_and_file", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "Tuple", "[", "Optional", "[", "str", "]", ",", "Optional", "[", "bytes", "]", "]", ":", "if", "not", "(", "key", "in", "form...
Extracts a file's name and contents from a "file" input in a CGI form. Returns ``(name, contents)``, or ``(None, None)`` if no such file was uploaded.
[ "Extracts", "a", "file", "s", "name", "and", "contents", "from", "a", "file", "input", "in", "a", "CGI", "form", ".", "Returns", "(", "name", "contents", ")", "or", "(", "None", "None", ")", "if", "no", "such", "file", "was", "uploaded", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L268-L302
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
cgi_parameter_exists
def cgi_parameter_exists(form: cgi.FieldStorage, key: str) -> bool: """ Does a CGI form contain the key? """ s = get_cgi_parameter_str(form, key) return s is not None
python
def cgi_parameter_exists(form: cgi.FieldStorage, key: str) -> bool: """ Does a CGI form contain the key? """ s = get_cgi_parameter_str(form, key) return s is not None
[ "def", "cgi_parameter_exists", "(", "form", ":", "cgi", ".", "FieldStorage", ",", "key", ":", "str", ")", "->", "bool", ":", "s", "=", "get_cgi_parameter_str", "(", "form", ",", "key", ")", "return", "s", "is", "not", "None" ]
Does a CGI form contain the key?
[ "Does", "a", "CGI", "form", "contain", "the", "key?" ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L312-L317
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
getenv_escaped
def getenv_escaped(key: str, default: str = None) -> Optional[str]: """ Returns an environment variable's value, CGI-escaped, or ``None``. """ value = os.getenv(key, default) # noinspection PyDeprecation return cgi.escape(value) if value is not None else None
python
def getenv_escaped(key: str, default: str = None) -> Optional[str]: """ Returns an environment variable's value, CGI-escaped, or ``None``. """ value = os.getenv(key, default) # noinspection PyDeprecation return cgi.escape(value) if value is not None else None
[ "def", "getenv_escaped", "(", "key", ":", "str", ",", "default", ":", "str", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "value", "=", "os", ".", "getenv", "(", "key", ",", "default", ")", "# noinspection PyDeprecation", "return", "cgi", ...
Returns an environment variable's value, CGI-escaped, or ``None``.
[ "Returns", "an", "environment", "variable", "s", "value", "CGI", "-", "escaped", "or", "None", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L349-L355
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
getconfigvar_escaped
def getconfigvar_escaped(config: configparser.ConfigParser, section: str, key: str) -> Optional[str]: """ Returns a CGI-escaped version of the value read from an INI file using :class:`ConfigParser`, or ``None``. """ value = config.get(section, key) ...
python
def getconfigvar_escaped(config: configparser.ConfigParser, section: str, key: str) -> Optional[str]: """ Returns a CGI-escaped version of the value read from an INI file using :class:`ConfigParser`, or ``None``. """ value = config.get(section, key) ...
[ "def", "getconfigvar_escaped", "(", "config", ":", "configparser", ".", "ConfigParser", ",", "section", ":", "str", ",", "key", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "value", "=", "config", ".", "get", "(", "section", ",", "key", ")"...
Returns a CGI-escaped version of the value read from an INI file using :class:`ConfigParser`, or ``None``.
[ "Returns", "a", "CGI", "-", "escaped", "version", "of", "the", "value", "read", "from", "an", "INI", "file", "using", ":", "class", ":", "ConfigParser", "or", "None", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L358-L367
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_cgi_fieldstorage_from_wsgi_env
def get_cgi_fieldstorage_from_wsgi_env( env: Dict[str, str], include_query_string: bool = True) -> cgi.FieldStorage: """ Returns a :class:`cgi.FieldStorage` object from the WSGI environment. """ # http://stackoverflow.com/questions/530526/accessing-post-data-from-wsgi post_env = env....
python
def get_cgi_fieldstorage_from_wsgi_env( env: Dict[str, str], include_query_string: bool = True) -> cgi.FieldStorage: """ Returns a :class:`cgi.FieldStorage` object from the WSGI environment. """ # http://stackoverflow.com/questions/530526/accessing-post-data-from-wsgi post_env = env....
[ "def", "get_cgi_fieldstorage_from_wsgi_env", "(", "env", ":", "Dict", "[", "str", ",", "str", "]", ",", "include_query_string", ":", "bool", "=", "True", ")", "->", "cgi", ".", "FieldStorage", ":", "# http://stackoverflow.com/questions/530526/accessing-post-data-from-ws...
Returns a :class:`cgi.FieldStorage` object from the WSGI environment.
[ "Returns", "a", ":", "class", ":", "cgi", ".", "FieldStorage", "object", "from", "the", "WSGI", "environment", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L370-L385
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_png_data_url
def get_png_data_url(blob: Optional[bytes]) -> str: """ Converts a PNG blob into a local URL encapsulating the PNG. """ return BASE64_PNG_URL_PREFIX + base64.b64encode(blob).decode('ascii')
python
def get_png_data_url(blob: Optional[bytes]) -> str: """ Converts a PNG blob into a local URL encapsulating the PNG. """ return BASE64_PNG_URL_PREFIX + base64.b64encode(blob).decode('ascii')
[ "def", "get_png_data_url", "(", "blob", ":", "Optional", "[", "bytes", "]", ")", "->", "str", ":", "return", "BASE64_PNG_URL_PREFIX", "+", "base64", ".", "b64encode", "(", "blob", ")", ".", "decode", "(", "'ascii'", ")" ]
Converts a PNG blob into a local URL encapsulating the PNG.
[ "Converts", "a", "PNG", "blob", "into", "a", "local", "URL", "encapsulating", "the", "PNG", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L401-L405
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
get_png_img_html
def get_png_img_html(blob: Union[bytes, memoryview], extra_html_class: str = None) -> str: """ Converts a PNG blob to an HTML IMG tag with embedded data. """ return """<img {}src="{}" />""".format( 'class="{}" '.format(extra_html_class) if extra_html_class else "", g...
python
def get_png_img_html(blob: Union[bytes, memoryview], extra_html_class: str = None) -> str: """ Converts a PNG blob to an HTML IMG tag with embedded data. """ return """<img {}src="{}" />""".format( 'class="{}" '.format(extra_html_class) if extra_html_class else "", g...
[ "def", "get_png_img_html", "(", "blob", ":", "Union", "[", "bytes", ",", "memoryview", "]", ",", "extra_html_class", ":", "str", "=", "None", ")", "->", "str", ":", "return", "\"\"\"<img {}src=\"{}\" />\"\"\"", ".", "format", "(", "'class=\"{}\" '", ".", "form...
Converts a PNG blob to an HTML IMG tag with embedded data.
[ "Converts", "a", "PNG", "blob", "to", "an", "HTML", "IMG", "tag", "with", "embedded", "data", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L408-L416
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
pdf_result
def pdf_result(pdf_binary: bytes, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None, filename: str = None) -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for a PDF. """ extraheaders = extraheaders or [] if filename: extraheaders.append...
python
def pdf_result(pdf_binary: bytes, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None, filename: str = None) -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for a PDF. """ extraheaders = extraheaders or [] if filename: extraheaders.append...
[ "def", "pdf_result", "(", "pdf_binary", ":", "bytes", ",", "extraheaders", ":", "TYPE_WSGI_RESPONSE_HEADERS", "=", "None", ",", "filename", ":", "str", "=", "None", ")", "->", "WSGI_TUPLE_TYPE", ":", "extraheaders", "=", "extraheaders", "or", "[", "]", "if", ...
Returns ``(contenttype, extraheaders, data)`` tuple for a PDF.
[ "Returns", "(", "contenttype", "extraheaders", "data", ")", "tuple", "for", "a", "PDF", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L427-L442
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
zip_result
def zip_result(zip_binary: bytes, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None, filename: str = None) -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for a ZIP. """ extraheaders = extraheaders or [] if filename: extraheaders.append...
python
def zip_result(zip_binary: bytes, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None, filename: str = None) -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for a ZIP. """ extraheaders = extraheaders or [] if filename: extraheaders.append...
[ "def", "zip_result", "(", "zip_binary", ":", "bytes", ",", "extraheaders", ":", "TYPE_WSGI_RESPONSE_HEADERS", "=", "None", ",", "filename", ":", "str", "=", "None", ")", "->", "WSGI_TUPLE_TYPE", ":", "extraheaders", "=", "extraheaders", "or", "[", "]", "if", ...
Returns ``(contenttype, extraheaders, data)`` tuple for a ZIP.
[ "Returns", "(", "contenttype", "extraheaders", "data", ")", "tuple", "for", "a", "ZIP", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L445-L459
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
html_result
def html_result(html: str, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None) \ -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 HTML. """ extraheaders = extraheaders or [] return 'text/html; charset=utf-8', extraheaders, html.encode("utf-8"...
python
def html_result(html: str, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None) \ -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 HTML. """ extraheaders = extraheaders or [] return 'text/html; charset=utf-8', extraheaders, html.encode("utf-8"...
[ "def", "html_result", "(", "html", ":", "str", ",", "extraheaders", ":", "TYPE_WSGI_RESPONSE_HEADERS", "=", "None", ")", "->", "WSGI_TUPLE_TYPE", ":", "extraheaders", "=", "extraheaders", "or", "[", "]", "return", "'text/html; charset=utf-8'", ",", "extraheaders", ...
Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 HTML.
[ "Returns", "(", "contenttype", "extraheaders", "data", ")", "tuple", "for", "UTF", "-", "8", "HTML", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L462-L469
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
xml_result
def xml_result(xml: str, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None) \ -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 XML. """ extraheaders = extraheaders or [] return 'text/xml; charset=utf-8', extraheaders, xml.encode("utf-8")
python
def xml_result(xml: str, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None) \ -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 XML. """ extraheaders = extraheaders or [] return 'text/xml; charset=utf-8', extraheaders, xml.encode("utf-8")
[ "def", "xml_result", "(", "xml", ":", "str", ",", "extraheaders", ":", "TYPE_WSGI_RESPONSE_HEADERS", "=", "None", ")", "->", "WSGI_TUPLE_TYPE", ":", "extraheaders", "=", "extraheaders", "or", "[", "]", "return", "'text/xml; charset=utf-8'", ",", "extraheaders", ",...
Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 XML.
[ "Returns", "(", "contenttype", "extraheaders", "data", ")", "tuple", "for", "UTF", "-", "8", "XML", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L472-L479
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
text_result
def text_result(text: str, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None, filename: str = None) -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 text. """ extraheaders = extraheaders or [] if filename: extraheaders.append...
python
def text_result(text: str, extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None, filename: str = None) -> WSGI_TUPLE_TYPE: """ Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 text. """ extraheaders = extraheaders or [] if filename: extraheaders.append...
[ "def", "text_result", "(", "text", ":", "str", ",", "extraheaders", ":", "TYPE_WSGI_RESPONSE_HEADERS", "=", "None", ",", "filename", ":", "str", "=", "None", ")", "->", "WSGI_TUPLE_TYPE", ":", "extraheaders", "=", "extraheaders", "or", "[", "]", "if", "filen...
Returns ``(contenttype, extraheaders, data)`` tuple for UTF-8 text.
[ "Returns", "(", "contenttype", "extraheaders", "data", ")", "tuple", "for", "UTF", "-", "8", "text", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L482-L496
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
print_result_for_plain_cgi_script_from_tuple
def print_result_for_plain_cgi_script_from_tuple( contenttype_headers_content: WSGI_TUPLE_TYPE, status: str = '200 OK') -> None: """ Writes HTTP result to stdout. Args: contenttype_headers_content: the tuple ``(contenttype, extraheaders, data)`` status: ...
python
def print_result_for_plain_cgi_script_from_tuple( contenttype_headers_content: WSGI_TUPLE_TYPE, status: str = '200 OK') -> None: """ Writes HTTP result to stdout. Args: contenttype_headers_content: the tuple ``(contenttype, extraheaders, data)`` status: ...
[ "def", "print_result_for_plain_cgi_script_from_tuple", "(", "contenttype_headers_content", ":", "WSGI_TUPLE_TYPE", ",", "status", ":", "str", "=", "'200 OK'", ")", "->", "None", ":", "contenttype", ",", "headers", ",", "content", "=", "contenttype_headers_content", "pri...
Writes HTTP result to stdout. Args: contenttype_headers_content: the tuple ``(contenttype, extraheaders, data)`` status: HTTP status message (default ``"200 OK``)
[ "Writes", "HTTP", "result", "to", "stdout", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L520-L533
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
print_result_for_plain_cgi_script
def print_result_for_plain_cgi_script(contenttype: str, headers: TYPE_WSGI_RESPONSE_HEADERS, content: bytes, status: str = '200 OK') -> None: """ Writes HTTP request result to stdout. """ he...
python
def print_result_for_plain_cgi_script(contenttype: str, headers: TYPE_WSGI_RESPONSE_HEADERS, content: bytes, status: str = '200 OK') -> None: """ Writes HTTP request result to stdout. """ he...
[ "def", "print_result_for_plain_cgi_script", "(", "contenttype", ":", "str", ",", "headers", ":", "TYPE_WSGI_RESPONSE_HEADERS", ",", "content", ":", "bytes", ",", "status", ":", "str", "=", "'200 OK'", ")", "->", "None", ":", "headers", "=", "[", "(", "\"Status...
Writes HTTP request result to stdout.
[ "Writes", "HTTP", "request", "result", "to", "stdout", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L536-L549
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
wsgi_simple_responder
def wsgi_simple_responder( result: Union[str, bytes], handler: Callable[[Union[str, bytes]], WSGI_TUPLE_TYPE], start_response: TYPE_WSGI_START_RESPONSE, status: str = '200 OK', extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None) \ -> TYPE_WSGI_APP_RESULT: """ Simple ...
python
def wsgi_simple_responder( result: Union[str, bytes], handler: Callable[[Union[str, bytes]], WSGI_TUPLE_TYPE], start_response: TYPE_WSGI_START_RESPONSE, status: str = '200 OK', extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None) \ -> TYPE_WSGI_APP_RESULT: """ Simple ...
[ "def", "wsgi_simple_responder", "(", "result", ":", "Union", "[", "str", ",", "bytes", "]", ",", "handler", ":", "Callable", "[", "[", "Union", "[", "str", ",", "bytes", "]", "]", ",", "WSGI_TUPLE_TYPE", "]", ",", "start_response", ":", "TYPE_WSGI_START_RE...
Simple WSGI app. Args: result: the data to be processed by ``handler`` handler: a function returning a ``(contenttype, extraheaders, data)`` tuple, e.g. ``text_result``, ``html_result`` start_response: standard WSGI ``start_response`` function status: status code (defaul...
[ "Simple", "WSGI", "app", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L556-L587
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
webify
def webify(v: Any, preserve_newlines: bool = True) -> str: """ Converts a value into an HTML-safe ``str`` (formerly, in Python 2: ``unicode``). Converts value ``v`` to a string; escapes it to be safe in HTML format (escaping ampersands, replacing newlines with ``<br>``, etc.). Returns ``""`` fo...
python
def webify(v: Any, preserve_newlines: bool = True) -> str: """ Converts a value into an HTML-safe ``str`` (formerly, in Python 2: ``unicode``). Converts value ``v`` to a string; escapes it to be safe in HTML format (escaping ampersands, replacing newlines with ``<br>``, etc.). Returns ``""`` fo...
[ "def", "webify", "(", "v", ":", "Any", ",", "preserve_newlines", ":", "bool", "=", "True", ")", "->", "str", ":", "nl", "=", "\"<br>\"", "if", "preserve_newlines", "else", "\" \"", "if", "v", "is", "None", ":", "return", "\"\"", "if", "not", "isinstanc...
Converts a value into an HTML-safe ``str`` (formerly, in Python 2: ``unicode``). Converts value ``v`` to a string; escapes it to be safe in HTML format (escaping ampersands, replacing newlines with ``<br>``, etc.). Returns ``""`` for blank input.
[ "Converts", "a", "value", "into", "an", "HTML", "-", "safe", "str", "(", "formerly", "in", "Python", "2", ":", "unicode", ")", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L594-L609
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
bold_if_not_blank
def bold_if_not_blank(x: Optional[str]) -> str: """ HTML-emboldens content, unless blank. """ if x is None: return u"{}".format(x) return u"<b>{}</b>".format(x)
python
def bold_if_not_blank(x: Optional[str]) -> str: """ HTML-emboldens content, unless blank. """ if x is None: return u"{}".format(x) return u"<b>{}</b>".format(x)
[ "def", "bold_if_not_blank", "(", "x", ":", "Optional", "[", "str", "]", ")", "->", "str", ":", "if", "x", "is", "None", ":", "return", "u\"{}\"", ".", "format", "(", "x", ")", "return", "u\"<b>{}</b>\"", ".", "format", "(", "x", ")" ]
HTML-emboldens content, unless blank.
[ "HTML", "-", "emboldens", "content", "unless", "blank", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L628-L634
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
make_urls_hyperlinks
def make_urls_hyperlinks(text: str) -> str: """ Adds hyperlinks to text that appears to contain URLs. See - http://stackoverflow.com/questions/1071191 - ... except that double-replaces everything; e.g. try with ``text = "[email protected] [email protected]"`` - http://stackp.online.f...
python
def make_urls_hyperlinks(text: str) -> str: """ Adds hyperlinks to text that appears to contain URLs. See - http://stackoverflow.com/questions/1071191 - ... except that double-replaces everything; e.g. try with ``text = "[email protected] [email protected]"`` - http://stackp.online.f...
[ "def", "make_urls_hyperlinks", "(", "text", ":", "str", ")", "->", "str", ":", "find_url", "=", "r'''\n (?x)( # verbose identify URLs within text\n (http|ftp|gopher) # make sure we find a resource type\n :// # ...needs to be followed by colon...
Adds hyperlinks to text that appears to contain URLs. See - http://stackoverflow.com/questions/1071191 - ... except that double-replaces everything; e.g. try with ``text = "[email protected] [email protected]"`` - http://stackp.online.fr/?p=19
[ "Adds", "hyperlinks", "to", "text", "that", "appears", "to", "contain", "URLs", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L637-L668
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_web.py
html_table_from_query
def html_table_from_query(rows: Iterable[Iterable[Optional[str]]], descriptions: Iterable[Optional[str]]) -> str: """ Converts rows from an SQL query result to an HTML table. Suitable for processing output from the defunct function ``rnc_db.fetchall_with_fieldnames(sql)``. ...
python
def html_table_from_query(rows: Iterable[Iterable[Optional[str]]], descriptions: Iterable[Optional[str]]) -> str: """ Converts rows from an SQL query result to an HTML table. Suitable for processing output from the defunct function ``rnc_db.fetchall_with_fieldnames(sql)``. ...
[ "def", "html_table_from_query", "(", "rows", ":", "Iterable", "[", "Iterable", "[", "Optional", "[", "str", "]", "]", "]", ",", "descriptions", ":", "Iterable", "[", "Optional", "[", "str", "]", "]", ")", "->", "str", ":", "html", "=", "u\"<table>\\n\"",...
Converts rows from an SQL query result to an HTML table. Suitable for processing output from the defunct function ``rnc_db.fetchall_with_fieldnames(sql)``.
[ "Converts", "rows", "from", "an", "SQL", "query", "result", "to", "an", "HTML", "table", ".", "Suitable", "for", "processing", "output", "from", "the", "defunct", "function", "rnc_db", ".", "fetchall_with_fieldnames", "(", "sql", ")", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_web.py#L671-L698
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
rst_underline
def rst_underline(heading: str, underline_char: str) -> str: """ Underlines a heading for RST files. Args: heading: text to underline underline_char: character to use Returns: underlined heading, over two lines (without a final terminating newline) """ assert "\...
python
def rst_underline(heading: str, underline_char: str) -> str: """ Underlines a heading for RST files. Args: heading: text to underline underline_char: character to use Returns: underlined heading, over two lines (without a final terminating newline) """ assert "\...
[ "def", "rst_underline", "(", "heading", ":", "str", ",", "underline_char", ":", "str", ")", "->", "str", ":", "assert", "\"\\n\"", "not", "in", "heading", "assert", "len", "(", "underline_char", ")", "==", "1", "return", "heading", "+", "\"\\n\"", "+", "...
Underlines a heading for RST files. Args: heading: text to underline underline_char: character to use Returns: underlined heading, over two lines (without a final terminating newline)
[ "Underlines", "a", "heading", "for", "RST", "files", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L78-L92
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
write_if_allowed
def write_if_allowed(filename: str, content: str, overwrite: bool = False, mock: bool = False) -> None: """ Writes the contents to a file, if permitted. Args: filename: filename to write content: contents to write overwr...
python
def write_if_allowed(filename: str, content: str, overwrite: bool = False, mock: bool = False) -> None: """ Writes the contents to a file, if permitted. Args: filename: filename to write content: contents to write overwr...
[ "def", "write_if_allowed", "(", "filename", ":", "str", ",", "content", ":", "str", ",", "overwrite", ":", "bool", "=", "False", ",", "mock", ":", "bool", "=", "False", ")", "->", "None", ":", "# Check we're allowed", "if", "not", "overwrite", "and", "ex...
Writes the contents to a file, if permitted. Args: filename: filename to write content: contents to write overwrite: permit overwrites? mock: pretend to write, but don't Raises: RuntimeError: if file exists but overwriting not permitted
[ "Writes", "the", "contents", "to", "a", "file", "if", "permitted", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L100-L131
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
FileToAutodocument.rst_filename_rel_autodoc_index
def rst_filename_rel_autodoc_index(self, index_filename: str) -> str: """ Returns the filename of the target RST file, relative to a specified index file. Used to make the index refer to the RST. """ index_dir = dirname(abspath(expanduser(index_filename))) return relpath(...
python
def rst_filename_rel_autodoc_index(self, index_filename: str) -> str: """ Returns the filename of the target RST file, relative to a specified index file. Used to make the index refer to the RST. """ index_dir = dirname(abspath(expanduser(index_filename))) return relpath(...
[ "def", "rst_filename_rel_autodoc_index", "(", "self", ",", "index_filename", ":", "str", ")", "->", "str", ":", "index_dir", "=", "dirname", "(", "abspath", "(", "expanduser", "(", "index_filename", ")", ")", ")", "return", "relpath", "(", "self", ".", "targ...
Returns the filename of the target RST file, relative to a specified index file. Used to make the index refer to the RST.
[ "Returns", "the", "filename", "of", "the", "target", "RST", "file", "relative", "to", "a", "specified", "index", "file", ".", "Used", "to", "make", "the", "index", "refer", "to", "the", "RST", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L291-L297
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
FileToAutodocument.python_module_name
def python_module_name(self) -> str: """ Returns the name of the Python module that this instance refers to, in dotted Python module notation, or a blank string if it doesn't. """ if not self.is_python: return "" filepath = self.source_filename_rel_python_root...
python
def python_module_name(self) -> str: """ Returns the name of the Python module that this instance refers to, in dotted Python module notation, or a blank string if it doesn't. """ if not self.is_python: return "" filepath = self.source_filename_rel_python_root...
[ "def", "python_module_name", "(", "self", ")", "->", "str", ":", "if", "not", "self", ".", "is_python", ":", "return", "\"\"", "filepath", "=", "self", ".", "source_filename_rel_python_root", "dirs_and_base", "=", "splitext", "(", "filepath", ")", "[", "0", ...
Returns the name of the Python module that this instance refers to, in dotted Python module notation, or a blank string if it doesn't.
[ "Returns", "the", "name", "of", "the", "Python", "module", "that", "this", "instance", "refers", "to", "in", "dotted", "Python", "module", "notation", "or", "a", "blank", "string", "if", "it", "doesn", "t", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L300-L310
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
FileToAutodocument.pygments_language
def pygments_language(self) -> str: """ Returns the code type annotation for Pygments; e.g. ``python`` for Python, ``cpp`` for C++, etc. """ extension = splitext(self.source_filename)[1] if extension in self.pygments_language_override: return self.pygments_lan...
python
def pygments_language(self) -> str: """ Returns the code type annotation for Pygments; e.g. ``python`` for Python, ``cpp`` for C++, etc. """ extension = splitext(self.source_filename)[1] if extension in self.pygments_language_override: return self.pygments_lan...
[ "def", "pygments_language", "(", "self", ")", "->", "str", ":", "extension", "=", "splitext", "(", "self", ".", "source_filename", ")", "[", "1", "]", "if", "extension", "in", "self", ".", "pygments_language_override", ":", "return", "self", ".", "pygments_l...
Returns the code type annotation for Pygments; e.g. ``python`` for Python, ``cpp`` for C++, etc.
[ "Returns", "the", "code", "type", "annotation", "for", "Pygments", ";", "e", ".", "g", ".", "python", "for", "Python", "cpp", "for", "C", "++", "etc", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L313-L327
RudolfCardinal/pythonlib
cardinal_pythonlib/sphinxtools.py
FileToAutodocument.rst_content
def rst_content(self, prefix: str = "", suffix: str = "", heading_underline_char: str = "=", method: AutodocMethod = None) -> str: """ Returns the text contents of an RST file that will automatically document our sou...
python
def rst_content(self, prefix: str = "", suffix: str = "", heading_underline_char: str = "=", method: AutodocMethod = None) -> str: """ Returns the text contents of an RST file that will automatically document our sou...
[ "def", "rst_content", "(", "self", ",", "prefix", ":", "str", "=", "\"\"", ",", "suffix", ":", "str", "=", "\"\"", ",", "heading_underline_char", ":", "str", "=", "\"=\"", ",", "method", ":", "AutodocMethod", "=", "None", ")", "->", "str", ":", "spacer...
Returns the text contents of an RST file that will automatically document our source file. Args: prefix: prefix, e.g. RST copyright comment suffix: suffix, after the part we're creating heading_underline_char: RST character to use to underline the hea...
[ "Returns", "the", "text", "contents", "of", "an", "RST", "file", "that", "will", "automatically", "document", "our", "source", "file", "." ]
train
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sphinxtools.py#L329-L412