Beispiel #1
0
class RegisterForm(FlaskForm):
    register_email = StringField('email',
                                 validators=[
                                     InputRequired(),
                                     Email(message='Invalid email'),
                                     Length(max=30)
                                 ])
    register_password = PasswordField(
        'password', validators=[InputRequired(),
                                Length(min=1, max=100)])
    register_nom = StringField(
        'nom', validators=[InputRequired(),
                           Length(min=1, max=30)])
    register_prenom = StringField(
        'prenom', validators=[InputRequired(),
                              Length(min=1, max=30)])
    register_tags = SelectMultipleField('Tags', choices=Tags(TAGS))
    register_rue = StringField(
        'rue', validators=[InputRequired(),
                           Length(min=1, max=50)])
    register_cp = StringField(
        'cp', validators=[InputRequired(),
                          Length(min=5, max=5)])
    register_ville = StringField(
        'ville', validators=[InputRequired(),
                             Length(min=1, max=30)])
    register_submit = SubmitField('Valider')


###############################################################################
    def fit(self,
            data,
            class_name,
            categorial_name,
            multidimentionality=False):
        # X,y series
        self.categorial_name = categorial_name
        conjugate_matrix = ConjugateMatrix()
        conjugate_matrix.make(data, class_name, categorial_name)
        probability_matrix = ProbabilityMatrix()
        probability_matrix.make_form_cobjugate_matrix(conjugate_matrix)
        conjugate_matrix.get_D1()
        # conjugate_matrix = None

        D1 = probability_matrix.get_D1()
        D2 = probability_matrix.get_D2()
        D1_sqrt_ = fractional_matrix_power(D1, -0.5)
        D2_sqrt_ = fractional_matrix_power(D2, -0.5)
        PH = np.dot(np.dot(D1_sqrt_, probability_matrix.matrix), D2_sqrt_)
        T_1 = np.dot(PH.T, PH)
        # T_2 = np.dot(PH,PH.T)
        tags = Tags()
        tags.make(T_1, D2_sqrt_, multidimentionality)
        self.C = tags.tags
        return self
    def __init__(self, short_names=False, last_metric=None):
        """Initialize a new metrics object.

        Parameters
        ----------
        short_names : bool
                Toggle short object tags in output metrics.
        last_metric : Metrics object
                Metric object used for delta metric calculation.
        """
        self.t = Tags(short_names)
        # Header Information
        self._timestamp = int(time.time())
        if last_metric is None:
            self.interval = 0
        else:
            self.interval = self._timestamp - last_metric._timestamp

        # Network Metrics
        self._net_connections = []
        self.listening_tcp_ports = []
        self.listening_udp_ports = []

        # Network Stats By Interface
        self.total_counts = {}  # The raw values from the system
        self._interface_stats = {}  # The diff values, if delta metrics are used
        if last_metric is None:
            self._old_interface_stats = {}
        else:
            self._old_interface_stats = last_metric.total_counts

        self.max_list_size = 50
    def get_tags(self, installer_name):
        """get list of tags available for this installer."""
        if not installer_name:
            raise Installer_Exception(
                "What extension would you like to know the available revisions for?"
            )

        return Tags().gettags(installer_name)
Beispiel #5
0
def run():
    """main function
    """
    file_data = None
    filename = ""
    validation_msgs = ValidationMessages()
    tags = Tags()
    peeps = People(validation_msgs)
    fam = Families(peeps, validation_msgs)
    peeps.set_families(fam)

    if len(sys.argv) < 2:
        sys.exit("Usage: " + sys.argv[0] + " path-to-gedom-file")
    filename = sys.argv[1]

    try:
        file_data = open(filename)
    except IOError:
        sys.exit("ERROR: file " + sys.argv[1] + "was not found!")

    for line in file_data:
        try:
            data = tags.processline(line)
            if data["valid"] == "Y":
                fam.process_line_data(data)
                peeps.process_line_data(data)

        except TagsError as err:
            sys.exit("ERROR: ", err)

    fam.validate()
    peeps.validate()

    if validation_msgs.get_messages():
        print("Validation Messages")
        validation_msgs.print_all()
        print("")

    print("Individuals")
    peeps.print_all()
    peeps.us29_print_deceased()
    peeps.us31_print_single()
    peeps.us35_print_recent_births()
    peeps.us36_print_recent_deaths()
    peeps.us_38_print_upcoming_birthdays()
    print("")

    print("Families")
    fam.print_all()
    fam.us30_print_married()
    fam.us32_print_multiple_births()
    fam.us33_print_orphans()
    fam.us34_print_big_age_diff()
    fam.us_39_print_upcoming_anniversaries()
    print("")
