<commit_before>from __future__ import print_function, division, absolute_import

from doto.logger import log
from doto.d0_mixin import d0mixin

import requests


class Droplet(d0mixin, object):

    def __str__(self):
        return ("Droplet:%s") % (self.id)

    def __repr__(self):
        return ("Droplet:%s") % (self.id)

    def __init__(self, **kwds):
        self.__dict__.update(kwds)

    def update(self):
        # https://api.digitalocean.com/events/[event_id]/?
        # client_id=[your_client_id]&api_key=[your_api_key]

        data = self._request("/droplets/"+str(self.id))

        self.__dict__.update(**data['droplet'])

    def event_update(self):
        # https://api.digitalocean.com/events/[event_id]/?
        # client_id=[your_client_id]&api_key=[your_api_key]

        url = "/events/%s" % (str(self.event_id))
        data = self._request(url)
        log.debug("Updating Event")
        log.debug(data)

        data['event']['event_id'] = data['event']['id']
        data['event']['id'] = data['event']['droplet_id']

        self.__dict__.update(**data['event'])

    def percentage_update(self):
        """
        Convenience method to return the percentage of event completion
        """

        #needed to grab ip_address
        self.update()

        self.event_update()
        return self.percentage

    def rename(self,name=None):

        """
        This method renames the droplet to the specified name.

        :type name: str
        :param name: Name of the new droplet

        """

        # https://api.digitalocean.com/droplets/[droplet_id]/rename/?
        # client_id=[your_client_id]&api_key=[your_api_key]&name=[name]

        url = "/droplets/%s/rename" % (str(self.id))

        data = self._request(url,name=name)

        self.event_id = data['event_id']

        log.info("Renaming: %d To: %s Event: %d" % (self.id, name, self.event_id))
        self.update()

    def destroy(self, scrub_data=True):
        """
        This method destroys one of your droplets - this is irreversible.

        :type scrub_data: bool
        :param scrub_data: An optional bool which will strictly write 0s to your prior
        partition to ensure that all data is completely erased. True by default

        """<commit_msg>changing bool parameter to 1<commit_after>from __future__ import print_function, division, absolute_import

from doto.logger import log
from doto.d0_mixin import d0mixin

import requests


class Droplet(d0mixin, object):

    def __str__(self):
        return ("Droplet:%s") % (self.id)

    def __repr__(self):
        return ("Droplet:%s") % (self.id)

    def __init__(self, **kwds):
        self.__dict__.update(kwds)

    def update(self):
        # https://api.digitalocean.com/events/[event_id]/?
        # client_id=[your_client_id]&api_key=[your_api_key]

        data = self._request("/droplets/"+str(self.id))

        self.__dict__.update(**data['droplet'])

    def event_update(self):
        # https://api.digitalocean.com/events/[event_id]/?
        # client_id=[your_client_id]&api_key=[your_api_key]

        url = "/events/%s" % (str(self.event_id))
        data = self._request(url)
        log.debug("Updating Event")
        log.debug(data)

        data['event']['event_id'] = data['event']['id']
        data['event']['id'] = data['event']['droplet_id']

        self.__dict__.update(**data['event'])

    def percentage_update(self):
        """
        Convenience method to return the percentage of event completion
        """

        #needed to grab ip_address
        self.update()

        self.event_update()
        return self.percentage

    def rename(self,name=None):

        """
        This method renames the droplet to the specified name.

        :type name: str
        :param name: Name of the new droplet

        """

        # https://api.digitalocean.com/droplets/[droplet_id]/rename/?
        # client_id=[your_client_id]&api_key=[your_api_key]&name=[name]

        url = "/droplets/%s/rename" % (str(self.id))

        data = self._request(url,name=name)

        self.event_id = data['event_id']

        log.info("Renaming: %d To: %s Event: %d" % (self.id, name, self.event_id))
        self.update()

    def destroy(self, scrub_data=1):
        """
        This method destroys one of your droplets - this is irreversible.

        :type scrub_data: bool
        :param scrub_data: An optional bool which will strictly write 0s to your prior
        partition to ensure that all data is completely erased. True by default

        """
{'fraction_non_alphanumeric': 0.13353765323992994, 'fraction_numerical': 0.0021891418563922942, 'mean_word_length': 2.6118577075098814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1251366', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1382, 'n_words': 318}