repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
smarie/python-autoclass
autoclass/autodict_.py
_execute_autodict_on_class
def _execute_autodict_on_class(object_type, # type: Type[T] include=None, # type: Union[str, Tuple[str]] exclude=None, # type: Union[str, Tuple[str]] only_constructor_args=True, # ...
python
def _execute_autodict_on_class(object_type, # type: Type[T] include=None, # type: Union[str, Tuple[str]] exclude=None, # type: Union[str, Tuple[str]] only_constructor_args=True, # ...
[ "def", "_execute_autodict_on_class", "(", "object_type", ",", "# type: Type[T]", "include", "=", "None", ",", "# type: Union[str, Tuple[str]]", "exclude", "=", "None", ",", "# type: Union[str, Tuple[str]]", "only_constructor_args", "=", "True", ",", "# type: bool", "only_pu...
This method makes objects of the class behave like a read-only `dict`. It does several things: * it adds collections.Mapping to the list of parent classes (i.e. to the class' `__bases__`) * it generates `__len__`, `__iter__` and `__getitem__` in order for the appropriate fields to be exposed in the dict vie...
[ "This", "method", "makes", "objects", "of", "the", "class", "behave", "like", "a", "read", "-", "only", "dict", ".", "It", "does", "several", "things", ":", "*", "it", "adds", "collections", ".", "Mapping", "to", "the", "list", "of", "parent", "classes",...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autodict_.py#L97-L549
smarie/python-autoclass
autoclass/autodict_.py
autodict_override_decorate
def autodict_override_decorate(func # type: Callable ): # type: (...) -> Callable """ Used to decorate a function as an overridden dictionary method (such as __iter__), without using the @autodict_override annotation. :param func: the function on which to execute. No...
python
def autodict_override_decorate(func # type: Callable ): # type: (...) -> Callable """ Used to decorate a function as an overridden dictionary method (such as __iter__), without using the @autodict_override annotation. :param func: the function on which to execute. No...
[ "def", "autodict_override_decorate", "(", "func", "# type: Callable", ")", ":", "# type: (...) -> Callable", "if", "func", ".", "__name__", "not", "in", "{", "Mapping", ".", "__iter__", ".", "__name__", ",", "Mapping", ".", "__getitem__", ".", "__name__", ",", "...
Used to decorate a function as an overridden dictionary method (such as __iter__), without using the @autodict_override annotation. :param func: the function on which to execute. Note that it won't be wrapped but simply annotated. :return:
[ "Used", "to", "decorate", "a", "function", "as", "an", "overridden", "dictionary", "method", "(", "such", "as", "__iter__", ")", "without", "using", "the", "@autodict_override", "annotation", "." ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autodict_.py#L560-L581
alexflint/process-isolation
process_isolation.py
map_values
def map_values(f, D): '''Map each value in the dictionary D to f(value).''' return { key:f(val) for key,val in D.iteritems() }
python
def map_values(f, D): '''Map each value in the dictionary D to f(value).''' return { key:f(val) for key,val in D.iteritems() }
[ "def", "map_values", "(", "f", ",", "D", ")", ":", "return", "{", "key", ":", "f", "(", "val", ")", "for", "key", ",", "val", "in", "D", ".", "iteritems", "(", ")", "}" ]
Map each value in the dictionary D to f(value).
[ "Map", "each", "value", "in", "the", "dictionary", "D", "to", "f", "(", "value", ")", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L62-L64
alexflint/process-isolation
process_isolation.py
raw_repr
def raw_repr(obj): '''Produce a representation using the default repr() regardless of whether the object provides an implementation of its own.''' if isproxy(obj): return '<%s with prime_id=%d>' % (obj.__class__.__name__, obj.prime_id) else: return repr(obj)
python
def raw_repr(obj): '''Produce a representation using the default repr() regardless of whether the object provides an implementation of its own.''' if isproxy(obj): return '<%s with prime_id=%d>' % (obj.__class__.__name__, obj.prime_id) else: return repr(obj)
[ "def", "raw_repr", "(", "obj", ")", ":", "if", "isproxy", "(", "obj", ")", ":", "return", "'<%s with prime_id=%d>'", "%", "(", "obj", ".", "__class__", ".", "__name__", ",", "obj", ".", "prime_id", ")", "else", ":", "return", "repr", "(", "obj", ")" ]
Produce a representation using the default repr() regardless of whether the object provides an implementation of its own.
[ "Produce", "a", "representation", "using", "the", "default", "repr", "()", "regardless", "of", "whether", "the", "object", "provides", "an", "implementation", "of", "its", "own", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L72-L78
alexflint/process-isolation
process_isolation.py
_load_module
def _load_module(module_name, path): '''A helper function invoked on the server to tell it to import a module.''' # TODO: handle the case that the module is already loaded try: # First try to find a non-builtin, non-frozen, non-special # module using the client's search path fd, file...
python
def _load_module(module_name, path): '''A helper function invoked on the server to tell it to import a module.''' # TODO: handle the case that the module is already loaded try: # First try to find a non-builtin, non-frozen, non-special # module using the client's search path fd, file...
[ "def", "_load_module", "(", "module_name", ",", "path", ")", ":", "# TODO: handle the case that the module is already loaded", "try", ":", "# First try to find a non-builtin, non-frozen, non-special", "# module using the client's search path", "fd", ",", "filename", ",", "info", ...
A helper function invoked on the server to tell it to import a module.
[ "A", "helper", "function", "invoked", "on", "the", "server", "to", "tell", "it", "to", "import", "a", "module", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L84-L101
alexflint/process-isolation
process_isolation.py
byvalue
def byvalue(proxy): '''Return a copy of the underlying object for which the argument is a proxy.''' assert isinstance(proxy, Proxy) return proxy.client.execute(ByValueDelegate(proxy))
python
def byvalue(proxy): '''Return a copy of the underlying object for which the argument is a proxy.''' assert isinstance(proxy, Proxy) return proxy.client.execute(ByValueDelegate(proxy))
[ "def", "byvalue", "(", "proxy", ")", ":", "assert", "isinstance", "(", "proxy", ",", "Proxy", ")", "return", "proxy", ".", "client", ".", "execute", "(", "ByValueDelegate", "(", "proxy", ")", ")" ]
Return a copy of the underlying object for which the argument is a proxy.
[ "Return", "a", "copy", "of", "the", "underlying", "object", "for", "which", "the", "argument", "is", "a", "proxy", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L103-L107
alexflint/process-isolation
process_isolation.py
import_isolated
def import_isolated(module_name, fromlist=[], level=-1, path=None): '''Import an module into an isolated context as if with "__import__('module_name')"''' sys.modules[module_name] = load_module(module_name, path=path) return __import__(module_name, fromlist=fromlist, level=level)
python
def import_isolated(module_name, fromlist=[], level=-1, path=None): '''Import an module into an isolated context as if with "__import__('module_name')"''' sys.modules[module_name] = load_module(module_name, path=path) return __import__(module_name, fromlist=fromlist, level=level)
[ "def", "import_isolated", "(", "module_name", ",", "fromlist", "=", "[", "]", ",", "level", "=", "-", "1", ",", "path", "=", "None", ")", ":", "sys", ".", "modules", "[", "module_name", "]", "=", "load_module", "(", "module_name", ",", "path", "=", "...
Import an module into an isolated context as if with "__import__('module_name')"
[ "Import", "an", "module", "into", "an", "isolated", "context", "as", "if", "with", "__import__", "(", "module_name", ")" ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L945-L949
alexflint/process-isolation
process_isolation.py
Client.state
def state(self, state): '''Change the state of the client. This is one of the values defined in ClientStates.''' logger.debug('client changing to state=%s', ClientState.Names[state]) self._state = state
python
def state(self, state): '''Change the state of the client. This is one of the values defined in ClientStates.''' logger.debug('client changing to state=%s', ClientState.Names[state]) self._state = state
[ "def", "state", "(", "self", ",", "state", ")", ":", "logger", ".", "debug", "(", "'client changing to state=%s'", ",", "ClientState", ".", "Names", "[", "state", "]", ")", "self", ".", "_state", "=", "state" ]
Change the state of the client. This is one of the values defined in ClientStates.
[ "Change", "the", "state", "of", "the", "client", ".", "This", "is", "one", "of", "the", "values", "defined", "in", "ClientStates", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L607-L611
alexflint/process-isolation
process_isolation.py
Client._read_result
def _read_result(self, num_retries): '''Read an object from a channel, possibly retrying if the attempt is interrupted by a signal from the operating system.''' for i in range(num_retries): self._assert_alive() try: return self._result_channel.get() ...
python
def _read_result(self, num_retries): '''Read an object from a channel, possibly retrying if the attempt is interrupted by a signal from the operating system.''' for i in range(num_retries): self._assert_alive() try: return self._result_channel.get() ...
[ "def", "_read_result", "(", "self", ",", "num_retries", ")", ":", "for", "i", "in", "range", "(", "num_retries", ")", ":", "self", ".", "_assert_alive", "(", ")", "try", ":", "return", "self", ".", "_result_channel", ".", "get", "(", ")", "except", "IO...
Read an object from a channel, possibly retrying if the attempt is interrupted by a signal from the operating system.
[ "Read", "an", "object", "from", "a", "channel", "possibly", "retrying", "if", "the", "attempt", "is", "interrupted", "by", "a", "signal", "from", "the", "operating", "system", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L697-L716
alexflint/process-isolation
process_isolation.py
Client.terminate
def terminate(self): '''Stop the server process and change our state to TERMINATING. Only valid if state=READY.''' logger.debug('client.terminate() called (state=%s)', self.strstate) if self.state == ClientState.WAITING_FOR_RESULT: raise ClientStateError('terimate() called while stat...
python
def terminate(self): '''Stop the server process and change our state to TERMINATING. Only valid if state=READY.''' logger.debug('client.terminate() called (state=%s)', self.strstate) if self.state == ClientState.WAITING_FOR_RESULT: raise ClientStateError('terimate() called while stat...
[ "def", "terminate", "(", "self", ")", ":", "logger", ".", "debug", "(", "'client.terminate() called (state=%s)'", ",", "self", ".", "strstate", ")", "if", "self", ".", "state", "==", "ClientState", ".", "WAITING_FOR_RESULT", ":", "raise", "ClientStateError", "("...
Stop the server process and change our state to TERMINATING. Only valid if state=READY.
[ "Stop", "the", "server", "process", "and", "change", "our", "state", "to", "TERMINATING", ".", "Only", "valid", "if", "state", "=", "READY", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L808-L839
alexflint/process-isolation
process_isolation.py
Client.cleanup
def cleanup(self): '''Terminate this client if it has not already terminated.''' if self.state == ClientState.WAITING_FOR_RESULT: # There is an ongoing call to execute() # Not sure what to do here logger.warn('cleanup() called while state is WAITING_FOR_RESULT: ignori...
python
def cleanup(self): '''Terminate this client if it has not already terminated.''' if self.state == ClientState.WAITING_FOR_RESULT: # There is an ongoing call to execute() # Not sure what to do here logger.warn('cleanup() called while state is WAITING_FOR_RESULT: ignori...
[ "def", "cleanup", "(", "self", ")", ":", "if", "self", ".", "state", "==", "ClientState", ".", "WAITING_FOR_RESULT", ":", "# There is an ongoing call to execute()", "# Not sure what to do here", "logger", ".", "warn", "(", "'cleanup() called while state is WAITING_FOR_RESUL...
Terminate this client if it has not already terminated.
[ "Terminate", "this", "client", "if", "it", "has", "not", "already", "terminated", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L841-L865
alexflint/process-isolation
process_isolation.py
IsolationContext.start
def start(self): '''Create a process in which the isolated code will be run.''' assert self._client is None logger.debug('IsolationContext[%d] starting', id(self)) # Create the queues request_queue = multiprocessing.Queue() response_queue = multiprocessing.Queue() ...
python
def start(self): '''Create a process in which the isolated code will be run.''' assert self._client is None logger.debug('IsolationContext[%d] starting', id(self)) # Create the queues request_queue = multiprocessing.Queue() response_queue = multiprocessing.Queue() ...
[ "def", "start", "(", "self", ")", ":", "assert", "self", ".", "_client", "is", "None", "logger", ".", "debug", "(", "'IsolationContext[%d] starting'", ",", "id", "(", "self", ")", ")", "# Create the queues", "request_queue", "=", "multiprocessing", ".", "Queue...
Create a process in which the isolated code will be run.
[ "Create", "a", "process", "in", "which", "the", "isolated", "code", "will", "be", "run", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L898-L914
alexflint/process-isolation
process_isolation.py
IsolationContext.load_module
def load_module(self, module_name, path=None): '''Import a module into this isolation context and return a proxy for it.''' self.ensure_started() if path is None: path = sys.path mod = self.client.call(_load_module, module_name, path) mod.__isolation_context__ = self ...
python
def load_module(self, module_name, path=None): '''Import a module into this isolation context and return a proxy for it.''' self.ensure_started() if path is None: path = sys.path mod = self.client.call(_load_module, module_name, path) mod.__isolation_context__ = self ...
[ "def", "load_module", "(", "self", ",", "module_name", ",", "path", "=", "None", ")", ":", "self", ".", "ensure_started", "(", ")", "if", "path", "is", "None", ":", "path", "=", "sys", ".", "path", "mod", "=", "self", ".", "client", ".", "call", "(...
Import a module into this isolation context and return a proxy for it.
[ "Import", "a", "module", "into", "this", "isolation", "context", "and", "return", "a", "proxy", "for", "it", "." ]
train
https://github.com/alexflint/process-isolation/blob/1b09862a5ed63be71049dfa8ad22f7c5fc75745c/process_isolation.py#L921-L928
smarie/python-autoclass
ci_tools/generate-junit-badge.py
download_badge
def download_badge(test_stats, # type: TestStats dest_folder='reports/junit' # type: str ): """ Downloads the badge corresponding to the provided success percentage, from https://img.shields.io. :param test_stats: :param dest_folder: :return: ...
python
def download_badge(test_stats, # type: TestStats dest_folder='reports/junit' # type: str ): """ Downloads the badge corresponding to the provided success percentage, from https://img.shields.io. :param test_stats: :param dest_folder: :return: ...
[ "def", "download_badge", "(", "test_stats", ",", "# type: TestStats", "dest_folder", "=", "'reports/junit'", "# type: str", ")", ":", "if", "not", "path", ".", "exists", "(", "dest_folder", ")", ":", "makedirs", "(", "dest_folder", ")", "# , exist_ok=True) not pytho...
Downloads the badge corresponding to the provided success percentage, from https://img.shields.io. :param test_stats: :param dest_folder: :return:
[ "Downloads", "the", "badge", "corresponding", "to", "the", "provided", "success", "percentage", "from", "https", ":", "//", "img", ".", "shields", ".", "io", "." ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/ci_tools/generate-junit-badge.py#L42-L76
smarie/python-autoclass
autoclass/autoprops_.py
autoprops
def autoprops(include=None, # type: Union[str, Tuple[str]] exclude=None, # type: Union[str, Tuple[str]] cls=DECORATED): """ A decorator to automatically generate all properties getters and setters from the class constructor. * if a @contract annotation exist on the __init__ met...
python
def autoprops(include=None, # type: Union[str, Tuple[str]] exclude=None, # type: Union[str, Tuple[str]] cls=DECORATED): """ A decorator to automatically generate all properties getters and setters from the class constructor. * if a @contract annotation exist on the __init__ met...
[ "def", "autoprops", "(", "include", "=", "None", ",", "# type: Union[str, Tuple[str]]", "exclude", "=", "None", ",", "# type: Union[str, Tuple[str]]", "cls", "=", "DECORATED", ")", ":", "return", "autoprops_decorate", "(", "cls", ",", "include", "=", "include", ",...
A decorator to automatically generate all properties getters and setters from the class constructor. * if a @contract annotation exist on the __init__ method, mentioning a contract for a given parameter, the parameter contract will be added on the generated setter method * The user may override the generate...
[ "A", "decorator", "to", "automatically", "generate", "all", "properties", "getters", "and", "setters", "from", "the", "class", "constructor", ".", "*", "if", "a", "@contract", "annotation", "exist", "on", "the", "__init__", "method", "mentioning", "a", "contract...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L46-L61
smarie/python-autoclass
autoclass/autoprops_.py
autoprops_decorate
def autoprops_decorate(cls, # type: Type[T] include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): # type: (...) -> Type[T] """ To automatically generate all properties getters and setters ...
python
def autoprops_decorate(cls, # type: Type[T] include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): # type: (...) -> Type[T] """ To automatically generate all properties getters and setters ...
[ "def", "autoprops_decorate", "(", "cls", ",", "# type: Type[T]", "include", "=", "None", ",", "# type: Union[str, Tuple[str]]", "exclude", "=", "None", "# type: Union[str, Tuple[str]]", ")", ":", "# type: (...) -> Type[T]", "# first check that we do not conflict with other known ...
To automatically generate all properties getters and setters from the class constructor manually, without using @autoprops decorator. * if a @contract annotation exist on the __init__ method, mentioning a contract for a given parameter, the parameter contract will be added on the generated setter method ...
[ "To", "automatically", "generate", "all", "properties", "getters", "and", "setters", "from", "the", "class", "constructor", "manually", "without", "using", "@autoprops", "decorator", ".", "*", "if", "a", "@contract", "annotation", "exist", "on", "the", "__init__",...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L64-L97
smarie/python-autoclass
autoclass/autoprops_.py
_execute_autoprops_on_class
def _execute_autoprops_on_class(object_type, # type: Type[T] include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): """ This method will automatically add one getter and one ...
python
def _execute_autoprops_on_class(object_type, # type: Type[T] include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): """ This method will automatically add one getter and one ...
[ "def", "_execute_autoprops_on_class", "(", "object_type", ",", "# type: Type[T]", "include", "=", "None", ",", "# type: Union[str, Tuple[str]]", "exclude", "=", "None", "# type: Union[str, Tuple[str]]", ")", ":", "# 0. first check parameters", "validate_include_exclude", "(", ...
This method will automatically add one getter and one setter for each constructor argument, except for those overridden using autoprops_override_decorate(), @getter_override or @setter_override. It will add a @contract on top of all setters (generated or overridden, if they don't already have one) :param o...
[ "This", "method", "will", "automatically", "add", "one", "getter", "and", "one", "setter", "for", "each", "constructor", "argument", "except", "for", "those", "overridden", "using", "autoprops_override_decorate", "()", "@getter_override", "or", "@setter_override", "."...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L100-L157
smarie/python-autoclass
autoclass/autoprops_.py
_add_property
def _add_property(object_type, # type: Type[T] parameter, # type: Parameter pycontract=None, # type: Any validators=None # type: Any ): """ A method to dynamically add a property to a class with the optional given pycontract ...
python
def _add_property(object_type, # type: Type[T] parameter, # type: Parameter pycontract=None, # type: Any validators=None # type: Any ): """ A method to dynamically add a property to a class with the optional given pycontract ...
[ "def", "_add_property", "(", "object_type", ",", "# type: Type[T]", "parameter", ",", "# type: Parameter", "pycontract", "=", "None", ",", "# type: Any", "validators", "=", "None", "# type: Any", ")", ":", "property_name", "=", "parameter", ".", "name", "# 1. create...
A method to dynamically add a property to a class with the optional given pycontract or validators. If the property getter and/or setter have been overridden, it is taken into account too. :param object_type: the class on which to execute. :param parameter: :param pycontract: :param validators: ...
[ "A", "method", "to", "dynamically", "add", "a", "property", "to", "a", "class", "with", "the", "optional", "given", "pycontract", "or", "validators", ".", "If", "the", "property", "getter", "and", "/", "or", "setter", "have", "been", "overridden", "it", "i...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L160-L215
smarie/python-autoclass
autoclass/autoprops_.py
_has_annotation
def _has_annotation(annotation, value): """ Returns a function that can be used as a predicate in get_members, that """ def matches_property_name(fun): """ return true if fun is a callable that has the correct annotation with value """ return callable(fun) and hasattr(fun, annotation) \ ...
python
def _has_annotation(annotation, value): """ Returns a function that can be used as a predicate in get_members, that """ def matches_property_name(fun): """ return true if fun is a callable that has the correct annotation with value """ return callable(fun) and hasattr(fun, annotation) \ ...
[ "def", "_has_annotation", "(", "annotation", ",", "value", ")", ":", "def", "matches_property_name", "(", "fun", ")", ":", "\"\"\" return true if fun is a callable that has the correct annotation with value \"\"\"", "return", "callable", "(", "fun", ")", "and", "hasattr", ...
Returns a function that can be used as a predicate in get_members, that
[ "Returns", "a", "function", "that", "can", "be", "used", "as", "a", "predicate", "in", "get_members", "that" ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L218-L225
smarie/python-autoclass
autoclass/autoprops_.py
_get_getter_fun
def _get_getter_fun(object_type, # type: Type parameter, # type: Parameter private_property_name # type: str ): """ Utility method to find the overridden getter function for a given property, or generate a new one :param obj...
python
def _get_getter_fun(object_type, # type: Type parameter, # type: Parameter private_property_name # type: str ): """ Utility method to find the overridden getter function for a given property, or generate a new one :param obj...
[ "def", "_get_getter_fun", "(", "object_type", ",", "# type: Type", "parameter", ",", "# type: Parameter", "private_property_name", "# type: str", ")", ":", "property_name", "=", "parameter", ".", "name", "# -- check overridden getter for this property name", "overridden_getters...
Utility method to find the overridden getter function for a given property, or generate a new one :param object_type: :param property_name: :param private_property_name: :return:
[ "Utility", "method", "to", "find", "the", "overridden", "getter", "function", "for", "a", "given", "property", "or", "generate", "a", "new", "one" ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L228-L278
smarie/python-autoclass
autoclass/autoprops_.py
_get_setter_fun
def _get_setter_fun(object_type, # type: Type parameter, # type: Parameter private_property_name # type: str ): """ Utility method to find the overridden setter function for a given property, or generate a new one :param obj...
python
def _get_setter_fun(object_type, # type: Type parameter, # type: Parameter private_property_name # type: str ): """ Utility method to find the overridden setter function for a given property, or generate a new one :param obj...
[ "def", "_get_setter_fun", "(", "object_type", ",", "# type: Type", "parameter", ",", "# type: Parameter", "private_property_name", "# type: str", ")", ":", "# the property will have the same name than the constructor argument", "property_name", "=", "parameter", ".", "name", "o...
Utility method to find the overridden setter function for a given property, or generate a new one :param object_type: :param property_name: :param property_type: :param private_property_name: :return:
[ "Utility", "method", "to", "find", "the", "overridden", "setter", "function", "for", "a", "given", "property", "or", "generate", "a", "new", "one" ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L281-L338
smarie/python-autoclass
autoclass/autoprops_.py
getter_override
def getter_override(attribute=None, # type: str f=DECORATED ): """ A decorator to indicate an overridden getter for a given attribute. If the attribute name is None, the function name will be used as the attribute name. :param attribute: the attribute name for w...
python
def getter_override(attribute=None, # type: str f=DECORATED ): """ A decorator to indicate an overridden getter for a given attribute. If the attribute name is None, the function name will be used as the attribute name. :param attribute: the attribute name for w...
[ "def", "getter_override", "(", "attribute", "=", "None", ",", "# type: str", "f", "=", "DECORATED", ")", ":", "return", "autoprops_override_decorate", "(", "f", ",", "attribute", "=", "attribute", ",", "is_getter", "=", "True", ")" ]
A decorator to indicate an overridden getter for a given attribute. If the attribute name is None, the function name will be used as the attribute name. :param attribute: the attribute name for which the decorated function is an overridden getter :return:
[ "A", "decorator", "to", "indicate", "an", "overridden", "getter", "for", "a", "given", "attribute", ".", "If", "the", "attribute", "name", "is", "None", "the", "function", "name", "will", "be", "used", "as", "the", "attribute", "name", "." ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L431-L441
smarie/python-autoclass
autoclass/autoprops_.py
setter_override
def setter_override(attribute=None, # type: str f=DECORATED ): """ A decorator to indicate an overridden setter for a given attribute. If the attribute name is None, the function name will be used as the attribute name. The @contract will still be dynamically added....
python
def setter_override(attribute=None, # type: str f=DECORATED ): """ A decorator to indicate an overridden setter for a given attribute. If the attribute name is None, the function name will be used as the attribute name. The @contract will still be dynamically added....
[ "def", "setter_override", "(", "attribute", "=", "None", ",", "# type: str", "f", "=", "DECORATED", ")", ":", "return", "autoprops_override_decorate", "(", "f", ",", "attribute", "=", "attribute", ",", "is_getter", "=", "False", ")" ]
A decorator to indicate an overridden setter for a given attribute. If the attribute name is None, the function name will be used as the attribute name. The @contract will still be dynamically added. :param attribute: the attribute name for which the decorated function is an overridden setter :return:
[ "A", "decorator", "to", "indicate", "an", "overridden", "setter", "for", "a", "given", "attribute", ".", "If", "the", "attribute", "name", "is", "None", "the", "function", "name", "will", "be", "used", "as", "the", "attribute", "name", ".", "The", "@contra...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L445-L455
smarie/python-autoclass
autoclass/autoprops_.py
autoprops_override_decorate
def autoprops_override_decorate(func, # type: Callable attribute=None, # type: str is_getter=True # type: bool ): # type: (...) -> Callable """ Used to decorate a function as an overridden getter or...
python
def autoprops_override_decorate(func, # type: Callable attribute=None, # type: str is_getter=True # type: bool ): # type: (...) -> Callable """ Used to decorate a function as an overridden getter or...
[ "def", "autoprops_override_decorate", "(", "func", ",", "# type: Callable", "attribute", "=", "None", ",", "# type: str", "is_getter", "=", "True", "# type: bool", ")", ":", "# type: (...) -> Callable", "# Simply annotate the fact that this is a function", "attr_name", "=", ...
Used to decorate a function as an overridden getter or setter, without using the @getter_override or @setter_override annotations. If the overridden setter has no @contract, the contract will still be dynamically added. Note: this should be executed BEFORE @autoprops or autoprops_decorate(). :param func: ...
[ "Used", "to", "decorate", "a", "function", "as", "an", "overridden", "getter", "or", "setter", "without", "using", "the", "@getter_override", "or", "@setter_override", "annotations", ".", "If", "the", "overridden", "setter", "has", "no", "@contract", "the", "con...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoprops_.py#L458-L489
smarie/python-autoclass
ci_tools/github_release.py
create_or_update_release
def create_or_update_release(user, pwd, secret, repo_slug, changelog_file, doc_url, data_file, tag): """ Creates or updates (TODO) a github release corresponding to git tag <TAG>. """ # 1- AUTHENTICATION if user is not None and secret is None: # using username and password # vali...
python
def create_or_update_release(user, pwd, secret, repo_slug, changelog_file, doc_url, data_file, tag): """ Creates or updates (TODO) a github release corresponding to git tag <TAG>. """ # 1- AUTHENTICATION if user is not None and secret is None: # using username and password # vali...
[ "def", "create_or_update_release", "(", "user", ",", "pwd", ",", "secret", ",", "repo_slug", ",", "changelog_file", ",", "doc_url", ",", "data_file", ",", "tag", ")", ":", "# 1- AUTHENTICATION", "if", "user", "is", "not", "None", "and", "secret", "is", "None...
Creates or updates (TODO) a github release corresponding to git tag <TAG>.
[ "Creates", "or", "updates", "(", "TODO", ")", "a", "github", "release", "corresponding", "to", "git", "tag", "<TAG", ">", "." ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/ci_tools/github_release.py#L23-L100
smarie/python-autoclass
autoclass/utils.py
validate_include_exclude
def validate_include_exclude(include, exclude): """ Common validator for include and exclude arguments :param include: :param exclude: :return: """ if include is not None and exclude is not None: raise ValueError("Only one of 'include' or 'exclude' argument should be provided.") ...
python
def validate_include_exclude(include, exclude): """ Common validator for include and exclude arguments :param include: :param exclude: :return: """ if include is not None and exclude is not None: raise ValueError("Only one of 'include' or 'exclude' argument should be provided.") ...
[ "def", "validate_include_exclude", "(", "include", ",", "exclude", ")", ":", "if", "include", "is", "not", "None", "and", "exclude", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Only one of 'include' or 'exclude' argument should be provided.\"", ")", "vali...
Common validator for include and exclude arguments :param include: :param exclude: :return:
[ "Common", "validator", "for", "include", "and", "exclude", "arguments", ":", "param", "include", ":", ":", "param", "exclude", ":", ":", "return", ":" ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/utils.py#L10-L20
smarie/python-autoclass
autoclass/utils.py
is_attr_selected
def is_attr_selected(attr_name, # type: str include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): """decide whether an action has to be performed on the attribute or not, based on its name""" if include ...
python
def is_attr_selected(attr_name, # type: str include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): """decide whether an action has to be performed on the attribute or not, based on its name""" if include ...
[ "def", "is_attr_selected", "(", "attr_name", ",", "# type: str", "include", "=", "None", ",", "# type: Union[str, Tuple[str]]", "exclude", "=", "None", "# type: Union[str, Tuple[str]]", ")", ":", "if", "include", "is", "not", "None", "and", "exclude", "is", "not", ...
decide whether an action has to be performed on the attribute or not, based on its name
[ "decide", "whether", "an", "action", "has", "to", "be", "performed", "on", "the", "attribute", "or", "not", "based", "on", "its", "name" ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/utils.py#L23-L43
smarie/python-autoclass
autoclass/utils.py
get_constructor
def get_constructor(typ, allow_inheritance=False # type: bool ): """ Utility method to return the unique constructor (__init__) of a type :param typ: a type :param allow_inheritance: if True, the constructor will be returned even if it is not defined in this cla...
python
def get_constructor(typ, allow_inheritance=False # type: bool ): """ Utility method to return the unique constructor (__init__) of a type :param typ: a type :param allow_inheritance: if True, the constructor will be returned even if it is not defined in this cla...
[ "def", "get_constructor", "(", "typ", ",", "allow_inheritance", "=", "False", "# type: bool", ")", ":", "if", "allow_inheritance", ":", "return", "typ", ".", "__init__", "else", ":", "# check that the constructor is really defined here", "if", "'__init__'", "in", "typ...
Utility method to return the unique constructor (__init__) of a type :param typ: a type :param allow_inheritance: if True, the constructor will be returned even if it is not defined in this class (inherited). By default this is set to False: an exception is raised when no constructor is explicitly defined ...
[ "Utility", "method", "to", "return", "the", "unique", "constructor", "(", "__init__", ")", "of", "a", "type" ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/utils.py#L46-L65
smarie/python-autoclass
autoclass/utils.py
_check_known_decorators
def _check_known_decorators(typ, calling_decorator # type: str ): # type: (...) -> bool """ Checks that a given type is not already decorated by known decorators that may cause trouble. If so, it raises an Exception :return: """ for member in typ.__dict__.values(...
python
def _check_known_decorators(typ, calling_decorator # type: str ): # type: (...) -> bool """ Checks that a given type is not already decorated by known decorators that may cause trouble. If so, it raises an Exception :return: """ for member in typ.__dict__.values(...
[ "def", "_check_known_decorators", "(", "typ", ",", "calling_decorator", "# type: str", ")", ":", "# type: (...) -> bool", "for", "member", "in", "typ", ".", "__dict__", ".", "values", "(", ")", ":", "if", "hasattr", "(", "member", ",", "'__enforcer__'", ")", "...
Checks that a given type is not already decorated by known decorators that may cause trouble. If so, it raises an Exception :return:
[ "Checks", "that", "a", "given", "type", "is", "not", "already", "decorated", "by", "known", "decorators", "that", "may", "cause", "trouble", ".", "If", "so", "it", "raises", "an", "Exception", ":", "return", ":" ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/utils.py#L72-L85
smarie/python-autoclass
autoclass/utils.py
method_already_there
def method_already_there(object_type, method_name, this_class_only=False): """ Returns True if method `method_name` is already implemented by object_type, that is, its implementation differs from the one in `object`. :param object_type: :param method_name: :param this_class_only: :return: ...
python
def method_already_there(object_type, method_name, this_class_only=False): """ Returns True if method `method_name` is already implemented by object_type, that is, its implementation differs from the one in `object`. :param object_type: :param method_name: :param this_class_only: :return: ...
[ "def", "method_already_there", "(", "object_type", ",", "method_name", ",", "this_class_only", "=", "False", ")", ":", "if", "this_class_only", ":", "return", "method_name", "in", "vars", "(", "object_type", ")", "# or object_type.__dict__", "else", ":", "try", ":...
Returns True if method `method_name` is already implemented by object_type, that is, its implementation differs from the one in `object`. :param object_type: :param method_name: :param this_class_only: :return:
[ "Returns", "True", "if", "method", "method_name", "is", "already", "implemented", "by", "object_type", "that", "is", "its", "implementation", "differs", "from", "the", "one", "in", "object", "." ]
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/utils.py#L88-L106
smarie/python-autoclass
autoclass/autoargs_.py
autoargs
def autoargs(include=None, # type: Union[str, Tuple[str]] exclude=None, # type: Union[str, Tuple[str]] f=DECORATED ): """ Defines a decorator with parameters, to automatically assign the inputs of a function to self PRIOR to executing the function. In other words: ...
python
def autoargs(include=None, # type: Union[str, Tuple[str]] exclude=None, # type: Union[str, Tuple[str]] f=DECORATED ): """ Defines a decorator with parameters, to automatically assign the inputs of a function to self PRIOR to executing the function. In other words: ...
[ "def", "autoargs", "(", "include", "=", "None", ",", "# type: Union[str, Tuple[str]]", "exclude", "=", "None", ",", "# type: Union[str, Tuple[str]]", "f", "=", "DECORATED", ")", ":", "return", "autoargs_decorate", "(", "f", ",", "include", "=", "include", ",", "...
Defines a decorator with parameters, to automatically assign the inputs of a function to self PRIOR to executing the function. In other words: ``` @autoargs def myfunc(a): print('hello') ``` will create the equivalent of ``` def myfunc(a): self.a = a ...
[ "Defines", "a", "decorator", "with", "parameters", "to", "automatically", "assign", "the", "inputs", "of", "a", "function", "to", "self", "PRIOR", "to", "executing", "the", "function", ".", "In", "other", "words", ":", "@autoargs", "def", "myfunc", "(", "a",...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoargs_.py#L22-L51
smarie/python-autoclass
autoclass/autoargs_.py
autoargs_decorate
def autoargs_decorate(func, # type: Callable include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): # type: (...) -> Callable """ Defines a decorator with parameters, to automatically assign th...
python
def autoargs_decorate(func, # type: Callable include=None, # type: Union[str, Tuple[str]] exclude=None # type: Union[str, Tuple[str]] ): # type: (...) -> Callable """ Defines a decorator with parameters, to automatically assign th...
[ "def", "autoargs_decorate", "(", "func", ",", "# type: Callable", "include", "=", "None", ",", "# type: Union[str, Tuple[str]]", "exclude", "=", "None", "# type: Union[str, Tuple[str]]", ")", ":", "# type: (...) -> Callable", "# (0) first check parameters", "validate_include_ex...
Defines a decorator with parameters, to automatically assign the inputs of a function to self PRIOR to executing the function. This is the inline way to apply the decorator ``` myfunc2 = autoargs_decorate(myfunc) ``` See autoargs for details. :param func: the function to wrap ...
[ "Defines", "a", "decorator", "with", "parameters", "to", "automatically", "assign", "the", "inputs", "of", "a", "function", "to", "self", "PRIOR", "to", "executing", "the", "function", ".", "This", "is", "the", "inline", "way", "to", "apply", "the", "decorat...
train
https://github.com/smarie/python-autoclass/blob/097098776c69ebc87bc1aeda6997431b29bd583a/autoclass/autoargs_.py#L54-L140
planetarypy/pvl
pvl/_collections.py
OrderedMultiDict.append
def append(self, key, value): """Adds a (name, value) pair, doesn't overwrite the value if it already exists.""" self.__items.append((key, value)) try: dict_getitem(self, key).append(value) except KeyError: dict_setitem(self, key, [value])
python
def append(self, key, value): """Adds a (name, value) pair, doesn't overwrite the value if it already exists.""" self.__items.append((key, value)) try: dict_getitem(self, key).append(value) except KeyError: dict_setitem(self, key, [value])
[ "def", "append", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "__items", ".", "append", "(", "(", "key", ",", "value", ")", ")", "try", ":", "dict_getitem", "(", "self", ",", "key", ")", ".", "append", "(", "value", ")", "except"...
Adds a (name, value) pair, doesn't overwrite the value if it already exists.
[ "Adds", "a", "(", "name", "value", ")", "pair", "doesn", "t", "overwrite", "the", "value", "if", "it", "already", "exists", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/_collections.py#L211-L219
planetarypy/pvl
pvl/_collections.py
OrderedMultiDict.extend
def extend(self, *args, **kwargs): """Add key value pairs for an iterable.""" if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) iterable = args[0] if args else None if iterable: if isinstance(iterable, Mapping) or hasattr(itera...
python
def extend(self, *args, **kwargs): """Add key value pairs for an iterable.""" if len(args) > 1: raise TypeError('expected at most 1 arguments, got %d' % len(args)) iterable = args[0] if args else None if iterable: if isinstance(iterable, Mapping) or hasattr(itera...
[ "def", "extend", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "1", ":", "raise", "TypeError", "(", "'expected at most 1 arguments, got %d'", "%", "len", "(", "args", ")", ")", "iterable", "=", ...
Add key value pairs for an iterable.
[ "Add", "key", "value", "pairs", "for", "an", "iterable", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/_collections.py#L221-L239
planetarypy/pvl
pvl/_collections.py
OrderedMultiDict.__insert_wrapper
def __insert_wrapper(func): """Make sure the arguments given to the insert methods are correct""" def check_func(self, key, new_item, instance=0): if key not in self.keys(): raise KeyError("%s not a key in label" % (key)) if not isinstance(new_item, (list, Ordered...
python
def __insert_wrapper(func): """Make sure the arguments given to the insert methods are correct""" def check_func(self, key, new_item, instance=0): if key not in self.keys(): raise KeyError("%s not a key in label" % (key)) if not isinstance(new_item, (list, Ordered...
[ "def", "__insert_wrapper", "(", "func", ")", ":", "def", "check_func", "(", "self", ",", "key", ",", "new_item", ",", "instance", "=", "0", ")", ":", "if", "key", "not", "in", "self", ".", "keys", "(", ")", ":", "raise", "KeyError", "(", "\"%s not a ...
Make sure the arguments given to the insert methods are correct
[ "Make", "sure", "the", "arguments", "given", "to", "the", "insert", "methods", "are", "correct" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/_collections.py#L265-L275
planetarypy/pvl
pvl/_collections.py
OrderedMultiDict._get_index_for_insert
def _get_index_for_insert(self, key, instance): """Get the index of the key to insert before or after""" if instance == 0: # Index method will return the first occurence of the key index = self.keys().index(key) else: occurrence = -1 for index, k i...
python
def _get_index_for_insert(self, key, instance): """Get the index of the key to insert before or after""" if instance == 0: # Index method will return the first occurence of the key index = self.keys().index(key) else: occurrence = -1 for index, k i...
[ "def", "_get_index_for_insert", "(", "self", ",", "key", ",", "instance", ")", ":", "if", "instance", "==", "0", ":", "# Index method will return the first occurence of the key", "index", "=", "self", ".", "keys", "(", ")", ".", "index", "(", "key", ")", "else...
Get the index of the key to insert before or after
[ "Get", "the", "index", "of", "the", "key", "to", "insert", "before", "or", "after" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/_collections.py#L277-L301
planetarypy/pvl
pvl/_collections.py
OrderedMultiDict._insert_item
def _insert_item(self, key, new_item, instance, is_after): """Insert a new item before or after another item""" index = self._get_index_for_insert(key, instance) index = index + 1 if is_after else index self.__items = self.__items[:index] + new_item + self.__items[index:] # Make ...
python
def _insert_item(self, key, new_item, instance, is_after): """Insert a new item before or after another item""" index = self._get_index_for_insert(key, instance) index = index + 1 if is_after else index self.__items = self.__items[:index] + new_item + self.__items[index:] # Make ...
[ "def", "_insert_item", "(", "self", ",", "key", ",", "new_item", ",", "instance", ",", "is_after", ")", ":", "index", "=", "self", ".", "_get_index_for_insert", "(", "key", ",", "instance", ")", "index", "=", "index", "+", "1", "if", "is_after", "else", ...
Insert a new item before or after another item
[ "Insert", "a", "new", "item", "before", "or", "after", "another", "item" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/_collections.py#L303-L314
planetarypy/pvl
pvl/_collections.py
OrderedMultiDict.insert_after
def insert_after(self, key, new_item, instance=0): """Insert an item after a key""" self._insert_item(key, new_item, instance, True)
python
def insert_after(self, key, new_item, instance=0): """Insert an item after a key""" self._insert_item(key, new_item, instance, True)
[ "def", "insert_after", "(", "self", ",", "key", ",", "new_item", ",", "instance", "=", "0", ")", ":", "self", ".", "_insert_item", "(", "key", ",", "new_item", ",", "instance", ",", "True", ")" ]
Insert an item after a key
[ "Insert", "an", "item", "after", "a", "key" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/_collections.py#L317-L319
planetarypy/pvl
pvl/_collections.py
OrderedMultiDict.insert_before
def insert_before(self, key, new_item, instance=0): """Insert an item before a key""" self._insert_item(key, new_item, instance, False)
python
def insert_before(self, key, new_item, instance=0): """Insert an item before a key""" self._insert_item(key, new_item, instance, False)
[ "def", "insert_before", "(", "self", ",", "key", ",", "new_item", ",", "instance", "=", "0", ")", ":", "self", ".", "_insert_item", "(", "key", ",", "new_item", ",", "instance", ",", "False", ")" ]
Insert an item before a key
[ "Insert", "an", "item", "before", "a", "key" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/_collections.py#L322-L324
planetarypy/pvl
pvl/stream.py
BufferedStream.read
def read(self, n): """Read n bytes. Returns exactly n bytes of data unless the underlying raw IO stream reaches EOF. """ buf = self._read_buf pos = self._read_pos end = pos + n if end <= len(buf): # Fast path: the data to read is fully buffere...
python
def read(self, n): """Read n bytes. Returns exactly n bytes of data unless the underlying raw IO stream reaches EOF. """ buf = self._read_buf pos = self._read_pos end = pos + n if end <= len(buf): # Fast path: the data to read is fully buffere...
[ "def", "read", "(", "self", ",", "n", ")", ":", "buf", "=", "self", ".", "_read_buf", "pos", "=", "self", ".", "_read_pos", "end", "=", "pos", "+", "n", "if", "end", "<=", "len", "(", "buf", ")", ":", "# Fast path: the data to read is fully buffered.", ...
Read n bytes. Returns exactly n bytes of data unless the underlying raw IO stream reaches EOF.
[ "Read", "n", "bytes", ".", "Returns", "exactly", "n", "bytes", "of", "data", "unless", "the", "underlying", "raw", "IO", "stream", "reaches", "EOF", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/stream.py#L45-L70
planetarypy/pvl
pvl/stream.py
ByteStream.read
def read(self, n): """Read n bytes. Returns exactly n bytes of data unless the underlying raw IO stream reaches EOF. """ pos = self._read_pos self._read_pos = min(len(self.raw), pos + n) return self.raw[pos:self._read_pos]
python
def read(self, n): """Read n bytes. Returns exactly n bytes of data unless the underlying raw IO stream reaches EOF. """ pos = self._read_pos self._read_pos = min(len(self.raw), pos + n) return self.raw[pos:self._read_pos]
[ "def", "read", "(", "self", ",", "n", ")", ":", "pos", "=", "self", ".", "_read_pos", "self", ".", "_read_pos", "=", "min", "(", "len", "(", "self", ".", "raw", ")", ",", "pos", "+", "n", ")", "return", "self", ".", "raw", "[", "pos", ":", "s...
Read n bytes. Returns exactly n bytes of data unless the underlying raw IO stream reaches EOF.
[ "Read", "n", "bytes", ".", "Returns", "exactly", "n", "bytes", "of", "data", "unless", "the", "underlying", "raw", "IO", "stream", "reaches", "EOF", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/stream.py#L117-L124
planetarypy/pvl
pvl/stream.py
ByteStream.peek
def peek(self, n): """Returns buffered bytes without advancing the position. The argument indicates a desired minimal number of bytes; we do at most one raw read to satisfy it. We never return more than self.buffer_size. """ pos = self._read_pos end = pos + n ...
python
def peek(self, n): """Returns buffered bytes without advancing the position. The argument indicates a desired minimal number of bytes; we do at most one raw read to satisfy it. We never return more than self.buffer_size. """ pos = self._read_pos end = pos + n ...
[ "def", "peek", "(", "self", ",", "n", ")", ":", "pos", "=", "self", ".", "_read_pos", "end", "=", "pos", "+", "n", "return", "self", ".", "raw", "[", "pos", ":", "end", "]" ]
Returns buffered bytes without advancing the position. The argument indicates a desired minimal number of bytes; we do at most one raw read to satisfy it. We never return more than self.buffer_size.
[ "Returns", "buffered", "bytes", "without", "advancing", "the", "position", ".", "The", "argument", "indicates", "a", "desired", "minimal", "number", "of", "bytes", ";", "we", "do", "at", "most", "one", "raw", "read", "to", "satisfy", "it", ".", "We", "neve...
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/stream.py#L126-L134
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_block
def parse_block(self, stream, has_end): """ PVLModuleContents ::= (Statement | WSC)* EndStatement? AggrObject ::= BeginObjectStmt AggrContents EndObjectStmt AggrGroup ::= BeginGroupStmt AggrContents EndGroupStmt AggrContents := WSC Statement (WSC | Statement)* """ ...
python
def parse_block(self, stream, has_end): """ PVLModuleContents ::= (Statement | WSC)* EndStatement? AggrObject ::= BeginObjectStmt AggrContents EndObjectStmt AggrGroup ::= BeginGroupStmt AggrContents EndGroupStmt AggrContents := WSC Statement (WSC | Statement)* """ ...
[ "def", "parse_block", "(", "self", ",", "stream", ",", "has_end", ")", ":", "statements", "=", "[", "]", "while", "1", ":", "self", ".", "skip_whitespace_or_comment", "(", "stream", ")", "if", "has_end", "(", "stream", ")", ":", "return", "statements", "...
PVLModuleContents ::= (Statement | WSC)* EndStatement? AggrObject ::= BeginObjectStmt AggrContents EndObjectStmt AggrGroup ::= BeginGroupStmt AggrContents EndGroupStmt AggrContents := WSC Statement (WSC | Statement)*
[ "PVLModuleContents", "::", "=", "(", "Statement", "|", "WSC", ")", "*", "EndStatement?", "AggrObject", "::", "=", "BeginObjectStmt", "AggrContents", "EndObjectStmt", "AggrGroup", "::", "=", "BeginGroupStmt", "AggrContents", "EndGroupStmt", "AggrContents", ":", "=", ...
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L235-L264
planetarypy/pvl
pvl/decoder.py
PVLDecoder.skip_statement_delimiter
def skip_statement_delimiter(self, stream): """Ensure that a Statement Delimiter consists of one semicolon, optionally preceded by multiple White Spaces and/or Comments, OR one or more Comments and/or White Space sequences. StatementDelim ::= WSC (SemiColon | WhiteSpace | Comment) ...
python
def skip_statement_delimiter(self, stream): """Ensure that a Statement Delimiter consists of one semicolon, optionally preceded by multiple White Spaces and/or Comments, OR one or more Comments and/or White Space sequences. StatementDelim ::= WSC (SemiColon | WhiteSpace | Comment) ...
[ "def", "skip_statement_delimiter", "(", "self", ",", "stream", ")", ":", "self", ".", "skip_whitespace_or_comment", "(", "stream", ")", "self", ".", "optional", "(", "stream", ",", "self", ".", "statement_delimiter", ")" ]
Ensure that a Statement Delimiter consists of one semicolon, optionally preceded by multiple White Spaces and/or Comments, OR one or more Comments and/or White Space sequences. StatementDelim ::= WSC (SemiColon | WhiteSpace | Comment) | EndProvidedOctetSeq
[ "Ensure", "that", "a", "Statement", "Delimiter", "consists", "of", "one", "semicolon", "optionally", "preceded", "by", "multiple", "White", "Spaces", "and", "/", "or", "Comments", "OR", "one", "or", "more", "Comments", "and", "/", "or", "White", "Space", "se...
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L278-L288
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_statement
def parse_statement(self, stream): """ Statement ::= AggrGroup | AggrObject | AssignmentStmt """ if self.has_group(stream): return self.parse_group(stream) if self.has_object(stream): return self.parse_object(strea...
python
def parse_statement(self, stream): """ Statement ::= AggrGroup | AggrObject | AssignmentStmt """ if self.has_group(stream): return self.parse_group(stream) if self.has_object(stream): return self.parse_object(strea...
[ "def", "parse_statement", "(", "self", ",", "stream", ")", ":", "if", "self", ".", "has_group", "(", "stream", ")", ":", "return", "self", ".", "parse_group", "(", "stream", ")", "if", "self", ".", "has_object", "(", "stream", ")", ":", "return", "self...
Statement ::= AggrGroup | AggrObject | AssignmentStmt
[ "Statement", "::", "=", "AggrGroup", "|", "AggrObject", "|", "AssignmentStmt" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L290-L309
planetarypy/pvl
pvl/decoder.py
PVLDecoder.has_end
def has_end(self, stream): """ EndStatement ::= EndKeyword (SemiColon | WhiteSpace | Comment | EndProvidedOctetSeq) """ for token in self.end_tokens: if not self.has_next(token, stream): continue offset = len(token) if sel...
python
def has_end(self, stream): """ EndStatement ::= EndKeyword (SemiColon | WhiteSpace | Comment | EndProvidedOctetSeq) """ for token in self.end_tokens: if not self.has_next(token, stream): continue offset = len(token) if sel...
[ "def", "has_end", "(", "self", ",", "stream", ")", ":", "for", "token", "in", "self", ".", "end_tokens", ":", "if", "not", "self", ".", "has_next", "(", "token", ",", "stream", ")", ":", "continue", "offset", "=", "len", "(", "token", ")", "if", "s...
EndStatement ::= EndKeyword (SemiColon | WhiteSpace | Comment | EndProvidedOctetSeq)
[ "EndStatement", "::", "=", "EndKeyword", "(", "SemiColon", "|", "WhiteSpace", "|", "Comment", "|", "EndProvidedOctetSeq", ")" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L352-L375
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_group
def parse_group(self, stream): """Block Name must match Block Name in paired End Group Statement if Block Name is present in End Group Statement. BeginGroupStmt ::= BeginGroupKeywd WSC AssignmentSymbol WSC BlockName StatementDelim """ self.expect_in(stream, self.begi...
python
def parse_group(self, stream): """Block Name must match Block Name in paired End Group Statement if Block Name is present in End Group Statement. BeginGroupStmt ::= BeginGroupKeywd WSC AssignmentSymbol WSC BlockName StatementDelim """ self.expect_in(stream, self.begi...
[ "def", "parse_group", "(", "self", ",", "stream", ")", ":", "self", ".", "expect_in", "(", "stream", ",", "self", ".", "begin_group_tokens", ")", "self", ".", "ensure_assignment", "(", "stream", ")", "name", "=", "self", ".", "next_token", "(", "stream", ...
Block Name must match Block Name in paired End Group Statement if Block Name is present in End Group Statement. BeginGroupStmt ::= BeginGroupKeywd WSC AssignmentSymbol WSC BlockName StatementDelim
[ "Block", "Name", "must", "match", "Block", "Name", "in", "paired", "End", "Group", "Statement", "if", "Block", "Name", "is", "present", "in", "End", "Group", "Statement", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L402-L421
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_object
def parse_object(self, stream): """Block Name must match Block Name in paired End Object Statement if Block Name is present in End Object Statement StatementDelim. BeginObjectStmt ::= BeginObjectKeywd WSC AssignmentSymbol WSC BlockName StatementDelim """ self.expect_...
python
def parse_object(self, stream): """Block Name must match Block Name in paired End Object Statement if Block Name is present in End Object Statement StatementDelim. BeginObjectStmt ::= BeginObjectKeywd WSC AssignmentSymbol WSC BlockName StatementDelim """ self.expect_...
[ "def", "parse_object", "(", "self", ",", "stream", ")", ":", "self", ".", "expect_in", "(", "stream", ",", "self", ".", "begin_object_tokens", ")", "self", ".", "ensure_assignment", "(", "stream", ")", "name", "=", "self", ".", "next_token", "(", "stream",...
Block Name must match Block Name in paired End Object Statement if Block Name is present in End Object Statement StatementDelim. BeginObjectStmt ::= BeginObjectKeywd WSC AssignmentSymbol WSC BlockName StatementDelim
[ "Block", "Name", "must", "match", "Block", "Name", "in", "paired", "End", "Object", "Statement", "if", "Block", "Name", "is", "present", "in", "End", "Object", "Statement", "StatementDelim", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L433-L452
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_assignment
def parse_assignment(self, stream): """ AssignmentStmt ::= Name WSC AssignmentSymbol WSC Value StatementDelim """ lineno = stream.lineno name = self.next_token(stream) self.ensure_assignment(stream) at_an_end = any(( self.has_end_group(stream), ...
python
def parse_assignment(self, stream): """ AssignmentStmt ::= Name WSC AssignmentSymbol WSC Value StatementDelim """ lineno = stream.lineno name = self.next_token(stream) self.ensure_assignment(stream) at_an_end = any(( self.has_end_group(stream), ...
[ "def", "parse_assignment", "(", "self", ",", "stream", ")", ":", "lineno", "=", "stream", ".", "lineno", "name", "=", "self", ".", "next_token", "(", "stream", ")", "self", ".", "ensure_assignment", "(", "stream", ")", "at_an_end", "=", "any", "(", "(", ...
AssignmentStmt ::= Name WSC AssignmentSymbol WSC Value StatementDelim
[ "AssignmentStmt", "::", "=", "Name", "WSC", "AssignmentSymbol", "WSC", "Value", "StatementDelim" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L469-L487
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_value
def parse_value(self, stream): """ Value ::= (SimpleValue | Set | Sequence) WSC UnitsExpression? """ if self.has_sequence(stream): value = self.parse_sequence(stream) elif self.has_set(stream): value = self.parse_set(stream) else: value...
python
def parse_value(self, stream): """ Value ::= (SimpleValue | Set | Sequence) WSC UnitsExpression? """ if self.has_sequence(stream): value = self.parse_sequence(stream) elif self.has_set(stream): value = self.parse_set(stream) else: value...
[ "def", "parse_value", "(", "self", ",", "stream", ")", ":", "if", "self", ".", "has_sequence", "(", "stream", ")", ":", "value", "=", "self", ".", "parse_sequence", "(", "stream", ")", "elif", "self", ".", "has_set", "(", "stream", ")", ":", "value", ...
Value ::= (SimpleValue | Set | Sequence) WSC UnitsExpression?
[ "Value", "::", "=", "(", "SimpleValue", "|", "Set", "|", "Sequence", ")", "WSC", "UnitsExpression?" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L489-L505
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_iterable
def parse_iterable(self, stream, start, end): """ Sequence ::= SequenceStart WSC SequenceValue? WSC SequenceEnd Set := SetStart WSC SequenceValue? WSC SetEnd SequenceValue ::= Value (WSC SeparatorSymbol WSC Value)* """ values = [] self.expect(stream, start) ...
python
def parse_iterable(self, stream, start, end): """ Sequence ::= SequenceStart WSC SequenceValue? WSC SequenceEnd Set := SetStart WSC SequenceValue? WSC SetEnd SequenceValue ::= Value (WSC SeparatorSymbol WSC Value)* """ values = [] self.expect(stream, start) ...
[ "def", "parse_iterable", "(", "self", ",", "stream", ",", "start", ",", "end", ")", ":", "values", "=", "[", "]", "self", ".", "expect", "(", "stream", ",", "start", ")", "self", ".", "skip_whitespace_or_comment", "(", "stream", ")", "if", "self", ".",...
Sequence ::= SequenceStart WSC SequenceValue? WSC SequenceEnd Set := SetStart WSC SequenceValue? WSC SetEnd SequenceValue ::= Value (WSC SeparatorSymbol WSC Value)*
[ "Sequence", "::", "=", "SequenceStart", "WSC", "SequenceValue?", "WSC", "SequenceEnd", "Set", ":", "=", "SetStart", "WSC", "SequenceValue?", "WSC", "SetEnd", "SequenceValue", "::", "=", "Value", "(", "WSC", "SeparatorSymbol", "WSC", "Value", ")", "*" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L507-L531
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_units
def parse_units(self, stream): """ UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd """ value = b'' self.expect(stream, self.begin_units) while not self.has_next(self.end_units, stream): if self.has_eof(stream): ...
python
def parse_units(self, stream): """ UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd """ value = b'' self.expect(stream, self.begin_units) while not self.has_next(self.end_units, stream): if self.has_eof(stream): ...
[ "def", "parse_units", "(", "self", ",", "stream", ")", ":", "value", "=", "b''", "self", ".", "expect", "(", "stream", ",", "self", ".", "begin_units", ")", "while", "not", "self", ".", "has_next", "(", "self", ".", "end_units", ",", "stream", ")", "...
UnitsExpression ::= UnitsStart WhiteSpace* UnitsValue WhiteSpace* UnitsEnd
[ "UnitsExpression", "::", "=", "UnitsStart", "WhiteSpace", "*", "UnitsValue", "WhiteSpace", "*", "UnitsEnd" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L552-L566
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_simple_value
def parse_simple_value(self, stream): """ SimpleValue ::= Integer | FloatingPoint | Exponential | BinaryNum | OctalNum | HexadecimalNum | DateTimeValue ...
python
def parse_simple_value(self, stream): """ SimpleValue ::= Integer | FloatingPoint | Exponential | BinaryNum | OctalNum | HexadecimalNum | DateTimeValue ...
[ "def", "parse_simple_value", "(", "self", ",", "stream", ")", ":", "if", "self", ".", "has_quoted_string", "(", "stream", ")", ":", "return", "self", ".", "parse_quoted_string", "(", "stream", ")", "if", "self", ".", "has_binary_number", "(", "stream", ")", ...
SimpleValue ::= Integer | FloatingPoint | Exponential | BinaryNum | OctalNum | HexadecimalNum | DateTimeValue | QuotedString | UnquotedString
[ "SimpleValue", "::", "=", "Integer", "|", "FloatingPoint", "|", "Exponential", "|", "BinaryNum", "|", "OctalNum", "|", "HexadecimalNum", "|", "DateTimeValue", "|", "QuotedString", "|", "UnquotedString" ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L568-L601
planetarypy/pvl
pvl/decoder.py
PVLDecoder.parse_radix
def parse_radix(self, radix, chars, stream): """ BinaryNum ::= [+-]? '2' RadixSymbol [0-1]+ RadixSymbol OctalChar ::= [+-]? '8' RadixSymbol [0-7]+ RadixSymbol HexadecimalNum ::= [+-]? '16' RadixSymbol [0-9a-zA-Z]+ RadixSymbol """ value = b'' sign = self.parse_sign...
python
def parse_radix(self, radix, chars, stream): """ BinaryNum ::= [+-]? '2' RadixSymbol [0-1]+ RadixSymbol OctalChar ::= [+-]? '8' RadixSymbol [0-7]+ RadixSymbol HexadecimalNum ::= [+-]? '16' RadixSymbol [0-9a-zA-Z]+ RadixSymbol """ value = b'' sign = self.parse_sign...
[ "def", "parse_radix", "(", "self", ",", "radix", ",", "chars", ",", "stream", ")", ":", "value", "=", "b''", "sign", "=", "self", ".", "parse_sign", "(", "stream", ")", "self", ".", "expect", "(", "stream", ",", "b", "(", "str", "(", "radix", ")", ...
BinaryNum ::= [+-]? '2' RadixSymbol [0-1]+ RadixSymbol OctalChar ::= [+-]? '8' RadixSymbol [0-7]+ RadixSymbol HexadecimalNum ::= [+-]? '16' RadixSymbol [0-9a-zA-Z]+ RadixSymbol
[ "BinaryNum", "::", "=", "[", "+", "-", "]", "?", "2", "RadixSymbol", "[", "0", "-", "1", "]", "+", "RadixSymbol", "OctalChar", "::", "=", "[", "+", "-", "]", "?", "8", "RadixSymbol", "[", "0", "-", "7", "]", "+", "RadixSymbol", "HexadecimalNum", ...
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/decoder.py#L625-L650
BetterWorks/django-anonymizer
anonymizer/base.py
DjangoFaker.varchar
def varchar(self, field=None): """ Returns a chunk of text, of maximum length 'max_length' """ assert field is not None, "The field parameter must be passed to the 'varchar' method." max_length = field.max_length def source(): length = random.choice(range(1, ...
python
def varchar(self, field=None): """ Returns a chunk of text, of maximum length 'max_length' """ assert field is not None, "The field parameter must be passed to the 'varchar' method." max_length = field.max_length def source(): length = random.choice(range(1, ...
[ "def", "varchar", "(", "self", ",", "field", "=", "None", ")", ":", "assert", "field", "is", "not", "None", ",", "\"The field parameter must be passed to the 'varchar' method.\"", "max_length", "=", "field", ".", "max_length", "def", "source", "(", ")", ":", "le...
Returns a chunk of text, of maximum length 'max_length'
[ "Returns", "a", "chunk", "of", "text", "of", "maximum", "length", "max_length" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L80-L90
BetterWorks/django-anonymizer
anonymizer/base.py
DjangoFaker.simple_pattern
def simple_pattern(self, pattern, field=None): """ Use a simple pattern to make the field - # is replaced with a random number, ? with a random letter. """ return self.get_allowed_value(lambda: self.faker.bothify(pattern), field)
python
def simple_pattern(self, pattern, field=None): """ Use a simple pattern to make the field - # is replaced with a random number, ? with a random letter. """ return self.get_allowed_value(lambda: self.faker.bothify(pattern), field)
[ "def", "simple_pattern", "(", "self", ",", "pattern", ",", "field", "=", "None", ")", ":", "return", "self", ".", "get_allowed_value", "(", "lambda", ":", "self", ".", "faker", ".", "bothify", "(", "pattern", ")", ",", "field", ")" ]
Use a simple pattern to make the field - # is replaced with a random number, ? with a random letter.
[ "Use", "a", "simple", "pattern", "to", "make", "the", "field", "-", "#", "is", "replaced", "with", "a", "random", "number", "?", "with", "a", "random", "letter", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L92-L97
BetterWorks/django-anonymizer
anonymizer/base.py
DjangoFaker.datetime
def datetime(self, field=None, val=None): """ Returns a random datetime. If 'val' is passed, a datetime within two years of that date will be returned. """ if val is None: def source(): tzinfo = get_default_timezone() if settings.USE_TZ else None ...
python
def datetime(self, field=None, val=None): """ Returns a random datetime. If 'val' is passed, a datetime within two years of that date will be returned. """ if val is None: def source(): tzinfo = get_default_timezone() if settings.USE_TZ else None ...
[ "def", "datetime", "(", "self", ",", "field", "=", "None", ",", "val", "=", "None", ")", ":", "if", "val", "is", "None", ":", "def", "source", "(", ")", ":", "tzinfo", "=", "get_default_timezone", "(", ")", "if", "settings", ".", "USE_TZ", "else", ...
Returns a random datetime. If 'val' is passed, a datetime within two years of that date will be returned.
[ "Returns", "a", "random", "datetime", ".", "If", "val", "is", "passed", "a", "datetime", "within", "two", "years", "of", "that", "date", "will", "be", "returned", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L117-L133
BetterWorks/django-anonymizer
anonymizer/base.py
DjangoFaker.date
def date(self, field=None, val=None): """ Like datetime, but truncated to be a date only """ return self.datetime(field=field, val=val).date()
python
def date(self, field=None, val=None): """ Like datetime, but truncated to be a date only """ return self.datetime(field=field, val=val).date()
[ "def", "date", "(", "self", ",", "field", "=", "None", ",", "val", "=", "None", ")", ":", "return", "self", ".", "datetime", "(", "field", "=", "field", ",", "val", "=", "val", ")", ".", "date", "(", ")" ]
Like datetime, but truncated to be a date only
[ "Like", "datetime", "but", "truncated", "to", "be", "a", "date", "only" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L135-L139
BetterWorks/django-anonymizer
anonymizer/base.py
DjangoFaker.lorem
def lorem(self, field=None, val=None): """ Returns lorem ipsum text. If val is provided, the lorem ipsum text will be the same length as the original text, and with the same pattern of line breaks. """ if val == '': return '' if val is not None: ...
python
def lorem(self, field=None, val=None): """ Returns lorem ipsum text. If val is provided, the lorem ipsum text will be the same length as the original text, and with the same pattern of line breaks. """ if val == '': return '' if val is not None: ...
[ "def", "lorem", "(", "self", ",", "field", "=", "None", ",", "val", "=", "None", ")", ":", "if", "val", "==", "''", ":", "return", "''", "if", "val", "is", "not", "None", ":", "def", "generate", "(", "length", ")", ":", "# Get lorem ipsum of a specif...
Returns lorem ipsum text. If val is provided, the lorem ipsum text will be the same length as the original text, and with the same pattern of line breaks.
[ "Returns", "lorem", "ipsum", "text", ".", "If", "val", "is", "provided", "the", "lorem", "ipsum", "text", "will", "be", "the", "same", "length", "as", "the", "original", "text", "and", "with", "the", "same", "pattern", "of", "line", "breaks", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L152-L181
BetterWorks/django-anonymizer
anonymizer/base.py
DjangoFaker.unique_lorem
def unique_lorem(self, field=None, val=None): """ Returns lorem ipsum text guaranteed to be unique. First uses lorem function then adds a unique integer suffix. """ lorem_text = self.lorem(field, val) max_length = getattr(field, 'max_length', None) suffix_str = s...
python
def unique_lorem(self, field=None, val=None): """ Returns lorem ipsum text guaranteed to be unique. First uses lorem function then adds a unique integer suffix. """ lorem_text = self.lorem(field, val) max_length = getattr(field, 'max_length', None) suffix_str = s...
[ "def", "unique_lorem", "(", "self", ",", "field", "=", "None", ",", "val", "=", "None", ")", ":", "lorem_text", "=", "self", ".", "lorem", "(", "field", ",", "val", ")", "max_length", "=", "getattr", "(", "field", ",", "'max_length'", ",", "None", ")...
Returns lorem ipsum text guaranteed to be unique. First uses lorem function then adds a unique integer suffix.
[ "Returns", "lorem", "ipsum", "text", "guaranteed", "to", "be", "unique", ".", "First", "uses", "lorem", "function", "then", "adds", "a", "unique", "integer", "suffix", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L183-L197
BetterWorks/django-anonymizer
anonymizer/base.py
Anonymizer.alter_object
def alter_object(self, obj): """ Alters all the attributes in an individual object. If it returns False, the object will not be saved """ for attname, field, replacer in self.replacers: currentval = getattr(obj, attname) replacement = replacer(self, obj, ...
python
def alter_object(self, obj): """ Alters all the attributes in an individual object. If it returns False, the object will not be saved """ for attname, field, replacer in self.replacers: currentval = getattr(obj, attname) replacement = replacer(self, obj, ...
[ "def", "alter_object", "(", "self", ",", "obj", ")", ":", "for", "attname", ",", "field", ",", "replacer", "in", "self", ".", "replacers", ":", "currentval", "=", "getattr", "(", "obj", ",", "attname", ")", "replacement", "=", "replacer", "(", "self", ...
Alters all the attributes in an individual object. If it returns False, the object will not be saved
[ "Alters", "all", "the", "attributes", "in", "an", "individual", "object", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/base.py#L289-L298
BetterWorks/django-anonymizer
anonymizer/replacers.py
uuid
def uuid(anon, obj, field, val): """ Returns a random uuid string """ return anon.faker.uuid(field=field)
python
def uuid(anon, obj, field, val): """ Returns a random uuid string """ return anon.faker.uuid(field=field)
[ "def", "uuid", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "uuid", "(", "field", "=", "field", ")" ]
Returns a random uuid string
[ "Returns", "a", "random", "uuid", "string" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L4-L8
BetterWorks/django-anonymizer
anonymizer/replacers.py
varchar
def varchar(anon, obj, field, val): """ Returns random data for a varchar field. """ return anon.faker.varchar(field=field)
python
def varchar(anon, obj, field, val): """ Returns random data for a varchar field. """ return anon.faker.varchar(field=field)
[ "def", "varchar", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "varchar", "(", "field", "=", "field", ")" ]
Returns random data for a varchar field.
[ "Returns", "random", "data", "for", "a", "varchar", "field", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L11-L15
BetterWorks/django-anonymizer
anonymizer/replacers.py
bool
def bool(anon, obj, field, val): """ Returns a random boolean value (True/False) """ return anon.faker.bool(field=field)
python
def bool(anon, obj, field, val): """ Returns a random boolean value (True/False) """ return anon.faker.bool(field=field)
[ "def", "bool", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "bool", "(", "field", "=", "field", ")" ]
Returns a random boolean value (True/False)
[ "Returns", "a", "random", "boolean", "value", "(", "True", "/", "False", ")" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L18-L22
BetterWorks/django-anonymizer
anonymizer/replacers.py
integer
def integer(anon, obj, field, val): """ Returns a random integer (for a Django IntegerField) """ return anon.faker.integer(field=field)
python
def integer(anon, obj, field, val): """ Returns a random integer (for a Django IntegerField) """ return anon.faker.integer(field=field)
[ "def", "integer", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "integer", "(", "field", "=", "field", ")" ]
Returns a random integer (for a Django IntegerField)
[ "Returns", "a", "random", "integer", "(", "for", "a", "Django", "IntegerField", ")" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L25-L29
BetterWorks/django-anonymizer
anonymizer/replacers.py
positive_integer
def positive_integer(anon, obj, field, val): """ Returns a random positive integer (for a Django PositiveIntegerField) """ return anon.faker.positive_integer(field=field)
python
def positive_integer(anon, obj, field, val): """ Returns a random positive integer (for a Django PositiveIntegerField) """ return anon.faker.positive_integer(field=field)
[ "def", "positive_integer", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "positive_integer", "(", "field", "=", "field", ")" ]
Returns a random positive integer (for a Django PositiveIntegerField)
[ "Returns", "a", "random", "positive", "integer", "(", "for", "a", "Django", "PositiveIntegerField", ")" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L32-L36
BetterWorks/django-anonymizer
anonymizer/replacers.py
small_integer
def small_integer(anon, obj, field, val): """ Returns a random small integer (for a Django SmallIntegerField) """ return anon.faker.small_integer(field=field)
python
def small_integer(anon, obj, field, val): """ Returns a random small integer (for a Django SmallIntegerField) """ return anon.faker.small_integer(field=field)
[ "def", "small_integer", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "small_integer", "(", "field", "=", "field", ")" ]
Returns a random small integer (for a Django SmallIntegerField)
[ "Returns", "a", "random", "small", "integer", "(", "for", "a", "Django", "SmallIntegerField", ")" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L39-L43
BetterWorks/django-anonymizer
anonymizer/replacers.py
positive_small_integer
def positive_small_integer(anon, obj, field, val): """ Returns a positive small random integer (for a Django PositiveSmallIntegerField) """ return anon.faker.positive_small_integer(field=field)
python
def positive_small_integer(anon, obj, field, val): """ Returns a positive small random integer (for a Django PositiveSmallIntegerField) """ return anon.faker.positive_small_integer(field=field)
[ "def", "positive_small_integer", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "positive_small_integer", "(", "field", "=", "field", ")" ]
Returns a positive small random integer (for a Django PositiveSmallIntegerField)
[ "Returns", "a", "positive", "small", "random", "integer", "(", "for", "a", "Django", "PositiveSmallIntegerField", ")" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L46-L50
BetterWorks/django-anonymizer
anonymizer/replacers.py
datetime
def datetime(anon, obj, field, val): """ Returns a random datetime """ return anon.faker.datetime(field=field)
python
def datetime(anon, obj, field, val): """ Returns a random datetime """ return anon.faker.datetime(field=field)
[ "def", "datetime", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "datetime", "(", "field", "=", "field", ")" ]
Returns a random datetime
[ "Returns", "a", "random", "datetime" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L53-L57
BetterWorks/django-anonymizer
anonymizer/replacers.py
date
def date(anon, obj, field, val): """ Returns a random date """ return anon.faker.date(field=field)
python
def date(anon, obj, field, val): """ Returns a random date """ return anon.faker.date(field=field)
[ "def", "date", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "date", "(", "field", "=", "field", ")" ]
Returns a random date
[ "Returns", "a", "random", "date" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L60-L64
BetterWorks/django-anonymizer
anonymizer/replacers.py
decimal
def decimal(anon, obj, field, val): """ Returns a random decimal """ return anon.faker.decimal(field=field)
python
def decimal(anon, obj, field, val): """ Returns a random decimal """ return anon.faker.decimal(field=field)
[ "def", "decimal", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "decimal", "(", "field", "=", "field", ")" ]
Returns a random decimal
[ "Returns", "a", "random", "decimal" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L67-L71
BetterWorks/django-anonymizer
anonymizer/replacers.py
postcode
def postcode(anon, obj, field, val): """ Generates a random postcode (not necessarily valid, but it will look like one). """ return anon.faker.postcode(field=field)
python
def postcode(anon, obj, field, val): """ Generates a random postcode (not necessarily valid, but it will look like one). """ return anon.faker.postcode(field=field)
[ "def", "postcode", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "postcode", "(", "field", "=", "field", ")" ]
Generates a random postcode (not necessarily valid, but it will look like one).
[ "Generates", "a", "random", "postcode", "(", "not", "necessarily", "valid", "but", "it", "will", "look", "like", "one", ")", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L74-L78
BetterWorks/django-anonymizer
anonymizer/replacers.py
country
def country(anon, obj, field, val): """ Returns a randomly selected country. """ return anon.faker.country(field=field)
python
def country(anon, obj, field, val): """ Returns a randomly selected country. """ return anon.faker.country(field=field)
[ "def", "country", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "country", "(", "field", "=", "field", ")" ]
Returns a randomly selected country.
[ "Returns", "a", "randomly", "selected", "country", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L81-L85
BetterWorks/django-anonymizer
anonymizer/replacers.py
username
def username(anon, obj, field, val): """ Generates a random username """ return anon.faker.user_name(field=field)
python
def username(anon, obj, field, val): """ Generates a random username """ return anon.faker.user_name(field=field)
[ "def", "username", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "user_name", "(", "field", "=", "field", ")" ]
Generates a random username
[ "Generates", "a", "random", "username" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L88-L92
BetterWorks/django-anonymizer
anonymizer/replacers.py
first_name
def first_name(anon, obj, field, val): """ Returns a random first name """ return anon.faker.first_name(field=field)
python
def first_name(anon, obj, field, val): """ Returns a random first name """ return anon.faker.first_name(field=field)
[ "def", "first_name", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "first_name", "(", "field", "=", "field", ")" ]
Returns a random first name
[ "Returns", "a", "random", "first", "name" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L95-L99
BetterWorks/django-anonymizer
anonymizer/replacers.py
last_name
def last_name(anon, obj, field, val): """ Returns a random second name """ return anon.faker.last_name(field=field)
python
def last_name(anon, obj, field, val): """ Returns a random second name """ return anon.faker.last_name(field=field)
[ "def", "last_name", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "last_name", "(", "field", "=", "field", ")" ]
Returns a random second name
[ "Returns", "a", "random", "second", "name" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L102-L106
BetterWorks/django-anonymizer
anonymizer/replacers.py
name
def name(anon, obj, field, val): """ Generates a random full name (using first name and last name) """ return anon.faker.name(field=field)
python
def name(anon, obj, field, val): """ Generates a random full name (using first name and last name) """ return anon.faker.name(field=field)
[ "def", "name", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "name", "(", "field", "=", "field", ")" ]
Generates a random full name (using first name and last name)
[ "Generates", "a", "random", "full", "name", "(", "using", "first", "name", "and", "last", "name", ")" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L109-L113
BetterWorks/django-anonymizer
anonymizer/replacers.py
email
def email(anon, obj, field, val): """ Generates a random email address. """ return anon.faker.email(field=field)
python
def email(anon, obj, field, val): """ Generates a random email address. """ return anon.faker.email(field=field)
[ "def", "email", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "email", "(", "field", "=", "field", ")" ]
Generates a random email address.
[ "Generates", "a", "random", "email", "address", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L116-L120
BetterWorks/django-anonymizer
anonymizer/replacers.py
similar_email
def similar_email(anon, obj, field, val): """ Generate a random email address using the same domain. """ return val if 'betterworks.com' in val else '@'.join([anon.faker.user_name(field=field), val.split('@')[-1]])
python
def similar_email(anon, obj, field, val): """ Generate a random email address using the same domain. """ return val if 'betterworks.com' in val else '@'.join([anon.faker.user_name(field=field), val.split('@')[-1]])
[ "def", "similar_email", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "val", "if", "'betterworks.com'", "in", "val", "else", "'@'", ".", "join", "(", "[", "anon", ".", "faker", ".", "user_name", "(", "field", "=", "field", ")...
Generate a random email address using the same domain.
[ "Generate", "a", "random", "email", "address", "using", "the", "same", "domain", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L123-L127
BetterWorks/django-anonymizer
anonymizer/replacers.py
full_address
def full_address(anon, obj, field, val): """ Generates a random full address, using newline characters between the lines. Resembles a US address """ return anon.faker.address(field=field)
python
def full_address(anon, obj, field, val): """ Generates a random full address, using newline characters between the lines. Resembles a US address """ return anon.faker.address(field=field)
[ "def", "full_address", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "address", "(", "field", "=", "field", ")" ]
Generates a random full address, using newline characters between the lines. Resembles a US address
[ "Generates", "a", "random", "full", "address", "using", "newline", "characters", "between", "the", "lines", ".", "Resembles", "a", "US", "address" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L130-L135
BetterWorks/django-anonymizer
anonymizer/replacers.py
phonenumber
def phonenumber(anon, obj, field, val): """ Generates a random US-style phone number """ return anon.faker.phone_number(field=field)
python
def phonenumber(anon, obj, field, val): """ Generates a random US-style phone number """ return anon.faker.phone_number(field=field)
[ "def", "phonenumber", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "phone_number", "(", "field", "=", "field", ")" ]
Generates a random US-style phone number
[ "Generates", "a", "random", "US", "-", "style", "phone", "number" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L138-L142
BetterWorks/django-anonymizer
anonymizer/replacers.py
street_address
def street_address(anon, obj, field, val): """ Generates a random street address - the first line of a full address """ return anon.faker.street_address(field=field)
python
def street_address(anon, obj, field, val): """ Generates a random street address - the first line of a full address """ return anon.faker.street_address(field=field)
[ "def", "street_address", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "street_address", "(", "field", "=", "field", ")" ]
Generates a random street address - the first line of a full address
[ "Generates", "a", "random", "street", "address", "-", "the", "first", "line", "of", "a", "full", "address" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L145-L149
BetterWorks/django-anonymizer
anonymizer/replacers.py
city
def city(anon, obj, field, val): """ Generates a random city name. Resembles the name of US/UK city. """ return anon.faker.city(field=field)
python
def city(anon, obj, field, val): """ Generates a random city name. Resembles the name of US/UK city. """ return anon.faker.city(field=field)
[ "def", "city", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "city", "(", "field", "=", "field", ")" ]
Generates a random city name. Resembles the name of US/UK city.
[ "Generates", "a", "random", "city", "name", ".", "Resembles", "the", "name", "of", "US", "/", "UK", "city", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L152-L156
BetterWorks/django-anonymizer
anonymizer/replacers.py
state
def state(anon, obj, field, val): """ Returns a randomly selected US state code """ return anon.faker.state(field=field)
python
def state(anon, obj, field, val): """ Returns a randomly selected US state code """ return anon.faker.state(field=field)
[ "def", "state", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "state", "(", "field", "=", "field", ")" ]
Returns a randomly selected US state code
[ "Returns", "a", "randomly", "selected", "US", "state", "code" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L159-L163
BetterWorks/django-anonymizer
anonymizer/replacers.py
zip_code
def zip_code(anon, obj, field, val): """ Returns a randomly generated US zip code (not necessarily valid, but will look like one). """ return anon.faker.zipcode(field=field)
python
def zip_code(anon, obj, field, val): """ Returns a randomly generated US zip code (not necessarily valid, but will look like one). """ return anon.faker.zipcode(field=field)
[ "def", "zip_code", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "zipcode", "(", "field", "=", "field", ")" ]
Returns a randomly generated US zip code (not necessarily valid, but will look like one).
[ "Returns", "a", "randomly", "generated", "US", "zip", "code", "(", "not", "necessarily", "valid", "but", "will", "look", "like", "one", ")", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L166-L170
BetterWorks/django-anonymizer
anonymizer/replacers.py
company
def company(anon, obj, field, val): """ Generates a random company name """ return anon.faker.company(field=field)
python
def company(anon, obj, field, val): """ Generates a random company name """ return anon.faker.company(field=field)
[ "def", "company", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "company", "(", "field", "=", "field", ")" ]
Generates a random company name
[ "Generates", "a", "random", "company", "name" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L173-L177
BetterWorks/django-anonymizer
anonymizer/replacers.py
lorem
def lorem(anon, obj, field, val): """ Generates a paragraph of lorem ipsum text """ return ' '.join(anon.faker.sentences(field=field))
python
def lorem(anon, obj, field, val): """ Generates a paragraph of lorem ipsum text """ return ' '.join(anon.faker.sentences(field=field))
[ "def", "lorem", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "' '", ".", "join", "(", "anon", ".", "faker", ".", "sentences", "(", "field", "=", "field", ")", ")" ]
Generates a paragraph of lorem ipsum text
[ "Generates", "a", "paragraph", "of", "lorem", "ipsum", "text" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L180-L184
BetterWorks/django-anonymizer
anonymizer/replacers.py
unique_lorem
def unique_lorem(anon, obj, field, val): """ Generates a unique paragraph of lorem ipsum text """ return anon.faker.unique_lorem(field=field)
python
def unique_lorem(anon, obj, field, val): """ Generates a unique paragraph of lorem ipsum text """ return anon.faker.unique_lorem(field=field)
[ "def", "unique_lorem", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "unique_lorem", "(", "field", "=", "field", ")" ]
Generates a unique paragraph of lorem ipsum text
[ "Generates", "a", "unique", "paragraph", "of", "lorem", "ipsum", "text" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L187-L191
BetterWorks/django-anonymizer
anonymizer/replacers.py
similar_datetime
def similar_datetime(anon, obj, field, val): """ Returns a datetime that is within plus/minus two years of the original datetime """ return anon.faker.datetime(field=field, val=val)
python
def similar_datetime(anon, obj, field, val): """ Returns a datetime that is within plus/minus two years of the original datetime """ return anon.faker.datetime(field=field, val=val)
[ "def", "similar_datetime", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "datetime", "(", "field", "=", "field", ",", "val", "=", "val", ")" ]
Returns a datetime that is within plus/minus two years of the original datetime
[ "Returns", "a", "datetime", "that", "is", "within", "plus", "/", "minus", "two", "years", "of", "the", "original", "datetime" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L194-L198
BetterWorks/django-anonymizer
anonymizer/replacers.py
similar_date
def similar_date(anon, obj, field, val): """ Returns a date that is within plus/minus two years of the original date """ return anon.faker.date(field=field, val=val)
python
def similar_date(anon, obj, field, val): """ Returns a date that is within plus/minus two years of the original date """ return anon.faker.date(field=field, val=val)
[ "def", "similar_date", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "date", "(", "field", "=", "field", ",", "val", "=", "val", ")" ]
Returns a date that is within plus/minus two years of the original date
[ "Returns", "a", "date", "that", "is", "within", "plus", "/", "minus", "two", "years", "of", "the", "original", "date" ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L201-L205
BetterWorks/django-anonymizer
anonymizer/replacers.py
similar_lorem
def similar_lorem(anon, obj, field, val): """ Generates lorem ipsum text with the same length and same pattern of linebreaks as the original. If the original often takes a standard form (e.g. a single word 'yes' or 'no'), this could easily fail to hide the original data. """ return anon.faker.lo...
python
def similar_lorem(anon, obj, field, val): """ Generates lorem ipsum text with the same length and same pattern of linebreaks as the original. If the original often takes a standard form (e.g. a single word 'yes' or 'no'), this could easily fail to hide the original data. """ return anon.faker.lo...
[ "def", "similar_lorem", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "lorem", "(", "field", "=", "field", ",", "val", "=", "val", ")" ]
Generates lorem ipsum text with the same length and same pattern of linebreaks as the original. If the original often takes a standard form (e.g. a single word 'yes' or 'no'), this could easily fail to hide the original data.
[ "Generates", "lorem", "ipsum", "text", "with", "the", "same", "length", "and", "same", "pattern", "of", "linebreaks", "as", "the", "original", ".", "If", "the", "original", "often", "takes", "a", "standard", "form", "(", "e", ".", "g", ".", "a", "single"...
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L208-L214
BetterWorks/django-anonymizer
anonymizer/replacers.py
choice
def choice(anon, obj, field, val): """ Randomly chooses one of the choices set on the field. """ return anon.faker.choice(field=field)
python
def choice(anon, obj, field, val): """ Randomly chooses one of the choices set on the field. """ return anon.faker.choice(field=field)
[ "def", "choice", "(", "anon", ",", "obj", ",", "field", ",", "val", ")", ":", "return", "anon", ".", "faker", ".", "choice", "(", "field", "=", "field", ")" ]
Randomly chooses one of the choices set on the field.
[ "Randomly", "chooses", "one", "of", "the", "choices", "set", "on", "the", "field", "." ]
train
https://github.com/BetterWorks/django-anonymizer/blob/2d25bb6e8b5e4230c58031c4b6d10cc536669b3e/anonymizer/replacers.py#L217-L221
planetarypy/pvl
pvl/__init__.py
load
def load(stream, cls=PVLDecoder, strict=True, **kwargs): """Deserialize ``stream`` as a pvl module. :param stream: a ``.read()``-supporting file-like object containing a module. If ``stream`` is a string it will be treated as a filename :param cls: the decoder class used to deserialize the pvl mod...
python
def load(stream, cls=PVLDecoder, strict=True, **kwargs): """Deserialize ``stream`` as a pvl module. :param stream: a ``.read()``-supporting file-like object containing a module. If ``stream`` is a string it will be treated as a filename :param cls: the decoder class used to deserialize the pvl mod...
[ "def", "load", "(", "stream", ",", "cls", "=", "PVLDecoder", ",", "strict", "=", "True", ",", "*", "*", "kwargs", ")", ":", "decoder", "=", "__create_decoder", "(", "cls", ",", "strict", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "stream"...
Deserialize ``stream`` as a pvl module. :param stream: a ``.read()``-supporting file-like object containing a module. If ``stream`` is a string it will be treated as a filename :param cls: the decoder class used to deserialize the pvl module. You may use the default ``PVLDecoder`` class or pro...
[ "Deserialize", "stream", "as", "a", "pvl", "module", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/__init__.py#L82-L97
planetarypy/pvl
pvl/__init__.py
loads
def loads(data, cls=PVLDecoder, strict=True, **kwargs): """Deserialize ``data`` as a pvl module. :param data: a pvl module as a byte or unicode string :param cls: the decoder class used to deserialize the pvl module. You may use the default ``PVLDecoder`` class or provide a custom sublcass. :...
python
def loads(data, cls=PVLDecoder, strict=True, **kwargs): """Deserialize ``data`` as a pvl module. :param data: a pvl module as a byte or unicode string :param cls: the decoder class used to deserialize the pvl module. You may use the default ``PVLDecoder`` class or provide a custom sublcass. :...
[ "def", "loads", "(", "data", ",", "cls", "=", "PVLDecoder", ",", "strict", "=", "True", ",", "*", "*", "kwargs", ")", ":", "decoder", "=", "__create_decoder", "(", "cls", ",", "strict", ",", "*", "*", "kwargs", ")", "if", "not", "isinstance", "(", ...
Deserialize ``data`` as a pvl module. :param data: a pvl module as a byte or unicode string :param cls: the decoder class used to deserialize the pvl module. You may use the default ``PVLDecoder`` class or provide a custom sublcass. :param **kwargs: the keyword arguments to pass to the decoder cl...
[ "Deserialize", "data", "as", "a", "pvl", "module", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/__init__.py#L100-L113
planetarypy/pvl
pvl/__init__.py
dump
def dump(module, stream, cls=PVLEncoder, **kwargs): """Serialize ``module`` as a pvl module to the provided ``stream``. :param module: a ```PVLModule``` or ```dict``` like object to serialize :param stream: a ``.write()``-supporting file-like object to serialize the module to. If ``stream`` is a s...
python
def dump(module, stream, cls=PVLEncoder, **kwargs): """Serialize ``module`` as a pvl module to the provided ``stream``. :param module: a ```PVLModule``` or ```dict``` like object to serialize :param stream: a ``.write()``-supporting file-like object to serialize the module to. If ``stream`` is a s...
[ "def", "dump", "(", "module", ",", "stream", ",", "cls", "=", "PVLEncoder", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "stream", ",", "six", ".", "string_types", ")", ":", "with", "open", "(", "stream", ",", "'wb'", ")", "as", "fp"...
Serialize ``module`` as a pvl module to the provided ``stream``. :param module: a ```PVLModule``` or ```dict``` like object to serialize :param stream: a ``.write()``-supporting file-like object to serialize the module to. If ``stream`` is a string it will be treated as a filename :param cls: the...
[ "Serialize", "module", "as", "a", "pvl", "module", "to", "the", "provided", "stream", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/__init__.py#L116-L134
planetarypy/pvl
pvl/__init__.py
dumps
def dumps(module, cls=PVLEncoder, **kwargs): """Serialize ``module`` as a pvl module formated byte string. :param module: a ```PVLModule``` or ```dict``` like object to serialize :param cls: the encoder class used to serialize the pvl module. You may use the default ``PVLEncoder`` class or provide...
python
def dumps(module, cls=PVLEncoder, **kwargs): """Serialize ``module`` as a pvl module formated byte string. :param module: a ```PVLModule``` or ```dict``` like object to serialize :param cls: the encoder class used to serialize the pvl module. You may use the default ``PVLEncoder`` class or provide...
[ "def", "dumps", "(", "module", ",", "cls", "=", "PVLEncoder", ",", "*", "*", "kwargs", ")", ":", "stream", "=", "io", ".", "BytesIO", "(", ")", "cls", "(", "*", "*", "kwargs", ")", ".", "encode", "(", "module", ",", "stream", ")", "return", "stre...
Serialize ``module`` as a pvl module formated byte string. :param module: a ```PVLModule``` or ```dict``` like object to serialize :param cls: the encoder class used to serialize the pvl module. You may use the default ``PVLEncoder`` class or provided encoder formats such as the ```IsisCubeLab...
[ "Serialize", "module", "as", "a", "pvl", "module", "formated", "byte", "string", "." ]
train
https://github.com/planetarypy/pvl/blob/ed92b284c4208439b033d28c9c176534c0faac0e/pvl/__init__.py#L137-L153
pycampers/zproc
zproc/state/_type.py
_create_remote_dict_method
def _create_remote_dict_method(dict_method_name: str): """ Generates a method for the State class, that will call the "method_name" on the state (a ``dict``) stored on the server, and return the result. Glorified RPC. """ def remote_method(self, *args, **kwargs): return self._s_req...
python
def _create_remote_dict_method(dict_method_name: str): """ Generates a method for the State class, that will call the "method_name" on the state (a ``dict``) stored on the server, and return the result. Glorified RPC. """ def remote_method(self, *args, **kwargs): return self._s_req...
[ "def", "_create_remote_dict_method", "(", "dict_method_name", ":", "str", ")", ":", "def", "remote_method", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_s_request_reply", "(", "{", "Msgs", ".", "cmd", ":", "C...
Generates a method for the State class, that will call the "method_name" on the state (a ``dict``) stored on the server, and return the result. Glorified RPC.
[ "Generates", "a", "method", "for", "the", "State", "class", "that", "will", "call", "the", "method_name", "on", "the", "state", "(", "a", "dict", ")", "stored", "on", "the", "server", "and", "return", "the", "result", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/_type.py#L21-L41
pycampers/zproc
zproc/state/server.py
StateServer.run_dict_method
def run_dict_method(self, request): """Execute a method on the state ``dict`` and reply with the result.""" state_method_name, args, kwargs = ( request[Msgs.info], request[Msgs.args], request[Msgs.kwargs], ) # print(method_name, args, kwargs) w...
python
def run_dict_method(self, request): """Execute a method on the state ``dict`` and reply with the result.""" state_method_name, args, kwargs = ( request[Msgs.info], request[Msgs.args], request[Msgs.kwargs], ) # print(method_name, args, kwargs) w...
[ "def", "run_dict_method", "(", "self", ",", "request", ")", ":", "state_method_name", ",", "args", ",", "kwargs", "=", "(", "request", "[", "Msgs", ".", "info", "]", ",", "request", "[", "Msgs", ".", "args", "]", ",", "request", "[", "Msgs", ".", "kw...
Execute a method on the state ``dict`` and reply with the result.
[ "Execute", "a", "method", "on", "the", "state", "dict", "and", "reply", "with", "the", "result", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/server.py#L72-L81
pycampers/zproc
zproc/state/server.py
StateServer.run_fn_atomically
def run_fn_atomically(self, request): """Execute a function, atomically and reply with the result.""" fn = serializer.loads_fn(request[Msgs.info]) args, kwargs = request[Msgs.args], request[Msgs.kwargs] with self.mutate_safely(): self.reply(fn(self.state, *args, **kwargs))
python
def run_fn_atomically(self, request): """Execute a function, atomically and reply with the result.""" fn = serializer.loads_fn(request[Msgs.info]) args, kwargs = request[Msgs.args], request[Msgs.kwargs] with self.mutate_safely(): self.reply(fn(self.state, *args, **kwargs))
[ "def", "run_fn_atomically", "(", "self", ",", "request", ")", ":", "fn", "=", "serializer", ".", "loads_fn", "(", "request", "[", "Msgs", ".", "info", "]", ")", "args", ",", "kwargs", "=", "request", "[", "Msgs", ".", "args", "]", ",", "request", "["...
Execute a function, atomically and reply with the result.
[ "Execute", "a", "function", "atomically", "and", "reply", "with", "the", "result", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/server.py#L83-L88
pycampers/zproc
zproc/util.py
clean_process_tree
def clean_process_tree(*signal_handler_args): """Stop all Processes in the current Process tree, recursively.""" parent = psutil.Process() procs = parent.children(recursive=True) if procs: print(f"[ZProc] Cleaning up {parent.name()!r} ({os.getpid()})...") for p in procs: with suppre...
python
def clean_process_tree(*signal_handler_args): """Stop all Processes in the current Process tree, recursively.""" parent = psutil.Process() procs = parent.children(recursive=True) if procs: print(f"[ZProc] Cleaning up {parent.name()!r} ({os.getpid()})...") for p in procs: with suppre...
[ "def", "clean_process_tree", "(", "*", "signal_handler_args", ")", ":", "parent", "=", "psutil", ".", "Process", "(", ")", "procs", "=", "parent", ".", "children", "(", "recursive", "=", "True", ")", "if", "procs", ":", "print", "(", "f\"[ZProc] Cleaning up ...
Stop all Processes in the current Process tree, recursively.
[ "Stop", "all", "Processes", "in", "the", "current", "Process", "tree", "recursively", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/util.py#L109-L129