Beispiel #6
0
 def test_all(self):
     with patch('tags.Synonyms.all') as synonyms,\
             patch('tags.Tags._get_page', autospec=True) as mocked_get,\
             open('test/fixture/tags1.json') as tags_page_1,\
             open('test/fixture/tags2.json') as tags_page_2:
         synonyms.return_value = [('py', 'python'),
                                  ('python-shell', 'python')]
         mocked_get.side_effect = lambda _self: json.load(tags_page_1) \
             if _self.page_nr == 1 else json.load(tags_page_2)
         tags = [tag for tag in Tags().all()]
         self.assertEqual(tags, self.expected_tags)
Beispiel #7
0
class TestTags(TestCase):
    tags = Tags(Tags.MP3_TAGGER_MODULE)

    def test_builder_returns_right_class(self):
        manager = Tags(Tags.MP3_TAGGER_MODULE)

        assert (type(manager.manager) == mp3_tagger_manager.Mp3TaggerManager)

    def test_cant_open_file_as_mp3(self):
        not_mp3_file_path = Path('./files/file.txt')

        with self.assertRaises(Exception):  # MP3OpenFileError
            self.tags.open_mp3_file(not_mp3_file_path)

    def test_can_open_file_as_mp3(self):
        mp3_file_source_path = Path('./files/jax-jones-years-years-play.mp3')

        assert self.tags.open_mp3_file(str(mp3_file_source_path))

    def test_return_right_mp3_tags(self):
        mock_file = Mock(artist='artist', song='song')

        tags = self.tags.read_tags(mock_file)

        self.assertEqual('artist', tags['artist'])
        self.assertEqual('song', tags['song'])

    def test_get_artist_and_song_from_not_valid_file_name(self):
        mock_file = MagicMock()
        mock_file.name = 'not_valid_name.txt'

        assert not self.tags.get_artist_and_song_from_file_name(mock_file)

    def test_get_artist_and_song_from_valid_file_name(self):
        mock_file = MagicMock()
        mock_file.name = 'artist_name-song_tittle.txt'

        tags = self.tags.get_artist_and_song_from_file_name(mock_file)

        assert len(tags) == 2
        assert tags['artist'] == 'artist name'
        assert tags['song'] == 'song tittle'

    def test_write_tags(self):
        mp3_file = Mock(artist='foo', song='bar')

        mp3_file = self.tags.write_artist_and_song_tags(
            mp3_file, {
                'artist': 'artist',
                'song': 'song'
            })

        assert mp3_file.artist == 'artist'
        assert mp3_file.song == 'song'
Beispiel #8
0
 def __init__(self,
              group,
              yt_key=None,
              delim="$",
              refresh_group_interval=600):
     """
     :param group: the group this object will read messages from
     :param yt_key: youtube api key. need it to use yt_search but not needed for other commands
     :param delim: the first character that will let the bot know it is a command. default is "$"
     """
     self.group = group
     self.delim = delim
     self.ult = Utilities(yt_key)
     self.tags = Tags(group.name, group.id, group.members)
     self.valid_commands = ["avatar", "git", "yt", "tag", "help"]
     Timer(refresh_group_interval, self.reload_group).start()
