repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
prometheus/client_python
prometheus_client/exposition.py
make_wsgi_app
def make_wsgi_app(registry=REGISTRY): """Create a WSGI app which serves the metrics from a registry.""" def prometheus_app(environ, start_response): params = parse_qs(environ.get('QUERY_STRING', '')) r = registry encoder, content_type = choose_encoder(environ.get('HTTP_ACCEPT')) ...
python
def make_wsgi_app(registry=REGISTRY): """Create a WSGI app which serves the metrics from a registry.""" def prometheus_app(environ, start_response): params = parse_qs(environ.get('QUERY_STRING', '')) r = registry encoder, content_type = choose_encoder(environ.get('HTTP_ACCEPT')) ...
[ "def", "make_wsgi_app", "(", "registry", "=", "REGISTRY", ")", ":", "def", "prometheus_app", "(", "environ", ",", "start_response", ")", ":", "params", "=", "parse_qs", "(", "environ", ".", "get", "(", "'QUERY_STRING'", ",", "''", ")", ")", "r", "=", "re...
Create a WSGI app which serves the metrics from a registry.
[ "Create", "a", "WSGI", "app", "which", "serves", "the", "metrics", "from", "a", "registry", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L36-L52
train
Create a WSGI app which serves the metrics from a registry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
start_wsgi_server
def start_wsgi_server(port, addr='', registry=REGISTRY): """Starts a WSGI server for prometheus metrics as a daemon thread.""" app = make_wsgi_app(registry) httpd = make_server(addr, port, app, handler_class=_SilentHandler) t = threading.Thread(target=httpd.serve_forever) t.daemon = True t.start...
python
def start_wsgi_server(port, addr='', registry=REGISTRY): """Starts a WSGI server for prometheus metrics as a daemon thread.""" app = make_wsgi_app(registry) httpd = make_server(addr, port, app, handler_class=_SilentHandler) t = threading.Thread(target=httpd.serve_forever) t.daemon = True t.start...
[ "def", "start_wsgi_server", "(", "port", ",", "addr", "=", "''", ",", "registry", "=", "REGISTRY", ")", ":", "app", "=", "make_wsgi_app", "(", "registry", ")", "httpd", "=", "make_server", "(", "addr", ",", "port", ",", "app", ",", "handler_class", "=", ...
Starts a WSGI server for prometheus metrics as a daemon thread.
[ "Starts", "a", "WSGI", "server", "for", "prometheus", "metrics", "as", "a", "daemon", "thread", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L62-L68
train
Starts a WSGI server for prometheus metrics as a daemon thread.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
start_http_server
def start_http_server(port, addr='', registry=REGISTRY): """Starts an HTTP server for prometheus metrics as a daemon thread""" CustomMetricsHandler = MetricsHandler.factory(registry) httpd = _ThreadingSimpleServer((addr, port), CustomMetricsHandler) t = threading.Thread(target=httpd.serve_forever) t...
python
def start_http_server(port, addr='', registry=REGISTRY): """Starts an HTTP server for prometheus metrics as a daemon thread""" CustomMetricsHandler = MetricsHandler.factory(registry) httpd = _ThreadingSimpleServer((addr, port), CustomMetricsHandler) t = threading.Thread(target=httpd.serve_forever) t...
[ "def", "start_http_server", "(", "port", ",", "addr", "=", "''", ",", "registry", "=", "REGISTRY", ")", ":", "CustomMetricsHandler", "=", "MetricsHandler", ".", "factory", "(", "registry", ")", "httpd", "=", "_ThreadingSimpleServer", "(", "(", "addr", ",", "...
Starts an HTTP server for prometheus metrics as a daemon thread
[ "Starts", "an", "HTTP", "server", "for", "prometheus", "metrics", "as", "a", "daemon", "thread" ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L190-L196
train
Starts an HTTP server for prometheus metrics as a daemon thread
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
write_to_textfile
def write_to_textfile(path, registry): """Write metrics to the given path. This is intended for use with the Node exporter textfile collector. The path must end in .prom for the textfile collector to process it.""" tmppath = '%s.%s.%s' % (path, os.getpid(), threading.current_thread().ident) with op...
python
def write_to_textfile(path, registry): """Write metrics to the given path. This is intended for use with the Node exporter textfile collector. The path must end in .prom for the textfile collector to process it.""" tmppath = '%s.%s.%s' % (path, os.getpid(), threading.current_thread().ident) with op...
[ "def", "write_to_textfile", "(", "path", ",", "registry", ")", ":", "tmppath", "=", "'%s.%s.%s'", "%", "(", "path", ",", "os", ".", "getpid", "(", ")", ",", "threading", ".", "current_thread", "(", ")", ".", "ident", ")", "with", "open", "(", "tmppath"...
Write metrics to the given path. This is intended for use with the Node exporter textfile collector. The path must end in .prom for the textfile collector to process it.
[ "Write", "metrics", "to", "the", "given", "path", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L199-L208
train
Write metrics to the given path.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
default_handler
def default_handler(url, method, timeout, headers, data): """Default handler that implements HTTP/HTTPS connections. Used by the push_to_gateway functions. Can be re-used by other handlers.""" def handle(): request = Request(url, data=data) request.get_method = lambda: method for k...
python
def default_handler(url, method, timeout, headers, data): """Default handler that implements HTTP/HTTPS connections. Used by the push_to_gateway functions. Can be re-used by other handlers.""" def handle(): request = Request(url, data=data) request.get_method = lambda: method for k...
[ "def", "default_handler", "(", "url", ",", "method", ",", "timeout", ",", "headers", ",", "data", ")", ":", "def", "handle", "(", ")", ":", "request", "=", "Request", "(", "url", ",", "data", "=", "data", ")", "request", ".", "get_method", "=", "lamb...
Default handler that implements HTTP/HTTPS connections. Used by the push_to_gateway functions. Can be re-used by other handlers.
[ "Default", "handler", "that", "implements", "HTTP", "/", "HTTPS", "connections", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L211-L226
train
Default handler that implements HTTP and HTTPS connections.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
basic_auth_handler
def basic_auth_handler(url, method, timeout, headers, data, username=None, password=None): """Handler that implements HTTP/HTTPS connections with Basic Auth. Sets auth headers using supplied 'username' and 'password', if set. Used by the push_to_gateway functions. Can be re-used by other handlers.""" ...
python
def basic_auth_handler(url, method, timeout, headers, data, username=None, password=None): """Handler that implements HTTP/HTTPS connections with Basic Auth. Sets auth headers using supplied 'username' and 'password', if set. Used by the push_to_gateway functions. Can be re-used by other handlers.""" ...
[ "def", "basic_auth_handler", "(", "url", ",", "method", ",", "timeout", ",", "headers", ",", "data", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "def", "handle", "(", ")", ":", "\"\"\"Handler that implements HTTP Basic Auth.\n \"...
Handler that implements HTTP/HTTPS connections with Basic Auth. Sets auth headers using supplied 'username' and 'password', if set. Used by the push_to_gateway functions. Can be re-used by other handlers.
[ "Handler", "that", "implements", "HTTP", "/", "HTTPS", "connections", "with", "Basic", "Auth", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L229-L245
train
A basic auth handler that uses HTTP Basic Auth.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
push_to_gateway
def push_to_gateway( gateway, job, registry, grouping_key=None, timeout=30, handler=default_handler): """Push metrics to the given pushgateway. `gateway` the url for your push gateway. Either of the form 'http://pushgateway.local', or 'pushgateway.local'. Scheme defa...
python
def push_to_gateway( gateway, job, registry, grouping_key=None, timeout=30, handler=default_handler): """Push metrics to the given pushgateway. `gateway` the url for your push gateway. Either of the form 'http://pushgateway.local', or 'pushgateway.local'. Scheme defa...
[ "def", "push_to_gateway", "(", "gateway", ",", "job", ",", "registry", ",", "grouping_key", "=", "None", ",", "timeout", "=", "30", ",", "handler", "=", "default_handler", ")", ":", "_use_gateway", "(", "'PUT'", ",", "gateway", ",", "job", ",", "registry",...
Push metrics to the given pushgateway. `gateway` the url for your push gateway. Either of the form 'http://pushgateway.local', or 'pushgateway.local'. Scheme defaults to 'http' if none is provided `job` is the job label to be attached to all pushed metrics `registry` is an insta...
[ "Push", "metrics", "to", "the", "given", "pushgateway", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L248-L289
train
Push metrics to the given pushgateway.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
delete_from_gateway
def delete_from_gateway( gateway, job, grouping_key=None, timeout=30, handler=default_handler): """Delete metrics from the given pushgateway. `gateway` the url for your push gateway. Either of the form 'http://pushgateway.local', or 'pushgateway.local'. Scheme defaults to 'h...
python
def delete_from_gateway( gateway, job, grouping_key=None, timeout=30, handler=default_handler): """Delete metrics from the given pushgateway. `gateway` the url for your push gateway. Either of the form 'http://pushgateway.local', or 'pushgateway.local'. Scheme defaults to 'h...
[ "def", "delete_from_gateway", "(", "gateway", ",", "job", ",", "grouping_key", "=", "None", ",", "timeout", "=", "30", ",", "handler", "=", "default_handler", ")", ":", "_use_gateway", "(", "'DELETE'", ",", "gateway", ",", "job", ",", "None", ",", "groupin...
Delete metrics from the given pushgateway. `gateway` the url for your push gateway. Either of the form 'http://pushgateway.local', or 'pushgateway.local'. Scheme defaults to 'http' if none is provided `job` is the job label to be attached to all pushed metrics `grouping_key` ple...
[ "Delete", "metrics", "from", "the", "given", "pushgateway", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L318-L339
train
Delete metrics from the given pushgateway.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
instance_ip_grouping_key
def instance_ip_grouping_key(): """Grouping key with instance set to the IP Address of this host.""" with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as s: s.connect(('localhost', 0)) return {'instance': s.getsockname()[0]}
python
def instance_ip_grouping_key(): """Grouping key with instance set to the IP Address of this host.""" with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as s: s.connect(('localhost', 0)) return {'instance': s.getsockname()[0]}
[ "def", "instance_ip_grouping_key", "(", ")", ":", "with", "closing", "(", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", ")", "as", "s", ":", "s", ".", "connect", "(", "(", "'localhost'", ",", "0", ")", ...
Grouping key with instance set to the IP Address of this host.
[ "Grouping", "key", "with", "instance", "set", "to", "the", "IP", "Address", "of", "this", "host", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L364-L368
train
Returns a key that can be used to group the hosts by IP Address.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/exposition.py
MetricsHandler.factory
def factory(cls, registry): """Returns a dynamic MetricsHandler class tied to the passed registry. """ # This implementation relies on MetricsHandler.registry # (defined above and defaulted to REGISTRY). # As we have unicode_literals, we need to create a str() ...
python
def factory(cls, registry): """Returns a dynamic MetricsHandler class tied to the passed registry. """ # This implementation relies on MetricsHandler.registry # (defined above and defaulted to REGISTRY). # As we have unicode_literals, we need to create a str() ...
[ "def", "factory", "(", "cls", ",", "registry", ")", ":", "# This implementation relies on MetricsHandler.registry", "# (defined above and defaulted to REGISTRY).", "# As we have unicode_literals, we need to create a str()", "# object for type().", "cls_name", "=", "str", "(", "cls"...
Returns a dynamic MetricsHandler class tied to the passed registry.
[ "Returns", "a", "dynamic", "MetricsHandler", "class", "tied", "to", "the", "passed", "registry", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/exposition.py#L165-L177
train
Returns a dynamic MetricsHandler class tied to the passed registry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/openmetrics/parser.py
text_fd_to_metric_families
def text_fd_to_metric_families(fd): """Parse Prometheus text format from a file descriptor. This is a laxer parser than the main Go parser, so successful parsing does not imply that the parsed text meets the specification. Yields Metric's. """ name = None allowed_names = [] eof = F...
python
def text_fd_to_metric_families(fd): """Parse Prometheus text format from a file descriptor. This is a laxer parser than the main Go parser, so successful parsing does not imply that the parsed text meets the specification. Yields Metric's. """ name = None allowed_names = [] eof = F...
[ "def", "text_fd_to_metric_families", "(", "fd", ")", ":", "name", "=", "None", "allowed_names", "=", "[", "]", "eof", "=", "False", "seen_metrics", "=", "set", "(", ")", "def", "build_metric", "(", "name", ",", "documentation", ",", "typ", ",", "unit", "...
Parse Prometheus text format from a file descriptor. This is a laxer parser than the main Go parser, so successful parsing does not imply that the parsed text meets the specification. Yields Metric's.
[ "Parse", "Prometheus", "text", "format", "from", "a", "file", "descriptor", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/openmetrics/parser.py#L292-L455
train
Parse Prometheus text format from a file descriptor.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/registry.py
CollectorRegistry.register
def register(self, collector): """Add a collector to the registry.""" with self._lock: names = self._get_names(collector) duplicates = set(self._names_to_collectors).intersection(names) if duplicates: raise ValueError( 'Duplicated t...
python
def register(self, collector): """Add a collector to the registry.""" with self._lock: names = self._get_names(collector) duplicates = set(self._names_to_collectors).intersection(names) if duplicates: raise ValueError( 'Duplicated t...
[ "def", "register", "(", "self", ",", "collector", ")", ":", "with", "self", ".", "_lock", ":", "names", "=", "self", ".", "_get_names", "(", "collector", ")", "duplicates", "=", "set", "(", "self", ".", "_names_to_collectors", ")", ".", "intersection", "...
Add a collector to the registry.
[ "Add", "a", "collector", "to", "the", "registry", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/registry.py#L21-L32
train
Add a collector to the registry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/registry.py
CollectorRegistry.unregister
def unregister(self, collector): """Remove a collector from the registry.""" with self._lock: for name in self._collector_to_names[collector]: del self._names_to_collectors[name] del self._collector_to_names[collector]
python
def unregister(self, collector): """Remove a collector from the registry.""" with self._lock: for name in self._collector_to_names[collector]: del self._names_to_collectors[name] del self._collector_to_names[collector]
[ "def", "unregister", "(", "self", ",", "collector", ")", ":", "with", "self", ".", "_lock", ":", "for", "name", "in", "self", ".", "_collector_to_names", "[", "collector", "]", ":", "del", "self", ".", "_names_to_collectors", "[", "name", "]", "del", "se...
Remove a collector from the registry.
[ "Remove", "a", "collector", "from", "the", "registry", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/registry.py#L34-L39
train
Removes a collector from the registry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/registry.py
CollectorRegistry._get_names
def _get_names(self, collector): """Get names of timeseries the collector produces.""" desc_func = None # If there's a describe function, use it. try: desc_func = collector.describe except AttributeError: pass # Otherwise, if auto describe is enabl...
python
def _get_names(self, collector): """Get names of timeseries the collector produces.""" desc_func = None # If there's a describe function, use it. try: desc_func = collector.describe except AttributeError: pass # Otherwise, if auto describe is enabl...
[ "def", "_get_names", "(", "self", ",", "collector", ")", ":", "desc_func", "=", "None", "# If there's a describe function, use it.", "try", ":", "desc_func", "=", "collector", ".", "describe", "except", "AttributeError", ":", "pass", "# Otherwise, if auto describe is en...
Get names of timeseries the collector produces.
[ "Get", "names", "of", "timeseries", "the", "collector", "produces", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/registry.py#L41-L67
train
Get names of timeseries the collector produces.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/registry.py
CollectorRegistry.collect
def collect(self): """Yields metrics from the collectors in the registry.""" collectors = None with self._lock: collectors = copy.copy(self._collector_to_names) for collector in collectors: for metric in collector.collect(): yield metric
python
def collect(self): """Yields metrics from the collectors in the registry.""" collectors = None with self._lock: collectors = copy.copy(self._collector_to_names) for collector in collectors: for metric in collector.collect(): yield metric
[ "def", "collect", "(", "self", ")", ":", "collectors", "=", "None", "with", "self", ".", "_lock", ":", "collectors", "=", "copy", ".", "copy", "(", "self", ".", "_collector_to_names", ")", "for", "collector", "in", "collectors", ":", "for", "metric", "in...
Yields metrics from the collectors in the registry.
[ "Yields", "metrics", "from", "the", "collectors", "in", "the", "registry", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/registry.py#L69-L76
train
Yields metrics from the collectors in the registry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/registry.py
CollectorRegistry.restricted_registry
def restricted_registry(self, names): """Returns object that only collects some metrics. Returns an object which upon collect() will return only samples with the given names. Intended usage is: generate_latest(REGISTRY.restricted_registry(['a_timeseries'])) Experim...
python
def restricted_registry(self, names): """Returns object that only collects some metrics. Returns an object which upon collect() will return only samples with the given names. Intended usage is: generate_latest(REGISTRY.restricted_registry(['a_timeseries'])) Experim...
[ "def", "restricted_registry", "(", "self", ",", "names", ")", ":", "names", "=", "set", "(", "names", ")", "collectors", "=", "set", "(", ")", "with", "self", ".", "_lock", ":", "for", "name", "in", "names", ":", "if", "name", "in", "self", ".", "_...
Returns object that only collects some metrics. Returns an object which upon collect() will return only samples with the given names. Intended usage is: generate_latest(REGISTRY.restricted_registry(['a_timeseries'])) Experimental.
[ "Returns", "object", "that", "only", "collects", "some", "metrics", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/registry.py#L78-L107
train
Returns an object that only collects some metrics with the given names.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/registry.py
CollectorRegistry.get_sample_value
def get_sample_value(self, name, labels=None): """Returns the sample value, or None if not found. This is inefficient, and intended only for use in unittests. """ if labels is None: labels = {} for metric in self.collect(): for s in metric.samples: ...
python
def get_sample_value(self, name, labels=None): """Returns the sample value, or None if not found. This is inefficient, and intended only for use in unittests. """ if labels is None: labels = {} for metric in self.collect(): for s in metric.samples: ...
[ "def", "get_sample_value", "(", "self", ",", "name", ",", "labels", "=", "None", ")", ":", "if", "labels", "is", "None", ":", "labels", "=", "{", "}", "for", "metric", "in", "self", ".", "collect", "(", ")", ":", "for", "s", "in", "metric", ".", ...
Returns the sample value, or None if not found. This is inefficient, and intended only for use in unittests.
[ "Returns", "the", "sample", "value", "or", "None", "if", "not", "found", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/registry.py#L109-L120
train
Returns the sample value for the given name and labels.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/multiprocess.py
mark_process_dead
def mark_process_dead(pid, path=None): """Do bookkeeping for when one process dies in a multi-process setup.""" if path is None: path = os.environ.get('prometheus_multiproc_dir') for f in glob.glob(os.path.join(path, 'gauge_livesum_{0}.db'.format(pid))): os.remove(f) for f in glob.glob(o...
python
def mark_process_dead(pid, path=None): """Do bookkeeping for when one process dies in a multi-process setup.""" if path is None: path = os.environ.get('prometheus_multiproc_dir') for f in glob.glob(os.path.join(path, 'gauge_livesum_{0}.db'.format(pid))): os.remove(f) for f in glob.glob(o...
[ "def", "mark_process_dead", "(", "pid", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "'prometheus_multiproc_dir'", ")", "for", "f", "in", "glob", ".", "glob", "(", "os", ".",...
Do bookkeeping for when one process dies in a multi-process setup.
[ "Do", "bookkeeping", "for", "when", "one", "process", "dies", "in", "a", "multi", "-", "process", "setup", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/multiprocess.py#L121-L128
train
Mark a process as dead.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/multiprocess.py
MultiProcessCollector.merge
def merge(files, accumulate=True): """Merge metrics from given mmap files. By default, histograms are accumulated, as per prometheus wire format. But if writing the merged data back to mmap files, use accumulate=False to avoid compound accumulation. """ metrics = {} ...
python
def merge(files, accumulate=True): """Merge metrics from given mmap files. By default, histograms are accumulated, as per prometheus wire format. But if writing the merged data back to mmap files, use accumulate=False to avoid compound accumulation. """ metrics = {} ...
[ "def", "merge", "(", "files", ",", "accumulate", "=", "True", ")", ":", "metrics", "=", "{", "}", "for", "f", "in", "files", ":", "parts", "=", "os", ".", "path", ".", "basename", "(", "f", ")", ".", "split", "(", "'_'", ")", "typ", "=", "parts...
Merge metrics from given mmap files. By default, histograms are accumulated, as per prometheus wire format. But if writing the merged data back to mmap files, use accumulate=False to avoid compound accumulation.
[ "Merge", "metrics", "from", "given", "mmap", "files", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/multiprocess.py#L29-L114
train
Merge metrics from given mmap files.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/decorator.py
getargspec
def getargspec(f): """A replacement for inspect.getargspec""" spec = getfullargspec(f) return ArgSpec(spec.args, spec.varargs, spec.varkw, spec.defaults)
python
def getargspec(f): """A replacement for inspect.getargspec""" spec = getfullargspec(f) return ArgSpec(spec.args, spec.varargs, spec.varkw, spec.defaults)
[ "def", "getargspec", "(", "f", ")", ":", "spec", "=", "getfullargspec", "(", "f", ")", "return", "ArgSpec", "(", "spec", ".", "args", ",", "spec", ".", "varargs", ",", "spec", ".", "varkw", ",", "spec", ".", "defaults", ")" ]
A replacement for inspect.getargspec
[ "A", "replacement", "for", "inspect", ".", "getargspec" ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/decorator.py#L78-L81
train
A replacement for inspect. getargspec that returns ArgSpec
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/decorator.py
decorate
def decorate(func, caller): """ decorate(func, caller) decorates a function using a caller. """ evaldict = dict(_call_=caller, _func_=func) fun = FunctionMaker.create( func, "return _call_(_func_, %(shortsignature)s)", evaldict, __wrapped__=func) if hasattr(func, '__qualname__'):...
python
def decorate(func, caller): """ decorate(func, caller) decorates a function using a caller. """ evaldict = dict(_call_=caller, _func_=func) fun = FunctionMaker.create( func, "return _call_(_func_, %(shortsignature)s)", evaldict, __wrapped__=func) if hasattr(func, '__qualname__'):...
[ "def", "decorate", "(", "func", ",", "caller", ")", ":", "evaldict", "=", "dict", "(", "_call_", "=", "caller", ",", "_func_", "=", "func", ")", "fun", "=", "FunctionMaker", ".", "create", "(", "func", ",", "\"return _call_(_func_, %(shortsignature)s)\"", ",...
decorate(func, caller) decorates a function using a caller.
[ "decorate", "(", "func", "caller", ")", "decorates", "a", "function", "using", "a", "caller", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/decorator.py#L229-L239
train
Decorates a function using a caller.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/decorator.py
decorator
def decorator(caller, _func=None): """decorator(caller) converts a caller function into a decorator""" if _func is not None: # return a decorated function # this is obsolete behavior; you should use decorate instead return decorate(_func, caller) # else return a decorator function if in...
python
def decorator(caller, _func=None): """decorator(caller) converts a caller function into a decorator""" if _func is not None: # return a decorated function # this is obsolete behavior; you should use decorate instead return decorate(_func, caller) # else return a decorator function if in...
[ "def", "decorator", "(", "caller", ",", "_func", "=", "None", ")", ":", "if", "_func", "is", "not", "None", ":", "# return a decorated function", "# this is obsolete behavior; you should use decorate instead", "return", "decorate", "(", "_func", ",", "caller", ")", ...
decorator(caller) converts a caller function into a decorator
[ "decorator", "(", "caller", ")", "converts", "a", "caller", "function", "into", "a", "decorator" ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/decorator.py#L242-L265
train
decorator that converts a caller function into a decorator
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/decorator.py
append
def append(a, vancestors): """ Append ``a`` to the list of the virtual ancestors, unless it is already included. """ add = True for j, va in enumerate(vancestors): if issubclass(va, a): add = False break if issubclass(a, va): vancestors[j] = a ...
python
def append(a, vancestors): """ Append ``a`` to the list of the virtual ancestors, unless it is already included. """ add = True for j, va in enumerate(vancestors): if issubclass(va, a): add = False break if issubclass(a, va): vancestors[j] = a ...
[ "def", "append", "(", "a", ",", "vancestors", ")", ":", "add", "=", "True", "for", "j", ",", "va", "in", "enumerate", "(", "vancestors", ")", ":", "if", "issubclass", "(", "va", ",", "a", ")", ":", "add", "=", "False", "break", "if", "issubclass", ...
Append ``a`` to the list of the virtual ancestors, unless it is already included.
[ "Append", "a", "to", "the", "list", "of", "the", "virtual", "ancestors", "unless", "it", "is", "already", "included", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/decorator.py#L306-L320
train
Append a to the list of virtual ancestors unless it is already included.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/parser.py
text_fd_to_metric_families
def text_fd_to_metric_families(fd): """Parse Prometheus text format from a file descriptor. This is a laxer parser than the main Go parser, so successful parsing does not imply that the parsed text meets the specification. Yields Metric's. """ name = '' documentation = '' typ = 'un...
python
def text_fd_to_metric_families(fd): """Parse Prometheus text format from a file descriptor. This is a laxer parser than the main Go parser, so successful parsing does not imply that the parsed text meets the specification. Yields Metric's. """ name = '' documentation = '' typ = 'un...
[ "def", "text_fd_to_metric_families", "(", "fd", ")", ":", "name", "=", "''", "documentation", "=", "''", "typ", "=", "'untyped'", "samples", "=", "[", "]", "allowed_names", "=", "[", "]", "def", "build_metric", "(", "name", ",", "documentation", ",", "typ"...
Parse Prometheus text format from a file descriptor. This is a laxer parser than the main Go parser, so successful parsing does not imply that the parsed text meets the specification. Yields Metric's.
[ "Parse", "Prometheus", "text", "format", "from", "a", "file", "descriptor", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/parser.py#L144-L232
train
Parse Prometheus text format from a file descriptor. Yields Metric s.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/mmap_dict.py
mmap_key
def mmap_key(metric_name, name, labelnames, labelvalues): """Format a key for use in the mmap file.""" # ensure labels are in consistent order for identity labels = dict(zip(labelnames, labelvalues)) return json.dumps([metric_name, name, labels], sort_keys=True)
python
def mmap_key(metric_name, name, labelnames, labelvalues): """Format a key for use in the mmap file.""" # ensure labels are in consistent order for identity labels = dict(zip(labelnames, labelvalues)) return json.dumps([metric_name, name, labels], sort_keys=True)
[ "def", "mmap_key", "(", "metric_name", ",", "name", ",", "labelnames", ",", "labelvalues", ")", ":", "# ensure labels are in consistent order for identity", "labels", "=", "dict", "(", "zip", "(", "labelnames", ",", "labelvalues", ")", ")", "return", "json", ".", ...
Format a key for use in the mmap file.
[ "Format", "a", "key", "for", "use", "in", "the", "mmap", "file", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/mmap_dict.py#L125-L129
train
Format a key for use in the mmap file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/mmap_dict.py
MmapedDict._init_value
def _init_value(self, key): """Initialize a value. Lock must be held by caller.""" encoded = key.encode('utf-8') # Pad to be 8-byte aligned. padded = encoded + (b' ' * (8 - (len(encoded) + 4) % 8)) value = struct.pack('i{0}sd'.format(len(padded)).encode(), len(encoded), padded, 0...
python
def _init_value(self, key): """Initialize a value. Lock must be held by caller.""" encoded = key.encode('utf-8') # Pad to be 8-byte aligned. padded = encoded + (b' ' * (8 - (len(encoded) + 4) % 8)) value = struct.pack('i{0}sd'.format(len(padded)).encode(), len(encoded), padded, 0...
[ "def", "_init_value", "(", "self", ",", "key", ")", ":", "encoded", "=", "key", ".", "encode", "(", "'utf-8'", ")", "# Pad to be 8-byte aligned.", "padded", "=", "encoded", "+", "(", "b' '", "*", "(", "8", "-", "(", "len", "(", "encoded", ")", "+", "...
Initialize a value. Lock must be held by caller.
[ "Initialize", "a", "value", ".", "Lock", "must", "be", "held", "by", "caller", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/mmap_dict.py#L56-L71
train
Initialize a value. Lock must be held by caller.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/mmap_dict.py
MmapedDict._read_all_values
def _read_all_values(self): """Yield (key, value, pos). No locking is performed.""" pos = 8 # cache variables to local ones and prevent attributes lookup # on every loop iteration used = self._used data = self._m unpack_from = struct.unpack_from while p...
python
def _read_all_values(self): """Yield (key, value, pos). No locking is performed.""" pos = 8 # cache variables to local ones and prevent attributes lookup # on every loop iteration used = self._used data = self._m unpack_from = struct.unpack_from while p...
[ "def", "_read_all_values", "(", "self", ")", ":", "pos", "=", "8", "# cache variables to local ones and prevent attributes lookup", "# on every loop iteration", "used", "=", "self", ".", "_used", "data", "=", "self", ".", "_m", "unpack_from", "=", "struct", ".", "un...
Yield (key, value, pos). No locking is performed.
[ "Yield", "(", "key", "value", "pos", ")", ".", "No", "locking", "is", "performed", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/mmap_dict.py#L73-L96
train
Yields all the values in the cache.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics.py
MetricWrapperBase.labels
def labels(self, *labelvalues, **labelkwargs): """Return the child for the given labelset. All metrics can have labels, allowing grouping of related time series. Taking a counter as an example: from prometheus_client import Counter c = Counter('my_requests_total', 'HTT...
python
def labels(self, *labelvalues, **labelkwargs): """Return the child for the given labelset. All metrics can have labels, allowing grouping of related time series. Taking a counter as an example: from prometheus_client import Counter c = Counter('my_requests_total', 'HTT...
[ "def", "labels", "(", "self", ",", "*", "labelvalues", ",", "*", "*", "labelkwargs", ")", ":", "if", "not", "self", ".", "_labelnames", ":", "raise", "ValueError", "(", "'No label names were set when constructing %s'", "%", "self", ")", "if", "self", ".", "_...
Return the child for the given labelset. All metrics can have labels, allowing grouping of related time series. Taking a counter as an example: from prometheus_client import Counter c = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint']) c.labels(...
[ "Return", "the", "child", "for", "the", "given", "labelset", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics.py#L105-L158
train
Return the child for the given labelset.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics.py
MetricWrapperBase.remove
def remove(self, *labelvalues): if not self._labelnames: raise ValueError('No label names were set when constructing %s' % self) """Remove the given labelset from the metric.""" if len(labelvalues) != len(self._labelnames): raise ValueError('Incorrect label count (expect...
python
def remove(self, *labelvalues): if not self._labelnames: raise ValueError('No label names were set when constructing %s' % self) """Remove the given labelset from the metric.""" if len(labelvalues) != len(self._labelnames): raise ValueError('Incorrect label count (expect...
[ "def", "remove", "(", "self", ",", "*", "labelvalues", ")", ":", "if", "not", "self", ".", "_labelnames", ":", "raise", "ValueError", "(", "'No label names were set when constructing %s'", "%", "self", ")", "if", "len", "(", "labelvalues", ")", "!=", "len", ...
Remove the given labelset from the metric.
[ "Remove", "the", "given", "labelset", "from", "the", "metric", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics.py#L160-L169
train
Removes the given labelset from the metric.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics.py
Gauge.set_function
def set_function(self, f): """Call the provided function to return the Gauge value. The function must return a float, and may be called from multiple threads. All other methods of the Gauge become NOOPs. """ def samples(self): return (('', {}, float(f())),) ...
python
def set_function(self, f): """Call the provided function to return the Gauge value. The function must return a float, and may be called from multiple threads. All other methods of the Gauge become NOOPs. """ def samples(self): return (('', {}, float(f())),) ...
[ "def", "set_function", "(", "self", ",", "f", ")", ":", "def", "samples", "(", "self", ")", ":", "return", "(", "(", "''", ",", "{", "}", ",", "float", "(", "f", "(", ")", ")", ")", ",", ")", "self", ".", "_child_samples", "=", "types", ".", ...
Call the provided function to return the Gauge value. The function must return a float, and may be called from multiple threads. All other methods of the Gauge become NOOPs.
[ "Call", "the", "provided", "function", "to", "return", "the", "Gauge", "value", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics.py#L362-L372
train
Call the provided function to return the Gauge value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics.py
Summary.observe
def observe(self, amount): """Observe the given amount.""" self._count.inc(1) self._sum.inc(amount)
python
def observe(self, amount): """Observe the given amount.""" self._count.inc(1) self._sum.inc(amount)
[ "def", "observe", "(", "self", ",", "amount", ")", ":", "self", ".", "_count", ".", "inc", "(", "1", ")", "self", ".", "_sum", ".", "inc", "(", "amount", ")" ]
Observe the given amount.
[ "Observe", "the", "given", "amount", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics.py#L417-L420
train
Observe the given amount.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics.py
Histogram.observe
def observe(self, amount): """Observe the given amount.""" self._sum.inc(amount) for i, bound in enumerate(self._upper_bounds): if amount <= bound: self._buckets[i].inc(1) break
python
def observe(self, amount): """Observe the given amount.""" self._sum.inc(amount) for i, bound in enumerate(self._upper_bounds): if amount <= bound: self._buckets[i].inc(1) break
[ "def", "observe", "(", "self", ",", "amount", ")", ":", "self", ".", "_sum", ".", "inc", "(", "amount", ")", "for", "i", ",", "bound", "in", "enumerate", "(", "self", ".", "_upper_bounds", ")", ":", "if", "amount", "<=", "bound", ":", "self", ".", ...
Observe the given amount.
[ "Observe", "the", "given", "amount", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics.py#L525-L531
train
Observe the given amount.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics.py
Info.info
def info(self, val): """Set info metric.""" if self._labelname_set.intersection(val.keys()): raise ValueError('Overlapping labels for Info metric, metric: %s child: %s' % ( self._labelnames, val)) with self._lock: self._value = dict(val)
python
def info(self, val): """Set info metric.""" if self._labelname_set.intersection(val.keys()): raise ValueError('Overlapping labels for Info metric, metric: %s child: %s' % ( self._labelnames, val)) with self._lock: self._value = dict(val)
[ "def", "info", "(", "self", ",", "val", ")", ":", "if", "self", ".", "_labelname_set", ".", "intersection", "(", "val", ".", "keys", "(", ")", ")", ":", "raise", "ValueError", "(", "'Overlapping labels for Info metric, metric: %s child: %s'", "%", "(", "self",...
Set info metric.
[ "Set", "info", "metric", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics.py#L575-L581
train
Set the value of the Info metric.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
prometheus/client_python
prometheus_client/metrics.py
Enum.state
def state(self, state): """Set enum metric state.""" with self._lock: self._value = self._states.index(state)
python
def state(self, state): """Set enum metric state.""" with self._lock: self._value = self._states.index(state)
[ "def", "state", "(", "self", ",", "state", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_value", "=", "self", ".", "_states", ".", "index", "(", "state", ")" ]
Set enum metric state.
[ "Set", "enum", "metric", "state", "." ]
31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb
https://github.com/prometheus/client_python/blob/31f5557e2e84ca4ffa9a03abf6e3f4d0c8b8c3eb/prometheus_client/metrics.py#L634-L637
train
Set enum metric state.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/dupefilter.py
RFPDupeFilter.from_settings
def from_settings(cls, settings): """Returns an instance from given settings. This uses by default the key ``dupefilter:<timestamp>``. When using the ``scrapy_redis.scheduler.Scheduler`` class, this method is not used as it needs to pass the spider name in the key. Parameters ...
python
def from_settings(cls, settings): """Returns an instance from given settings. This uses by default the key ``dupefilter:<timestamp>``. When using the ``scrapy_redis.scheduler.Scheduler`` class, this method is not used as it needs to pass the spider name in the key. Parameters ...
[ "def", "from_settings", "(", "cls", ",", "settings", ")", ":", "server", "=", "get_redis_from_settings", "(", "settings", ")", "# XXX: This creates one-time key. needed to support to use this", "# class as standalone dupefilter with scrapy's default scheduler", "# if scrapy passes sp...
Returns an instance from given settings. This uses by default the key ``dupefilter:<timestamp>``. When using the ``scrapy_redis.scheduler.Scheduler`` class, this method is not used as it needs to pass the spider name in the key. Parameters ---------- settings : scrapy.s...
[ "Returns", "an", "instance", "from", "given", "settings", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/dupefilter.py#L43-L68
train
Returns an instance of the class from given settings.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/dupefilter.py
RFPDupeFilter.request_seen
def request_seen(self, request): """Returns True if request was already seen. Parameters ---------- request : scrapy.http.Request Returns ------- bool """ fp = self.request_fingerprint(request) # This returns the number of values added, ...
python
def request_seen(self, request): """Returns True if request was already seen. Parameters ---------- request : scrapy.http.Request Returns ------- bool """ fp = self.request_fingerprint(request) # This returns the number of values added, ...
[ "def", "request_seen", "(", "self", ",", "request", ")", ":", "fp", "=", "self", ".", "request_fingerprint", "(", "request", ")", "# This returns the number of values added, zero if already exists.", "added", "=", "self", ".", "server", ".", "sadd", "(", "self", "...
Returns True if request was already seen. Parameters ---------- request : scrapy.http.Request Returns ------- bool
[ "Returns", "True", "if", "request", "was", "already", "seen", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/dupefilter.py#L86-L101
train
Returns True if request was already seen.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/dupefilter.py
RFPDupeFilter.log
def log(self, request, spider): """Logs given request. Parameters ---------- request : scrapy.http.Request spider : scrapy.spiders.Spider """ if self.debug: msg = "Filtered duplicate request: %(request)s" self.logger.debug(msg, {'request'...
python
def log(self, request, spider): """Logs given request. Parameters ---------- request : scrapy.http.Request spider : scrapy.spiders.Spider """ if self.debug: msg = "Filtered duplicate request: %(request)s" self.logger.debug(msg, {'request'...
[ "def", "log", "(", "self", ",", "request", ",", "spider", ")", ":", "if", "self", ".", "debug", ":", "msg", "=", "\"Filtered duplicate request: %(request)s\"", "self", ".", "logger", ".", "debug", "(", "msg", ",", "{", "'request'", ":", "request", "}", "...
Logs given request. Parameters ---------- request : scrapy.http.Request spider : scrapy.spiders.Spider
[ "Logs", "given", "request", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/dupefilter.py#L140-L157
train
Logs given request.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
example-project/process_items.py
process_items
def process_items(r, keys, timeout, limit=0, log_every=1000, wait=.1): """Process items from a redis queue. Parameters ---------- r : Redis Redis connection instance. keys : list List of keys to read the items from. timeout: int Read timeout. """ limit = limit o...
python
def process_items(r, keys, timeout, limit=0, log_every=1000, wait=.1): """Process items from a redis queue. Parameters ---------- r : Redis Redis connection instance. keys : list List of keys to read the items from. timeout: int Read timeout. """ limit = limit o...
[ "def", "process_items", "(", "r", ",", "keys", ",", "timeout", ",", "limit", "=", "0", ",", "log_every", "=", "1000", ",", "wait", "=", ".1", ")", ":", "limit", "=", "limit", "or", "float", "(", "'inf'", ")", "processed", "=", "0", "while", "proces...
Process items from a redis queue. Parameters ---------- r : Redis Redis connection instance. keys : list List of keys to read the items from. timeout: int Read timeout.
[ "Process", "items", "from", "a", "redis", "queue", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/example-project/process_items.py#L20-L61
train
Process items from a redis queue.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/connection.py
get_redis_from_settings
def get_redis_from_settings(settings): """Returns a redis client instance from given Scrapy settings object. This function uses ``get_client`` to instantiate the client and uses ``defaults.REDIS_PARAMS`` global as defaults values for the parameters. You can override them using the ``REDIS_PARAMS`` sett...
python
def get_redis_from_settings(settings): """Returns a redis client instance from given Scrapy settings object. This function uses ``get_client`` to instantiate the client and uses ``defaults.REDIS_PARAMS`` global as defaults values for the parameters. You can override them using the ``REDIS_PARAMS`` sett...
[ "def", "get_redis_from_settings", "(", "settings", ")", ":", "params", "=", "defaults", ".", "REDIS_PARAMS", ".", "copy", "(", ")", "params", ".", "update", "(", "settings", ".", "getdict", "(", "'REDIS_PARAMS'", ")", ")", "# XXX: Deprecate REDIS_* settings.", "...
Returns a redis client instance from given Scrapy settings object. This function uses ``get_client`` to instantiate the client and uses ``defaults.REDIS_PARAMS`` global as defaults values for the parameters. You can override them using the ``REDIS_PARAMS`` setting. Parameters ---------- settin...
[ "Returns", "a", "redis", "client", "instance", "from", "given", "Scrapy", "settings", "object", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/connection.py#L17-L60
train
Returns a Redis client instance from a Scrapy settings object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/connection.py
get_redis
def get_redis(**kwargs): """Returns a redis client instance. Parameters ---------- redis_cls : class, optional Defaults to ``redis.StrictRedis``. url : str, optional If given, ``redis_cls.from_url`` is used to instantiate the class. **kwargs Extra parameters to be passed...
python
def get_redis(**kwargs): """Returns a redis client instance. Parameters ---------- redis_cls : class, optional Defaults to ``redis.StrictRedis``. url : str, optional If given, ``redis_cls.from_url`` is used to instantiate the class. **kwargs Extra parameters to be passed...
[ "def", "get_redis", "(", "*", "*", "kwargs", ")", ":", "redis_cls", "=", "kwargs", ".", "pop", "(", "'redis_cls'", ",", "defaults", ".", "REDIS_CLS", ")", "url", "=", "kwargs", ".", "pop", "(", "'url'", ",", "None", ")", "if", "url", ":", "return", ...
Returns a redis client instance. Parameters ---------- redis_cls : class, optional Defaults to ``redis.StrictRedis``. url : str, optional If given, ``redis_cls.from_url`` is used to instantiate the class. **kwargs Extra parameters to be passed to the ``redis_cls`` class. ...
[ "Returns", "a", "redis", "client", "instance", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/connection.py#L67-L90
train
Returns a Redis client instance.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/utils.py
bytes_to_str
def bytes_to_str(s, encoding='utf-8'): """Returns a str if a bytes object is given.""" if six.PY3 and isinstance(s, bytes): return s.decode(encoding) return s
python
def bytes_to_str(s, encoding='utf-8'): """Returns a str if a bytes object is given.""" if six.PY3 and isinstance(s, bytes): return s.decode(encoding) return s
[ "def", "bytes_to_str", "(", "s", ",", "encoding", "=", "'utf-8'", ")", ":", "if", "six", ".", "PY3", "and", "isinstance", "(", "s", ",", "bytes", ")", ":", "return", "s", ".", "decode", "(", "encoding", ")", "return", "s" ]
Returns a str if a bytes object is given.
[ "Returns", "a", "str", "if", "a", "bytes", "object", "is", "given", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/utils.py#L4-L8
train
Returns a str if a bytes object is given.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/spiders.py
RedisMixin.setup_redis
def setup_redis(self, crawler=None): """Setup redis connection and idle signal. This should be called after the spider has set its crawler object. """ if self.server is not None: return if crawler is None: # We allow optional crawler argument to keep bac...
python
def setup_redis(self, crawler=None): """Setup redis connection and idle signal. This should be called after the spider has set its crawler object. """ if self.server is not None: return if crawler is None: # We allow optional crawler argument to keep bac...
[ "def", "setup_redis", "(", "self", ",", "crawler", "=", "None", ")", ":", "if", "self", ".", "server", "is", "not", "None", ":", "return", "if", "crawler", "is", "None", ":", "# We allow optional crawler argument to keep backwards", "# compatibility.", "# XXX: Rai...
Setup redis connection and idle signal. This should be called after the spider has set its crawler object.
[ "Setup", "redis", "connection", "and", "idle", "signal", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/spiders.py#L22-L73
train
Setup redis connection and idle signal.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/spiders.py
RedisMixin.next_requests
def next_requests(self): """Returns a request to be scheduled or none.""" use_set = self.settings.getbool('REDIS_START_URLS_AS_SET', defaults.START_URLS_AS_SET) fetch_one = self.server.spop if use_set else self.server.lpop # XXX: Do we need to use a timeout here? found = 0 ...
python
def next_requests(self): """Returns a request to be scheduled or none.""" use_set = self.settings.getbool('REDIS_START_URLS_AS_SET', defaults.START_URLS_AS_SET) fetch_one = self.server.spop if use_set else self.server.lpop # XXX: Do we need to use a timeout here? found = 0 ...
[ "def", "next_requests", "(", "self", ")", ":", "use_set", "=", "self", ".", "settings", ".", "getbool", "(", "'REDIS_START_URLS_AS_SET'", ",", "defaults", ".", "START_URLS_AS_SET", ")", "fetch_one", "=", "self", ".", "server", ".", "spop", "if", "use_set", "...
Returns a request to be scheduled or none.
[ "Returns", "a", "request", "to", "be", "scheduled", "or", "none", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/spiders.py#L75-L95
train
Returns a generator that yields the next set of requests.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/spiders.py
RedisMixin.make_request_from_data
def make_request_from_data(self, data): """Returns a Request instance from data coming from Redis. By default, ``data`` is an encoded URL. You can override this method to provide your own message decoding. Parameters ---------- data : bytes Message from redi...
python
def make_request_from_data(self, data): """Returns a Request instance from data coming from Redis. By default, ``data`` is an encoded URL. You can override this method to provide your own message decoding. Parameters ---------- data : bytes Message from redi...
[ "def", "make_request_from_data", "(", "self", ",", "data", ")", ":", "url", "=", "bytes_to_str", "(", "data", ",", "self", ".", "redis_encoding", ")", "return", "self", ".", "make_requests_from_url", "(", "url", ")" ]
Returns a Request instance from data coming from Redis. By default, ``data`` is an encoded URL. You can override this method to provide your own message decoding. Parameters ---------- data : bytes Message from redis.
[ "Returns", "a", "Request", "instance", "from", "data", "coming", "from", "Redis", "." ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/spiders.py#L97-L110
train
Returns a Request instance from data coming from Redis.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/spiders.py
RedisMixin.schedule_next_requests
def schedule_next_requests(self): """Schedules a request if available""" # TODO: While there is capacity, schedule a batch of redis requests. for req in self.next_requests(): self.crawler.engine.crawl(req, spider=self)
python
def schedule_next_requests(self): """Schedules a request if available""" # TODO: While there is capacity, schedule a batch of redis requests. for req in self.next_requests(): self.crawler.engine.crawl(req, spider=self)
[ "def", "schedule_next_requests", "(", "self", ")", ":", "# TODO: While there is capacity, schedule a batch of redis requests.", "for", "req", "in", "self", ".", "next_requests", "(", ")", ":", "self", ".", "crawler", ".", "engine", ".", "crawl", "(", "req", ",", "...
Schedules a request if available
[ "Schedules", "a", "request", "if", "available" ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/spiders.py#L112-L116
train
Schedules a request if available.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/queue.py
Base._encode_request
def _encode_request(self, request): """Encode a request object""" obj = request_to_dict(request, self.spider) return self.serializer.dumps(obj)
python
def _encode_request(self, request): """Encode a request object""" obj = request_to_dict(request, self.spider) return self.serializer.dumps(obj)
[ "def", "_encode_request", "(", "self", ",", "request", ")", ":", "obj", "=", "request_to_dict", "(", "request", ",", "self", ".", "spider", ")", "return", "self", ".", "serializer", ".", "dumps", "(", "obj", ")" ]
Encode a request object
[ "Encode", "a", "request", "object" ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/queue.py#L40-L43
train
Encode a request object
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/queue.py
Base._decode_request
def _decode_request(self, encoded_request): """Decode an request previously encoded""" obj = self.serializer.loads(encoded_request) return request_from_dict(obj, self.spider)
python
def _decode_request(self, encoded_request): """Decode an request previously encoded""" obj = self.serializer.loads(encoded_request) return request_from_dict(obj, self.spider)
[ "def", "_decode_request", "(", "self", ",", "encoded_request", ")", ":", "obj", "=", "self", ".", "serializer", ".", "loads", "(", "encoded_request", ")", "return", "request_from_dict", "(", "obj", ",", "self", ".", "spider", ")" ]
Decode an request previously encoded
[ "Decode", "an", "request", "previously", "encoded" ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/queue.py#L45-L48
train
Decode an encoded request from the serialized version
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/queue.py
FifoQueue.push
def push(self, request): """Push a request""" self.server.lpush(self.key, self._encode_request(request))
python
def push(self, request): """Push a request""" self.server.lpush(self.key, self._encode_request(request))
[ "def", "push", "(", "self", ",", "request", ")", ":", "self", ".", "server", ".", "lpush", "(", "self", ".", "key", ",", "self", ".", "_encode_request", "(", "request", ")", ")" ]
Push a request
[ "Push", "a", "request" ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/queue.py#L74-L76
train
Push a request onto the end of the list.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/queue.py
PriorityQueue.push
def push(self, request): """Push a request""" data = self._encode_request(request) score = -request.priority # We don't use zadd method as the order of arguments change depending on # whether the class is Redis or StrictRedis, and the option of using # kwargs only accepts...
python
def push(self, request): """Push a request""" data = self._encode_request(request) score = -request.priority # We don't use zadd method as the order of arguments change depending on # whether the class is Redis or StrictRedis, and the option of using # kwargs only accepts...
[ "def", "push", "(", "self", ",", "request", ")", ":", "data", "=", "self", ".", "_encode_request", "(", "request", ")", "score", "=", "-", "request", ".", "priority", "# We don't use zadd method as the order of arguments change depending on", "# whether the class is Red...
Push a request
[ "Push", "a", "request" ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/queue.py#L97-L104
train
Push a request to the set with the highest priority.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
rmax/scrapy-redis
src/scrapy_redis/queue.py
PriorityQueue.pop
def pop(self, timeout=0): """ Pop a request timeout not support in this queue class """ # use atomic range/remove using multi/exec pipe = self.server.pipeline() pipe.multi() pipe.zrange(self.key, 0, 0).zremrangebyrank(self.key, 0, 0) results, count...
python
def pop(self, timeout=0): """ Pop a request timeout not support in this queue class """ # use atomic range/remove using multi/exec pipe = self.server.pipeline() pipe.multi() pipe.zrange(self.key, 0, 0).zremrangebyrank(self.key, 0, 0) results, count...
[ "def", "pop", "(", "self", ",", "timeout", "=", "0", ")", ":", "# use atomic range/remove using multi/exec", "pipe", "=", "self", ".", "server", ".", "pipeline", "(", ")", "pipe", ".", "multi", "(", ")", "pipe", ".", "zrange", "(", "self", ".", "key", ...
Pop a request timeout not support in this queue class
[ "Pop", "a", "request", "timeout", "not", "support", "in", "this", "queue", "class" ]
31c022dd145654cb4ea1429f09852a82afa0a01c
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/queue.py#L106-L117
train
Pop a request from the queue.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
b-ryan/powerline-shell
powerline_shell/colortrans.py
rgb2short
def rgb2short(r, g, b): """ Find the closest xterm-256 approximation to the given RGB value. @param r,g,b: each is a number between 0-255 for the Red, Green, and Blue values @returns: integer between 0 and 255, compatible with xterm. >>> rgb2short(18, 52, 86) 23 >>> rgb2short(255, 255, 255) ...
python
def rgb2short(r, g, b): """ Find the closest xterm-256 approximation to the given RGB value. @param r,g,b: each is a number between 0-255 for the Red, Green, and Blue values @returns: integer between 0 and 255, compatible with xterm. >>> rgb2short(18, 52, 86) 23 >>> rgb2short(255, 255, 255) ...
[ "def", "rgb2short", "(", "r", ",", "g", ",", "b", ")", ":", "incs", "=", "(", "0x00", ",", "0x5f", ",", "0x87", ",", "0xaf", ",", "0xd7", ",", "0xff", ")", "# Break 6-char RGB code into 3 integer vals.", "parts", "=", "[", "r", ",", "g", ",", "b", ...
Find the closest xterm-256 approximation to the given RGB value. @param r,g,b: each is a number between 0-255 for the Red, Green, and Blue values @returns: integer between 0 and 255, compatible with xterm. >>> rgb2short(18, 52, 86) 23 >>> rgb2short(255, 255, 255) 231 >>> rgb2short(13, 173, 2...
[ "Find", "the", "closest", "xterm", "-", "256", "approximation", "to", "the", "given", "RGB", "value", "." ]
a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc
https://github.com/b-ryan/powerline-shell/blob/a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc/powerline_shell/colortrans.py#L284-L312
train
Find the closest xterm - 256 approximation to the given RGB value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
b-ryan/powerline-shell
powerline_shell/utils.py
RepoStats.n_or_empty
def n_or_empty(self, _key): """Given a string name of one of the properties of this class, returns the value of the property as a string when the value is greater than 1. When it is not greater than one, returns an empty string. As an example, if you want to show an icon for new files, ...
python
def n_or_empty(self, _key): """Given a string name of one of the properties of this class, returns the value of the property as a string when the value is greater than 1. When it is not greater than one, returns an empty string. As an example, if you want to show an icon for new files, ...
[ "def", "n_or_empty", "(", "self", ",", "_key", ")", ":", "return", "unicode_", "(", "self", "[", "_key", "]", ")", "if", "int", "(", "self", "[", "_key", "]", ")", ">", "1", "else", "u''" ]
Given a string name of one of the properties of this class, returns the value of the property as a string when the value is greater than 1. When it is not greater than one, returns an empty string. As an example, if you want to show an icon for new files, but you only want a number to a...
[ "Given", "a", "string", "name", "of", "one", "of", "the", "properties", "of", "this", "class", "returns", "the", "value", "of", "the", "property", "as", "a", "string", "when", "the", "value", "is", "greater", "than", "1", ".", "When", "it", "is", "not"...
a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc
https://github.com/b-ryan/powerline-shell/blob/a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc/powerline_shell/utils.py#L65-L76
train
Returns a string that represents the number of the entry in the class.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
b-ryan/powerline-shell
powerline_shell/segments/cwd.py
maybe_shorten_name
def maybe_shorten_name(powerline, name): """If the user has asked for each directory name to be shortened, will return the name up to their specified length. Otherwise returns the full name.""" max_size = powerline.segment_conf("cwd", "max_dir_size") if max_size: return name[:max_size] r...
python
def maybe_shorten_name(powerline, name): """If the user has asked for each directory name to be shortened, will return the name up to their specified length. Otherwise returns the full name.""" max_size = powerline.segment_conf("cwd", "max_dir_size") if max_size: return name[:max_size] r...
[ "def", "maybe_shorten_name", "(", "powerline", ",", "name", ")", ":", "max_size", "=", "powerline", ".", "segment_conf", "(", "\"cwd\"", ",", "\"max_dir_size\"", ")", "if", "max_size", ":", "return", "name", "[", ":", "max_size", "]", "return", "name" ]
If the user has asked for each directory name to be shortened, will return the name up to their specified length. Otherwise returns the full name.
[ "If", "the", "user", "has", "asked", "for", "each", "directory", "name", "to", "be", "shortened", "will", "return", "the", "name", "up", "to", "their", "specified", "length", ".", "Otherwise", "returns", "the", "full", "name", "." ]
a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc
https://github.com/b-ryan/powerline-shell/blob/a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc/powerline_shell/segments/cwd.py#L33-L40
train
If the user has asked for each directory name to be shortened return the full name. Otherwise returns the full name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
b-ryan/powerline-shell
powerline_shell/segments/cwd.py
get_fg_bg
def get_fg_bg(powerline, name, is_last_dir): """Returns the foreground and background color to use for the given name. """ if requires_special_home_display(powerline, name): return (powerline.theme.HOME_FG, powerline.theme.HOME_BG,) if is_last_dir: return (powerline.theme.CWD_FG, powerl...
python
def get_fg_bg(powerline, name, is_last_dir): """Returns the foreground and background color to use for the given name. """ if requires_special_home_display(powerline, name): return (powerline.theme.HOME_FG, powerline.theme.HOME_BG,) if is_last_dir: return (powerline.theme.CWD_FG, powerl...
[ "def", "get_fg_bg", "(", "powerline", ",", "name", ",", "is_last_dir", ")", ":", "if", "requires_special_home_display", "(", "powerline", ",", "name", ")", ":", "return", "(", "powerline", ".", "theme", ".", "HOME_FG", ",", "powerline", ".", "theme", ".", ...
Returns the foreground and background color to use for the given name.
[ "Returns", "the", "foreground", "and", "background", "color", "to", "use", "for", "the", "given", "name", "." ]
a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc
https://github.com/b-ryan/powerline-shell/blob/a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc/powerline_shell/segments/cwd.py#L43-L52
train
Returns the foreground and background color to use for the given name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
b-ryan/powerline-shell
powerline_shell/__init__.py
get_valid_cwd
def get_valid_cwd(): """Determine and check the current working directory for validity. Typically, an directory arises when you checkout a different branch on git that doesn't have this directory. When an invalid directory is found, a warning is printed to the screen, but the directory is still returne...
python
def get_valid_cwd(): """Determine and check the current working directory for validity. Typically, an directory arises when you checkout a different branch on git that doesn't have this directory. When an invalid directory is found, a warning is printed to the screen, but the directory is still returne...
[ "def", "get_valid_cwd", "(", ")", ":", "try", ":", "cwd", "=", "_current_dir", "(", ")", "except", ":", "warn", "(", "\"Your current directory is invalid. If you open a ticket at \"", "+", "\"https://github.com/milkbikis/powerline-shell/issues/new \"", "+", "\"we would love t...
Determine and check the current working directory for validity. Typically, an directory arises when you checkout a different branch on git that doesn't have this directory. When an invalid directory is found, a warning is printed to the screen, but the directory is still returned as-is, since this is w...
[ "Determine", "and", "check", "the", "current", "working", "directory", "for", "validity", "." ]
a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc
https://github.com/b-ryan/powerline-shell/blob/a9b8c9bb39dbfb7ec3c639e497b5a76fa6dcb8cc/powerline_shell/__init__.py#L30-L54
train
Determine and check the current working directory for validity.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
validate_email
def validate_email(value: str) -> Tuple[str, str]: """ Brutally simple email address validation. Note unlike most email address validation * raw ip address (literal) domain parts are not allowed. * "John Doe <local_part@domain.com>" style "pretty" email addresses are processed * the local part check...
python
def validate_email(value: str) -> Tuple[str, str]: """ Brutally simple email address validation. Note unlike most email address validation * raw ip address (literal) domain parts are not allowed. * "John Doe <local_part@domain.com>" style "pretty" email addresses are processed * the local part check...
[ "def", "validate_email", "(", "value", ":", "str", ")", "->", "Tuple", "[", "str", ",", "str", "]", ":", "if", "email_validator", "is", "None", ":", "raise", "ImportError", "(", "'email-validator is not installed, run `pip install pydantic[email]`'", ")", "m", "="...
Brutally simple email address validation. Note unlike most email address validation * raw ip address (literal) domain parts are not allowed. * "John Doe <local_part@domain.com>" style "pretty" email addresses are processed * the local part check is extremely basic. This raises the possibility of unicode spo...
[ "Brutally", "simple", "email", "address", "validation", ".", "Note", "unlike", "most", "email", "address", "validation", "*", "raw", "ip", "address", "(", "literal", ")", "domain", "parts", "are", "not", "allowed", ".", "*", "John", "Doe", "<local_part@domain"...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L49-L75
train
Validate an email address.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
make_dsn
def make_dsn( *, driver: str, user: str = None, password: str = None, host: str = None, port: str = None, name: str = None, query: Dict[str, Any] = None, ) -> str: """ Create a DSN from from connection settings. Stolen approximately from sqlalchemy/engine/url.py:URL. """...
python
def make_dsn( *, driver: str, user: str = None, password: str = None, host: str = None, port: str = None, name: str = None, query: Dict[str, Any] = None, ) -> str: """ Create a DSN from from connection settings. Stolen approximately from sqlalchemy/engine/url.py:URL. """...
[ "def", "make_dsn", "(", "*", ",", "driver", ":", "str", ",", "user", ":", "str", "=", "None", ",", "password", ":", "str", "=", "None", ",", "host", ":", "str", "=", "None", ",", "port", ":", "str", "=", "None", ",", "name", ":", "str", "=", ...
Create a DSN from from connection settings. Stolen approximately from sqlalchemy/engine/url.py:URL.
[ "Create", "a", "DSN", "from", "from", "connection", "settings", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L82-L117
train
Create a DSN from connection settings.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
import_string
def import_string(dotted_path: str) -> Any: """ Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import fails. """ try: module_path, class_name = dotted_path.strip(' ').rsplit('.', 1...
python
def import_string(dotted_path: str) -> Any: """ Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import fails. """ try: module_path, class_name = dotted_path.strip(' ').rsplit('.', 1...
[ "def", "import_string", "(", "dotted_path", ":", "str", ")", "->", "Any", ":", "try", ":", "module_path", ",", "class_name", "=", "dotted_path", ".", "strip", "(", "' '", ")", ".", "rsplit", "(", "'.'", ",", "1", ")", "except", "ValueError", "as", "e",...
Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the last name in the path. Raise ImportError if the import fails.
[ "Stolen", "approximately", "from", "django", ".", "Import", "a", "dotted", "module", "path", "and", "return", "the", "attribute", "/", "class", "designated", "by", "the", "last", "name", "in", "the", "path", ".", "Raise", "ImportError", "if", "the", "import"...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L120-L134
train
Import a dotted module path and return the attribute or class designated by the last name in the path. Raise ImportError if the import fails.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
truncate
def truncate(v: str, *, max_len: int = 80) -> str: """ Truncate a value and add a unicode ellipsis (three dots) to the end if it was too long """ if isinstance(v, str) and len(v) > (max_len - 2): # -3 so quote + string + … + quote has correct length return repr(v[: (max_len - 3)] + '…') ...
python
def truncate(v: str, *, max_len: int = 80) -> str: """ Truncate a value and add a unicode ellipsis (three dots) to the end if it was too long """ if isinstance(v, str) and len(v) > (max_len - 2): # -3 so quote + string + … + quote has correct length return repr(v[: (max_len - 3)] + '…') ...
[ "def", "truncate", "(", "v", ":", "str", ",", "*", ",", "max_len", ":", "int", "=", "80", ")", "->", "str", ":", "if", "isinstance", "(", "v", ",", "str", ")", "and", "len", "(", "v", ")", ">", "(", "max_len", "-", "2", ")", ":", "# -3 so quo...
Truncate a value and add a unicode ellipsis (three dots) to the end if it was too long
[ "Truncate", "a", "value", "and", "add", "a", "unicode", "ellipsis", "(", "three", "dots", ")", "to", "the", "end", "if", "it", "was", "too", "long" ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L137-L147
train
Truncates a value and adds an ellipsis to the end if it was too long.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
validate_field_name
def validate_field_name(bases: List[Type['BaseModel']], field_name: str) -> None: """ Ensure that the field's name does not shadow an existing attribute of the model. """ for base in bases: if getattr(base, field_name, None): raise NameError( f'Field name "{field_name...
python
def validate_field_name(bases: List[Type['BaseModel']], field_name: str) -> None: """ Ensure that the field's name does not shadow an existing attribute of the model. """ for base in bases: if getattr(base, field_name, None): raise NameError( f'Field name "{field_name...
[ "def", "validate_field_name", "(", "bases", ":", "List", "[", "Type", "[", "'BaseModel'", "]", "]", ",", "field_name", ":", "str", ")", "->", "None", ":", "for", "base", "in", "bases", ":", "if", "getattr", "(", "base", ",", "field_name", ",", "None", ...
Ensure that the field's name does not shadow an existing attribute of the model.
[ "Ensure", "that", "the", "field", "s", "name", "does", "not", "shadow", "an", "existing", "attribute", "of", "the", "model", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L188-L197
train
Ensure that the field s name shadows an existing attribute of the BaseModel.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
url_regex_generator
def url_regex_generator(*, relative: bool, require_tld: bool) -> Pattern[str]: """ Url regex generator taken from Marshmallow library, for details please follow library source code: https://github.com/marshmallow-code/marshmallow/blob/298870ef6c089fb4d91efae9ca4168453ffe00d2/marshmallow/validate.py#...
python
def url_regex_generator(*, relative: bool, require_tld: bool) -> Pattern[str]: """ Url regex generator taken from Marshmallow library, for details please follow library source code: https://github.com/marshmallow-code/marshmallow/blob/298870ef6c089fb4d91efae9ca4168453ffe00d2/marshmallow/validate.py#...
[ "def", "url_regex_generator", "(", "*", ",", "relative", ":", "bool", ",", "require_tld", ":", "bool", ")", "->", "Pattern", "[", "str", "]", ":", "return", "re", ".", "compile", "(", "r''", ".", "join", "(", "(", "r'^'", ",", "r'('", "if", "relative...
Url regex generator taken from Marshmallow library, for details please follow library source code: https://github.com/marshmallow-code/marshmallow/blob/298870ef6c089fb4d91efae9ca4168453ffe00d2/marshmallow/validate.py#L37
[ "Url", "regex", "generator", "taken", "from", "Marshmallow", "library", "for", "details", "please", "follow", "library", "source", "code", ":", "https", ":", "//", "github", ".", "com", "/", "marshmallow", "-", "code", "/", "marshmallow", "/", "blob", "/", ...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L201-L228
train
Returns a regex pattern that matches the given URL.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
resolve_annotations
def resolve_annotations(raw_annotations: Dict[str, AnyType], module_name: Optional[str]) -> Dict[str, AnyType]: """ Partially taken from typing.get_type_hints. Resolve string or ForwardRef annotations into type objects if possible. """ if module_name: base_globals: Optional[Dict[str, Any]] ...
python
def resolve_annotations(raw_annotations: Dict[str, AnyType], module_name: Optional[str]) -> Dict[str, AnyType]: """ Partially taken from typing.get_type_hints. Resolve string or ForwardRef annotations into type objects if possible. """ if module_name: base_globals: Optional[Dict[str, Any]] ...
[ "def", "resolve_annotations", "(", "raw_annotations", ":", "Dict", "[", "str", ",", "AnyType", "]", ",", "module_name", ":", "Optional", "[", "str", "]", ")", "->", "Dict", "[", "str", ",", "AnyType", "]", ":", "if", "module_name", ":", "base_globals", "...
Partially taken from typing.get_type_hints. Resolve string or ForwardRef annotations into type objects if possible.
[ "Partially", "taken", "from", "typing", ".", "get_type_hints", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L247-L267
train
Resolve string or ForwardRef annotations into type objects if possible.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/utils.py
update_field_forward_refs
def update_field_forward_refs(field: 'Field', globalns: Any, localns: Any) -> None: """ Try to update ForwardRefs on fields based on this Field, globalns and localns. """ if type(field.type_) == ForwardRef: field.type_ = field.type_._evaluate(globalns, localns or None) # type: ignore fi...
python
def update_field_forward_refs(field: 'Field', globalns: Any, localns: Any) -> None: """ Try to update ForwardRefs on fields based on this Field, globalns and localns. """ if type(field.type_) == ForwardRef: field.type_ = field.type_._evaluate(globalns, localns or None) # type: ignore fi...
[ "def", "update_field_forward_refs", "(", "field", ":", "'Field'", ",", "globalns", ":", "Any", ",", "localns", ":", "Any", ")", "->", "None", ":", "if", "type", "(", "field", ".", "type_", ")", "==", "ForwardRef", ":", "field", ".", "type_", "=", "fiel...
Try to update ForwardRefs on fields based on this Field, globalns and localns.
[ "Try", "to", "update", "ForwardRefs", "on", "fields", "based", "on", "this", "Field", "globalns", "and", "localns", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/utils.py#L282-L291
train
Update ForwardRefs on a Field based on globalns and localns.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/validators.py
ip_v4_network_validator
def ip_v4_network_validator(v: Any) -> IPv4Network: """ Assume IPv4Network initialised with a default ``strict`` argument See more: https://docs.python.org/library/ipaddress.html#ipaddress.IPv4Network """ if isinstance(v, IPv4Network): return v with change_exception(errors.IPv4Netw...
python
def ip_v4_network_validator(v: Any) -> IPv4Network: """ Assume IPv4Network initialised with a default ``strict`` argument See more: https://docs.python.org/library/ipaddress.html#ipaddress.IPv4Network """ if isinstance(v, IPv4Network): return v with change_exception(errors.IPv4Netw...
[ "def", "ip_v4_network_validator", "(", "v", ":", "Any", ")", "->", "IPv4Network", ":", "if", "isinstance", "(", "v", ",", "IPv4Network", ")", ":", "return", "v", "with", "change_exception", "(", "errors", ".", "IPv4NetworkError", ",", "ValueError", ")", ":",...
Assume IPv4Network initialised with a default ``strict`` argument See more: https://docs.python.org/library/ipaddress.html#ipaddress.IPv4Network
[ "Assume", "IPv4Network", "initialised", "with", "a", "default", "strict", "argument" ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/validators.py#L238-L249
train
Validate IPv4Network.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/validators.py
ip_v6_network_validator
def ip_v6_network_validator(v: Any) -> IPv6Network: """ Assume IPv6Network initialised with a default ``strict`` argument See more: https://docs.python.org/library/ipaddress.html#ipaddress.IPv6Network """ if isinstance(v, IPv6Network): return v with change_exception(errors.IPv6Netw...
python
def ip_v6_network_validator(v: Any) -> IPv6Network: """ Assume IPv6Network initialised with a default ``strict`` argument See more: https://docs.python.org/library/ipaddress.html#ipaddress.IPv6Network """ if isinstance(v, IPv6Network): return v with change_exception(errors.IPv6Netw...
[ "def", "ip_v6_network_validator", "(", "v", ":", "Any", ")", "->", "IPv6Network", ":", "if", "isinstance", "(", "v", ",", "IPv6Network", ")", ":", "return", "v", "with", "change_exception", "(", "errors", ".", "IPv6NetworkError", ",", "ValueError", ")", ":",...
Assume IPv6Network initialised with a default ``strict`` argument See more: https://docs.python.org/library/ipaddress.html#ipaddress.IPv6Network
[ "Assume", "IPv6Network", "initialised", "with", "a", "default", "strict", "argument" ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/validators.py#L252-L263
train
Validate IPv6Network.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/validators.py
callable_validator
def callable_validator(v: Any) -> AnyCallable: """ Perform a simple check if the value is callable. Note: complete matching of argument type hints and return types is not performed """ if callable(v): return v raise errors.CallableError(value=v)
python
def callable_validator(v: Any) -> AnyCallable: """ Perform a simple check if the value is callable. Note: complete matching of argument type hints and return types is not performed """ if callable(v): return v raise errors.CallableError(value=v)
[ "def", "callable_validator", "(", "v", ":", "Any", ")", "->", "AnyCallable", ":", "if", "callable", "(", "v", ")", ":", "return", "v", "raise", "errors", ".", "CallableError", "(", "value", "=", "v", ")" ]
Perform a simple check if the value is callable. Note: complete matching of argument type hints and return types is not performed
[ "Perform", "a", "simple", "check", "if", "the", "value", "is", "callable", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/validators.py#L297-L306
train
Validate that the value is callable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/env_settings.py
BaseSettings._build_environ
def _build_environ(self) -> Dict[str, Optional[str]]: """ Build environment variables suitable for passing to the Model. """ d: Dict[str, Optional[str]] = {} if self.__config__.case_insensitive: env_vars = {k.lower(): v for k, v in os.environ.items()} else: ...
python
def _build_environ(self) -> Dict[str, Optional[str]]: """ Build environment variables suitable for passing to the Model. """ d: Dict[str, Optional[str]] = {} if self.__config__.case_insensitive: env_vars = {k.lower(): v for k, v in os.environ.items()} else: ...
[ "def", "_build_environ", "(", "self", ")", "->", "Dict", "[", "str", ",", "Optional", "[", "str", "]", "]", ":", "d", ":", "Dict", "[", "str", ",", "Optional", "[", "str", "]", "]", "=", "{", "}", "if", "self", ".", "__config__", ".", "case_insen...
Build environment variables suitable for passing to the Model.
[ "Build", "environment", "variables", "suitable", "for", "passing", "to", "the", "Model", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/env_settings.py#L29-L56
train
Build environment variables suitable for passing to the Model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/class_validators.py
validator
def validator( *fields: str, pre: bool = False, whole: bool = False, always: bool = False, check_fields: bool = True ) -> Callable[[AnyCallable], classmethod]: """ Decorate methods on the class indicating that they should be used to validate fields :param fields: which field(s) the method should be call...
python
def validator( *fields: str, pre: bool = False, whole: bool = False, always: bool = False, check_fields: bool = True ) -> Callable[[AnyCallable], classmethod]: """ Decorate methods on the class indicating that they should be used to validate fields :param fields: which field(s) the method should be call...
[ "def", "validator", "(", "*", "fields", ":", "str", ",", "pre", ":", "bool", "=", "False", ",", "whole", ":", "bool", "=", "False", ",", "always", ":", "bool", "=", "False", ",", "check_fields", ":", "bool", "=", "True", ")", "->", "Callable", "[",...
Decorate methods on the class indicating that they should be used to validate fields :param fields: which field(s) the method should be called on :param pre: whether or not this validator should be called before the standard validators (else after) :param whole: for complex objects (sets, lists etc.) whethe...
[ "Decorate", "methods", "on", "the", "class", "indicating", "that", "they", "should", "be", "used", "to", "validate", "fields", ":", "param", "fields", ":", "which", "field", "(", "s", ")", "the", "method", "should", "be", "called", "on", ":", "param", "p...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/class_validators.py#L32-L63
train
Decorator to create a classmethod that validates the given fields on the object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/class_validators.py
make_generic_validator
def make_generic_validator(validator: AnyCallable) -> 'ValidatorCallable': """ Make a generic function which calls a validator with the right arguments. Unfortunately other approaches (eg. return a partial of a function that builds the arguments) is slow, hence this laborious way of doing things. ...
python
def make_generic_validator(validator: AnyCallable) -> 'ValidatorCallable': """ Make a generic function which calls a validator with the right arguments. Unfortunately other approaches (eg. return a partial of a function that builds the arguments) is slow, hence this laborious way of doing things. ...
[ "def", "make_generic_validator", "(", "validator", ":", "AnyCallable", ")", "->", "'ValidatorCallable'", ":", "sig", "=", "signature", "(", "validator", ")", "args", "=", "list", "(", "sig", ".", "parameters", ".", "keys", "(", ")", ")", "first_arg", "=", ...
Make a generic function which calls a validator with the right arguments. Unfortunately other approaches (eg. return a partial of a function that builds the arguments) is slow, hence this laborious way of doing things. It's done like this so validators don't all need **kwargs in their signature, eg. any c...
[ "Make", "a", "generic", "function", "which", "calls", "a", "validator", "with", "the", "right", "arguments", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/class_validators.py#L122-L145
train
Make a generic function which calls a validator with the right arguments.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/fields.py
Field._validate_sequence_like
def _validate_sequence_like( self, v: Any, values: Dict[str, Any], loc: 'LocType', cls: Optional['ModelOrDc'] ) -> 'ValidateReturn': """ Validate sequence-like containers: lists, tuples, sets and generators """ if not sequence_like(v): e: errors_.PydanticTypeErro...
python
def _validate_sequence_like( self, v: Any, values: Dict[str, Any], loc: 'LocType', cls: Optional['ModelOrDc'] ) -> 'ValidateReturn': """ Validate sequence-like containers: lists, tuples, sets and generators """ if not sequence_like(v): e: errors_.PydanticTypeErro...
[ "def", "_validate_sequence_like", "(", "self", ",", "v", ":", "Any", ",", "values", ":", "Dict", "[", "str", ",", "Any", "]", ",", "loc", ":", "'LocType'", ",", "cls", ":", "Optional", "[", "'ModelOrDc'", "]", ")", "->", "'ValidateReturn'", ":", "if", ...
Validate sequence-like containers: lists, tuples, sets and generators
[ "Validate", "sequence", "-", "like", "containers", ":", "lists", "tuples", "sets", "and", "generators" ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/fields.py#L303-L344
train
Validate a sequence - like container.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/fields.py
Field.is_complex
def is_complex(self) -> bool: """ Whether the field is "complex" eg. env variables should be parsed as JSON. """ from .main import BaseModel # noqa: F811 return ( self.shape != Shape.SINGLETON or lenient_issubclass(self.type_, (BaseModel, list, set, dict...
python
def is_complex(self) -> bool: """ Whether the field is "complex" eg. env variables should be parsed as JSON. """ from .main import BaseModel # noqa: F811 return ( self.shape != Shape.SINGLETON or lenient_issubclass(self.type_, (BaseModel, list, set, dict...
[ "def", "is_complex", "(", "self", ")", "->", "bool", ":", "from", ".", "main", "import", "BaseModel", "# noqa: F811", "return", "(", "self", ".", "shape", "!=", "Shape", ".", "SINGLETON", "or", "lenient_issubclass", "(", "self", ".", "type_", ",", "(", "...
Whether the field is "complex" eg. env variables should be parsed as JSON.
[ "Whether", "the", "field", "is", "complex", "eg", ".", "env", "variables", "should", "be", "parsed", "as", "JSON", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/fields.py#L434-L444
train
Whether the field is complex eg. env variables should be parsed as JSON.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
schema
def schema( models: Sequence[Type['main.BaseModel']], *, by_alias: bool = True, title: Optional[str] = None, description: Optional[str] = None, ref_prefix: Optional[str] = None, ) -> Dict[str, Any]: """ Process a list of models and generate a single JSON Schema with all of them defined i...
python
def schema( models: Sequence[Type['main.BaseModel']], *, by_alias: bool = True, title: Optional[str] = None, description: Optional[str] = None, ref_prefix: Optional[str] = None, ) -> Dict[str, Any]: """ Process a list of models and generate a single JSON Schema with all of them defined i...
[ "def", "schema", "(", "models", ":", "Sequence", "[", "Type", "[", "'main.BaseModel'", "]", "]", ",", "*", ",", "by_alias", ":", "bool", "=", "True", ",", "title", ":", "Optional", "[", "str", "]", "=", "None", ",", "description", ":", "Optional", "[...
Process a list of models and generate a single JSON Schema with all of them defined in the ``definitions`` top-level JSON key, including their sub-models. :param models: a list of models to include in the generated JSON Schema :param by_alias: generate the schemas using the aliases defined, if any :par...
[ "Process", "a", "list", "of", "models", "and", "generate", "a", "single", "JSON", "Schema", "with", "all", "of", "them", "defined", "in", "the", "definitions", "top", "-", "level", "JSON", "key", "including", "their", "sub", "-", "models", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L144-L186
train
Generates a JSON Schema for a list of models and sub - models.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
model_schema
def model_schema( model: Type['main.BaseModel'], by_alias: bool = True, ref_prefix: Optional[str] = None ) -> Dict[str, Any]: """ Generate a JSON Schema for one model. With all the sub-models defined in the ``definitions`` top-level JSON key. :param model: a Pydantic model (a class that inherits fr...
python
def model_schema( model: Type['main.BaseModel'], by_alias: bool = True, ref_prefix: Optional[str] = None ) -> Dict[str, Any]: """ Generate a JSON Schema for one model. With all the sub-models defined in the ``definitions`` top-level JSON key. :param model: a Pydantic model (a class that inherits fr...
[ "def", "model_schema", "(", "model", ":", "Type", "[", "'main.BaseModel'", "]", ",", "by_alias", ":", "bool", "=", "True", ",", "ref_prefix", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "ref_pre...
Generate a JSON Schema for one model. With all the sub-models defined in the ``definitions`` top-level JSON key. :param model: a Pydantic model (a class that inherits from BaseModel) :param by_alias: generate the schemas using the aliases defined, if any :param ref_prefix: the JSON Pointer prefix for s...
[ "Generate", "a", "JSON", "Schema", "for", "one", "model", ".", "With", "all", "the", "sub", "-", "models", "defined", "in", "the", "definitions", "top", "-", "level", "JSON", "key", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L189-L213
train
Generate a JSON Schema for a Pydantic model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
field_schema
def field_schema( field: Field, *, by_alias: bool = True, model_name_map: Dict[Type['main.BaseModel'], str], ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Process a Pydantic field and return a tuple with a JSON Schema for it as the first item. Also ret...
python
def field_schema( field: Field, *, by_alias: bool = True, model_name_map: Dict[Type['main.BaseModel'], str], ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Process a Pydantic field and return a tuple with a JSON Schema for it as the first item. Also ret...
[ "def", "field_schema", "(", "field", ":", "Field", ",", "*", ",", "by_alias", ":", "bool", "=", "True", ",", "model_name_map", ":", "Dict", "[", "Type", "[", "'main.BaseModel'", "]", ",", "str", "]", ",", "ref_prefix", ":", "Optional", "[", "str", "]",...
Process a Pydantic field and return a tuple with a JSON Schema for it as the first item. Also return a dictionary of definitions with models as keys and their schemas as values. If the passed field is a model and has sub-models, and those sub-models don't have overrides (as ``title``, ``default``, etc), they ...
[ "Process", "a", "Pydantic", "field", "and", "return", "a", "tuple", "with", "a", "JSON", "Schema", "for", "it", "as", "the", "first", "item", ".", "Also", "return", "a", "dictionary", "of", "definitions", "with", "models", "as", "keys", "and", "their", "...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L216-L268
train
Returns a tuple with a JSON Schema for this field and additional definitions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
get_field_schema_validations
def get_field_schema_validations(field: Field) -> Dict[str, Any]: """ Get the JSON Schema validation keywords for a ``field`` with an annotation of a Pydantic ``Schema`` with validation arguments. """ f_schema: Dict[str, Any] = {} if lenient_issubclass(field.type_, (str, bytes)): for att...
python
def get_field_schema_validations(field: Field) -> Dict[str, Any]: """ Get the JSON Schema validation keywords for a ``field`` with an annotation of a Pydantic ``Schema`` with validation arguments. """ f_schema: Dict[str, Any] = {} if lenient_issubclass(field.type_, (str, bytes)): for att...
[ "def", "get_field_schema_validations", "(", "field", ":", "Field", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "f_schema", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "if", "lenient_issubclass", "(", "field", ".", "type_", ",", ...
Get the JSON Schema validation keywords for a ``field`` with an annotation of a Pydantic ``Schema`` with validation arguments.
[ "Get", "the", "JSON", "Schema", "validation", "keywords", "for", "a", "field", "with", "an", "annotation", "of", "a", "Pydantic", "Schema", "with", "validation", "arguments", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L287-L306
train
Get the JSON Schema validation keywords for a field with an annotation of a Pydantic Schema with validation arguments.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
get_model_name_map
def get_model_name_map(unique_models: Set[Type['main.BaseModel']]) -> Dict[Type['main.BaseModel'], str]: """ Process a set of models and generate unique names for them to be used as keys in the JSON Schema definitions. By default the names are the same as the class name. But if two models in different Pytho...
python
def get_model_name_map(unique_models: Set[Type['main.BaseModel']]) -> Dict[Type['main.BaseModel'], str]: """ Process a set of models and generate unique names for them to be used as keys in the JSON Schema definitions. By default the names are the same as the class name. But if two models in different Pytho...
[ "def", "get_model_name_map", "(", "unique_models", ":", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", ")", "->", "Dict", "[", "Type", "[", "'main.BaseModel'", "]", ",", "str", "]", ":", "name_model_map", "=", "{", "}", "conflicting_names", ":", "S...
Process a set of models and generate unique names for them to be used as keys in the JSON Schema definitions. By default the names are the same as the class name. But if two models in different Python modules have the same name (e.g. "users.Model" and "items.Model"), the generated names will be based on the...
[ "Process", "a", "set", "of", "models", "and", "generate", "unique", "names", "for", "them", "to", "be", "used", "as", "keys", "in", "the", "JSON", "Schema", "definitions", ".", "By", "default", "the", "names", "are", "the", "same", "as", "the", "class", ...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L309-L333
train
Generates a dictionary mapping models to their names.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
get_flat_models_from_model
def get_flat_models_from_model(model: Type['main.BaseModel']) -> Set[Type['main.BaseModel']]: """ Take a single ``model`` and generate a set with itself and all the sub-models in the tree. I.e. if you pass model ``Foo`` (subclass of Pydantic ``BaseModel``) as ``model``, and it has a field of type ``Bar`` (a...
python
def get_flat_models_from_model(model: Type['main.BaseModel']) -> Set[Type['main.BaseModel']]: """ Take a single ``model`` and generate a set with itself and all the sub-models in the tree. I.e. if you pass model ``Foo`` (subclass of Pydantic ``BaseModel``) as ``model``, and it has a field of type ``Bar`` (a...
[ "def", "get_flat_models_from_model", "(", "model", ":", "Type", "[", "'main.BaseModel'", "]", ")", "->", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", ":", "flat_models", ":", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", "=", "set", "(",...
Take a single ``model`` and generate a set with itself and all the sub-models in the tree. I.e. if you pass model ``Foo`` (subclass of Pydantic ``BaseModel``) as ``model``, and it has a field of type ``Bar`` (also subclass of ``BaseModel``) and that model ``Bar`` has a field of type ``Baz`` (also subclass of ``...
[ "Take", "a", "single", "model", "and", "generate", "a", "set", "with", "itself", "and", "all", "the", "sub", "-", "models", "in", "the", "tree", ".", "I", ".", "e", ".", "if", "you", "pass", "model", "Foo", "(", "subclass", "of", "Pydantic", "BaseMod...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L336-L350
train
Takes a single model and generates a set with itself and all the sub - models in the tree.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
get_flat_models_from_field
def get_flat_models_from_field(field: Field) -> Set[Type['main.BaseModel']]: """ Take a single Pydantic ``Field`` (from a model) that could have been declared as a sublcass of BaseModel (so, it could be a submodel), and generate a set with its model and all the sub-models in the tree. I.e. if you pass a...
python
def get_flat_models_from_field(field: Field) -> Set[Type['main.BaseModel']]: """ Take a single Pydantic ``Field`` (from a model) that could have been declared as a sublcass of BaseModel (so, it could be a submodel), and generate a set with its model and all the sub-models in the tree. I.e. if you pass a...
[ "def", "get_flat_models_from_field", "(", "field", ":", "Field", ")", "->", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", ":", "flat_models", ":", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", "=", "set", "(", ")", "if", "field", ".", ...
Take a single Pydantic ``Field`` (from a model) that could have been declared as a sublcass of BaseModel (so, it could be a submodel), and generate a set with its model and all the sub-models in the tree. I.e. if you pass a field that was declared to be of type ``Foo`` (subclass of BaseModel) as ``field``, and ...
[ "Take", "a", "single", "Pydantic", "Field", "(", "from", "a", "model", ")", "that", "could", "have", "been", "declared", "as", "a", "sublcass", "of", "BaseModel", "(", "so", "it", "could", "be", "a", "submodel", ")", "and", "generate", "a", "set", "wit...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L353-L372
train
Returns a set of all the models that are used in the field.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
get_flat_models_from_fields
def get_flat_models_from_fields(fields: Sequence[Field]) -> Set[Type['main.BaseModel']]: """ Take a list of Pydantic ``Field``s (from a model) that could have been declared as sublcasses of ``BaseModel`` (so, any of them could be a submodel), and generate a set with their models and all the sub-models in t...
python
def get_flat_models_from_fields(fields: Sequence[Field]) -> Set[Type['main.BaseModel']]: """ Take a list of Pydantic ``Field``s (from a model) that could have been declared as sublcasses of ``BaseModel`` (so, any of them could be a submodel), and generate a set with their models and all the sub-models in t...
[ "def", "get_flat_models_from_fields", "(", "fields", ":", "Sequence", "[", "Field", "]", ")", "->", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", ":", "flat_models", ":", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", "=", "set", "(", ")...
Take a list of Pydantic ``Field``s (from a model) that could have been declared as sublcasses of ``BaseModel`` (so, any of them could be a submodel), and generate a set with their models and all the sub-models in the tree. I.e. if you pass a the fields of a model ``Foo`` (subclass of ``BaseModel``) as ``fields...
[ "Take", "a", "list", "of", "Pydantic", "Field", "s", "(", "from", "a", "model", ")", "that", "could", "have", "been", "declared", "as", "sublcasses", "of", "BaseModel", "(", "so", "any", "of", "them", "could", "be", "a", "submodel", ")", "and", "genera...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L375-L389
train
Given a list of Pydantic Field s generate a set of all the models declared in the fields and return a set of all the sub - models that are also in the tree.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
get_flat_models_from_models
def get_flat_models_from_models(models: Sequence[Type['main.BaseModel']]) -> Set[Type['main.BaseModel']]: """ Take a list of ``models`` and generate a set with them and all their sub-models in their trees. I.e. if you pass a list of two models, ``Foo`` and ``Bar``, both subclasses of Pydantic ``BaseModel`` ...
python
def get_flat_models_from_models(models: Sequence[Type['main.BaseModel']]) -> Set[Type['main.BaseModel']]: """ Take a list of ``models`` and generate a set with them and all their sub-models in their trees. I.e. if you pass a list of two models, ``Foo`` and ``Bar``, both subclasses of Pydantic ``BaseModel`` ...
[ "def", "get_flat_models_from_models", "(", "models", ":", "Sequence", "[", "Type", "[", "'main.BaseModel'", "]", "]", ")", "->", "Set", "[", "Type", "[", "'main.BaseModel'", "]", "]", ":", "flat_models", ":", "Set", "[", "Type", "[", "'main.BaseModel'", "]",...
Take a list of ``models`` and generate a set with them and all their sub-models in their trees. I.e. if you pass a list of two models, ``Foo`` and ``Bar``, both subclasses of Pydantic ``BaseModel`` as models, and ``Bar`` has a field of type ``Baz`` (also subclass of ``BaseModel``), the return value will be ``se...
[ "Take", "a", "list", "of", "models", "and", "generate", "a", "set", "with", "them", "and", "all", "their", "sub", "-", "models", "in", "their", "trees", ".", "I", ".", "e", ".", "if", "you", "pass", "a", "list", "of", "two", "models", "Foo", "and",...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L392-L401
train
Given a list of models and a set of models generate a set with them and all their sub - models.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
field_type_schema
def field_type_schema( field: Field, *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], schema_overrides: bool = False, ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Used by ``field_schema()``, you probably should be using that funct...
python
def field_type_schema( field: Field, *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], schema_overrides: bool = False, ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Used by ``field_schema()``, you probably should be using that funct...
[ "def", "field_type_schema", "(", "field", ":", "Field", ",", "*", ",", "by_alias", ":", "bool", ",", "model_name_map", ":", "Dict", "[", "Type", "[", "'main.BaseModel'", "]", ",", "str", "]", ",", "schema_overrides", ":", "bool", "=", "False", ",", "ref_...
Used by ``field_schema()``, you probably should be using that function. Take a single ``field`` and generate the schema for its type only, not including additional information as title, etc. Also return additional schema definitions, from sub-models.
[ "Used", "by", "field_schema", "()", "you", "probably", "should", "be", "using", "that", "function", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L408-L474
train
Generates a schema for a single object or list of objects.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
model_process_schema
def model_process_schema( model: Type['main.BaseModel'], *, by_alias: bool = True, model_name_map: Dict[Type['main.BaseModel'], str], ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Used by ``model_schema()``, you probably should be using that function. ...
python
def model_process_schema( model: Type['main.BaseModel'], *, by_alias: bool = True, model_name_map: Dict[Type['main.BaseModel'], str], ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ Used by ``model_schema()``, you probably should be using that function. ...
[ "def", "model_process_schema", "(", "model", ":", "Type", "[", "'main.BaseModel'", "]", ",", "*", ",", "by_alias", ":", "bool", "=", "True", ",", "model_name_map", ":", "Dict", "[", "Type", "[", "'main.BaseModel'", "]", ",", "str", "]", ",", "ref_prefix", ...
Used by ``model_schema()``, you probably should be using that function. Take a single ``model`` and generate its schema. Also return additional schema definitions, from sub-models. The sub-models of the returned schema will be referenced, but their definitions will not be included in the schema. All the de...
[ "Used", "by", "model_schema", "()", "you", "probably", "should", "be", "using", "that", "function", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L477-L499
train
Generates a schema from a single model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
model_type_schema
def model_type_schema( model: Type['main.BaseModel'], *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ You probably should be using ``model_schema()``, this function is indirectly used by t...
python
def model_type_schema( model: Type['main.BaseModel'], *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ You probably should be using ``model_schema()``, this function is indirectly used by t...
[ "def", "model_type_schema", "(", "model", ":", "Type", "[", "'main.BaseModel'", "]", ",", "*", ",", "by_alias", ":", "bool", ",", "model_name_map", ":", "Dict", "[", "Type", "[", "'main.BaseModel'", "]", ",", "str", "]", ",", "ref_prefix", ":", "Optional",...
You probably should be using ``model_schema()``, this function is indirectly used by that function. Take a single ``model`` and generate the schema for its type only, not including additional information as title, etc. Also return additional schema definitions, from sub-models.
[ "You", "probably", "should", "be", "using", "model_schema", "()", "this", "function", "is", "indirectly", "used", "by", "that", "function", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L502-L539
train
Generates a schema for a single object of type object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
field_singleton_sub_fields_schema
def field_singleton_sub_fields_schema( sub_fields: Sequence[Field], *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], schema_overrides: bool = False, ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ This function is indirectly used by ...
python
def field_singleton_sub_fields_schema( sub_fields: Sequence[Field], *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], schema_overrides: bool = False, ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ This function is indirectly used by ...
[ "def", "field_singleton_sub_fields_schema", "(", "sub_fields", ":", "Sequence", "[", "Field", "]", ",", "*", ",", "by_alias", ":", "bool", ",", "model_name_map", ":", "Dict", "[", "Type", "[", "'main.BaseModel'", "]", ",", "str", "]", ",", "schema_overrides", ...
This function is indirectly used by ``field_schema()``, you probably should be using that function. Take a list of Pydantic ``Field`` from the declaration of a type with parameters, and generate their schema. I.e., fields used as "type parameters", like ``str`` and ``int`` in ``Tuple[str, int]``.
[ "This", "function", "is", "indirectly", "used", "by", "field_schema", "()", "you", "probably", "should", "be", "using", "that", "function", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L542-L579
train
Returns a schema for a list of sub - fields.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
field_singleton_schema
def field_singleton_schema( # noqa: C901 (ignore complexity) field: Field, *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], schema_overrides: bool = False, ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ This function is indirectly ...
python
def field_singleton_schema( # noqa: C901 (ignore complexity) field: Field, *, by_alias: bool, model_name_map: Dict[Type['main.BaseModel'], str], schema_overrides: bool = False, ref_prefix: Optional[str] = None, ) -> Tuple[Dict[str, Any], Dict[str, Any]]: """ This function is indirectly ...
[ "def", "field_singleton_schema", "(", "# noqa: C901 (ignore complexity)", "field", ":", "Field", ",", "*", ",", "by_alias", ":", "bool", ",", "model_name_map", ":", "Dict", "[", "Type", "[", "'main.BaseModel'", "]", ",", "str", "]", ",", "schema_overrides", ":",...
This function is indirectly used by ``field_schema()``, you should probably be using that function. Take a single Pydantic ``Field``, and return its schema and any additional definitions from sub-models.
[ "This", "function", "is", "indirectly", "used", "by", "field_schema", "()", "you", "should", "probably", "be", "using", "that", "function", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L632-L696
train
Returns a schema for a single Pydantic Field and any additional definitions from sub - models.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/schema.py
get_annotation_from_schema
def get_annotation_from_schema(annotation: Any, schema: Schema) -> Type[Any]: """ Get an annotation with validation implemented for numbers and strings based on the schema. :param annotation: an annotation from a field specification, as ``str``, ``ConstrainedStr`` :param schema: an instance of Schema, ...
python
def get_annotation_from_schema(annotation: Any, schema: Schema) -> Type[Any]: """ Get an annotation with validation implemented for numbers and strings based on the schema. :param annotation: an annotation from a field specification, as ``str``, ``ConstrainedStr`` :param schema: an instance of Schema, ...
[ "def", "get_annotation_from_schema", "(", "annotation", ":", "Any", ",", "schema", ":", "Schema", ")", "->", "Type", "[", "Any", "]", ":", "if", "isinstance", "(", "annotation", ",", "type", ")", ":", "attrs", ":", "Optional", "[", "Tuple", "[", "str", ...
Get an annotation with validation implemented for numbers and strings based on the schema. :param annotation: an annotation from a field specification, as ``str``, ``ConstrainedStr`` :param schema: an instance of Schema, possibly with declarations for validations and JSON Schema :return: the same ``annotat...
[ "Get", "an", "annotation", "with", "validation", "implemented", "for", "numbers", "and", "strings", "based", "on", "the", "schema", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/schema.py#L714-L745
train
Get an annotation from a field specification as str ConstrainedStr or ConstrainedInt.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/main.py
create_model
def create_model( # noqa: C901 (ignore complexity) model_name: str, *, __config__: Type[BaseConfig] = None, __base__: Type[BaseModel] = None, __module__: Optional[str] = None, __validators__: Dict[str, classmethod] = None, **field_definitions: Any, ) -> BaseModel: """ Dynamically cr...
python
def create_model( # noqa: C901 (ignore complexity) model_name: str, *, __config__: Type[BaseConfig] = None, __base__: Type[BaseModel] = None, __module__: Optional[str] = None, __validators__: Dict[str, classmethod] = None, **field_definitions: Any, ) -> BaseModel: """ Dynamically cr...
[ "def", "create_model", "(", "# noqa: C901 (ignore complexity)", "model_name", ":", "str", ",", "*", ",", "__config__", ":", "Type", "[", "BaseConfig", "]", "=", "None", ",", "__base__", ":", "Type", "[", "BaseModel", "]", "=", "None", ",", "__module__", ":",...
Dynamically create a model. :param model_name: name of the created model :param __config__: config class to use for the new model :param __base__: base class for the new model to inherit from :param __validators__: a dict of method names and @validator class methods :param **field_definitions: field...
[ "Dynamically", "create", "a", "model", ".", ":", "param", "model_name", ":", "name", "of", "the", "created", "model", ":", "param", "__config__", ":", "config", "class", "to", "use", "for", "the", "new", "model", ":", "param", "__base__", ":", "base", "c...
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/main.py#L521-L574
train
Dynamically creates a new model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/main.py
validate_model
def validate_model( # noqa: C901 (ignore complexity) model: Union[BaseModel, Type[BaseModel]], input_data: 'DictStrAny', raise_exc: bool = True, cls: 'ModelOrDc' = None ) -> Union['DictStrAny', Tuple['DictStrAny', Optional[ValidationError]]]: """ validate data against a model. """ values = {} e...
python
def validate_model( # noqa: C901 (ignore complexity) model: Union[BaseModel, Type[BaseModel]], input_data: 'DictStrAny', raise_exc: bool = True, cls: 'ModelOrDc' = None ) -> Union['DictStrAny', Tuple['DictStrAny', Optional[ValidationError]]]: """ validate data against a model. """ values = {} e...
[ "def", "validate_model", "(", "# noqa: C901 (ignore complexity)", "model", ":", "Union", "[", "BaseModel", ",", "Type", "[", "BaseModel", "]", "]", ",", "input_data", ":", "'DictStrAny'", ",", "raise_exc", ":", "bool", "=", "True", ",", "cls", ":", "'ModelOrDc...
validate data against a model.
[ "validate", "data", "against", "a", "model", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/main.py#L577-L636
train
Validate a single object against a single model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/main.py
BaseModel.dict
def dict( self, *, include: 'SetStr' = None, exclude: 'SetStr' = None, by_alias: bool = False, skip_defaults: bool = False ) -> 'DictStrAny': """ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. """ get_key = self._g...
python
def dict( self, *, include: 'SetStr' = None, exclude: 'SetStr' = None, by_alias: bool = False, skip_defaults: bool = False ) -> 'DictStrAny': """ Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. """ get_key = self._g...
[ "def", "dict", "(", "self", ",", "*", ",", "include", ":", "'SetStr'", "=", "None", ",", "exclude", ":", "'SetStr'", "=", "None", ",", "by_alias", ":", "bool", "=", "False", ",", "skip_defaults", ":", "bool", "=", "False", ")", "->", "'DictStrAny'", ...
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
[ "Generate", "a", "dictionary", "representation", "of", "the", "model", "optionally", "specifying", "which", "fields", "to", "include", "or", "exclude", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/main.py#L273-L288
train
Generate a dictionary representation of the object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/main.py
BaseModel.json
def json( self, *, include: 'SetStr' = None, exclude: 'SetStr' = None, by_alias: bool = False, skip_defaults: bool = False, encoder: Optional[Callable[[Any], Any]] = None, **dumps_kwargs: Any, ) -> str: """ Generate a JSON representatio...
python
def json( self, *, include: 'SetStr' = None, exclude: 'SetStr' = None, by_alias: bool = False, skip_defaults: bool = False, encoder: Optional[Callable[[Any], Any]] = None, **dumps_kwargs: Any, ) -> str: """ Generate a JSON representatio...
[ "def", "json", "(", "self", ",", "*", ",", "include", ":", "'SetStr'", "=", "None", ",", "exclude", ":", "'SetStr'", "=", "None", ",", "by_alias", ":", "bool", "=", "False", ",", "skip_defaults", ":", "bool", "=", "False", ",", "encoder", ":", "Optio...
Generate a JSON representation of the model, `include` and `exclude` arguments as per `dict()`. `encoder` is an optional function to supply as `default` to json.dumps(), other arguments as per `json.dumps()`.
[ "Generate", "a", "JSON", "representation", "of", "the", "model", "include", "and", "exclude", "arguments", "as", "per", "dict", "()", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/main.py#L296-L316
train
Generate a JSON representation of the object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/main.py
BaseModel.construct
def construct(cls: Type['Model'], values: 'DictAny', fields_set: 'SetStr') -> 'Model': """ Creates a new model and set __values__ without any validation, thus values should already be trusted. Chances are you don't want to use this method directly. """ m = cls.__new__(cls) ...
python
def construct(cls: Type['Model'], values: 'DictAny', fields_set: 'SetStr') -> 'Model': """ Creates a new model and set __values__ without any validation, thus values should already be trusted. Chances are you don't want to use this method directly. """ m = cls.__new__(cls) ...
[ "def", "construct", "(", "cls", ":", "Type", "[", "'Model'", "]", ",", "values", ":", "'DictAny'", ",", "fields_set", ":", "'SetStr'", ")", "->", "'Model'", ":", "m", "=", "cls", ".", "__new__", "(", "cls", ")", "object", ".", "__setattr__", "(", "m"...
Creates a new model and set __values__ without any validation, thus values should already be trusted. Chances are you don't want to use this method directly.
[ "Creates", "a", "new", "model", "and", "set", "__values__", "without", "any", "validation", "thus", "values", "should", "already", "be", "trusted", ".", "Chances", "are", "you", "don", "t", "want", "to", "use", "this", "method", "directly", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/main.py#L360-L368
train
Constructs a new object and sets values and fields_set.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/main.py
BaseModel.copy
def copy( self: 'Model', *, include: 'SetStr' = None, exclude: 'SetStr' = None, update: 'DictStrAny' = None, deep: bool = False, ) -> 'Model': """ Duplicate a model, optionally choose which fields to include, exclude and change. :param include...
python
def copy( self: 'Model', *, include: 'SetStr' = None, exclude: 'SetStr' = None, update: 'DictStrAny' = None, deep: bool = False, ) -> 'Model': """ Duplicate a model, optionally choose which fields to include, exclude and change. :param include...
[ "def", "copy", "(", "self", ":", "'Model'", ",", "*", ",", "include", ":", "'SetStr'", "=", "None", ",", "exclude", ":", "'SetStr'", "=", "None", ",", "update", ":", "'DictStrAny'", "=", "None", ",", "deep", ":", "bool", "=", "False", ",", ")", "->...
Duplicate a model, optionally choose which fields to include, exclude and change. :param include: fields to include in new model :param exclude: fields to exclude from new model, as with values this takes precedence over include :param update: values to change/add in the new model. Note: the da...
[ "Duplicate", "a", "model", "optionally", "choose", "which", "fields", "to", "include", "exclude", "and", "change", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/main.py#L370-L401
train
Creates a copy of the current model with the same fields as the current one.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/main.py
BaseModel.update_forward_refs
def update_forward_refs(cls, **localns: Any) -> None: """ Try to update ForwardRefs on fields based on this Model, globalns and localns. """ globalns = sys.modules[cls.__module__].__dict__ globalns.setdefault(cls.__name__, cls) for f in cls.__fields__.values(): ...
python
def update_forward_refs(cls, **localns: Any) -> None: """ Try to update ForwardRefs on fields based on this Model, globalns and localns. """ globalns = sys.modules[cls.__module__].__dict__ globalns.setdefault(cls.__name__, cls) for f in cls.__fields__.values(): ...
[ "def", "update_forward_refs", "(", "cls", ",", "*", "*", "localns", ":", "Any", ")", "->", "None", ":", "globalns", "=", "sys", ".", "modules", "[", "cls", ".", "__module__", "]", ".", "__dict__", "globalns", ".", "setdefault", "(", "cls", ".", "__name...
Try to update ForwardRefs on fields based on this Model, globalns and localns.
[ "Try", "to", "update", "ForwardRefs", "on", "fields", "based", "on", "this", "Model", "globalns", "and", "localns", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/main.py#L456-L463
train
Update ForwardRefs on all the related objects in this class based on the given localns.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/datetime_parse.py
parse_date
def parse_date(value: Union[date, StrIntFloat]) -> date: """ Parse a date/int/float/string and return a datetime.date. Raise ValueError if the input is well formatted but not a valid date. Raise ValueError if the input isn't well formatted. """ if isinstance(value, date): if isinstance(...
python
def parse_date(value: Union[date, StrIntFloat]) -> date: """ Parse a date/int/float/string and return a datetime.date. Raise ValueError if the input is well formatted but not a valid date. Raise ValueError if the input isn't well formatted. """ if isinstance(value, date): if isinstance(...
[ "def", "parse_date", "(", "value", ":", "Union", "[", "date", ",", "StrIntFloat", "]", ")", "->", "date", ":", "if", "isinstance", "(", "value", ",", "date", ")", ":", "if", "isinstance", "(", "value", ",", "datetime", ")", ":", "return", "value", "....
Parse a date/int/float/string and return a datetime.date. Raise ValueError if the input is well formatted but not a valid date. Raise ValueError if the input isn't well formatted.
[ "Parse", "a", "date", "/", "int", "/", "float", "/", "string", "and", "return", "a", "datetime", ".", "date", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/datetime_parse.py#L86-L110
train
Parse a date string and return a datetime. date.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/datetime_parse.py
parse_time
def parse_time(value: Union[time, str]) -> time: """ Parse a time/string and return a datetime.time. This function doesn't support time zone offsets. Raise ValueError if the input is well formatted but not a valid time. Raise ValueError if the input isn't well formatted, in particular if it contai...
python
def parse_time(value: Union[time, str]) -> time: """ Parse a time/string and return a datetime.time. This function doesn't support time zone offsets. Raise ValueError if the input is well formatted but not a valid time. Raise ValueError if the input isn't well formatted, in particular if it contai...
[ "def", "parse_time", "(", "value", ":", "Union", "[", "time", ",", "str", "]", ")", "->", "time", ":", "if", "isinstance", "(", "value", ",", "time", ")", ":", "return", "value", "match", "=", "time_re", ".", "match", "(", "value", ")", "if", "not"...
Parse a time/string and return a datetime.time. This function doesn't support time zone offsets. Raise ValueError if the input is well formatted but not a valid time. Raise ValueError if the input isn't well formatted, in particular if it contains an offset.
[ "Parse", "a", "time", "/", "string", "and", "return", "a", "datetime", ".", "time", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/datetime_parse.py#L113-L136
train
Parse a time string and return a datetime. time. time object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/datetime_parse.py
parse_datetime
def parse_datetime(value: Union[datetime, StrIntFloat]) -> datetime: """ Parse a datetime/int/float/string and return a datetime.datetime. This function supports time zone offsets. When the input contains one, the output uses a timezone with a fixed offset from UTC. Raise ValueError if the input i...
python
def parse_datetime(value: Union[datetime, StrIntFloat]) -> datetime: """ Parse a datetime/int/float/string and return a datetime.datetime. This function supports time zone offsets. When the input contains one, the output uses a timezone with a fixed offset from UTC. Raise ValueError if the input i...
[ "def", "parse_datetime", "(", "value", ":", "Union", "[", "datetime", ",", "StrIntFloat", "]", ")", "->", "datetime", ":", "if", "isinstance", "(", "value", ",", "datetime", ")", ":", "return", "value", "number", "=", "get_numeric", "(", "value", ")", "i...
Parse a datetime/int/float/string and return a datetime.datetime. This function supports time zone offsets. When the input contains one, the output uses a timezone with a fixed offset from UTC. Raise ValueError if the input is well formatted but not a valid datetime. Raise ValueError if the input isn'...
[ "Parse", "a", "datetime", "/", "int", "/", "float", "/", "string", "and", "return", "a", "datetime", ".", "datetime", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/datetime_parse.py#L139-L180
train
Parse a datetime string and return a datetime. datetime object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
samuelcolvin/pydantic
pydantic/datetime_parse.py
parse_duration
def parse_duration(value: StrIntFloat) -> timedelta: """ Parse a duration int/float/string and return a datetime.timedelta. The preferred format for durations in Django is '%d %H:%M:%S.%f'. Also supports ISO 8601 representation. """ if isinstance(value, timedelta): return value if...
python
def parse_duration(value: StrIntFloat) -> timedelta: """ Parse a duration int/float/string and return a datetime.timedelta. The preferred format for durations in Django is '%d %H:%M:%S.%f'. Also supports ISO 8601 representation. """ if isinstance(value, timedelta): return value if...
[ "def", "parse_duration", "(", "value", ":", "StrIntFloat", ")", "->", "timedelta", ":", "if", "isinstance", "(", "value", ",", "timedelta", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",", "(", "int", ",", "float", ")", ")", ":", "# ...
Parse a duration int/float/string and return a datetime.timedelta. The preferred format for durations in Django is '%d %H:%M:%S.%f'. Also supports ISO 8601 representation.
[ "Parse", "a", "duration", "int", "/", "float", "/", "string", "and", "return", "a", "datetime", ".", "timedelta", "." ]
bff8a1789dfde2c38928cced6640887b53615aa3
https://github.com/samuelcolvin/pydantic/blob/bff8a1789dfde2c38928cced6640887b53615aa3/pydantic/datetime_parse.py#L183-L212
train
Parse a duration int float or string and return a datetime. timedelta.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pycontribs/jira
jira/client.py
translate_resource_args
def translate_resource_args(func): """Decorator that converts Issue and Project resources to their keys when used as arguments.""" @wraps(func) def wrapper(*args, **kwargs): """ :type args: *Any :type kwargs: **Any :return: Any """ arg_list = [] for ar...
python
def translate_resource_args(func): """Decorator that converts Issue and Project resources to their keys when used as arguments.""" @wraps(func) def wrapper(*args, **kwargs): """ :type args: *Any :type kwargs: **Any :return: Any """ arg_list = [] for ar...
[ "def", "translate_resource_args", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n :type args: *Any\n :type kwargs: **Any\n :return: Any\n \"\"\"", "arg_li...
Decorator that converts Issue and Project resources to their keys when used as arguments.
[ "Decorator", "that", "converts", "Issue", "and", "Project", "resources", "to", "their", "keys", "when", "used", "as", "arguments", "." ]
397db5d78441ed6a680a9b7db4c62030ade1fd8a
https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/client.py#L121-L139
train
Decorator that converts Issue and Project resources to their keys when used as arguments.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pycontribs/jira
jira/client.py
JIRA._check_update_
def _check_update_(self): """Check if the current version of the library is outdated.""" try: data = requests.get("https://pypi.python.org/pypi/jira/json", timeout=2.001).json() released_version = data['info']['version'] if parse_version(released_version) > parse_ver...
python
def _check_update_(self): """Check if the current version of the library is outdated.""" try: data = requests.get("https://pypi.python.org/pypi/jira/json", timeout=2.001).json() released_version = data['info']['version'] if parse_version(released_version) > parse_ver...
[ "def", "_check_update_", "(", "self", ")", ":", "try", ":", "data", "=", "requests", ".", "get", "(", "\"https://pypi.python.org/pypi/jira/json\"", ",", "timeout", "=", "2.001", ")", ".", "json", "(", ")", "released_version", "=", "data", "[", "'info'", "]",...
Check if the current version of the library is outdated.
[ "Check", "if", "the", "current", "version", "of", "the", "library", "is", "outdated", "." ]
397db5d78441ed6a680a9b7db4c62030ade1fd8a
https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/client.py#L552-L565
train
Check if the current version of the library is outdated.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
pycontribs/jira
jira/client.py
JIRA._fetch_pages
def _fetch_pages(self, item_type, items_key, request_path, startAt=0, maxResults=50, params=None, base=JIRA_BASE_URL, ): """Fetch pages. ...
python
def _fetch_pages(self, item_type, items_key, request_path, startAt=0, maxResults=50, params=None, base=JIRA_BASE_URL, ): """Fetch pages. ...
[ "def", "_fetch_pages", "(", "self", ",", "item_type", ",", "items_key", ",", "request_path", ",", "startAt", "=", "0", ",", "maxResults", "=", "50", ",", "params", "=", "None", ",", "base", "=", "JIRA_BASE_URL", ",", ")", ":", "async_class", "=", "None",...
Fetch pages. :param item_type: Type of single item. ResultList of such items will be returned. :type item_type: type :param items_key: Path to the items in JSON returned from server. Set it to None, if response is an array, and not a JSON object. :type items_key: Optiona...
[ "Fetch", "pages", "." ]
397db5d78441ed6a680a9b7db4c62030ade1fd8a
https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/client.py#L599-L703
train
Fetch all pages from the server.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...