How to use the pyravendb.tools.utils.Utils.string_to_datetime function in pyravendb

To help you get started, we’ve selected a few pyravendb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ravendb / ravendb-python-client / pyravendb / tools / utils.py View on Github external
entity.__class__ = object_type

            entity = Utils.initialize_object(document, object_type)

            if nested_object_types:
                for key in nested_object_types:
                    attr = getattr(entity, key)
                    if attr:
                        try:
                            if isinstance(attr, list):
                                nested_list = []
                                for attribute in attr:
                                    nested_list.append(Utils.initialize_object(attribute, nested_object_types[key]))
                                setattr(entity, key, nested_list)
                            elif nested_object_types[key] is datetime:
                                setattr(entity, key, Utils.string_to_datetime(attr))
                            elif nested_object_types[key] is timedelta:
                                setattr(entity, key, Utils.string_to_timedelta(attr))
                            else:
                                setattr(entity, key, Utils.initialize_object(attr, nested_object_types[key]))
                        except TypeError as e:
                            print(e)
                            pass

        if 'Id' in entity.__dict__:
            entity.Id = metadata.get('@id', None)
        return entity, metadata, original_metadata, original_document
github ravendb / ravendb-python-client / pyravendb / hilo / hilo_generator.py View on Github external
def get_next_range(self):
        hilo_command = NextHiLoCommand(self._tag, self._last_batch_size, self._last_range_at,
                                       self._identity_parts_separator, self._range.max_id)
        result = self._store.get_request_executor().execute(hilo_command)
        self._prefix = result["prefix"]
        self._server_tag = result["server_tag"]
        self._last_range_at = Utils.string_to_datetime(result["last_range_at"])
        self._last_batch_size = result["last_size"]
        self._range = RangeValue(result["low"], result["high"])
github ravendb / ravendb-python-client / pyravendb / subscriptions / data.py View on Github external
def __init__(self, query=None, change_vector_for_next_batch_starting_point=None, subscription_id=0,
                 subscription_name=None, last_time_server_made_progress_with_documents=None,
                 last_client_connection_time=None, disabled=False, **kwargs):
        self.query = query
        self.change_vector_for_next_batch_starting_point = change_vector_for_next_batch_starting_point
        self.subscription_id = subscription_id
        self.subscription_name = subscription_name
        if isinstance(last_time_server_made_progress_with_documents, str):
            last_time_server_made_progress_with_documents = Utils.string_to_datetime(
                last_time_server_made_progress_with_documents)
        self.last_time_server_made_progress_with_documents = last_time_server_made_progress_with_documents
        if isinstance(last_client_connection_time, str):
            last_client_connection_time = Utils.string_to_datetime(last_client_connection_time)
        self.last_client_connection_time = last_client_connection_time
        self.closed = disabled
        self.latest_change_vector_client_acknowledged = kwargs.get("LatestChangeVectorClientACKnowledged", None)
github ravendb / ravendb-python-client / pyravendb / subscriptions / data.py View on Github external
def __init__(self, query=None, change_vector_for_next_batch_starting_point=None, subscription_id=0,
                 subscription_name=None, last_time_server_made_progress_with_documents=None,
                 last_client_connection_time=None, disabled=False, **kwargs):
        self.query = query
        self.change_vector_for_next_batch_starting_point = change_vector_for_next_batch_starting_point
        self.subscription_id = subscription_id
        self.subscription_name = subscription_name
        if isinstance(last_time_server_made_progress_with_documents, str):
            last_time_server_made_progress_with_documents = Utils.string_to_datetime(
                last_time_server_made_progress_with_documents)
        self.last_time_server_made_progress_with_documents = last_time_server_made_progress_with_documents
        if isinstance(last_client_connection_time, str):
            last_client_connection_time = Utils.string_to_datetime(last_client_connection_time)
        self.last_client_connection_time = last_client_connection_time
        self.closed = disabled
        self.latest_change_vector_client_acknowledged = kwargs.get("LatestChangeVectorClientACKnowledged", None)