Beispiel #9
0
class GeneralForm(FlaskForm):
    add_dep=StringField('Adresse de départ :', validators=[DataRequired()])
    dep_home=BooleanField('Partir de votre domicile')
    add_arr=StringField('Adresse d\'arrivée :', validators=[DataRequired()])
    tags = SelectMultipleField('Tags', choices=Tags(TAGS))
    locomotion=RadioField('Locomotion :', choices=[('driving','Voiture'),('transit','Transports en commun'),('walking','A pied')])
    optimisation=RadioField('Optimisation :', choices=[('distance','Distance'),('time','Temps'),('affinity','Affinités')])
    h_dep=TimeField('Heure de départ :')
    j_dep=DateField('Jour de départ :')
    h_arr=TimeField('Heure d\'arrivée :')
    j_arr=DateField('Jour d\'arrivée :')
    max_escales=SelectField('Nombre d\'escales souhaité :', choices=[(0,0),(1,1),(2,2),(3,3),(4,4),(5,5)])
    escales=TextField('Escales :')
    t_max=RadioField('Durée maximale sans pause :', choices=[(0,'Sans pause'),(3600,'1h00'),(7200,'2h00'),(10800,'3h00')])
    d_max=RadioField('Distance maximale sans pause:', choices=[(0,'Sans pause'),(100000,'100km'),(20000,'200km'),(300000,'300km')])
    submit=SubmitField('Valider')
###############################################################################    
Beispiel #10
0
 def test_tagging_deletion(self):
     self.__moto_setup()
     s3_client = boto3.client('s3')
     # ek object upload karo
     source_objectname_value = '1.txt'
     source_objectname_value2 = '2.txt'
     s3_client.put_object(Bucket='shivam1052061', Key=source_objectname_value)
     s3_client.put_object(Bucket='shivam1052061', Key=source_objectname_value2)
     # tag dalo
     tagset_value = {'TagSet': [{'Key': 'notdivby2', 'Value': '2no'}]}
     t = Tags(parameter)
     t.tagging_insertion(source_objectname_value, tagset_value)
     # tag retrieve karo
     response = s3_client.get_object_tagging(
         Bucket=parameter['SourceBucketName'],
         Key=source_objectname_value
     )
     # delete karo
     output_to_be_checked = [tag for tag in response.get('TagSet')]
     # print(" last : \n")
     # print(output_to_be_checked)
     if output_to_be_checked == [{'Key': 'notdivby2', 'Value': '2no'}]:
         resp = s3_client.delete_object(
             Bucket=parameter["SourceBucketName"],
             Key=source_objectname_value
         )
         #  print("lol \n")
         # print(resp)
         # print(resp['ResponseMetadata']['HTTPStatusCode'])
         # self.assertEqual(resp['ResponseMetadata']['HTTPStatusCode'],204)
         # obect_count_in_the_bucket_before_deletion = 2
         object_count_in_the_bucket_after_deletion = 1
         s3_bucket_object_count = 0
         response = s3_client.list_objects_v2(Bucket='shivam1052061')
         if response:
             try:
                 for _object in response['Contents']:
                     s3_bucket_object_count = s3_bucket_object_count + 1
             except KeyError:
                 print("KeyError. No such key exists in the specified bucket")
         # print("object_count_in_the_bucket_after_deletion")
         # print(s3_bucket_object_count)
         # assertequals karo
         self.assertEqual(1, object_count_in_the_bucket_after_deletion)
