repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Yelp/threat_intel
threat_intel/util/http.py
AvailabilityLimiter.map_with_retries
def map_with_retries(self, requests, responses_for_requests): """Provides session-based retry functionality :param requests: A collection of Request objects. :param responses_for_requests: Dictionary mapping of requests to responses :param max_retries: The maximum number of retries to p...
python
def map_with_retries(self, requests, responses_for_requests): """Provides session-based retry functionality :param requests: A collection of Request objects. :param responses_for_requests: Dictionary mapping of requests to responses :param max_retries: The maximum number of retries to p...
[ "def", "map_with_retries", "(", "self", ",", "requests", ",", "responses_for_requests", ")", ":", "retries", "=", "[", "]", "response_futures", "=", "[", "preq", ".", "callable", "(", ")", "for", "preq", "in", "requests", "]", "for", "request", ",", "respo...
Provides session-based retry functionality :param requests: A collection of Request objects. :param responses_for_requests: Dictionary mapping of requests to responses :param max_retries: The maximum number of retries to perform per session :param args: Additional arguments to pass into...
[ "Provides", "session", "-", "based", "retry", "functionality" ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L122-L151
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest.multi_get
def multi_get(self, urls, query_params=None, to_json=True): """Issue multiple GET requests. Args: urls - A string URL or list of string URLs query_params - None, a dict, or a list of dicts representing the query params to_json - A boolean, should the responses be ret...
python
def multi_get(self, urls, query_params=None, to_json=True): """Issue multiple GET requests. Args: urls - A string URL or list of string URLs query_params - None, a dict, or a list of dicts representing the query params to_json - A boolean, should the responses be ret...
[ "def", "multi_get", "(", "self", ",", "urls", ",", "query_params", "=", "None", ",", "to_json", "=", "True", ")", ":", "return", "self", ".", "_multi_request", "(", "MultiRequest", ".", "_VERB_GET", ",", "urls", ",", "query_params", ",", "data", "=", "No...
Issue multiple GET requests. Args: urls - A string URL or list of string URLs query_params - None, a dict, or a list of dicts representing the query params to_json - A boolean, should the responses be returned as JSON blobs Returns: a list of dicts if to_...
[ "Issue", "multiple", "GET", "requests", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L203-L218
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest.multi_post
def multi_post(self, urls, query_params=None, data=None, to_json=True, send_as_file=False): """Issue multiple POST requests. Args: urls - A string URL or list of string URLs query_params - None, a dict, or a list of dicts representing the query params data - None, a ...
python
def multi_post(self, urls, query_params=None, data=None, to_json=True, send_as_file=False): """Issue multiple POST requests. Args: urls - A string URL or list of string URLs query_params - None, a dict, or a list of dicts representing the query params data - None, a ...
[ "def", "multi_post", "(", "self", ",", "urls", ",", "query_params", "=", "None", ",", "data", "=", "None", ",", "to_json", "=", "True", ",", "send_as_file", "=", "False", ")", ":", "return", "self", ".", "_multi_request", "(", "MultiRequest", ".", "_VERB...
Issue multiple POST requests. Args: urls - A string URL or list of string URLs query_params - None, a dict, or a list of dicts representing the query params data - None, a dict or string, or a list of dicts and strings representing the data body. to_json - A bool...
[ "Issue", "multiple", "POST", "requests", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L220-L237
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest._create_request
def _create_request(self, verb, url, query_params=None, data=None, send_as_file=False): """Helper method to create a single post/get requests. Args: verb - MultiRequest._VERB_POST or MultiRequest._VERB_GET url - A string URL query_params - None or a dict ...
python
def _create_request(self, verb, url, query_params=None, data=None, send_as_file=False): """Helper method to create a single post/get requests. Args: verb - MultiRequest._VERB_POST or MultiRequest._VERB_GET url - A string URL query_params - None or a dict ...
[ "def", "_create_request", "(", "self", ",", "verb", ",", "url", ",", "query_params", "=", "None", ",", "data", "=", "None", ",", "send_as_file", "=", "False", ")", ":", "# Prepare a set of kwargs to make it easier to avoid missing default params.", "kwargs", "=", "{...
Helper method to create a single post/get requests. Args: verb - MultiRequest._VERB_POST or MultiRequest._VERB_GET url - A string URL query_params - None or a dict data - None or a string or a dict send_as_file - A boolean, should the data be sent as ...
[ "Helper", "method", "to", "create", "a", "single", "post", "/", "get", "requests", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L239-L270
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest._zip_request_params
def _zip_request_params(self, urls, query_params, data): """Massages inputs and returns a list of 3-tuples zipping them up. This is all the smarts behind deciding how many requests to issue. It's fine for an input to have 0, 1, or a list of values. If there are two inputs each with a li...
python
def _zip_request_params(self, urls, query_params, data): """Massages inputs and returns a list of 3-tuples zipping them up. This is all the smarts behind deciding how many requests to issue. It's fine for an input to have 0, 1, or a list of values. If there are two inputs each with a li...
[ "def", "_zip_request_params", "(", "self", ",", "urls", ",", "query_params", ",", "data", ")", ":", "# Everybody gets to be a list", "if", "not", "isinstance", "(", "urls", ",", "list", ")", ":", "urls", "=", "[", "urls", "]", "if", "not", "isinstance", "(...
Massages inputs and returns a list of 3-tuples zipping them up. This is all the smarts behind deciding how many requests to issue. It's fine for an input to have 0, 1, or a list of values. If there are two inputs each with a list of values, the cardinality of those lists much match. Ar...
[ "Massages", "inputs", "and", "returns", "a", "list", "of", "3", "-", "tuples", "zipping", "them", "up", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L272-L322
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest._wait_for_response
def _wait_for_response(self, requests): """Issues a batch of requests and waits for the responses. If some of the requests fail it will retry the failed ones up to `_max_retry` times. Args: requests - A list of requests Returns: A list of `requests.models.Respons...
python
def _wait_for_response(self, requests): """Issues a batch of requests and waits for the responses. If some of the requests fail it will retry the failed ones up to `_max_retry` times. Args: requests - A list of requests Returns: A list of `requests.models.Respons...
[ "def", "_wait_for_response", "(", "self", ",", "requests", ")", ":", "failed_requests", "=", "[", "]", "responses_for_requests", "=", "OrderedDict", ".", "fromkeys", "(", "requests", ")", "for", "retry", "in", "range", "(", "self", ".", "_max_retry", ")", ":...
Issues a batch of requests and waits for the responses. If some of the requests fail it will retry the failed ones up to `_max_retry` times. Args: requests - A list of requests Returns: A list of `requests.models.Response` objects Raises: InvalidReque...
[ "Issues", "a", "batch", "of", "requests", "and", "waits", "for", "the", "responses", ".", "If", "some", "of", "the", "requests", "fail", "it", "will", "retry", "the", "failed", "ones", "up", "to", "_max_retry", "times", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L324-L380
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest._convert_to_json
def _convert_to_json(self, response): """Converts response to JSON. If the response cannot be converted to JSON then `None` is returned. Args: response - An object of type `requests.models.Response` Returns: Response in JSON format if the response can be converte...
python
def _convert_to_json(self, response): """Converts response to JSON. If the response cannot be converted to JSON then `None` is returned. Args: response - An object of type `requests.models.Response` Returns: Response in JSON format if the response can be converte...
[ "def", "_convert_to_json", "(", "self", ",", "response", ")", ":", "try", ":", "return", "response", ".", "json", "(", ")", "except", "ValueError", ":", "logging", ".", "warning", "(", "'Expected response in JSON format from {0} but the actual response text is: {1}'", ...
Converts response to JSON. If the response cannot be converted to JSON then `None` is returned. Args: response - An object of type `requests.models.Response` Returns: Response in JSON format if the response can be converted to JSON. `None` otherwise.
[ "Converts", "response", "to", "JSON", ".", "If", "the", "response", "cannot", "be", "converted", "to", "JSON", "then", "None", "is", "returned", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L382-L397
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest._multi_request
def _multi_request(self, verb, urls, query_params, data, to_json=True, send_as_file=False): """Issues multiple batches of simultaneous HTTP requests and waits for responses. Args: verb - MultiRequest._VERB_POST or MultiRequest._VERB_GET urls - A string URL or list of string URLs...
python
def _multi_request(self, verb, urls, query_params, data, to_json=True, send_as_file=False): """Issues multiple batches of simultaneous HTTP requests and waits for responses. Args: verb - MultiRequest._VERB_POST or MultiRequest._VERB_GET urls - A string URL or list of string URLs...
[ "def", "_multi_request", "(", "self", ",", "verb", ",", "urls", ",", "query_params", ",", "data", ",", "to_json", "=", "True", ",", "send_as_file", "=", "False", ")", ":", "if", "not", "urls", ":", "raise", "InvalidRequestError", "(", "'No URL supplied'", ...
Issues multiple batches of simultaneous HTTP requests and waits for responses. Args: verb - MultiRequest._VERB_POST or MultiRequest._VERB_GET urls - A string URL or list of string URLs query_params - None, a dict, or a list of dicts representing the query params ...
[ "Issues", "multiple", "batches", "of", "simultaneous", "HTTP", "requests", "and", "waits", "for", "responses", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L399-L443
Yelp/threat_intel
threat_intel/util/http.py
MultiRequest.error_handling
def error_handling(cls, fn): """Decorator to handle errors""" def wrapper(*args, **kwargs): try: result = fn(*args, **kwargs) return result except InvalidRequestError as e: write_exception(e) if hasattr(e, 'request'...
python
def error_handling(cls, fn): """Decorator to handle errors""" def wrapper(*args, **kwargs): try: result = fn(*args, **kwargs) return result except InvalidRequestError as e: write_exception(e) if hasattr(e, 'request'...
[ "def", "error_handling", "(", "cls", ",", "fn", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "result", "=", "fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "result", "except", "Inval...
Decorator to handle errors
[ "Decorator", "to", "handle", "errors" ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/http.py#L450-L465
glasslion/redlock
redlock/lock.py
RedLockFactory.create_lock
def create_lock(self, resource, **kwargs): """ Create a new RedLock object and reuse stored Redis clients. All the kwargs it received would be passed to the RedLock's __init__ function. """ lock = RedLock(resource=resource, created_by_factory=True, **kwargs) lock....
python
def create_lock(self, resource, **kwargs): """ Create a new RedLock object and reuse stored Redis clients. All the kwargs it received would be passed to the RedLock's __init__ function. """ lock = RedLock(resource=resource, created_by_factory=True, **kwargs) lock....
[ "def", "create_lock", "(", "self", ",", "resource", ",", "*", "*", "kwargs", ")", ":", "lock", "=", "RedLock", "(", "resource", "=", "resource", ",", "created_by_factory", "=", "True", ",", "*", "*", "kwargs", ")", "lock", ".", "redis_nodes", "=", "sel...
Create a new RedLock object and reuse stored Redis clients. All the kwargs it received would be passed to the RedLock's __init__ function.
[ "Create", "a", "new", "RedLock", "object", "and", "reuse", "stored", "Redis", "clients", ".", "All", "the", "kwargs", "it", "received", "would", "be", "passed", "to", "the", "RedLock", "s", "__init__", "function", "." ]
train
https://github.com/glasslion/redlock/blob/7f873cc362eefa7f7adee8d4913e64f87c1fd1c9/redlock/lock.py#L62-L72
glasslion/redlock
redlock/lock.py
RedLock.acquire_node
def acquire_node(self, node): """ acquire a single redis node """ try: return node.set(self.resource, self.lock_key, nx=True, px=self.ttl) except (redis.exceptions.ConnectionError, redis.exceptions.TimeoutError): return False
python
def acquire_node(self, node): """ acquire a single redis node """ try: return node.set(self.resource, self.lock_key, nx=True, px=self.ttl) except (redis.exceptions.ConnectionError, redis.exceptions.TimeoutError): return False
[ "def", "acquire_node", "(", "self", ",", "node", ")", ":", "try", ":", "return", "node", ".", "set", "(", "self", ".", "resource", ",", "self", ".", "lock_key", ",", "nx", "=", "True", ",", "px", "=", "self", ".", "ttl", ")", "except", "(", "redi...
acquire a single redis node
[ "acquire", "a", "single", "redis", "node" ]
train
https://github.com/glasslion/redlock/blob/7f873cc362eefa7f7adee8d4913e64f87c1fd1c9/redlock/lock.py#L135-L142
glasslion/redlock
redlock/lock.py
RedLock.release_node
def release_node(self, node): """ release a single redis node """ # use the lua script to release the lock in a safe way try: node._release_script(keys=[self.resource], args=[self.lock_key]) except (redis.exceptions.ConnectionError, redis.exceptions.TimeoutErr...
python
def release_node(self, node): """ release a single redis node """ # use the lua script to release the lock in a safe way try: node._release_script(keys=[self.resource], args=[self.lock_key]) except (redis.exceptions.ConnectionError, redis.exceptions.TimeoutErr...
[ "def", "release_node", "(", "self", ",", "node", ")", ":", "# use the lua script to release the lock in a safe way", "try", ":", "node", ".", "_release_script", "(", "keys", "=", "[", "self", ".", "resource", "]", ",", "args", "=", "[", "self", ".", "lock_key"...
release a single redis node
[ "release", "a", "single", "redis", "node" ]
train
https://github.com/glasslion/redlock/blob/7f873cc362eefa7f7adee8d4913e64f87c1fd1c9/redlock/lock.py#L144-L152
Yelp/threat_intel
threat_intel/alexaranking.py
AlexaRankingApi.get_alexa_rankings
def get_alexa_rankings(self, domains): """Retrieves the most recent VT info for a set of domains. Args: domains: list of string domains. Returns: A dict with the domain as key and the VT report as value. """ api_name = 'alexa_rankings' (all_respo...
python
def get_alexa_rankings(self, domains): """Retrieves the most recent VT info for a set of domains. Args: domains: list of string domains. Returns: A dict with the domain as key and the VT report as value. """ api_name = 'alexa_rankings' (all_respo...
[ "def", "get_alexa_rankings", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'alexa_rankings'", "(", "all_responses", ",", "domains", ")", "=", "self", ".", "_bulk_cache_lookup", "(", "api_name", ",", "domains", ")", "responses", "=", "self", ".", "...
Retrieves the most recent VT info for a set of domains. Args: domains: list of string domains. Returns: A dict with the domain as key and the VT report as value.
[ "Retrieves", "the", "most", "recent", "VT", "info", "for", "a", "set", "of", "domains", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/alexaranking.py#L38-L57
Yelp/threat_intel
threat_intel/alexaranking.py
AlexaRankingApi._request_reports
def _request_reports(self, domains): """Sends multiples requests for the resources to a particular endpoint. Args: resource_param_name: a string name of the resource parameter. resources: list of of the resources. endpoint_name: AlexaRankingApi endpoint URL suffix. ...
python
def _request_reports(self, domains): """Sends multiples requests for the resources to a particular endpoint. Args: resource_param_name: a string name of the resource parameter. resources: list of of the resources. endpoint_name: AlexaRankingApi endpoint URL suffix. ...
[ "def", "_request_reports", "(", "self", ",", "domains", ")", ":", "params", "=", "[", "{", "'url'", ":", "domain", "}", "for", "domain", "in", "domains", "]", "responses", "=", "self", ".", "_requests", ".", "multi_get", "(", "self", ".", "BASE_URL", "...
Sends multiples requests for the resources to a particular endpoint. Args: resource_param_name: a string name of the resource parameter. resources: list of of the resources. endpoint_name: AlexaRankingApi endpoint URL suffix. Returns: A list of the respon...
[ "Sends", "multiples", "requests", "for", "the", "resources", "to", "a", "particular", "endpoint", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/alexaranking.py#L59-L72
Yelp/threat_intel
threat_intel/alexaranking.py
AlexaRankingApi._extract_response_xml
def _extract_response_xml(self, domain, response): """Extract XML content of an HTTP response into dictionary format. Args: response: HTML Response objects Returns: A dictionary: {alexa-ranking key : alexa-ranking value}. """ attributes = {} alexa...
python
def _extract_response_xml(self, domain, response): """Extract XML content of an HTTP response into dictionary format. Args: response: HTML Response objects Returns: A dictionary: {alexa-ranking key : alexa-ranking value}. """ attributes = {} alexa...
[ "def", "_extract_response_xml", "(", "self", ",", "domain", ",", "response", ")", ":", "attributes", "=", "{", "}", "alexa_keys", "=", "{", "'POPULARITY'", ":", "'TEXT'", ",", "'REACH'", ":", "'RANK'", ",", "'RANK'", ":", "'DELTA'", "}", "try", ":", "xml...
Extract XML content of an HTTP response into dictionary format. Args: response: HTML Response objects Returns: A dictionary: {alexa-ranking key : alexa-ranking value}.
[ "Extract", "XML", "content", "of", "an", "HTTP", "response", "into", "dictionary", "format", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/alexaranking.py#L74-L95
Yelp/threat_intel
threat_intel/alexaranking.py
AlexaRankingApi._bulk_cache_lookup
def _bulk_cache_lookup(self, api_name, keys): """Performes a bulk cache lookup and returns a tuple with the results found and the keys missing in the cache. If cached is not configured it will return an empty dictionary of found results and the initial list of keys. Args: ...
python
def _bulk_cache_lookup(self, api_name, keys): """Performes a bulk cache lookup and returns a tuple with the results found and the keys missing in the cache. If cached is not configured it will return an empty dictionary of found results and the initial list of keys. Args: ...
[ "def", "_bulk_cache_lookup", "(", "self", ",", "api_name", ",", "keys", ")", ":", "if", "self", ".", "_cache", ":", "responses", "=", "self", ".", "_cache", ".", "bulk_lookup", "(", "api_name", ",", "keys", ")", "missing_keys", "=", "[", "key", "for", ...
Performes a bulk cache lookup and returns a tuple with the results found and the keys missing in the cache. If cached is not configured it will return an empty dictionary of found results and the initial list of keys. Args: api_name: a string name of the API. key...
[ "Performes", "a", "bulk", "cache", "lookup", "and", "returns", "a", "tuple", "with", "the", "results", "found", "and", "the", "keys", "missing", "in", "the", "cache", ".", "If", "cached", "is", "not", "configured", "it", "will", "return", "an", "empty", ...
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/alexaranking.py#L97-L114
Yelp/threat_intel
threat_intel/util/api_cache.py
ApiCache.close
def close(self): """Write the contents of the cache to disk (only if `update_cache` parameter during the object initialization was not set to `False`) and clear the in memory cache.""" if self._cache: if self._update_cache: self._write_cache_to_file() ...
python
def close(self): """Write the contents of the cache to disk (only if `update_cache` parameter during the object initialization was not set to `False`) and clear the in memory cache.""" if self._cache: if self._update_cache: self._write_cache_to_file() ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_cache", ":", "if", "self", ".", "_update_cache", ":", "self", ".", "_write_cache_to_file", "(", ")", "self", ".", "_cache", "=", "None" ]
Write the contents of the cache to disk (only if `update_cache` parameter during the object initialization was not set to `False`) and clear the in memory cache.
[ "Write", "the", "contents", "of", "the", "cache", "to", "disk", "(", "only", "if", "update_cache", "parameter", "during", "the", "object", "initialization", "was", "not", "set", "to", "False", ")", "and", "clear", "the", "in", "memory", "cache", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L33-L40
Yelp/threat_intel
threat_intel/util/api_cache.py
ApiCache._write_cache_to_file
def _write_cache_to_file(self): """Write the contents of the cache to a file on disk.""" with(open(self._cache_file_name, 'w')) as fp: fp.write(simplejson.dumps(self._cache))
python
def _write_cache_to_file(self): """Write the contents of the cache to a file on disk.""" with(open(self._cache_file_name, 'w')) as fp: fp.write(simplejson.dumps(self._cache))
[ "def", "_write_cache_to_file", "(", "self", ")", ":", "with", "(", "open", "(", "self", ".", "_cache_file_name", ",", "'w'", ")", ")", "as", "fp", ":", "fp", ".", "write", "(", "simplejson", ".", "dumps", "(", "self", ".", "_cache", ")", ")" ]
Write the contents of the cache to a file on disk.
[ "Write", "the", "contents", "of", "the", "cache", "to", "a", "file", "on", "disk", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L42-L45
Yelp/threat_intel
threat_intel/util/api_cache.py
ApiCache._read_cache_from_file
def _read_cache_from_file(self): """Read the contents of the cache from a file on disk.""" cache = {} try: with(open(self._cache_file_name, 'r')) as fp: contents = fp.read() cache = simplejson.loads(contents) except (IOError, JSONDecodeError): ...
python
def _read_cache_from_file(self): """Read the contents of the cache from a file on disk.""" cache = {} try: with(open(self._cache_file_name, 'r')) as fp: contents = fp.read() cache = simplejson.loads(contents) except (IOError, JSONDecodeError): ...
[ "def", "_read_cache_from_file", "(", "self", ")", ":", "cache", "=", "{", "}", "try", ":", "with", "(", "open", "(", "self", ".", "_cache_file_name", ",", "'r'", ")", ")", "as", "fp", ":", "contents", "=", "fp", ".", "read", "(", ")", "cache", "=",...
Read the contents of the cache from a file on disk.
[ "Read", "the", "contents", "of", "the", "cache", "from", "a", "file", "on", "disk", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L47-L58
Yelp/threat_intel
threat_intel/util/api_cache.py
ApiCache.cache_value
def cache_value(self, api_name, key, value): """Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call. value: the value of the call using the specific ke...
python
def cache_value(self, api_name, key, value): """Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call. value: the value of the call using the specific ke...
[ "def", "cache_value", "(", "self", ",", "api_name", ",", "key", ",", "value", ")", ":", "self", ".", "_cache", ".", "setdefault", "(", "api_name", ",", "{", "}", ")", "self", ".", "_cache", "[", "api_name", "]", "[", "key", "]", "=", "value" ]
Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call. value: the value of the call using the specific key
[ "Add", "the", "value", "of", "an", "API", "call", "to", "the", "cache", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L60-L69
Yelp/threat_intel
threat_intel/util/api_cache.py
ApiCache.lookup_value
def lookup_value(self, api_name, key): """Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call. """ if api_name in self._cache: return s...
python
def lookup_value(self, api_name, key): """Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call. """ if api_name in self._cache: return s...
[ "def", "lookup_value", "(", "self", ",", "api_name", ",", "key", ")", ":", "if", "api_name", "in", "self", ".", "_cache", ":", "return", "self", ".", "_cache", "[", "api_name", "]", ".", "get", "(", "key", ",", "None", ")", "return", "None" ]
Add the value of an API call to the cache. Args: api_name: a string name of the API. Keys and values are segmented by api_name. key: a string key for the specific call.
[ "Add", "the", "value", "of", "an", "API", "call", "to", "the", "cache", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L71-L80
Yelp/threat_intel
threat_intel/util/api_cache.py
ApiCache.bulk_lookup
def bulk_lookup(self, api_name, keys): """Perform lookup on an enumerable of keys. Args: api_name: a string name of the API. Keys and values are segmented by api_name. keys: an enumerable of string keys. """ cached_data = {} for key in keys: ...
python
def bulk_lookup(self, api_name, keys): """Perform lookup on an enumerable of keys. Args: api_name: a string name of the API. Keys and values are segmented by api_name. keys: an enumerable of string keys. """ cached_data = {} for key in keys: ...
[ "def", "bulk_lookup", "(", "self", ",", "api_name", ",", "keys", ")", ":", "cached_data", "=", "{", "}", "for", "key", "in", "keys", ":", "value", "=", "self", ".", "lookup_value", "(", "api_name", ",", "key", ")", "if", "value", "is", "not", "None",...
Perform lookup on an enumerable of keys. Args: api_name: a string name of the API. Keys and values are segmented by api_name. keys: an enumerable of string keys.
[ "Perform", "lookup", "on", "an", "enumerable", "of", "keys", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/util/api_cache.py#L82-L95
Yelp/threat_intel
threat_intel/opendns.py
_cached_by_domain
def _cached_by_domain(api_name): """A caching wrapper for functions that take a list of domains as parameters. Raises: ResponseError - if the response received from the endpoint is not valid. """ def wrapped(func): def decorated(self, domains): if not self._cach...
python
def _cached_by_domain(api_name): """A caching wrapper for functions that take a list of domains as parameters. Raises: ResponseError - if the response received from the endpoint is not valid. """ def wrapped(func): def decorated(self, domains): if not self._cach...
[ "def", "_cached_by_domain", "(", "api_name", ")", ":", "def", "wrapped", "(", "func", ")", ":", "def", "decorated", "(", "self", ",", "domains", ")", ":", "if", "not", "self", ".", "_cache", ":", "return", "func", "(", "self", ",", "domains", ")", "a...
A caching wrapper for functions that take a list of domains as parameters. Raises: ResponseError - if the response received from the endpoint is not valid.
[ "A", "caching", "wrapper", "for", "functions", "that", "take", "a", "list", "of", "domains", "as", "parameters", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L16-L45
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.domain_score
def domain_score(self, domains): """Calls domain scores endpoint. This method is deprecated since OpenDNS Investigate API endpoint is also deprecated. """ warn( 'OpenDNS Domain Scores endpoint is deprecated. Use ' 'InvestigateApi.categorization() instead'...
python
def domain_score(self, domains): """Calls domain scores endpoint. This method is deprecated since OpenDNS Investigate API endpoint is also deprecated. """ warn( 'OpenDNS Domain Scores endpoint is deprecated. Use ' 'InvestigateApi.categorization() instead'...
[ "def", "domain_score", "(", "self", ",", "domains", ")", ":", "warn", "(", "'OpenDNS Domain Scores endpoint is deprecated. Use '", "'InvestigateApi.categorization() instead'", ",", "DeprecationWarning", ",", ")", "url_path", "=", "'domains/score/'", "return", "self", ".", ...
Calls domain scores endpoint. This method is deprecated since OpenDNS Investigate API endpoint is also deprecated.
[ "Calls", "domain", "scores", "endpoint", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L115-L126
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi._multi_get
def _multi_get(self, cache_api_name, fmt_url_path, url_params, query_params=None): """Makes multiple GETs to an OpenDNS endpoint. Args: cache_api_name: string api_name for caching fmt_url_path: format string for building URL paths url_params: An enumerable of strings...
python
def _multi_get(self, cache_api_name, fmt_url_path, url_params, query_params=None): """Makes multiple GETs to an OpenDNS endpoint. Args: cache_api_name: string api_name for caching fmt_url_path: format string for building URL paths url_params: An enumerable of strings...
[ "def", "_multi_get", "(", "self", ",", "cache_api_name", ",", "fmt_url_path", ",", "url_params", ",", "query_params", "=", "None", ")", ":", "all_responses", "=", "{", "}", "if", "self", ".", "_cache", ":", "all_responses", "=", "self", ".", "_cache", ".",...
Makes multiple GETs to an OpenDNS endpoint. Args: cache_api_name: string api_name for caching fmt_url_path: format string for building URL paths url_params: An enumerable of strings used in building URLs query_params - None / dict / list of dicts containing query...
[ "Makes", "multiple", "GETs", "to", "an", "OpenDNS", "endpoint", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L129-L154
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.security
def security(self, domains): """Calls security end point and adds an 'is_suspicious' key to each response. Args: domains: An enumerable of strings Returns: A dict of {domain: security_result} """ api_name = 'opendns-security' fmt_url_path = u'secu...
python
def security(self, domains): """Calls security end point and adds an 'is_suspicious' key to each response. Args: domains: An enumerable of strings Returns: A dict of {domain: security_result} """ api_name = 'opendns-security' fmt_url_path = u'secu...
[ "def", "security", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'opendns-security'", "fmt_url_path", "=", "u'security/name/{0}.json'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "domains", ")" ]
Calls security end point and adds an 'is_suspicious' key to each response. Args: domains: An enumerable of strings Returns: A dict of {domain: security_result}
[ "Calls", "security", "end", "point", "and", "adds", "an", "is_suspicious", "key", "to", "each", "response", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L156-L166
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.whois_emails
def whois_emails(self, emails): """Calls WHOIS Email end point Args: emails: An enumerable of string Emails Returns: A dict of {email: domain_result} """ api_name = 'opendns-whois-emails' fmt_url_path = u'whois/emails/{0}' return self._mul...
python
def whois_emails(self, emails): """Calls WHOIS Email end point Args: emails: An enumerable of string Emails Returns: A dict of {email: domain_result} """ api_name = 'opendns-whois-emails' fmt_url_path = u'whois/emails/{0}' return self._mul...
[ "def", "whois_emails", "(", "self", ",", "emails", ")", ":", "api_name", "=", "'opendns-whois-emails'", "fmt_url_path", "=", "u'whois/emails/{0}'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "emails", ")" ]
Calls WHOIS Email end point Args: emails: An enumerable of string Emails Returns: A dict of {email: domain_result}
[ "Calls", "WHOIS", "Email", "end", "point" ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L168-L178
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.whois_nameservers
def whois_nameservers(self, nameservers): """Calls WHOIS Nameserver end point Args: emails: An enumerable of nameservers Returns: A dict of {nameserver: domain_result} """ api_name = 'opendns-whois-nameservers' fmt_url_path = u'whois/nameservers/{...
python
def whois_nameservers(self, nameservers): """Calls WHOIS Nameserver end point Args: emails: An enumerable of nameservers Returns: A dict of {nameserver: domain_result} """ api_name = 'opendns-whois-nameservers' fmt_url_path = u'whois/nameservers/{...
[ "def", "whois_nameservers", "(", "self", ",", "nameservers", ")", ":", "api_name", "=", "'opendns-whois-nameservers'", "fmt_url_path", "=", "u'whois/nameservers/{0}'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "nameservers", ")" ]
Calls WHOIS Nameserver end point Args: emails: An enumerable of nameservers Returns: A dict of {nameserver: domain_result}
[ "Calls", "WHOIS", "Nameserver", "end", "point" ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L180-L190
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.whois_domains
def whois_domains(self, domains): """Calls WHOIS domain end point Args: domains: An enumerable of domains Returns: A dict of {domain: domain_result} """ api_name = 'opendns-whois-domain' fmt_url_path = u'whois/{0}' return self._multi_get(a...
python
def whois_domains(self, domains): """Calls WHOIS domain end point Args: domains: An enumerable of domains Returns: A dict of {domain: domain_result} """ api_name = 'opendns-whois-domain' fmt_url_path = u'whois/{0}' return self._multi_get(a...
[ "def", "whois_domains", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'opendns-whois-domain'", "fmt_url_path", "=", "u'whois/{0}'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "domains", ")" ]
Calls WHOIS domain end point Args: domains: An enumerable of domains Returns: A dict of {domain: domain_result}
[ "Calls", "WHOIS", "domain", "end", "point" ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L192-L202
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.whois_domains_history
def whois_domains_history(self, domains): """Calls WHOIS domain history end point Args: domains: An enumerable of domains Returns: A dict of {domain: domain_history_result} """ api_name = 'opendns-whois-domain-history' fmt_url_path = u'whois/{0}/h...
python
def whois_domains_history(self, domains): """Calls WHOIS domain history end point Args: domains: An enumerable of domains Returns: A dict of {domain: domain_history_result} """ api_name = 'opendns-whois-domain-history' fmt_url_path = u'whois/{0}/h...
[ "def", "whois_domains_history", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'opendns-whois-domain-history'", "fmt_url_path", "=", "u'whois/{0}/history'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "domains", ")" ]
Calls WHOIS domain history end point Args: domains: An enumerable of domains Returns: A dict of {domain: domain_history_result}
[ "Calls", "WHOIS", "domain", "history", "end", "point" ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L204-L214
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.cooccurrences
def cooccurrences(self, domains): """Get the domains related to input domains. Args: domains: an enumerable of strings domain names Returns: An enumerable of string domain names """ api_name = 'opendns-cooccurrences' fmt_url_path = u'recommendatio...
python
def cooccurrences(self, domains): """Get the domains related to input domains. Args: domains: an enumerable of strings domain names Returns: An enumerable of string domain names """ api_name = 'opendns-cooccurrences' fmt_url_path = u'recommendatio...
[ "def", "cooccurrences", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'opendns-cooccurrences'", "fmt_url_path", "=", "u'recommendations/name/{0}.json'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "domains", ")" ]
Get the domains related to input domains. Args: domains: an enumerable of strings domain names Returns: An enumerable of string domain names
[ "Get", "the", "domains", "related", "to", "input", "domains", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L216-L226
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.domain_tag
def domain_tag(self, domains): """Get the data range when a domain is part of OpenDNS block list. Args: domains: an enumerable of strings domain names Returns: An enumerable of string with period, category, and url """ api_name = 'opendns-domain_tag' ...
python
def domain_tag(self, domains): """Get the data range when a domain is part of OpenDNS block list. Args: domains: an enumerable of strings domain names Returns: An enumerable of string with period, category, and url """ api_name = 'opendns-domain_tag' ...
[ "def", "domain_tag", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'opendns-domain_tag'", "fmt_url_path", "=", "u'domains/{0}/latest_tags'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "domains", ")" ]
Get the data range when a domain is part of OpenDNS block list. Args: domains: an enumerable of strings domain names Returns: An enumerable of string with period, category, and url
[ "Get", "the", "data", "range", "when", "a", "domain", "is", "part", "of", "OpenDNS", "block", "list", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L228-L238
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.related_domains
def related_domains(self, domains): """Get list of domain names that have been seen requested around the same time (up to 60 seconds before or after) to the given domain name. Args: domains: an enumerable of strings domain names Returns: An enumerable of [domain ...
python
def related_domains(self, domains): """Get list of domain names that have been seen requested around the same time (up to 60 seconds before or after) to the given domain name. Args: domains: an enumerable of strings domain names Returns: An enumerable of [domain ...
[ "def", "related_domains", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'opendns-related_domains'", "fmt_url_path", "=", "u'links/name/{0}.json'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "domains", ")" ]
Get list of domain names that have been seen requested around the same time (up to 60 seconds before or after) to the given domain name. Args: domains: an enumerable of strings domain names Returns: An enumerable of [domain name, scores]
[ "Get", "list", "of", "domain", "names", "that", "have", "been", "seen", "requested", "around", "the", "same", "time", "(", "up", "to", "60", "seconds", "before", "or", "after", ")", "to", "the", "given", "domain", "name", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L240-L251
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.rr_history
def rr_history(self, ips): """Get the domains related to input ips. Args: ips: an enumerable of strings as ips Returns: An enumerable of resource records and features """ api_name = 'opendns-rr_history' fmt_url_path = u'dnsdb/ip/a/{0}.json' ...
python
def rr_history(self, ips): """Get the domains related to input ips. Args: ips: an enumerable of strings as ips Returns: An enumerable of resource records and features """ api_name = 'opendns-rr_history' fmt_url_path = u'dnsdb/ip/a/{0}.json' ...
[ "def", "rr_history", "(", "self", ",", "ips", ")", ":", "api_name", "=", "'opendns-rr_history'", "fmt_url_path", "=", "u'dnsdb/ip/a/{0}.json'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "ips", ")" ]
Get the domains related to input ips. Args: ips: an enumerable of strings as ips Returns: An enumerable of resource records and features
[ "Get", "the", "domains", "related", "to", "input", "ips", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L253-L263
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.dns_rr
def dns_rr(self, ips): """Get the domains related to input domains. Args: domains: an enumerable of strings as domains Returns: An enumerable of resource records and features """ api_name = 'opendns-dns_rr' fmt_url_path = u'dnsdb/name/a/{0}.json' ...
python
def dns_rr(self, ips): """Get the domains related to input domains. Args: domains: an enumerable of strings as domains Returns: An enumerable of resource records and features """ api_name = 'opendns-dns_rr' fmt_url_path = u'dnsdb/name/a/{0}.json' ...
[ "def", "dns_rr", "(", "self", ",", "ips", ")", ":", "api_name", "=", "'opendns-dns_rr'", "fmt_url_path", "=", "u'dnsdb/name/a/{0}.json'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "ips", ")" ]
Get the domains related to input domains. Args: domains: an enumerable of strings as domains Returns: An enumerable of resource records and features
[ "Get", "the", "domains", "related", "to", "input", "domains", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L265-L275
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.sample
def sample(self, hashes): """Get the information about a sample based on its hash. Args: hashes: an enumerable of strings as hashes Returns: An enumerable of arrays which contains the information about the original samples """ api_name = 'open...
python
def sample(self, hashes): """Get the information about a sample based on its hash. Args: hashes: an enumerable of strings as hashes Returns: An enumerable of arrays which contains the information about the original samples """ api_name = 'open...
[ "def", "sample", "(", "self", ",", "hashes", ")", ":", "api_name", "=", "'opendns-sample'", "fmt_url_path", "=", "u'sample/{0}'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "hashes", ")" ]
Get the information about a sample based on its hash. Args: hashes: an enumerable of strings as hashes Returns: An enumerable of arrays which contains the information about the original samples
[ "Get", "the", "information", "about", "a", "sample", "based", "on", "its", "hash", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L289-L300
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.search
def search(self, patterns, start=30, limit=1000, include_category=False): """Performs pattern searches against the Investigate database. Args: patterns: An enumerable of RegEx domain patterns to search for start: How far back results extend from in days (max is 30) ...
python
def search(self, patterns, start=30, limit=1000, include_category=False): """Performs pattern searches against the Investigate database. Args: patterns: An enumerable of RegEx domain patterns to search for start: How far back results extend from in days (max is 30) ...
[ "def", "search", "(", "self", ",", "patterns", ",", "start", "=", "30", ",", "limit", "=", "1000", ",", "include_category", "=", "False", ")", ":", "api_name", "=", "'opendns-patterns'", "fmt_url_path", "=", "u'search/{0}'", "start", "=", "'-{0}days'", ".", ...
Performs pattern searches against the Investigate database. Args: patterns: An enumerable of RegEx domain patterns to search for start: How far back results extend from in days (max is 30) limit: Number of results to show (max is 1000) include_category: Inclu...
[ "Performs", "pattern", "searches", "against", "the", "Investigate", "database", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L302-L322
Yelp/threat_intel
threat_intel/opendns.py
InvestigateApi.risk_score
def risk_score(self, domains): """Performs Umbrella risk score analysis on the input domains Args: domains: an enumerable of domains Returns: An enumerable of associated domain risk scores """ api_name = 'opendns-risk_score' fmt_url_path = u'domai...
python
def risk_score(self, domains): """Performs Umbrella risk score analysis on the input domains Args: domains: an enumerable of domains Returns: An enumerable of associated domain risk scores """ api_name = 'opendns-risk_score' fmt_url_path = u'domai...
[ "def", "risk_score", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'opendns-risk_score'", "fmt_url_path", "=", "u'domains/risk-score/{0}'", "return", "self", ".", "_multi_get", "(", "api_name", ",", "fmt_url_path", ",", "domains", ")" ]
Performs Umbrella risk score analysis on the input domains Args: domains: an enumerable of domains Returns: An enumerable of associated domain risk scores
[ "Performs", "Umbrella", "risk", "score", "analysis", "on", "the", "input", "domains" ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/opendns.py#L324-L334
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi._extract_all_responses
def _extract_all_responses(self, resources, api_endpoint, api_name): """ Aux function to extract all the API endpoint responses. Args: resources: list of string hashes. api_endpoint: endpoint path api_name: endpoint name Returns: A dict with the h...
python
def _extract_all_responses(self, resources, api_endpoint, api_name): """ Aux function to extract all the API endpoint responses. Args: resources: list of string hashes. api_endpoint: endpoint path api_name: endpoint name Returns: A dict with the h...
[ "def", "_extract_all_responses", "(", "self", ",", "resources", ",", "api_endpoint", ",", "api_name", ")", ":", "all_responses", ",", "resources", "=", "self", ".", "_bulk_cache_lookup", "(", "api_name", ",", "resources", ")", "resource_chunks", "=", "self", "."...
Aux function to extract all the API endpoint responses. Args: resources: list of string hashes. api_endpoint: endpoint path api_name: endpoint name Returns: A dict with the hash as key and the VT report as value.
[ "Aux", "function", "to", "extract", "all", "the", "API", "endpoint", "responses", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L52-L67
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_file_behaviour
def get_file_behaviour(self, resources): """Retrieves a report about the behaviour of a md5, sha1, and/or sha2 hash of a file when executed in a sandboxed environment (Cuckoo sandbox). Args: resources: list of string hashes. """ api_name = 'virustotal-file-behaviour'...
python
def get_file_behaviour(self, resources): """Retrieves a report about the behaviour of a md5, sha1, and/or sha2 hash of a file when executed in a sandboxed environment (Cuckoo sandbox). Args: resources: list of string hashes. """ api_name = 'virustotal-file-behaviour'...
[ "def", "get_file_behaviour", "(", "self", ",", "resources", ")", ":", "api_name", "=", "'virustotal-file-behaviour'", "api_endpoint", "=", "'file/behaviour'", "return", "self", ".", "_extract_all_responses", "(", "resources", ",", "api_endpoint", ",", "api_name", ")" ...
Retrieves a report about the behaviour of a md5, sha1, and/or sha2 hash of a file when executed in a sandboxed environment (Cuckoo sandbox). Args: resources: list of string hashes.
[ "Retrieves", "a", "report", "about", "the", "behaviour", "of", "a", "md5", "sha1", "and", "/", "or", "sha2", "hash", "of", "a", "file", "when", "executed", "in", "a", "sandboxed", "environment", "(", "Cuckoo", "sandbox", ")", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L70-L79
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_file_download
def get_file_download(self, resources): """Retrieves a file from its a md5, sha1, and/or sha2 hash. Args: resources: list of string hashes. Returns: a file download """ api_name = 'virustotal-file-download' api_endpoint = 'file/download' r...
python
def get_file_download(self, resources): """Retrieves a file from its a md5, sha1, and/or sha2 hash. Args: resources: list of string hashes. Returns: a file download """ api_name = 'virustotal-file-download' api_endpoint = 'file/download' r...
[ "def", "get_file_download", "(", "self", ",", "resources", ")", ":", "api_name", "=", "'virustotal-file-download'", "api_endpoint", "=", "'file/download'", "return", "self", ".", "_extract_all_responses", "(", "resources", ",", "api_endpoint", ",", "api_name", ")" ]
Retrieves a file from its a md5, sha1, and/or sha2 hash. Args: resources: list of string hashes. Returns: a file download
[ "Retrieves", "a", "file", "from", "its", "a", "md5", "sha1", "and", "/", "or", "sha2", "hash", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L82-L92
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_file_network_traffic
def get_file_network_traffic(self, resources): """Retrieves a report about the network traffic of a md5, sha1, and/or sha2 hash of file, when it is executed. Args: resources: list of string hashes. """ api_name = 'virustotal-file-network-traffic' api_endpo...
python
def get_file_network_traffic(self, resources): """Retrieves a report about the network traffic of a md5, sha1, and/or sha2 hash of file, when it is executed. Args: resources: list of string hashes. """ api_name = 'virustotal-file-network-traffic' api_endpo...
[ "def", "get_file_network_traffic", "(", "self", ",", "resources", ")", ":", "api_name", "=", "'virustotal-file-network-traffic'", "api_endpoint", "=", "'file/network-traffic'", "return", "self", ".", "_extract_all_responses", "(", "resources", ",", "api_endpoint", ",", ...
Retrieves a report about the network traffic of a md5, sha1, and/or sha2 hash of file, when it is executed. Args: resources: list of string hashes.
[ "Retrieves", "a", "report", "about", "the", "network", "traffic", "of", "a", "md5", "sha1", "and", "/", "or", "sha2", "hash", "of", "file", "when", "it", "is", "executed", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L95-L104
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_domain_reports
def get_domain_reports(self, domains): """Retrieves the most recent VT info for a set of domains. Args: domains: list of string domains. Returns: A dict with the domain as key and the VT report as value. """ api_name = 'virustotal-domain-reports' ...
python
def get_domain_reports(self, domains): """Retrieves the most recent VT info for a set of domains. Args: domains: list of string domains. Returns: A dict with the domain as key and the VT report as value. """ api_name = 'virustotal-domain-reports' ...
[ "def", "get_domain_reports", "(", "self", ",", "domains", ")", ":", "api_name", "=", "'virustotal-domain-reports'", "(", "all_responses", ",", "domains", ")", "=", "self", ".", "_bulk_cache_lookup", "(", "api_name", ",", "domains", ")", "responses", "=", "self",...
Retrieves the most recent VT info for a set of domains. Args: domains: list of string domains. Returns: A dict with the domain as key and the VT report as value.
[ "Retrieves", "the", "most", "recent", "VT", "info", "for", "a", "set", "of", "domains", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L107-L125
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_url_distribution
def get_url_distribution(self, params=None): """Retrieves a live feed with the latest URLs submitted to VT. Args: resources: a dictionary with name and value for optional arguments Returns: A dict with the VT report. """ params = params or {} all_...
python
def get_url_distribution(self, params=None): """Retrieves a live feed with the latest URLs submitted to VT. Args: resources: a dictionary with name and value for optional arguments Returns: A dict with the VT report. """ params = params or {} all_...
[ "def", "get_url_distribution", "(", "self", ",", "params", "=", "None", ")", ":", "params", "=", "params", "or", "{", "}", "all_responses", "=", "{", "}", "api_name", "=", "'virustotal-url-distribution'", "response_chunks", "=", "self", ".", "_request_reports", ...
Retrieves a live feed with the latest URLs submitted to VT. Args: resources: a dictionary with name and value for optional arguments Returns: A dict with the VT report.
[ "Retrieves", "a", "live", "feed", "with", "the", "latest", "URLs", "submitted", "to", "VT", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L128-L143
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_url_reports
def get_url_reports(self, resources): """Retrieves a scan report on a given URL. Args: resources: list of URLs. Returns: A dict with the URL as key and the VT report as value. """ api_name = 'virustotal-url-reports' (all_responses, resources) = s...
python
def get_url_reports(self, resources): """Retrieves a scan report on a given URL. Args: resources: list of URLs. Returns: A dict with the URL as key and the VT report as value. """ api_name = 'virustotal-url-reports' (all_responses, resources) = s...
[ "def", "get_url_reports", "(", "self", ",", "resources", ")", ":", "api_name", "=", "'virustotal-url-reports'", "(", "all_responses", ",", "resources", ")", "=", "self", ".", "_bulk_cache_lookup", "(", "api_name", ",", "resources", ")", "resource_chunks", "=", "...
Retrieves a scan report on a given URL. Args: resources: list of URLs. Returns: A dict with the URL as key and the VT report as value.
[ "Retrieves", "a", "scan", "report", "on", "a", "given", "URL", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L167-L182
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_ip_reports
def get_ip_reports(self, ips): """Retrieves the most recent VT info for a set of ips. Args: ips: list of IPs. Returns: A dict with the IP as key and the VT report as value. """ api_name = 'virustotal-ip-address-reports' (all_responses, ips) = sel...
python
def get_ip_reports(self, ips): """Retrieves the most recent VT info for a set of ips. Args: ips: list of IPs. Returns: A dict with the IP as key and the VT report as value. """ api_name = 'virustotal-ip-address-reports' (all_responses, ips) = sel...
[ "def", "get_ip_reports", "(", "self", ",", "ips", ")", ":", "api_name", "=", "'virustotal-ip-address-reports'", "(", "all_responses", ",", "ips", ")", "=", "self", ".", "_bulk_cache_lookup", "(", "api_name", ",", "ips", ")", "responses", "=", "self", ".", "_...
Retrieves the most recent VT info for a set of ips. Args: ips: list of IPs. Returns: A dict with the IP as key and the VT report as value.
[ "Retrieves", "the", "most", "recent", "VT", "info", "for", "a", "set", "of", "ips", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L185-L203
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_file_search
def get_file_search(self, query): """Performs advanced search on samples, matching certain binary/ metadata/detection criteria. Possible queries: file size, file type, first or last submission to VT, number of positives, bynary content, etc. Args: query: di...
python
def get_file_search(self, query): """Performs advanced search on samples, matching certain binary/ metadata/detection criteria. Possible queries: file size, file type, first or last submission to VT, number of positives, bynary content, etc. Args: query: di...
[ "def", "get_file_search", "(", "self", ",", "query", ")", ":", "api_name", "=", "'virustotal-file-search'", "(", "all_responses", ",", "query", ")", "=", "self", ".", "_bulk_cache_lookup", "(", "api_name", ",", "query", ")", "response_chunks", "=", "self", "."...
Performs advanced search on samples, matching certain binary/ metadata/detection criteria. Possible queries: file size, file type, first or last submission to VT, number of positives, bynary content, etc. Args: query: dictionary with search arguments Ex...
[ "Performs", "advanced", "search", "on", "samples", "matching", "certain", "binary", "/", "metadata", "/", "detection", "criteria", ".", "Possible", "queries", ":", "file", "size", "file", "type", "first", "or", "last", "submission", "to", "VT", "number", "of",...
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L206-L224
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi.get_file_clusters
def get_file_clusters(self, date): """Retrieves file similarity clusters for a given time frame. Args: date: the specific date for which we want the clustering details. Example: 'date': '2013-09-10' Returns: A dict with the VT report. """ api_...
python
def get_file_clusters(self, date): """Retrieves file similarity clusters for a given time frame. Args: date: the specific date for which we want the clustering details. Example: 'date': '2013-09-10' Returns: A dict with the VT report. """ api_...
[ "def", "get_file_clusters", "(", "self", ",", "date", ")", ":", "api_name", "=", "'virustotal-file-clusters'", "(", "all_responses", ",", "resources", ")", "=", "self", ".", "_bulk_cache_lookup", "(", "api_name", ",", "date", ")", "response", "=", "self", ".",...
Retrieves file similarity clusters for a given time frame. Args: date: the specific date for which we want the clustering details. Example: 'date': '2013-09-10' Returns: A dict with the VT report.
[ "Retrieves", "file", "similarity", "clusters", "for", "a", "given", "time", "frame", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L227-L242
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi._prepare_resource_chunks
def _prepare_resource_chunks(self, resources, resource_delim=','): """As in some VirusTotal API methods the call can be made for multiple resources at once this method prepares a list of concatenated resources according to the maximum number of resources per requests. Args: ...
python
def _prepare_resource_chunks(self, resources, resource_delim=','): """As in some VirusTotal API methods the call can be made for multiple resources at once this method prepares a list of concatenated resources according to the maximum number of resources per requests. Args: ...
[ "def", "_prepare_resource_chunks", "(", "self", ",", "resources", ",", "resource_delim", "=", "','", ")", ":", "return", "[", "self", ".", "_prepare_resource_chunk", "(", "resources", ",", "resource_delim", ",", "pos", ")", "for", "pos", "in", "range", "(", ...
As in some VirusTotal API methods the call can be made for multiple resources at once this method prepares a list of concatenated resources according to the maximum number of resources per requests. Args: resources: a list of the resources. resource_delim: a string used ...
[ "As", "in", "some", "VirusTotal", "API", "methods", "the", "call", "can", "be", "made", "for", "multiple", "resources", "at", "once", "this", "method", "prepares", "a", "list", "of", "concatenated", "resources", "according", "to", "the", "maximum", "number", ...
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L263-L276
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi._request_reports
def _request_reports(self, resource_param_name, resources, endpoint_name): """Sends multiples requests for the resources to a particular endpoint. Args: resource_param_name: a string name of the resource parameter. resources: list of of the resources. endpoint_name: ...
python
def _request_reports(self, resource_param_name, resources, endpoint_name): """Sends multiples requests for the resources to a particular endpoint. Args: resource_param_name: a string name of the resource parameter. resources: list of of the resources. endpoint_name: ...
[ "def", "_request_reports", "(", "self", ",", "resource_param_name", ",", "resources", ",", "endpoint_name", ")", ":", "params", "=", "[", "{", "resource_param_name", ":", "resource", ",", "'apikey'", ":", "self", ".", "_api_key", "}", "for", "resource", "in", ...
Sends multiples requests for the resources to a particular endpoint. Args: resource_param_name: a string name of the resource parameter. resources: list of of the resources. endpoint_name: VirusTotal endpoint URL suffix. Returns: A list of the responses.
[ "Sends", "multiples", "requests", "for", "the", "resources", "to", "a", "particular", "endpoint", "." ]
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L282-L293
Yelp/threat_intel
threat_intel/virustotal.py
VirusTotalApi._extract_response_chunks
def _extract_response_chunks(self, all_responses, response_chunks, api_name): """Extracts and caches the responses from the response chunks in case of the responses for the requests containing multiple concatenated resources. Extracted responses are added to the already cached responses ...
python
def _extract_response_chunks(self, all_responses, response_chunks, api_name): """Extracts and caches the responses from the response chunks in case of the responses for the requests containing multiple concatenated resources. Extracted responses are added to the already cached responses ...
[ "def", "_extract_response_chunks", "(", "self", ",", "all_responses", ",", "response_chunks", ",", "api_name", ")", ":", "for", "response_chunk", "in", "response_chunks", ":", "if", "not", "isinstance", "(", "response_chunk", ",", "list", ")", ":", "response_chunk...
Extracts and caches the responses from the response chunks in case of the responses for the requests containing multiple concatenated resources. Extracted responses are added to the already cached responses passed in the all_responses parameter. Args: all_responses: a list c...
[ "Extracts", "and", "caches", "the", "responses", "from", "the", "response", "chunks", "in", "case", "of", "the", "responses", "for", "the", "requests", "containing", "multiple", "concatenated", "resources", ".", "Extracted", "responses", "are", "added", "to", "t...
train
https://github.com/Yelp/threat_intel/blob/60eef841d7cca115ec7857aeb9c553b72b694851/threat_intel/virustotal.py#L295-L315
letmaik/lensfunpy
lensfunpy/util.py
remapOpenCv
def remapOpenCv(im, coords): """ Remap an image using OpenCV. See :func:`remap` for parameters. """ # required for older OpenCV versions im = np.require(im, im.dtype, 'C') return cv2.remap(im, coords, None, cv2.INTER_LANCZOS4)
python
def remapOpenCv(im, coords): """ Remap an image using OpenCV. See :func:`remap` for parameters. """ # required for older OpenCV versions im = np.require(im, im.dtype, 'C') return cv2.remap(im, coords, None, cv2.INTER_LANCZOS4)
[ "def", "remapOpenCv", "(", "im", ",", "coords", ")", ":", "# required for older OpenCV versions", "im", "=", "np", ".", "require", "(", "im", ",", "im", ".", "dtype", ",", "'C'", ")", "return", "cv2", ".", "remap", "(", "im", ",", "coords", ",", "None"...
Remap an image using OpenCV. See :func:`remap` for parameters.
[ "Remap", "an", "image", "using", "OpenCV", ".", "See", ":", "func", ":", "remap", "for", "parameters", "." ]
train
https://github.com/letmaik/lensfunpy/blob/e8800496874b1b1360cb9c245e2f137febbd41d7/lensfunpy/util.py#L12-L18
letmaik/lensfunpy
lensfunpy/util.py
remapScipy
def remapScipy(im, coords): """ Remap an image using SciPy. See :func:`remap` for parameters. """ height, width = im.shape[0], im.shape[1] # switch to y,x order coords = coords[:,:,::-1] # make it (h, w, 3, 3) coords_channels = np.empty((height, width, 3, 3)) coords_channel = n...
python
def remapScipy(im, coords): """ Remap an image using SciPy. See :func:`remap` for parameters. """ height, width = im.shape[0], im.shape[1] # switch to y,x order coords = coords[:,:,::-1] # make it (h, w, 3, 3) coords_channels = np.empty((height, width, 3, 3)) coords_channel = n...
[ "def", "remapScipy", "(", "im", ",", "coords", ")", ":", "height", ",", "width", "=", "im", ".", "shape", "[", "0", "]", ",", "im", ".", "shape", "[", "1", "]", "# switch to y,x order", "coords", "=", "coords", "[", ":", ",", ":", ",", ":", ":", ...
Remap an image using SciPy. See :func:`remap` for parameters.
[ "Remap", "an", "image", "using", "SciPy", ".", "See", ":", "func", ":", "remap", "for", "parameters", "." ]
train
https://github.com/letmaik/lensfunpy/blob/e8800496874b1b1360cb9c245e2f137febbd41d7/lensfunpy/util.py#L20-L43
letmaik/lensfunpy
lensfunpy/util.py
remap
def remap(im, coords): """ Remap an RGB image using the given target coordinate array. If available, OpenCV is used (faster), otherwise SciPy. :type im: ndarray of shape (h,w,3) :param im: RGB image to be remapped :type coords: ndarray of shape (h,w,2) :param coords: target coordin...
python
def remap(im, coords): """ Remap an RGB image using the given target coordinate array. If available, OpenCV is used (faster), otherwise SciPy. :type im: ndarray of shape (h,w,3) :param im: RGB image to be remapped :type coords: ndarray of shape (h,w,2) :param coords: target coordin...
[ "def", "remap", "(", "im", ",", "coords", ")", ":", "if", "cv2", ":", "return", "remapOpenCv", "(", "im", ",", "coords", ")", "else", ":", "return", "remapScipy", "(", "im", ",", "coords", ")" ]
Remap an RGB image using the given target coordinate array. If available, OpenCV is used (faster), otherwise SciPy. :type im: ndarray of shape (h,w,3) :param im: RGB image to be remapped :type coords: ndarray of shape (h,w,2) :param coords: target coordinates in x,y order for each pixel ...
[ "Remap", "an", "RGB", "image", "using", "the", "given", "target", "coordinate", "array", ".", "If", "available", "OpenCV", "is", "used", "(", "faster", ")", "otherwise", "SciPy", ".", ":", "type", "im", ":", "ndarray", "of", "shape", "(", "h", "w", "3"...
train
https://github.com/letmaik/lensfunpy/blob/e8800496874b1b1360cb9c245e2f137febbd41d7/lensfunpy/util.py#L45-L61
divio/djangocms-text-ckeditor
djangocms_text_ckeditor/cms_plugins.py
TextPlugin.get_editor_widget
def get_editor_widget(self, request, plugins, plugin): """ Returns the Django form Widget to be used for the text area """ cancel_url_name = self.get_admin_url_name('delete_on_cancel') cancel_url = reverse('admin:%s' % cancel_url_name) render_plugin_url_name = se...
python
def get_editor_widget(self, request, plugins, plugin): """ Returns the Django form Widget to be used for the text area """ cancel_url_name = self.get_admin_url_name('delete_on_cancel') cancel_url = reverse('admin:%s' % cancel_url_name) render_plugin_url_name = se...
[ "def", "get_editor_widget", "(", "self", ",", "request", ",", "plugins", ",", "plugin", ")", ":", "cancel_url_name", "=", "self", ".", "get_admin_url_name", "(", "'delete_on_cancel'", ")", "cancel_url", "=", "reverse", "(", "'admin:%s'", "%", "cancel_url_name", ...
Returns the Django form Widget to be used for the text area
[ "Returns", "the", "Django", "form", "Widget", "to", "be", "used", "for", "the", "text", "area" ]
train
https://github.com/divio/djangocms-text-ckeditor/blob/a6069096fdac80931fd328055d1d615d168c33df/djangocms_text_ckeditor/cms_plugins.py#L227-L257
divio/djangocms-text-ckeditor
djangocms_text_ckeditor/cms_plugins.py
TextPlugin.get_form_class
def get_form_class(self, request, plugins, plugin): """ Returns a subclass of Form to be used by this plugin """ widget = self.get_editor_widget( request=request, plugins=plugins, plugin=plugin, ) instance = plugin.get_plugin_instance(...
python
def get_form_class(self, request, plugins, plugin): """ Returns a subclass of Form to be used by this plugin """ widget = self.get_editor_widget( request=request, plugins=plugins, plugin=plugin, ) instance = plugin.get_plugin_instance(...
[ "def", "get_form_class", "(", "self", ",", "request", ",", "plugins", ",", "plugin", ")", ":", "widget", "=", "self", ".", "get_editor_widget", "(", "request", "=", "request", ",", "plugins", "=", "plugins", ",", "plugin", "=", "plugin", ",", ")", "insta...
Returns a subclass of Form to be used by this plugin
[ "Returns", "a", "subclass", "of", "Form", "to", "be", "used", "by", "this", "plugin" ]
train
https://github.com/divio/djangocms-text-ckeditor/blob/a6069096fdac80931fd328055d1d615d168c33df/djangocms_text_ckeditor/cms_plugins.py#L259-L291
divio/djangocms-text-ckeditor
djangocms_text_ckeditor/utils.py
_plugin_tags_to_html
def _plugin_tags_to_html(text, output_func): """ Convert plugin object 'tags' into the form for public site. context is the template context to use, placeholder is the placeholder name """ plugins_by_id = get_plugins_from_text(text) def _render_tag(m): try: plugin_id = int(...
python
def _plugin_tags_to_html(text, output_func): """ Convert plugin object 'tags' into the form for public site. context is the template context to use, placeholder is the placeholder name """ plugins_by_id = get_plugins_from_text(text) def _render_tag(m): try: plugin_id = int(...
[ "def", "_plugin_tags_to_html", "(", "text", ",", "output_func", ")", ":", "plugins_by_id", "=", "get_plugins_from_text", "(", "text", ")", "def", "_render_tag", "(", "m", ")", ":", "try", ":", "plugin_id", "=", "int", "(", "m", ".", "groupdict", "(", ")", ...
Convert plugin object 'tags' into the form for public site. context is the template context to use, placeholder is the placeholder name
[ "Convert", "plugin", "object", "tags", "into", "the", "form", "for", "public", "site", "." ]
train
https://github.com/divio/djangocms-text-ckeditor/blob/a6069096fdac80931fd328055d1d615d168c33df/djangocms_text_ckeditor/utils.py#L91-L110
divio/djangocms-text-ckeditor
djangocms_text_ckeditor/html.py
clean_html
def clean_html(data, full=True, parser=DEFAULT_PARSER): """ Cleans HTML from XSS vulnerabilities using html5lib If full is False, only the contents inside <body> will be returned (without the <body> tags). """ if full: dom_tree = parser.parse(data) else: dom_tree = parser.par...
python
def clean_html(data, full=True, parser=DEFAULT_PARSER): """ Cleans HTML from XSS vulnerabilities using html5lib If full is False, only the contents inside <body> will be returned (without the <body> tags). """ if full: dom_tree = parser.parse(data) else: dom_tree = parser.par...
[ "def", "clean_html", "(", "data", ",", "full", "=", "True", ",", "parser", "=", "DEFAULT_PARSER", ")", ":", "if", "full", ":", "dom_tree", "=", "parser", ".", "parse", "(", "data", ")", "else", ":", "dom_tree", "=", "parser", ".", "parseFragment", "(",...
Cleans HTML from XSS vulnerabilities using html5lib If full is False, only the contents inside <body> will be returned (without the <body> tags).
[ "Cleans", "HTML", "from", "XSS", "vulnerabilities", "using", "html5lib", "If", "full", "is", "False", "only", "the", "contents", "inside", "<body", ">", "will", "be", "returned", "(", "without", "the", "<body", ">", "tags", ")", "." ]
train
https://github.com/divio/djangocms-text-ckeditor/blob/a6069096fdac80931fd328055d1d615d168c33df/djangocms_text_ckeditor/html.py#L56-L73
divio/djangocms-text-ckeditor
djangocms_text_ckeditor/html.py
extract_images
def extract_images(data, plugin): """ extracts base64 encoded images from drag and drop actions in browser and saves those images as plugins """ if not settings.TEXT_SAVE_IMAGE_FUNCTION: return data tree_builder = html5lib.treebuilders.getTreeBuilder('dom') parser = html5lib.html5par...
python
def extract_images(data, plugin): """ extracts base64 encoded images from drag and drop actions in browser and saves those images as plugins """ if not settings.TEXT_SAVE_IMAGE_FUNCTION: return data tree_builder = html5lib.treebuilders.getTreeBuilder('dom') parser = html5lib.html5par...
[ "def", "extract_images", "(", "data", ",", "plugin", ")", ":", "if", "not", "settings", ".", "TEXT_SAVE_IMAGE_FUNCTION", ":", "return", "data", "tree_builder", "=", "html5lib", ".", "treebuilders", ".", "getTreeBuilder", "(", "'dom'", ")", "parser", "=", "html...
extracts base64 encoded images from drag and drop actions in browser and saves those images as plugins
[ "extracts", "base64", "encoded", "images", "from", "drag", "and", "drop", "actions", "in", "browser", "and", "saves", "those", "images", "as", "plugins" ]
train
https://github.com/divio/djangocms-text-ckeditor/blob/a6069096fdac80931fd328055d1d615d168c33df/djangocms_text_ckeditor/html.py#L76-L140
edx/i18n-tools
i18n/config.py
Configuration.default_config_filename
def default_config_filename(root_dir=None): """ Returns the default name of the configuration file. """ root_dir = Path(root_dir) if root_dir else Path('.').abspath() locale_dir = root_dir / 'locale' if not os.path.exists(locale_dir): locale_dir = root_dir / '...
python
def default_config_filename(root_dir=None): """ Returns the default name of the configuration file. """ root_dir = Path(root_dir) if root_dir else Path('.').abspath() locale_dir = root_dir / 'locale' if not os.path.exists(locale_dir): locale_dir = root_dir / '...
[ "def", "default_config_filename", "(", "root_dir", "=", "None", ")", ":", "root_dir", "=", "Path", "(", "root_dir", ")", "if", "root_dir", "else", "Path", "(", "'.'", ")", ".", "abspath", "(", ")", "locale_dir", "=", "root_dir", "/", "'locale'", "if", "n...
Returns the default name of the configuration file.
[ "Returns", "the", "default", "name", "of", "the", "configuration", "file", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/config.py#L47-L55
edx/i18n-tools
i18n/config.py
Configuration.read_config
def read_config(self, filename): """ Returns data found in config file (as dict), or raises exception if file not found """ if not os.path.exists(filename): raise Exception("Configuration file cannot be found: %s" % filename) with io.open(filename, encoding='UTF-8') a...
python
def read_config(self, filename): """ Returns data found in config file (as dict), or raises exception if file not found """ if not os.path.exists(filename): raise Exception("Configuration file cannot be found: %s" % filename) with io.open(filename, encoding='UTF-8') a...
[ "def", "read_config", "(", "self", ",", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "raise", "Exception", "(", "\"Configuration file cannot be found: %s\"", "%", "filename", ")", "with", "io", ".", "open", ...
Returns data found in config file (as dict), or raises exception if file not found
[ "Returns", "data", "found", "in", "config", "file", "(", "as", "dict", ")", "or", "raises", "exception", "if", "file", "not", "found" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/config.py#L57-L64
edx/i18n-tools
i18n/config.py
Configuration.rtl_langs
def rtl_langs(self): """ Returns the set of translated RTL language codes present in self.locales. Ignores source locale. """ def is_rtl(lang): """ Returns True if lang is a RTL language args: lang (str): The language to be che...
python
def rtl_langs(self): """ Returns the set of translated RTL language codes present in self.locales. Ignores source locale. """ def is_rtl(lang): """ Returns True if lang is a RTL language args: lang (str): The language to be che...
[ "def", "rtl_langs", "(", "self", ")", ":", "def", "is_rtl", "(", "lang", ")", ":", "\"\"\"\n Returns True if lang is a RTL language\n\n args:\n lang (str): The language to be checked\n\n Returns:\n True if lang is an RTL language...
Returns the set of translated RTL language codes present in self.locales. Ignores source locale.
[ "Returns", "the", "set", "of", "translated", "RTL", "language", "codes", "present", "in", "self", ".", "locales", ".", "Ignores", "source", "locale", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/config.py#L94-L115
edx/i18n-tools
i18n/branch_cleanup.py
BranchCleanup.clean_conf_folder
def clean_conf_folder(self, locale): """Remove the configuration directory for `locale`""" dirname = self.configuration.get_messages_dir(locale) dirname.removedirs_p()
python
def clean_conf_folder(self, locale): """Remove the configuration directory for `locale`""" dirname = self.configuration.get_messages_dir(locale) dirname.removedirs_p()
[ "def", "clean_conf_folder", "(", "self", ",", "locale", ")", ":", "dirname", "=", "self", ".", "configuration", ".", "get_messages_dir", "(", "locale", ")", "dirname", ".", "removedirs_p", "(", ")" ]
Remove the configuration directory for `locale`
[ "Remove", "the", "configuration", "directory", "for", "locale" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/branch_cleanup.py#L27-L30
edx/i18n-tools
i18n/changed.py
Changed.run
def run(self, args): """ Main entry point of script """ changes_detected = self.detect_changes() message = self.get_message(changes_detected) print(message) return int(changes_detected)
python
def run(self, args): """ Main entry point of script """ changes_detected = self.detect_changes() message = self.get_message(changes_detected) print(message) return int(changes_detected)
[ "def", "run", "(", "self", ",", "args", ")", ":", "changes_detected", "=", "self", ".", "detect_changes", "(", ")", "message", "=", "self", ".", "get_message", "(", "changes_detected", ")", "print", "(", "message", ")", "return", "int", "(", "changes_detec...
Main entry point of script
[ "Main", "entry", "point", "of", "script" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/changed.py#L16-L23
edx/i18n-tools
i18n/segment.py
segment_pofiles
def segment_pofiles(configuration, locale): """Segment all the pofiles for `locale`. Returns a set of filenames, all the segment files written. """ files_written = set() for filename, segments in configuration.segment.items(): filename = configuration.get_messages_dir(locale) / filename ...
python
def segment_pofiles(configuration, locale): """Segment all the pofiles for `locale`. Returns a set of filenames, all the segment files written. """ files_written = set() for filename, segments in configuration.segment.items(): filename = configuration.get_messages_dir(locale) / filename ...
[ "def", "segment_pofiles", "(", "configuration", ",", "locale", ")", ":", "files_written", "=", "set", "(", ")", "for", "filename", ",", "segments", "in", "configuration", ".", "segment", ".", "items", "(", ")", ":", "filename", "=", "configuration", ".", "...
Segment all the pofiles for `locale`. Returns a set of filenames, all the segment files written.
[ "Segment", "all", "the", "pofiles", "for", "locale", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/segment.py#L20-L30
edx/i18n-tools
i18n/segment.py
segment_pofile
def segment_pofile(filename, segments): """Segment a .po file using patterns in `segments`. The .po file at `filename` is read, and the occurrence locations of its messages are examined. `segments` is a dictionary: the keys are segment .po filenames, the values are lists of patterns:: { ...
python
def segment_pofile(filename, segments): """Segment a .po file using patterns in `segments`. The .po file at `filename` is read, and the occurrence locations of its messages are examined. `segments` is a dictionary: the keys are segment .po filenames, the values are lists of patterns:: { ...
[ "def", "segment_pofile", "(", "filename", ",", "segments", ")", ":", "reading_msg", "=", "\"Reading {num} entries from {file}\"", "writing_msg", "=", "\"Writing {num} entries to {file}\"", "source_po", "=", "polib", ".", "pofile", "(", "filename", ")", "LOG", ".", "in...
Segment a .po file using patterns in `segments`. The .po file at `filename` is read, and the occurrence locations of its messages are examined. `segments` is a dictionary: the keys are segment .po filenames, the values are lists of patterns:: { 'django-studio.po': [ 'c...
[ "Segment", "a", ".", "po", "file", "using", "patterns", "in", "segments", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/segment.py#L33-L116
edx/i18n-tools
i18n/segment.py
get_parser
def get_parser(parser): """ Grabs the parser. args: parser: The parser """ parser.description = textwrap.dedent(""" Segment the .po files in LOCALE(s) based on the segmenting rules in config.yaml. Note that segmenting is *not* idempotent: it modifies the input file,...
python
def get_parser(parser): """ Grabs the parser. args: parser: The parser """ parser.description = textwrap.dedent(""" Segment the .po files in LOCALE(s) based on the segmenting rules in config.yaml. Note that segmenting is *not* idempotent: it modifies the input file,...
[ "def", "get_parser", "(", "parser", ")", ":", "parser", ".", "description", "=", "textwrap", ".", "dedent", "(", "\"\"\"\n Segment the .po files in LOCALE(s) based on the segmenting rules in\n config.yaml.\n\n Note that segmenting is *not* idempotent: it modifies the...
Grabs the parser. args: parser: The parser
[ "Grabs", "the", "parser", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/segment.py#L119-L133
edx/i18n-tools
i18n/segment.py
Segment.add_args
def add_args(self): """ Adds arguments """ self.parser.description = textwrap.dedent(""" Segment the .po files in LOCALE(s) based on the segmenting rules in config.yaml. Note that segmenting is *not* idempotent: it modifies the input file, so be careful t...
python
def add_args(self): """ Adds arguments """ self.parser.description = textwrap.dedent(""" Segment the .po files in LOCALE(s) based on the segmenting rules in config.yaml. Note that segmenting is *not* idempotent: it modifies the input file, so be careful t...
[ "def", "add_args", "(", "self", ")", ":", "self", ".", "parser", ".", "description", "=", "textwrap", ".", "dedent", "(", "\"\"\"\n Segment the .po files in LOCALE(s) based on the segmenting rules in\n config.yaml.\n\n Note that segmenting is *not* idempotent: it...
Adds arguments
[ "Adds", "arguments" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/segment.py#L140-L151
edx/i18n-tools
i18n/segment.py
Segment.run
def run(self, args): # pylint: disable=unused-argument """ Main entry point of script """ logging.basicConfig(stream=sys.stdout, level=logging.INFO) # This is used as a tool only to segment translation files when adding a # new segment. In the regular workflow, the wor...
python
def run(self, args): # pylint: disable=unused-argument """ Main entry point of script """ logging.basicConfig(stream=sys.stdout, level=logging.INFO) # This is used as a tool only to segment translation files when adding a # new segment. In the regular workflow, the wor...
[ "def", "run", "(", "self", ",", "args", ")", ":", "# pylint: disable=unused-argument", "logging", ".", "basicConfig", "(", "stream", "=", "sys", ".", "stdout", ",", "level", "=", "logging", ".", "INFO", ")", "# This is used as a tool only to segment translation file...
Main entry point of script
[ "Main", "entry", "point", "of", "script" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/segment.py#L153-L164
edx/i18n-tools
i18n/extract.py
fix_header
def fix_header(pofile): """ Replace default headers with edX headers """ # By default, django-admin.py makemessages creates this header: # # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE...
python
def fix_header(pofile): """ Replace default headers with edX headers """ # By default, django-admin.py makemessages creates this header: # # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE...
[ "def", "fix_header", "(", "pofile", ")", ":", "# By default, django-admin.py makemessages creates this header:", "#", "# SOME DESCRIPTIVE TITLE.", "# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER", "# This file is distributed under the same license as the PACKAGE package.", "# FIRS...
Replace default headers with edX headers
[ "Replace", "default", "headers", "with", "edX", "headers" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/extract.py#L184-L216
edx/i18n-tools
i18n/extract.py
strip_key_strings
def strip_key_strings(pofile): """ Removes all entries in PO which are key strings. These entries should appear only in messages.po, not in any other po files. """ newlist = [entry for entry in pofile if not is_key_string(entry.msgid)] del pofile[:] pofile += newlist
python
def strip_key_strings(pofile): """ Removes all entries in PO which are key strings. These entries should appear only in messages.po, not in any other po files. """ newlist = [entry for entry in pofile if not is_key_string(entry.msgid)] del pofile[:] pofile += newlist
[ "def", "strip_key_strings", "(", "pofile", ")", ":", "newlist", "=", "[", "entry", "for", "entry", "in", "pofile", "if", "not", "is_key_string", "(", "entry", ".", "msgid", ")", "]", "del", "pofile", "[", ":", "]", "pofile", "+=", "newlist" ]
Removes all entries in PO which are key strings. These entries should appear only in messages.po, not in any other po files.
[ "Removes", "all", "entries", "in", "PO", "which", "are", "key", "strings", ".", "These", "entries", "should", "appear", "only", "in", "messages", ".", "po", "not", "in", "any", "other", "po", "files", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/extract.py#L249-L256
edx/i18n-tools
i18n/extract.py
Extract.base
def base(self, path1, *paths): """Return a relative path from config.BASE_DIR to path1 / paths[0] / ... """ root_dir = self.configuration.root_dir return root_dir.relpathto(path1.joinpath(*paths))
python
def base(self, path1, *paths): """Return a relative path from config.BASE_DIR to path1 / paths[0] / ... """ root_dir = self.configuration.root_dir return root_dir.relpathto(path1.joinpath(*paths))
[ "def", "base", "(", "self", ",", "path1", ",", "*", "paths", ")", ":", "root_dir", "=", "self", ".", "configuration", ".", "root_dir", "return", "root_dir", ".", "relpathto", "(", "path1", ".", "joinpath", "(", "*", "paths", ")", ")" ]
Return a relative path from config.BASE_DIR to path1 / paths[0] / ...
[ "Return", "a", "relative", "path", "from", "config", ".", "BASE_DIR", "to", "path1", "/", "paths", "[", "0", "]", "/", "..." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/extract.py#L43-L46
edx/i18n-tools
i18n/extract.py
Extract.rename_source_file
def rename_source_file(self, src, dst): """ Rename a file in the source directory. """ try: os.rename(self.source_msgs_dir.joinpath(src), self.source_msgs_dir.joinpath(dst)) except OSError: pass
python
def rename_source_file(self, src, dst): """ Rename a file in the source directory. """ try: os.rename(self.source_msgs_dir.joinpath(src), self.source_msgs_dir.joinpath(dst)) except OSError: pass
[ "def", "rename_source_file", "(", "self", ",", "src", ",", "dst", ")", ":", "try", ":", "os", ".", "rename", "(", "self", ".", "source_msgs_dir", ".", "joinpath", "(", "src", ")", ",", "self", ".", "source_msgs_dir", ".", "joinpath", "(", "dst", ")", ...
Rename a file in the source directory.
[ "Rename", "a", "file", "in", "the", "source", "directory", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/extract.py#L55-L62
edx/i18n-tools
i18n/extract.py
Extract.run
def run(self, args): """ Main entry point of script """ logging.basicConfig(stream=sys.stdout, level=logging.INFO) configuration = self.configuration configuration.locale_dir.parent.makedirs_p() # pylint: disable=attribute-defined-outside-init self.source_...
python
def run(self, args): """ Main entry point of script """ logging.basicConfig(stream=sys.stdout, level=logging.INFO) configuration = self.configuration configuration.locale_dir.parent.makedirs_p() # pylint: disable=attribute-defined-outside-init self.source_...
[ "def", "run", "(", "self", ",", "args", ")", ":", "logging", ".", "basicConfig", "(", "stream", "=", "sys", ".", "stdout", ",", "level", "=", "logging", ".", "INFO", ")", "configuration", "=", "self", ".", "configuration", "configuration", ".", "locale_d...
Main entry point of script
[ "Main", "entry", "point", "of", "script" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/extract.py#L64-L181
edx/i18n-tools
i18n/main.py
get_valid_commands
def get_valid_commands(): """ Returns valid commands. Returns: commands (list): List of valid commands """ modules = [m.basename().split('.')[0] for m in Path(__file__).dirname().files('*.py')] commands = [] for modname in modules: if modname == 'main': continue ...
python
def get_valid_commands(): """ Returns valid commands. Returns: commands (list): List of valid commands """ modules = [m.basename().split('.')[0] for m in Path(__file__).dirname().files('*.py')] commands = [] for modname in modules: if modname == 'main': continue ...
[ "def", "get_valid_commands", "(", ")", ":", "modules", "=", "[", "m", ".", "basename", "(", ")", ".", "split", "(", "'.'", ")", "[", "0", "]", "for", "m", "in", "Path", "(", "__file__", ")", ".", "dirname", "(", ")", ".", "files", "(", "'*.py'", ...
Returns valid commands. Returns: commands (list): List of valid commands
[ "Returns", "valid", "commands", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/main.py#L11-L26
edx/i18n-tools
i18n/main.py
error_message
def error_message(): """ Writes out error message specifying the valid commands. Returns: Failure code for system exit """ sys.stderr.write('valid commands:\n') for cmd in get_valid_commands(): sys.stderr.write('\t%s\n' % cmd) return -1
python
def error_message(): """ Writes out error message specifying the valid commands. Returns: Failure code for system exit """ sys.stderr.write('valid commands:\n') for cmd in get_valid_commands(): sys.stderr.write('\t%s\n' % cmd) return -1
[ "def", "error_message", "(", ")", ":", "sys", ".", "stderr", ".", "write", "(", "'valid commands:\\n'", ")", "for", "cmd", "in", "get_valid_commands", "(", ")", ":", "sys", ".", "stderr", ".", "write", "(", "'\\t%s\\n'", "%", "cmd", ")", "return", "-", ...
Writes out error message specifying the valid commands. Returns: Failure code for system exit
[ "Writes", "out", "error", "message", "specifying", "the", "valid", "commands", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/main.py#L29-L39
edx/i18n-tools
i18n/main.py
main
def main(): """ Executes the given command. Returns error_message if command is not valid. Returns: Output of the given command or error message if command is not valid. """ try: command = sys.argv[1] except IndexError: return error_message() try: module = i...
python
def main(): """ Executes the given command. Returns error_message if command is not valid. Returns: Output of the given command or error message if command is not valid. """ try: command = sys.argv[1] except IndexError: return error_message() try: module = i...
[ "def", "main", "(", ")", ":", "try", ":", "command", "=", "sys", ".", "argv", "[", "1", "]", "except", "IndexError", ":", "return", "error_message", "(", ")", "try", ":", "module", "=", "importlib", ".", "import_module", "(", "'i18n.%s'", "%", "command...
Executes the given command. Returns error_message if command is not valid. Returns: Output of the given command or error message if command is not valid.
[ "Executes", "the", "given", "command", ".", "Returns", "error_message", "if", "command", "is", "not", "valid", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/main.py#L42-L60
edx/i18n-tools
i18n/validate.py
validate_po_files
def validate_po_files(configuration, locale_dir, root_dir=None, report_empty=False, check_all=False): """ Validate all of the po files found in the root directory that are not product of a merge. Returns a boolean indicating whether or not problems were found. """ found_problems = False # List...
python
def validate_po_files(configuration, locale_dir, root_dir=None, report_empty=False, check_all=False): """ Validate all of the po files found in the root directory that are not product of a merge. Returns a boolean indicating whether or not problems were found. """ found_problems = False # List...
[ "def", "validate_po_files", "(", "configuration", ",", "locale_dir", ",", "root_dir", "=", "None", ",", "report_empty", "=", "False", ",", "check_all", "=", "False", ")", ":", "found_problems", "=", "False", "# List of .po files that are the product of a merge (see gene...
Validate all of the po files found in the root directory that are not product of a merge. Returns a boolean indicating whether or not problems were found.
[ "Validate", "all", "of", "the", "po", "files", "found", "in", "the", "root", "directory", "that", "are", "not", "product", "of", "a", "merge", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/validate.py#L22-L63
edx/i18n-tools
i18n/validate.py
msgfmt_check_po_file
def msgfmt_check_po_file(locale_dir, filename): """ Call GNU msgfmt -c on each .po file to validate its format. Any errors caught by msgfmt are logged to log. Returns a boolean indicating whether or not problems were found. """ found_problems = False # Use relative paths to make output les...
python
def msgfmt_check_po_file(locale_dir, filename): """ Call GNU msgfmt -c on each .po file to validate its format. Any errors caught by msgfmt are logged to log. Returns a boolean indicating whether or not problems were found. """ found_problems = False # Use relative paths to make output les...
[ "def", "msgfmt_check_po_file", "(", "locale_dir", ",", "filename", ")", ":", "found_problems", "=", "False", "# Use relative paths to make output less noisy.", "rfile", "=", "os", ".", "path", ".", "relpath", "(", "filename", ",", "locale_dir", ")", "out", ",", "e...
Call GNU msgfmt -c on each .po file to validate its format. Any errors caught by msgfmt are logged to log. Returns a boolean indicating whether or not problems were found.
[ "Call", "GNU", "msgfmt", "-", "c", "on", "each", ".", "po", "file", "to", "validate", "its", "format", ".", "Any", "errors", "caught", "by", "msgfmt", "are", "logged", "to", "log", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/validate.py#L66-L83
edx/i18n-tools
i18n/validate.py
tags_in_string
def tags_in_string(msg): """ Return the set of tags in a message string. Tags includes HTML tags, data placeholders, etc. Skips tags that might change due to translations: HTML entities, <abbr>, and so on. """ def is_linguistic_tag(tag): """Is this tag one that can change with the...
python
def tags_in_string(msg): """ Return the set of tags in a message string. Tags includes HTML tags, data placeholders, etc. Skips tags that might change due to translations: HTML entities, <abbr>, and so on. """ def is_linguistic_tag(tag): """Is this tag one that can change with the...
[ "def", "tags_in_string", "(", "msg", ")", ":", "def", "is_linguistic_tag", "(", "tag", ")", ":", "\"\"\"Is this tag one that can change with the language?\"\"\"", "if", "tag", ".", "startswith", "(", "\"&\"", ")", ":", "return", "True", "if", "any", "(", "x", "i...
Return the set of tags in a message string. Tags includes HTML tags, data placeholders, etc. Skips tags that might change due to translations: HTML entities, <abbr>, and so on.
[ "Return", "the", "set", "of", "tags", "in", "a", "message", "string", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/validate.py#L86-L105
edx/i18n-tools
i18n/validate.py
astral
def astral(msg): """Does `msg` have characters outside the Basic Multilingual Plane?""" # Python2 narrow builds present astral characters as surrogate pairs. # By encoding as utf32, and decoding DWORDS, we can get at the real code # points. utf32 = msg.encode("utf32")[4:] # [4:] to drop the ...
python
def astral(msg): """Does `msg` have characters outside the Basic Multilingual Plane?""" # Python2 narrow builds present astral characters as surrogate pairs. # By encoding as utf32, and decoding DWORDS, we can get at the real code # points. utf32 = msg.encode("utf32")[4:] # [4:] to drop the ...
[ "def", "astral", "(", "msg", ")", ":", "# Python2 narrow builds present astral characters as surrogate pairs.", "# By encoding as utf32, and decoding DWORDS, we can get at the real code", "# points.", "utf32", "=", "msg", ".", "encode", "(", "\"utf32\"", ")", "[", "4", ":", "...
Does `msg` have characters outside the Basic Multilingual Plane?
[ "Does", "msg", "have", "characters", "outside", "the", "Basic", "Multilingual", "Plane?" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/validate.py#L108-L115
edx/i18n-tools
i18n/validate.py
check_messages
def check_messages(filename, report_empty=False): """ Checks messages in `filename` in various ways: * Translations must have the same slots as the English. * Messages can't have astral characters in them. If `report_empty` is True, will also report empty translation strings. Returns the pro...
python
def check_messages(filename, report_empty=False): """ Checks messages in `filename` in various ways: * Translations must have the same slots as the English. * Messages can't have astral characters in them. If `report_empty` is True, will also report empty translation strings. Returns the pro...
[ "def", "check_messages", "(", "filename", ",", "report_empty", "=", "False", ")", ":", "problems", "=", "[", "]", "pomsgs", "=", "polib", ".", "pofile", "(", "filename", ")", "for", "msg", "in", "pomsgs", ":", "# Check for characters Javascript can't support.", ...
Checks messages in `filename` in various ways: * Translations must have the same slots as the English. * Messages can't have astral characters in them. If `report_empty` is True, will also report empty translation strings. Returns the problems, a list of tuples. Each is a description, a msgid, and ...
[ "Checks", "messages", "in", "filename", "in", "various", "ways", ":" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/validate.py#L118-L179
edx/i18n-tools
i18n/validate.py
report_problems
def report_problems(filename, problems): """ Report on the problems found in `filename`. `problems` is a list of tuples as returned by `check_messages`. """ problem_file = filename.replace(".po", ".prob") id_filler = textwrap.TextWrapper(width=79, initial_indent=" msgid: ", subsequent_indent=...
python
def report_problems(filename, problems): """ Report on the problems found in `filename`. `problems` is a list of tuples as returned by `check_messages`. """ problem_file = filename.replace(".po", ".prob") id_filler = textwrap.TextWrapper(width=79, initial_indent=" msgid: ", subsequent_indent=...
[ "def", "report_problems", "(", "filename", ",", "problems", ")", ":", "problem_file", "=", "filename", ".", "replace", "(", "\".po\"", ",", "\".prob\"", ")", "id_filler", "=", "textwrap", ".", "TextWrapper", "(", "width", "=", "79", ",", "initial_indent", "=...
Report on the problems found in `filename`. `problems` is a list of tuples as returned by `check_messages`.
[ "Report", "on", "the", "problems", "found", "in", "filename", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/validate.py#L182-L203
edx/i18n-tools
i18n/validate.py
Validate.run
def run(self, args): """ Main entry point for script Returns an integer representing the exit code that should be returned by the script. """ exit_code = 0 if args.verbose: log_level = logging.INFO else: log_level = logging.WARNING ...
python
def run(self, args): """ Main entry point for script Returns an integer representing the exit code that should be returned by the script. """ exit_code = 0 if args.verbose: log_level = logging.INFO else: log_level = logging.WARNING ...
[ "def", "run", "(", "self", ",", "args", ")", ":", "exit_code", "=", "0", "if", "args", ".", "verbose", ":", "log_level", "=", "logging", ".", "INFO", "else", ":", "log_level", "=", "logging", ".", "WARNING", "logging", ".", "basicConfig", "(", "stream"...
Main entry point for script Returns an integer representing the exit code that should be returned by the script.
[ "Main", "entry", "point", "for", "script" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/validate.py#L234-L268
edx/i18n-tools
i18n/generate.py
merge
def merge(configuration, locale, target='django.po', sources=('django-partial.po',), fail_if_missing=True): """ For the given locale, merge the `sources` files to become the `target` file. Note that the target file might also be one of the sources. If fail_if_missing is true, and the files to be merge...
python
def merge(configuration, locale, target='django.po', sources=('django-partial.po',), fail_if_missing=True): """ For the given locale, merge the `sources` files to become the `target` file. Note that the target file might also be one of the sources. If fail_if_missing is true, and the files to be merge...
[ "def", "merge", "(", "configuration", ",", "locale", ",", "target", "=", "'django.po'", ",", "sources", "=", "(", "'django-partial.po'", ",", ")", ",", "fail_if_missing", "=", "True", ")", ":", "LOG", ".", "info", "(", "'Merging %s locale %s'", ",", "target"...
For the given locale, merge the `sources` files to become the `target` file. Note that the target file might also be one of the sources. If fail_if_missing is true, and the files to be merged are missing, throw an Exception, otherwise return silently. If fail_if_missing is false, and the files to be ...
[ "For", "the", "given", "locale", "merge", "the", "sources", "files", "to", "become", "the", "target", "file", ".", "Note", "that", "the", "target", "file", "might", "also", "be", "one", "of", "the", "sources", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/generate.py#L32-L72
edx/i18n-tools
i18n/generate.py
merge_files
def merge_files(configuration, locale, fail_if_missing=True): """ Merge all the files in `locale`, as specified in config.yaml. """ for target, sources in configuration.generate_merge.items(): merge(configuration, locale, target, sources, fail_if_missing)
python
def merge_files(configuration, locale, fail_if_missing=True): """ Merge all the files in `locale`, as specified in config.yaml. """ for target, sources in configuration.generate_merge.items(): merge(configuration, locale, target, sources, fail_if_missing)
[ "def", "merge_files", "(", "configuration", ",", "locale", ",", "fail_if_missing", "=", "True", ")", ":", "for", "target", ",", "sources", "in", "configuration", ".", "generate_merge", ".", "items", "(", ")", ":", "merge", "(", "configuration", ",", "locale"...
Merge all the files in `locale`, as specified in config.yaml.
[ "Merge", "all", "the", "files", "in", "locale", "as", "specified", "in", "config", ".", "yaml", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/generate.py#L75-L80
edx/i18n-tools
i18n/generate.py
clean_pofile
def clean_pofile(pofile_path): """ Clean various aspect of a .po file. Fixes: - Removes the fuzzy flag on metadata. - Removes occurrence line numbers so that the generated files don't generate a lot of line noise when they're committed. Returns a list of any duplicate entri...
python
def clean_pofile(pofile_path): """ Clean various aspect of a .po file. Fixes: - Removes the fuzzy flag on metadata. - Removes occurrence line numbers so that the generated files don't generate a lot of line noise when they're committed. Returns a list of any duplicate entri...
[ "def", "clean_pofile", "(", "pofile_path", ")", ":", "# Reading in the .po file and saving it again fixes redundancies.", "pomsgs", "=", "pofile", "(", "pofile_path", ")", "# The msgcat tool marks the metadata as fuzzy, but it's ok as it is.", "pomsgs", ".", "metadata_is_fuzzy", "=...
Clean various aspect of a .po file. Fixes: - Removes the fuzzy flag on metadata. - Removes occurrence line numbers so that the generated files don't generate a lot of line noise when they're committed. Returns a list of any duplicate entries found.
[ "Clean", "various", "aspect", "of", "a", ".", "po", "file", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/generate.py#L83-L135
edx/i18n-tools
i18n/generate.py
validate_files
def validate_files(directory, files_to_merge): """ Asserts that the given files exist. files_to_merge is a list of file names (no directories). directory is the directory (a path object from path.py) in which the files should appear. raises an Exception if any of the files are not in dir. """ ...
python
def validate_files(directory, files_to_merge): """ Asserts that the given files exist. files_to_merge is a list of file names (no directories). directory is the directory (a path object from path.py) in which the files should appear. raises an Exception if any of the files are not in dir. """ ...
[ "def", "validate_files", "(", "directory", ",", "files_to_merge", ")", ":", "for", "file_path", "in", "files_to_merge", ":", "pathname", "=", "directory", ".", "joinpath", "(", "file_path", ")", "if", "not", "pathname", ".", "exists", "(", ")", ":", "raise",...
Asserts that the given files exist. files_to_merge is a list of file names (no directories). directory is the directory (a path object from path.py) in which the files should appear. raises an Exception if any of the files are not in dir.
[ "Asserts", "that", "the", "given", "files", "exist", ".", "files_to_merge", "is", "a", "list", "of", "file", "names", "(", "no", "directories", ")", ".", "directory", "is", "the", "directory", "(", "a", "path", "object", "from", "path", ".", "py", ")", ...
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/generate.py#L138-L150
edx/i18n-tools
i18n/generate.py
Generate.run
def run(self, args): """ Main entry point for script """ logging.basicConfig(stream=sys.stdout, level=logging.INFO) configuration = self.configuration if args.ltr: langs = configuration.ltr_langs elif args.rtl: langs = configuration.rtl_la...
python
def run(self, args): """ Main entry point for script """ logging.basicConfig(stream=sys.stdout, level=logging.INFO) configuration = self.configuration if args.ltr: langs = configuration.ltr_langs elif args.rtl: langs = configuration.rtl_la...
[ "def", "run", "(", "self", ",", "args", ")", ":", "logging", ".", "basicConfig", "(", "stream", "=", "sys", ".", "stdout", ",", "level", "=", "logging", ".", "INFO", ")", "configuration", "=", "self", ".", "configuration", "if", "args", ".", "ltr", "...
Main entry point for script
[ "Main", "entry", "point", "for", "script" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/generate.py#L161-L198
edx/i18n-tools
i18n/dummy.py
make_dummy
def make_dummy(filename, locale, converter): """ Takes a source po file, reads it, and writes out a new po file in :param locale: containing a dummy translation. """ if not Path(filename).exists(): raise IOError('File does not exist: %r' % filename) pofile = polib.pofile(filename) fo...
python
def make_dummy(filename, locale, converter): """ Takes a source po file, reads it, and writes out a new po file in :param locale: containing a dummy translation. """ if not Path(filename).exists(): raise IOError('File does not exist: %r' % filename) pofile = polib.pofile(filename) fo...
[ "def", "make_dummy", "(", "filename", ",", "locale", ",", "converter", ")", ":", "if", "not", "Path", "(", "filename", ")", ".", "exists", "(", ")", ":", "raise", "IOError", "(", "'File does not exist: %r'", "%", "filename", ")", "pofile", "=", "polib", ...
Takes a source po file, reads it, and writes out a new po file in :param locale: containing a dummy translation.
[ "Takes", "a", "source", "po", "file", "reads", "it", "and", "writes", "out", "a", "new", "po", "file", "in", ":", "param", "locale", ":", "containing", "a", "dummy", "translation", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/dummy.py#L190-L214
edx/i18n-tools
i18n/dummy.py
new_filename
def new_filename(original_filename, new_locale): """Returns a filename derived from original_filename, using new_locale as the locale""" orig_file = Path(original_filename) new_file = orig_file.parent.parent.parent / new_locale / orig_file.parent.name / orig_file.name return new_file.abspath()
python
def new_filename(original_filename, new_locale): """Returns a filename derived from original_filename, using new_locale as the locale""" orig_file = Path(original_filename) new_file = orig_file.parent.parent.parent / new_locale / orig_file.parent.name / orig_file.name return new_file.abspath()
[ "def", "new_filename", "(", "original_filename", ",", "new_locale", ")", ":", "orig_file", "=", "Path", "(", "original_filename", ")", "new_file", "=", "orig_file", ".", "parent", ".", "parent", ".", "parent", "/", "new_locale", "/", "orig_file", ".", "parent"...
Returns a filename derived from original_filename, using new_locale as the locale
[ "Returns", "a", "filename", "derived", "from", "original_filename", "using", "new_locale", "as", "the", "locale" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/dummy.py#L217-L221
edx/i18n-tools
i18n/dummy.py
BaseDummyConverter.convert_msg
def convert_msg(self, msg): """ Takes one POEntry object and converts it (adds a dummy translation to it) msg is an instance of polib.POEntry """ source = msg.msgid if not source: # don't translate empty string return plural = msg.msgid_pl...
python
def convert_msg(self, msg): """ Takes one POEntry object and converts it (adds a dummy translation to it) msg is an instance of polib.POEntry """ source = msg.msgid if not source: # don't translate empty string return plural = msg.msgid_pl...
[ "def", "convert_msg", "(", "self", ",", "msg", ")", ":", "source", "=", "msg", ".", "msgid", "if", "not", "source", ":", "# don't translate empty string", "return", "plural", "=", "msg", ".", "msgid_plural", "if", "plural", ":", "# translate singular and plural"...
Takes one POEntry object and converts it (adds a dummy translation to it) msg is an instance of polib.POEntry
[ "Takes", "one", "POEntry", "object", "and", "converts", "it", "(", "adds", "a", "dummy", "translation", "to", "it", ")", "msg", "is", "an", "instance", "of", "polib", ".", "POEntry" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/dummy.py#L68-L90
edx/i18n-tools
i18n/dummy.py
Dummy.pad
def pad(self, string): """ Add some lorem ipsum text to the end of string to simulate more verbose languages (like German). Padding factor extrapolated by guidelines at http://www.w3.org/International/articles/article-text-size.en """ size = len(string) target = size * (4...
python
def pad(self, string): """ Add some lorem ipsum text to the end of string to simulate more verbose languages (like German). Padding factor extrapolated by guidelines at http://www.w3.org/International/articles/article-text-size.en """ size = len(string) target = size * (4...
[ "def", "pad", "(", "self", ",", "string", ")", ":", "size", "=", "len", "(", "string", ")", "target", "=", "size", "*", "(", "4.75", "-", "size", "**", "0.27", ")", "pad_len", "=", "int", "(", "target", ")", "-", "size", "return", "string", "+", ...
Add some lorem ipsum text to the end of string to simulate more verbose languages (like German). Padding factor extrapolated by guidelines at http://www.w3.org/International/articles/article-text-size.en
[ "Add", "some", "lorem", "ipsum", "text", "to", "the", "end", "of", "string", "to", "simulate", "more", "verbose", "languages", "(", "like", "German", ")", ".", "Padding", "factor", "extrapolated", "by", "guidelines", "at", "http", ":", "//", "www", ".", ...
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/dummy.py#L156-L164
edx/i18n-tools
i18n/dummy.py
DummyCommand.run
def run(self, args): """ Generate dummy strings for all source po files. """ configuration = self.configuration source_messages_dir = configuration.source_messages_dir for locale, converter in zip(configuration.dummy_locales, [Dummy(), Dummy2(), ArabicDummy()]): ...
python
def run(self, args): """ Generate dummy strings for all source po files. """ configuration = self.configuration source_messages_dir = configuration.source_messages_dir for locale, converter in zip(configuration.dummy_locales, [Dummy(), Dummy2(), ArabicDummy()]): ...
[ "def", "run", "(", "self", ",", "args", ")", ":", "configuration", "=", "self", ".", "configuration", "source_messages_dir", "=", "configuration", ".", "source_messages_dir", "for", "locale", ",", "converter", "in", "zip", "(", "configuration", ".", "dummy_local...
Generate dummy strings for all source po files.
[ "Generate", "dummy", "strings", "for", "all", "source", "po", "files", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/dummy.py#L235-L248
edx/i18n-tools
i18n/execute.py
execute
def execute(command, working_directory=config.BASE_DIR, stderr=sp.STDOUT): """ Executes shell command in a given working_directory. Command is a string to pass to the shell. Output is ignored. """ LOG.info("Executing in %s ...", working_directory) LOG.info(command) sp.check_call(command,...
python
def execute(command, working_directory=config.BASE_DIR, stderr=sp.STDOUT): """ Executes shell command in a given working_directory. Command is a string to pass to the shell. Output is ignored. """ LOG.info("Executing in %s ...", working_directory) LOG.info(command) sp.check_call(command,...
[ "def", "execute", "(", "command", ",", "working_directory", "=", "config", ".", "BASE_DIR", ",", "stderr", "=", "sp", ".", "STDOUT", ")", ":", "LOG", ".", "info", "(", "\"Executing in %s ...\"", ",", "working_directory", ")", "LOG", ".", "info", "(", "comm...
Executes shell command in a given working_directory. Command is a string to pass to the shell. Output is ignored.
[ "Executes", "shell", "command", "in", "a", "given", "working_directory", ".", "Command", "is", "a", "string", "to", "pass", "to", "the", "shell", ".", "Output", "is", "ignored", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/execute.py#L13-L21
edx/i18n-tools
i18n/execute.py
call
def call(command, working_directory=config.BASE_DIR): """ Executes shell command in a given working_directory. Command is a list of strings to execute as a command line. Returns a tuple of two byte strings: (stdout, stderr) """ LOG.info(command) proc = sp.Popen(command, stdout=sp.PIPE, stde...
python
def call(command, working_directory=config.BASE_DIR): """ Executes shell command in a given working_directory. Command is a list of strings to execute as a command line. Returns a tuple of two byte strings: (stdout, stderr) """ LOG.info(command) proc = sp.Popen(command, stdout=sp.PIPE, stde...
[ "def", "call", "(", "command", ",", "working_directory", "=", "config", ".", "BASE_DIR", ")", ":", "LOG", ".", "info", "(", "command", ")", "proc", "=", "sp", ".", "Popen", "(", "command", ",", "stdout", "=", "sp", ".", "PIPE", ",", "stderr", "=", ...
Executes shell command in a given working_directory. Command is a list of strings to execute as a command line. Returns a tuple of two byte strings: (stdout, stderr)
[ "Executes", "shell", "command", "in", "a", "given", "working_directory", ".", "Command", "is", "a", "list", "of", "strings", "to", "execute", "as", "a", "command", "line", ".", "Returns", "a", "tuple", "of", "two", "byte", "strings", ":", "(", "stdout", ...
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/execute.py#L24-L34
edx/i18n-tools
i18n/execute.py
remove_file
def remove_file(filename, verbose=True): """ Attempt to delete filename. log is boolean. If true, removal is logged. Log a warning if file does not exist. Logging filenames are relative to config.BASE_DIR to cut down on noise in output. """ if verbose: LOG.info('Deleting file %s', os...
python
def remove_file(filename, verbose=True): """ Attempt to delete filename. log is boolean. If true, removal is logged. Log a warning if file does not exist. Logging filenames are relative to config.BASE_DIR to cut down on noise in output. """ if verbose: LOG.info('Deleting file %s', os...
[ "def", "remove_file", "(", "filename", ",", "verbose", "=", "True", ")", ":", "if", "verbose", ":", "LOG", ".", "info", "(", "'Deleting file %s'", ",", "os", ".", "path", ".", "relpath", "(", "filename", ",", "config", ".", "BASE_DIR", ")", ")", "if", ...
Attempt to delete filename. log is boolean. If true, removal is logged. Log a warning if file does not exist. Logging filenames are relative to config.BASE_DIR to cut down on noise in output.
[ "Attempt", "to", "delete", "filename", ".", "log", "is", "boolean", ".", "If", "true", "removal", "is", "logged", ".", "Log", "a", "warning", "if", "file", "does", "not", "exist", ".", "Logging", "filenames", "are", "relative", "to", "config", ".", "BASE...
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/execute.py#L37-L49
edx/i18n-tools
i18n/transifex.py
push
def push(*resources): """ Push translation source English files to Transifex. Arguments name specific resources to push. Otherwise, push all the source files. """ cmd = 'tx push -s' if resources: for resource in resources: execute(cmd + ' -r {resource}'.format(resource=r...
python
def push(*resources): """ Push translation source English files to Transifex. Arguments name specific resources to push. Otherwise, push all the source files. """ cmd = 'tx push -s' if resources: for resource in resources: execute(cmd + ' -r {resource}'.format(resource=r...
[ "def", "push", "(", "*", "resources", ")", ":", "cmd", "=", "'tx push -s'", "if", "resources", ":", "for", "resource", "in", "resources", ":", "execute", "(", "cmd", "+", "' -r {resource}'", ".", "format", "(", "resource", "=", "resource", ")", ")", "els...
Push translation source English files to Transifex. Arguments name specific resources to push. Otherwise, push all the source files.
[ "Push", "translation", "source", "English", "files", "to", "Transifex", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L17-L29
edx/i18n-tools
i18n/transifex.py
pull
def pull(configuration, *resources): """ Pull translations from all languages listed in conf/locale/config.yaml where there is at least 10% reviewed translations. If arguments are provided, they are specific resources to pull. Otherwise, all resources are pulled. """ print("Pulling conf/l...
python
def pull(configuration, *resources): """ Pull translations from all languages listed in conf/locale/config.yaml where there is at least 10% reviewed translations. If arguments are provided, they are specific resources to pull. Otherwise, all resources are pulled. """ print("Pulling conf/l...
[ "def", "pull", "(", "configuration", ",", "*", "resources", ")", ":", "print", "(", "\"Pulling conf/locale/config.yaml:locales from Transifex...\"", ")", "for", "lang", "in", "configuration", ".", "translated_locales", ":", "cmd", "=", "'tx pull -f --mode=reviewed --minim...
Pull translations from all languages listed in conf/locale/config.yaml where there is at least 10% reviewed translations. If arguments are provided, they are specific resources to pull. Otherwise, all resources are pulled.
[ "Pull", "translations", "from", "all", "languages", "listed", "in", "conf", "/", "locale", "/", "config", ".", "yaml", "where", "there", "is", "at", "least", "10%", "reviewed", "translations", "." ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L47-L65
edx/i18n-tools
i18n/transifex.py
pull_all_ltr
def pull_all_ltr(configuration): """ Pulls all translations - reviewed or not - for LTR languages """ print("Pulling all translated LTR languages from transifex...") for lang in configuration.ltr_langs: print('rm -rf conf/locale/' + lang) execute('rm -rf conf/locale/' + lang) ...
python
def pull_all_ltr(configuration): """ Pulls all translations - reviewed or not - for LTR languages """ print("Pulling all translated LTR languages from transifex...") for lang in configuration.ltr_langs: print('rm -rf conf/locale/' + lang) execute('rm -rf conf/locale/' + lang) ...
[ "def", "pull_all_ltr", "(", "configuration", ")", ":", "print", "(", "\"Pulling all translated LTR languages from transifex...\"", ")", "for", "lang", "in", "configuration", ".", "ltr_langs", ":", "print", "(", "'rm -rf conf/locale/'", "+", "lang", ")", "execute", "("...
Pulls all translations - reviewed or not - for LTR languages
[ "Pulls", "all", "translations", "-", "reviewed", "or", "not", "-", "for", "LTR", "languages" ]
train
https://github.com/edx/i18n-tools/blob/99b20c17d1a0ca07a8839f33e0e9068248a581e5/i18n/transifex.py#L79-L88