Beispiel #11
0
def find_unique_tags(train_data_tags, null_label=False):

    unique_tags = Tags()

    for tags in train_data_tags:
        for tag, label in unfreeze_dict(tags).items():
            if not unique_tags.tagExists(tag):
                unique_tags.addTag(tag)

            curTag = unique_tags.getTagbyName(tag)

            if not curTag.labelExists(label):
                curTag.addLabel(label)

    # Add null labels to unseen tags in each tag set
    if null_label:
        for tag in unique_tags:
            tag.addLabel("NULL")

    return unique_tags
    def fit(self, X, multidimentionality=False):
        X = deepcopy(X)
        #         X - only caregorial
        self.columns = X.columns.values
        p = X.columns.values.shape[0]
        binary_matrix = BinaryMatrixData()
        binary_matrix = binary_matrix.make(X)
        D = binary_matrix.make_D()

        D_sqrt_ = fractional_matrix_power(D, -0.5)
        D = None
        F = np.dot(((1 / p ** 0.5) * binary_matrix.matrix), D_sqrt_)
        binary_matrix = None
        T_1 = np.dot(F.T, F)
        F = None
        tags = Tags()
        tags.make(T_1,D_sqrt_,multidimentionality)
        T_1 = None
        self.C = tags.tags
        return self
Beispiel #13
0
    def test_tagging_insertion(self):
        self.__moto_setup()
        s3_client = boto3.client('s3')
        source_objectname_value = '1.txt'
        s3_client.put_object(Bucket='shivam1052061', Key=source_objectname_value)
        tagset_value = {'TagSet': [{'Key': 'notdivby2', 'Value': '2no'},
                                   {'Key': 'key1', 'Value': 'val1'}]}
        t = Tags(parameter)

        t.tagging_insertion(source_objectname_value, tagset_value)
        s3_client = boto3.client('s3')
        response = s3_client.get_object_tagging(
            Bucket=parameter['SourceBucketName'],
            Key=source_objectname_value
        )
        # print("get object taggings")
        output_to_be_checked = [tag for tag in response.get('TagSet')]
        # print(output_to_be_checked)
        for b in output_to_be_checked:
            self.assertIn(b, output_to_be_checked)
    def __init__(self, client_id, short_names=False, last_metric=None):
        """Initialize a new metrics object

        Parameters
        ----------
        client_id : str
                Unique identifier for the device that emitted the metrics
        short_names : bool
                Toggle short object tags in output metrics.
        last_metric : Metrics object
                Metric object used for delta metric calculation.
        """
        self.t = Tags(short_names)
        # Header Information
        self.client_id = client_id
        self._timestamp = int(time.time())
        if last_metric is None:
            self.interval = 0
        else:
            self.interval = self._timestamp - last_metric._timestamp

        # Network Metrics
        self._net_connections = []
        self.listening_tcp_ports = []
        self.listening_udp_ports = []

        # PCR Metrics
        self.pcr_measurement = []

        # Network Stats By Interface
        self._interface_stats = {}
        if last_metric is None:
            self._old_interface_stats = {}
        else:
            self._old_interface_stats = last_metric._interface_stats

        self.max_list_size = 50
Beispiel #15
0
 def dialog_tag(self):
     dialog = Tags(self.BOT_URL, self.data)
Beispiel #16
0
import endpoint_config
import tkinter as tk
from tkinter import ttk
from datetime import datetime, timezone
import requests
from user import User
from gui import Window, WindowFrame, ButtonFrame, ProjectButtons
from client import Client
from projects import Projects
from tags import Tags

user = User()
workspaceId = user.workspaces[0]["id"]
clients = Client(workspaceId)
tags = Tags(workspaceId)
project_name_and_id = {}
payload = {}


def tag_select():
    tag_list = [tag_var.get()]
    payload['tagIds'] = tag_list


def clear_data():
    ticket.set("")
    scratch_pad.delete('1.0', tk.END)
    client_label['text'] = "Client: "
    project_name_and_id.clear()
    toggle_submit()
    tag_var.set(None)
Beispiel #17
0
 def tags(s):
     return Tags(s)
Beispiel #18
0
    def test_builder_returns_right_class(self):
        manager = Tags(Tags.MP3_TAGGER_MODULE)

        assert (type(manager.manager) == mp3_tagger_manager.Mp3TaggerManager)
Beispiel #19
0
def batches(batch_size=100):
    iter_all = iter(Tags().all())
    batch = list(itertools.islice(iter_all, batch_size))
    while batch:
        yield batch
        batch = list(itertools.islice(iter_all, batch_size))